{-# LANGUAGE UndecidableInstances #-}
module Bio.Sequence.Class
(
SequenceDecodable (..)
, Sequence
, WeightedSequence
, MarkedSequence
, BareSequence
, Range
, sequ
, markings
, weights
, bareSequ
, IsMarking
, IsWeight (..)
, IsSequence (..)
, IsWeightedSequence
, IsMarkedSequence
, IsBareSequence
, ContainsMarking
, ContainsNoMarking
, ContainsWeight
, ContainsNoWeight
, createSequence
, unsafeCreateSequence
, bareSequence
, weightedSequence
, unsafeWeightedSequence
, markedSequence
, unsafeMarkedSequence
, _sequenceInner
) where
import Bio.Sequence.Utilities (Range, checkRange, unsafeEither)
import Control.Lens
import Control.Monad.Except (MonadError, throwError)
import Data.Kind (Constraint)
import qualified Data.List as L (length, null)
import Data.Text (Text)
import Data.Vector (Vector)
import qualified Data.Vector as V (fromList, length)
import GHC.Generics (Generic)
import GHC.TypeLits (ErrorMessage (..), TypeError)
data Sequence mk w a = Sequence { Sequence mk w a -> Vector a
_sequ :: Vector a
, Sequence mk w a -> [(mk, Range)]
_markings :: [(mk, Range)]
, Sequence mk w a -> Vector w
_weights :: Vector w
}
deriving (Sequence mk w a -> Sequence mk w a -> Bool
(Sequence mk w a -> Sequence mk w a -> Bool)
-> (Sequence mk w a -> Sequence mk w a -> Bool)
-> Eq (Sequence mk w a)
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
forall mk w a.
(Eq a, Eq mk, Eq w) =>
Sequence mk w a -> Sequence mk w a -> Bool
/= :: Sequence mk w a -> Sequence mk w a -> Bool
$c/= :: forall mk w a.
(Eq a, Eq mk, Eq w) =>
Sequence mk w a -> Sequence mk w a -> Bool
== :: Sequence mk w a -> Sequence mk w a -> Bool
$c== :: forall mk w a.
(Eq a, Eq mk, Eq w) =>
Sequence mk w a -> Sequence mk w a -> Bool
Eq, Int -> Sequence mk w a -> ShowS
[Sequence mk w a] -> ShowS
Sequence mk w a -> String
(Int -> Sequence mk w a -> ShowS)
-> (Sequence mk w a -> String)
-> ([Sequence mk w a] -> ShowS)
-> Show (Sequence mk w a)
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
forall mk w a.
(Show a, Show mk, Show w) =>
Int -> Sequence mk w a -> ShowS
forall mk w a.
(Show a, Show mk, Show w) =>
[Sequence mk w a] -> ShowS
forall mk w a.
(Show a, Show mk, Show w) =>
Sequence mk w a -> String
showList :: [Sequence mk w a] -> ShowS
$cshowList :: forall mk w a.
(Show a, Show mk, Show w) =>
[Sequence mk w a] -> ShowS
show :: Sequence mk w a -> String
$cshow :: forall mk w a.
(Show a, Show mk, Show w) =>
Sequence mk w a -> String
showsPrec :: Int -> Sequence mk w a -> ShowS
$cshowsPrec :: forall mk w a.
(Show a, Show mk, Show w) =>
Int -> Sequence mk w a -> ShowS
Show, (forall x. Sequence mk w a -> Rep (Sequence mk w a) x)
-> (forall x. Rep (Sequence mk w a) x -> Sequence mk w a)
-> Generic (Sequence mk w a)
forall x. Rep (Sequence mk w a) x -> Sequence mk w a
forall x. Sequence mk w a -> Rep (Sequence mk w a) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall mk w a x. Rep (Sequence mk w a) x -> Sequence mk w a
forall mk w a x. Sequence mk w a -> Rep (Sequence mk w a) x
$cto :: forall mk w a x. Rep (Sequence mk w a) x -> Sequence mk w a
$cfrom :: forall mk w a x. Sequence mk w a -> Rep (Sequence mk w a) x
Generic, a -> Sequence mk w b -> Sequence mk w a
(a -> b) -> Sequence mk w a -> Sequence mk w b
(forall a b. (a -> b) -> Sequence mk w a -> Sequence mk w b)
-> (forall a b. a -> Sequence mk w b -> Sequence mk w a)
-> Functor (Sequence mk w)
forall a b. a -> Sequence mk w b -> Sequence mk w a
forall a b. (a -> b) -> Sequence mk w a -> Sequence mk w b
forall mk w a b. a -> Sequence mk w b -> Sequence mk w a
forall mk w a b. (a -> b) -> Sequence mk w a -> Sequence mk w b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
<$ :: a -> Sequence mk w b -> Sequence mk w a
$c<$ :: forall mk w a b. a -> Sequence mk w b -> Sequence mk w a
fmap :: (a -> b) -> Sequence mk w a -> Sequence mk w b
$cfmap :: forall mk w a b. (a -> b) -> Sequence mk w a -> Sequence mk w b
Functor)
instance Semigroup (Sequence mk w a) where
Sequence mk w a
sequA <> :: Sequence mk w a -> Sequence mk w a -> Sequence mk w a
<> Sequence mk w a
sequB = Sequence mk w a
res
where
newSequ :: Vector a
newSequ = Sequence mk w a
sequA Sequence mk w a
-> Getting (Vector a) (Sequence mk w a) (Vector a) -> Vector a
forall s a. s -> Getting a s a -> a
^. Getting (Vector a) (Sequence mk w a) (Vector a)
forall mk w a. Getter (Sequence mk w a) (Vector a)
sequ Vector a -> Vector a -> Vector a
forall a. Semigroup a => a -> a -> a
<> Sequence mk w a
sequB Sequence mk w a
-> Getting (Vector a) (Sequence mk w a) (Vector a) -> Vector a
forall s a. s -> Getting a s a -> a
^. Getting (Vector a) (Sequence mk w a) (Vector a)
forall mk w a. Getter (Sequence mk w a) (Vector a)
sequ
newMarkings :: [(mk, Range)]
newMarkings = Sequence mk w a
sequA Sequence mk w a
-> Getting [(mk, Range)] (Sequence mk w a) [(mk, Range)]
-> [(mk, Range)]
forall s a. s -> Getting a s a -> a
^. Getting [(mk, Range)] (Sequence mk w a) [(mk, Range)]
forall mk w a. Getter (Sequence mk w a) [(mk, Range)]
markings [(mk, Range)] -> [(mk, Range)] -> [(mk, Range)]
forall a. Semigroup a => a -> a -> a
<> ((mk, Range) -> (mk, Range)) -> [(mk, Range)] -> [(mk, Range)]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ((Range -> Range) -> (mk, Range) -> (mk, Range)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ((Int -> Int) -> (Int -> Int) -> Range -> Range
forall (p :: * -> * -> *) a b c d.
Bifunctor p =>
(a -> b) -> (c -> d) -> p a c -> p b d
bimap Int -> Int
addInd Int -> Int
addInd)) (Sequence mk w a
sequB Sequence mk w a
-> Getting [(mk, Range)] (Sequence mk w a) [(mk, Range)]
-> [(mk, Range)]
forall s a. s -> Getting a s a -> a
^. Getting [(mk, Range)] (Sequence mk w a) [(mk, Range)]
forall mk w a. Getter (Sequence mk w a) [(mk, Range)]
markings)
newWeights :: Vector w
newWeights = Sequence mk w a
sequA Sequence mk w a
-> Getting (Vector w) (Sequence mk w a) (Vector w) -> Vector w
forall s a. s -> Getting a s a -> a
^. Getting (Vector w) (Sequence mk w a) (Vector w)
forall mk w a. Getter (Sequence mk w a) (Vector w)
weights Vector w -> Vector w -> Vector w
forall a. Semigroup a => a -> a -> a
<> Sequence mk w a
sequB Sequence mk w a
-> Getting (Vector w) (Sequence mk w a) (Vector w) -> Vector w
forall s a. s -> Getting a s a -> a
^. Getting (Vector w) (Sequence mk w a) (Vector w)
forall mk w a. Getter (Sequence mk w a) (Vector w)
weights
res :: Sequence mk w a
res = Vector a -> [(mk, Range)] -> Vector w -> Sequence mk w a
forall mk w a.
Vector a -> [(mk, Range)] -> Vector w -> Sequence mk w a
Sequence Vector a
newSequ [(mk, Range)]
newMarkings Vector w
newWeights
addInd :: Int -> Int
addInd :: Int -> Int
addInd = (Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Vector a -> Int
forall a. Vector a -> Int
V.length (Sequence mk w a
sequA Sequence mk w a
-> Getting (Vector a) (Sequence mk w a) (Vector a) -> Vector a
forall s a. s -> Getting a s a -> a
^. Getting (Vector a) (Sequence mk w a) (Vector a)
forall mk w a. Getter (Sequence mk w a) (Vector a)
sequ))
instance Monoid (Sequence mk () a) where
mempty :: Sequence mk () a
mempty = Vector a -> [(mk, Range)] -> Vector () -> Sequence mk () a
forall mk w a.
Vector a -> [(mk, Range)] -> Vector w -> Sequence mk w a
Sequence Vector a
forall a. Monoid a => a
mempty [(mk, Range)]
forall a. Monoid a => a
mempty Vector ()
forall a. Monoid a => a
mempty
instance Foldable (Sequence mk w) where
foldMap :: (a -> m) -> Sequence mk w a -> m
foldMap a -> m
f = (a -> m) -> Vector a -> m
forall (t :: * -> *) m a.
(Foldable t, Monoid m) =>
(a -> m) -> t a -> m
foldMap a -> m
f (Vector a -> m)
-> (Sequence mk w a -> Vector a) -> Sequence mk w a -> m
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Sequence mk w a -> Vector a
forall mk w a. Sequence mk w a -> Vector a
_sequ
length :: Sequence mk w a -> Int
length = Vector a -> Int
forall a. Vector a -> Int
V.length (Vector a -> Int)
-> (Sequence mk w a -> Vector a) -> Sequence mk w a -> Int
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Sequence mk w a -> Vector a
forall mk w a. Sequence mk w a -> Vector a
_sequ
instance Traversable (Sequence mk w) where
traverse :: (a -> f b) -> Sequence mk w a -> f (Sequence mk w b)
traverse a -> f b
f s :: Sequence mk w a
s@Sequence{[(mk, Range)]
Vector w
Vector a
_weights :: Vector w
_markings :: [(mk, Range)]
_sequ :: Vector a
_weights :: forall mk w a. Sequence mk w a -> Vector w
_markings :: forall mk w a. Sequence mk w a -> [(mk, Range)]
_sequ :: forall mk w a. Sequence mk w a -> Vector a
..} = (\Vector b
newSeq -> Sequence mk w a
s { _sequ :: Vector b
_sequ = Vector b
newSeq }) (Vector b -> Sequence mk w b)
-> f (Vector b) -> f (Sequence mk w b)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (a -> f b) -> Vector a -> f (Vector b)
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse a -> f b
f Vector a
_sequ
_sequenceInner :: Vector a -> [(mk, Range)] -> Vector w -> Sequence mk w a
_sequenceInner :: Vector a -> [(mk, Range)] -> Vector w -> Sequence mk w a
_sequenceInner = Vector a -> [(mk, Range)] -> Vector w -> Sequence mk w a
forall mk w a.
Vector a -> [(mk, Range)] -> Vector w -> Sequence mk w a
Sequence
type WeightedSequence w a = Sequence () w a
type MarkedSequence mk a = Sequence mk () a
type BareSequence a = Sequence () () a
sequ :: Getter (Sequence mk w a) (Vector a)
sequ :: (Vector a -> f (Vector a))
-> Sequence mk w a -> f (Sequence mk w a)
sequ = (Sequence mk w a -> Vector a)
-> (Vector a -> f (Vector a))
-> Sequence mk w a
-> f (Sequence mk w a)
forall (p :: * -> * -> *) (f :: * -> *) s a.
(Profunctor p, Contravariant f) =>
(s -> a) -> Optic' p f s a
to Sequence mk w a -> Vector a
forall mk w a. Sequence mk w a -> Vector a
_sequ
markings :: Getter (Sequence mk w a) [(mk, Range)]
markings :: ([(mk, Range)] -> f [(mk, Range)])
-> Sequence mk w a -> f (Sequence mk w a)
markings = (Sequence mk w a -> [(mk, Range)])
-> ([(mk, Range)] -> f [(mk, Range)])
-> Sequence mk w a
-> f (Sequence mk w a)
forall (p :: * -> * -> *) (f :: * -> *) s a.
(Profunctor p, Contravariant f) =>
(s -> a) -> Optic' p f s a
to Sequence mk w a -> [(mk, Range)]
forall mk w a. Sequence mk w a -> [(mk, Range)]
_markings
weights :: Getter (Sequence mk w a) (Vector w)
weights :: (Vector w -> f (Vector w))
-> Sequence mk w a -> f (Sequence mk w a)
weights = (Sequence mk w a -> Vector w)
-> (Vector w -> f (Vector w))
-> Sequence mk w a
-> f (Sequence mk w a)
forall (p :: * -> * -> *) (f :: * -> *) s a.
(Profunctor p, Contravariant f) =>
(s -> a) -> Optic' p f s a
to Sequence mk w a -> Vector w
forall mk w a. Sequence mk w a -> Vector w
_weights
bareSequ :: Lens' (BareSequence a) (Vector a)
bareSequ :: (Vector a -> f (Vector a)) -> BareSequence a -> f (BareSequence a)
bareSequ = (BareSequence a -> Vector a)
-> (BareSequence a -> Vector a -> BareSequence a)
-> Lens (BareSequence a) (BareSequence a) (Vector a) (Vector a)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
lens BareSequence a -> Vector a
forall mk w a. Sequence mk w a -> Vector a
_sequ (\BareSequence a
s Vector a
v -> BareSequence a
s { _sequ :: Vector a
_sequ = Vector a
v })
class (Eq mk, Ord mk) => IsMarking mk where
instance IsMarking ()
class IsWeight w where
toDouble :: w -> Double
instance IsWeight () where
toDouble :: () -> Double
toDouble = String -> () -> Double
forall a. HasCallStack => String -> a
error String
"Bio.Sequence.Class: () can't be valid 'Weight'."
instance IsWeight Double where
toDouble :: Double -> Double
toDouble = Double -> Double
forall a. a -> a
id
class (IsMarking (Marking s), IsWeight (Weight s)) => IsSequence s where
type Element s :: *
type Marking s :: *
type Weight s :: *
toSequence :: s -> Sequence (Marking s) (Weight s) (Element s)
fromSequence :: Sequence (Marking s) (Weight s) (Element s) -> s
instance (IsMarking mk, IsWeight w) => IsSequence (Sequence mk w a) where
type Element (Sequence mk w a) = a
type Marking (Sequence mk w a) = mk
type Weight (Sequence mk w a) = w
toSequence :: Sequence mk w a
-> Sequence
(Marking (Sequence mk w a))
(Weight (Sequence mk w a))
(Element (Sequence mk w a))
toSequence = Sequence mk w a
-> Sequence
(Marking (Sequence mk w a))
(Weight (Sequence mk w a))
(Element (Sequence mk w a))
forall a. a -> a
id
fromSequence :: Sequence
(Marking (Sequence mk w a))
(Weight (Sequence mk w a))
(Element (Sequence mk w a))
-> Sequence mk w a
fromSequence = Sequence
(Marking (Sequence mk w a))
(Weight (Sequence mk w a))
(Element (Sequence mk w a))
-> Sequence mk w a
forall a. a -> a
id
class IsSequence s => SequenceDecodable a s where
sequenceDecode :: a -> Either Text s
type IsWeightedSequence s = (IsSequence s, Unit (Marking s), NotUnit (Weight s))
type IsMarkedSequence s = (IsSequence s, NotUnit (Marking s), Unit (Weight s))
type IsBareSequence s = (IsSequence s, Unit (Marking s), Unit (Weight s))
type ContainsMarking s = (IsSequence s, NotUnit (Marking s))
type ContainsNoMarking s = (IsSequence s, Unit (Marking s))
type ContainsWeight s = (IsSequence s, NotUnit (Weight s))
type ContainsNoWeight s = (IsSequence s, Unit (Weight s))
createSequence :: (ContainsMarking s, ContainsWeight s, MonadError Text m) => [Element s] -> [(Marking s, Range)] -> [Weight s] -> m s
createSequence :: [Element s] -> [(Marking s, Range)] -> [Weight s] -> m s
createSequence = Bool
-> Bool -> [Element s] -> [(Marking s, Range)] -> [Weight s] -> m s
forall s (m :: * -> *).
(IsSequence s, MonadError Text m) =>
Bool
-> Bool -> [Element s] -> [(Marking s, Range)] -> [Weight s] -> m s
createSequenceInner Bool
True Bool
True
unsafeCreateSequence :: (ContainsMarking s, ContainsWeight s) => [Element s] -> [(Marking s, Range)] -> [Weight s] -> s
unsafeCreateSequence :: [Element s] -> [(Marking s, Range)] -> [Weight s] -> s
unsafeCreateSequence [Element s]
s [(Marking s, Range)]
markings' = Either Text s -> s
forall a. Either Text a -> a
unsafeEither (Either Text s -> s)
-> ([Weight s] -> Either Text s) -> [Weight s] -> s
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Element s] -> [(Marking s, Range)] -> [Weight s] -> Either Text s
forall s (m :: * -> *).
(ContainsMarking s, ContainsWeight s, MonadError Text m) =>
[Element s] -> [(Marking s, Range)] -> [Weight s] -> m s
createSequence [Element s]
s [(Marking s, Range)]
markings'
bareSequence :: IsBareSequence s => [Element s] -> s
bareSequence :: [Element s] -> s
bareSequence [Element s]
s = Sequence (Marking s) (Weight s) (Element s) -> s
forall s.
IsSequence s =>
Sequence (Marking s) (Weight s) (Element s) -> s
fromSequence (Sequence (Marking s) (Weight s) (Element s) -> s)
-> Sequence (Marking s) (Weight s) (Element s) -> s
forall a b. (a -> b) -> a -> b
$ Vector (Element s)
-> [(Marking s, Range)]
-> Vector (Weight s)
-> Sequence (Marking s) (Weight s) (Element s)
forall mk w a.
Vector a -> [(mk, Range)] -> Vector w -> Sequence mk w a
Sequence ([Element s] -> Vector (Element s)
forall a. [a] -> Vector a
V.fromList [Element s]
s) [(Marking s, Range)]
forall a. Monoid a => a
mempty Vector (Weight s)
forall a. Monoid a => a
mempty
markedSequence :: (IsMarkedSequence s, MonadError Text m) => [Element s] -> [(Marking s, Range)] -> m s
markedSequence :: [Element s] -> [(Marking s, Range)] -> m s
markedSequence [Element s]
s [(Marking s, Range)]
markings' = Bool
-> Bool -> [Element s] -> [(Marking s, Range)] -> [Weight s] -> m s
forall s (m :: * -> *).
(IsSequence s, MonadError Text m) =>
Bool
-> Bool -> [Element s] -> [(Marking s, Range)] -> [Weight s] -> m s
createSequenceInner Bool
True Bool
False [Element s]
s [(Marking s, Range)]
markings' []
unsafeMarkedSequence :: IsMarkedSequence s => [Element s] -> [(Marking s, Range)] -> s
unsafeMarkedSequence :: [Element s] -> [(Marking s, Range)] -> s
unsafeMarkedSequence [Element s]
s = Either Text s -> s
forall a. Either Text a -> a
unsafeEither (Either Text s -> s)
-> ([(Marking s, Range)] -> Either Text s)
-> [(Marking s, Range)]
-> s
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Element s] -> [(Marking s, Range)] -> Either Text s
forall s (m :: * -> *).
(IsMarkedSequence s, MonadError Text m) =>
[Element s] -> [(Marking s, Range)] -> m s
markedSequence [Element s]
s
weightedSequence :: (IsWeightedSequence s, MonadError Text m) => [Element s] -> [Weight s] -> m s
weightedSequence :: [Element s] -> [Weight s] -> m s
weightedSequence [Element s]
s = Bool
-> Bool -> [Element s] -> [(Marking s, Range)] -> [Weight s] -> m s
forall s (m :: * -> *).
(IsSequence s, MonadError Text m) =>
Bool
-> Bool -> [Element s] -> [(Marking s, Range)] -> [Weight s] -> m s
createSequenceInner Bool
False Bool
True [Element s]
s []
unsafeWeightedSequence :: IsWeightedSequence s => [Element s] -> [Weight s] -> s
unsafeWeightedSequence :: [Element s] -> [Weight s] -> s
unsafeWeightedSequence [Element s]
s = Either Text s -> s
forall a. Either Text a -> a
unsafeEither (Either Text s -> s)
-> ([Weight s] -> Either Text s) -> [Weight s] -> s
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Element s] -> [Weight s] -> Either Text s
forall s (m :: * -> *).
(IsWeightedSequence s, MonadError Text m) =>
[Element s] -> [Weight s] -> m s
weightedSequence [Element s]
s
type family NotUnit a :: Constraint where
NotUnit () = TypeError ('Text "cobot-io: this function doesn't work with when parametrized by ().")
NotUnit _ = ()
type family Unit a :: Constraint where
Unit () = ()
Unit _ = TypeError ('Text "cobot-io: this function doesn't work with when not parametrized by ().")
createSequenceInner :: (IsSequence s, MonadError Text m) => Bool -> Bool -> [Element s] -> [(Marking s, Range)] -> [Weight s] -> m s
createSequenceInner :: Bool
-> Bool -> [Element s] -> [(Marking s, Range)] -> [Weight s] -> m s
createSequenceInner Bool
checkMk Bool
checkW [Element s]
s [(Marking s, Range)]
markings' [Weight s]
weights' | Bool
checkMk Bool -> Bool -> Bool
&& Bool -> Bool
not Bool
checkRanges = Text -> m s
forall e (m :: * -> *) a. MonadError e m => e -> m a
throwError Text
rangesError
| Bool
checkW Bool -> Bool -> Bool
&& Bool -> Bool
not Bool
checkNullWeights = Text -> m s
forall e (m :: * -> *) a. MonadError e m => e -> m a
throwError Text
weightsNullError
| Bool
checkW Bool -> Bool -> Bool
&& Bool -> Bool
not Bool
checkLenWeights = Text -> m s
forall e (m :: * -> *) a. MonadError e m => e -> m a
throwError Text
weightsLenError
| Bool
otherwise = s -> m s
forall (f :: * -> *) a. Applicative f => a -> f a
pure s
resSequence
where
seqVector :: Vector (Element s)
seqVector = [Element s] -> Vector (Element s)
forall a. [a] -> Vector a
V.fromList [Element s]
s
weightsVector :: Vector (Weight s)
weightsVector = [Weight s] -> Vector (Weight s)
forall a. [a] -> Vector a
V.fromList [Weight s]
weights'
resSequence :: s
resSequence = Sequence (Marking s) (Weight s) (Element s) -> s
forall s.
IsSequence s =>
Sequence (Marking s) (Weight s) (Element s) -> s
fromSequence (Sequence (Marking s) (Weight s) (Element s) -> s)
-> Sequence (Marking s) (Weight s) (Element s) -> s
forall a b. (a -> b) -> a -> b
$ Vector (Element s)
-> [(Marking s, Range)]
-> Vector (Weight s)
-> Sequence (Marking s) (Weight s) (Element s)
forall mk w a.
Vector a -> [(mk, Range)] -> Vector w -> Sequence mk w a
Sequence Vector (Element s)
seqVector [(Marking s, Range)]
markings' Vector (Weight s)
weightsVector
checkRanges :: Bool
checkRanges :: Bool
checkRanges = (Range -> Bool) -> [Range] -> Bool
forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Bool
all (Int -> Range -> Bool
checkRange ([Element s] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
L.length [Element s]
s)) ([Range] -> Bool) -> [Range] -> Bool
forall a b. (a -> b) -> a -> b
$ ((Marking s, Range) -> Range) -> [(Marking s, Range)] -> [Range]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (Marking s, Range) -> Range
forall a b. (a, b) -> b
snd [(Marking s, Range)]
markings'
checkNullWeights :: Bool
checkNullWeights :: Bool
checkNullWeights = Bool -> Bool
not ([Weight s] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
L.null [Weight s]
weights')
checkLenWeights :: Bool
checkLenWeights :: Bool
checkLenWeights = [Element s] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
L.length [Element s]
s Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== [Weight s] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
L.length [Weight s]
weights'
rangesError :: Text
rangesError :: Text
rangesError = Text
"Bio.Sequence.Class: invalid 'Range' found in sequence's marking."
weightsNullError :: Text
weightsNullError :: Text
weightsNullError = Text
"Bio.Sequence.Class: weights are null for sequence."
weightsLenError :: Text
weightsLenError :: Text
weightsLenError = Text
"Bio.Sequence.Class: sequence and weights have different lengths."