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
afe8cbe7
Commit
afe8cbe7
authored
May 18, 2020
by
Yoann Dufresne
Browse files
remove bg analysis
parent
5b114601
Changes
1
Hide whitespace changes
Inline
Side-by-side
deconvolution/main/evaluate.py
View file @
afe8cbe7
...
...
@@ -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"
,
"bg"
,
"d2-2annotate"
,
"dgraphs"
],
default
=
"path"
,
required
=
True
,
parser
.
add_argument
(
'--type'
,
'-t'
,
choices
=
[
"d2"
,
"path"
,
"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'
)
...
...
@@ -259,8 +259,9 @@ def print_d2_summary(connected_components, longest_path, coverage_vars=(0, 0), l
print
(
"Longest path for increasing molecule number:"
)
print
(
path_dg_idx
)
print
(
f
"Size of the longest path:
{
len
(
longest_path
)
}
"
)
print
(
"Jumps in central nodes:"
)
print
(
path_to_jumps
(
longest_path
))
if
not
light_print
:
print
(
"Jumps in central nodes:"
)
print
(
path_to_jumps
(
longest_path
))
print
(
f
"Number of usable coverage variables:
{
len
(
coverage_vars
[
1
])
}
"
)
print
(
f
"Coverage:
{
len
(
coverage_vars
[
0
])
}
/
{
len
(
coverage_vars
[
1
])
}
"
)
...
...
@@ -324,6 +325,7 @@ def compute_next_nodes(d2_component, max_jumps=0):
def
compute_longest_increasing_paths
(
d2_component
,
max_gap
=
0
):
next_nodes
=
compute_next_nodes
(
d2_component
,
max_jumps
=
max_gap
)
sys
.
setrecursionlimit
(
len
(
d2_component
.
nodes
)
*
2
)
# Compute the longest path for each node
longest_paths
=
{}
...
...
@@ -489,39 +491,6 @@ def recursive_longest_path(current_node, current_molecule, next_nodes, longest_p
return
longest_paths
[
current_node
][
current_molecule
]
# def longest_common_subsequence(barcode_true_path, barcoded_graph):
# """ Assume that the two graphs have an attribute barcode for each node and a unique node name"""
# path_nodes = []
# path_nodes_barcodes = []
# for node, data in barcode_true_path.nodes(data=True):
# path_nodes.append(node)
# path_nodes_barcodes.append(data["barcode"])
# path_nodes_to_idx = {n: idx for idx, n in enumerate(path_nodes)}
#
# graph_nodes = []
# graph_nodes_barcodes = []
# for node, data in barcoded_graph.nodes(data=True):
# graph_nodes.append(node)
# graph_nodes_barcodes.append(data["barcode"])
# graph_nodes_to_idx = {n: idx for idx, n in enumerate(graph_nodes)}
#
# dynamic_array = [[0 for _ in range(len(graph_nodes)+1)] for _ in range(len(path_nodes)+1)]
# for row in range(1, len(path_nodes)+1):
# path_node = path_nodes[row-1]
# path_barcode = path_nodes_barcodes[row-1]
#
# for column in range(1, len(graph_nodes)):
# graph_node = graph_nodes[column-1]
# graph_barcode = graph_nodes_barcodes[column-1]
#
# prev_scores = [dynamic_array[row-1][column]]
# for neighbor_node in barcoded_graph[graph_node]:
# neighbor_idx = graph_nodes_to_idx[neighbor_node]
# prev_scores.append(dynamic_array[row-1][neighbor_idx])
#
# match_point = 1 if path_barcode == graph_barcode else 0
# dynamic_array[row][column] = max(prev_scores) + match_point
def
compute_covered_variables
(
graph
,
path
):
path_nodes
=
set
()
...
...
@@ -669,10 +638,7 @@ def main():
elif
args
.
type
==
"dgraphs"
:
udg_per_node
=
parse_udg_qualities
(
graph
)
# print(udg_per_node)
elif
args
.
type
==
"bg"
or
args
.
type
==
"d2"
:
if
args
.
type
==
"bg"
:
graph
=
transform_bg
(
graph
)
elif
args
.
type
==
"d2"
:
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