function post_process($d) { // guid $d->guid = $d->institutionCode . ':' . $d->collectionCode . ':' . $d->catalogNumber; // Fix dates if (isset($d->verbatimCollectingDate)) { $date = format_date($d->verbatimCollectingDate); if ('' != $date) { $d->dateCollected = $date; } } if (isset($d->dateLastModified)) { $date = format_date($d->dateLastModified); if ('' != $date) { $d->dateModified = $date; } } // Coordinates // F**K! What are people doing!!!!!!! // KU 289791 occurs three times in the same XML document, but worse the // decimalLatitude and decimalLongtitude fields contain the degree symbol and hemisphere. if (isset($d->latitude)) { if (preg_match("/°N/", $d->latitude)) { $d->latitude = str_replace("°N", "", $d->latitude); } if (preg_match("/°S/", $d->latitude)) { $d->latitude = str_replace("°S", "", $d->latitude); if ($d->latitude > 0) { $d->latitude *= -1.0; } } } if (isset($d->longitude)) { if (preg_match("/°E/", $d->longitude)) { $d->longitude = str_replace("°E", "", $d->longitude); } if (preg_match("/°W/", $d->longitude)) { $d->longitude = str_replace("°W", "", $d->longitude); if ($d->longitude > 0) { $d->longitude *= -1.0; } } } // Can't do this as loc can't be NULL /* if (isset($d->longitude) && isset($d->latitude)) { $d->loc = "GeomFromText('POINT(" . $d->longitude . " " . $d->latitude . ")')"; } */ // uBio name lookup $name = ''; if (isset($d->organism)) { $d->organism = trim($d->organism); $name = $d->organism; } else { if (isset($d->genus)) { $name = $d->genus; if (isset($d->species)) { $name .= ' ' . $d->species; } $d->organism = $name; } } if ($name != '') { $names = ubio_namebank_search_rest(trim($name), false, true); // just take simple exact match if (count($names) > 0) { $d->namebankID = array(); foreach ($names as $n) { array_push($d->namebankID, $n); } } } return $d; }
<?php require_once dirname(__FILE__) . '/ubios.php'; $name = ''; $namebankID = array(); if (isset($_GET['name'])) { $name = $_GET['name']; } if ($name != '') { $names = ubio_namebank_search_rest(trim($name), false, true); // just take simple exact match //print_r($names); if (count($names) > 0) { foreach ($names as $n) { array_push($namebankID, $n); } } } echo json_encode($namebankID);
function gb_host(&$data) { if (isset($data->source->host)) { $names = ubio_namebank_search_rest(trim($data->source->host), false, true); // just take simple exact match if (count($names) > 0) { $data->source->host_namebankID = $names[0]; } } }
} print_r($item); $item_id = store_item($item); // if ($item->pmid != '') exit(); //----------------------------------------------------------------------------------------------- // Handle names // keywords are taxon names uBio has extracted from articles/abstracts foreach ($item->keywords as $k) { echo $k, "\n"; } // Do our thang $annotations = extract_new_names(strip_tags($item->title), $item->keywords); echo "Names--------------------\n"; print_r($annotations); // store names foreach ($annotations as $k => $v) { // lookup name $namebankID = 0; $find = ubio_namebank_search_rest($k, false, true); if (count($find) != 0) { $namebankID = $find[0]; } // store echo $k . ' ' . $namebankID . ' ' . $v['rank'] . ' ' . $v['new'] . "\n"; store_one_name($k, $namebankID, $v['rank'], $v['new'], $item_id); // join to source } $lineages = extract_lineages(strip_tags($item->title), $item->keywords); echo "Lineages-----------------\n"; print_r($lineages); }