Skip to content

Commit

Permalink
Grammar update to treat Count as saccharides again
Browse files Browse the repository at this point in the history
  • Loading branch information
Old-Shatterhand committed Oct 15, 2024
1 parent c1a6013 commit cd69bc7
Show file tree
Hide file tree
Showing 6 changed files with 360 additions and 709 deletions.
2 changes: 2 additions & 0 deletions glyles/glycans/poly/walker.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,8 @@ def build_recipe(self, node):
tmp = self.build_recipe(c)
if isinstance(c, GlycanParser.ModiContext):
recipe.append(("".join([x[0] for x in tmp]), GlycanLexer.MOD))
elif isinstance(c, GlycanParser.SaciContext):
recipe += [(x[0], GlycanLexer.SAC) for x in tmp]
else:
recipe += tmp
return recipe
Expand Down
26 changes: 11 additions & 15 deletions glyles/grammar/Glycan.g4
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,19 @@ grammar Glycan;
start:
'#' (LBRACK branch RBRACK)* begin '#';
begin:
branch glycan ' ' TYPE
| branch glycan
| glycan ' ' TYPE
| glycan;
branch deriv ' ' TYPE
| branch deriv
| deriv ' ' TYPE
| deriv;
branch:
glycan con
| glycan con branch
deriv con
| deriv con branch
| LBRACE branch RBRACE
| glycan con LBRACE branch RBRACE branch
| glycan con LBRACE branch RBRACE LBRACE branch RBRACE branch
| glycan con LBRACE branch RBRACE LBRACE branch RBRACE LBRACE branch RBRACE branch;
glycan:
deriv RING TYPE | deriv TYPE | deriv RING | deriv;
| deriv con LBRACE branch RBRACE branch
| deriv con LBRACE branch RBRACE LBRACE branch RBRACE branch
| deriv con LBRACE branch RBRACE LBRACE branch RBRACE LBRACE branch RBRACE branch;
deriv:
saci+ RING TYPE modi* | saci+ TYPE modi* | saci+ RING modi* | saci+ modi*
| modi+ saci+ RING TYPE modi* | modi+ saci+ TYPE modi* | modi+ saci+ RING modi* | modi+ saci+ modi*;
modi* saci+ modi* RING? TYPE?;
saci: COUNT | SAC;
con:
LPAR typi NUM DASH qnum RPAR
Expand All @@ -39,7 +36,7 @@ modi:
| NUM ((COLON NUM)? D | E | carb)
| HEAD
| HEADD DASH
| DASH END; // |bridge deleted
| DASH END;
qnum:
QMARK | NUM;
typi:
Expand Down Expand Up @@ -124,5 +121,4 @@ I:
QMARK:
'?';


// antlr -Dlanguage=Python3 Glycan.g4
Loading

0 comments on commit cd69bc7

Please sign in to comment.