Commit b7409d1b authored by Quentin Lobbé's avatar Quentin Lobbé

add the Metrics and the Filters

parent f5ebe987
Pipeline #298 failed with stage
...@@ -199,13 +199,14 @@ data PairTo = Childs | Parents ...@@ -199,13 +199,14 @@ data PairTo = Childs | Parents
-- | PhyloView | -- -- | PhyloView | --
data EdgeType = Ascendant | Descendant | Complete deriving (Show) data Filiation = Ascendant | Descendant | Complete deriving (Show)
data EdgeType = PeriodEdge | LevelEdge deriving (Show)
data PhyloView = PhyloView data PhyloView = PhyloView
{ _phylo_viewParam :: PhyloParam { _phylo_viewParam :: PhyloParam
, _phylo_viewLabel :: Text , _phylo_viewLabel :: Text
, _phylo_viewDescription :: Text , _phylo_viewDescription :: Text
, _phylo_viewEdgeType :: EdgeType , _phylo_viewFiliation :: Filiation
, _phylo_viewMeta :: Map Text Double , _phylo_viewMeta :: Map Text Double
, _phylo_viewBranches :: [PhyloBranch] , _phylo_viewBranches :: [PhyloBranch]
, _phylo_viewNodes :: [PhyloNode] , _phylo_viewNodes :: [PhyloNode]
...@@ -223,12 +224,14 @@ data PhyloBranch = PhyloBranch ...@@ -223,12 +224,14 @@ data PhyloBranch = PhyloBranch
data PhyloEdge = PhyloEdge data PhyloEdge = PhyloEdge
{ _phylo_edgeSource :: PhyloGroupId { _phylo_edgeSource :: PhyloGroupId
, _phylo_edgeTarget :: PhyloGroupId , _phylo_edgeTarget :: PhyloGroupId
, _phylo_edgeType :: EdgeType
, _phylo_edgeWeight :: Weight , _phylo_edgeWeight :: Weight
} deriving (Show) } deriving (Show)
data PhyloNode = PhyloNode data PhyloNode = PhyloNode
{ _phylo_nodeId :: PhyloGroupId { _phylo_nodeId :: PhyloGroupId
, _phylo_nodeBranchId :: Maybe PhyloBranchId
, _phylo_nodeLabel :: Text , _phylo_nodeLabel :: Text
, _phylo_nodeNgramsIdx :: [Int] , _phylo_nodeNgramsIdx :: [Int]
, _phylo_nodeNgrams :: Maybe [Ngrams] , _phylo_nodeNgrams :: Maybe [Ngrams]
...@@ -239,7 +242,7 @@ data PhyloNode = PhyloNode ...@@ -239,7 +242,7 @@ data PhyloNode = PhyloNode
-- | PhyloQuery | -- -- | PhyloQuery | --
data Filter = LonelyBranchFilter data Filter = LonelyBranch
data Metric = BranchAge data Metric = BranchAge
data Tagger = BranchLabelFreq | GroupLabelCooc | GroupDynamics data Tagger = BranchLabelFreq | GroupLabelCooc | GroupDynamics
...@@ -247,16 +250,13 @@ data Tagger = BranchLabelFreq | GroupLabelCooc | GroupDynamics ...@@ -247,16 +250,13 @@ data Tagger = BranchLabelFreq | GroupLabelCooc | GroupDynamics
data Sort = ByBranchAge data Sort = ByBranchAge
data Order = Asc | Desc data Order = Asc | Desc
data QueryParam = Qp1 Int | Qp2 Text | Qp3 Bool deriving (Eq, Ord)
data DisplayMode = Flat | Nested data DisplayMode = Flat | Nested
-- | A query filter seen as : prefix && ((filter params)(clause)) -- | A query filter seen as : prefix && ((filter params)(clause))
data QueryFilter = QueryFilter data QueryFilter = QueryFilter
{ _query_filter :: Filter { _query_filter :: Filter
, _query_params :: [QueryParam] , _query_params :: [Double]
, _query_clause :: (QueryParam -> Bool)
} }
...@@ -264,8 +264,8 @@ data QueryFilter = QueryFilter ...@@ -264,8 +264,8 @@ data QueryFilter = QueryFilter
data PhyloQuery = PhyloQuery data PhyloQuery = PhyloQuery
{ _query_lvl :: Level { _query_lvl :: Level
-- Does the PhyloGraph contain ascendant, descendant or both (filiation) edges ? -- Does the PhyloGraph contain ascendant, descendant or a complete Filiation ?
, _query_edgeType :: EdgeType , _query_filiation :: Filiation
-- Does the PhyloGraph contain some levelChilds ? How deep must it go ? -- Does the PhyloGraph contain some levelChilds ? How deep must it go ?
, _query_childs :: Bool , _query_childs :: Bool
...@@ -300,6 +300,10 @@ makeLenses ''PhyloLevel ...@@ -300,6 +300,10 @@ makeLenses ''PhyloLevel
makeLenses ''PhyloPeriod makeLenses ''PhyloPeriod
makeLenses ''PhyloView makeLenses ''PhyloView
makeLenses ''PhyloQuery makeLenses ''PhyloQuery
makeLenses ''PhyloBranch
makeLenses ''PhyloNode
makeLenses ''PhyloEdge
makeLenses ''QueryFilter
-- | JSON instances -- | JSON instances
$(deriveJSON (unPrefix "_phylo_" ) ''Phylo ) $(deriveJSON (unPrefix "_phylo_" ) ''Phylo )
......
...@@ -31,9 +31,9 @@ module Gargantext.Viz.Phylo.Example where ...@@ -31,9 +31,9 @@ module Gargantext.Viz.Phylo.Example where
import Control.Lens hiding (makeLenses, both, Level) import Control.Lens hiding (makeLenses, both, Level)
import Data.Bool (Bool, not) import Data.Bool (Bool, not)
import Data.List (notElem, concat, union, intersect, tails, tail, head, last, null, zip, sort, length, any, (++), (!!), nub, sortOn, reverse, splitAt, take, delete, init, groupBy) import Data.List ((\\), notElem, concat, union, intersect, tails, tail, head, last, null, zip, sort, length, any, (++), (!!), nub, sortOn, reverse, splitAt, take, delete, init, groupBy)
import Data.Map (Map, elems, member, adjust, singleton, empty, (!), keys, restrictKeys, mapWithKey, filterWithKey, mapKeys, intersectionWith, unionWith) import Data.Map (Map, elems, insert, member, adjust, singleton, empty, (!), keys, restrictKeys, mapWithKey, filterWithKey, mapKeys, intersectionWith, unionWith)
import Data.Maybe (mapMaybe) import Data.Maybe (mapMaybe,isJust,fromJust)
import Data.Semigroup (Semigroup) import Data.Semigroup (Semigroup)
import Data.Set (Set) import Data.Set (Set)
import Data.Text (Text, unwords, toLower, words) import Data.Text (Text, unwords, toLower, words)
...@@ -41,6 +41,8 @@ import Data.Tuple (fst, snd) ...@@ -41,6 +41,8 @@ import Data.Tuple (fst, snd)
import Data.Tuple.Extra import Data.Tuple.Extra
import Data.Vector (Vector, fromList, elemIndex, (!)) import Data.Vector (Vector, fromList, elemIndex, (!))
import Debug.Trace (trace)
import Gargantext.Prelude hiding (head) import Gargantext.Prelude hiding (head)
import Gargantext.Text.Terms.Mono (monoTexts) import Gargantext.Text.Terms.Mono (monoTexts)
...@@ -70,15 +72,6 @@ import qualified Data.Vector as Vector ...@@ -70,15 +72,6 @@ import qualified Data.Vector as Vector
-- | STEP 12 | -- Return a Phylo for upcomming visiualization tasks -- | STEP 12 | -- Return a Phylo for upcomming visiualization tasks
-- -- | To get all the single PhyloPeriodIds covered by a PhyloBranch
-- getBranchPeriods :: PhyloBranch -> [PhyloPeriodId]
-- getBranchPeriods b = nub $ map (fst . fst) $ getBranchGroupIds b
-- -- | To get all the single PhyloPeriodIds covered by a PhyloBranch
-- getBranchGroupIds :: PhyloBranch -> [PhyloGroupId]
-- getBranchGroupIds =_phylo_branchGroups
-- | To transform a list of Ngrams Indexes into a Label -- | To transform a list of Ngrams Indexes into a Label
ngramsToLabel :: Vector Ngrams -> [Int] -> Text ngramsToLabel :: Vector Ngrams -> [Int] -> Text
...@@ -113,27 +106,63 @@ mostOccNgrams thr group = (nub . concat ) ...@@ -113,27 +106,63 @@ mostOccNgrams thr group = (nub . concat )
freqToLabel :: Int -> [PhyloGroup] -> Vector Ngrams -> Text freqToLabel :: Int -> [PhyloGroup] -> Vector Ngrams -> Text
freqToLabel thr l ngs = ngramsToLabel ngs $ mostFreqNgrams thr l freqToLabel thr l ngs = ngramsToLabel ngs $ mostFreqNgrams thr l
--------- To Do tagger, sort et display
-- | To filter a list of Branches by avoiding the lone's one (ie: with just a few phyloGroups in the middle of the whole timeline)
-- filterLoneBranches :: Int -> Int -> Int -> [PhyloPeriodId] -> [PhyloBranch] -> [PhyloBranch]
-- filterLoneBranches nbPinf nbPsup nbG periods branches = filter (not . isLone) branches
-- where
-- --------------------------------------
-- isLone :: PhyloBranch -> Bool
-- isLone b = ((length . getBranchGroupIds) b <= nbG)
-- && notElem ((head . getBranchPeriods) b) (take nbPinf periods)
-- && notElem ((head . getBranchPeriods) b) (take nbPsup $ reverse periods)
-- --------------------------------------
getNodeId :: PhyloNode -> PhyloGroupId
getNodeId n = n ^. phylo_nodeId
getSourceId :: PhyloEdge -> PhyloGroupId
getSourceId e = e ^. phylo_edgeSource
getTargetId :: PhyloEdge -> PhyloGroupId
getTargetId e = e ^. phylo_edgeTarget
filterLonelyBranch :: PhyloView -> PhyloView getNodeBranchId :: PhyloNode -> PhyloBranchId
filterLonelyBranch graph = graph getNodeBranchId n = case n ^. phylo_nodeBranchId of
Nothing -> panic "[ERR][Viz.Phylo.Tools.getNodeBranchId] branchId not found"
Just i -> i
filterHandler :: QueryFilter -> PhyloView -> PhyloView
filterHandler fq graph = case _query_filter fq of getBranchId :: PhyloBranch -> PhyloBranchId
LonelyBranchFilter -> filterLonelyBranch graph getBranchId b = b ^. phylo_branchId
getViewBranchIds :: PhyloView -> [PhyloBranchId]
getViewBranchIds v = map getBranchId $ v ^. phylo_viewBranches
cleanNodesEdges :: PhyloView -> PhyloView -> PhyloView
cleanNodesEdges v v' = v' & phylo_viewNodes %~ (filter (\n -> not $ elem (getNodeId n) nIds))
& phylo_viewEdges %~ (filter (\e -> (not $ elem (getSourceId e) nIds)
&& (not $ elem (getTargetId e) nIds)))
where
--------------------------------------
nIds :: [PhyloGroupId]
nIds = map getNodeId
$ filter (\n -> elem (getNodeBranchId n) bIds)
$ getNodesInBranches v
--------------------------------------
bIds :: [PhyloBranchId]
bIds = (getViewBranchIds v) \\ (getViewBranchIds v')
--------------------------------------
filterLonelyBranch :: Int -> Int -> Int -> [PhyloPeriodId] -> PhyloView -> PhyloView
filterLonelyBranch nbInf nbSup nbNs prds v = cleanNodesEdges v v'
where
--------------------------------------
v' :: PhyloView
v' = v & phylo_viewBranches %~ (filter (\b -> let ns = filter (\n -> (getBranchId b) == (getNodeBranchId n))
$ getNodesInBranches v
prds' = nub $ map (\n -> (fst . fst) $ getNodeId n) ns
in not (isLone ns prds')))
--------------------------------------
isLone :: [PhyloNode] -> [PhyloPeriodId] -> Bool
isLone ns prds' = (length ns <= nbNs)
&& notElem (head prds') (take nbInf prds)
&& notElem (head prds') (take nbSup $ reverse prds)
--------------------------------------
getBranchIdsWith :: Level -> Phylo -> [PhyloBranchId] getBranchIdsWith :: Level -> Phylo -> [PhyloBranchId]
...@@ -150,96 +179,135 @@ getPhyloParams p = phyloParams ...@@ -150,96 +179,135 @@ getPhyloParams p = phyloParams
initPhyloBranch :: PhyloBranchId -> Text -> PhyloBranch initPhyloBranch :: PhyloBranchId -> Text -> PhyloBranch
initPhyloBranch id lbl = PhyloBranch id lbl empty initPhyloBranch id lbl = PhyloBranch id lbl empty
addPhyloNodes :: Bool -> Bool -> Vector Ngrams -> [PhyloGroup] -> [PhyloNode] groupsToNodes :: Bool -> Bool -> Vector Ngrams -> [PhyloGroup] -> [PhyloNode]
addPhyloNodes isR isV ns gs = map (\g -> let idxs = getGroupNgrams g groupsToNodes isR isV ns gs = map (\g -> let idxs = getGroupNgrams g
in PhyloNode in PhyloNode
(getGroupId g) "" idxs (getGroupId g)
(getGroupBranchId g)
"" idxs
(if isV (if isV
then Just (ngramsToText ns idxs) then Just (ngramsToText ns idxs)
else Nothing) else Nothing)
empty empty
(if isR (if (not isR)
then Just (head $ getGroupLevelParentsId g) then Just (head $ getGroupLevelParentsId g)
else Nothing) else Nothing)
) $ gs ) gs
initPhyloEdge :: PhyloGroup -> [Pointer] -> [PhyloEdge] initPhyloEdge :: PhyloGroupId -> [Pointer] -> EdgeType -> [PhyloEdge]
initPhyloEdge g pts = map (\pt -> PhyloEdge (getGroupId g) (fst pt) (snd pt)) pts initPhyloEdge id pts et = map (\pt -> PhyloEdge id (fst pt) et (snd pt)) pts
addPhyloEdgesLevel :: EdgeType -> [PhyloGroup] -> [PhyloEdge]
addPhyloEdgesLevel e gs = concat
$ map (\g -> case e of
Ascendant -> initPhyloEdge g (_phylo_groupLevelParents g)
Descendant -> initPhyloEdge g (_phylo_groupLevelChilds g)) gs
addPhyloEdgesPeriod :: EdgeType -> [PhyloGroup] -> [PhyloEdge] groupsToEdges :: Filiation -> EdgeType -> [PhyloGroup] -> [PhyloEdge]
addPhyloEdgesPeriod e gs = concat groupsToEdges fl et gs = case fl of
$ map (\g -> case e of Complete -> (groupsToEdges Ascendant et gs) ++ (groupsToEdges Descendant et gs)
Ascendant -> initPhyloEdge g (_phylo_groupPeriodParents g) _ -> concat
Descendant -> initPhyloEdge g (_phylo_groupPeriodChilds g)) gs $ map (\g -> case fl of
Ascendant -> case et of
PeriodEdge -> initPhyloEdge (getGroupId g) (getGroupPeriodParents g) et
LevelEdge -> initPhyloEdge (getGroupId g) (getGroupLevelParents g) et
Descendant -> case et of
PeriodEdge -> initPhyloEdge (getGroupId g) (getGroupPeriodChilds g) et
LevelEdge -> initPhyloEdge (getGroupId g) (getGroupLevelChilds g) et
) gs
addBranches :: Level -> Phylo -> [PhyloBranch] addBranches :: Level -> Phylo -> [PhyloBranch]
addBranches lvl p = map (\id -> initPhyloBranch id "") addBranches lvl p = map (\id -> initPhyloBranch id "") $ nub $ getBranchIdsWith lvl p
$ getBranchIdsWith lvl p
initPhyloView :: Level -> Text -> Text -> EdgeType -> Bool -> Phylo -> PhyloView initPhyloView :: Level -> Text -> Text -> Filiation -> Bool -> Phylo -> PhyloView
initPhyloView lvl lbl dsc e vb p = PhyloView (getPhyloParams p) lbl dsc e empty initPhyloView lvl lbl dsc fl vb p = PhyloView (getPhyloParams p) lbl dsc fl empty
([] ++ (addBranches lvl p)) ([] ++ (addBranches lvl p))
([] ++ (addPhyloNodes True vb (getFoundations p) groups)) ([] ++ (groupsToNodes True vb (getFoundations p) gs))
(case e of ([] ++ (groupsToEdges fl PeriodEdge gs))
Complete -> [] ++ (addPhyloEdgesPeriod Ascendant groups) ++ (addPhyloEdgesPeriod Descendant groups)
_ -> [] ++ (addPhyloEdgesPeriod e groups))
where where
-------------------------------------- --------------------------------------
groups :: [PhyloGroup] gs :: [PhyloGroup]
groups = getGroupsWithLevel lvl p gs = getGroupsWithLevel lvl p
-------------------------------------- --------------------------------------
addChildNodes :: Bool -> Level -> Level -> Bool -> EdgeType -> Phylo -> PhyloView -> PhyloView addChildNodes :: Bool -> Level -> Level -> Bool -> Filiation -> Phylo -> PhyloView -> PhyloView
addChildNodes ok lvl lvl' vb e p v addChildNodes shouldDo lvl lvl' vb fl p v =
| not ok = v if (not shouldDo) || (lvl == lvl')
| lvl == lvl' = v then v
| otherwise = addChildNodes ok lvl (lvl' - 1) vb e p else addChildNodes shouldDo lvl (lvl' - 1) vb fl p
$ v & over (phylo_viewBranches) (++ (addBranches (lvl' - 1) p)) $ v & phylo_viewBranches %~ (++ (addBranches (lvl' - 1) p))
& over (phylo_viewNodes) (++ (addPhyloNodes False vb (getFoundations p) groups')) & phylo_viewNodes %~ (++ (groupsToNodes False vb (getFoundations p) gs'))
& over (phylo_viewEdges) (case e of & phylo_viewEdges %~ (++ (groupsToEdges fl PeriodEdge gs'))
Complete -> (++ ((addPhyloEdgesPeriod Ascendant groups') ++ (addPhyloEdgesPeriod Descendant groups'))) & phylo_viewEdges %~ (++ (groupsToEdges Descendant LevelEdge gs ))
_ -> (++ (addPhyloEdgesPeriod e groups))) & phylo_viewEdges %~ (++ (groupsToEdges Ascendant LevelEdge gs'))
& over (phylo_viewEdges) (++ (addPhyloEdgesLevel Descendant groups))
& over (phylo_viewEdges) (++ (addPhyloEdgesLevel Ascendant groups'))
where where
-------------------------------------- --------------------------------------
groups :: [PhyloGroup] gs :: [PhyloGroup]
groups = getGroupsWithLevel lvl' p gs = getGroupsWithLevel lvl' p
-------------------------------------- --------------------------------------
groups' :: [PhyloGroup] gs' :: [PhyloGroup]
groups' = getGroupsWithLevel (lvl' - 1) p gs' = getGroupsWithLevel (lvl' - 1) p
-------------------------------------- --------------------------------------
addBranchMeta :: PhyloBranchId -> Text -> Double -> PhyloView -> PhyloView
addBranchMeta id lbl val v = over (phylo_viewBranches
. traverse)
(\b -> if getBranchId b == id
then b & phylo_branchMeta %~ insert lbl val
else b) v
getNodesInBranches :: PhyloView -> [PhyloNode]
getNodesInBranches v = filter (\n -> isJust $ n ^. phylo_nodeBranchId)
$ v ^. phylo_viewNodes
branchAge :: PhyloView -> PhyloView
branchAge v = foldl (\v' b -> let bId = (fst . head) b
prds = sortOn fst $ map snd b
in addBranchMeta bId "age" ((abs . fromIntegral)
$ ((snd . last) prds) - ((fst . head) prds)) v') v
$ groupBy ((==) `on` fst)
$ sortOn fst
$ map (\n -> (getNodeBranchId n, (fst . fst) $ getNodeId n))
$ getNodesInBranches v
processMetrics :: [Metric] -> Phylo -> PhyloView -> PhyloView
processMetrics ms p v = foldl (\v' m -> case m of
BranchAge -> branchAge v'
_ -> panic "[ERR][Viz.Phylo.Example.processMetrics] metric not found") v ms
processFilters :: [QueryFilter] -> Phylo -> PhyloView -> PhyloView
processFilters fs p v = foldl (\v' f -> case f ^. query_filter of
LonelyBranch -> filterLonelyBranch (round $ (f ^. query_params) !! 0)
(round $ (f ^. query_params) !! 1)
(round $ (f ^. query_params) !! 2) (getPhyloPeriods p) v'
_ -> panic "[ERR][Viz.Phylo.Example.processFilters] filter not found") v fs
queryToView :: PhyloQuery -> Phylo -> PhyloView queryToView :: PhyloQuery -> Phylo -> PhyloView
queryToView q p = addChildNodes (_query_childs q) (_query_lvl q) (_query_childsDepth q) (_query_verbose q) (_query_edgeType q) p queryToView q p = processFilters (q ^.query_filters) p
$ initPhyloView (_query_lvl q) "Phylo2000" "This is a Phylo" (_query_edgeType q) (_query_verbose q) p $ processMetrics (q ^.query_metrics) p
$ addChildNodes (q ^. query_childs) (q ^. query_lvl) (q ^. query_childsDepth) (q ^. query_verbose) (q ^. query_filiation) p
$ initPhyloView (q ^. query_lvl) "Phylo2000" "This is a Phylo" (q ^. query_filiation) (q ^. query_verbose) p
defaultQuery :: PhyloQuery defaultQuery :: PhyloQuery
defaultQuery = PhyloQuery 3 Descendant False 0 [] [] [] Nothing Flat True defaultQuery = PhyloQuery 3 Descendant False 0 [] [] [] Nothing Flat True
textQuery :: Text urlQuery :: Text
textQuery = "level=3&childs=false&filter=LonelyBranchFilter(2,2,1):true&metric=BranchAge&tagger=BranchLabelFreq&tagger=GroupLabelCooc" urlQuery = "level=3&childs=false&filter=LonelyBranchFilter(2,2,1):true&metric=BranchAge&tagger=BranchLabelFreq&tagger=GroupLabelCooc"
-- | To do : add a queryParser from an URL and then update the defaultQuery -- | To do : add a queryParser from an URL and then update the defaultQuery
urlToQuery :: Text -> PhyloQuery urlToQuery :: Text -> PhyloQuery
urlToQuery url = defaultQuery urlToQuery url = defaultQuery
& query_lvl .~ 3 & query_lvl .~ 3
& query_childs .~ False & query_childs .~ False
& over (query_metrics) (++ [BranchAge]) & query_metrics %~ (++ [BranchAge])
& over (query_filters) (++ [QueryFilter LonelyBranchFilter [Qp1 2,Qp1 2,Qp1 1] (== Qp3 True)]) & query_filters %~ (++ [QueryFilter LonelyBranch [2,2,1]])
& over (query_taggers) (++ [BranchLabelFreq,GroupLabelCooc]) & query_taggers %~ (++ [BranchLabelFreq,GroupLabelCooc])
toPhyloView :: Text -> Phylo -> PhyloView toPhyloView :: Text -> Phylo -> PhyloView
......
...@@ -140,7 +140,7 @@ getGroupBranchId = _phylo_groupBranchId ...@@ -140,7 +140,7 @@ getGroupBranchId = _phylo_groupBranchId
-- | To get the PhyloGroups Childs of a PhyloGroup -- | To get the PhyloGroups Childs of a PhyloGroup
getGroupChilds :: PhyloGroup -> Phylo -> [PhyloGroup] getGroupChilds :: PhyloGroup -> Phylo -> [PhyloGroup]
getGroupChilds g p = getGroupsFromIds (map fst $ _phylo_groupPeriodChilds g) p getGroupChilds g p = getGroupsFromIds (getGroupPeriodChildsId g) p
-- | To get the id of a PhyloGroup -- | To get the id of a PhyloGroup
...@@ -158,14 +158,24 @@ getGroupLevel :: PhyloGroup -> Int ...@@ -158,14 +158,24 @@ getGroupLevel :: PhyloGroup -> Int
getGroupLevel = snd . fst . getGroupId getGroupLevel = snd . fst . getGroupId
-- | To get the level child pointers of a PhyloGroup
getGroupLevelChilds :: PhyloGroup -> [Pointer]
getGroupLevelChilds = _phylo_groupLevelChilds
-- | To get the PhyloGroups Level Childs Ids of a PhyloGroup -- | To get the PhyloGroups Level Childs Ids of a PhyloGroup
getGroupLevelChildsId :: PhyloGroup -> [PhyloGroupId] getGroupLevelChildsId :: PhyloGroup -> [PhyloGroupId]
getGroupLevelChildsId g = map fst $ _phylo_groupLevelChilds g getGroupLevelChildsId g = map fst $ getGroupLevelChilds g
-- | To get the level parent pointers of a PhyloGroup
getGroupLevelParents :: PhyloGroup -> [Pointer]
getGroupLevelParents = _phylo_groupLevelParents
-- | To get the PhyloGroups Level Parents Ids of a PhyloGroup -- | To get the PhyloGroups Level Parents Ids of a PhyloGroup
getGroupLevelParentsId :: PhyloGroup -> [PhyloGroupId] getGroupLevelParentsId :: PhyloGroup -> [PhyloGroupId]
getGroupLevelParentsId g = map fst $ _phylo_groupLevelParents g getGroupLevelParentsId g = map fst $ getGroupLevelParents g
-- | To get the Ngrams of a PhyloGroup -- | To get the Ngrams of a PhyloGroup
...@@ -180,7 +190,7 @@ getGroupPairs g p = (getGroupChilds g p) ++ (getGroupParents g p) ...@@ -180,7 +190,7 @@ getGroupPairs g p = (getGroupChilds g p) ++ (getGroupParents g p)
-- | To get the PhyloGroups Parents of a PhyloGroup -- | To get the PhyloGroups Parents of a PhyloGroup
getGroupParents :: PhyloGroup -> Phylo -> [PhyloGroup] getGroupParents :: PhyloGroup -> Phylo -> [PhyloGroup]
getGroupParents g p = getGroupsFromIds (map fst $ _phylo_groupPeriodParents g) p getGroupParents g p = getGroupsFromIds (getGroupPeriodParentsId g) p
-- | To get the period out of the id of a PhyloGroup -- | To get the period out of the id of a PhyloGroup
...@@ -188,6 +198,26 @@ getGroupPeriod :: PhyloGroup -> (Date,Date) ...@@ -188,6 +198,26 @@ getGroupPeriod :: PhyloGroup -> (Date,Date)
getGroupPeriod = fst . fst . getGroupId getGroupPeriod = fst . fst . getGroupId
-- | To get the period child pointers of a PhyloGroup
getGroupPeriodChilds :: PhyloGroup -> [Pointer]
getGroupPeriodChilds = _phylo_groupPeriodChilds
-- | To get the PhyloGroups Period Parents Ids of a PhyloGroup
getGroupPeriodChildsId :: PhyloGroup -> [PhyloGroupId]
getGroupPeriodChildsId g = map fst $ getGroupPeriodChilds g
-- | To get the period parent pointers of a PhyloGroup
getGroupPeriodParents :: PhyloGroup -> [Pointer]
getGroupPeriodParents = _phylo_groupPeriodParents
-- | To get the PhyloGroups Period Parents Ids of a PhyloGroup
getGroupPeriodParentsId :: PhyloGroup -> [PhyloGroupId]
getGroupPeriodParentsId g = map fst $ getGroupPeriodParents g
-- | To get all the PhyloGroup of a Phylo -- | To get all the PhyloGroup of a Phylo
getGroups :: Phylo -> [PhyloGroup] getGroups :: Phylo -> [PhyloGroup]
getGroups = view ( phylo_periods getGroups = view ( phylo_periods
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment