Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
haskell-gargantext
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
148
Issues
148
List
Board
Labels
Milestones
Merge Requests
12
Merge Requests
12
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
gargantext
haskell-gargantext
Commits
7c1ce395
Commit
7c1ce395
authored
Apr 11, 2019
by
Quentin Lobbé
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
just finalized the dot export
parent
edd553c5
Pipeline
#348
failed with stage
Changes
6
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
139 additions
and
93 deletions
+139
-93
Phylo.hs
src/Gargantext/Viz/Phylo.hs
+3
-0
Example.hs
src/Gargantext/Viz/Phylo/Example.hs
+6
-1
Tools.hs
src/Gargantext/Viz/Phylo/Tools.hs
+53
-4
Display.hs
src/Gargantext/Viz/Phylo/View/Display.hs
+9
-8
Export.hs
src/Gargantext/Viz/Phylo/View/Export.hs
+66
-78
ViewMaker.hs
src/Gargantext/Viz/Phylo/View/ViewMaker.hs
+2
-2
No files found.
src/Gargantext/Viz/Phylo.hs
View file @
7c1ce395
...
@@ -362,6 +362,7 @@ data PhyloView = PhyloView
...
@@ -362,6 +362,7 @@ data PhyloView = PhyloView
,
_pv_title
::
Text
,
_pv_title
::
Text
,
_pv_description
::
Text
,
_pv_description
::
Text
,
_pv_filiation
::
Filiation
,
_pv_filiation
::
Filiation
,
_pv_level
::
Level
,
_pv_metrics
::
Map
Text
[
Double
]
,
_pv_metrics
::
Map
Text
[
Double
]
,
_pv_branches
::
[
PhyloBranch
]
,
_pv_branches
::
[
PhyloBranch
]
,
_pv_nodes
::
[
PhyloNode
]
,
_pv_nodes
::
[
PhyloNode
]
...
@@ -398,6 +399,7 @@ data PhyloNode = PhyloNode
...
@@ -398,6 +399,7 @@ data PhyloNode = PhyloNode
------------------------
------------------------
data
ExportMode
=
Json
|
Dot
|
Svg
data
DisplayMode
=
Flat
|
Nested
data
DisplayMode
=
Flat
|
Nested
-- | A PhyloQueryView describes a Phylo as an output view
-- | A PhyloQueryView describes a Phylo as an output view
...
@@ -421,6 +423,7 @@ data PhyloQueryView = PhyloQueryView
...
@@ -421,6 +423,7 @@ data PhyloQueryView = PhyloQueryView
,
_qv_sort
::
Maybe
(
Sort
,
Order
)
,
_qv_sort
::
Maybe
(
Sort
,
Order
)
-- A display mode to apply to the PhyloGraph, ie: [Node[Node,Edge],Edge] or [[Node,Node],[Edge,Edge]]
-- A display mode to apply to the PhyloGraph, ie: [Node[Node,Edge],Edge] or [[Node,Node],[Edge,Edge]]
,
_qv_export
::
ExportMode
,
_qv_display
::
DisplayMode
,
_qv_display
::
DisplayMode
,
_qv_verbose
::
Bool
,
_qv_verbose
::
Bool
}
}
...
...
src/Gargantext/Viz/Phylo/Example.hs
View file @
7c1ce395
...
@@ -28,6 +28,7 @@ TODO:
...
@@ -28,6 +28,7 @@ TODO:
module
Gargantext.Viz.Phylo.Example
where
module
Gargantext.Viz.Phylo.Example
where
import
Data.GraphViz.Types.Generalised
(
DotGraph
)
import
Data.Text
(
Text
)
import
Data.Text
(
Text
)
import
Data.List
((
++
),
last
)
import
Data.List
((
++
),
last
)
import
Data.Map
(
Map
)
import
Data.Map
(
Map
)
...
@@ -44,6 +45,7 @@ import Gargantext.Viz.Phylo.LevelMaker
...
@@ -44,6 +45,7 @@ import Gargantext.Viz.Phylo.LevelMaker
import
Gargantext.Viz.Phylo.LinkMaker
import
Gargantext.Viz.Phylo.LinkMaker
import
Gargantext.Viz.Phylo.Tools
import
Gargantext.Viz.Phylo.Tools
import
Gargantext.Viz.Phylo.View.ViewMaker
import
Gargantext.Viz.Phylo.View.ViewMaker
import
Gargantext.Viz.Phylo.View.Export
import
qualified
Data.List
as
List
import
qualified
Data.List
as
List
...
@@ -52,6 +54,9 @@ import qualified Data.List as List
...
@@ -52,6 +54,9 @@ import qualified Data.List as List
------------------------------------------------------
------------------------------------------------------
phyloDot
::
DotGraph
DotId
phyloDot
=
viewToDot
phyloView
phyloView
::
PhyloView
phyloView
::
PhyloView
phyloView
=
toPhyloView
(
queryParser'
queryViewEx
)
phyloFromQuery
phyloView
=
toPhyloView
(
queryParser'
queryViewEx
)
phyloFromQuery
...
@@ -69,7 +74,7 @@ queryViewEx = "level=3"
...
@@ -69,7 +74,7 @@ queryViewEx = "level=3"
phyloQueryView
::
PhyloQueryView
phyloQueryView
::
PhyloQueryView
phyloQueryView
=
PhyloQueryView
2
Merge
False
1
[
BranchAge
]
[
defaultSmallBranch
]
[
BranchLabelFreq
,
GroupLabelCooc
]
(
Just
(
ByBranchAge
,
Asc
))
Flat
True
phyloQueryView
=
PhyloQueryView
2
Merge
False
1
[
BranchAge
]
[
defaultSmallBranch
]
[
BranchLabelFreq
,
GroupLabelCooc
]
(
Just
(
ByBranchAge
,
Asc
))
Json
Flat
True
--------------------------------------------------
--------------------------------------------------
...
...
src/Gargantext/Viz/Phylo/Tools.hs
View file @
7c1ce395
...
@@ -586,6 +586,55 @@ getViewBranchIds v = map getBranchId $ v ^. pv_branches
...
@@ -586,6 +586,55 @@ getViewBranchIds v = map getBranchId $ v ^. pv_branches
-- | PhyloQuery & QueryView | --
-- | PhyloQuery & QueryView | --
--------------------------------
--------------------------------
-- | To filter PhyloView's Branches by level
filterBranchesByLevel
::
Level
->
PhyloView
->
[
PhyloBranch
]
filterBranchesByLevel
lvl
pv
=
filter
(
\
pb
->
lvl
==
(
fst
$
pb
^.
pb_id
))
$
pv
^.
pv_branches
-- | To filter PhyloView's Edges by level
filterEdgesByLevel
::
Level
->
[
PhyloEdge
]
->
[
PhyloEdge
]
filterEdgesByLevel
lvl
pes
=
filter
(
\
pe
->
(
lvl
==
((
snd
.
fst
)
$
pe
^.
pe_source
))
&&
(
lvl
==
((
snd
.
fst
)
$
pe
^.
pe_target
)))
pes
-- | To filter PhyloView's Edges by type
filterEdgesByType
::
EdgeType
->
[
PhyloEdge
]
->
[
PhyloEdge
]
filterEdgesByType
t
pes
=
filter
(
\
pe
->
t
==
(
pe
^.
pe_type
))
pes
-- | To filter PhyloView's Nodes by the oldest Period
filterNodesByFirstPeriod
::
[
PhyloNode
]
->
[
PhyloNode
]
filterNodesByFirstPeriod
pns
=
filter
(
\
pn
->
fstPrd
==
((
fst
.
fst
)
$
pn
^.
pn_id
))
pns
where
--------------------------------------
fstPrd
::
(
Date
,
Date
)
fstPrd
=
(
head'
"filterNodesByFirstPeriod"
)
$
sortOn
fst
$
map
(
\
pn
->
(
fst
.
fst
)
$
pn
^.
pn_id
)
pns
--------------------------------------
-- | To filter PhyloView's Nodes by Branch
filterNodesByBranch
::
PhyloBranchId
->
[
PhyloNode
]
->
[
PhyloNode
]
filterNodesByBranch
bId
pns
=
filter
(
\
pn
->
if
isJust
$
pn
^.
pn_bid
then
if
bId
==
(
fromJust
$
pn
^.
pn_bid
)
then
True
else
False
else
False
)
pns
-- | To filter PhyloView's Nodes by level
filterNodesByLevel
::
Level
->
[
PhyloNode
]
->
[
PhyloNode
]
filterNodesByLevel
lvl
pns
=
filter
(
\
pn
->
lvl
==
((
snd
.
fst
)
$
pn
^.
pn_id
))
pns
-- | To filter PhyloView's Nodes by Period
filterNodesByPeriod
::
PhyloPeriodId
->
[
PhyloNode
]
->
[
PhyloNode
]
filterNodesByPeriod
prd
pns
=
filter
(
\
pn
->
prd
==
((
fst
.
fst
)
$
pn
^.
pn_id
))
pns
-- | To get the first clustering method to apply to get the contextual units of a Phylo
-- | To get the first clustering method to apply to get the contextual units of a Phylo
getContextualUnit
::
PhyloQueryBuild
->
Cluster
getContextualUnit
::
PhyloQueryBuild
->
Cluster
getContextualUnit
q
=
q
^.
q_contextualUnit
getContextualUnit
q
=
q
^.
q_contextualUnit
...
@@ -667,9 +716,9 @@ initPhyloQuery name desc (def 5 -> grain) (def 3 -> steps) (def defaultFis -> cl
...
@@ -667,9 +716,9 @@ initPhyloQuery name desc (def 5 -> grain) (def 3 -> steps) (def defaultFis -> cl
-- | To initialize a PhyloQueryView default parameters
-- | To initialize a PhyloQueryView default parameters
initPhyloQueryView
::
Maybe
Level
->
Maybe
Filiation
->
Maybe
Bool
->
Maybe
Level
->
Maybe
[
Metric
]
->
Maybe
[
Filter
]
->
Maybe
[
Tagger
]
->
Maybe
(
Sort
,
Order
)
->
Maybe
DisplayMode
->
Maybe
Bool
->
PhyloQueryView
initPhyloQueryView
::
Maybe
Level
->
Maybe
Filiation
->
Maybe
Bool
->
Maybe
Level
->
Maybe
[
Metric
]
->
Maybe
[
Filter
]
->
Maybe
[
Tagger
]
->
Maybe
(
Sort
,
Order
)
->
Maybe
ExportMode
->
Maybe
DisplayMode
->
Maybe
Bool
->
PhyloQueryView
initPhyloQueryView
(
def
2
->
lvl
)
(
def
Descendant
->
f
)
(
def
False
->
c
)
(
def
1
->
d
)
(
def
[]
->
ms
)
(
def
[]
->
fs
)
(
def
[]
->
ts
)
s
(
def
Flat
->
dm
)
(
def
True
->
v
)
=
initPhyloQueryView
(
def
2
->
lvl
)
(
def
Descendant
->
f
)
(
def
False
->
c
)
(
def
1
->
d
)
(
def
[]
->
ms
)
(
def
[]
->
fs
)
(
def
[]
->
ts
)
s
(
def
Json
->
em
)
(
def
Flat
->
dm
)
(
def
True
->
v
)
=
PhyloQueryView
lvl
f
c
d
ms
fs
ts
s
dm
v
PhyloQueryView
lvl
f
c
d
ms
fs
ts
s
em
dm
v
-- | To define some obvious boolean getters
-- | To define some obvious boolean getters
...
@@ -716,7 +765,7 @@ defaultQuery = initPhyloQuery "Cesar et Cleôpatre" "An example of Phylomemy (fr
...
@@ -716,7 +765,7 @@ defaultQuery = initPhyloQuery "Cesar et Cleôpatre" "An example of Phylomemy (fr
Nothing
Nothing
Nothing
Nothing
Nothing
Nothing
Nothing
Nothing
Nothing
Nothing
Nothing
Nothing
Nothing
Nothing
Nothing
Nothing
defaultQueryView
::
PhyloQueryView
defaultQueryView
::
PhyloQueryView
defaultQueryView
=
initPhyloQueryView
Nothing
Nothing
Nothing
Nothing
Nothing
Nothing
Nothing
Nothing
Nothing
Nothing
defaultQueryView
=
initPhyloQueryView
Nothing
Nothing
Nothing
Nothing
Nothing
Nothing
Nothing
Nothing
Nothing
Nothing
Nothing
-- Software
-- Software
...
...
src/Gargantext/Viz/Phylo/View/Display.hs
View file @
7c1ce395
...
@@ -43,11 +43,12 @@ toNestedView ns ns'
...
@@ -43,11 +43,12 @@ toNestedView ns ns'
-- | To process a DisplayMode to a PhyloView
-- | To process a DisplayMode to a PhyloView
processDisplay
::
DisplayMode
->
PhyloView
->
PhyloView
processDisplay
::
DisplayMode
->
ExportMode
->
PhyloView
->
PhyloView
processDisplay
d
v
=
case
d
of
processDisplay
d
e
v
=
case
e
of
Flat
->
v
Json
->
case
d
of
Nested
->
let
ns
=
sortOn
getNodeLevel
$
v
^.
pv_nodes
Flat
->
v
lvl
=
getNodeLevel
$
head'
"processDisplay"
ns
Nested
->
let
ns
=
sortOn
getNodeLevel
$
v
^.
pv_nodes
in
v
&
pv_nodes
.~
toNestedView
(
filter
(
\
n
->
lvl
==
getNodeLevel
n
)
ns
)
lvl
=
getNodeLevel
$
head'
"processDisplay"
ns
(
filter
(
\
n
->
lvl
<
getNodeLevel
n
)
ns
)
in
v
&
pv_nodes
.~
toNestedView
(
filter
(
\
n
->
lvl
==
getNodeLevel
n
)
ns
)
--
_
->
panic
"[ERR][Viz.Phylo.Example.processDisplay] display not found"
(
filter
(
\
n
->
lvl
<
getNodeLevel
n
)
ns
)
_
->
v
src/Gargantext/Viz/Phylo/View/Export.hs
View file @
7c1ce395
...
@@ -53,70 +53,47 @@ viewToSvg v = undefined
...
@@ -53,70 +53,47 @@ viewToSvg v = undefined
-- | PhyloView to DOT | --
-- | PhyloView to DOT | --
--------------------------
--------------------------
--
From http://haroldcarr.com/posts/2014-02-28-using-graphviz-via-haskell.html
--
| From http://haroldcarr.com/posts/2014-02-28-using-graphviz-via-haskell.html & https://hackage.haskell.org/package/graphviz
-- | To create a custom Graphviz's Attribute
setAttr
::
AttributeName
->
T'
.
Text
->
CustomAttribute
setAttr
::
AttributeName
->
T'
.
Text
->
CustomAttribute
setAttr
k
v
=
customAttribute
k
v
setAttr
k
v
=
customAttribute
k
v
-- | To create customs Graphviz's Attributes out of some Metrics
setAttrFromMetrics
::
Map
T
.
Text
[
Double
]
->
[
CustomAttribute
]
setAttrFromMetrics
::
Map
T
.
Text
[
Double
]
->
[
CustomAttribute
]
setAttrFromMetrics
attrs
=
map
(
\
(
k
,
v
)
->
setAttr
(
fromStrict
k
)
setAttrFromMetrics
attrs
=
map
(
\
(
k
,
v
)
->
setAttr
(
fromStrict
k
)
$
(
pack
.
unwords
)
$
(
pack
.
unwords
)
$
map
show
v
)
$
toList
attrs
$
map
show
v
)
$
toList
attrs
getBranchDotId
::
PhyloBranchId
->
DotId
getBranchDotId
(
lvl
,
idx
)
=
fromStrict
$
T
.
pack
$
(
show
lvl
)
++
(
show
idx
)
getNodeDotId
::
PhyloGroupId
->
DotId
getNodeDotId
(((
d
,
d'
),
lvl
),
idx
)
=
fromStrict
$
T
.
pack
$
(
show
d
)
++
(
show
d'
)
++
(
show
lvl
)
++
(
show
idx
)
getPeriodDotId
::
PhyloPeriodId
->
DotId
getPeriodDotId
(
d
,
d'
)
=
fromStrict
$
T
.
pack
$
(
show
d
)
++
(
show
d'
)
getPeriodDotLabel
::
PhyloPeriodId
->
Label
getPeriodDotLabel
(
d
,
d'
)
=
toDotLabel
$
T
.
pack
$
(
show
d
)
++
" "
++
(
show
d'
)
getBranchesByLevel
::
Level
->
PhyloView
->
[
PhyloBranch
]
getBranchesByLevel
lvl
pv
=
filter
(
\
pb
->
lvl
==
(
fst
$
pb
^.
pb_id
))
$
pv
^.
pv_branches
filterNodesByPeriod
::
PhyloPeriodId
->
[
PhyloNode
]
->
[
PhyloNode
]
filterNodesByPeriod
prd
pns
=
filter
(
\
pn
->
prd
==
((
fst
.
fst
)
$
pn
^.
pn_id
))
pns
filterNodesByLevel
::
Level
->
[
PhyloNode
]
->
[
PhyloNode
]
-- | To transform a PhyloBranchId into a DotId
filterNodesByLevel
lvl
pns
=
filter
(
\
pn
->
lvl
==
((
snd
.
fst
)
$
pn
^.
pn_id
))
pns
toBranchDotId
::
PhyloBranchId
->
DotId
toBranchDotId
(
lvl
,
idx
)
=
fromStrict
$
T
.
pack
$
(
show
lvl
)
++
(
show
idx
)
filterNodesByBranch
::
PhyloBranchId
->
[
PhyloNode
]
->
[
PhyloNode
]
-- | To transform a PhyloGroupId into a DotId
filterNodesByBranch
bId
pns
=
filter
(
\
pn
->
if
isJust
$
pn
^.
pn_bid
toNodeDotId
::
PhyloGroupId
->
DotId
then
if
bId
==
(
fromJust
$
pn
^.
pn_bid
)
toNodeDotId
(((
d
,
d'
),
lvl
),
idx
)
=
fromStrict
$
T
.
pack
$
(
show
d
)
++
(
show
d'
)
++
(
show
lvl
)
++
(
show
idx
)
then
True
else
False
else
False
)
pns
filterEdgesByType
::
EdgeType
->
[
PhyloEdge
]
->
[
PhyloEdge
]
-- | To transform a PhyloPeriodId into a DotId
filterEdgesByType
t
pes
=
filter
(
\
pe
->
t
==
(
pe
^.
pe_type
))
pes
toPeriodDotId
::
PhyloPeriodId
->
DotId
toPeriodDotId
(
d
,
d'
)
=
fromStrict
$
T
.
pack
$
(
show
d
)
++
(
show
d'
)
filterEdgesByLevel
::
Level
->
[
PhyloEdge
]
->
[
PhyloEdge
]
filterEdgesByLevel
lvl
pes
=
filter
(
\
pe
->
(
lvl
==
((
snd
.
fst
)
$
pe
^.
pe_source
))
&&
(
lvl
==
((
snd
.
fst
)
$
pe
^.
pe_target
)))
pes
-- | To transform a PhyloPeriodId into a Graphviz's label
filterNodesByFirstPeriod
::
[
PhyloNode
]
->
[
PhyloNode
]
toPeriodDotLabel
::
PhyloPeriodId
->
Label
filterNodesByFirstPeriod
pns
=
filter
(
\
pn
->
fstPrd
==
((
fst
.
fst
)
$
pn
^.
pn_id
))
pns
toPeriodDotLabel
(
d
,
d'
)
=
toDotLabel
$
T
.
pack
$
(
show
d
)
++
" "
++
(
show
d'
)
where
--------------------------------------
fstPrd
::
(
Date
,
Date
)
fstPrd
=
(
head'
"filterNodesByFirstPeriod"
)
$
sortOn
fst
$
map
(
\
pn
->
(
fst
.
fst
)
$
pn
^.
pn_id
)
pns
--------------------------------------
-- | To get all the Phyloperiods covered by a PhyloView
getViewPeriods
::
PhyloView
->
[
PhyloPeriodId
]
getViewPeriods
::
PhyloView
->
[
PhyloPeriodId
]
getViewPeriods
pv
=
sortOn
fst
$
nub
$
map
(
\
pn
->
(
fst
.
fst
)
$
pn
^.
pn_id
)
$
pv
^.
pv_nodes
getViewPeriods
pv
=
sortOn
fst
$
nub
$
map
(
\
pn
->
(
fst
.
fst
)
$
pn
^.
pn_id
)
$
pv
^.
pv_nodes
-- | To get for each PhyloBranch, their corresponding oldest PhyloNodes
getFirstNodes
::
Level
->
PhyloView
->
[(
PhyloBranchId
,
PhyloGroupId
)]
getFirstNodes
::
Level
->
PhyloView
->
[(
PhyloBranchId
,
PhyloGroupId
)]
getFirstNodes
lvl
pv
=
concat
getFirstNodes
lvl
pv
=
concat
$
map
(
\
bId
->
map
(
\
pn
->
(
bId
,
pn
^.
pn_id
))
$
map
(
\
bId
->
map
(
\
pn
->
(
bId
,
pn
^.
pn_id
))
...
@@ -127,21 +104,28 @@ getFirstNodes lvl pv = concat
...
@@ -127,21 +104,28 @@ getFirstNodes lvl pv = concat
where
where
--------------------------------------
--------------------------------------
bIds
::
[
PhyloBranchId
]
bIds
::
[
PhyloBranchId
]
bIds
=
map
getBranchId
$
get
BranchesByLevel
lvl
pv
bIds
=
map
getBranchId
$
filter
BranchesByLevel
lvl
pv
--------------------------------------
--------------------------------------
-- | To transform a Text into a Graphviz's Label
toDotLabel
::
T
.
Text
->
Label
toDotLabel
::
T
.
Text
->
Label
toDotLabel
lbl
=
StrLabel
$
fromStrict
lbl
toDotLabel
lbl
=
StrLabel
$
fromStrict
lbl
-- | To set a Peak Node
setPeakDotNode
::
PhyloBranch
->
Dot
DotId
setPeakDotNode
::
PhyloBranch
->
Dot
DotId
setPeakDotNode
pb
=
node
(
get
BranchDotId
$
pb
^.
pb_id
)
setPeakDotNode
pb
=
node
(
to
BranchDotId
$
pb
^.
pb_id
)
([
FillColor
[
toWColor
CornSilk
],
FontName
"Arial"
,
FontSize
40
,
Shape
Egg
,
Style
[
SItem
Bold
[]
],
Label
(
toDotLabel
$
pb
^.
pb_label
)]
([
FillColor
[
toWColor
CornSilk
],
FontName
"Arial"
,
FontSize
40
,
Shape
Egg
,
Style
[
SItem
Bold
[]
],
Label
(
toDotLabel
$
pb
^.
pb_label
)]
<>
(
setAttrFromMetrics
$
pb
^.
pb_metrics
))
<>
(
setAttrFromMetrics
$
pb
^.
pb_metrics
))
-- | To set a Peak Edge
setPeakDotEdge
::
DotId
->
DotId
->
Dot
DotId
setPeakDotEdge
::
DotId
->
DotId
->
Dot
DotId
setPeakDotEdge
bId
nId
=
edge
bId
nId
[
Width
3
,
Color
[
toWColor
Black
],
ArrowHead
(
AType
[(
ArrMod
FilledArrow
RightSide
,
DotArrow
)])]
setPeakDotEdge
bId
nId
=
edge
bId
nId
[
Width
3
,
Color
[
toWColor
Black
],
ArrowHead
(
AType
[(
ArrMod
FilledArrow
RightSide
,
DotArrow
)])]
-- | To set an HTML table
setHtmlTable
::
PhyloNode
->
H
.
Label
setHtmlTable
::
PhyloNode
->
H
.
Label
setHtmlTable
pn
=
H
.
Table
H
.
HTable
setHtmlTable
pn
=
H
.
Table
H
.
HTable
{
H
.
tableFontAttrs
=
Just
[
H
.
PointSize
14
,
H
.
Align
H
.
HLeft
]
{
H
.
tableFontAttrs
=
Just
[
H
.
PointSize
14
,
H
.
Align
H
.
HLeft
]
...
@@ -160,66 +144,70 @@ setHtmlTable pn = H.Table H.HTable
...
@@ -160,66 +144,70 @@ setHtmlTable pn = H.Table H.HTable
--------------------------------------
--------------------------------------
-- | To set a Node
setDotNode
::
PhyloNode
->
Dot
DotId
setDotNode
::
PhyloNode
->
Dot
DotId
setDotNode
pn
=
node
(
get
NodeDotId
$
pn
^.
pn_id
)
setDotNode
pn
=
node
(
to
NodeDotId
$
pn
^.
pn_id
)
([
FontName
"Arial"
,
Shape
Square
,
toLabel
(
setHtmlTable
pn
)])
([
FontName
"Arial"
,
Shape
Square
,
toLabel
(
setHtmlTable
pn
)])
-- | To set an Edge
setDotEdge
::
PhyloEdge
->
Dot
DotId
setDotEdge
::
PhyloEdge
->
Dot
DotId
setDotEdge
pe
=
edge
(
getNodeDotId
$
pe
^.
pe_source
)
(
getNodeDotId
$
pe
^.
pe_target
)
[
Width
2
,
Color
[
toWColor
Black
]]
setDotEdge
pe
=
edge
(
toNodeDotId
$
pe
^.
pe_source
)
(
toNodeDotId
$
pe
^.
pe_target
)
[
Width
2
,
Color
[
toWColor
Black
]]
-- | To set a Period Edge
setDotPeriodEdge
::
(
PhyloPeriodId
,
PhyloPeriodId
)
->
Dot
DotId
setDotPeriodEdge
::
(
PhyloPeriodId
,
PhyloPeriodId
)
->
Dot
DotId
setDotPeriodEdge
(
prd
,
prd'
)
=
edge
(
getPeriodDotId
prd
)
(
get
PeriodDotId
prd'
)
[
Width
5
,
Color
[
toWColor
Black
]]
setDotPeriodEdge
(
prd
,
prd'
)
=
edge
(
toPeriodDotId
prd
)
(
to
PeriodDotId
prd'
)
[
Width
5
,
Color
[
toWColor
Black
]]
viewToDot
::
PhyloView
->
Level
->
DotGraph
DotId
-- | To transform a given PhyloView into the corresponding GraphViz Graph (ie: Dot format)
viewToDot
pv
lvl
=
digraph
((
Str
.
fromStrict
)
$
pv
^.
pv_title
)
viewToDot
::
PhyloView
->
DotGraph
DotId
viewToDot
pv
=
digraph
((
Str
.
fromStrict
)
$
pv
^.
pv_title
)
$
do
$
do
-- set the global graph attributes
-- set the global graph attributes
graphAttrs
(
[
Label
(
toDotLabel
$
pv
^.
pv_title
)]
graphAttrs
(
[
Label
(
toDotLabel
$
pv
^.
pv_title
)]
<>
[
setAttr
"description"
$
fromStrict
$
pv
^.
pv_description
]
<>
[
setAttr
"description"
$
fromStrict
$
pv
^.
pv_description
]
<>
[
setAttr
"filiation"
$
(
pack
.
show
)
$
pv
^.
pv_filiation
]
<>
[
setAttr
"filiation"
$
(
pack
.
show
)
$
pv
^.
pv_filiation
]
<>
(
setAttrFromMetrics
$
pv
^.
pv_metrics
)
<>
(
setAttrFromMetrics
$
pv
^.
pv_metrics
)
<>
[
FontSize
(
fromIntegral
30
),
LabelLoc
VTop
,
Splines
SplineEdges
,
Overlap
ScaleOverlaps
,
<>
[
FontSize
(
fromIntegral
30
),
LabelLoc
VTop
,
Splines
SplineEdges
,
Overlap
ScaleOverlaps
,
Ratio
AutoRatio
,
Style
[
SItem
Filled
[]
],
Color
[
toWColor
White
]])
Ratio
AutoRatio
,
Style
[
SItem
Filled
[]
],
Color
[
toWColor
White
]])
-- set the peaks
-- set the peaks
subgraph
(
Str
"Peaks"
)
subgraph
(
Str
"Peaks"
)
$
do
$
do
graphAttrs
[
Rank
SameRank
]
graphAttrs
[
Rank
SameRank
]
mapM
setPeakDotNode
$
filterBranchesByLevel
(
pv
^.
pv_level
)
pv
mapM
setPeakDotNode
$
getBranchesByLevel
lvl
pv
-- set the nodes, period by period
-- set the nodes, period by period
mapM
(
\
prd
->
subgraph
(
Str
$
fromStrict
$
T
.
pack
$
"subGraph "
++
(
show
$
(
fst
prd
))
++
(
show
$
(
snd
prd
)))
mapM
(
\
prd
->
$
do
subgraph
(
Str
$
fromStrict
$
T
.
pack
$
"subGraph "
++
(
show
$
(
fst
prd
))
++
(
show
$
(
snd
prd
)))
graphAttrs
[
Rank
SameRank
]
$
do
-- set the period label
graphAttrs
[
Rank
SameRank
]
node
(
toPeriodDotId
prd
)
[
Shape
Square
,
FontSize
50
,
Label
(
toPeriodDotLabel
prd
)
]
-- set the period label
mapM
setDotNode
$
filterNodesByPeriod
prd
$
filterNodesByLevel
(
pv
^.
pv_level
)
(
pv
^.
pv_nodes
)
node
(
getPeriodDotId
prd
)
[
Shape
Square
,
FontSize
50
,
Label
(
getPeriodDotLabel
prd
)]
)
$
getViewPeriods
pv
mapM
setDotNode
$
filterNodesByPeriod
prd
$
filterNodesByLevel
lvl
(
pv
^.
pv_nodes
)
-- set the edges : from peaks to nodes, from nodes to nodes, from periods to periods
)
$
getViewPeriods
pv
-- set the edges : from peaks to nodes, from nodes to nodes, from periods to periods
mapM
(
\
(
bId
,
nId
)
->
setPeakDotEdge
(
toBranchDotId
bId
)
(
toNodeDotId
nId
))
$
getFirstNodes
(
pv
^.
pv_level
)
pv
mapM
(
\
(
bId
,
nId
)
->
setPeakDotEdge
(
getBranchDotId
bId
)
(
getNodeDotId
nId
))
$
getFirstNodes
lvl
pv
mapM
setDotEdge
$
filterEdgesByLevel
(
pv
^.
pv_level
)
$
filterEdgesByType
PeriodEdge
(
pv
^.
pv_edges
)
mapM
setDotEdge
$
filterEdgesByLevel
lvl
$
filterEdgesByType
PeriodEdge
(
pv
^.
pv_edges
)
mapM
setDotPeriodEdge
$
listToSequentialCombi
$
getViewPeriods
pv
mapM
setDotPeriodEdge
$
listToSequentialCombi
$
getViewPeriods
pv
...
...
src/Gargantext/Viz/Phylo/View/ViewMaker.hs
View file @
7c1ce395
...
@@ -46,7 +46,7 @@ initPhyloEdge id pts et = map (\pt -> PhyloEdge id (fst pt) et (snd pt)) pts
...
@@ -46,7 +46,7 @@ initPhyloEdge id pts et = map (\pt -> PhyloEdge id (fst pt) et (snd pt)) pts
-- | To init a PhyloView
-- | To init a PhyloView
initPhyloView
::
Level
->
Text
->
Text
->
Filiation
->
Bool
->
Phylo
->
PhyloView
initPhyloView
::
Level
->
Text
->
Text
->
Filiation
->
Bool
->
Phylo
->
PhyloView
initPhyloView
lvl
lbl
dsc
fl
vb
p
=
PhyloView
(
getPhyloParams
p
)
lbl
dsc
fl
empty
initPhyloView
lvl
lbl
dsc
fl
vb
p
=
PhyloView
(
getPhyloParams
p
)
lbl
dsc
fl
lvl
empty
(
[]
++
(
phyloToBranches
lvl
p
))
(
[]
++
(
phyloToBranches
lvl
p
))
(
[]
++
(
groupsToNodes
True
vb
(
getPeaksLabels
p
)
gs
))
(
[]
++
(
groupsToNodes
True
vb
(
getPeaksLabels
p
)
gs
))
(
[]
++
(
groupsToEdges
fl
PeriodEdge
gs
))
(
[]
++
(
groupsToEdges
fl
PeriodEdge
gs
))
...
@@ -135,7 +135,7 @@ addChildNodes shouldDo lvl lvlMin vb fl p v =
...
@@ -135,7 +135,7 @@ addChildNodes shouldDo lvl lvlMin vb fl p v =
-- | To transform a PhyloQuery into a PhyloView
-- | To transform a PhyloQuery into a PhyloView
toPhyloView
::
PhyloQueryView
->
Phylo
->
PhyloView
toPhyloView
::
PhyloQueryView
->
Phylo
->
PhyloView
toPhyloView
q
p
=
processDisplay
(
q
^.
qv_display
)
toPhyloView
q
p
=
processDisplay
(
q
^.
qv_display
)
(
q
^.
qv_export
)
$
processSort
(
q
^.
qv_sort
)
p
$
processSort
(
q
^.
qv_sort
)
p
$
processTaggers
(
q
^.
qv_taggers
)
p
$
processTaggers
(
q
^.
qv_taggers
)
p
$
processFilters
(
q
^.
qv_filters
)
p
$
processFilters
(
q
^.
qv_filters
)
p
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment