From 515c392e2d995aa63e7609b8e5f0ffbdba7656db Mon Sep 17 00:00:00 2001 From: Kevin Bonham Date: Tue, 14 Dec 2021 15:49:17 -0500 Subject: [PATCH] add metabolite feature (#124) * add metabolite feature * remove qualifier --- src/Microbiome.jl | 10 +++++----- src/features.jl | 30 +++++++++++++++++++++++++++++- 2 files changed, 34 insertions(+), 6 deletions(-) diff --git a/src/Microbiome.jl b/src/Microbiome.jl index a95f12f..48fc8f4 100644 --- a/src/Microbiome.jl +++ b/src/Microbiome.jl @@ -4,6 +4,7 @@ module Microbiome export MicrobiomeSample, Taxon, GeneFunction, + Metabolite, metadata, set!, unset!, @@ -14,7 +15,10 @@ export MicrobiomeSample, hasrank, taxon, hastaxon, - genefunction + genefunction, + commonname, + masscharge, + retentiontime # EcoBase Translations export abundances, @@ -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") diff --git a/src/features.jl b/src/features.jl index 3e033d9..e326321 100644 --- a/src/features.jl +++ b/src/features.jl @@ -180,4 +180,32 @@ function genefunction(n::AbstractString) end end -Base.string(f::AbstractFeature) = String(f) \ No newline at end of file +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 \ No newline at end of file