Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Yoann DUFRESNE
linked reads molecule ordering
Commits
ba61e7d2
Commit
ba61e7d2
authored
Aug 13, 2019
by
Yoann Dufresne
Browse files
refactor mains and subgraph definition to be coherent with nx graph heritage
parent
3474f04e
Changes
4
Hide whitespace changes
Inline
Side-by-side
deconvolution/d2_graph.py
View file @
ba61e7d2
...
...
@@ -23,6 +23,14 @@ class D2Graph(nx.Graph):
self
.
barcode_edge_idxs
[(
edge
[
1
],
edge
[
0
])]
=
idx
""" Redefine subgraph to avoid errors type instantiation errors.
"""
def
subgraph
(
self
,
nodes
):
G
=
nx
.
Graph
()
G
.
add_edges_from
(
self
.
edges
())
return
G
.
subgraph
(
nodes
)
def
construct_from_barcodes
(
self
,
index_size
=
3
,
verbose
=
True
,
debug
=
False
):
# Compute all the d-graphs
if
verbose
:
...
...
deconvolution/d2_to_path.py
View file @
ba61e7d2
...
...
@@ -34,8 +34,8 @@ def main():
d2g
.
load
(
d2_file
)
# Take the principal component
largest_component_nodes
=
max
(
nx
.
connected_components
(
d2g
.
nx_graph
),
key
=
len
)
largest_component
=
d2g
.
nx_graph
.
subgraph
(
largest_component_nodes
)
largest_component_nodes
=
max
(
nx
.
connected_components
(
d2g
),
key
=
len
)
largest_component
=
d2g
.
subgraph
(
largest_component_nodes
)
unitigs
=
compute_unitigs
(
largest_component
)
# Write the simplificated graph
...
...
deconvolution/d2_transitive_reduction.py
View file @
ba61e7d2
...
...
@@ -37,7 +37,7 @@ def main():
d2a
.
transitive_reduction
(
d2g
)
# Write the simplificated graph
nx
.
write_gexf
(
d2g
.
nx_graph
,
args
.
output_d2_name
)
nx
.
write_gexf
(
d2g
,
args
.
output_d2_name
)
if
__name__
==
"__main__"
:
...
...
deconvolution/to_d2_graph.py
View file @
ba61e7d2
...
...
@@ -29,10 +29,9 @@ def main():
# Index size must be changed for general purpose. 8 is good for d=5
d2g
=
d2
.
D2Graph
(
G
)
d2g
.
construct_from_barcodes
(
index_size
=
8
)
d2g
.
save
(
f
"
{
args
.
output_prefix
}
.tsv"
)
G
,
names
=
d2g
.
to_nx_graph
(
)
nx
.
write_gexf
(
G
,
f
"
{
args
.
output_prefix
}
.gexf"
)
d2g
.
save
(
f
"
{
args
.
output_prefix
}
.tsv"
)
nx
.
write_gexf
(
d2g
,
f
"
{
args
.
output_prefix
}
.gexf"
)
if
__name__
==
"__main__"
:
...
...
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