1
$\begingroup$

In HGVS package, how to create more complex variants ?

I just wonder how can I parse more complex insertions such as those :

NM_004006.2:c.940_941ins[903_940inv;851_885inv]

NC_000006.11:g.8897754_8897755ins[(543);8897743_8897754]

NC_000006.11:g.10791926_10791927ins[NC_000004.11:g.106370094_106370420;A[26]]

(All taken from the varnomen website)

When I tried I got parsing errors (mainly because of the brackets that represent the inserted sequences)

Whole traceback :

In [6]: var_g = hp.parse_hgvs_variant('NM_004006.2:c.940_941ins[903_940inv;851_885inv]')
---------------------------------------------------------------------------
ParseError                                Traceback (most recent call last)
~/playground/python/hgvs/venv/lib/python3.9/site-packages/hgvs/parser.py in rule_fxn(s)
    129                 try:
--> 130                     return self._grammar(s).__getattr__(rule_name)()
    131                 except ometa.runtime.ParseError as exc:

~/playground/python/hgvs/venv/lib/python3.9/site-packages/parsley.py in invokeRule(*args, **kwargs)
     97                                      [["message", "expected EOF"]], err.trail)
---> 98             raise err
     99         return invokeRule

~/playground/python/hgvs/venv/lib/python3.9/site-packages/ometa/runtime.py in _or(self, fns)
    597                 m = self.input
--> 598                 ret, err = f()
    599                 errors.append(err)

/pymeta_generated_code/pymeta_grammar__Grammar.py in _G_or_212()
    803                 self._trace('| dna_in', (5502, 5510), self.input.position)
--> 804                 _G_apply_213, lastError = self._apply(self.rule_dna_ins, "dna_ins", [])
    805                 self.considerError(lastError, None)

~/playground/python/hgvs/venv/lib/python3.9/site-packages/ometa/runtime.py in _apply(self, rule, ruleName, args)
    494                 memoRec = self.input.setMemo(ruleName,
--> 495                                          [rule(), self.input])
    496             except ParseError as e:

/pymeta_generated_code/pymeta_grammar__Grammar.py in rule_dna_ins(self)
    980                 return (_G_many1_275, self.currentError)
--> 981             _G_consumedby_276, lastError = self.consumedby(_G_consumedby_272)
    982             self.considerError(lastError, 'dna_ins')

~/playground/python/hgvs/venv/lib/python3.9/site-packages/ometa/runtime.py in consumedby(self, expr)
    675         oldInput = self.input
--> 676         _, e = expr()
    677         slice = oldInput.data[oldInput.position:self.input.position]

/pymeta_generated_code/pymeta_grammar__Grammar.py in _G_consumedby_272()
    977                     return (_G_apply_274, self.currentError)
--> 978                 _G_many1_275, lastError = self.many(_G_many1_273, _G_many1_273())
    979                 self.considerError(lastError, None)

/pymeta_generated_code/pymeta_grammar__Grammar.py in _G_many1_273()
    974                     self._trace('<dn', (5909, 5912), self.input.position)
--> 975                     _G_apply_274, lastError = self._apply(self.rule_dna, "dna", [])
    976                     self.considerError(lastError, None)

~/playground/python/hgvs/venv/lib/python3.9/site-packages/ometa/runtime.py in _apply(self, rule, ruleName, args)
    494                 memoRec = self.input.setMemo(ruleName,
--> 495                                          [rule(), self.input])
    496             except ParseError as e:

/pymeta_generated_code/pymeta_grammar__Grammar.py in rule_dna(self)
   2667             self._trace('= dna_iupa', (11894, 11904), self.input.position)
-> 2668             _G_apply_809, lastError = self._apply(self.rule_dna_iupac, "dna_iupac", [])
   2669             self.considerError(lastError, 'dna')

~/playground/python/hgvs/venv/lib/python3.9/site-packages/ometa/runtime.py in _apply(self, rule, ruleName, args)
    494                 memoRec = self.input.setMemo(ruleName,
--> 495                                          [rule(), self.input])
    496             except ParseError as e:

/pymeta_generated_code/pymeta_grammar__Grammar.py in rule_dna_iupac(self)
   2682                 return (_G_python_813, self.currentError)
-> 2683             _G_pred_814, lastError = self.pred(_G_pred_811)
   2684             self.considerError(lastError, 'dna_iupac')

~/playground/python/hgvs/venv/lib/python3.9/site-packages/ometa/runtime.py in pred(self, expr)
    648         if not val:
--> 649             raise e
    650         else:

ParseError: 
NM_004006.2:c.940_941ins[903_940inv;851_885inv]
                        ^
Parse error at line 1, column 24: Syntax error. trail: [dna_iupac dna dna_ins dna_edit c_posedit c_variant hgvs_variant]


During handling of the above exception, another exception occurred:

HGVSParseError                            Traceback (most recent call last)
<ipython-input-6-9d483e266162> in <module>
----> 1 var_g = hp.parse_hgvs_variant('NM_004006.2:c.940_941ins[903_940inv;851_885inv]')

~/playground/python/hgvs/venv/lib/python3.9/site-packages/hgvs/parser.py in rule_fxn(s)
    130                     return self._grammar(s).__getattr__(rule_name)()
    131                 except ometa.runtime.ParseError as exc:
--> 132                     raise HGVSParseError("{s}: char {exc.position}: {reason}".format(
    133                         s=s, exc=exc, reason=exc.formatReason()))
    134 

HGVSParseError: NM_004006.2:c.940_941ins[903_940inv;851_885inv]: char 24: Syntax error
$\endgroup$

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.