function get_all_taxa()
 {
     $this->institution_uris = self::get_institution_uris();
     self::load_zip_contents();
     print_r($this->text_path);
     require_library('connectors/FishBaseAPI');
     $func = new FishBaseAPI();
     $fields = array("lngSpeciesSenior_ID", "lngSpecies_ID", "lngRepository_ID", "strCatNr", "lngPrepMeth_ID", "lngPersPrep_ID", "lngPersID2_ID", "lngPersID3_ID", "bytCountPrep", "lngDocuTypeSpecimen", "lngPrep_ID", "txtPrepNotes", "lngSpecimen_ID", "strTypeStat", "lngLoc_ID", "strLocName", "txtLocDescr", "sngElevation", "sngLatitudeWGS84", "sngLongitudeWGS84", "lngMacrohabitat_ID", "lngPermanency_ID", "strDepth", "lngGeology_ID", "lngSpecLocal_ID");
     $records_specimen = $func->make_array($this->text_path["sd_specimen"], $fields, "", array());
     array_shift($records_specimen);
     $fields = array("lngPersIdent_ID", "lngSpecimen_ID");
     $records_specimen_identifier = $func->make_array($this->text_path["sd_specimen_identifier"], $fields, "", array());
     array_shift($records_specimen_identifier);
     $fields = array("lngSpeciesSenior_ID", "lngMacroMicro_ID", "lngSpecies_ID");
     $records_habitat = $func->make_array($this->text_path["sd_macro_locality"], $fields, "", array());
     array_shift($records_habitat);
     /*
     $fields = array("lngLoc_ID", "strLocName", "txtLocDescr", "sngElevation", "sngLatitudeWGS84", "sngLongitudeWGS84", "lngMacrohabitat_ID", "lngPermanency_ID", "strDepth", "lngGeology_ID", "lngSpecLocal_ID", "lngSpecimen_ID", "lngSpeciesSenior_ID", "lngSpecies_ID");
     $records_locality = $func->make_array($this->text_path["sd_locality"], $fields, "", array());
     array_shift($records_locality);
     */
     $this->assemble_identified_by($records_specimen_identifier);
     $this->create_instances_from_taxon_object($records_specimen, "specimen");
     // $this->create_instances_from_taxon_object($records_locality, "locality");
     $this->create_instances_from_taxon_object($records_habitat, "habitat");
     $this->create_archive();
     // remove temp dir
     $path = $this->text_path["sd_specimen"];
     $parts = pathinfo($path);
     $parts["dirname"] = str_ireplace("/type_specimen", "", $parts["dirname"]);
     recursive_rmdir($parts["dirname"]);
     debug("\n temporary directory removed: " . $parts["dirname"]);
 }
 private function get_worms_taxa()
 {
     require_library('connectors/FishBaseAPI');
     $func = new FishBaseAPI();
     $fields = array();
     $excluded_fields = array("taxonID", "furtherInformationURL", "referenceID", "namePublishedIn", "taxonomicStatus", "taxonRemarks", "rightsHolder", "parentNameUsageID");
     $taxa = $func->make_array($this->text_path["worms"]["worms_taxon"], $fields, "", $excluded_fields);
     array_shift($taxa);
     foreach ($taxa as $taxon) {
         $final[Functions::canonical_form($taxon["scientificName"])] = $taxon["taxonRank"];
     }
     unset($taxa);
     return $final;
 }
 private function process_text_files()
 {
     if (!self::load_zip_contents()) {
         return false;
     }
     print_r($this->text_path);
     require_library('connectors/FishBaseAPI');
     $func = new FishBaseAPI();
     $fields = array("IDNUM", "TAXONID", "TAXID1", "SUBORDER", "TAXID2", "DIVISION", "TAXID5", "SUPERFAM", "TAXID9", "FAMILY", "TAXID13", "SUBFAM", "TAXID17", "TRIBE", "TAXID20", "SUBTRIBE", "GENUS", "SUBGENUS", "SPECIES", "SUBSPECS", "RECTYPCD", "RECTYPE", "UPDATE", "UPDUSER", "LOCGENUS", "LOCSUBGN", "SPCGROUP", "LOCSPECS", "LOCSUBSP", "INFRASUB", "CAUTHOR", "ORIGAUTH", "AUTHOR", "PUBYEAR", "JOURNAL", "COLLATN", "INTROADV", "TYPEDEP", "TYPMATTX", "TYPELOC", "SEXTX", "TSGENUS", "TSSUBGEN", "TSSPECS", "TSSUBSP", "TSAUTHOR", "TSKIND", "INFRATYP", "LOCVAR", "SEQUENCE", "UPSTAT");
     $taxa = $func->make_array($this->text_path[1], $fields, "", array(), "^");
     /* to get the breakdown of taxa levels
        foreach($taxa as $rec)
        {
            if(@$temp[$rec["RECTYPE"]]) $temp[$rec["RECTYPE"]]++;
            else $temp[$rec["RECTYPE"]] = 1;
        }
        print_r($temp);
        // [Super-Generic ]        => 614 xxx
        // [Genus/Subgenus ]       => 2540 xxx
        // [Genus/Subgenus Synon]  => 3459
        // [Species ]              => 19970 xxx
        // [Species Synonym ]      => 11083
        // [Unplaced Taxon ]       => 445 xxx
        // [Nomen Nudum ]          => 177
        // [Species Group ]        => 440 xxx
        */
     $i = 0;
     $link = array();
     foreach ($taxa as $rec) {
         if (in_array($rec["RECTYPE"], array("Species", "Genus/Subgenus", "Species Group", "Super-Generic"))) {
             $i++;
             $sciname = $rec["GENUS"] . " " . $rec["SPECIES"];
             $sciname = trim($sciname);
             if ($rec["RECTYPE"] == "Species Group") {
                 $sciname = $rec["SPCGROUP"];
             }
             $temp[$sciname] = 1;
             $link = $this->create_instances_from_taxon_object($rec, $link);
         }
     }
     echo "\n\n total rows: " . count($taxa);
     echo "\n total taxa: " . count($temp);
     echo "\n link: " . count($link) . "\n";
     $free_text = self::process_free_text($func, $link);
     $geo_data = self::process_geo_data($link);
     $ecology = self::process_ecology($func, $link);
     $pollen_visitation = self::process_pollen_visitation($func, $link);
     $predation = self::process_predation($func, $link);
     return true;
     /* Waiting from SPG on items below this line */
     // some sort of references
     // $fields = array("IDNUM", "REVSNTX", "TAXNTX");
     // $references = $func->make_array($this->text_path[4], $fields, "", array(), "^");
     // references for biology and morphology
     // $fields = array("IDNUM", "BIOLGYTX", "MORPHTX");
     // $texts = $func->make_array($this->text_path[5], $fields, "", array(), "^");
     // $ref_ids = array();
     // $agent_ids = array();
     // foreach($texts as $text)
     // {
     //     $biology = $text["BIOLGYTX"];
     //     $morphology = $text["MORPHTX"];
     //     $taxon_id = @$link[$text["IDNUM"]];
     //     if($biology) $ref_ids = array_merge($ref_ids, get_object_reference_ids($biology));
     //     if($morphology) $ref_ids = array_merge($ref_ids, get_object_reference_ids($morphology));
     // }
     // comma-separated taxon names
     // $fields = array("IDNUM", "AHOSTTX", "PHOSTTX");
     // $taxon_remarks = $func->make_array($this->text_path[7], $fields, "", array(), "^");
     // comma-separated taxon names
     // $fields = array("IDNUM", "PARATX", "SECHOSTX");
     // $taxon_remarks2 = $func->make_array($this->text_path[8], $fields, "", array(), "^");
     // wait for SPG to classify
     // $fields = array("IDNUM", "HYPATX", "SYNTX");
     // $comments = $func->make_array($this->text_path[10], $fields, "", array(), "^");
 }
