rki-mf1 / covsonar

A database-driven system for handling genomic sequences of SARS-CoV-2 and screening genomic profiles.
GNU General Public License v3.0
6 stars 0 forks source link

build database fails due to non-unique entries in fasta #22

Closed silenus092 closed 2 years ago

silenus092 commented 2 years ago

In GitLab by @oliverdrechsel on Jan 6, 2022, 10:45

If covsonar hits non-unique ids in building database it fails. That's perfect. A helpful hint would be, if it would state the violating id.

Traceback (most recent call last):
  File "[...]sonar.py", line 430, in <module>
    snr.add(args.file, cachedir=args.cache, cpus=args.cpus, force=args.force, timeout=args.timeout, quiet=args.quiet, noprogress=args.noprogress, compressed=args.compressed, source=args.source, collection=args.collection, lab=args.lab
  File "[...]/tools/covsonar/sonar.py", line 242, in add
    self.db.import_genome_from_cache(cache.dirname, to_import, msg=msg, dbm=dbm, disable_progressbar=disable_progressbar)
  File "[...]/tools/covsonar/lib/sonardb.py", line 2239, in import_genome_from_cache
    self.import_genome(**preprocessed_data, seq=seq, dbm=dbm)
  File "[...]/tools/covsonar/lib/sonardb.py", line 2272, in import_genome
    dbm.insert_genome(acc, descr, seqhash)
  File "[...]/tools/covsonar/lib/sonardb.py", line 1308, in insert_genome
    self.cursor.execute(sql, [acc, descr, seqhash])
sqlite3.IntegrityError: UNIQUE constraint failed: genome.accession
silenus092 commented 2 years ago

In GitLab by @kunaphas.kon on Jan 11, 2022, 23:10

Hi @oliverdrechsel ,

Thank you for your report

If you don't mind, can you provide the command and related files to generate this error?🐛

Then, we can reproduce this error and enhance it properly.

Thanks

silenus092 commented 2 years ago

In GitLab by @kunaphas.kon on Jan 13, 2022, 14:20

Ok, thank you @oliverdrechsel

so next time if we get an error during the add command, it will report the error with the causal ID.

(Error while processing ID: {#ID}")

For example

Error while processing ID: 'XXX-negative-XXX-01'
# and  then follow with raising an exception as usual 
warning:
Traceback (most recent call last):
  File "/covsonar/lib/sonardb.py", line 2258, in import_genome_from_cache
    self.import_genome(**preprocessed_data, seq=seq, dbm=dbm)
  File "/covsonar/lib/sonardb.py", line 2307, in import_genome
    raise  er
  File "/covsonar/lib/sonardb.py", line 2292, in import_genome
    dbm.insert_genome(acc, descr, seqhash)
  File "/covsonar/lib/sonardb.py", line 1310, in insert_genome
    self.cursor.execute(sql, [acc, descr, seqhash])
sqlite3.IntegrityError: UNIQUE constraint failed: genome.accession

if this ok, I will put this update into the next covSonar update