Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
K
KNOT
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
Operations
Operations
Incidents
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
MARIJON Pierre
KNOT
Commits
b1a46e75
Commit
b1a46e75
authored
Jan 08, 2019
by
MARIJON Pierre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add option to choose the path search mode
parent
ed5b112d
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
15 additions
and
8 deletions
+15
-8
knot/AAG.rules
knot/AAG.rules
+1
-1
knot/__main__.py
knot/__main__.py
+4
-1
knot/path_search/__main__.py
knot/path_search/__main__.py
+3
-2
knot/path_search/paths.py
knot/path_search/paths.py
+7
-4
No files found.
knot/AAG.rules
View file @
b1a46e75
...
...
@@ -10,7 +10,7 @@ rule build_AGG:
"{prefix}_AAG.csv"
shell:
"python -m knot.path_search {input.search} {output} {input.ovl_graph} {input.read2asm} {input.asm_graph} {input.tig2tig}
"
"python -m knot.path_search {input.search} {output} {input.ovl_graph} {input.read2asm} {input.asm_graph} {input.tig2tig}
--search-mode " + config["search_mode"]
rule filter_contigs:
input:
...
...
knot/__main__.py
View file @
b1a46e75
...
...
@@ -35,6 +35,8 @@ def main(args = None):
parser
.
add_argument
(
"-o"
,
"--output"
,
required
=
True
,
help
=
"output prefix"
)
parser
.
add_argument
(
"--search-mode"
,
choices
=
[
"base"
,
"node"
],
default
=
"base"
,
help
=
"what path search optimize, number of base or number of node"
)
parser
.
add_argument
(
"--contig-min-length"
,
default
=
100000
,
type
=
int
,
help
=
"contig with size lower this parameter are ignored"
)
parser
.
add_argument
(
"--read-type"
,
choices
=
[
"pb"
,
"ont"
],
default
=
"pb"
,
...
...
@@ -50,7 +52,7 @@ def main(args = None):
parser
.
print_help
()
snakemake_help
()
return
1
## if contig graph isn't set generate empty file
if
args
[
"contigs_graph"
]
is
None
:
args
[
"contigs_graph"
]
=
tempfile
.
NamedTemporaryFile
(
delete
=
False
).
name
...
...
@@ -65,6 +67,7 @@ def main(args = None):
"contigs_graph="
+
args
[
"contigs_graph"
],
"read_type="
+
args
[
"read_type"
],
"min_contig_length="
+
str
(
args
[
"contig_min_length"
]),
"search_mode="
+
args
[
"search_mode"
],
"package_path="
+
package_path
]
...
...
knot/path_search/__main__.py
View file @
b1a46e75
...
...
@@ -37,6 +37,8 @@ def main(args=None):
parser
.
add_argument
(
"read2asm"
,
type
=
argparse
.
FileType
(
'r'
))
parser
.
add_argument
(
"asm_graph"
,
type
=
argparse
.
FileType
(
'r'
))
parser
.
add_argument
(
"tig2tig"
,
type
=
argparse
.
FileType
(
'r'
))
parser
.
add_argument
(
"--search-mode"
,
choices
=
[
"base"
,
"node"
],
default
=
"base"
,
help
=
"what path search optimize, number of base or number of node"
)
args
=
vars
(
parser
.
parse_args
(
args
))
...
...
@@ -47,7 +49,6 @@ def main(args=None):
# get info about contig
valid_read
=
extremity_search
.
get_valid_read
(
args
[
"ovl_graph"
])
tig2reads
=
{
tig
[
0
]:
{
v
[
2
]
for
v
in
val
}
for
tig
,
val
in
extremity_search
.
get_tig2posread
(
args
[
"read2asm"
],
valid_read
).
items
()}
# build list of search
tig_ext
=
list
()
...
...
@@ -72,7 +73,7 @@ def main(args=None):
print
(
ext1
[
0
],
node1
,
ext2
[
0
],
node2
,
0
,
0
,
"not_search"
,
"not_search"
,
sep
=
","
,
file
=
args
[
"result"
])
continue
(
path
,
weight
)
=
paths
.
get_path
(
sg
,
node1
,
node2
)
(
path
,
weight
)
=
paths
.
get_path
(
sg
,
node1
,
node2
,
args
[
"search_mode"
]
)
if
path
:
nbread_contig
=
paths
.
format_node_contig_counter
(
paths
.
path_through_contig
(
tig2reads
,
path
),
...
...
knot/path_search/paths.py
View file @
b1a46e75
...
...
@@ -5,10 +5,13 @@ from collections import Counter
# pip import
import
networkx
as
nx
def
get_path
(
graph
,
n1
,
n2
):
def
get_path
(
graph
,
n1
,
n2
,
mode
=
"base"
):
try
:
path
=
nx
.
shortest_path
(
graph
,
n1
,
n2
,
weight
=
"weight"
)
if
mode
==
"base"
:
path
=
nx
.
shortest_path
(
graph
,
n1
,
n2
,
weight
=
"weight"
)
else
:
path
=
nx
.
shortest_path
(
graph
,
n1
,
n2
)
except
nx
.
exception
.
NetworkXError
as
e
:
logging
.
debug
(
"Networkx exception"
+
str
(
e
))
path
=
[]
...
...
@@ -18,8 +21,8 @@ def get_path(graph, n1, n2):
except
nx
.
exception
.
NodeNotFound
as
e
:
logging
.
debug
(
"Node not found exception "
+
str
(
e
))
path
=
[]
return
path
,
sum
([
graph
.
edges
[
x
,
y
][
"weight"
]
for
x
,
y
in
zip
(
path
,
path
[
1
:])])
return
path
,
sum
([
graph
.
edges
[
x
,
y
][
"weight"
]
for
x
,
y
in
zip
(
path
,
path
[
1
:])])
def
path_through_contig
(
tig2reads
,
path
):
tig2nb_read
=
Counter
()
...
...
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