Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

149 fix missing resistances #179

Merged
merged 3 commits into from
Aug 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions microSALT/utils/scraper.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,9 +257,9 @@ def scrape_blast(self, type="", file_list=[]):
].capitalize()
#Ignores reference name and finds relevant resFinder entry

padder = [x for x in locilengths.keys() if x.startswith('>{}'.format(partials[1]))]
padder = [x for x in locilengths.keys() if x.startswith('>{}_'.format(partials[1]))]
if len(padder) == 0:
padder = [x for x in locilengths.keys() if x.startswith('>{}'.format(partials[1][:-1]))]
padder = [x for x in locilengths.keys() if x.startswith('>{}_'.format(partials[1][:-1]))]
try:
padder = padder[0]
except IndexError as e:
Expand Down Expand Up @@ -438,6 +438,7 @@ def scrape_blast(self, type="", file_list=[]):
self.name, str(e)
)
)
return hypo

def load_resistances(self):
"""Legacy function, loads common resistance names for genes from notes file"""
Expand Down
5 changes: 3 additions & 2 deletions tests/test_scraper.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,9 @@ def test_blast_scraping(scraper, testdata_prefix, caplog):
scraper.scrape_blast(type='seq_type',file_list=["{}/blast_single_loci.txt".format(testdata_prefix)])
assert "candidate" in caplog.text
caplog.clear()
scraper.scrape_blast(type='resistance',file_list=["{}/blast_single_resistance.txt".format(testdata_prefix)])
assert "candidate" in caplog.text
hits = scraper.scrape_blast(type='resistance',file_list=["{}/blast_single_resistance.txt".format(testdata_prefix)])
samuell marked this conversation as resolved.
Show resolved Hide resolved
genes = [h["gene"] for h in hits]
assert "blaOXA-48" in genes

