Skip to content

Commit

Permalink
Merge pull request #28 from EcoJulia/feature-nearest
Browse files Browse the repository at this point in the history
Improve synonyms functions
  • Loading branch information
tpoisot authored Feb 9, 2021
2 parents 0859f41 + 919f03c commit c54e4ab
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "NCBITaxonomy"
uuid = "f88b31d2-eb98-4433-b52d-2dd32bc6efce"
authors = ["Timothée Poisot <[email protected]>"]
version = "0.0.6"
version = "0.0.7"

[deps]
Arrow = "69666777-d1a9-59fb-9406-91d4454c9d45"
Expand Down
1 change: 1 addition & 0 deletions docs/src/namefinding.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
```@docs
taxid
vernacular
synonyms
```

The `taxid` function will return a `NCBITaxon` object, which has two fields:
Expand Down
4 changes: 2 additions & 2 deletions src/NCBITaxonomy.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
13 changes: 13 additions & 0 deletions src/vernacular.jl → src/nametools.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 4 additions & 0 deletions test/taxid.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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

2 comments on commit c54e4ab

@tpoisot
Copy link
Member Author

@tpoisot tpoisot commented on c54e4ab Feb 9, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator register()

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/29731

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.0.7 -m "<description of version>" c54e4ab80272c44761257077172e1031f9ec0c6e
git push origin v0.0.7

Please sign in to comment.