Created
October 28, 2011 15:16
-
-
Save lmatteis/1322511 to your computer and use it in GitHub Desktop.
This is a PHP snippet on how to get all the triats of an ontology given its name:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class traits { | |
var $url = 'http://www.cropontology-curationtool.org'; | |
function get_children($parent_id) { | |
$children = json_decode(file_get_contents($this->url. '/get-children/' . $parent_id)); | |
foreach($children as $child) { | |
if($child->has_children > 0) { | |
$child->children = $this->get_children($child->id); | |
} | |
} | |
return $children; | |
} | |
function traits($crop) { | |
$this->crop = $crop; | |
} | |
function get() { | |
$ontology_id = file_get_contents($this->url . '/get-ontology-id?ontology_name=' . $this->crop); | |
$onto_roots = json_decode(file_get_contents($this->url . '/get-ontology-roots/' . trim($ontology_id))); | |
$arr = array(); | |
foreach($onto_roots as $onto) { | |
$arr[$onto->name] = $this->get_children($onto->id); | |
} | |
return $arr; | |
} | |
} | |
$traits = new traits('Cassava'); | |
print_r($traits->get()); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment