-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into tpoisot/issue23
- Loading branch information
Showing
6 changed files
with
153 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
function _divisionfinder(division::Symbol) | ||
nodes_subset = select(NCBITaxonomy.nodes_table, [:tax_id, :division_code]) | ||
filter!((r) -> r.division_code == division, nodes_subset) | ||
df = leftjoin(nodes_subset, NCBITaxonomy.names_table; on=:tax_id) | ||
return namefinder(df) | ||
end | ||
|
||
function _divisionfinder(division::Vector{Symbol}) | ||
nodes_subset = select(NCBITaxonomy.nodes_table, [:tax_id, :division_code]) | ||
filter!((r) -> r.division_code in division, nodes_subset) | ||
df = leftjoin(nodes_subset, NCBITaxonomy.names_table; on=:tax_id) | ||
return namefinder(df) | ||
end | ||
|
||
""" | ||
virusfinder() | ||
Returns a `namefinder` limited to the viral division of the NCBI taxonomy. See | ||
the documentation for `namefinder` and `taxid` for more information about | ||
arguments. | ||
""" | ||
virusfinder() = _divisionfinder(:VRL) | ||
|
||
""" | ||
bacteriafinder() | ||
Returns a `namefinder` limited to the bacterial division of the NCBI taxonomy. See | ||
the documentation for `namefinder` and `taxid` for more information about | ||
arguments. | ||
""" | ||
bacteriafinder() = _divisionfinder(:BCT) | ||
|
||
""" | ||
plantfinder() | ||
Returns a `namefinder` limited to the "plant and fungi" division of the NCBI | ||
taxonomy. See the documentation for `namefinder` and `taxid` for more | ||
information about arguments. | ||
""" | ||
plantfinder() = _divisionfinder(:PLN) | ||
|
||
""" | ||
primatefinder() | ||
Returns a `namefinder` limited to the primate division of the NCBI taxonomy. See | ||
the documentation for `namefinder` and `taxid` for more information about | ||
arguments. | ||
""" | ||
primatefinder() = _divisionfinder(:PRI) | ||
|
||
""" | ||
rodentfinder() | ||
Returns a `namefinder` limited to the rodent division of the NCBI | ||
taxonomy. See the documentation for `namefinder` and `taxid` for more | ||
information about arguments. | ||
""" | ||
rodentfinder() = _divisionfinder(:ROD) | ||
|
||
""" | ||
mammalfinder(;inclusive::Bool=true) | ||
Returns a `namefinder` limited to the mammal division of the NCBI taxonomy. See | ||
the documentation for `namefinder` and `taxid` for more information about | ||
arguments. | ||
If the keyword argument `inclusive` is set to `false`, this will *not* search | ||
for organisms assigned to a lower division, in this case rodents (covered by | ||
`rodentfinder`) and primates (covered by `primatefinder`). The default behavior | ||
is to include these groups. | ||
""" | ||
mammalfinder(inclusive::Bool=true) = inclusive ? _divisionfinder([:MAM, :ROD, :PRI]) : _divisionfinder(:MAM) | ||
|
||
""" | ||
vertebratefinder(;inclusive::Bool=true) | ||
Returns a `namefinder` limited to the vertebrate division of the NCBI taxonomy. | ||
See the documentation for `namefinder` and `taxid` for more information about | ||
arguments. | ||
If the keyword argument `inclusive` is set to `false`, this will *not* search | ||
for organisms assigned to a lower division, in this case mammals (covered by | ||
`mammalfinder`). The default behavior is to include these groups, which also | ||
include the groups covered by `mammalfinder` itself. | ||
""" | ||
vertebratefinder(inclusive::Bool=true) = inclusive ? _divisionfinder([:VRT, :MAM, :ROD, :PRI]) : _divisionfinder(:VRT) | ||
|
||
""" | ||
invertebratefinder() | ||
Returns a `namefinder` limited to the invertebrate division of the NCBI taxonomy. See | ||
the documentation for `namefinder` and `taxid` for more information about | ||
arguments. | ||
Note that this is limited organisms not covered by `plantfinder`, | ||
`bacteriafinder`, and `virusfinder`. | ||
""" | ||
invertebratefinder() = _divisionfinder(:INV) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
module TestDivisionFinders | ||
|
||
using Test | ||
using NCBITaxonomy | ||
|
||
@test typeof(virusfinder()("Ebolavirus")) <: NCBITaxon | ||
@test typeof(plantfinder()("Acer")) <: NCBITaxon | ||
@test isnothing(mammalfinder(false)("Homo")) | ||
@test isnothing(mammalfinder(false)("Mus")) | ||
@test !isnothing(mammalfinder(true)("Mus")) | ||
@test !isnothing(rodentfinder()("Mus")) | ||
@test isnothing(vertebratefinder(false)("Homo")) | ||
@test !isnothing(vertebratefinder(true)("Homo")) | ||
@test !isnothing(primatefinder()("Homo")) | ||
@test !isnothing(vertebratefinder(true)("Homo")) | ||
@test !isnothing(bacteriafinder()("Pseudomonas")) | ||
@test !isnothing(invertebratefinder()("Lamellodiscus")) | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters