Commit c211be8c authored by Floreal Cabanettes's avatar Floreal Cabanettes
Browse files

Add summary for excluded matches

parent 632e3490
......@@ -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):
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"])) +
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")
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment