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

Ignore additional columns in MLST profiles #152

Merged
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: 2 additions & 3 deletions ariba/mlst_profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ class MlstProfile:
def __init__(self, infile, duplicate_warnings=True):
self.infile = infile
self.duplicate_warnings = duplicate_warnings
self.columns_to_ignore = ['clonal_complex', 'CC', 'Lineage', 'mlst_clade', 'species']

if not os.path.exists(self.infile):
raise Error('Error! Input file "' + self.infile + '" not found.')
Expand All @@ -22,9 +23,7 @@ def _load_input_file(self):
if reader.fieldnames[0] != 'ST':
raise Error('Error. Expected first column of profile file "' + self.infile + '" to be "ST"')

self.genes_list = reader.fieldnames[1:]
if self.genes_list[-1] == 'clonal_complex':
self.genes_list.pop()
self.genes_list = [column_name for column_name in reader.fieldnames[1:] if column_name not in self.columns_to_ignore]

for row in reader:
type_tuple = tuple(int(row[x]) for x in self.genes_list)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
ST nusA rpoB eno gltB lepA nuoL nrdA clonal_complex CC Lineage mlst_clade species
1 1 26 2 2 59 8 1 1 CC10 II 123 Bacteria
2 1 26 2 4 59 2 5 2 CC10 II 123 Bacteria
13 changes: 13 additions & 0 deletions ariba/tests/mlst_profile_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,19 @@ def test_init(self):
(1, 26, 2, 4, 59, 2, 5): 2
}
self.assertEqual(expected_dict, profile.profile_to_type)

def test_init_multiple_extra_columns(self):
'''test init'''
infile = os.path.join(data_dir, 'mlst_profile_test.init_multiple_extra_columns.profile.tsv')
profile = mlst_profile.MlstProfile(infile)
expected_genes = ['nusA', 'rpoB', 'eno', 'gltB', 'lepA', 'nuoL', 'nrdA']
self.assertEqual(expected_genes, profile.genes_list)
self.assertEqual(set(expected_genes), profile.genes_set)
expected_dict = {
(1, 26, 2, 2, 59, 8, 1): 1,
(1, 26, 2, 4, 59, 2, 5): 2
}
self.assertEqual(expected_dict, profile.profile_to_type)


def test_has_gene(self):
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
setup(
ext_modules=[minimap_mod, fermilite_mod, vcfcall_mod],
name='ariba',
version='2.6.0',
version='2.6.1',
description='ARIBA: Antibiotic Resistance Identification By Assembly',
packages = find_packages(),
package_data={'ariba': ['test_run_data/*']},
Expand Down