diff --git a/tests/unit/test_algorithm.py b/tests/unit/test_algorithm.py index 044c4a6..52967a7 100644 --- a/tests/unit/test_algorithm.py +++ b/tests/unit/test_algorithm.py @@ -9,7 +9,6 @@ soft_species_probability, hard_species_probability, threshold_assignment_probability, - iter_threshold, ) from unassigner.alignment import AlignedPair diff --git a/tests/unit/test_aligned.py b/tests/unit/test_aligned.py index 87d64f8..0f391b5 100644 --- a/tests/unit/test_aligned.py +++ b/tests/unit/test_aligned.py @@ -53,17 +53,17 @@ def test_region_subject_to_query_no_endgaps(self): r = AlignedRegion.from_subject(a, 0, 3) self.assertEqual(r.in_alignment(), (0, 3)) rq = AlignedRegion.from_query(a, 0, 3) - self.assertEqual(r.in_alignment(), (0, 3)) + self.assertEqual(rq.in_alignment(), (0, 3)) r = AlignedRegion.from_subject(a, 1, 5) self.assertEqual(r.in_alignment(), (1, 5)) rq = AlignedRegion.from_query(a, 1, 5) - self.assertEqual(r.in_alignment(), (1, 5)) + self.assertEqual(rq.in_alignment(), (1, 5)) r = AlignedRegion.from_subject(a) self.assertEqual(r.in_alignment(), (0, 6)) rq = AlignedRegion.from_query(a) - self.assertEqual(r.in_alignment(), (0, 6)) + self.assertEqual(rq.in_alignment(), (0, 6)) def test_region_subject_to_query_with_endgaps(self): a = AlignedPair(("a", "--ABC-EF---"), ("b", "HIJKLMNOPQR")) diff --git a/tests/unit/test_mismatch_db.py b/tests/unit/test_mismatch_db.py index a5d1e99..dd0c8f1 100644 --- a/tests/unit/test_mismatch_db.py +++ b/tests/unit/test_mismatch_db.py @@ -1,4 +1,3 @@ -import collections import os import io import tempfile @@ -8,7 +7,6 @@ MismatchLocationApp, main, group_by_n, - MutableMismatchDb, ) DATA_DIR = os.path.join(os.path.dirname(os.path.realpath(__file__)), "data") diff --git a/tests/unit/test_parse.py b/tests/unit/test_parse.py index fe5712b..57a0050 100644 --- a/tests/unit/test_parse.py +++ b/tests/unit/test_parse.py @@ -1,6 +1,7 @@ import tempfile import unittest + from unassigner.parse import parse_fasta, parse_results, load_fasta, write_fasta diff --git a/tests/unit/test_trim.py b/tests/unit/test_trim.py index 60c0944..2a241f8 100644 --- a/tests/unit/test_trim.py +++ b/tests/unit/test_trim.py @@ -153,7 +153,7 @@ def test_alignment_match_subj_left(self): ) m = AlignmentMatcher(self.test_dir) alignment_matches = list(m.find_in_seqs(s)) - match_id, matchobj = alignment_matches[0] + _, matchobj = alignment_matches[0] self.assertEqual(matchobj.start, 0) self.assertEqual(matchobj.end, 3) @@ -167,7 +167,7 @@ def test_alignment_match_middle(self): ) m = AlignmentMatcher(self.test_dir) alignment_matches = list(m.find_in_seqs(s)) - match_id, matchobj = alignment_matches[0] + _, matchobj = alignment_matches[0] self.assertEqual((matchobj.start, matchobj.end), (7, 12)) def test_alignment_match_middle_gaps(self): @@ -180,7 +180,7 @@ def test_alignment_match_middle_gaps(self): ) m = AlignmentMatcher(self.test_dir) alignment_matches = list(m.find_in_seqs(s)) - match_id, matchobj = alignment_matches[0] + _, matchobj = alignment_matches[0] self.assertEqual((matchobj.start, matchobj.end), (7, 11)) def test_trim_right(self): diff --git a/unassigner/algorithm.py b/unassigner/algorithm.py index d42a807..f5bdea9 100644 --- a/unassigner/algorithm.py +++ b/unassigner/algorithm.py @@ -78,7 +78,7 @@ def load_database(cls, f): line = line.rstrip() toks = line.split("\t") typestrain_id = toks[0] - ref_seq_id = toks[1] + # ref_seq_id = toks[1] mismatch_positions = [int(x) for x in toks[2:]] cls.db[typestrain_id].append(mismatch_positions) diff --git a/unassigner/align.py b/unassigner/align.py index b2270d3..29502da 100644 --- a/unassigner/align.py +++ b/unassigner/align.py @@ -4,7 +4,7 @@ import tempfile from Bio import pairwise2 -from unassigner.parse import write_fasta, load_fasta, parse_fasta +from unassigner.parse import write_fasta, parse_fasta from unassigner.alignment import AlignedPair BLAST_FMT = ( diff --git a/unassigner/alignment.py b/unassigner/alignment.py index b1bec09..e8d1222 100644 --- a/unassigner/alignment.py +++ b/unassigner/alignment.py @@ -1,5 +1,4 @@ import itertools -import operator class AlignedPair(object): diff --git a/unassigner/mismatch_db.py b/unassigner/mismatch_db.py index e46023f..e3762be 100644 --- a/unassigner/mismatch_db.py +++ b/unassigner/mismatch_db.py @@ -6,7 +6,6 @@ import collections import itertools import operator -import sys import tempfile from unassigner.parse import parse_fasta, write_fasta diff --git a/unassigner/parse.py b/unassigner/parse.py index 60fbeba..fb6a931 100644 --- a/unassigner/parse.py +++ b/unassigner/parse.py @@ -1,10 +1,9 @@ import logging -import re from io import StringIO def parse_species_names(f): - for desc, seq in parse_fasta(f): + for desc, _ in parse_fasta(f): vals = desc.split("\t", maxsplit=1) accession = vals[0] if len(vals) == 2: @@ -62,7 +61,7 @@ def parse_desc(desc): # This is the old way of parsing the description, 01_2022 # accession = re.findall(r"\[accession=(.*?)\]", desc)[0] # species_name = re.findall(r"\[organism=(.*?)\]", desc)[0] - except IndexError as e: + except IndexError: logging.error(f"Couldn't find accession and/or organism identifier in {desc}") logging.error(f"Skipping this sequence...") return None, None diff --git a/unassigner/prepare_strain_data.py b/unassigner/prepare_strain_data.py index 3e3246e..5a65826 100755 --- a/unassigner/prepare_strain_data.py +++ b/unassigner/prepare_strain_data.py @@ -77,7 +77,7 @@ def main(argv=None): clean(db_dir) sys.exit(0) - ltp_metadata_fp = use_or_download(args.ltp_metadata_fp, LTP_METADATA_URL, db_dir) + use_or_download(args.ltp_metadata_fp, LTP_METADATA_URL, db_dir) ltp_seqs_fp = use_or_download(args.ltp_seqs_fp, LTP_SEQS_URL, db_dir) process_ltp_seqs(ltp_seqs_fp, db_dir) diff --git a/unassigner/trim.py b/unassigner/trim.py index af77051..e787dd2 100644 --- a/unassigner/trim.py +++ b/unassigner/trim.py @@ -140,7 +140,7 @@ def find_match(self, seq): else: msg = "Complete, {0} mismatches".format(n_mismatches) end_idx = start_idx + len(query) - obs_primer = seq[start_idx:end_idx] + # obs_primer = seq[start_idx:end_idx] return PrimerMatch(start_idx, end_idx, 0, msg) diff --git a/unassigner/unassignment_probability.py b/unassigner/unassignment_probability.py index bde4cf5..33c36ad 100644 --- a/unassigner/unassignment_probability.py +++ b/unassigner/unassignment_probability.py @@ -5,7 +5,7 @@ def species_probability(self, species_alignment, refseq_alignments): start = species_alignment.start_pos end = species_alignment.end_pos for r in refseq_alignments: - refseq_id = r.subject_id + # refseq_id = r.subject_id a, b = r.count_matches(start, end) c, d = r.count_matches() yield query_id, species_id, a, b, r.subject_id, c, d