Skip to content

Commit

Permalink
fixed to identify owl vs obo, even when incorrect filename
Browse files Browse the repository at this point in the history
  • Loading branch information
micheldumontier committed Sep 16, 2015
1 parent f4ab401 commit 86c22e6
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions bioportal/bioportal.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,9 @@ function Run()
foreach($ontologies AS $i => $o) {
$label = (string) $o->name;
$abbv = (string) $o->acronym;

if(array_search($abbv,$exclude_list) !== FALSE) continue;
if(array_search($abbv,$exclude_list) !== FALSE) {
continue;
}
if($include_list[0] != 'all') {
// ignore if we don't find it in the include list OR we do find it in the exclude list
if( (array_search($abbv,$include_list) === FALSE)
Expand All @@ -106,9 +107,7 @@ function Run()
if(!isset($ls['hasOntologyLanguage'])) {echo 'insufficient metadata'.PHP_EOL;continue;}

$format = strtolower($ls['hasOntologyLanguage']);
/***********/
if($format != 'owl' and $format != 'obo') continue;

echo "Processing ($i/$total) $abbv ... ";

$version = $ls['version'];
Expand All @@ -117,7 +116,6 @@ function Run()

$rfile = $ls['ontology']['links']['download'];


$lfile = $abbv.".".$format.".gz";
if(parent::getParameterValue('download') == 'true') {
echo "downloading ... ";
Expand All @@ -138,6 +136,7 @@ function Run()
if(isset($m[1])) {
$filename = $m[1];
if(strstr($filename,".zip")) continue;

} else {echo "error: no filename".PHP_EOL;continue;}

$body = substr($ret, $header_size);
Expand All @@ -148,6 +147,7 @@ function Run()

$lz = "compress.zlib://".$idir.$lfile;
file_put_contents($lz,$body);

echo "done".PHP_EOL;
}

Expand All @@ -160,6 +160,11 @@ function Run()
// process
echo "converting ... ";
set_time_limit(0);
// let's double check the format
$fp = gzopen($idir.$lfile,"r");
$l = gzgets($fp);
if(strstr($l,"xml")) $format= "owl";
gzclose($fp);
if($format == 'obo') {
$this->OBO2RDF($abbv);
} else if($format == 'owl') {
Expand Down Expand Up @@ -366,6 +371,7 @@ function OBO2RDF($abbv)
if($abbv == "doid") $abbv = "do";
$minimal = (parent::getParameterValue('detail') == 'min')?true:false;
$minimalp = (parent::getParameterValue('detail') == 'min+')?true:false;
$version = parent::getParameterValue("bio2rdf_release");

$tid = '';
$first = true;
Expand All @@ -374,7 +380,7 @@ function OBO2RDF($abbv)
$min = $buf = '';
$ouri = "http://bio2rdf.org/lsr:".$abbv;

$dataset_uri = $abbv."_resource:bio2rdf.dataset.$abbv.R3";
$dataset_uri = $abbv."_resource:bio2rdf.dataset.$abbv.R".$version;
parent::setGraphURI($dataset_uri);
$buf = parent::triplify($ouri,"rdf:type","owl:Ontology");
$graph_uri = '<'.parent::getRegistry()->getFQURI(parent::getGraphURI()).'>';
Expand Down

0 comments on commit 86c22e6

Please sign in to comment.