module Biobase.Types.Taxonomy where
import Control.DeepSeq
import Data.Aeson
import Data.Binary
import Data.Hashable (Hashable, hashWithSalt)
import Data.Primitive.Types
import Data.Serialize
import Data.Text (Text)
import Data.Vector.Binary
import Data.Vector.Serialize
import Data.Vector.Unboxed.Deriving
import Data.Vector (Vector)
import GHC.Generics (Generic)
import Biobase.Types.Accession (Accession,Species)
import Biobase.Types.Names (SpeciesName, TaxonomicRank)
data Classification
= Kingdom
| Phylum
| Class
| Order
| SubOrder
| Family
| Genus
| Species
| Unknown
deriving (Eq,Ord,Read,Show,Enum,Generic)
instance Binary Classification
instance FromJSON Classification
instance Hashable Classification
instance Serialize Classification
instance ToJSON Classification
instance NFData Classification
derivingUnbox "Classification"
[t| Classification -> Int |] [| fromEnum |] [| toEnum |]
data Taxon = Taxon
{ species :: !SpeciesName
, accession :: !(Accession Species)
, classification :: !(Vector (TaxonomicRank,Classification))
}
deriving (Eq,Read,Show,Generic)
instance Binary Taxon
instance FromJSON Taxon
instance Serialize Taxon
instance ToJSON Taxon
instance NFData Taxon
instance Hashable Taxon where
hashWithSalt h (Taxon s a _) = hashWithSalt h (s,a)