Next changeset 1:f9d76a46799a (2019-06-14) |
Commit message:
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tools/spocc_occ commit e37f100e1c3ea68ade708868f9de3f4c0dd7e720 |
added:
spocc_occ.R spocc_occ.xml test-data/canis-lupus_gbif_bison1.tab |
b |
diff -r 000000000000 -r 724ad06de5a5 spocc_occ.R --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/spocc_occ.R Thu May 23 09:58:35 2019 -0400 |
[ |
@@ -0,0 +1,57 @@ +#!/usr/bin/Rscript + +library(spocc) + + +##Def functions : +help<-function(){ + cat("HELP\n") + cat("Spocc::occ, Search on a single species name, or many. And search across a single or many data sources.\n\n") + cat("Need 3 args :\n") + cat(" - query : (character) One to many scientific names.\n") + cat(" - from : (character) Data source to get data from, any combination of gbif, bison, inat,ebird, ecoengine and/or vertnet.\n") + cat(" - limit : (numeric) Number of records to return. This is passed across all sources.\n") + q("no") +} + +formatSpName <- function(spName) paste(strsplit(spName, split=' ')[[1]], collapse='_') ###Wallace function + +#################################### + +args = commandArgs(trailingOnly=TRUE) + +#Help display +if(args[1]=="-h" || args[1]=="--help" || length(args)<3){help()} + +#Get args +sname<-args[1] +dbase_input<-args[2] +max<-as.integer(args[3]) + +#Get all databases +bases<-strsplit(dbase_input,",") +dbase<-c() +for (base in bases){ + dbase<-c(dbase,base) +} + +#Get occurrences +results <- spocc::occ(query=sname, from=dbase, limit=max, has_coords=TRUE) + +#Dispay results +if(length(dbase)==1){ + results_data <- results[[dbase[1]]]$data[[formatSpName(sname)]] +}else{ + res <- occ2df(results) + results_data <- res +} + +results_data<-as.matrix(results_data) + +#If empty +if(length(results_data)==0){cat("\nNo occurrences found.\nLittle tip : Check your input typo, some databases are case sensitive : Genus species.\n")} + +#Write them +write.table(file="output.tab",results_data,sep="\t",row.names=FALSE) + +q('no') |
b |
diff -r 000000000000 -r 724ad06de5a5 spocc_occ.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/spocc_occ.xml Thu May 23 09:58:35 2019 -0400 |
[ |
@@ -0,0 +1,124 @@ +<tool id="spocc_occ" name="Get species occurrences data" version="0.9.0"> + <description>from GBIF, ALA, iNAT and others</description> + <requirements> + <requirement type="package" version="0.9.0">r-spocc</requirement> + </requirements> + <command detect_errors="exit_code"><![CDATA[ + Rscript '$__tool_directory__/spocc_occ.R' + '$sname' + '$from' + $limit; + + #if $from=='gbif': + sed -z -i -e 's/\n \"/ /g' -e 's/\n}/ /g' output.tab + #end if + ]]></command> + <inputs> + <param name="sname" type="text" label="Scientific name of the species" help="Genus species format, eg : Canis lupus"/> + <param name="from" type="select" multiple="true" label="Data source to get data from" help="Any combination of gbif, bison, inat, ebird, antweb, ala, idigbio, obis, ecoengine and/or vertnet" value="gbif,bison,inat"> + <option value="gbif">Global Biodiversity Information Facility : GBIF</option> + <option value="bison">Biodiversity Information Serving Our Nation : BISON</option> + <option value="inat">INaturalist : INAT</option> + <option value="ebird">eBbird</option> + <option value="antweb">AntWeb</option> + <option value="ala">Atlas of Living Australia : ALA</option> + <option value="idigbio">Integrated Digitized Biocollections : iDigBio</option> + <option value="obis">Oceanic Biogeographic Information System : OBIS</option> + <option value="ecoengine">Berkeley Ecoinformatics Engine : EcoEngine</option> + <option value="vernet">VerNet</option> + </param> + <param name="limit" type="integer" label="Number of records to return" help="This is passed across all sources" value="500"/> + </inputs> + <outputs> + <data name="output" format="tabular" from_work_dir="output.tab" label="Species occurences"/> + </outputs> + <tests> + <test> + <param name="sname" value="Canis lupus"/> + <param name="from" value="gbif,bison"/> + <param name="limit" value="50"/> + <output name="output"> + <assert_contents> + <has_text text="name"/> + <has_text text="Canis lupus"/> + <has_n_columns n="6"/> + </assert_contents> + </output> + </test> + </tests> + <help><![CDATA[ +=========================== +Get species occurences data +=========================== +**What it does** + +Search species occurences across a single or many data sources. + +| + +**How to use it** + +Enter a species scientific name, be careful that the tool is case sensitive. Eg : Canis lupus. + +Select one or more data source. It can be any combination of gbif, bison, inat, ebird, antweb, ala, idigbio, obis, ecoengine and/or vertnet. + +| + +**Output** + +The tool returns a table with the species observations available in the chosen databases. + +Output file will have the following attributes : name, longituden latitude, prov, data, key. + +prov is the datasouce and key the occurence corresponding unique identifier. + +| + +**How it works** + +This tool use the spocc R package (Spocc::occ) : + +A programmatic interface to many species occurrence data sources, including : + + - Global Biodiversity Information Facility : GBIF + https://www.gbif.org/ + + - USGSs' Biodiversity Information Serving Our Nation : BISON + https://bison.usgs.gov/#home + + - iNaturalist : iNat + https://www.inaturalist.org/, + + - eBird + https://ebird.org/home + + - Berkeley Ecoinformatics Engine : EcoEngine + https://ecoengine.berkeley.edu/ + + - AntWeb + https://www.antweb.org/ + + - Integrated Digitized Biocollections : iDigBio + https://www.idigbio.org/ + + - VertNet + http://vertnet.org/ + + - Ocean Biogeographic Information System : OBIS + https://obis.org/ + + - Atlas of Living Australia : ALA + https://www.ala.org.au/. + + +Includes functionality for retrieving species occurrence data, and combining those data. + +| + +**Sources** + +Original source : https://cran.r-project.org/web/packages/spocc/index.html + +Reference manual : https://cran.r-project.org/web/packages/spocc/spocc.pdf + ]]></help> +</tool> |
b |
diff -r 000000000000 -r 724ad06de5a5 test-data/canis-lupus_gbif_bison1.tab --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test-data/canis-lupus_gbif_bison1.tab Thu May 23 09:58:35 2019 -0400 |
b |
b'@@ -0,0 +1,101 @@\n+"name"\t"longitude"\t"latitude"\t"prov"\t"date"\t"key"\n+"Canis lupus Linnaeus, 1758"\t" 12.163912"\t" 60.28862"\t"gbif"\t"2019-01-18"\t"1988307594"\n+"Canis familiaris Linnaeus, 1758"\t" 100.405060"\t" 14.78179"\t"gbif"\t"2019-01-21"\t"2005338796"\n+"Canis lupus Linnaeus, 1758"\t" 11.048093"\t" 59.48167"\t"gbif"\t"2019-01-23"\t"2012823436"\n+"Canis lupus Linnaeus, 1758"\t" 28.973364"\t" 69.23767"\t"gbif"\t"2019-01-16"\t"2028051051"\n+"Canis lupus dingo Meyer, 1793"\t" 145.545322"\t"-16.27793"\t"gbif"\t"2019-01-19"\t"1990575442"\n+"Canis familiaris Linnaeus, 1758"\t" -78.833777"\t" 36.05233"\t"gbif"\t"2019-01-24"\t"1990576477"\n+"Canis lupus Linnaeus, 1758"\t" 11.159160"\t" 59.72548"\t"gbif"\t"2019-01-27"\t"1990656034"\n+"Canis familiaris Linnaeus, 1758"\t" 74.792893"\t" 13.35156"\t"gbif"\t"2019-01-07"\t"1986608286"\n+"Canis lupus Linnaeus, 1758"\t" 11.000690"\t" 59.53739"\t"gbif"\t"2019-01-19"\t"1988307939"\n+"Canis familiaris Linnaeus, 1758"\t"-117.216541"\t" 33.98280"\t"gbif"\t"2019-01-20"\t"2005276886"\n+"Canis familiaris Linnaeus, 1758"\t" -97.673194"\t" 28.42286"\t"gbif"\t"2019-01-23"\t"1990570437"\n+"Canis lupus Linnaeus, 1758"\t" 11.047684"\t" 59.48154"\t"gbif"\t"2019-01-23"\t"2006001212"\n+"Canis lupus lycaon Schreber, 1775"\t" -78.401972"\t" 45.57230"\t"gbif"\t"2019-01-02"\t"1986610881"\n+"Canis familiaris Linnaeus, 1758"\t"-101.629497"\t" 37.12117"\t"gbif"\t"2019-01-10"\t"1990470069"\n+"Canis lupus Linnaeus, 1758"\t" 9.030524"\t" 44.74131"\t"gbif"\t"2019-01-12"\t"1990488501"\n+"Canis lupus Linnaeus, 1758"\t" -93.110484"\t" 45.40214"\t"gbif"\t"2019-01-17"\t"1993718245"\n+"Canis lupus Linnaeus, 1758"\t" 12.003221"\t" 61.36278"\t"gbif"\t"2019-01-01"\t"2028051584"\n+"Canis familiaris Linnaeus, 1758"\t"-121.098885"\t" 37.08132"\t"gbif"\t"2019-01-28"\t"1993725010"\n+"Canis lupus Linnaeus, 1758"\t" 7.619356"\t" 45.69360"\t"gbif"\t"2019-01-03"\t"2236240391"\n+"Canis familiaris Linnaeus, 1758"\t" 8.252381"\t" 51.48241"\t"gbif"\t"2019-01-21"\t"1989765540"\n+"Canis lupus Linnaeus, 1758"\t" 7.030619"\t" 45.16022"\t"gbif"\t"2019-01-04"\t"1986578666"\n+"Canis lupus Linnaeus, 1758"\t" 11.771043"\t" 60.79850"\t"gbif"\t"2019-01-27"\t"1989766089"\n+"Canis lupus Linnaeus, 1758"\t" 11.009331"\t" 59.86555"\t"gbif"\t"2019-01-21"\t"1989766220"\n+"Canis lupus Linnaeus, 1758"\t" 11.024379"\t" 59.71250"\t"gbif"\t"2019-01-17"\t"1988308206"\n+"Canis lupus Linnaeus, 1758"\t" 11.683887"\t" 59.69185"\t"gbif"\t"2019-01-23"\t"1989766131"\n+"Canis lupus Linnaeus, 1758"\t" -93.337121"\t" 45.51879"\t"gbif"\t"2019-01-26"\t"1990625756"\n+"Canis lupus Linnaeus, 1758"\t" 10.340948"\t" 63.10199"\t"gbif"\t"2019-01-19"\t"2028054300"\n+"Canis familiaris Linnaeus, 1758"\t" -85.648400"\t" 32.44466"\t"gbif"\t"2019-01-22"\t"1993716904"\n+"Canis lupus Linnaeus, 1758"\t" 10.920536"\t" 59.58577"\t"gbif"\t"2019-01-10"\t"1988308000"\n+"Canis familiaris Linnaeus, 1758"\t" -85.646839"\t" 32.44423"\t"gbif"\t"2019-01-22"\t"2237420714"\n+"Canis lupus Linnaeus, 1758"\t" 10.994740"\t" 59.85693"\t"gbif"\t"2019-01-22"\t"1989766129"\n+"Canis lupus Linnaeus, 1758"\t"-113.686295"\t" 47.46992"\t"gbif"\t"2019-01-26"\t"1993733922"\n+"Canis lupus Linnaeus, 1758"\t" 11.329828"\t" 59.55214"\t"gbif"\t"2019-01-10"\t"1988307663"\n+"Canis lupus Linnaeus, 1758"\t" 12.037582"\t" 61.38100"\t"gbif"\t"2019-01-01"\t"2028051614"\n+"Canis familiaris Linnaeus, 1758"\t" 6.627318"\t" 50.70491"\t"gbif"\t"2019-01-03"\t"1984208185"\n+"Canis familiaris Linnaeus, 1758"\t" 120.602292"\t" 23.99870"\t"gbif"\t"2019-01-24"\t"1990574963"\n+"Canis familiaris Linnaeus, 1758"\t" 47.806338"\t" 30.47966"\t"gbif"\t"2019-01-07"\t"2005345445"\n+"Canis familiaris Linnaeus, 1758"\t" 11.450637"\t" 48.38851"\t"gbif"\t"2019-01-31"\t"1990656210"\n+"Canis familiaris Linnaeus, 1758"\t" 8.352727"\t" 49.68351"\t"gbif"\t"2019-01-12"\t"1988294116"\n+"Canis lupus Linnaeus, 1758"\t" 28.852713"\t" 69.22144"\t"gbif"\t"2019-01-05"\t"2028042974"\n+"Canis lupus Linnaeus, 1758"\t" 10.920496"\t" 59.58575"\t"gbif"\t"2019-01-10"\t"1988307998"\n+"Canis lupus Linnaeus, 1758"\t" 11.770231"\t" 60.79854"\t"gbif"\t"2019-01-27"\t"1989766090"\n+"Canis familiaris Linnaeus, 1758"\t" -17.776737"\t" 28.61137"\t"gbif"\t"2019-01-08"\t"1988294122"\n+"Canis lupus'..b'5227"\t"gbif"\t"2019-01-01"\t"1984208113"\n+"Canis familiaris Linnaeus, 1758"\t"-101.629348"\t" 37.12143"\t"gbif"\t"2019-01-10"\t"1986628708"\n+"Canis lupus baileyi Nelson & Goldman, 1929"\t" -85.149113"\t" 42.24575"\t"gbif"\t"2019-01-17"\t"1989894063"\n+"Canis lupus Linnaeus, 1758"\t" 11.080055"\t" 59.72776"\t"gbif"\t"2019-01-23"\t"1989766095"\n+"Canis familiaris Linnaeus, 1758"\t" 108.263023"\t" 16.00398"\t"gbif"\t"2019-01-22"\t"1990559572"\n+"Canis lupus"\t" -94.218414"\t" 35.97121"\t"bison"\t"1957-01-01"\t"919969407"\n+"Canis lupus"\t" -92.678590"\t" 36.26666"\t"bison"\t"1972-01-09"\t"919969412"\n+"Canis lupus"\t" -92.140495"\t" 35.85699"\t"bison"\t"1970-01-01"\t"919969420"\n+"Canis lupus"\t" -94.274990"\t" 35.19698"\t"bison"\tNA\t"919969655"\n+"Canis lupus"\t" -94.274990"\t" 35.19698"\t"bison"\t"1970-01-01"\t"919969656"\n+"Canis lupus"\t" -92.689250"\t" 35.26570"\t"bison"\t"1970-07-06"\t"919969664"\n+"Canis lupus"\t" -90.779290"\t" 34.77975"\t"bison"\t"1970-07-21"\t"919969665"\n+"Canis lupus"\t" -94.218414"\t" 35.97121"\t"bison"\t"1970-01-01"\t"919969666"\n+"Canis lupus"\t" -93.031530"\t" 35.45530"\t"bison"\t"1968-08-15"\t"919969671"\n+"Canis lupus"\t" -94.256190"\t" 36.33783"\t"bison"\t"1968-10-16"\t"919969689"\n+"Canis lupus"\t" -94.274990"\t" 35.19698"\t"bison"\tNA\t"919969690"\n+"Canis lupus"\t" -92.140495"\t" 35.85699"\t"bison"\t"1970-01-01"\t"919969694"\n+"Canis lupus"\t" -91.722780"\t" 33.58724"\t"bison"\t"1970-04-06"\t"919969702"\n+"Canis lupus"\t" -93.408300"\t" 34.99771"\t"bison"\t"1970-06-15"\t"919969708"\n+"Canis lupus"\t" -95.393036"\t" 29.85727"\t"bison"\tNA\t"919969805"\n+"Canis lupus"\t" -94.218414"\t" 35.97121"\t"bison"\t"1972-01-01"\t"919969833"\n+"Canis lupus"\t" -94.218414"\t" 35.97121"\t"bison"\t"1949-11-11"\t"919969859"\n+"Canis lupus"\t" -92.140495"\t" 35.85699"\t"bison"\t"1936-04-01"\t"919969875"\n+"Canis lupus"\t" -93.720566"\t" 35.21855"\t"bison"\t"1950-11-29"\t"919969879"\n+"Canis lupus"\t" -94.218414"\t" 35.97121"\t"bison"\t"1949-12-19"\t"919969896"\n+"Canis lupus"\t" -91.203316"\t" 34.67951"\t"bison"\t"1970-03-18"\t"919969918"\n+"Canis lupus"\t" -91.101150"\t" 36.04110"\t"bison"\t"1951-07-20"\t"919969956"\n+"Canis lupus"\t" -94.766080"\t" 34.11707"\t"bison"\t"1936-03-24"\t"919970090"\n+"Canis lupus"\t" -94.766080"\t" 34.11707"\t"bison"\t"1936-07-04"\t"919970107"\n+"Canis lupus"\tNA\tNA\t"bison"\tNA\t"919970259"\n+"Canis lupus"\t" -93.720566"\t" 35.21855"\t"bison"\t"1975-12-15"\t"919970279"\n+"Canis lupus"\tNA\tNA\t"bison"\tNA\t"919970291"\n+"Canis lupus"\t" -94.808205"\t" 36.39337"\t"bison"\t"1988-12-14"\t"919972484"\n+"Canis lupus"\t" -94.808205"\t" 36.39337"\t"bison"\tNA\t"919972528"\n+"Canis lupus"\t" -94.256190"\t" 36.33783"\t"bison"\t"1988-02-19"\t"919972597"\n+"Canis lupus"\t" -92.515976"\t" 35.58296"\t"bison"\t"1969-06-06"\t"919973097"\n+"Canis lupus"\t" -91.280140"\t" 47.35155"\t"bison"\t"2017-11-02"\t"1806350848"\n+"Canis lupus"\t" -95.261180"\t" 47.35066"\t"bison"\t"2018-01-19"\t"1806334455"\n+"Canis lupus"\t"-125.546340"\t" 48.94160"\t"bison"\t"2017-05-19"\t"1562977820"\n+"Canis lupus"\t"-110.392006"\t" 44.52775"\t"bison"\t"2011-07-15"\t"1848809578"\n+"Canis lupus"\t"-110.191980"\t" 44.93100"\t"bison"\t"2012-07-21"\t"1848805186"\n+"Canis lupus"\t" -78.560486"\t" 45.56983"\t"bison"\t"2000-07-19"\t"920908694"\n+"Canis lupus"\t" -78.560486"\t" 45.56983"\t"bison"\t"2000-07-20"\t"920921836"\n+"Canis lupus"\t" -94.137210"\t" 58.69291"\t"bison"\t"2010-06-07"\t"920989000"\n+"Canis lupus"\t"-130.648040"\t" 60.09208"\t"bison"\t"1967-06-01"\t"876159279"\n+"Canis lupus"\t" -96.000000"\t" 42.00000"\t"bison"\tNA\t"36231929"\n+"Canis lupus"\t"-103.900000"\t" 50.80000"\t"bison"\tNA\t"36231931"\n+"Canis lupus"\t" -84.830000"\t" 34.15000"\t"bison"\tNA\t"36232359"\n+"Canis lupus"\t"-145.532780"\t" 62.91389"\t"bison"\t"1968-12-01"\t"202062196"\n+"Canis lupus"\t"-114.295815"\t" 48.24529"\t"bison"\t"2000-09-03"\t"1147030583"\n+"Canis lupus"\t" -76.473480"\t" 42.45300"\t"bison"\t"1975-05-11"\t"1147032515"\n+"Canis lupus"\t"-114.295815"\t" 48.24529"\t"bison"\t"2000-09-03"\t"1147034599"\n+"Canis lupus"\t"-114.295815"\t" 48.24529"\t"bison"\t"2000-09-03"\t"1147040577"\n+"Canis lupus"\t" -76.473480"\t" 42.45300"\t"bison"\t"1975-05-09"\t"1147041973"\n+"Canis lupus"\t" -76.473480"\t" 42.45300"\t"bison"\t"1975-03-12"\t"1147042200"\n' |