Copyright | (c) Dominik Schrempf 2020 |
---|---|
License | GPL-3.0-or-later |
Maintainer | dominik.schrempf@gmail.com |
Stability | unstable |
Portability | portable |
Safe Haskell | None |
Language | Haskell2010 |
Creation date: Sat Jul 11 10:28:28 2020.
A Topology
differs from a classical rose Tree
in that it does
not have internal node labels. The leaves have labels.
For rooted trees, please see Rooted
.
In phylogenetics, the order of children of a topology node is arbitrary.
Internally, however, the underlying Topology
data structure stores the
sub-forest as a (non-empty) list, which has a specific order. Hence, we have
to do some tricks when comparing topologies, and topology comparison is slow.
Synopsis
- data Topology a
- type Forest a = NonEmpty (Topology a)
- fromTree :: Tree a -> Topology a
- fromLabeledTree :: Tree e a -> Topology a
- degree :: Topology a -> Int
- leaves :: Ord a => Topology a -> [a]
- flatten :: Topology a -> [a]
- identify :: Traversable t => t a -> t Int
- prune :: Topology a -> Topology a
- dropLeavesWith :: (a -> Bool) -> Topology a -> Maybe (Topology a)
- zipTreesWith :: (a1 -> a2 -> a) -> Topology a1 -> Topology a2 -> Maybe (Topology a)
- zipTrees :: Topology a1 -> Topology a2 -> Maybe (Topology (a1, a2))
- duplicateLeaves :: Ord a => Topology a -> Bool
Data type
Rooted topologies with leaf labels.
Instances
Monad Topology Source # | |
Functor Topology Source # | |
Applicative Topology Source # | |
Foldable Topology Source # | |
Defined in ELynx.Data.Topology.Rooted fold :: Monoid m => Topology m -> m # foldMap :: Monoid m => (a -> m) -> Topology a -> m # foldr :: (a -> b -> b) -> b -> Topology a -> b # foldr' :: (a -> b -> b) -> b -> Topology a -> b # foldl :: (b -> a -> b) -> b -> Topology a -> b # foldl' :: (b -> a -> b) -> b -> Topology a -> b # foldr1 :: (a -> a -> a) -> Topology a -> a # foldl1 :: (a -> a -> a) -> Topology a -> a # elem :: Eq a => a -> Topology a -> Bool # maximum :: Ord a => Topology a -> a # minimum :: Ord a => Topology a -> a # | |
Traversable Topology Source # | |
Eq a => Eq (Topology a) Source # | |
Data a => Data (Topology a) Source # | |
Defined in ELynx.Data.Topology.Rooted gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Topology a -> c (Topology a) # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (Topology a) # toConstr :: Topology a -> Constr # dataTypeOf :: Topology a -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (Topology a)) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Topology a)) # gmapT :: (forall b. Data b => b -> b) -> Topology a -> Topology a # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Topology a -> r # gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Topology a -> r # gmapQ :: (forall d. Data d => d -> u) -> Topology a -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> Topology a -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Topology a -> m (Topology a) # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Topology a -> m (Topology a) # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Topology a -> m (Topology a) # | |
Read a => Read (Topology a) Source # | |
Show a => Show (Topology a) Source # | |
Generic (Topology a) Source # | |
NFData a => NFData (Topology a) Source # | |
Defined in ELynx.Data.Topology.Rooted | |
ToJSON a => ToJSON (Topology a) Source # | |
Defined in ELynx.Data.Topology.Rooted | |
FromJSON a => FromJSON (Topology a) Source # | |
type Rep (Topology a) Source # | |
Defined in ELynx.Data.Topology.Rooted type Rep (Topology a) = D1 (MetaData "Topology" "ELynx.Data.Topology.Rooted" "elynx-tree-0.3.2-D4z8hEm7d0IGPFAaza2gb3" False) (C1 (MetaCons "Node" PrefixI True) (S1 (MetaSel (Just "forest") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Forest a))) :+: C1 (MetaCons "Leaf" PrefixI True) (S1 (MetaSel (Just "label") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 a))) |
fromTree :: Tree a -> Topology a Source #
Convert a rooted rose tree to a rooted topology. Internal node labels are lost.
fromLabeledTree :: Tree e a -> Topology a Source #
Convert a rooted, labeled rose tree to a rooted topology. Branch labels and internal node labels are lost.
Functions
identify :: Traversable t => t a -> t Int Source #
Label the leaves with unique integers starting at 0.
dropLeavesWith :: (a -> Bool) -> Topology a -> Maybe (Topology a) Source #
Drop leaves satisfying predicate.
Degree two nodes may arise.
Return Nothing
if all leaves satisfy the predicate.
zipTreesWith :: (a1 -> a2 -> a) -> Topology a1 -> Topology a2 -> Maybe (Topology a) Source #
Zip leaves of two equal topologies.
Return Nothing
if the topologies are different.