-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adjusted pytest to include the required folders in the pythonpath
- Loading branch information
1 parent
ce6999c
commit c65c9e4
Showing
15 changed files
with
76 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
Empty file.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,58 +1,61 @@ | ||
import importlib | ||
import unittest | ||
import os | ||
|
||
from pathlib import Path | ||
|
||
script_dir = Path(__file__).resolve().parent | ||
uniprot_dir = script_dir / '../../helpers/database-import-scripts/uniprot' | ||
uniprot_dir = uniprot_dir.resolve() | ||
|
||
preprocess_taxonomy = importlib.import_module("helpers.database-import-scripts.uniprot.preprocess_taxonomy_for_uniprot") | ||
parse_metadata =preprocess_taxonomy.parse_metadata | ||
match_taxid_to_gca = preprocess_taxonomy.match_taxid_to_gca | ||
get_species_level_taxonomy = preprocess_taxonomy.get_species_level_taxonomy | ||
from helpers.database_import_scripts.uniprot.preprocess_taxonomy_for_uniprot import ( | ||
get_species_level_taxonomy, | ||
match_taxid_to_gca, | ||
parse_metadata, | ||
) | ||
|
||
|
||
class TestPreprocessTaxonomyForUniprot(unittest.TestCase): | ||
def setUp(self): | ||
self.metadata_file = os.path.join(script_dir, "fixtures", "preprocess_taxonomy_for_uniprot", | ||
"sample_metadata.tsv") | ||
self.metadata_file = ( | ||
Path(__file__).resolve().parent | ||
/ "fixtures/preprocess_taxonomy_for_uniprot/sample_metadata.tsv" | ||
) | ||
self.gca_accessions, self.sample_accessions = parse_metadata(self.metadata_file) | ||
self.mgyg_to_gca, self.gca_to_taxid = match_taxid_to_gca(self.gca_accessions, self.sample_accessions, 2) | ||
self.mgyg_to_gca, self.gca_to_taxid = match_taxid_to_gca( | ||
self.gca_accessions, self.sample_accessions, 2 | ||
) | ||
|
||
def test_match_taxid_to_gca(self): | ||
expected_gca_to_taxid = {'GCA_946182765': '370804', | ||
'GCA_946182785': '244328', | ||
'GCA_946182825': '297314', | ||
'GCA_946182815': '370804', | ||
'GCA_946182805': '190764', | ||
'GCA_946182835': '370804', | ||
'GCA_946183145': '1678694', | ||
'GCA_946183335': '157472'} | ||
expected_mgyg_to_gca = {'MGYG000304400': 'GCA_946182765', | ||
'MGYG000304401': 'GCA_946182785', | ||
'MGYG000304403': 'GCA_946182825', | ||
'MGYG000304404': 'GCA_946182815', | ||
'MGYG000304405': 'GCA_946182805', | ||
'MGYG000304406': 'GCA_946182835', | ||
'MGYG000304407': 'GCA_946183145', | ||
'MGYG000304408': 'GCA_946183335'} | ||
expected_gca_to_taxid = { | ||
"GCA_946182765": "370804", | ||
"GCA_946182785": "244328", | ||
"GCA_946182825": "297314", | ||
"GCA_946182815": "370804", | ||
"GCA_946182805": "190764", | ||
"GCA_946182835": "370804", | ||
"GCA_946183145": "1678694", | ||
"GCA_946183335": "157472", | ||
} | ||
expected_mgyg_to_gca = { | ||
"MGYG000304400": "GCA_946182765", | ||
"MGYG000304401": "GCA_946182785", | ||
"MGYG000304403": "GCA_946182825", | ||
"MGYG000304404": "GCA_946182815", | ||
"MGYG000304405": "GCA_946182805", | ||
"MGYG000304406": "GCA_946182835", | ||
"MGYG000304407": "GCA_946183145", | ||
"MGYG000304408": "GCA_946183335", | ||
} | ||
self.assertEqual(self.mgyg_to_gca, expected_mgyg_to_gca) | ||
self.assertEqual(self.gca_to_taxid, expected_gca_to_taxid) | ||
|
||
def test_get_species_level_taxonomy(self): | ||
taxid1, name1, submittable1, lineage1 = get_species_level_taxonomy( | ||
"k__Bacteria;p__Bacillota_I;c__Bacilli_A;o__RFN20;f__CAG-826;g__UBA3207;s__UBA3207 sp946183335") | ||
self.assertEqual(lineage1, "d__Bacteria;p__Bacillota_I;c__Bacilli_A;o__RFN20;f__CAG-826;g__UBA3207;s__UBA3207 sp946183335") | ||
_, name1, submittable1, lineage1 = get_species_level_taxonomy( | ||
"k__Bacteria;p__Bacillota_I;c__Bacilli_A;o__RFN20;f__CAG-826;g__UBA3207;s__UBA3207 sp946183335" | ||
) | ||
self.assertEqual( | ||
lineage1, | ||
"d__Bacteria;p__Bacillota_I;c__Bacilli_A;o__RFN20;f__CAG-826;g__UBA3207;s__UBA3207 sp946183335", | ||
) | ||
self.assertEqual(submittable1, False) | ||
self.assertEqual(name1, "UBA3207 sp946183335") | ||
|
||
taxid2, name2, submittable2, lineage2 = get_species_level_taxonomy( | ||
"d__Bacteria; p__Pseudomonadota; c__Gammaproteobacteria; o__Enterobacterales; f__Enterobacteriaceae; g__Escherichia; s__Escherichia coli") | ||
|
||
taxid2, _, submittable2, _ = get_species_level_taxonomy( | ||
"d__Bacteria; p__Pseudomonadota; c__Gammaproteobacteria; o__Enterobacterales; f__Enterobacteriaceae; g__Escherichia; s__Escherichia coli" | ||
) | ||
self.assertEqual(submittable2, True) | ||
self.assertEqual(taxid2, '562') | ||
|
||
|
||
|
||
|
||
self.assertEqual(taxid2, "562") |