Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

standardize and export getter names #190

Merged
merged 9 commits into from
Jan 22, 2023
2 changes: 1 addition & 1 deletion docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ makedocs(
"Home" => "index.md",
"Manual" => [
"Installation" => "man/installation.md",
#"Network manipulation" => "man/netmanipulation.md",
"Network manipulation" => "man/netmanipulation.md",
"Input Data for SNaQ" => "man/inputdata.md",
"TICR pipeline" => "man/ticr_howtogetQuartetCFs.md",
"Network estimation and display" => "man/snaq_plot.md",
Expand Down
2 changes: 1 addition & 1 deletion docs/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ for network inference:
```@contents
Pages = [
"man/installation.md",
# "man/netmanipulation.md",
"man/netmanipulation.md",
"man/inputdata.md",
"man/ticr_howtogetQuartetCFs.md",
"man/snaq_plot.md",
Expand Down
38 changes: 29 additions & 9 deletions docs/src/lib/public.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,36 @@ Private = false
Order = [:type]
```

## utilities
## basic utilities

```@docs
tipLabels
sorttaxa!
printEdges
printNodes
summarizeDataCF
getroot
isrootof
#isleaf
#isexternal
isparentof
#ischildof
hassinglechild
getchild
#getchildren
#getchildedge
getparent
#getparents
#getparentminor
#getparentedge
#getparentedgeminor
getpartneredge
getNodeAges
pairwiseTaxonDistanceMatrix
```

## utilities to manipulate networks

```@docs
sorttaxa!
directEdges!
checkroot!
preorder!
Expand All @@ -46,15 +68,9 @@ shrink2cycles!
shrink3cycles!
deleteHybridThreshold!
rotate!
getindex(::TraitSimulation, ::Symbol)
getNodeAges
pairwiseTaxonDistanceMatrix
biconnectedComponents
blobDecomposition
treeedgecomponents
getlabels
nparams
mapindividuals
nni!
```

Expand Down Expand Up @@ -87,6 +103,7 @@ mapAllelesCFtable
snaq!
topologyMaxQPseudolik!
topologyQPseudolik!
summarizeDataCF
fittedQuartetCF
bootsnaq
calibrateFromPairwiseDistances!
Expand Down Expand Up @@ -131,6 +148,7 @@ regressorShift
regressorHybrid
sharedPathMatrix
vcv
getindex(::TraitSimulation, ::Symbol)
```

## discrete trait evolution
Expand All @@ -143,7 +161,9 @@ randomTrait
randomTrait!
fitdiscrete
maxParsimonyNet
getlabels
nstates
nparams
stationary
empiricalDNAfrequencies
```
15 changes: 11 additions & 4 deletions docs/src/man/netmanipulation.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,17 @@ To traverse or learn something about a network, node or edge, see for example:
- [`displayedTrees`](@ref), [`majorTree`](@ref),
[`biconnectedComponents`](@ref), [`PhyloNetworks.blobInfo`](@ref)
- [`hardwiredCluster`](@ref), [`hardwiredClusters`](@ref)
- [`PhyloNetworks.getPartner`](@ref),
[`PhyloNetworks.getChild`](@ref), [`PhyloNetworks.getChildren`](@ref), [`PhyloNetworks.getChildEdge`](@ref)
[`PhyloNetworks.getParent`](@ref), [`PhyloNetworks.getParents`](@ref),
[`PhyloNetworks.getMajorParent`](@ref), [`PhyloNetworks.getMajorParentEdge`](@ref),
- [`getroot`](@ref), [`isrootof`](@ref),
[`isleaf`](@ref PhyloNetworks.isrootof), [`isexternal`](@ref PhyloNetworks.isrootof),
[`isparentof`](@ref), [`ischildof`](@ref PhyloNetworks.isparentof),
[`hassinglechild`](@ref),
- [`getchild`](@ref), [`getchildren`](@ref PhyloNetworks.getchild),
[`getchildedge`](@ref PhyloNetworks.getchild)
[`getparent`](@ref), [`getparents`](@ref PhyloNetworks.getparent),
[`getparentminor`](@ref PhyloNetworks.getparent),
[`getparentedge`](@ref PhyloNetworks.getparent),
[`getparentedgeminor`](@ref PhyloNetworks.getparent),
[`getpartneredge`](@ref)

To modify a network, for example:
- [`rootonedge!`](@ref), [`rootatnode!`](@ref):
Expand Down
22 changes: 18 additions & 4 deletions src/PhyloNetworks.jl
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,25 @@ module PhyloNetworks
readSnaqNetwork,
topologyMaxQPseudolik!,
topologyQPseudolik!,
## getters
# fixit: add ancestors? getsibling? getdescendants (currently descendants)?
getroot,
isrootof,
isleaf,
isexternal,
isparentof,
ischildof,
hassinglechild,
getchild,
getchildren,
getchildedge,
getparent,
getparents,
getparentminor,
getparentedge,
getparentedgeminor,
getpartneredge,
## Network Manipulation
# getParent, getParents, getMajorParentEdge, getMinorParentEdge, getChildren,
# functions above: first rename them throughout to be consistent with other packages, like:
# parent child parents children parentmajor parentminor ancestor sibling offspring
rootatnode!,
rootonedge!,
directEdges!,
Expand All @@ -96,7 +111,6 @@ module PhyloNetworks
biconnectedComponents,
blobDecomposition!,
blobDecomposition,
mapindividuals,
nni!,
checkroot!,
treeedgecomponents,
Expand Down
16 changes: 8 additions & 8 deletions src/addHybrid.jl
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ julia> PhyloNetworks.addhybridedge!(net, true, true)
name:H3
hybrid node
attached to 3 edges, numbered: 5 16 17
, PhyloNetworks.Edge:
, PhyloNetworks.EdgeT{PhyloNetworks.Node}:
number:17
length:0.01
minor hybrid edge with gamma=0.32771460911632916
Expand Down Expand Up @@ -77,8 +77,8 @@ function addhybridedge!(net::HybridNetwork, nohybridladder::Bool, no3cycle::Bool
continue # if (e1,e2) was already attempted
nattempts += 1
## check that constraints are met
p1 = getParent(edge1)
p2 = getParent(edge2)
p1 = getparent(edge1)
p2 = getparent(edge2)
constraintsmet = true
for con in constraints
if con.type == 1 # forbid going out of (edge1) or into (edge2) the species group
Expand All @@ -97,7 +97,7 @@ function addhybridedge!(net::HybridNetwork, nohybridladder::Bool, no3cycle::Bool
end
## check for no hybrid ladder, if requested:
# edge2 cannot be a hybrid edge or the child of a hybrid node
if nohybridladder && (edge2.hybrid || getParent(edge2).hybrid)
if nohybridladder && (edge2.hybrid || getparent(edge2).hybrid)
push!(blacklist, (e1,e2))
continue
end
Expand Down Expand Up @@ -151,7 +151,7 @@ julia> hybnode, hybedge = PhyloNetworks.addhybridedge!(net, net.edge[13], net.ed
name:H3
hybrid node
attached to 3 edges, numbered: 8 16 17
, PhyloNetworks.Edge:
, PhyloNetworks.EdgeT{PhyloNetworks.Node}:
number:17
length:0.0
minor hybrid edge with gamma=0.2
Expand Down Expand Up @@ -182,7 +182,7 @@ function addhybridedge!(net::HybridNetwork, edge1::Edge, edge2::Edge, hybridpart
edgeabovee2.isMajor = false
end
else
c2 = getChild(edge2) # child of edge2 before we switch its direction
c2 = getchild(edge2) # child of edge2 before we switch its direction
i2 = findfirst(isequal(c2), net.node)
net.root = i2 # makes c2 the new root node
edge2.hybrid = true
Expand Down Expand Up @@ -245,13 +245,13 @@ Output: `true` if a conflict would arise (non-DAG), `false` if no conflict.
"""
function directionalconflict(net::HybridNetwork, parent::Node, edge2::Edge, hybridpartnernew::Bool)
if hybridpartnernew # all edges would retain their directions: use isChild1 fields
c2 = getChild(edge2)
c2 = getchild(edge2)
return parent === c2 || isdescendant(parent, c2)
else # after hybrid addition, edge 2 would be reversed: "up" toward its own parent
if !edge2.containRoot || edge2.hybrid
return true # direction of edge2 cannot be reversed
else # net would be a DAG with reversed directions, could even be rooted on edge2
p2 = getParent(edge2)
p2 = getparent(edge2)
return parent === p2 || isdescendant_undirected(parent, p2, edge2)
end
end
Expand Down
8 changes: 4 additions & 4 deletions src/addHybrid_snaq.jl
Original file line number Diff line number Diff line change
Expand Up @@ -410,8 +410,8 @@ function addHybridBetweenClades!(hybnum::Number,sisnum::Number,net::HybridNetwor
sisind = getIndexNode(sisnum,net)

## hybridization ed1->ed2
edge1 = getMajorParentEdge(net.node[sisind])
edge2 = getMajorParentEdge(net.node[hybind])
edge1 = getparentedge(net.node[sisind]) # major parent edges
edge2 = getparentedge(net.node[hybind])

edge3,edge4 = parameters4createHybrid!(edge1, edge2,net)
hybridnode = createHybrid!(edge1, edge2, edge3, edge4, net, 0.1) ## gamma=0.1, fixed later
Expand All @@ -434,9 +434,9 @@ function addHybridBetweenClades!(hybnum::Number,sisnum::Number,net::HybridNetwor
edge2.isChild1 = false
end
## used gamma=0.1 to make the new edge a minor edge, but we really do not have gamma value:
emaj = getMajorParentEdge(hybridnode)
emaj = getparentedge(hybridnode)
emaj.gamma = -1
e = getMinorParentEdge(hybridnode)
e = getparentedgeminor(hybridnode)
e.gamma = -1
return e.number
end
Loading