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
5c6f2630
Commit
5c6f2630
authored
Feb 08, 2019
by
MARIJON Pierre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add instruction in Readme to generate html knot report
parent
7fc484d9
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
94 additions
and
21 deletions
+94
-21
MANIFEST.in
MANIFEST.in
+1
-4
Readme.md
Readme.md
+15
-0
knot/analysis/__init__.py
knot/analysis/__init__.py
+1
-1
knot/analysis/generate_report.py
knot/analysis/generate_report.py
+26
-15
knot/analysis/hamilton_path.py
knot/analysis/hamilton_path.py
+3
-0
knot/analysis/template/hamilton_path.jinja2.html
knot/analysis/template/hamilton_path.jinja2.html
+45
-0
knot/analysis/template/report.jinja2.html
knot/analysis/template/report.jinja2.html
+2
-0
setup.py
setup.py
+1
-1
No files found.
MANIFEST.in
View file @
5c6f2630
include *.md
include knot/*.rules
include knot/config.yaml
recursive-include knot/extremity_search *
recursive-include knot/filter_tig *
recursive-include knot/path_search *
recursive-include knot/analysis *
recursive-include knot/analysis/template *
Readme.md
View file @
5c6f2630
...
...
@@ -7,6 +7,8 @@ Give an assembly and a set of reads to KNOT, it will output an information-rich
-
[
Input
](
#input
)
-
[
Output
](
#output
)
-
[
Usage
](
#usage
)
*
[
Run knot
](
#run-knot
)
*
[
Generate html report on knot result
](
generate-html-report-on-knot-result
)
-
[
Installation
](
#installation
)
*
[
Install with conda
](
#install-with-conda
)
*
[
Install without conda
](
#install-without-conda
)
...
...
@@ -53,6 +55,8 @@ Assume that
-
contigs are stored in
`contigs.fasta`
-
contig graph is stored in
`contigs.gfa`
### Run knot
Then run KNOT as:
```
...
...
@@ -94,6 +98,17 @@ optional arguments:
In addition, snakemake parameters can be add after
`--`
.
### Generate html report on knot result
You can generate a html report
`knot_report.html`
on knot information generate previously with this command:
```
knot.analysis -i {output prefix give to knot previously} -c -p -o knot_report.html
```
If
`-c`
is present, knot.analysis run a path classification, based on path length and composition see
[
manuscript
](
#citation
)
for more details.
If
`-p`
is present, knot.analysis run a hamilton path search, see
[
manuscript
](
#citation
)
for more details.
## Installation
### Install with conda
...
...
knot/analysis/__init__.py
View file @
5c6f2630
__version__
=
"0.1.0"
knot/analysis/generate_report.py
View file @
5c6f2630
...
...
@@ -5,6 +5,7 @@ import os
import
csv
import
sys
import
argparse
import
subprocess
from
jinja2
import
FileSystemLoader
from
jinja2
import
Environment
...
...
@@ -18,29 +19,33 @@ def main(args=None):
parser
=
argparse
.
ArgumentParser
(
prog
=
"knot.analysis.generate_report"
)
parser
.
add_argument
(
"-
a"
,
"--aag"
,
type
=
argparse
.
FileType
(
'r'
),
help
=
"AAG filepath"
)
parser
.
add_argument
(
"-
C"
,
"--contig"
,
type
=
argparse
.
FileType
(
'r'
),
help
=
"contig filepath
"
,
required
=
True
)
parser
.
add_argument
(
"-c"
,
"--classification"
,
type
=
argparse
.
FileType
(
'r'
),
help
=
"path classification filepath"
,
required
=
True
)
parser
.
add_argument
(
"-
p"
,
"--hamilton-path"
,
type
=
argparse
.
FileType
(
'r'
),
help
=
"hamilton path filepath
"
)
parser
.
add_argument
(
"-
o"
,
"--output"
,
type
=
argparse
.
FileType
(
'wb'
),
help
=
"path where report was writ
e"
)
parser
.
add_argument
(
"-
i"
,
"--input_prefix"
,
type
=
str
,
help
=
"prefix of knot output"
,
required
=
True
)
parser
.
add_argument
(
"-
o"
,
"--output"
,
type
=
argparse
.
FileType
(
'wb'
),
help
=
"path where report was write
"
,
required
=
True
)
parser
.
add_argument
(
"-
c"
,
"--classification"
,
help
=
"Add path classification in report"
,
action
=
"store_true
"
)
parser
.
add_argument
(
"-
p"
,
"--hamilton-path"
,
help
=
"Add hamilton path in report"
,
action
=
"store_tru
e"
)
args
=
vars
(
parser
.
parse_args
(
args
))
template_path
=
os
.
path
.
dirname
(
__file__
)
+
os
.
sep
+
"template"
+
os
.
sep
env
=
Environment
(
loader
=
FileSystemLoader
(
template_path
))
template
=
env
.
get_template
(
'report.jinja2.html'
)
param
=
dict
()
contig_info
(
param
,
args
[
"contig"
])
classification_info
(
param
,
args
[
"classification"
])
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"
))
if
args
[
"hamilton_path"
]
is
not
None
:
hamilton_info
(
param
,
args
[
"hamilton_path"
])
if
args
[
"hamilton_path"
]:
run_hamilton
(
args
[
"input_prefix"
]
+
"AAG.csv"
,
args
[
"input_prefix"
])
hamilton_info
(
param
,
open
(
args
[
"input_prefix"
]
+
"hamilton_path.csv"
))
full_aag_info
(
param
,
args
[
"aag"
]
)
args
[
"aag"
].
seek
(
0
)
build_AAG_representation
(
param
,
args
[
"aag"
]
)
full_aag_info
(
param
,
open
(
args
[
"input_prefix"
]
+
"AAG.csv"
)
)
build_AAG_representation
(
param
,
open
(
args
[
"input_prefix"
]
+
"AAG.csv"
)
)
args
[
"output"
].
write
(
template
.
render
(
param
).
encode
(
"utf-8"
))
...
...
@@ -52,6 +57,9 @@ 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
):
ext2type
=
dict
()
...
...
@@ -60,6 +68,9 @@ def classification_info(param, classification_file):
param
[
"classification_info"
]
=
ext2type
def
run_hamilton
(
aag_path
,
prefix_output
):
subprocess
.
run
([
"knot.analysis.hamilton_path"
,
"-i"
,
aag_path
,
"-o"
,
prefix_output
+
"_hamilton_path.csv"
])
def
hamilton_info
(
param
,
hamilton_file
):
hamilton_path
=
list
()
...
...
@@ -103,8 +114,8 @@ def build_AAG_representation(param, aag_file):
for
tig
in
tig_set
:
nodes
+=
"{{ id: '{}_begin', label: '
{}_
begin' }},
\n
"
.
format
(
tig
,
tig
)
nodes
+=
"{{ id: '{}_end', label: '
{}_
end' }},
\n
"
.
format
(
tig
,
tig
)
nodes
+=
"{{ id: '{}_begin', label: 'begin' }},
\n
"
.
format
(
tig
,
tig
)
nodes
+=
"{{ id: '{}_end', label: 'end' }},
\n
"
.
format
(
tig
,
tig
)
for
tig
in
tig_set
:
e1
=
tig
+
"_begin"
...
...
knot/analysis/hamilton_path.py
View file @
5c6f2630
...
...
@@ -85,6 +85,9 @@ def AAG2graph(AAG_path):
else
:
nb_base
=
int
(
row
[
"nb_base"
])
if
nb_base
<
0
:
nb_base
=
0
if
key
in
paths
and
paths
[
key
]
<
nb_base
:
continue
...
...
knot/analysis/template/hamilton_path.jinja2.html
View file @
5c6f2630
<h1>
Hamiltonian path
</h1>
<h2>
Table of path with weight
</h2>
<table
class=
"dataframe"
,
border=
1
>
<tr>
<th>
path
</th>
...
...
@@ -12,3 +13,47 @@
</tr>
{% endfor %}
</table>
<h2>
Evolution of weight
</h2>
<div
id=
"hamilton_curve"
></div>
<script
type=
"text/javascript"
>
var
container
=
document
.
getElementById
(
'
hamilton_curve
'
)
var
items
=
[
{
%
for
_
,
weight
in
hamilton_info
%
}
{
x
:
{{
loop
.
index
}},
y
:
{{
weight
}}},
{
%
endfor
%
}
]
var
dataset
=
new
vis
.
DataSet
(
items
);
var
options
=
{
format
:
{
minorLabels
:
{
millisecond
:
'
x
'
,
second
:
'
x
'
,
minute
:
'
x
'
,
hour
:
'
x
'
,
weekday
:
'
x
'
,
day
:
'
x
'
,
month
:
'
x
'
,
year
:
'
x
'
},
majorLabels
:
{
millisecond
:
''
,
second
:
''
,
minute
:
''
,
hour
:
''
,
weekday
:
''
,
day
:
''
,
month
:
''
,
year
:
''
}
},
timeAxis
:
{
scale
:
'
millisecond
'
,
step
:
10
},
};
var
graph2d
=
new
vis
.
Graph2d
(
container
,
dataset
,
options
);
</script>
knot/analysis/template/report.jinja2.html
View file @
5c6f2630
...
...
@@ -13,7 +13,9 @@
{% include 'contig_report.jinja2.html' %}
{% if classification_info is defined %}
{% include 'path_classification.jinja2.html' %}
{% endif %}
{% include 'aag.jinja2.html' %}
...
...
setup.py
View file @
5c6f2630
...
...
@@ -45,7 +45,7 @@ setup(
'knot.extremity_search = knot.extremity_search.__main__:main'
,
'knot.analysis.classifications = knot.analysis.classifications:main'
,
'knot.analysis.hamilton_path = knot.analysis.hamilton_path:main'
,
'knot.analysis
.generation_report
= knot.analysis.generation_report:main'
'knot.analysis = knot.analysis.generation_report: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