Skip to content

Commit a3ef2b4

Browse files
Merge pull request #421 from micheldumontier/release3
Major updates to scripts
2 parents 6539d4d + 86c22e6 commit a3ef2b4

File tree

19 files changed

+1217
-996
lines changed

19 files changed

+1217
-996
lines changed

README.md

-26
This file was deleted.

bioportal/bioportal.php

+12-6
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,9 @@ function Run()
8989
foreach($ontologies AS $i => $o) {
9090
$label = (string) $o->name;
9191
$abbv = (string) $o->acronym;
92-
93-
if(array_search($abbv,$exclude_list) !== FALSE) continue;
92+
if(array_search($abbv,$exclude_list) !== FALSE) {
93+
continue;
94+
}
9495
if($include_list[0] != 'all') {
9596
// ignore if we don't find it in the include list OR we do find it in the exclude list
9697
if( (array_search($abbv,$include_list) === FALSE)
@@ -106,9 +107,7 @@ function Run()
106107
if(!isset($ls['hasOntologyLanguage'])) {echo 'insufficient metadata'.PHP_EOL;continue;}
107108

108109
$format = strtolower($ls['hasOntologyLanguage']);
109-
/***********/
110110
if($format != 'owl' and $format != 'obo') continue;
111-
112111
echo "Processing ($i/$total) $abbv ... ";
113112

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

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

120-
121119
$lfile = $abbv.".".$format.".gz";
122120
if(parent::getParameterValue('download') == 'true') {
123121
echo "downloading ... ";
@@ -138,6 +136,7 @@ function Run()
138136
if(isset($m[1])) {
139137
$filename = $m[1];
140138
if(strstr($filename,".zip")) continue;
139+
141140
} else {echo "error: no filename".PHP_EOL;continue;}
142141

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

149148
$lz = "compress.zlib://".$idir.$lfile;
150149
file_put_contents($lz,$body);
150+
151151
echo "done".PHP_EOL;
152152
}
153153

@@ -160,6 +160,11 @@ function Run()
160160
// process
161161
echo "converting ... ";
162162
set_time_limit(0);
163+
// let's double check the format
164+
$fp = gzopen($idir.$lfile,"r");
165+
$l = gzgets($fp);
166+
if(strstr($l,"xml")) $format= "owl";
167+
gzclose($fp);
163168
if($format == 'obo') {
164169
$this->OBO2RDF($abbv);
165170
} else if($format == 'owl') {
@@ -366,6 +371,7 @@ function OBO2RDF($abbv)
366371
if($abbv == "doid") $abbv = "do";
367372
$minimal = (parent::getParameterValue('detail') == 'min')?true:false;
368373
$minimalp = (parent::getParameterValue('detail') == 'min+')?true:false;
374+
$version = parent::getParameterValue("bio2rdf_release");
369375

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

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

clinicaltrials/clinicaltrials.php

+9-8
Original file line numberDiff line numberDiff line change
@@ -233,12 +233,11 @@ function parse_dir(){
233233
**/
234234
function process_file($infile) {
235235
$indir = parent::getParameterValue('indir');
236-
$xml = new CXML($indir,basename($infile));
236+
$xml = new CXML($infile);
237237
$this->setCheckPoint('file');
238238
while($xml->Parse("clinical_study") == TRUE) {
239239
$this->setCheckPoint('record');
240240
$this->root = $root = $xml->GetXMLRoot();
241-
242241
$this->nct_id = $nct_id = $this->getString("//id_info/nct_id");
243242
$this->study_id = $study_id = parent::getNamespace()."$nct_id";
244243

@@ -759,7 +758,7 @@ function process_file($infile) {
759758
parent::triplifyString($location_uri,parent::getVoc()."status", $this->getString('//status',$location)).
760759
parent::triplify($study_id,parent::getVoc()."location",$location_uri).
761760
parent::triplify($location_uri, parent::getVoc()."address", $this->makeAddress($address)).
762-
parent::triplify($location_uri, parent::getVoc()."contact", $this->makeContact($contact))
761+
($contact != null?parent::triplify($location_uri, parent::getVoc()."contact", $this->makeContact($contact)):"")
763762
);
764763
if($backups) {
765764
foreach($backups AS $backup) {
@@ -831,11 +830,13 @@ function process_file($infile) {
831830
try{
832831
$links = $root->xpath('//link');
833832
foreach($links AS $i => $link) {
834-
$lid = parent::getRes().md5($this->getString('./url',$link));
833+
$url = $this->getString('./url',$link);
834+
$url = preg_replace("/>.*$/","",$url);
835+
$lid = parent::getRes().md5($url);
835836
parent::addRDF(
836837
parent::describeIndividual($lid, $this->getString('./description',$link), parent::getVoc()."Link").
837838
parent::describeClass(parent::getVoc()."Link","Link").
838-
parent::triplify($lid,parent::getVoc()."url",preg_replace("/>$/","",$this->getString('./url',$link))).
839+
parent::triplify($lid,parent::getVoc()."url",$url).
839840
parent::triplify($study_id,parent::getVoc()."link",$lid)
840841
);
841842
}
@@ -1166,7 +1167,7 @@ function process_file($infile) {
11661167
if(!$et) continue;
11671168
$ev_uri = parent::getVoc().str_replace(" ","-",$ev_label);
11681169

1169-
$categories = array_shift($et->xpath('./category_list'));
1170+
$categories = @array_shift($et->xpath('./category_list'));
11701171
foreach($categories AS $category) {
11711172
$major_title = $this->getString('./title', $category);
11721173
$major_title_uri = parent::getRes().md5($major_title);
@@ -1272,8 +1273,8 @@ public function getDatetimeFromDate($date)
12721273

12731274
public function makeContact($contact)
12741275
{
1275-
if($contact == null) return null;
1276-
$contact_uri = parent::getRes().md5($contact->asXML());
1276+
if($contact == null) return '';
1277+
$contact_uri = parent::getRes().md5($contact->asXML());
12771278
$contact_type_uri = parent::getVoc()."Contact";
12781279
$contact_label = trim($this->getString('//first_name',$contact)." ".$this->getString('//last_name', $contact));
12791280
parent::addRDF(

0 commit comments

Comments
 (0)