Skip to content

Commit 84944dc

Browse files
fix for namespace not provided in obo file
1 parent efd924b commit 84944dc

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

bioportal/bioportal.php

+13-7
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ function __construct($argv) {
3636
parent::__construct($argv,'bioportal');
3737
parent::addParameter('files',true,null,'all','all or comma-separated list of ontology short names to process');
3838
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');
4040
parent::addParameter('continue_from',false,null,"",'the ontology abbreviation to restart from');
4141
parent::addParameter('ncbo_api_key',false,null,null,'BioPortal API key (please use your own)');
4242
parent::addParameter('ncbo_api_key_file',false,null,'ncbo.api.key','BioPortal API key file');
@@ -123,7 +123,6 @@ function Run()
123123
if(isset($ls['description'])) $description = $ls['description'];
124124

125125
$rfile = $ls['ontology']['links']['download'];
126-
127126
$lfile = $abbv.".".$format.".gz";
128127
if(!file_exists($idir.$lfile) or parent::getParameterValue('download') == 'true') {
129128
echo "downloading ... ";
@@ -134,7 +133,7 @@ function Run()
134133
$ret = curl_setopt($ch, CURLOPT_HEADER, 1);
135134
$ret = curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
136135
$ret = curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
137-
$ret = curl_setopt($ch, CURLOPT_TIMEOUT, 300);
136+
$ret = curl_setopt($ch, CURLOPT_TIMEOUT, 600);
138137
$ret = curl_exec($ch);
139138
if(!$ret) {echo "no content";continue;}
140139

@@ -167,12 +166,13 @@ function Run()
167166

168167
// process
169168
echo "converting ... ";
170-
set_time_limit(0);
169+
171170
// let's double check the format
172171
$fp = gzopen($idir.$lfile,"r");
173172
$l = gzgets($fp);
174173
if(strstr($l,"xml")) $format= "owl";
175174
gzclose($fp);
175+
176176
if($format == 'obo') {
177177
$this->OBO2RDF($abbv);
178178
} else if($format == 'owl') {
@@ -182,6 +182,7 @@ function Run()
182182
} else {
183183
echo "no processor for $label (format $format)".PHP_EOL;
184184
}
185+
185186
if(!file_exists($odir.$ofile)) { echo "no output".PHP_EOL;continue;}
186187
parent::getWriteFile()->close();
187188
parent::clear();
@@ -366,7 +367,7 @@ public function TriplifyMap($a, $prefix)
366367

367368
} else {
368369
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']))
370371
);
371372
}
372373

@@ -461,6 +462,7 @@ function OBO2RDF($abbv)
461462
else {$ns = strtolower($c[0]);$id=$c[1];}
462463
$id = str_replace( array("(",")"), array("_",""), $id);
463464
$tid = $ns.":".$id;
465+
echo $tid.PHP_EOL;
464466
} else if($a[0] == "name") {
465467
$buf .= parent::describeClass($tid,addslashes(stripslashes($a[1])));
466468
} else if($a[0] == "is_a") {
@@ -483,7 +485,8 @@ function OBO2RDF($abbv)
483485
$buf .= $t;
484486
$is_deprecated = true;
485487
} 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";
487490
$tid = "$ns:$id";
488491
// $buf .= parent::describeClass($tid,null,"owl:Class");
489492
// $buf .= parent::triplify($tid,"rdfs:isDefinedBy",$ouri);
@@ -610,6 +613,7 @@ function OBO2RDF($abbv)
610613
} else if($a[0] == "is_a") {
611614
// do subclassing
612615
parent::getRegistry()->parseQName($a[1],$ns,$id);
616+
if(trim($ns) == '') $ns = "unspecified";
613617
$t = parent::triplify($tid,"rdfs:subClassOf","$ns:$id");
614618
$buf .= $t;
615619
$min .= $t;
@@ -657,17 +661,19 @@ function OBO2RDF($abbv)
657661
$c = explode(" ",$a[1]);
658662
if(count($c) == 1) { // just a class
659663
parent::getRegistry()->parseQName($c[0],$ns,$id);
664+
if(trim($ns) == '') $ns = "unspecified";
660665
$relationship .= parent::getRegistry()->getFQURI("$ns:$id");
661666
$buf .= parent::triplify($tid,"rdfs:subClassOf","$ns:$id");
662667

663668
} else if(count($c) == 2) { // an expression
664669
parent::getRegistry()->parseQName($c[0],$pred_ns,$pred_id);
665670
parent::getRegistry()->parseQName($c[1],$obj_ns,$obj_id);
671+
if(trim($obj_ns) == '') $obj_ns = "unspecified";
666672

667673
$relationship .= '_:b'.$bid.' <'.parent::getRegistry()->getFQURI('owl:onProperty').'> <'.parent::getRegistry()->getFQURI("obo_vocabulary:".$pred_id)."> $graph_uri .".PHP_EOL;
668674
$relationship .= '_:b'.$bid.' <'.parent::getRegistry()->getFQURI('owl:someValuesFrom').'> <'.parent::getRegistry()->getFQURI("$obj_ns:$obj_id")."> $graph_uri .".PHP_EOL;
669675

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
671677
}
672678
} else {
673679
// default handler

0 commit comments

Comments
 (0)