Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
purescript-gargantext
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
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
Grégoire Locqueville
purescript-gargantext
Commits
f6a3ba42
Verified
Commit
f6a3ba42
authored
May 23, 2023
by
Przemyslaw Kaminski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[phylo] some types fixes
parent
55589ac8
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
70 additions
and
70 deletions
+70
-70
JSON.purs
src/Gargantext/Components/PhyloExplorer/JSON.purs
+32
-32
Types.purs
src/Gargantext/Components/PhyloExplorer/Types.purs
+38
-38
No files found.
src/Gargantext/Components/PhyloExplorer/JSON.purs
View file @
f6a3ba42
...
@@ -21,8 +21,8 @@ newtype PhyloJSON = PhyloJSON
...
@@ -21,8 +21,8 @@ newtype PhyloJSON = PhyloJSON
, pd_data ::
, pd_data ::
{ _subgraph_cnt :: Int
{ _subgraph_cnt :: Int
, directed :: Boolean
, directed :: Boolean
, edges ::
Array RawEdge
, edges ::
Maybe (Array RawEdge)
, objects ::
Array RawObject
, objects ::
Maybe (Array RawObject)
, strict :: Boolean
, strict :: Boolean
| GraphData
| GraphData
}
}
...
@@ -65,65 +65,65 @@ type GraphData =
...
@@ -65,65 +65,65 @@ type GraphData =
--------------------------------------------------
--------------------------------------------------
type NodeData =
type NodeData =
( height :: String
( height ::
Maybe
String
, label :: String
, label :: String
, name :: String
, name :: String
, nodeType :: String
, nodeType ::
Maybe
String
, pos :: String
, pos ::
Maybe
String
, shape :: String
, shape ::
Maybe
String
, width :: String
, width ::
Maybe
String
)
)
data RawObject
data RawObject
= GroupToNode
= GroupToNode
{ _gvid :: Int
{ _gvid :: Int
, bId :: String
, bId ::
Maybe
String
, branchId :: String
, branchId ::
Maybe
String
, fontname :: String
, fontname ::
Maybe
String
, foundation :: String
, foundation ::
Maybe
String
, frequence :: String
, frequence ::
Maybe
String
, from :: String
, from ::
Maybe
String
, lbl :: String
, lbl ::
Maybe
String
, penwidth :: String
, penwidth ::
Maybe
String
, role :: String
, role ::
Maybe
String
-- @NOTE #219: not in API; but present in certain data (eg. "Knowledge
-- @NOTE #219: not in API; but present in certain data (eg. "Knowledge
-- visualisation")
-- visualisation")
, seaLvl :: Maybe String
, seaLvl :: Maybe String
, source :: String
, source ::
Maybe
String
, strFrom :: Maybe String
, strFrom :: Maybe String
, strTo :: Maybe String
, strTo :: Maybe String
, support :: String
, support ::
Maybe
String
, to :: String
, to ::
Maybe
String
, weight :: String
, weight ::
Maybe
String
| NodeData
| NodeData
}
}
| BranchToNode
| BranchToNode
{ _gvid :: Int
{ _gvid :: Int
, age :: String
, age ::
Maybe
String
, bId :: String
, bId ::
Maybe
String
, birth :: String
, birth ::
Maybe
String
, branchId :: String
, branchId ::
Maybe
String
, branch_x :: String
, branch_x ::
Maybe
String
, branch_y :: String
, branch_y ::
Maybe
String
, fillcolor :: String
, fillcolor ::
Maybe
String
, fontname :: String
, fontname ::
Maybe
String
, fontsize :: String
, fontsize :: String
, size :: String
, size ::
Maybe
String
, style :: String
, style :: String
| NodeData
| NodeData
}
}
| PeriodToNode
| PeriodToNode
{ _gvid :: Int
{ _gvid :: Int
, fontsize :: String
, fontsize :: String
, from :: String
, from ::
Maybe
String
, strFrom :: Maybe String
, strFrom :: Maybe String
, strTo :: Maybe String
, strTo :: Maybe String
, to :: String
, to ::
Maybe
String
| NodeData
| NodeData
}
}
| Layer
| Layer
{ _gvid :: Int
{ _gvid :: Int
, nodes ::
Array Int
, nodes ::
Maybe (Array Int)
| GraphData
| GraphData
}
}
...
...
src/Gargantext/Components/PhyloExplorer/Types.purs
View file @
f6a3ba42
...
@@ -22,7 +22,7 @@ import Data.Date as Date
...
@@ -22,7 +22,7 @@ import Data.Date as Date
import Data.Generic.Rep (class Generic)
import Data.Generic.Rep (class Generic)
import Data.FunctorWithIndex (mapWithIndex)
import Data.FunctorWithIndex (mapWithIndex)
import Data.Int as Int
import Data.Int as Int
import Data.Maybe (Maybe(..), maybe)
import Data.Maybe (Maybe(..), maybe
, fromMaybe
)
import Data.Newtype (class Newtype)
import Data.Newtype (class Newtype)
import Data.Number as Number
import Data.Number as Number
import Data.Show.Generic (genericShow)
import Data.Show.Generic (genericShow)
...
@@ -85,12 +85,12 @@ parseToPhyloSet (PhyloJSON o) = PhyloSet
...
@@ -85,12 +85,12 @@ parseToPhyloSet (PhyloJSON o) = PhyloSet
epochTS = p.phyloTimeScale == "epoch"
epochTS = p.phyloTimeScale == "epoch"
ancestorLinks = parseAncestorLinks p.edges
ancestorLinks = parseAncestorLinks
$ fromMaybe []
p.edges
branchLinks = parseBranchLinks p.edges
branchLinks = parseBranchLinks
$ fromMaybe []
p.edges
branches = parseBranches p.objects
branches = parseBranches
$ fromMaybe []
p.objects
groups = parseGroups epochTS p.objects
groups = parseGroups epochTS
$ fromMaybe []
p.objects
links = parseLinks p.edges
links = parseLinks
$ fromMaybe []
p.edges
periods = parsePeriods epochTS p.objects
periods = parsePeriods epochTS
$ fromMaybe []
p.objects
----------------------------------------------------------------------
----------------------------------------------------------------------
...
@@ -121,12 +121,12 @@ instance Show PhyloData where show = genericShow
...
@@ -121,12 +121,12 @@ instance Show PhyloData where show = genericShow
-----------------------------------------------------------
-----------------------------------------------------------
newtype Branch = Branch
newtype Branch = Branch
{ bId :: Int
{ bId ::
Maybe
Int
, gvid :: Int
, gvid :: Int
, label :: String
, label :: String
, x1 :: String
, x1 ::
Maybe
String
, x2 :: Number
, x2 ::
Maybe
Number
, y :: String
, y ::
Maybe
String
}
}
derive instance Generic Branch _
derive instance Generic Branch _
...
@@ -141,11 +141,11 @@ parseBranches
...
@@ -141,11 +141,11 @@ parseBranches
where
where
parse :: RawObject -> Maybe Branch
parse :: RawObject -> Maybe Branch
parse (BranchToNode o) = Just $ Branch
parse (BranchToNode o) = Just $ Branch
{ bId : parseInt o.bId
{ bId : parseInt
<$>
o.bId
, gvid : o._gvid
, gvid : o._gvid
, label : parseLabel o.label
, label : parseLabel o.label
, x1 : o.branch_x
, x1 : o.branch_x
, x2 : Tuple.fst
$ parsePos
o.pos
, x2 : Tuple.fst
<$> parsePos <$>
o.pos
, y : o.branch_y
, y : o.branch_y
}
}
parse _ = Nothing
parse _ = Nothing
...
@@ -157,9 +157,9 @@ parseBranches
...
@@ -157,9 +157,9 @@ parseBranches
-----------------------------------------------------------
-----------------------------------------------------------
newtype Period = Period
newtype Period = Period
{ from :: Date.Date
{ from ::
Maybe
Date.Date
, to :: Date.Date
, to ::
Maybe
Date.Date
, y :: Number
, y ::
Maybe
Number
}
}
derive instance Generic Period _
derive instance Generic Period _
...
@@ -174,27 +174,27 @@ parsePeriods epoch
...
@@ -174,27 +174,27 @@ parsePeriods epoch
where
where
parse :: RawObject -> Maybe Period
parse :: RawObject -> Maybe Period
parse (PeriodToNode o) = Just $ Period
parse (PeriodToNode o) = Just $ Period
{ from :
parseNodeDate o.strFrom o.from epoch
{ from :
(\f -> parseNodeDate o.strFrom f epoch) <$> o.from
, to :
parseNodeDate o.strTo o.to epoch
, to :
(\t -> parseNodeDate o.strTo t epoch) <$> o.to
, y : Tuple.snd
$ parsePos
o.pos
, y : Tuple.snd
<$> parsePos <$>
o.pos
}
}
parse _ = Nothing
parse _ = Nothing
-----------------------------------------------------------
-----------------------------------------------------------
newtype Group = Group
newtype Group = Group
{ bId :: Int
{ bId ::
Maybe
Int
, foundation :: Array Int -- @NOTE #219: Array String ???
, foundation :: Array Int -- @NOTE #219: Array String ???
, from :: Date.Date
, from ::
Maybe
Date.Date
, gId :: Int
, gId :: Int
, label :: Array String
, label :: Array String
, role :: Array Int
, role :: Array Int
, size :: Int
, size ::
Maybe
Int
, source :: Array String
, source :: Array String
, to :: Date.Date
, to ::
Maybe
Date.Date
, weight :: Number
, weight ::
Maybe
Number
, x :: Number
, x ::
Maybe
Number
, y :: Number
, y ::
Maybe
Number
}
}
derive instance Generic Group _
derive instance Generic Group _
...
@@ -209,18 +209,18 @@ parseGroups epoch
...
@@ -209,18 +209,18 @@ parseGroups epoch
where
where
parse :: RawObject -> Maybe Group
parse :: RawObject -> Maybe Group
parse (GroupToNode o) = Just $ Group
parse (GroupToNode o) = Just $ Group
{ bId : parseInt o.bId
{ bId : parseInt
<$>
o.bId
, foundation :
stringedArrayToArray'
o.foundation
, foundation :
fromMaybe [] $ stringedArrayToArray' <$>
o.foundation
, from :
parseNodeDate o.strFrom o.from epoch
, from :
(\f -> parseNodeDate o.strFrom f epoch) <$> o.from
, gId : o._gvid
, gId : o._gvid
, label :
stringedArrayToArray
o.lbl
, label :
fromMaybe [] $ stringedArrayToArray <$>
o.lbl
, role :
stringedArrayToArray_
o.role
, role :
fromMaybe [] $ stringedArrayToArray_ <$>
o.role
, size : parseInt o.support
, size : parseInt
<$>
o.support
, source :
parseSources
o.source
, source :
fromMaybe [] $ parseSources <$>
o.source
, to :
parseNodeDate o.strTo o.to epoch
, to :
(\to -> parseNodeDate o.strTo to epoch) <$> o.to
, weight : stringedMaybeToNumber o.weight
, weight : stringedMaybeToNumber
<$>
o.weight
, x : Tuple.fst
$ parsePos
o.pos
, x : Tuple.fst
<$> parsePos <$>
o.pos
, y : Tuple.snd
$ parsePos
o.pos
, y : Tuple.snd
<$> parsePos <$>
o.pos
}
}
parse _ = Nothing
parse _ = Nothing
...
@@ -433,7 +433,7 @@ getGlobalWeightedValue
...
@@ -433,7 +433,7 @@ getGlobalWeightedValue
= Array.last
= Array.last
>>> case _ of
>>> case _ of
Nothing -> false
Nothing -> false
Just (Group o) -> o.weight > 0.0
Just (Group o) ->
fromMaybe 0.0
o.weight > 0.0
stringedMaybeToNumber :: String -> Number
stringedMaybeToNumber :: String -> Number
stringedMaybeToNumber "Nothing" = 0.0
stringedMaybeToNumber "Nothing" = 0.0
...
...
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