Exemple #4
0
cs.conservation_status_title, cs.conservation_status_title_sp, cs.conservation_status_abbrev 
From nam_species s 
LEFT JOIN nam_genus g ON s.genus_id = g.genus_id 
LEFT Join nam_family f ON g.family_id = f.Family_ID 
LEFT Join nam_orders o ON f.order_id = o.order_id 
LEFT Join nam_conservation_status cs ON s.conservation_status_id = cs.id";

We've requested the partner to provide us with just a text dump of the result of the query above, but it seems they'll just
continue providing us with the Access MDB.
*/
$remote_file = "https://dl.dropboxusercontent.com/u/7597512/NorthAmericanMammals/data_from_sql_export.txt";
// $text_file = DOC_ROOT . "/update_resources/connectors/files/NorthAmericanMammals/data_from_sql_export.txt";
$text_file = Functions::save_remote_file_to_local($remote_file, array('download_wait_time' => 1000000, 'timeout' => 600));
require_library('connectors/FishBaseAPI');
$fields = array("species_id", "genus_name", "sci_name", "family_name", "order_name", "avg_length", "avg_length_sp", "range_length", "range_length_sp", "avg_weight", "avg_weight_sp", "range_weight", "range_weight_sp", "conservation_status_notes", "conservation_status_notes_sp", "common_name", "common_name_sp", "other_names", "other_names_sp", "refs", "refs_sp", "links", "links_sp", "dimorphism", "dimorphism_sp", "legend", "legend_sp", "refs(2)", "refs_sp(2)", "adaptation", "adaptation_sp", "conservation_status_id", "conservation_status_title", "conservation_status_title_sp", "conservation_status_abbrev");
$taxa = FishBaseAPI::make_array($text_file, $fields, "", array());
$resource_id = 85;
//for North American Mammals
$schema_taxa = array();
$used_taxa = array();
$ctr = 0;
foreach ($taxa as $row) {
    $ctr++;
    print "{$ctr} - ";
    $dwc_Kingdom = "Animalia";
    $dwc_Order = trim($row["order_name"]);
    $dwc_Family = trim($row["family_name"]);
    $dwc_Genus = trim($row["genus_name"]);
    $dwc_ScientificName = trim($row["sci_name"]);
    $taxon_identifier = "NAM_" . $row["species_id"];
    if (@$used_taxa[$taxon_identifier]) {
 function save_before_site_goes_dark()
 {
     if (!self::load_zip_contents()) {
         return FALSE;
     }
     $names_no_entry_from_partner = self::get_names_no_entry_from_partner();
     require_library('connectors/FishBaseAPI');
     $func = new FishBaseAPI();
     $fields = $this->media_fields;
     $records = $func->make_array($this->text_path["media"], $fields);
     $total = count($records);
     $i = 0;
     $folder = $this->local_destination . "_15";
     if (!file_exists($folder)) {
         mkdir($folder);
     }
     foreach ($records as $rec) {
         $i++;
         echo "\n {$i} of {$total} \n";
         // if($i <= 88325) continue; //debug 4,709
         $parts = pathinfo($rec["accessURI"]);
         $destination = $folder . "/" . $parts["basename"];
         // if(!file_exists($destination))
         if (!self::image_exists($parts["basename"])) {
             if (in_array($rec["accessURI"], $names_no_entry_from_partner)) {
                 continue;
             }
             // [$param] -> name_no_entry_from_partner";
             echo "- does not exist ";
             echo "\n -- " . $rec["accessURI"] . " processing... \n";
             $filenames = glob($folder . "/" . "*.*");
             if (count($filenames) >= 5000) {
                 $arr = explode("_", $folder);
                 $count = intval($arr[1]) + 1;
                 $folder = $this->local_destination . "_" . $count . "/";
                 if (!file_exists($folder)) {
                     mkdir($folder);
                 }
                 print "\n saving 111...";
                 echo "\n destination: [{$destination}] ";
                 self::save_big_file_to_local($rec["accessURI"], $destination);
             } else {
                 print "\n saving 222...";
                 echo "\n destination: [{$destination}] ";
                 self::save_big_file_to_local($rec["accessURI"], $destination);
             }
         } else {
             echo " - already exists";
         }
     }
 }
 function some_stats()
 {
     require_library('connectors/FishBaseAPI');
     $func = new FishBaseAPI();
     $fields = array("identifier", "full_reference");
     $path = DOC_ROOT . "applications/content_server/resources/660/reference.tab";
     $records = $func->make_array($path, $fields, "", array());
     foreach ($records as $rec) {
         print_r($rec);
     }
 }