Skip to content

Commit

Permalink
Merge pull request #421 from micheldumontier/release3
Browse files Browse the repository at this point in the history
Major updates to scripts
  • Loading branch information
micheldumontier committed Oct 7, 2015
2 parents 6539d4d + 86c22e6 commit a3ef2b4
Show file tree
Hide file tree
Showing 19 changed files with 1,217 additions and 996 deletions.
26 changes: 0 additions & 26 deletions README.md

This file was deleted.

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
17 changes: 9 additions & 8 deletions clinicaltrials/clinicaltrials.php
Original file line number Diff line number Diff line change
Expand Up @@ -233,12 +233,11 @@ function parse_dir(){
**/
function process_file($infile) {
$indir = parent::getParameterValue('indir');
$xml = new CXML($indir,basename($infile));
$xml = new CXML($infile);
$this->setCheckPoint('file');
while($xml->Parse("clinical_study") == TRUE) {
$this->setCheckPoint('record');
$this->root = $root = $xml->GetXMLRoot();

$this->nct_id = $nct_id = $this->getString("//id_info/nct_id");
$this->study_id = $study_id = parent::getNamespace()."$nct_id";

Expand Down Expand Up @@ -759,7 +758,7 @@ function process_file($infile) {
parent::triplifyString($location_uri,parent::getVoc()."status", $this->getString('//status',$location)).
parent::triplify($study_id,parent::getVoc()."location",$location_uri).
parent::triplify($location_uri, parent::getVoc()."address", $this->makeAddress($address)).
parent::triplify($location_uri, parent::getVoc()."contact", $this->makeContact($contact))
($contact != null?parent::triplify($location_uri, parent::getVoc()."contact", $this->makeContact($contact)):"")
);
if($backups) {
foreach($backups AS $backup) {
Expand Down Expand Up @@ -831,11 +830,13 @@ function process_file($infile) {
try{
$links = $root->xpath('//link');
foreach($links AS $i => $link) {
$lid = parent::getRes().md5($this->getString('./url',$link));
$url = $this->getString('./url',$link);
$url = preg_replace("/>.*$/","",$url);
$lid = parent::getRes().md5($url);
parent::addRDF(
parent::describeIndividual($lid, $this->getString('./description',$link), parent::getVoc()."Link").
parent::describeClass(parent::getVoc()."Link","Link").
parent::triplify($lid,parent::getVoc()."url",preg_replace("/>$/","",$this->getString('./url',$link))).
parent::triplify($lid,parent::getVoc()."url",$url).
parent::triplify($study_id,parent::getVoc()."link",$lid)
);
}
Expand Down Expand Up @@ -1166,7 +1167,7 @@ function process_file($infile) {
if(!$et) continue;
$ev_uri = parent::getVoc().str_replace(" ","-",$ev_label);

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

public function makeContact($contact)
{
if($contact == null) return null;
$contact_uri = parent::getRes().md5($contact->asXML());
if($contact == null) return '';
$contact_uri = parent::getRes().md5($contact->asXML());
$contact_type_uri = parent::getVoc()."Contact";
$contact_label = trim($this->getString('//first_name',$contact)." ".$this->getString('//last_name', $contact));
parent::addRDF(
Expand Down
Loading

0 comments on commit a3ef2b4

Please sign in to comment.