0 || $content2 > 0)
$GBIFs [] = [
$content2 + $content1,
$url,
' specimen(s)'
];
$url = "http://www.gbif.org/occurrence/search?TAXON_KEY=" . $key . "&BASIS_OF_RECORD=FOSSIL_SPECIMEN";
$count = "http://api.gbif.org/v1/occurrence/count?taxonKey=" . $key . "&basisOfRecord=FOSSIL_SPECIMEN";
$content = file_get_contents ( $count );
if ($content > 0)
$GBIFs [] = [
$content,
$url,
' fossil(s)'
];
}
}
return $GBIFs;
}
public static function getGBIFRecord($key) {
$GBIFs = [ ];
if ($key != "") {
$url = "http://www.gbif.org/occurrence/search?TAXON_KEY=" . $key . "&BASIS_OF_RECORD=PRESERVED_SPECIMEN&BASIS_OF_RECORD=LIVING_SPECIMEN";
$count = "http://api.gbif.org/v1/occurrence/count?taxonKey=" . $key . "&basisOfRecord=LIVING_SPECIMEN";
$content1 = file_get_contents ( $count );
$count2 = "http://api.gbif.org/v1/occurrence/count?taxonKey=" . $key . "&basisOfRecord=PRESERVED_SPECIMEN";
$content2 = file_get_contents ( $count2 );
if ($content1 > 0 || $content2 > 0)
$GBIFs [] = [
$content2 + $content1,
$url,
' specimen(s)'
];
$url = "http://www.gbif.org/occurrence/search?TAXON_KEY=" . $key . "&BASIS_OF_RECORD=FOSSIL_SPECIMEN";
$count = "http://api.gbif.org/v1/occurrence/count?taxonKey=" . $key . "&basisOfRecord=FOSSIL_SPECIMEN";
$content = file_get_contents ( $count );
if ($content > 0)
$GBIFs [] = [
$content,
$url,
' fossil(s)'
];
}
if (! empty ( $GBIFs ))
foreach ( $GBIFs as $GBIF )
echo '' . $GBIF [0] . $GBIF [2] . '
';
}
public static function getNCBIRecord($key) {
$NCBI = [ ];
if ($key != "") {
// echo "look for ".$key."
";
$outurl = "http://www.ncbi.nlm.nih.gov/nuccore/?term=txid" . $key . "[Organism:noexp]";
$urlNT = "http://eutils.ncbi.nlm.nih.gov/entrez/eutils/esearch.fcgi?db=nuccore&term=txid" . $key . "[Organism:noexp]";
$xml = new DOMDocument ( '1.0', 'UTF-8' );
$xml->load ( $urlNT );
$eSearchResult = $xml->getElementsByTagName ( 'eSearchResult' );
$element = $eSearchResult->item ( 0 );
$elts = $element->childNodes;
foreach ( $elts as $elt ) {
$nom = $elt->nodeName;
if ($nom == "Count") {
$cnt = $elt->nodeValue;
break;
}
}
if (isset ( $cnt ) && $cnt > 0)
$NCBI = [
$cnt . " Nucleotide record(s)",
$outurl
];
}
// return $NCBI;
echo '' . $NCBI [0] . '
';
}
public static function getBOLDRecord($name) {
// echo "getBOLD for " . $name;
$bold = "http://www.boldsystems.org/index.php/API_Public/specimen?format=xml&taxon=" . str_replace ( "_", "+", $name );
// echo $bold;
$content=file_get_contents($bold);
// Yii::info($content);
$cnt = 0;
try {
$doc=DOMDocument::loadXML($content);
if($doc){
$records = $doc->getElementsByTagName ( 'record' );
$cnt=$records->length;
}
} catch ( Exception $e ) {
echo $e;
}
echo $cnt;
}
public static function getGGBNRecords($fullscientificname, $tripleidstoreid) {
$GGBN = [ ];
if (! empty ( $fullscientificname )) {
$config = SOLRQueryManager::getConfigDetails ();
$sampletypes = [
"tissue",
"DNA",
"unknown"
];
foreach ( $sampletypes as $sampletype ) {
$query = SOLRQueryManager::createSearchQuery ( $config );
$value = str_replace ( " ", "\ ", $fullscientificname );
$value = str_replace ( "(", "\(", $value );
$value = str_replace ( ")", "\)", $value );
$value = str_replace ( ":", "\:", $value );
$filters = "fullScientificName_nc:" . $value . " AND NOT tripleidstoreid:" . $tripleidstoreid . " AND sampletype:" . $sampletype;
$query->setQuery ( "*:*" );
$query->setStart ( 0 )->setRows ( Yii::$app->params ['listPerPage'] );
$fq = "{!join from=lowestTripleIDs to=tripleidstoreid fromIndex=" . Yii::$app->params ['solrsearchname'] . "}" . $filters;
$query->createFilterQuery ( 'myfilter' )->setQuery ( $fq );
$query->setFields ( [
"[]"
] );
try {
$raw_response = SOLRQueryManager::$client->select ( $query );
$count = $raw_response->getNumFound ();
} catch ( Solarium\Exception\UnexpectedValueException $e ) {
$raw_response = SOLRQueryManager::$client->select ( $query );
$count = $raw_response->getNumFound ();
}
if ($count > 0) {
$outurl = "/" . Yii::$app->params ['siteName'] . "/search?fullScientificName=" . $fullscientificname . "&sampletype=" . $sampletype;
$GGBN [] = [
$count . " record(s) with " . $sampletype . "",
$outurl
];
}
}
}
return $GGBN;
}
}