diff --git a/src/covsonar/cache.py b/src/covsonar/cache.py index 6610fb9..476c357 100644 --- a/src/covsonar/cache.py +++ b/src/covsonar/cache.py @@ -375,9 +375,9 @@ def process_fasta_entry(self, header, seq): if not refmol: sys.exit( "input error: " - + record.id + + sample_id + " refers to an unknown reference molecule (" - + self._molregex.search(record.description) + + refmol + ")." ) seq = sonarBasics.harmonize(seq) @@ -412,10 +412,10 @@ def iter_fasta(self, *fnames): pbar.update(len(line)) line = line.strip() if line.startswith(">"): + header = line[1:] if seq: yield self.process_fasta_entry(header, "".join(seq)) seq = [] - header = line[1:] else: seq.append(line) if seq: @@ -593,9 +593,9 @@ def import_cached_samples(self): # noqa: C901 try: # nucleotide level import if not sample_data["seqhash"] is None: - sampleid = dbm.insert_sample( - sample_data["name"], sample_data["seqhash"] - ) + # sampleid = dbm.insert_sample( + # sample_data["name"], sample_data["seqhash"] + # ) algnid = dbm.insert_alignment( sample_data["seqhash"], sample_data["refmolid"] ) diff --git a/src/covsonar/dbm.py b/src/covsonar/dbm.py index c5134a6..e80e522 100644 --- a/src/covsonar/dbm.py +++ b/src/covsonar/dbm.py @@ -576,15 +576,6 @@ def get_alignment_data(self, sample_name, reference_accession=None): sql = 'SELECT "element.sequence", "element.symbol", "element.id" FROM alignmentView WHERE "sample.name" = ? AND "reference.accession" = ? ' return self.cursor.execute(sql, [sample_name, reference_accession]) - def get_alignment_id(self, seqhash, element_id): - sql = ( - 'SELECT id FROM alignment WHERE "element_id" = ? AND "seqhash" = ? LIMIT 1;' - ) - row = self.cursor.execute(sql, [element_id, seqhash]).fetchone() - if row: - return row["id"] - return None - def get_variant_id(self, element_id, start, end, ref, alt): sql = "SELECT id FROM variant WHERE element_id = ? AND start = ? AND end = ? AND ref = ? AND alt = ?;" row = self.cursor.execute(sql, [element_id, start, end, ref, alt]).fetchone() diff --git a/src/covsonar/sonar.py b/src/covsonar/sonar.py index 2b08e00..ec2770e 100644 --- a/src/covsonar/sonar.py +++ b/src/covsonar/sonar.py @@ -183,7 +183,7 @@ def parse_args(args): ) # view-prop parser - parser_viewprops = subparsers.add_parser( + subparsers.add_parser( "list-prop", parents=[general_parser], help="View sample properties added to the database.", @@ -271,12 +271,12 @@ def parse_args(args): ) # delete parser - parser_restore = subparsers.add_parser( + parser_delete = subparsers.add_parser( "delete", parents=[ref_parser, sample_parser, general_parser], help="delete one or more samples from the database.", ) - parser_restore.add_argument( + parser_delete.add_argument( "--aligned", help="ise aligned form (deletions indicated by - and insertions by lower-case letters)", action="store_true", @@ -295,27 +295,27 @@ def parse_args(args): ) # info parser - parser_info = subparsers.add_parser( + subparsers.add_parser( "info", parents=[general_parser], help="show software and database info" ) # optimize parser - parser_opt = subparsers.add_parser( + subparsers.add_parser( "optimize", parents=[general_parser], help="optimizes the database." ) # dev parser - parser_dev = subparsers.add_parser("dev", parents=[general_parser]) + subparsers.add_parser("dev", parents=[general_parser]) # db-upgrade parser - parser_opt = subparsers.add_parser( + subparsers.add_parser( "db-upgrade", parents=[general_parser], help="upgrade a database to the latest version", ) # update-lineage-info parser - parser_update_anno = subparsers.add_parser( + subparsers.add_parser( "update-lineage-info", parents=[general_parser], help="download latest lineage information", diff --git a/src/covsonar/sonardb.py b/src/covsonar/sonardb.py index 2e98419..91d2a56 100644 --- a/src/covsonar/sonardb.py +++ b/src/covsonar/sonardb.py @@ -750,7 +750,6 @@ def process_gff3(self, gff, fna): # noqa: C901 symbol_regex = re.compile("gene=([^;]+)(?:;|$)") locus_regex = re.compile("locus_tag=([^;]+)(?:;|$)") id_regex = re.compile("ID=([^;]+)(?:;|$)") - symbols = set() record = SeqIO.read(fna, "fasta") gseq = str(record.seq).upper() @@ -1761,7 +1760,7 @@ def import_genome_from_fasta_files( if dbm is None: dbm = stack.enter_context(sonarDBManager(self.db)) for i in tqdm( - range(len(fnames)), desc=msg, disable_progressbar=disable_progress + range(len(fnames)), desc=msg, disable_progressbar=disable_progressbar ): self.import_genome(**self.process_fasta(fnames[i]), dbm=dbm) @@ -2658,7 +2657,7 @@ def restore_alignment(self, acc, dbm=None): with ExitStack() as stack: if dbm is None: dbm = stack.enter_context(sonarDBManager(self.db, readonly=True)) - row = dbm.get_dna_vars(acc) + rows = dbm.get_dna_vars(acc) if rows: refseq = list(self.refseq) qryseq = refseq[:] @@ -2927,7 +2926,7 @@ def deslugify(string): @staticmethod def get_seqhash_from_fasta_name(fname): - return sonarCache.deslugify(os.path.basename(fname))[: -len(self._fasta_ext)] + return sonarCache.deslugify(os.path.basename(fname)) def iter_fasta(self, fname): """