Skip to content

Commit

Permalink
Merge pull request #25 from martinghunt/indels_bug
Browse files Browse the repository at this point in the history
Indels bug
  • Loading branch information
martinghunt authored Nov 18, 2016
2 parents 53ee96e + 3256ad8 commit f9e01c5
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 10 deletions.
13 changes: 9 additions & 4 deletions pymummer/snp.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
17 changes: 12 additions & 5 deletions pymummer/tests/snp_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down

0 comments on commit f9e01c5

Please sign in to comment.