Skip to content

Commit

Permalink
Merge pull request #32 from martinghunt/store_variant_strand
Browse files Browse the repository at this point in the history
Store reverse or not in Variant class
  • Loading branch information
martinghunt authored Feb 28, 2019
2 parents 73b4e5b + acb9799 commit fd97bcc
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
4 changes: 2 additions & 2 deletions pymummer/tests/variant_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ def test_update_indel_no_change(self):

def test_update_indel_insertion(self):
'''Test update_indel extends insertions correctly'''
insertion = variant.Variant(snp.Snp('\t'.join(['42', '.', 'A', '100', 'x', 'x', '300', '400', 'x', '1', 'ref', 'qry'])))
to_add = snp.Snp('\t'.join(['42', '.', 'C', '101', 'x', 'x', '300', '400', 'x', '1', 'ref', 'qry']))
insertion = variant.Variant(snp.Snp('\t'.join(['42', '.', 'A', '100', 'x', 'x', '300', '400', 'x', '-1', 'ref', 'qry'])))
to_add = snp.Snp('\t'.join(['42', '.', 'C', '101', 'x', 'x', '300', '400', 'x', '-1', 'ref', 'qry']))
expected = copy.copy(insertion)
# coords stored zero-based, so subtract 1 from the real expected coords
expected.ref_start = 41
Expand Down
7 changes: 5 additions & 2 deletions pymummer/variant.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ def __init__(self, snp):
self.qry_end = snp.qry_pos
self.qry_length = snp.qry_length
self.qry_name = snp.qry_name
self.reverse = snp.reverse


def __eq__(self, other):
Expand All @@ -54,7 +55,8 @@ def __str__(self):
str(self.qry_end + 1),
str(self.qry_length),
str(self.qry_name),
self.qry_base
self.qry_base,
'-1' if self.reverse else '1',
])

def update_indel(self, nucmer_snp):
Expand All @@ -63,7 +65,8 @@ def update_indel(self, nucmer_snp):
if self.var_type not in [INS, DEL] \
or self.var_type != new_variant.var_type \
or self.qry_name != new_variant.qry_name \
or self.ref_name != new_variant.ref_name:
or self.ref_name != new_variant.ref_name \
or self.reverse != new_variant.reverse:
return False
if self.var_type == INS \
and self.ref_start == new_variant.ref_start \
Expand Down

0 comments on commit fd97bcc

Please sign in to comment.