function fetch_one($id)
{
    global $config;
    $sequence = fetch_sequence($id);
    //print_r($sequence);
}
Example #2
0
$updated = $rss->appendChild($updated);
$value = $feed->createTextNode(date(DATE_ATOM));
$value = $updated->appendChild($value);
// id
$id = $feed->createElement('id');
$id = $rss->appendChild($id);
$id->appendChild($feed->createTextNode('urn:uuid:' . uuid()));
// author
$author = $feed->createElement('author');
$author = $rss->appendChild($author);
$name = $feed->createElement('name');
$name = $author->appendChild($name);
$name->appendChild($feed->createTextNode('Phyloinformatics'));
// Cache, store metadata, and make into RSS feed
foreach ($ids as $id) {
    $obj = fetch_sequence($id);
    //print_r($obj);
    if (isset($obj->accession)) {
        $item = new stdclass();
        $item->links = array();
        if (isset($obj->created)) {
            $item->created = $obj->created;
        }
        if (isset($obj->updated)) {
            $item->updated = $obj->updated;
        }
        if (isset($obj->source->latitude)) {
            $item->latitude = $obj->source->latitude;
        }
        if (isset($obj->source->longitude)) {
            $item->longitude = $obj->source->longitude;
 function Harvest()
 {
     global $debug;
     $xml = get($this->url);
     //echo $xml;
     $ids = array();
     $dom = new DOMDocument();
     $dom->loadXML($xml);
     $xpath = new DOMXPath($dom);
     $xpath_query = "//eSearchResult/IdList/Id";
     $nodeCollection = $xpath->query($xpath_query);
     foreach ($nodeCollection as $node) {
         $id = $node->firstChild->nodeValue;
         array_push($ids, $id);
     }
     //print_r($ids);
     // Get GenBank records
     // Cache, store metadata, and make into RSS feed
     foreach ($ids as $id) {
         $obj = fetch_sequence($id);
         //print_r($obj);
         if (isset($obj->accession)) {
             $item = new stdclass();
             $item->links = array();
             if (isset($obj->created)) {
                 $item->created = $obj->created;
             }
             if (isset($obj->updated)) {
                 $item->updated = $obj->updated;
             }
             if (isset($obj->source->latitude)) {
                 $item->latitude = $obj->source->latitude;
             }
             if (isset($obj->source->longitude)) {
                 $item->longitude = $obj->source->longitude;
             }
             $item->title = $obj->accession;
             $item->description = $obj->definition;
             $item->link = 'http://www.ncbi.nlm.nih.gov/nuccore/' . $obj->gi;
             $item->id = $item->link;
             $item->description .= '<br/><a href="http://www.ncbi.nlm.nih.gov/nuccore/' . $obj->accession . '">' . $obj->accession . '</a>';
             // Source taxon
             $txid = $obj->source->tax_id;
             array_push($item->links, array('taxon' => $txid));
             $item->description .= '<br/><a href="http://www.ncbi.nlm.nih.gov/Taxonomy/Browser/wwwtax.cgi?id=' . $txid . '">taxon:' . $txid . '</a>';
             /*
             $ref = $obj->references[0];
             if (isset($ref->doi))
             {
             	array_push($item->links, array('doi' =>  $ref->doi));							
             	$item->description .= '<br/><a href="http://dx.doi.org/' . $ref->doi . '">doi:' . $ref->doi . '</a>';
             }
             if (isset($ref->pmid))
             {
             	array_push($item->links, array('pmid' =>  $ref->pmid));
             }
             */
             //print_r($item);
             // Store
             $this->StoreFeedItem($item);
         }
     }
 }