/
rdf.go
226 lines (189 loc) · 7.43 KB
/
rdf.go
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
package rhea
import (
"encoding/xml"
)
/******************************************************************************
Lower level structs
These structs operate at the lowest level to parse the Rhea Rdf database dump
into structs that Golang can understand. Getting all of Rhea from Rdf->Golang
is quite verbose, and so most of the time you should not use these structs unless
you know what you are doing and it cannot be accomplished with higher level structs.
******************************************************************************/
// Rdf is the RDF XML representation of the Rhea database.
type Rdf struct {
XMLName xml.Name `xml:"RDF"`
Descriptions []Description `xml:"Description"`
}
// Description is the XML representation of an object in the Rhea database.
type Description struct {
// Reaction
XMLName xml.Name `xml:"Description"`
About string `xml:"about,attr"`
ID int `xml:"id"`
Accession string `xml:"accession"` // Accession refers to a Rhea accession number
Equation string `xml:"equation"`
HTMLEquation string `xml:"htmlEquation"`
IsChemicallyBalanced bool `xml:"isChemicallyBalanced"`
IsTransport bool `xml:"isTransport"`
Citations []Citation `xml:"citation"`
Substrates []Substrate `xml:"substrates"`
Products []Product `xml:"products"`
SubstrateOrProducts []SubstrateOrProduct `xml:"substratesOrProducts"`
Subclass []Subclass `xml:"subClassOf"`
Comment string `xml:"comment"`
EC EC `xml:"ec"`
Status Status `xml:"status"`
Compound CompoundXML `xml:"compound"`
// ReactionSide / Reaction Participant
BidirectionalReactions []BidirectionalReaction `xml:"bidirectionalReaction"`
DirectionalReactions []DirectionalReaction `xml:"directionalReaction"`
Side Side `xml:"side"`
SeeAlsos SeeAlso `xml:"seeAlso"`
TransformableTo TransformableTo `xml:"transformableTo"`
CuratedOrder int `xml:"curatedOrder"`
Contains Contains `xml:"contains"`
// ContainsX contains all other name-attribute pairs, with names like "contains1" in mind
ContainsX []ContainsX `xml:",any"`
// Small Molecule tags
Name string `xml:"name"`
HTMLName string `xml:"htmlName"`
Formula string `xml:"formula"`
Charge string `xml:"charge"`
ChEBI ChEBIXML `xml:"chebi"`
// Generic Compound
ReactivePartXML ReactivePartXML `xml:"reactivePart"`
// ReactivePart
Position string `xml:"position"`
// Polymer
UnderlyingChEBI UnderlyingChEBI `xml:"underlyingChEBI"`
PolymerizationIndex string `xml:"polymerizationIndex"`
// Transport
Location Location `xml:"location"`
}
// CitationStrings gives a list of citation strings from a description.
func (d *Description) CitationStrings() []string {
var output []string
for _, x := range d.Citations {
output = append(output, x.Resource)
}
return output
}
// SubstrateAccessionIDs gives a list of substrate accessions from a description.
func (d *Description) SubstrateAccessionIDs() []string {
var output []string
for _, x := range d.Substrates {
output = append(output, x.Resource)
}
return output
}
// ProductAccessionIDs gives a list of product accessions from a description.
func (d *Description) ProductAccessionIDs() []string {
var output []string
for _, x := range d.Products {
output = append(output, x.Resource)
}
return output
}
// SubstrateOrProductAccessionIDs gives a list of substrateOrProduct accessions from a description.
func (d *Description) SubstrateOrProductAccessionIDs() []string {
var output []string
for _, x := range d.SubstrateOrProducts {
output = append(output, x.Resource)
}
return output
}
// Citation is an XML representation of a citation of a description.
type Citation struct {
XMLName xml.Name `xml:"citation"`
Resource string `xml:"resource,attr"`
}
// Substrate is an XML representation of a substrate.
type Substrate struct {
XMLName xml.Name `xml:"substrates"`
Resource string `xml:"resource,attr"`
}
// Product is an XML representation of a product.
type Product struct {
XMLName xml.Name `xml:"products"`
Resource string `xml:"resource,attr"`
}
// SubstrateOrProduct is an XML representation of a SubstrateOrProduct.
type SubstrateOrProduct struct {
XMLName xml.Name `xml:"substratesOrProducts"`
Resource string `xml:"resource,attr"`
}
// Subclass is an XML representation of a subclass, which can mean many different things in Rhea.
type Subclass struct {
XMLName xml.Name `xml:"subClassOf"`
Resource string `xml:"resource,attr"`
}
// EC is an XML representation of an EC number (Enzyme Commission Number) of a description.
type EC struct {
XMLName xml.Name `xml:"ec"`
Resource string `xml:"resource,attr"`
}
// Status is an XML representation of the current status of an description.
type Status struct {
XMLName xml.Name `xml:"status"`
Resource string `xml:"resource,attr"`
}
// CompoundXML is an XML representation of a compound.
type CompoundXML struct {
XMLName xml.Name `xml:"compound"`
Resource string `xml:"resource,attr"`
}
// BidirectionalReaction is an XML representation of a Rhea bidirectional reaction.
type BidirectionalReaction struct {
XMLName xml.Name `xml:"bidirectionalReaction"`
Resource string `xml:"resource,attr"`
}
// DirectionalReaction is an XML representation of a Rhea directional reaction.
type DirectionalReaction struct {
XMLName xml.Name `xml:"directionalReaction"`
Resource string `xml:"resource,attr"`
}
// Side is an XML representation of a Rhea ReactionSide.
type Side struct {
XMLName xml.Name `xml:"side"`
Resource string `xml:"resource,attr"`
}
// SeeAlso is an XML representation of a SeeAlso XML in a description.
type SeeAlso struct {
XMLName xml.Name `xml:"seeAlso"`
Resource string `xml:"resource,attr"`
}
// TransformableTo is an XML representation of a transformableTo in a description. This essentially links two ReactionSides in Rhea.
type TransformableTo struct {
XMLName xml.Name `xml:"transformableTo"`
Resource string `xml:"resource,attr"`
}
// Contains is an XML representation of what Compound a ReactionParticipant contains.
type Contains struct {
XMLName xml.Name `xml:"contains"`
Resource string `xml:"resource,attr"`
}
// ContainsX is a catch-all XML representation of how many compounds a ReactionParticipant would use.
type ContainsX struct {
XMLName xml.Name
Content string `xml:"resource,attr"`
}
// ChEBIXML is an XML representation of a ChEBI.
type ChEBIXML struct {
XMLName xml.Name `xml:"chebi"`
Resource string `xml:"resource,attr"`
}
// UnderlyingChEBI is an XML representation of ChEBI that builds a Polymer.
type UnderlyingChEBI struct {
XMLName xml.Name `xml:"underlyingChEBI"`
Resource string `xml:"resource,attr"`
}
// ReactivePartXML is an XML representation of a ReactivePart.
type ReactivePartXML struct {
XMLName xml.Name `xml:"reactivePart"`
Resource string `xml:"resource,attr"`
}
// Location is an XML representation of Locations in a cell, usually referring to transport enzymes.
type Location struct {
XMLName xml.Name `xml:"location"`
Resource string `xml:"resource,attr"`
}