From 38d259d8a5190c8828abdb076bfc6b24cab675d4 Mon Sep 17 00:00:00 2001 From: lingutln Date: Wed, 24 Apr 2013 22:41:31 +0000 Subject: [PATCH] File reorganizatio and initial checkins for data import scripts svn path=/; revision=468 --- .../ia_upload/annotation_data_importer.pl | 100 ++++++++++++++++++ .../ia_upload/annotation_data_importer.pl~ | 100 ++++++++++++++++++ .../contact_process.php | 0 .../{ => balaji_prototype}/data.html | 0 .../{ => balaji_prototype}/index.html | 0 ...mg_data_DWS_NYBG_20130404.tab - Sheet1.tsv | 17 +++ .../{ => sql}/image_annotation.mwb | Bin .../{ => sql}/image_annotation.png | Bin .../{ => sql}/image_annotation.sql | 0 .../{ => sql}/image_annotation_v1.11.mwb | Bin .../{ => sql}/image_annotation_v1.11.png | Bin .../{ => sql}/image_annotation_v1_11_load.sql | 0 12 files changed, 217 insertions(+) create mode 100644 image_annotation_db/ia_upload/annotation_data_importer.pl create mode 100644 image_annotation_db/ia_upload/annotation_data_importer.pl~ rename image_annotation_db/ia_upload/{ => balaji_prototype}/contact_process.php (100%) rename image_annotation_db/ia_upload/{ => balaji_prototype}/data.html (100%) rename image_annotation_db/ia_upload/{ => balaji_prototype}/index.html (100%) create mode 100644 image_annotation_db/ia_upload/image_data/IADB_img_data_DWS_NYBG_20130404.tab - Sheet1.tsv rename image_annotation_db/{ => sql}/image_annotation.mwb (100%) rename image_annotation_db/{ => sql}/image_annotation.png (100%) rename image_annotation_db/{ => sql}/image_annotation.sql (100%) rename image_annotation_db/{ => sql}/image_annotation_v1.11.mwb (100%) rename image_annotation_db/{ => sql}/image_annotation_v1.11.png (100%) rename image_annotation_db/{ => sql}/image_annotation_v1_11_load.sql (100%) diff --git a/image_annotation_db/ia_upload/annotation_data_importer.pl b/image_annotation_db/ia_upload/annotation_data_importer.pl new file mode 100644 index 0000000..debbbef --- /dev/null +++ b/image_annotation_db/ia_upload/annotation_data_importer.pl @@ -0,0 +1,100 @@ +#!/usr/bin/perl -w + +=head1 NAME + + Image Annotation Data Importer + +=head1 VERSION + + 0.1 + +=head1 DESCRIPTION + + Read the data from the tab de;imited files present in the image_data directory present adjacent to this file + Add more description + +=head1 USAGE + + annotation_data_importer.pl + +=cut + +# general + +use strict; +use English; +use DBI; + +# configurations + +use constant IMAGE_DATA_DIR => "image_data"; + +sub establish_db_connection +{ + return DBI->connect('DBI:mysql:image_annotation;host=floret.cgrb.oregonstate.edu', 'lingutln', 'nikhil_iadb', + { RaiseError => 1 } + ); +} + +sub insert_curator_data(my $dbh, my @image_data_fields) +{ + my($curator_first, $curator_last) = split(/ /, $image_data_fields[6], 2); + my $curator_email = $image_data_fields[7]; + my $curator_affiliation = $image_data_fields[8]; + + $dbh->do('INSERT INTO curator (firstname, lastname, primary_email, alternate_email, affiliation) VALUES(?, ?, ?, ?, ?)', undef, $curator_first, $curator_last , $curator_email ,'', $curator_affiliation); + +} + +sub insert_record_into_database +{ + my $dbh = establish_db_connection; + + my @image_data_fields = split(/\t/); + + insert_curator_data($dbh, @image_data_fields); + + + +} + +sub import_image_data +{ + + print "Opening each image data(*.tsv) file and reading data...\n\n"; + + foreach (glob(IMAGE_DATA_DIR."/*.tsv")) + { + + my $content = do { + local $/ = undef; + open (my $file, "<", $_) or die("could not open $_: $!"); + <$file>; + }; + + chomp; + + my @image_data_records = split(/\n/, $content); + + splice @image_data_records, 0, 1; + + foreach (@image_data_records) + { + insert_record_into_database($_); + } + + close $_ or die("Could not close '$_': $OS_ERROR"); + + } +} + +# --------------------------------------------------------------------------- + # main +# --------------------------------------------------------------------------- + +import_image_data; +exit; + +# --------------------------------------------------------------------------- +# end +# --------------------------------------------------------------------------- diff --git a/image_annotation_db/ia_upload/annotation_data_importer.pl~ b/image_annotation_db/ia_upload/annotation_data_importer.pl~ new file mode 100644 index 0000000..debbbef --- /dev/null +++ b/image_annotation_db/ia_upload/annotation_data_importer.pl~ @@ -0,0 +1,100 @@ +#!/usr/bin/perl -w + +=head1 NAME + + Image Annotation Data Importer + +=head1 VERSION + + 0.1 + +=head1 DESCRIPTION + + Read the data from the tab de;imited files present in the image_data directory present adjacent to this file + Add more description + +=head1 USAGE + + annotation_data_importer.pl + +=cut + +# general + +use strict; +use English; +use DBI; + +# configurations + +use constant IMAGE_DATA_DIR => "image_data"; + +sub establish_db_connection +{ + return DBI->connect('DBI:mysql:image_annotation;host=floret.cgrb.oregonstate.edu', 'lingutln', 'nikhil_iadb', + { RaiseError => 1 } + ); +} + +sub insert_curator_data(my $dbh, my @image_data_fields) +{ + my($curator_first, $curator_last) = split(/ /, $image_data_fields[6], 2); + my $curator_email = $image_data_fields[7]; + my $curator_affiliation = $image_data_fields[8]; + + $dbh->do('INSERT INTO curator (firstname, lastname, primary_email, alternate_email, affiliation) VALUES(?, ?, ?, ?, ?)', undef, $curator_first, $curator_last , $curator_email ,'', $curator_affiliation); + +} + +sub insert_record_into_database +{ + my $dbh = establish_db_connection; + + my @image_data_fields = split(/\t/); + + insert_curator_data($dbh, @image_data_fields); + + + +} + +sub import_image_data +{ + + print "Opening each image data(*.tsv) file and reading data...\n\n"; + + foreach (glob(IMAGE_DATA_DIR."/*.tsv")) + { + + my $content = do { + local $/ = undef; + open (my $file, "<", $_) or die("could not open $_: $!"); + <$file>; + }; + + chomp; + + my @image_data_records = split(/\n/, $content); + + splice @image_data_records, 0, 1; + + foreach (@image_data_records) + { + insert_record_into_database($_); + } + + close $_ or die("Could not close '$_': $OS_ERROR"); + + } +} + +# --------------------------------------------------------------------------- + # main +# --------------------------------------------------------------------------- + +import_image_data; +exit; + +# --------------------------------------------------------------------------- +# end +# --------------------------------------------------------------------------- diff --git a/image_annotation_db/ia_upload/contact_process.php b/image_annotation_db/ia_upload/balaji_prototype/contact_process.php similarity index 100% rename from image_annotation_db/ia_upload/contact_process.php rename to image_annotation_db/ia_upload/balaji_prototype/contact_process.php diff --git a/image_annotation_db/ia_upload/data.html b/image_annotation_db/ia_upload/balaji_prototype/data.html similarity index 100% rename from image_annotation_db/ia_upload/data.html rename to image_annotation_db/ia_upload/balaji_prototype/data.html diff --git a/image_annotation_db/ia_upload/index.html b/image_annotation_db/ia_upload/balaji_prototype/index.html similarity index 100% rename from image_annotation_db/ia_upload/index.html rename to image_annotation_db/ia_upload/balaji_prototype/index.html diff --git a/image_annotation_db/ia_upload/image_data/IADB_img_data_DWS_NYBG_20130404.tab - Sheet1.tsv b/image_annotation_db/ia_upload/image_data/IADB_img_data_DWS_NYBG_20130404.tab - Sheet1.tsv new file mode 100644 index 0000000..9a7ce3e --- /dev/null +++ b/image_annotation_db/ia_upload/image_data/IADB_img_data_DWS_NYBG_20130404.tab - Sheet1.tsv @@ -0,0 +1,17 @@ +filename import_location keywords ontology_term_ids species species_id curator_name curator_email curator_affiliation collection_location geo_coords collection_date ip_comment doi source_db comments +Saurauia xs Ovary.jpg / locule|ovule|pericarp|septum PO:0025266|PO:0020003|PO:0009084|PO:0025262 Saurauia sp Dennis Stevenson dws@nybg.org NYBG COLOMBIA: Boyaca: Villa de Lleva, Iguaque National Park 2500-2800 M 20070429 PlantSystematics:DOL27827 +Helleborus_argutifolius_Carpels.jpg / carpel|style PO:0009030|PO:0009074 Helleborus argutifolius Dennis Stevenson dws@nybg.org NYBG AUSTRALIA: South Australia: Botanic Gardens of Adelaide Accession G880864 20110810 PlantSystematics:DOL40035 +Yucca_schidigera_flower.jpg / anther|filament|flower|ovary|petal|sepal|stigma PO:0009066|PO:0009067|PO:0009046|PO:0009072|PO:0009032|PO:0009031|PO:0009073 Yucca schidigera Lawrence M. Kelly lkelly@nybg.org NYBG USA: California:: San Diego Co. Near Miramar NAS 20040320 PlantSystematics:DOL11866 +Gunnera_tinctoria Prickle.jpg / prickle PO:0025169 Gunnera tinctoria Dennis Stevenson dws@nybg.org NYBG DENMARK: University of Copenhagen, Botanical Garden E6139 C001 A 20080813 PlantSystematics:DOL33711 + Acacia cornigera Stipules as Spines.jpg / stipule|stipule spine PO:0020041|PO:0025174 Acacia cornigera Lawrence M. Kelly lkelly@nybg.org NYBG COSTA RICA: Guanacaste: Palo Verde 2003 PlantSystematics:DOL4821 +Bougainvillea_spectabilis Thorn.jpg / thorn PO:0025172 Bougainvillea spectabilis Dennis Stevenson dws@nybg.org NYBG CHINA: Shenzhen, Fairylake Botanical Garden 20111025 +Parmentiera_cerifera Style & Stigma.jpg / stigma|style PO:0009073|PO:0009074 Parmentiera cerifera Dennis Stevenson dws@nybg.org NYBG USA: Florida:: Dade Co. Montgomery Botanical Center  20070404 PlantSystematics:DOL27681 +Leucojum_aestivum Flower.jpg / collective tepal structure|free tepal|plant ovary|stamen|tepal PO:0025021|PO:0025136PO:0009072|PO:0009029|PO:0009033 Leucojum aestivum Dennis Stevenson dws@nybg.org NYBG USA: NY:: Tompkins Co. Mins Garden, Cornell University 20050428 PlantSystematics:DOL12340|DOL12342 +Ticodendron incognitum.jpg / shoot node|petiole|shoot internode|stipule PO:0005004|PO:0020038|PO:0005005|PO:0020041| Ticodendron incognitum Lawrence M. Kelly lkelly@nybg.org NYBG COSTA RICA: Alajuela:: San Ramon Estacion Biologica Alberto M. Brenes 2003 PlantSystematics:DOL4844 +Agave sebastiana Labelled.jpg / locule|ovule|septum PO:0025266|PO:0020003|PO:0025262 Agave sebastiana Dennis Stevenson dws@nybg.org NYBG USA: California:: Santa Barbara Co. Santa Barbara Botanic Garden 20061208 PlantSystematics:DOL26528 +Acacia mangium Phyllode.JPG / inflorescence|phyllode leaf PO:0009049|PO:0025335 Acacia mangium Dennis Stevenson dws@nybg.org NYBG VIETNAM: Vinh Phuc Province: Me Linh District, Me Linh Station of the Institute of Ecology and Biological Resources, Vietnamese Academy of Science and Technology 21 23.309 N 105 42.837 E 20051210 PlantSystematics:DOL17750 +Acacia sp Phyllode.JPG / axillary inflorescence bud|phyllode leaf PO:0004711|PO:0025335 Acacia sp Dennis Stevenson dws@nybg.org NYBG AUSTRALIA: Western Australia: Kings Park, Perth 20110805 PlantSystematics:DOL39936 +EucalyptusKingsmillii6.JPG / calyptra corolla PO:0025330 Eucalyptus kingsmillii Dennis Stevenson dws@nybg.org NYBG AUSTRALIA: Western Australia: Kings Park, Perth 20110805 PlantSystematics:DOL39933 +EucalyptusKingsmillii2.JPG / calyptra corolla PO:0025330 Eucalyptus kingsmillii Dennis Stevenson dws@nybg.org NYBG AUSTRALIA: Western Australia: Kings Park, Perth 20110805 PlantSystematics:DOL39929 +GymnocalyciumMarsoneri1.JPG / areole bud|spine leaf PO:0025353|PO:0025173 Gymnocalycium marsoneri Dennis Stevenson dws@nybg.org NYBG USA: Arizona:: Maricopa Co. Desert Botanical Garden, Phoenix 20070114 PlantSystematics:DOL26949 +Anchomanes giganteus.JPG / prickle PO:0025169 Anchomanes giganteus Dennis Stevenson dws@nybg.org NYBG GERMANY: Botanical Garden, University of Bonn. Accession No. 02608 20060924 \ No newline at end of file diff --git a/image_annotation_db/image_annotation.mwb b/image_annotation_db/sql/image_annotation.mwb similarity index 100% rename from image_annotation_db/image_annotation.mwb rename to image_annotation_db/sql/image_annotation.mwb diff --git a/image_annotation_db/image_annotation.png b/image_annotation_db/sql/image_annotation.png similarity index 100% rename from image_annotation_db/image_annotation.png rename to image_annotation_db/sql/image_annotation.png diff --git a/image_annotation_db/image_annotation.sql b/image_annotation_db/sql/image_annotation.sql similarity index 100% rename from image_annotation_db/image_annotation.sql rename to image_annotation_db/sql/image_annotation.sql diff --git a/image_annotation_db/image_annotation_v1.11.mwb b/image_annotation_db/sql/image_annotation_v1.11.mwb similarity index 100% rename from image_annotation_db/image_annotation_v1.11.mwb rename to image_annotation_db/sql/image_annotation_v1.11.mwb diff --git a/image_annotation_db/image_annotation_v1.11.png b/image_annotation_db/sql/image_annotation_v1.11.png similarity index 100% rename from image_annotation_db/image_annotation_v1.11.png rename to image_annotation_db/sql/image_annotation_v1.11.png diff --git a/image_annotation_db/image_annotation_v1_11_load.sql b/image_annotation_db/sql/image_annotation_v1_11_load.sql similarity index 100% rename from image_annotation_db/image_annotation_v1_11_load.sql rename to image_annotation_db/sql/image_annotation_v1_11_load.sql -- 2.34.1