Skip to content

Commit

Permalink
add metabolite feature (#124)
Browse files Browse the repository at this point in the history
* add metabolite feature

* remove qualifier
  • Loading branch information
kescobo authored Dec 14, 2021
1 parent bc74fdc commit 515c392
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 6 deletions.
10 changes: 5 additions & 5 deletions src/Microbiome.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ module Microbiome
export MicrobiomeSample,
Taxon,
GeneFunction,
Metabolite,
metadata,
set!,
unset!,
Expand All @@ -14,7 +15,10 @@ export MicrobiomeSample,
hasrank,
taxon,
hastaxon,
genefunction
genefunction,
commonname,
masscharge,
retentiontime

# EcoBase Translations
export abundances,
Expand Down Expand Up @@ -76,10 +80,6 @@ using ReTest
import Dictionaries: set!, unset!, insert!, delete!
import Base: ==

@testset "test" begin
@test true
end

include("ecobase.jl")
include("samples.jl")
include("features.jl")
Expand Down
30 changes: 29 additions & 1 deletion src/features.jl
Original file line number Diff line number Diff line change
Expand Up @@ -180,4 +180,32 @@ function genefunction(n::AbstractString)
end
end

Base.string(f::AbstractFeature) = String(f)
Base.string(f::AbstractFeature) = String(f)

struct Metabolite <: AbstractFeature
name::String
commonname::Union{Missing, String}
mz::Union{Missing, Float64}
rt::Union{Missing, Float64}
end

Metabolite(n::AbstractString) = Metabolite(n, missing, missing, missing)

name(m::Metabolite) = m.name
commonname(m::Metabolite) = m.commonname
masscharge(m::Metabolite) = m.mz
retentiontime(m::Metabolite) = m.rt

@testset "Metabolites" begin
m1 = Metabolite("name", "common", 1., 1.)
@test name(m1) == "name"
@test commonname(m1) == "common"
@test masscharge(m1) == 1
@test retentiontime(m1) == 1
m2 = Metabolite("name")
@test name(m2) == "name"
@test ismissing(commonname(m2))
@test ismissing(masscharge(m2))
@test ismissing(masscharge(m2))

end

0 comments on commit 515c392

Please sign in to comment.