Skip to content

Commit

Permalink
Fixed VEP dash in deletions
Browse files Browse the repository at this point in the history
  • Loading branch information
kantale committed Dec 7, 2016
1 parent d1fe9e9 commit eb0cfd9
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
3 changes: 2 additions & 1 deletion MutationInfo/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2046,8 +2046,9 @@ def _search_VEP(self, variant, vep_assembly='grch38'):

#In case of a deletion we need to make this correction in order to report the same position as in HGVS
#For example: rs113993960
if variant_alleles == '':
if variant_alleles in [u'', u'-']:
offset = v[0]['start']
variant_alleles = u'';
else:
offset = v[0]['end']

Expand Down
27 changes: 26 additions & 1 deletion test/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,30 @@

mi = MutationInfo()

def remove_notes(r):
return {k:v for k,v in r.iteritems() if k != 'notes'}

def which(program):
'''
Blatantly copied from http://stackoverflow.com/questions/377017/test-if-executable-exists-in-python
'''
import os
def is_exe(fpath):
return os.path.isfile(fpath) and os.access(fpath, os.X_OK)

fpath, fname = os.path.split(program)
if fpath:
if is_exe(program):
return program
else:
for path in os.environ["PATH"].split(os.pathsep):
path = path.strip('"')
exe_file = os.path.join(path, program)
if is_exe(exe_file):
return exe_file

return None

class TestMutationInfo(unittest.TestCase):

maxDiff = None
Expand Down Expand Up @@ -85,6 +109,7 @@ def test_VARIATION_REPORTER(self):
print ret
self.assertEqual(ret, {'chrom': '7', 'notes': 'Variation Reporter converted NM_017781.2:c.166C>T to NC_000007.13:g.1023013C>T', 'source': 'NC_transcript', 'genome': 'GRCh37.p13', 'offset': 1023013, 'alt': 'T', 'ref': 'C'})

@unittest.skipIf(not which('transvar'), "transvar is not installed. Skipping..")
def test_TRANSVAR(self):
print '--------TRANSVAR------------------------'

Expand Down Expand Up @@ -168,7 +193,7 @@ def test_GET_INFO_HGVS(self):

info = mi.get_info('NM_000367.2:c.-178C>T')
print info
self.assertEqual(info, {'chrom': '6', 'notes': '', 'source': 'counsyl_hgvs_to_vcf', 'genome': 'hg19', 'offset': 18155397, 'alt': 'A', 'ref': 'G'})
self.assertEqual(remove_notes(info), {'chrom': '6', 'source': 'counsyl_hgvs_to_vcf', 'genome': 'hg19', 'offset': 18155397, 'alt': 'A', 'ref': 'G'})

info = mi.get_info('NT_005120.15:c.IVS1-72T>G', gene='UGT1A1')
print info
Expand Down

0 comments on commit eb0cfd9

Please sign in to comment.