@@ -36,7 +36,7 @@ function __construct($argv) {
36
36
parent ::__construct ($ argv ,'bioportal ' );
37
37
parent ::addParameter ('files ' ,true ,null ,'all ' ,'all or comma-separated list of ontology short names to process ' );
38
38
parent ::addParameter ('download_url ' ,false ,null ,'http://data.bioontology.org/ ' );
39
- parent ::addParameter ('exclude ' ,false ,null ,"AURA " ,'ontologies to exclude - use acronyms ' );
39
+ parent ::addParameter ('exclude ' ,false ,null ,"AURA,HOOM " ,'ontologies to exclude - use acronyms ' );
40
40
parent ::addParameter ('continue_from ' ,false ,null ,"" ,'the ontology abbreviation to restart from ' );
41
41
parent ::addParameter ('ncbo_api_key ' ,false ,null ,null ,'BioPortal API key (please use your own) ' );
42
42
parent ::addParameter ('ncbo_api_key_file ' ,false ,null ,'ncbo.api.key ' ,'BioPortal API key file ' );
@@ -123,7 +123,6 @@ function Run()
123
123
if (isset ($ ls ['description ' ])) $ description = $ ls ['description ' ];
124
124
125
125
$ rfile = $ ls ['ontology ' ]['links ' ]['download ' ];
126
-
127
126
$ lfile = $ abbv .". " .$ format .".gz " ;
128
127
if (!file_exists ($ idir .$ lfile ) or parent ::getParameterValue ('download ' ) == 'true ' ) {
129
128
echo "downloading ... " ;
@@ -134,7 +133,7 @@ function Run()
134
133
$ ret = curl_setopt ($ ch , CURLOPT_HEADER , 1 );
135
134
$ ret = curl_setopt ($ ch , CURLOPT_FOLLOWLOCATION , 1 );
136
135
$ ret = curl_setopt ($ ch , CURLOPT_RETURNTRANSFER , 1 );
137
- $ ret = curl_setopt ($ ch , CURLOPT_TIMEOUT , 300 );
136
+ $ ret = curl_setopt ($ ch , CURLOPT_TIMEOUT , 600 );
138
137
$ ret = curl_exec ($ ch );
139
138
if (!$ ret ) {echo "no content " ;continue ;}
140
139
@@ -167,12 +166,13 @@ function Run()
167
166
168
167
// process
169
168
echo "converting ... " ;
170
- set_time_limit ( 0 );
169
+
171
170
// let's double check the format
172
171
$ fp = gzopen ($ idir .$ lfile ,"r " );
173
172
$ l = gzgets ($ fp );
174
173
if (strstr ($ l ,"xml " )) $ format = "owl " ;
175
174
gzclose ($ fp );
175
+
176
176
if ($ format == 'obo ' ) {
177
177
$ this ->OBO2RDF ($ abbv );
178
178
} else if ($ format == 'owl ' ) {
@@ -182,6 +182,7 @@ function Run()
182
182
} else {
183
183
echo "no processor for $ label (format $ format) " .PHP_EOL ;
184
184
}
185
+
185
186
if (!file_exists ($ odir .$ ofile )) { echo "no output " .PHP_EOL ;continue ;}
186
187
parent ::getWriteFile ()->close ();
187
188
parent ::clear ();
@@ -366,7 +367,7 @@ public function TriplifyMap($a, $prefix)
366
367
367
368
} else {
368
369
parent ::addRDF (
369
- parent ::triplifyString ($ s_uri ,$ p_uri ,$ a ['o ' ],(($ a ['o_datatype ' ] == '' )?null :$ a ['o_datatype ' ]),(($ a ['o_lang ' ] == '' )?null :$ a ['o_lang ' ]))
370
+ parent ::triplifyString ($ s_uri ,$ p_uri ,addslashes ( $ a ['o ' ]) ,(($ a ['o_datatype ' ] == '' )?null :$ a ['o_datatype ' ]),(($ a ['o_lang ' ] == '' )?null :$ a ['o_lang ' ]))
370
371
);
371
372
}
372
373
@@ -394,7 +395,7 @@ function OBO2RDF($abbv)
394
395
$ graph_uri = '< ' .parent ::getRegistry ()->getFQURI (parent ::getGraphURI ()).'> ' ;
395
396
$ bid = 1 ;
396
397
397
- while ($ l = parent ::getReadFile ()->read ()) {
398
+ while (FALSE !== ( $ l = parent ::getReadFile ()->read () )) {
398
399
$ lt = trim ($ l );
399
400
if (strlen ($ lt ) == 0 ) continue ;
400
401
if ($ lt [0 ] == '! ' ) continue ;
@@ -461,6 +462,7 @@ function OBO2RDF($abbv)
461
462
else {$ ns = strtolower ($ c [0 ]);$ id =$ c [1 ];}
462
463
$ id = str_replace ( array ("( " ,") " ), array ("_ " ,"" ), $ id );
463
464
$ tid = $ ns .": " .$ id ;
465
+ echo $ tid .PHP_EOL ;
464
466
} else if ($ a [0 ] == "name " ) {
465
467
$ buf .= parent ::describeClass ($ tid ,addslashes (stripslashes ($ a [1 ])));
466
468
} else if ($ a [0 ] == "is_a " ) {
@@ -483,7 +485,8 @@ function OBO2RDF($abbv)
483
485
$ buf .= $ t ;
484
486
$ is_deprecated = true ;
485
487
} else if ($ a [0 ] == "id " ) {
486
- parent ::getRegistry ()->parseQName ($ a [1 ],$ ns ,$ id );
488
+ parent ::getRegistry ()->parseQName ($ a [1 ],$ ns ,$ id );
489
+ if (trim ($ ns ) == '' ) $ ns = "unspecified " ;
487
490
$ tid = "$ ns: $ id " ;
488
491
// $buf .= parent::describeClass($tid,null,"owl:Class");
489
492
// $buf .= parent::triplify($tid,"rdfs:isDefinedBy",$ouri);
@@ -610,6 +613,7 @@ function OBO2RDF($abbv)
610
613
} else if ($ a [0 ] == "is_a " ) {
611
614
// do subclassing
612
615
parent ::getRegistry ()->parseQName ($ a [1 ],$ ns ,$ id );
616
+ if (trim ($ ns ) == '' ) $ ns = "unspecified " ;
613
617
$ t = parent ::triplify ($ tid ,"rdfs:subClassOf " ,"$ ns: $ id " );
614
618
$ buf .= $ t ;
615
619
$ min .= $ t ;
@@ -657,17 +661,19 @@ function OBO2RDF($abbv)
657
661
$ c = explode (" " ,$ a [1 ]);
658
662
if (count ($ c ) == 1 ) { // just a class
659
663
parent ::getRegistry ()->parseQName ($ c [0 ],$ ns ,$ id );
664
+ if (trim ($ ns ) == '' ) $ ns = "unspecified " ;
660
665
$ relationship .= parent ::getRegistry ()->getFQURI ("$ ns: $ id " );
661
666
$ buf .= parent ::triplify ($ tid ,"rdfs:subClassOf " ,"$ ns: $ id " );
662
667
663
668
} else if (count ($ c ) == 2 ) { // an expression
664
669
parent ::getRegistry ()->parseQName ($ c [0 ],$ pred_ns ,$ pred_id );
665
670
parent ::getRegistry ()->parseQName ($ c [1 ],$ obj_ns ,$ obj_id );
671
+ if (trim ($ obj_ns ) == '' ) $ obj_ns = "unspecified " ;
666
672
667
673
$ relationship .= '_:b ' .$ bid .' < ' .parent ::getRegistry ()->getFQURI ('owl:onProperty ' ).'> < ' .parent ::getRegistry ()->getFQURI ("obo_vocabulary: " .$ pred_id )."> $ graph_uri . " .PHP_EOL ;
668
674
$ relationship .= '_:b ' .$ bid .' < ' .parent ::getRegistry ()->getFQURI ('owl:someValuesFrom ' ).'> < ' .parent ::getRegistry ()->getFQURI ("$ obj_ns: $ obj_id " )."> $ graph_uri . " .PHP_EOL ;
669
675
670
- $ buf .= parent ::triplify ($ tid ,"obo_vocabulary: $ pred_id " ,"$ obj_ns: $ obj_id " );
676
+ $ buf .= parent ::triplify ($ tid ,"obo_vocabulary: $ pred_id " ,"$ obj_ns: $ obj_id " ); #@todo this causes problem with OGG-MM
671
677
}
672
678
} else {
673
679
// default handler
@@ -676,7 +682,8 @@ function OBO2RDF($abbv)
676
682
} else {
677
683
//header
678
684
//format-version: 1.0
679
- $ buf .= parent ::triplifyString ($ ouri ,"obo_vocabulary: $ a [0 ]" ,str_replace ( array ('" ' ,'\: ' ), array ('\" ' ,': ' ), isset ($ a [1 ])?$ a [1 ]:"" ));
685
+ $ buf .= parent ::triplifyString ($ ouri ,"obo_vocabulary: $ a [0 ]" ,
686
+ str_replace ( array ('" ' ,'\: ' ), array ('\" ' ,': ' ), isset ($ a [1 ])?$ a [1 ]:"" ));
680
687
}
681
688
682
689
if ($ minimal || $ minimalp ) parent ::getWriteFile ()->write ($ min );
0 commit comments