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

(re-)Implement GMX RTP parser using lark-parser #359

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ install-requires = # ?? requires-dist?
pbr
numpy
networkx ~= 2.0
lark
zip-safe = False

[options.extras_require]
Expand Down
7 changes: 4 additions & 3 deletions vermouth/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,17 @@


# Find the data directory once.
from pathlib import Path
try:
import pkg_resources
except ImportError:
import os
DATA_PATH = os.path.join(os.path.dirname(__file__), 'data')
DATA_PATH = Path(os.path.dirname(__file__)) / 'data'
del os
else:
DATA_PATH = pkg_resources.resource_filename('vermouth', 'data')
DATA_PATH = Path(pkg_resources.resource_filename('vermouth', 'data'))
del pkg_resources

del Path
del pbr

try:
Expand Down
37 changes: 37 additions & 0 deletions vermouth/data/grammars/gmx_rtp.lark
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
_header{name}: "[" name "]" _NL+

start: _NL* bondedtypes? residue+
bondedtypes: _header{"bondedtypes"} INT~8 _NL*

residue: _header{NAME} mol_section*

?mol_section: atomsection
| _header{"bonds"} bond+ -> bonds
| _header{"angles"} angle+ -> angles
| _header{"dihedrals"} dihedral+ -> dihedrals
| _header{"impropers"} dihedral+ -> impropers
| _header{"cmap"} cmap+ -> cmaps
| _header{"exclusions"} bond+ -> exclusions

name_line: NAME INT _NL*

atomsection: _header{"atoms"} atom+
atom: NAME NAME SIGNED_NUMBER INT _NL*

INTERACTION_ATOM: ("+"+|"-"+)? NAME
bond: INTERACTION_ATOM~2 [parameters] _NL+
angle: INTERACTION_ATOM~3 [parameters] _NL+
dihedral: INTERACTION_ATOM~4 [parameters] _NL+
cmap: INTERACTION_ATOM~5 [parameters] _NL+

parameters: (NAME|SIGNED_NUMBER+)

NAME: /\w/+
VALUE: /./+
COMMENT: /;[^\n]*/
%ignore COMMENT

%import common (INT, SIGNED_NUMBER)
%import common.NEWLINE -> _NL
%import common.WS_INLINE
%ignore WS_INLINE
Loading