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
305b0142
Commit
305b0142
authored
Feb 12, 2019
by
MARIJON Pierre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add AAG with just adjacency edges
parent
5c6f2630
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
92 additions
and
20 deletions
+92
-20
knot/analysis/generate_report.py
knot/analysis/generate_report.py
+54
-20
knot/analysis/template/aag.jinja2.html
knot/analysis/template/aag.jinja2.html
+38
-0
No files found.
knot/analysis/generate_report.py
View file @
305b0142
...
...
@@ -33,19 +33,22 @@ def main(args=None):
param
=
dict
()
contig_info
(
param
,
open
(
args
[
"input_prefix"
]
+
"knot/contigs.fasta"
))
contig_info
(
param
,
open
(
args
[
"input_prefix"
]
+
"
_
knot/contigs.fasta"
))
if
args
[
"classification"
]:
run_classification
(
args
[
"input_prefix"
]
+
"AAG.csv"
,
args
[
"input_prefix"
])
classification_info
(
param
,
open
(
args
[
"input_prefix"
]
+
"classification.csv"
))
run_classification
(
args
[
"input_prefix"
]
+
"
_
AAG.csv"
,
args
[
"input_prefix"
])
classification_info
(
param
,
open
(
args
[
"input_prefix"
]
+
"
_knot"
+
os
.
sep
+
"
classification.csv"
))
if
args
[
"hamilton_path"
]:
run_hamilton
(
args
[
"input_prefix"
]
+
"AAG.csv"
,
args
[
"input_prefix"
])
hamilton_info
(
param
,
open
(
args
[
"input_prefix"
]
+
"hamilton_path.csv"
))
run_hamilton
(
args
[
"input_prefix"
]
+
"
_
AAG.csv"
,
args
[
"input_prefix"
])
hamilton_info
(
param
,
open
(
args
[
"input_prefix"
]
+
"
_knot"
+
os
.
sep
+
"
hamilton_path.csv"
))
full_aag_info
(
param
,
open
(
args
[
"input_prefix"
]
+
"AAG.csv"
))
full_aag_info
(
param
,
open
(
args
[
"input_prefix"
]
+
"
_
AAG.csv"
))
build_AAG_representation
(
param
,
open
(
args
[
"input_prefix"
]
+
"AAG.csv"
))
build_AAG_representation
(
param
,
open
(
args
[
"input_prefix"
]
+
"_AAG.csv"
))
if
args
[
"classification"
]:
build_clean_AAG
(
param
,
open
(
args
[
"input_prefix"
]
+
"_AAG.csv"
),
open
(
args
[
"input_prefix"
]
+
"_knot"
+
os
.
sep
+
"classification.csv"
))
args
[
"output"
].
write
(
template
.
render
(
param
).
encode
(
"utf-8"
))
...
...
@@ -58,18 +61,20 @@ def contig_info(param, contig_file):
param
[
"tig_info"
]
=
tig2len
def
run_classification
(
aag_path
,
prefix_output
):
subprocess
.
run
([
"knot.analysis.classifications"
,
"-i"
,
aag_path
,
"-o"
,
prefix_output
+
"_classification.csv"
])
def
classification_info
(
param
,
classification_file
):
subprocess
.
run
([
"knot.analysis.classifications"
,
"-i"
,
aag_path
,
"-o"
,
prefix_output
+
"_knot"
+
os
.
sep
+
"classification.csv"
])
def
__classification_info
(
classification_file
):
ext2type
=
dict
()
for
row
in
csv
.
DictReader
(
classification_file
):
ext2type
[(
row
[
"ext1"
],
row
[
"ext2"
])]
=
row
[
"type"
]
param
[
"classification_info"
]
=
ext2type
return
ext2type
def
classification_info
(
param
,
classification_file
):
param
[
"classification_info"
]
=
__classification_info
(
classification_file
)
def
run_hamilton
(
aag_path
,
prefix_output
):
subprocess
.
run
([
"knot.analysis.hamilton_path"
,
"-i"
,
aag_path
,
"-o"
,
prefix_output
+
"_
hamilton_path.csv"
])
subprocess
.
run
([
"knot.analysis.hamilton_path"
,
"-i"
,
aag_path
,
"-o"
,
prefix_output
+
"_knot"
+
os
.
sep
+
"
hamilton_path.csv"
])
def
hamilton_info
(
param
,
hamilton_file
):
...
...
@@ -87,9 +92,7 @@ def full_aag_info(param, aag_file):
param
[
"full_aag_info"
]
=
aag_record
def
build_AAG_representation
(
param
,
aag_file
):
nodes
=
""
edges
=
""
def
get_aag_graph
(
aag_file
):
edges_dict
=
dict
()
tig_set
=
set
()
...
...
@@ -107,12 +110,12 @@ def build_AAG_representation(param, aag_file):
edges_dict
[
frozenset
((
row
[
"tig1"
],
row
[
"tig2"
]))]
=
int
(
row
[
"nb_base"
])
for
(
tig1
,
tig2
),
length
in
edges_dict
.
items
():
if
length
<=
0
:
length
=
"overlap"
edges
+=
"{{ from: '{}', to: '{}', label: '{}', id: '{}' }},
\n
"
.
format
(
tig1
,
tig2
,
length
,
tig1
+
"-"
+
tig2
)
return
edges_dict
,
tig_set
def
__construct_tig
(
tig_set
):
nodes
=
""
edges
=
""
for
tig
in
tig_set
:
nodes
+=
"{{ id: '{}_begin', label: 'begin' }},
\n
"
.
format
(
tig
,
tig
)
nodes
+=
"{{ id: '{}_end', label: 'end' }},
\n
"
.
format
(
tig
,
tig
)
...
...
@@ -121,9 +124,40 @@ def build_AAG_representation(param, aag_file):
e1
=
tig
+
"_begin"
e2
=
tig
+
"_end"
edges
+=
"{{from: '{}', to: '{}', label: '{}', width: 10, length: 1}},
\n
"
.
format
(
e1
,
e2
,
tig
)
return
nodes
,
edges
def
build_AAG_representation
(
param
,
aag_file
):
edges_dict
,
tig_set
=
get_aag_graph
(
aag_file
)
nodes
,
edges
=
__construct_tig
(
tig_set
)
for
(
tig1
,
tig2
),
length
in
edges_dict
.
items
():
if
length
<=
0
:
length
=
"overlap"
edges
+=
"{{ from: '{}', to: '{}', label: '{}', id: '{}' }},
\n
"
.
format
(
tig1
,
tig2
,
length
,
tig1
+
"-"
+
tig2
)
param
[
"aag_nodes"
]
=
nodes
param
[
"aag_edges"
]
=
edges
def
build_clean_AAG
(
param
,
aag
,
classification
):
edges_dict
,
tig_set
=
get_aag_graph
(
aag
)
classification
=
__classification_info
(
classification
)
nodes
,
edges
=
__construct_tig
(
tig_set
)
for
(
tig1
,
tig2
),
value
in
classification
.
items
():
if
not
value
.
endswith
(
"adjacency"
):
continue
key
=
frozenset
((
tig1
,
tig2
))
length
=
edges_dict
[
key
]
if
length
<=
0
:
length
=
"overlap"
edges
+=
"{{ from: '{}', to: '{}', label: '{}', id: '{}' }},
\n
"
.
format
(
tig1
,
tig2
,
length
,
tig1
+
"-"
+
tig2
)
param
[
"aag_clean_nodes"
]
=
nodes
param
[
"aag_clean_edges"
]
=
edges
if
__name__
==
"__main__"
:
main
()
knot/analysis/template/aag.jinja2.html
View file @
305b0142
<h1>
Augmented Assembly Graph
</h1>
<h2>
ALL link
</h2>
<div
id=
"aag"
></div>
<script
type=
"text/javascript"
>
...
...
@@ -33,3 +34,40 @@
};
var
network
=
new
vis
.
Network
(
container
,
data
,
options
);
</script>
<h2>
Only adjacents link
</h2>
<div
id=
"aag_clean"
></div>
<script
type=
"text/javascript"
>
// create an array with nodes
var
nodes
=
new
vis
.
DataSet
([
{{
aag_clean_nodes
}}
]);
// create an array with edges
var
edges
=
new
vis
.
DataSet
([
{{
aag_clean_edges
}}
]);
// create a network
var
container
=
document
.
getElementById
(
'
aag_clean
'
);
var
data
=
{
nodes
:
nodes
,
edges
:
edges
};
var
options
=
{
height
:
'
600px
'
,
width
:
'
600px
'
,
nodes
:
{
shape
:
'
dot
'
,
},
physics
:
{
forceAtlas2Based
:
{
avoidOverlap
:
400
},
solver
:
'
forceAtlas2Based
'
,
}
};
var
network
=
new
vis
.
Network
(
container
,
data
,
options
);
</script>
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