Skip to content

Commit

Permalink
Merge pull request #50 from martinghunt/bug_in_get_one_variant_for_on…
Browse files Browse the repository at this point in the history
…e_contig_coding

Bug in get one variant for one contig coding
  • Loading branch information
martinghunt committed Apr 8, 2016
2 parents b90737d + 295b938 commit 39f77ce
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
8 changes: 4 additions & 4 deletions ariba/assembly_variants.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,12 @@ def _get_mummer_variants(cls, snp_file):
def _get_variant_effect(cls, variants, ref_sequence):
'''variants = list of variants in the same codon.
returns type of variant (cannot handle more than one indel in the same codon).'''
if len(variants) == 0:
return None
assert len(variants) != 0

var_types = [x.var_type for x in variants]
if len(set(var_types)) != 1:
return None
print('More than one type of variant in the same codon not yet implemented!', ref_sequence.id, file=sys.stderr)
return 'MULTIPLE', '.', '.'

var_type = var_types[0]

Expand Down Expand Up @@ -306,7 +306,7 @@ def get_variants(self, ref_sequence_name, nucmer_coords):

# include new variant, except if the ref type is variants only and
# the new variant matches to a known variant
if new_variant is not None and (ref_sequence_type != 'variants_only' or len(new_variant[5]) > 0 or new_variant[3] == 'INDELS'):
if new_variant is not None and (ref_sequence_type != 'variants_only' or len(new_variant[5]) > 0 or new_variant[3] in ['MULTIPLE', 'INDELS']):
variants[contig].append(new_variant)
used_known_variants.update(used_variants)

Expand Down
2 changes: 1 addition & 1 deletion ariba/samtools_variants.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ def get_depths_at_position(self, seq_name, position):
if seq_name in d and position in d[seq_name]:
return d[seq_name][position]
else:
return None
return 'ND', 'ND', 'ND', 'ND'


def run(self):
Expand Down
4 changes: 2 additions & 2 deletions ariba/tests/samtools_variants_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,8 @@ def test_get_depths_at_position(self):
samtools_vars.run()
tests = [
(('ref', 425), ('C', 'T', 31, '18,13')),
(('not_a_ref', 10), None),
(('ref', 1000000000), None)
(('not_a_ref', 10), ('ND', 'ND', 'ND', 'ND')),
(('ref', 1000000000), ('ND', 'ND', 'ND', 'ND'))
]
for (ref, pos), expected in tests:
got = samtools_vars.get_depths_at_position(ref, pos)
Expand Down

0 comments on commit 39f77ce

Please sign in to comment.