diff --git a/pymummer/snp.py b/pymummer/snp.py index eafbd01..b967362 100644 --- a/pymummer/snp.py +++ b/pymummer/snp.py @@ -3,18 +3,23 @@ class Error (Exception): pass class Snp: def __init__(self, line): + # Without the -C option to show-snps, looks like this: #[P1] [SUB] [SUB] [P2] [BUFF] [DIST] [LEN R] [LEN Q] [FRM] [TAGS] #187 A C 269 187 187 654 853 1 1 ref_name qry_name + + # With the -C option to show-snps, looks like this: + #[P1] [SUB] [SUB] [P2] [BUFF] [DIST] [R] [Q] [LEN R] [LEN Q] [FRM] [TAGS] + #187 A C 269 187 187 0 0 654 853 1 1 ref_name qry_name try: l = line.rstrip().split('\t') self.ref_pos = int(l[0]) - 1 self.ref_base = l[1] self.qry_base = l[2] self.qry_pos = int(l[3]) - 1 - self.ref_length = int(l[6]) - self.qry_length = int(l[7]) - self.ref_name = l[10] - self.qry_name = l[11] + self.ref_length = int(l[-6]) + self.qry_length = int(l[-5]) + self.ref_name = l[-2] + self.qry_name = l[-1] except: raise Error('Error constructing pymummer.snp.Snp from mummer show-snps output at this line:\n' + line) diff --git a/pymummer/tests/snp_test.py b/pymummer/tests/snp_test.py index 8f15553..d5d54e9 100644 --- a/pymummer/tests/snp_test.py +++ b/pymummer/tests/snp_test.py @@ -8,10 +8,17 @@ class TestSnp(unittest.TestCase): - def test_str(self): - '''Test __str__''' + def test_str_no_c_option(self): + '''Test __str__ with format with no -C option''' l_in = ['187', 'A', 'C', '269', '187', '187', '654', '853', '1', '1', 'ref_name', 'qry_name'] - # only use columns 0-3, 6-7, 10-11 - l_out = l_in[:4] + l_in[6:8] + l_in[10:] s = snp.Snp('\t'.join(l_in)) - self.assertEqual(str(s), '\t'.join(l_out)) + expected = '\t'.join(['187', 'A', 'C', '269', '654', '853', 'ref_name', 'qry_name']) + self.assertEqual(str(s), expected) + + + def test_str_with_c_option(self): + '''Test __str__ with format with -C option''' + l_in = ['187', 'A', 'C', '269', '187', '187', '0', '0', '654', '853', '1', '1', 'ref_name', 'qry_name'] + s = snp.Snp('\t'.join(l_in)) + expected = '\t'.join(['187', 'A', 'C', '269', '654', '853', 'ref_name', 'qry_name']) + self.assertEqual(str(s), expected) diff --git a/setup.py b/setup.py index db64baf..2c6b48b 100644 --- a/setup.py +++ b/setup.py @@ -26,7 +26,7 @@ setup( name='pymummer', - version='0.10.0', + version='0.10.1', description='Wrapper for MUMmer', packages = find_packages(), author='Martin Hunt, Nishadi De Silva',