Skip to content

Commit

Permalink
fix anomericity parsing in the 'simple' IUPAC dialect
Browse files Browse the repository at this point in the history
  • Loading branch information
mobiusklein committed Jan 27, 2025
1 parent be543d4 commit f9498b4
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/glypy/io/iupac.py
Original file line number Diff line number Diff line change
Expand Up @@ -790,11 +790,22 @@ def __call__(self, linkage_string):


class SimpleLinkageDeserializer(LinkageDeserializer):
pattern = re.compile(r"""\((?P<anomer>[abo?])
pattern = re.compile(r"""\((?P<anomer>[abo?]?)
(?P<child_linkage>[0-9?/]+)->?
(?P<parent_linkage>[0-9?/]+)?\)?""",
re.VERBOSE)

def get_anomericity(self, linkage_text):
hit = self.pattern.search(linkage_text)
if not hit:
return anomer_map_from["?"]
else:
anomer = hit.groupdict().get('anomer')
if not anomer:
anomer = '?'
return anomer_map_from[anomer]



parse_linkage_structure = LinkageDeserializer()

Expand Down Expand Up @@ -1088,6 +1099,9 @@ def build_residue(self, match_dict):
self.set_modifications(residue, modification)
self.set_substituents(residue, match_dict['substituent'], base_is_modified, base_type)
linkage = match_dict.get("linkage")
if linkage:
anomer = self.linkage_parser.get_anomericity(linkage)
residue.anomer = anomer
return residue, linkage


Expand Down

0 comments on commit f9498b4

Please sign in to comment.