Skip to content

Commit

Permalink
fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
Kongkitimanon committed Jul 4, 2022
1 parent 82b7539 commit 2eb725d
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 27 deletions.
12 changes: 6 additions & 6 deletions src/covsonar/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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"]
)
Expand Down
9 changes: 0 additions & 9 deletions src/covsonar/dbm.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
16 changes: 8 additions & 8 deletions src/covsonar/sonar.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
Expand Down Expand Up @@ -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",
Expand All @@ -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",
Expand Down
7 changes: 3 additions & 4 deletions src/covsonar/sonardb.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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[:]
Expand Down Expand Up @@ -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):
"""
Expand Down

0 comments on commit 2eb725d

Please sign in to comment.