def test_alignment_scraping(scraper, init_references, testdata_prefix):
scraper.scrape_alignment(file_list=glob.glob("{}/*.stats.*".format(testdata_prefix)))
33 changes: 33 additions & 0 deletions tests/testdata/blast_single_resistance.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,36 @@ ant(6)-Ia_2_KF421157 plus NODE_32_length_3197_cov_303.662317 ant(6)-Ia_2_KF4211
# Database: /tmp/aminoglycoside
# 0 hits found
# BLAST processed 215 queries
# BLASTN 2.12.0+
# Query: NODE_65_length_2231_cov_99.410745
# Database: /tmp/beta-lactam
# Fields: subject title, subject strand, query acc.ver, subject acc.ver, % identity, evalue, bit score, q. start, q. end, s. start, s. end, alignment length
# 28 hits found
blaOXA-48_1_AY236073 minus NODE_65_length_2231_cov_99.410745 blaOXA-48_1_AY236073 100.000 0.0 1474 1409 2206 798 1 798
blaOXA-566_1_MF099636 minus NODE_65_length_2231_cov_99.410745 blaOXA-566_1_MF099636 99.875 0.0 1469 1409 2206 798 1 798
blaOXA-244_1_KP659189 minus NODE_65_length_2231_cov_99.410745 blaOXA-244_1_KP659189 99.875 0.0 1469 1409 2206 798 1 798
blaOXA-162_1_GU197550 minus NODE_65_length_2231_cov_99.410745 blaOXA-162_1_GU197550 99.875 0.0 1469 1409 2206 798 1 798
blaOXA-519_1_KX349732 minus NODE_65_length_2231_cov_99.410745 blaOXA-519_1_KX349732 99.875 0.0 1469 1409 2206 798 1 798
blaOXA-505_1_KU531433 minus NODE_65_length_2231_cov_99.410745 blaOXA-505_1_KU531433 99.875 0.0 1469 1409 2206 798 1 798
blaOXA-245_1_JX438001 minus NODE_65_length_2231_cov_99.410745 blaOXA-245_1_JX438001 99.749 0.0 1463 1409 2206 798 1 798
blaOXA-370_1_KJ488943 minus NODE_65_length_2231_cov_99.410745 blaOXA-370_1_KJ488943 99.624 0.0 1458 1409 2206 798 1 798
blaOXA-199_1_JN704570 minus NODE_65_length_2231_cov_99.410745 blaOXA-199_1_JN704570 99.373 0.0 1447 1409 2206 798 1 798
blaOXA-252_1_NG_050608 minus NODE_65_length_2231_cov_99.410745 blaOXA-252_1_NG_050608 99.248 0.0 1441 1409 2206 798 1 798
blaOXA-515_1_KU866383 minus NODE_65_length_2231_cov_99.410745 blaOXA-515_1_KU866383 99.248 0.0 1441 1409 2206 798 1 798
blaOXA-517_1_KU878974 minus NODE_65_length_2231_cov_99.410745 blaOXA-517_1_KU878974 99.248 0.0 1435 1409 2206 792 1 798
blaOXA-204_1_KP027885 minus NODE_65_length_2231_cov_99.410745 blaOXA-204_1_KP027885 98.997 0.0 1430 1409 2206 798 1 798
blaOXA-546_1_KY682756 minus NODE_65_length_2231_cov_99.410745 blaOXA-546_1_KY682756 98.872 0.0 1424 1409 2206 798 1 798
blaOXA-547_1_KY684124 minus NODE_65_length_2231_cov_99.410745 blaOXA-547_1_KY684124 98.622 0.0 1413 1409 2206 798 1 798
blaOXA-438_1_KP410734 minus NODE_65_length_2231_cov_99.410745 blaOXA-438_1_KP410734 98.747 0.0 1413 1409 2206 792 1 798
blaOXA-405_1_KM589641 minus NODE_65_length_2231_cov_99.410745 blaOXA-405_1_KM589641 98.496 0.0 1397 1409 2206 786 1 798
blaOXA-247_1_JX893517 minus NODE_65_length_2231_cov_99.410745 blaOXA-247_1_JX893517 98.371 0.0 1391 1409 2206 786 1 798
blaOXA-163_1_HQ700343 minus NODE_65_length_2231_cov_99.410745 blaOXA-163_1_HQ700343 98.371 0.0 1391 1409 2206 786 1 798
blaOXA-439_1_KP727573 minus NODE_65_length_2231_cov_99.410745 blaOXA-439_1_KP727573 98.246 0.0 1386 1409 2206 786 1 798
blaOXA-514_1_KU866382 minus NODE_65_length_2231_cov_99.410745 blaOXA-514_1_KU866382 97.870 0.0 1380 1409 2206 798 1 798
blaOXA-538_1_KX827284 minus NODE_65_length_2231_cov_99.410745 blaOXA-538_1_KX827284 97.750 0.0 1375 1409 2206 798 1 800
blaOXA-416_1_KP264119 minus NODE_65_length_2231_cov_99.410745 blaOXA-416_1_KP264119 96.992 0.0 1341 1409 2206 798 1 798
blaOXA-181_1_CM004561 minus NODE_65_length_2231_cov_99.410745 blaOXA-181_1_CM004561 94.493 0.0 1230 1409 2206 798 1 799
blaOXA-232_1_JX423831 minus NODE_65_length_2231_cov_99.410745 blaOXA-232_1_JX423831 94.368 0.0 1225 1409 2206 798 1 799
blaOXA-484_1_KR401105 minus NODE_65_length_2231_cov_99.410745 blaOXA-484_1_KR401105 94.368 0.0 1225 1409 2206 798 1 799
blaOXA-535_1_KX828709 minus NODE_65_length_2231_cov_99.410745 blaOXA-535_1_KX828709 84.856 0.0 804 1409 2206 798 1 799
blaOXA-436_1_KT959105 minus NODE_65_length_2231_cov_99.410745 blaOXA-436_1_KT959105 84.481 0.0 787 1409 2206 798 1 799
Loading