module Biobase.Secondary where
import Data.Primitive.Types
import qualified Data.Vector.Generic as VG
import qualified Data.Vector.Generic.Mutable as VGM
import qualified Data.Vector.Unboxed as VU
import Data.Ix (Ix(..))
import Data.Tuple (swap)
import Biobase.Primary
import Biobase.Primary.Bounds
type PairIdx = (Int,Int)
type Pair = (Nuc,Nuc)
type ExtPairAnnotation = (CTisomerism,Edge,Edge)
type ExtPairIdx = (PairIdx,ExtPairAnnotation)
type ExtPair = (Pair,ExtPairAnnotation)
newtype Edge = Edge {unEdge :: Int}
deriving (Eq,Ord,Ix)
(wc : sugar : hoogsteen : unknownEdge : _) = map Edge [0..]
charEdgeList =
[ ('W',wc)
, ('S',sugar)
, ('H',hoogsteen)
, ('?',unknownEdge)
]
edgeCharList = map swap charEdgeList
instance Show Edge where
show k
| Just v <- k `lookup` edgeCharList = [v]
| otherwise = "?"
instance Read Edge where
readsPrec p [] = []
readsPrec p (x:xs)
| x ==' ' = readsPrec p xs
| Just n <- x `lookup` charEdgeList = [(n,xs)]
| otherwise = []
newtype CTisomerism = CT {unCT :: Int}
deriving (Eq,Ord,Ix)
(cis : trans : unknownCT : _) = map CT [0..]
antiCT = undefined
paraCT = undefined
charCTList =
[ ('C',cis)
, ('T',trans)
]
ctCharList = map swap charCTList
instance Show CTisomerism where
show k
| Just v <- k `lookup` ctCharList = [v]
| otherwise = "?"
instance Read CTisomerism where
readsPrec p [] = []
readsPrec p (x:xs)
| x ==' ' = readsPrec p xs
| Just n <- x `lookup` charCTList = [(n,xs)]
| otherwise = []
deriving instance Prim Edge
deriving instance VGM.MVector VU.MVector Edge
deriving instance VG.Vector VU.Vector Edge
deriving instance VU.Unbox Edge
instance Bounded Edge where
minBound = wc
maxBound = unknownEdge
instance Bounds Edge where
minNormal = wc
maxNormal = wc
minExtended = wc
maxExtended = hoogsteen
instance Enum Edge where
toEnum = Edge
fromEnum = unEdge
deriving instance Prim CTisomerism
deriving instance VGM.MVector VU.MVector CTisomerism
deriving instance VG.Vector VU.Vector CTisomerism
deriving instance VU.Unbox CTisomerism
instance Bounded CTisomerism where
minBound = cis
maxBound = unknownCT
instance Bounds CTisomerism where
minNormal = cis
maxNormal = cis
minExtended = cis
maxExtended = trans
instance Enum CTisomerism where
toEnum = CT
fromEnum = unCT
instance Show (CTisomerism,Edge,Edge) where
show (ct,eI,eJ) = concat [show ct, show eI, show eJ]