File tree Expand file tree Collapse file tree 1 file changed +54
-0
lines changed Expand file tree Collapse file tree 1 file changed +54
-0
lines changed Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ function OBOParser ($ in )
4
+ {
5
+ if ($ in === NULL ) return NULL ;
6
+
7
+ while ($ l = fgets ($ in )) {
8
+ if (strlen (trim ($ l )) == 0 ) continue ;
9
+
10
+ if (strstr ($ l ,"[Term] " )) {
11
+ if (isset ($ term )) {
12
+ $ terms [$ term ['id ' ][0 ]] = $ term ;
13
+ }
14
+ $ term = '' ;
15
+ } else if (strstr ($ l ,"[Typedef] " )) {
16
+ if (isset ($ term )) {
17
+ $ terms [$ term ['id ' ][0 ]] = $ term ;
18
+ unset($ term );
19
+ }
20
+ $ typedef = '' ;
21
+ } else {
22
+ if (isset ($ term )) {
23
+ $ a = explode (": " ,trim ($ l ));
24
+ $ a [1 ] = str_replace ('" ' ,'' ,$ a [1 ]); // remove brackets
25
+
26
+ preg_match ("/(.*) \! (.*)/ " ,$ a [1 ],$ m ); // parse out the label that may come with an id
27
+ if (count ($ m )) {
28
+ $ a [1 ] = $ m [1 ];
29
+ }
30
+ $ term [$ a [0 ]][] = $ a [1 ];
31
+
32
+ } else if (isset ($ typedef )) {
33
+
34
+ } else {
35
+ // in the header
36
+ //format-version: 1.0
37
+ $ a = explode (": " ,trim ($ l ));
38
+ $ terms ['ontology ' ][$ a [0 ]][] = $ a [1 ];
39
+ }
40
+ }
41
+ }
42
+ if (isset ($ term )) $ terms [$ term ['id ' ][0 ]] = $ term ;
43
+
44
+ return $ terms ;
45
+ }
46
+
47
+ function BuildNamespaceSearchList ($ terms , &$ out )
48
+ {
49
+ foreach ($ terms AS $ term ) {
50
+ if (isset ($ term ['namespace ' ][0 ]) && isset ( $ term ['id ' ][0 ] ) && isset ( $ term ['name ' ][0 ]))
51
+ $ out [$ term ['namespace ' ][0 ]][$ term ['id ' ][0 ]] = $ term ['name ' ][0 ];
52
+ }
53
+ }
54
+ ?>
You can’t perform that action at this time.
0 commit comments