Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
genotoul-bioinfo
miniannotator
Commits
c211be8c
Commit
c211be8c
authored
Aug 22, 2018
by
Floreal Cabanettes
Browse files
Add summary for excluded matches
parent
632e3490
Changes
1
Hide whitespace changes
Inline
Side-by-side
fixcontigs.py
View file @
c211be8c
...
...
@@ -339,6 +339,25 @@ def parse_valid_matches(matches, out_prefix, reference_fasta):
(
GAP_BLOCK_SIZE_MIN
,
n_prot_with_gaps
,
n_prot_with_gaps
/
len
(
matches
)
*
100
))
def
parse_unvalid_matches
(
matches
,
tsv
):
"""
Parse unvalid matches and write tsv summary file
:param matches: matches to parse
:type matches: list
:param tsv: output summary tsv file path
:type tsv: str
"""
if
os
.
path
.
exists
(
tsv
):
os
.
remove
(
tsv
)
with
open
(
tsv
,
"w"
)
as
tsv_f
:
tsv_f
.
write
(
"
\t
"
.
join
((
"Contig"
,
"Protein"
,
"prot_cov"
,
"score"
,
"e_value"
))
+
"
\n
"
)
for
match
in
matches
:
cov
=
"%0.2f"
%
(
abs
(
match
[
"prot"
][
"end"
]
-
match
[
"prot"
][
"start"
])
/
match
[
"prot"
][
"len"
]
*
100
)
tsv_f
.
write
(
"
\t
"
.
join
((
match
[
"ref"
][
"id"
],
match
[
"prot"
][
"id"
],
cov
,
match
[
"bitscore"
],
match
[
"e_value"
]))
+
"
\n
"
)
if
__name__
==
"__main__"
:
import
argparse
...
...
@@ -352,4 +371,8 @@ if __name__ == "__main__":
maps
,
bad_maps
=
get_valid_maps
(
args
.
diamond
)
print
(
"load OK"
,
flush
=
True
)
print
(
"Fix contigs..."
,
flush
=
True
)
parse_valid_matches
(
maps
,
args
.
output_prefix
,
args
.
reference
)
print
(
"Summarize excluded matches..."
,
flush
=
True
)
parse_unvalid_matches
(
bad_maps
,
args
.
output_prefix
+
"_ignored_matches.tsv"
)
print
(
"Done"
)
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