-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathHMDB.g4
237 lines (166 loc) · 10.1 KB
/
HMDB.g4
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
/*
* MIT License
*
* Copyright (c) the authors (listed in global LICENSE file)
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the 'Software'), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:;
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHether IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
grammar HMDB;
/* first rule is always start rule */
lipid : lipid_pure EOF | lipid_pure adduct_info EOF;
lipid_pure : lipid_class | lipid_class lipid_suffix;
lipid_class : fatty_acid | gl | pl | sl | st;
lipid_suffix : '[rac]';
/* adduct information */
adduct_info : adduct_sep | adduct_separator adduct_sep;
adduct_sep : '[M' adduct ']' charge_sign | '[M' adduct ']' charge charge_sign;
adduct : adduct_set;
adduct_set : adduct_element | adduct_element adduct_set;
adduct_element : element | element number | number element | plus_minus element | plus_minus element number | plus_minus number element;
/* fatty acyl rules */
fa : fa_core | furan_fa | fa_lcb_prefix fa_core | fa_core fa_lcb_suffix | fa_lcb_prefix fa_core fa_lcb_suffix | fa_synonym;
fa_core : carbon carbon_db_separator db | ether carbon carbon_db_separator db | methyl carbon carbon_db_separator db;
furan_fa : furan_fa_mono | furan_fa_di;
furan_fa_mono : furan_first_number 'M' furan_second_number | 'MonoMe(' furan_first_number ',' furan_second_number ')';
furan_fa_di : furan_first_number 'D' furan_second_number | 'DiMe(' furan_first_number ',' furan_second_number ')';
furan_first_number : number;
furan_second_number : number;
fa_synonym : 'Palmitic acid' | 'Linoleic acid' | 'AA' | 'ALA' | 'EPA' | 'DHA' | 'LTB4' | 'Resolvin D3' | 'Maresin 1' | 'Resolvin D2' | 'Resolvin D5' | 'Resolvin D1' | 'TXB1' | 'TXB2' | 'TXB3' | 'PGF2alpha' | 'PGD2' | 'PGE2' | 'PGB2' | 'PGJ2' | '15d-PGJ2';
lcb : lcb_core | fa_lcb_prefix lcb_core | lcb_core fa_lcb_suffix | fa_lcb_prefix lcb_core fa_lcb_suffix;
lcb_core : hydroxyl carbon carbon_db_separator db;
carbon : number;
db : db_count | db_count db_positions | db_count db_suffix | db_count db_positions db_suffix;
db_count : number;
db_suffix : 'e' | 'n' db_suffix_number;
db_suffix_number : number;
db_positions : ROB db_position RCB;
db_position : db_single_position | db_position db_position_separator db_position;
db_single_position : db_position_number | db_position_number cistrans;
db_position_number : number;
cistrans : 'E' | 'Z';
ether : ether_type | ether_link_pos ether_type;
ether_link_pos : number '-';
ether_type : 'o-' | 'O-' | 'P-';
methyl : 'i-' | 'a-';
hydroxyl : 'm' | 'd' | 't';
fa_lcb_suffix : fa_lcb_suffix_core | fa_lcb_suffix_separator fa_lcb_suffix_core | ROB fa_lcb_suffix_core RCB | fa_lcb_suffix_full;
fa_lcb_suffix_full : fa_lcb_suffix_full_sep fa_lcb_suffix_number fa_lcb_suffix_types ROB fa_lcb_suffix_positions RCB | fa_lcb_suffix_full_sep fa_lcb_suffix_types ROB fa_lcb_suffix_position_core RCB;
fa_lcb_suffix_full_sep : fa_lcb_suffix_separator | '+=';
fa_lcb_suffix_core : fa_lcb_suffix_type | fa_lcb_suffix_number fa_lcb_suffix_type | fa_lcb_suffix_number fa_lcb_suffix_separator fa_lcb_suffix_type;
fa_lcb_suffix_type : 'OH' | 'me';
fa_lcb_suffix_types : 'OH' | 'me' | 'O';
fa_lcb_suffix_number : number;
fa_lcb_prefix : fa_lcb_prefix_type | fa_lcb_prefix_type fa_lcb_prefix_separator;
fa_lcb_prefix_type : 'iso';
fa_lcb_suffix_positions : fa_lcb_suffix_position_core COMMA fa_lcb_suffix_positions | fa_lcb_suffix_position_core;
fa_lcb_suffix_position_core : fa_lcb_suffix_position | fa_lcb_suffix_position med_suffix;
fa_lcb_suffix_position : number;
/* different fatty acyl types */
fa_species : fa;
fa2 : fa2_sorted | fa2_unsorted;
fa2_sorted : fa sorted_fa_separator fa;
fa2_unsorted : fa unsorted_fa_separator fa;
fa3 : fa3_sorted | fa3_unsorted;
fa3_sorted : fa sorted_fa_separator fa sorted_fa_separator fa;
fa3_unsorted : fa unsorted_fa_separator fa unsorted_fa_separator fa;
fa4 : fa4_sorted | fa4_unsorted;
fa4_sorted : fa sorted_fa_separator fa sorted_fa_separator fa sorted_fa_separator fa;
fa4_unsorted : fa unsorted_fa_separator fa unsorted_fa_separator fa unsorted_fa_separator fa;
/* fatty acid rules */
fatty_acid : fa_hg fa_fa | fa_hg interlink_fa | fa_hg headgroup_separator fa_fa | mediator;
fa_hg : 'FA' | 'fatty acid' | 'fatty alcohol' | 'NAE' | 'GP-NAE' | 'FAHFA';
fa_fa : ROB fa RCB;
interlink_fa : ROB fa sorted_fa_separator fa RCB;
/* mediator rules */
mediator : mediator_single | mediator_single headgroup_separator med_positions;
mediator_single : mediator_single mediator_single | mediator_single '-' mediator_single | db_positions | med_positions | 'KETE' | 'keto' | 'oxo' | 'Hp' | 'EPE' | 'ETE' | 'ODE' | 'EPT' | 'H' | 'LXA4' | 'hydroxy' | 'Di' | 'RvE1' | 'glyceryl' | 'EpETrE' | 'DHE' | 'ETrE' | 'DHA' | 'DoHA' | 'LTB4' | 'PGE2' | ' PGE2' | 'PGF2alpha' | 'trihydroxy' | 'TriH' | 'OTrE' | 'dihydroxy' | 'Ep' | 'LXB4' | 'Tri' | 'PAHSA' | 'MUFA' | 'GPGP' | 'GPIP' | 'PGE1' | 'PGG2' | 'SFA' | 'PUFA' | 'PGI2' | 'TXA2' | 'CoA' | 'FAOH' | 'EA' | 'beta' | 'PGH2' | 'LTD4' | 'kete' | 'DPE' | ' PGD2' | 'PGD2' | 'PGF2' | 'LTC4' | 'LTA4' | 'PGD1' | 'PGA1' | 'LTDE4' | 'epoxyoleate' | 'epoxystearate' | 'carboxy' | 'PGH1' | 'EtrE' | 'HXA3' | 'HxA3' | 'HXA3-C';
med_positions : med_position | ROB med_position RCB;
med_position : med_position med_position_separator med_position | number med_suffix | number;
med_suffix : 'S' | 'R';
/* glycerolipid rules */
gl : gl_regular | gl_mono | gl_molecular;
gl_regular : gl_hg gl_fa | gl_hg headgroup_separator gl_fa;
gl_fa : ROB fa_species RCB | ROB fa3 RCB;
gl_hg : 'MG' | 'DG' | 'TG' | 'MAG' | 'DAG' | 'TAG';
gl_molecular : gl_molecular_hg gl_molecular_fa | gl_molecular_hg headgroup_separator gl_molecular_fa;
gl_molecular_fa : ROB fa2 RCB;
gl_molecular_hg : 'DG' | 'DAG';
gl_mono : gl_mono_hg gl_mono_fa | gl_mono_hg headgroup_separator gl_mono_fa;
gl_mono_fa : ROB fa_species RCB | ROB fa2 RCB;
gl_mono_hg : 'MHDG' | 'DHDG' | 'MGDG' | 'DGDG';
/* phospholipid rules */
pl : pl_regular | pl_three | pl_four;
pl_regular : pl_hg pl_fa | pl_hg headgroup_separator pl_fa;
pl_fa : ROB fa_species RCB | ROB fa2 RCB;
pl_hg : 'LPA' | 'LPC' | 'LPE' | 'LPG' | 'LPI' | 'LPS' | 'PA' | 'PC' | 'PE' | 'PG' | 'PI' | 'PS' | 'PGP' | 'PIP' | 'PIP[3]' | 'PIP[4]' | 'PIP[5]' | 'PIP2' | 'PIP2[3,4]' | 'PIP2[3,5]' | 'PIP2[4,5]' | 'PIP3' | 'PIP3[3,4,5]' | 'CDP-DAG' | 'LysoPA' | 'LysoPC' | 'LysoPE' | 'LysoPG' | 'LysoPI' | 'LysoPS' | 'PE-NMe' | 'PE-NMe2' | 'CDP-DG';
pl_three : pl_three_hg pl_three_fa | pl_three_hg headgroup_separator pl_three_fa;
pl_three_fa : ROB fa_species RCB | ROB fa3 RCB;
pl_three_hg : 'NAPE';
pl_four : pl_four_hg pl_four_fa | pl_four_hg headgroup_separator pl_four_fa;
pl_four_fa : ROB fa_species RCB | ROB fa2 RCB | ROB fa4 RCB;
pl_four_hg : 'BMP' | 'LBPA' | 'Lysobisphosphatidate' | 'CL' | 'MLCL' | 'DLCL';
/* sphingolipid rules */
sl : sl_hg sl_lcb | sl_hg headgroup_separator sl_lcb;
sl_hg : all_sl_hg_names | sl_hg_prefix all_sl_hg_names | all_sl_hg_names sl_hg_suffix | sl_hg_prefix all_sl_hg_names sl_hg_suffix;
all_sl_hg_names : sl_hg_names | ganglioside;
sl_hg_names : 'HexCer' | 'Hex2Cer' | 'SM' | 'PE-Cer' | 'Cer' | 'CerP' | 'IPC' | 'MIPC' | 'M(IP)2C' | 'Gb3Cer' | 'Gb4Cer' | 'Forssman' | 'MSGG' | 'DSGG' | 'NOR1' | 'NORint' | 'NOR2' | 'Globo-H' | 'Globo-A' | 'SB1a' | 'SM1b' | 'SM1a' | 'Branched-Forssman' | 'Globo-B' | 'Para-Forssman' | 'Globo-Lex-9' | 'LysoSM' | 'Glucosylceramide' | 'Ceramide' | 'Tetrahexosylceramide';
ganglioside : 'Ganglioside' headgroup_separator ganglioside_names | ganglioside_names;
ganglioside_names : 'Gb3' | 'GA2' | 'GA1' | 'GM3' | 'GM2' | 'GM1' | 'GD3' | 'GT3' | 'GD1' | 'GT1' | 'GQ1' | 'GM4' | 'GD2' | 'GT2' | 'GP1' | 'GD1a' | 'GM1b' | 'GT1b' | 'GQ1b' | 'GT1a' | 'GQ1c' | 'GP1c' | 'GD1c' | 'GD1b' | 'GT1c' | 'Ga1' | 'Ga2' | 'GB3' | 'Gb3' | 'GB4' | 'Gb4' | 'Gd1' | 'Gd2' | 'Gd3' | 'Gm1' | 'Gm2' | 'Gm3' | 'Gm4' | 'GP1' | 'Gp1' | 'Gq1' | 'Gt1' | 'Gt2' | 'Gt3';
sl_hg_prefix : sl_hg_prefix '-' | sl_hg_prefix sl_hg_prefix | ROB sl_hg_prefix RCB | 'Glc' | 'NAc' | 'Gal' | 'Fuc' | 'SO3' | 'NeuGc' | 'i' | 'NeuAc' | 'Lac' | 'Lex' | '(3\'-sulfo)' | 'Ac-O-9' | '(alpha2-8)' | '(alpha2-6)' | 'NeuAc' | 'Sulfo';
sl_hg_suffix : sl_hg_suffix sl_hg_suffix | sl_hg_suffix '/' | ROB sl_hg_suffix RCB | 'NeuAc' | 'NeuGc' | ' alpha';
sl_lcb : sl_lcb_species | sl_lcb_subspecies;
sl_lcb_species : ROB lcb RCB;
sl_lcb_subspecies : ROB lcb sorted_fa_separator fa RCB;
/* sterol rules */
st : st_species | st_sub1 | st_sub2;
st_species : st_species_hg st_species_fa | st_species_hg headgroup_separator st_species_fa;
st_species_hg : 'SE';
st_species_fa : ROB fa_species RCB;
st_sub1 : st_sub1_hg st_sub1_fa | st_sub1_hg headgroup_separator st_sub1_fa;
st_sub1_hg : 'CE';
st_sub1_fa : ROB fa RCB;
st_sub2 : st_sub2_hg st_sub2_fa | st_sub2_hg headgroup_separator st_sub2_fa;
st_sub2_hg : 'SE';
st_sub2_fa : ROB fa2 RCB;
/* separators */
SPACE : ' ';
COLON : ':';
SEMICOLON : ';';
DASH : '-';
UNDERSCORE : '_';
SLASH : '/';
BACKSLASH : '\\';
COMMA: ',';
ROB: '(';
RCB: ')';
unsorted_fa_separator : UNDERSCORE;
sorted_fa_separator : SLASH;
adduct_separator : SPACE;
headgroup_separator : SPACE;
carbon_db_separator : COLON;
db_position_separator : COMMA;
med_position_separator : COMMA;
fa_lcb_suffix_separator : DASH;
fa_lcb_prefix_separator : DASH;
number : digit | digit number;
digit : '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9';
element: 'C' | 'H' | 'N' | 'O' | 'P' | 'S' | 'Br' | 'I' | 'F' | 'Cl' | 'As';
charge : '1' | '2' | '3' | '4';
charge_sign : plus_minus;
plus_minus : '-' | '+';