Skip to content
GitLab
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
beef8eba
Commit
beef8eba
authored
May 18, 2020
by
Yoann Dufresne
Browse files
barcode graph evaluation
parent
2403e42b
Changes
1
Hide whitespace changes
Inline
Side-by-side
deconvolution/main/evaluate.py
View file @
beef8eba
...
...
@@ -12,7 +12,7 @@ def parse_args():
parser
=
argparse
.
ArgumentParser
(
description
=
'Process a d2 graph (complete graph or path) to evaluate its quality.'
)
parser
.
add_argument
(
'filename'
,
type
=
str
,
help
=
'The file to evalute'
)
parser
.
add_argument
(
'--type'
,
'-t'
,
choices
=
[
"d2"
,
"path"
,
"d2-2annotate"
,
"dgraphs"
],
default
=
"path"
,
required
=
True
,
parser
.
add_argument
(
'--type'
,
'-t'
,
choices
=
[
"d2"
,
"path"
,
"bg"
,
"d2-2annotate"
,
"dgraphs"
],
default
=
"path"
,
required
=
True
,
help
=
"Define the data type to evaluate. Must be 'd2' or 'path' or 'd2-2annotate' (Rayan's hack)."
)
parser
.
add_argument
(
'--light-print'
,
'-l'
,
action
=
'store_true'
,
help
=
'Print only wrong nodes and paths'
)
...
...
@@ -43,6 +43,20 @@ def save_graph(g, filename):
print
(
"Wrong file format. Require graphml or gefx format"
,
file
=
sys
.
stderr
)
exit
()
def
transform_bg
(
graph
):
idx
=
0
node_names
=
{}
nx
.
set_node_attributes
(
graph
,
0
,
'score'
)
nx
.
set_node_attributes
(
graph
,
""
,
'barcode_edges'
)
for
node
in
graph
.
nodes
():
graph
.
nodes
[
node
][
'udg'
]
=
f
"[
{
node
}
][][]"
node_names
[
node
]
=
str
(
idx
)
idx
+=
1
graph
=
nx
.
relabel_nodes
(
graph
,
node_names
)
return
graph
...
...
@@ -655,7 +669,11 @@ def main():
elif
args
.
type
==
"dgraphs"
:
udg_per_node
=
parse_udg_qualities
(
graph
)
# print(udg_per_node)
elif
args
.
type
==
"d2"
:
elif
args
.
type
==
"bg"
or
args
.
type
==
"d2"
:
if
args
.
type
==
"bg"
:
graph
=
transform_bg
(
graph
)
components
=
list
(
nx
.
connected_components
(
graph
))
components
.
sort
(
key
=
lambda
x
:
-
len
(
x
))
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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