diff --git a/Project.toml b/Project.toml index 4b54251..3e29a89 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "NCBITaxonomy" uuid = "f88b31d2-eb98-4433-b52d-2dd32bc6efce" authors = ["Timothée Poisot "] -version = "0.0.6" +version = "0.0.7" [deps] Arrow = "69666777-d1a9-59fb-9406-91d4454c9d45" diff --git a/docs/src/namefinding.md b/docs/src/namefinding.md index 165c553..2d9f14d 100644 --- a/docs/src/namefinding.md +++ b/docs/src/namefinding.md @@ -5,6 +5,7 @@ ```@docs taxid vernacular +synonyms ``` The `taxid` function will return a `NCBITaxon` object, which has two fields: diff --git a/src/NCBITaxonomy.jl b/src/NCBITaxonomy.jl index 6544374..257222c 100644 --- a/src/NCBITaxonomy.jl +++ b/src/NCBITaxonomy.jl @@ -43,7 +43,7 @@ export children, descendants include("lineage.jl") export lineage, parent, rank -include("vernacular.jl") -export vernacular +include("nametools.jl") +export vernacular, synonyms end diff --git a/src/vernacular.jl b/src/nametools.jl similarity index 62% rename from src/vernacular.jl rename to src/nametools.jl index 94586a3..441b76d 100644 --- a/src/vernacular.jl +++ b/src/nametools.jl @@ -12,4 +12,17 @@ function vernacular(t::NCBITaxon) all_names = vcat(common_names.name, genbank_names.name) length(all_names) == 0 && return nothing return unique(all_names) +end + +""" + synonyms(t::NCBITaxon) + +This function will return `nothing` if no synonyms exist, and an array of names +if they do. It returns all of the +""" +function synonyms(t::NCBITaxon) + names_from_tax = filter(r -> r.tax_id == t.id, NCBITaxonomy.names_table) + syn = filter(r -> r.class == NCBITaxonomy.class_synonym, names_from_tax) + size(syn,1) == 0 && return nothing + return unique(syn.name) end \ No newline at end of file diff --git a/test/taxid.jl b/test/taxid.jl index efc14c3..cd49977 100644 --- a/test/taxid.jl +++ b/test/taxid.jl @@ -46,4 +46,8 @@ module TestTaxid # Vernacular missing @test isnothing(vernacular(ncbi"Lamellodiscus elegans")) + # Synonyms + @test "Bos bovis" in synonyms(ncbi"Bos taurus") + @test isnothing(synonyms(ncbi"Lamellodiscus elegans")) + end