Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parser().parse_any_variant does not parse any variant #167

Closed
reece opened this issue Apr 24, 2014 · 3 comments
Closed

Parser().parse_any_variant does not parse any variant #167

reece opened this issue Apr 24, 2014 · 3 comments
Labels
bug Something isn't working

Comments

@reece
Copy link
Member

reece commented Apr 24, 2014

Originally reported by: andrew_mcmurry (Bitbucket: andrew_mcmurry, GitHub: hyperfl0w)


Expected: parse_any_variant returns any variant type defined in the Grammar.
Actual: parse_any_variant is inherited method of the Parser construction and doesn't actually traverse the grammar.

Suspected Cause: parse_any_variant was accidentally included by inheritance.


@reece
Copy link
Member Author

reece commented Apr 24, 2014

Original comment by andrew_mcmurry (Bitbucket: andrew_mcmurry, GitHub: hyperfl0w):


updated grammar to support parse_any_edit and parse_any_position

can I please have commit access?
diff is below

@reece
Copy link
Member Author

reece commented Apr 24, 2014

Original comment by andrew_mcmurry (Bitbucket: andrew_mcmurry, GitHub: hyperfl0w):


#!bash

diff -r a988c99ef912 hgvs/data/hgvs.pymeta
--- a/hgvs/data/hgvs.pymeta	Thu Apr 17 14:50:00 2014 -0700
+++ b/hgvs/data/hgvs.pymeta	Wed Apr 23 22:52:22 2014 -0700
@@ -79,11 +79,13 @@
 g_edit   = gmn_edit
 m_edit   = gmn_edit
 n_edit   = gmn_edit
-gmn_edit = gmn_type:type '.' gmn_posedit:posedit -> hgvs.variant.SequenceVariant(None,type,posedit)
+gmn_edit = gmn_type:type '.' gmn_posedit:posedit -> hgvs.variant.PosEdit(None,type,posedit)
 c_edit   = 'c':type '.'   c_posedit:posedit -> hgvs.variant.SequenceVariant(None,type,posedit)
 p_edit   = 'p':type '.'   p_posedit:posedit -> hgvs.variant.SequenceVariant(None,type,posedit)
 r_edit   = 'r':type '.'   r_posedit:posedit -> hgvs.variant.SequenceVariant(None,type,posedit)
 
+any_edit = gmn_edit | c_edit | r_edit | p_edit
+
 
 ############################################################################
 ## HGVS Position -- e.g., NM_01234.5:c.22+6 (without an edit)
@@ -97,11 +99,12 @@
 p_hgvs_position   = accn:ac ':' 'p':type      '.'   p_interval:pos -> hgvs.hgvsposition.HGVSPosition(ac, type, pos)
 r_hgvs_position   = accn:ac ':' 'r':type      '.'   r_interval:pos -> hgvs.hgvsposition.HGVSPosition(ac, type, pos)
 
+any_position = gmn_hgvs_position | c_hgvs_position | p_hgvs_position | r_hgvs_position
 
 ############################################################################
 ## PosEdits -- position + edit objects
 
-# any_posedit = g_posedit | m_posedit | n_posedit | c_posedit | r_posedit | p_posedit 
+any_posedit = g_posedit | m_posedit | n_posedit | c_posedit | r_posedit | p_posedit 
 
 g_posedit   = gmn_posedit
 m_posedit   = gmn_posedit
diff -r a988c99ef912 tests/test_hgvs_parser.py
--- a/tests/test_hgvs_parser.py	Thu Apr 17 14:50:00 2014 -0700
+++ b/tests/test_hgvs_parser.py	Wed Apr 23 22:52:22 2014 -0700
@@ -50,6 +50,56 @@
         #self.assertEqual( str(self.parser.parse_p_posedit('=?')), '(=)' )
         self.assertEqual( str(self.parser.parse_p_posedit('(=)')), '(=)' )
 
+
+    def test_Parse_any_edit(self):
+        """
+        any_edit = gmn_edit | c_edit | r_edit | p_edit
+        Test conditions include edit annotations from PubTator and
+         (c|r|p) edits of a BRCA2 variant stripped of its accession (NM_000059.3)
+        """
+        c_edit = 'c.424G>C'
+        r_edit = 'r.518G>C'
+        p_edit = 'p.L152P'
+        pubtator_edits = [c_edit, r_edit, p_edit]
+
+        c_edit = 'c.9218A>G'
+        r_edit = 'r.9445A>G'
+        p_edit = 'p.(Asp3073Gly)'
+        p_edit2= 'p.Asp3073Gly'
+        brca2_edits = [c_edit, r_edit, p_edit, p_edit]
+
+        unknown_edit = 'C152G'
+
+        for any_edit in pubtator_edits+brca2_edits:
+            variant = self.parser.parse_any_edit(any_edit)
+            self.assertIsNotNone(variant)
+
+        # Special case, we dont want this unknown text to be parsed!
+        can_parse = True
+        try:
+             self.parser.parse_any_edit(unknown_edit)
+        except:
+            can_parse = False
+        finally:
+            self.assertFalse(can_parse)
+
+    def test_Parse_any_position(self):
+        """
+        any_position = gmn_hgvs_position | c_hgvs_position | p_hgvs_position | r_hgvs_position
+        BRCA2 variant was first mapped into (c|p|r) space and then manually truncated of the edit,
+        containing only the position.
+        """
+        c_hgvs_position = 'NM_000059.3:c.9218'
+        p_hgvs_position = 'NM_000059.3:r.9445'
+        r_hgvs_position = 'NP_000050.2:p.(Asp3073)'
+
+        for any_position in [c_hgvs_position, p_hgvs_position, r_hgvs_position]:
+            variant = self.parser.parse_any_position(any_position)
+            self.assertIsNotNone(variant)
+
+
+
+
 if __name__ == '__main__':
     unittest.main()
 

@reece
Copy link
Member Author

reece commented Jun 11, 2014

Original comment by Reece Hart (Bitbucket: reece, GitHub: reece):


As discussed in person, the intent of the any_variant rule was solely to parse strings of the form :.<arbitrary_text> . However, the SV returned from this is not very useful, or is at least confusing.

I have commented out that rule from hgvs.pymeta until there is a well-defined need.

commit edbf482e0774

@reece reece added minor bug Something isn't working labels Mar 9, 2017
@reece reece closed this as completed Mar 9, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant