annotate screen_abricate_report.py @ 3:2262e531c50b draft

"planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/screen_abricate_report commit 50a464c3e6f87ca8d2c874842cbcee370d8aa9c4"
author public-health-bioinformatics
date Thu, 02 Jan 2020 17:14:34 -0500
parents 4f963b583186
children 22247b1a59d5
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
b2d56a44a872 "planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/screen_abricate_report commit 1d569fc27b052d1982d82ca19455caaff6386f46"
public-health-bioinformatics
parents:
diff changeset
1 #!/usr/bin/env python
b2d56a44a872 "planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/screen_abricate_report commit 1d569fc27b052d1982d82ca19455caaff6386f46"
public-health-bioinformatics
parents:
diff changeset
2
b2d56a44a872 "planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/screen_abricate_report commit 1d569fc27b052d1982d82ca19455caaff6386f46"
public-health-bioinformatics
parents:
diff changeset
3 from __future__ import print_function
b2d56a44a872 "planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/screen_abricate_report commit 1d569fc27b052d1982d82ca19455caaff6386f46"
public-health-bioinformatics
parents:
diff changeset
4
b2d56a44a872 "planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/screen_abricate_report commit 1d569fc27b052d1982d82ca19455caaff6386f46"
public-health-bioinformatics
parents:
diff changeset
5 import argparse
1
4f963b583186 "planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/screen_abricate_report commit c27095ceaf23aa2c910e0ea866db9ec8d3e7816b"
public-health-bioinformatics
parents: 0
diff changeset
6 import csv
0
b2d56a44a872 "planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/screen_abricate_report commit 1d569fc27b052d1982d82ca19455caaff6386f46"
public-health-bioinformatics
parents:
diff changeset
7 import re
1
4f963b583186 "planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/screen_abricate_report commit c27095ceaf23aa2c910e0ea866db9ec8d3e7816b"
public-health-bioinformatics
parents: 0
diff changeset
8
0
b2d56a44a872 "planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/screen_abricate_report commit 1d569fc27b052d1982d82ca19455caaff6386f46"
public-health-bioinformatics
parents:
diff changeset
9
3
2262e531c50b "planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/screen_abricate_report commit 50a464c3e6f87ca8d2c874842cbcee370d8aa9c4"
public-health-bioinformatics
parents: 1
diff changeset
10 class Range(object):
2262e531c50b "planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/screen_abricate_report commit 50a464c3e6f87ca8d2c874842cbcee370d8aa9c4"
public-health-bioinformatics
parents: 1
diff changeset
11 """
2262e531c50b "planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/screen_abricate_report commit 50a464c3e6f87ca8d2c874842cbcee370d8aa9c4"
public-health-bioinformatics
parents: 1
diff changeset
12 Used to limit the min_coverage and min_identity args to range 0.0 - 100.0
2262e531c50b "planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/screen_abricate_report commit 50a464c3e6f87ca8d2c874842cbcee370d8aa9c4"
public-health-bioinformatics
parents: 1
diff changeset
13 """
2262e531c50b "planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/screen_abricate_report commit 50a464c3e6f87ca8d2c874842cbcee370d8aa9c4"
public-health-bioinformatics
parents: 1
diff changeset
14 def __init__(self, start, end):
2262e531c50b "planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/screen_abricate_report commit 50a464c3e6f87ca8d2c874842cbcee370d8aa9c4"
public-health-bioinformatics
parents: 1
diff changeset
15 self.start = start
2262e531c50b "planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/screen_abricate_report commit 50a464c3e6f87ca8d2c874842cbcee370d8aa9c4"
public-health-bioinformatics
parents: 1
diff changeset
16 self.end = end
2262e531c50b "planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/screen_abricate_report commit 50a464c3e6f87ca8d2c874842cbcee370d8aa9c4"
public-health-bioinformatics
parents: 1
diff changeset
17
2262e531c50b "planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/screen_abricate_report commit 50a464c3e6f87ca8d2c874842cbcee370d8aa9c4"
public-health-bioinformatics
parents: 1
diff changeset
18 def __eq__(self, other):
2262e531c50b "planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/screen_abricate_report commit 50a464c3e6f87ca8d2c874842cbcee370d8aa9c4"
public-health-bioinformatics
parents: 1
diff changeset
19 return self.start <= other <= self.end
2262e531c50b "planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/screen_abricate_report commit 50a464c3e6f87ca8d2c874842cbcee370d8aa9c4"
public-health-bioinformatics
parents: 1
diff changeset
20
2262e531c50b "planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/screen_abricate_report commit 50a464c3e6f87ca8d2c874842cbcee370d8aa9c4"
public-health-bioinformatics
parents: 1
diff changeset
21 def __contains__(self, item):
2262e531c50b "planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/screen_abricate_report commit 50a464c3e6f87ca8d2c874842cbcee370d8aa9c4"
public-health-bioinformatics
parents: 1
diff changeset
22 return self.__eq__(item)
2262e531c50b "planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/screen_abricate_report commit 50a464c3e6f87ca8d2c874842cbcee370d8aa9c4"
public-health-bioinformatics
parents: 1
diff changeset
23
2262e531c50b "planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/screen_abricate_report commit 50a464c3e6f87ca8d2c874842cbcee370d8aa9c4"
public-health-bioinformatics
parents: 1
diff changeset
24 def __iter__(self):
2262e531c50b "planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/screen_abricate_report commit 50a464c3e6f87ca8d2c874842cbcee370d8aa9c4"
public-health-bioinformatics
parents: 1
diff changeset
25 yield self
2262e531c50b "planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/screen_abricate_report commit 50a464c3e6f87ca8d2c874842cbcee370d8aa9c4"
public-health-bioinformatics
parents: 1
diff changeset
26
2262e531c50b "planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/screen_abricate_report commit 50a464c3e6f87ca8d2c874842cbcee370d8aa9c4"
public-health-bioinformatics
parents: 1
diff changeset
27 def __repr__(self):
2262e531c50b "planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/screen_abricate_report commit 50a464c3e6f87ca8d2c874842cbcee370d8aa9c4"
public-health-bioinformatics
parents: 1
diff changeset
28 return str(self.start) + " - " + str(self.end)
2262e531c50b "planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/screen_abricate_report commit 50a464c3e6f87ca8d2c874842cbcee370d8aa9c4"
public-health-bioinformatics
parents: 1
diff changeset
29
2262e531c50b "planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/screen_abricate_report commit 50a464c3e6f87ca8d2c874842cbcee370d8aa9c4"
public-health-bioinformatics
parents: 1
diff changeset
30
0
b2d56a44a872 "planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/screen_abricate_report commit 1d569fc27b052d1982d82ca19455caaff6386f46"
public-health-bioinformatics
parents:
diff changeset
31 def parse_screen_file(screen_file):
b2d56a44a872 "planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/screen_abricate_report commit 1d569fc27b052d1982d82ca19455caaff6386f46"
public-health-bioinformatics
parents:
diff changeset
32 screen = []
b2d56a44a872 "planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/screen_abricate_report commit 1d569fc27b052d1982d82ca19455caaff6386f46"
public-health-bioinformatics
parents:
diff changeset
33 with open(screen_file) as f:
b2d56a44a872 "planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/screen_abricate_report commit 1d569fc27b052d1982d82ca19455caaff6386f46"
public-health-bioinformatics
parents:
diff changeset
34 reader = csv.DictReader(f, delimiter="\t", quotechar='"')
b2d56a44a872 "planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/screen_abricate_report commit 1d569fc27b052d1982d82ca19455caaff6386f46"
public-health-bioinformatics
parents:
diff changeset
35 for row in reader:
b2d56a44a872 "planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/screen_abricate_report commit 1d569fc27b052d1982d82ca19455caaff6386f46"
public-health-bioinformatics
parents:
diff changeset
36 screen.append(row)
b2d56a44a872 "planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/screen_abricate_report commit 1d569fc27b052d1982d82ca19455caaff6386f46"
public-health-bioinformatics
parents:
diff changeset
37 return screen
b2d56a44a872 "planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/screen_abricate_report commit 1d569fc27b052d1982d82ca19455caaff6386f46"
public-health-bioinformatics
parents:
diff changeset
38
1
4f963b583186 "planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/screen_abricate_report commit c27095ceaf23aa2c910e0ea866db9ec8d3e7816b"
public-health-bioinformatics
parents: 0
diff changeset
39
0
b2d56a44a872 "planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/screen_abricate_report commit 1d569fc27b052d1982d82ca19455caaff6386f46"
public-health-bioinformatics
parents:
diff changeset
40 def get_fieldnames(input_file):
b2d56a44a872 "planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/screen_abricate_report commit 1d569fc27b052d1982d82ca19455caaff6386f46"
public-health-bioinformatics
parents:
diff changeset
41 with open(input_file) as f:
b2d56a44a872 "planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/screen_abricate_report commit 1d569fc27b052d1982d82ca19455caaff6386f46"
public-health-bioinformatics
parents:
diff changeset
42 reader = csv.DictReader(f, delimiter="\t", quotechar='"')
b2d56a44a872 "planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/screen_abricate_report commit 1d569fc27b052d1982d82ca19455caaff6386f46"
public-health-bioinformatics
parents:
diff changeset
43 row = next(reader)
b2d56a44a872 "planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/screen_abricate_report commit 1d569fc27b052d1982d82ca19455caaff6386f46"
public-health-bioinformatics
parents:
diff changeset
44 fieldnames = row.keys()
b2d56a44a872 "planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/screen_abricate_report commit 1d569fc27b052d1982d82ca19455caaff6386f46"
public-health-bioinformatics
parents:
diff changeset
45 return fieldnames
1
4f963b583186 "planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/screen_abricate_report commit c27095ceaf23aa2c910e0ea866db9ec8d3e7816b"
public-health-bioinformatics
parents: 0
diff changeset
46
4f963b583186 "planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/screen_abricate_report commit c27095ceaf23aa2c910e0ea866db9ec8d3e7816b"
public-health-bioinformatics
parents: 0
diff changeset
47
3
2262e531c50b "planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/screen_abricate_report commit 50a464c3e6f87ca8d2c874842cbcee370d8aa9c4"
public-health-bioinformatics
parents: 1
diff changeset
48 def detect_gene(abricate_report_row, regex, min_coverage, min_identity):
2262e531c50b "planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/screen_abricate_report commit 50a464c3e6f87ca8d2c874842cbcee370d8aa9c4"
public-health-bioinformatics
parents: 1
diff changeset
49 gene_of_interest = bool(re.search(regex, abricate_report_row['GENE']))
2262e531c50b "planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/screen_abricate_report commit 50a464c3e6f87ca8d2c874842cbcee370d8aa9c4"
public-health-bioinformatics
parents: 1
diff changeset
50 sufficient_coverage = float(abricate_report_row['%COVERAGE']) >= min_coverage
2262e531c50b "planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/screen_abricate_report commit 50a464c3e6f87ca8d2c874842cbcee370d8aa9c4"
public-health-bioinformatics
parents: 1
diff changeset
51 sufficient_identity = float(abricate_report_row['%IDENTITY']) >= min_identity
2262e531c50b "planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/screen_abricate_report commit 50a464c3e6f87ca8d2c874842cbcee370d8aa9c4"
public-health-bioinformatics
parents: 1
diff changeset
52 if gene_of_interest and sufficient_coverage and sufficient_identity:
2262e531c50b "planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/screen_abricate_report commit 50a464c3e6f87ca8d2c874842cbcee370d8aa9c4"
public-health-bioinformatics
parents: 1
diff changeset
53 return True
2262e531c50b "planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/screen_abricate_report commit 50a464c3e6f87ca8d2c874842cbcee370d8aa9c4"
public-health-bioinformatics
parents: 1
diff changeset
54 else:
2262e531c50b "planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/screen_abricate_report commit 50a464c3e6f87ca8d2c874842cbcee370d8aa9c4"
public-health-bioinformatics
parents: 1
diff changeset
55 return False
2262e531c50b "planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/screen_abricate_report commit 50a464c3e6f87ca8d2c874842cbcee370d8aa9c4"
public-health-bioinformatics
parents: 1
diff changeset
56
2262e531c50b "planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/screen_abricate_report commit 50a464c3e6f87ca8d2c874842cbcee370d8aa9c4"
public-health-bioinformatics
parents: 1
diff changeset
57
0
b2d56a44a872 "planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/screen_abricate_report commit 1d569fc27b052d1982d82ca19455caaff6386f46"
public-health-bioinformatics
parents:
diff changeset
58 def main(args):
b2d56a44a872 "planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/screen_abricate_report commit 1d569fc27b052d1982d82ca19455caaff6386f46"
public-health-bioinformatics
parents:
diff changeset
59 screen = parse_screen_file(args.screening_file)
b2d56a44a872 "planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/screen_abricate_report commit 1d569fc27b052d1982d82ca19455caaff6386f46"
public-health-bioinformatics
parents:
diff changeset
60 gene_detection_status_fieldnames = ['gene_name', 'detected']
1
4f963b583186 "planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/screen_abricate_report commit c27095ceaf23aa2c910e0ea866db9ec8d3e7816b"
public-health-bioinformatics
parents: 0
diff changeset
61 with open(args.abricate_report, 'r') as f1, \
4f963b583186 "planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/screen_abricate_report commit c27095ceaf23aa2c910e0ea866db9ec8d3e7816b"
public-health-bioinformatics
parents: 0
diff changeset
62 open(args.screened_report, 'w') as f2, \
4f963b583186 "planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/screen_abricate_report commit c27095ceaf23aa2c910e0ea866db9ec8d3e7816b"
public-health-bioinformatics
parents: 0
diff changeset
63 open(args.gene_detection_status, 'w') as f3:
0
b2d56a44a872 "planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/screen_abricate_report commit 1d569fc27b052d1982d82ca19455caaff6386f46"
public-health-bioinformatics
parents:
diff changeset
64 abricate_report_reader = csv.DictReader(f1, delimiter="\t", quotechar='"')
1
4f963b583186 "planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/screen_abricate_report commit c27095ceaf23aa2c910e0ea866db9ec8d3e7816b"
public-health-bioinformatics
parents: 0
diff changeset
65 screened_report_writer = csv.DictWriter(f2, delimiter="\t", quotechar='"',
4f963b583186 "planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/screen_abricate_report commit c27095ceaf23aa2c910e0ea866db9ec8d3e7816b"
public-health-bioinformatics
parents: 0
diff changeset
66 fieldnames=abricate_report_reader.fieldnames)
4f963b583186 "planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/screen_abricate_report commit c27095ceaf23aa2c910e0ea866db9ec8d3e7816b"
public-health-bioinformatics
parents: 0
diff changeset
67 gene_detection_status_writer = csv.DictWriter(f3, delimiter="\t", quotechar='"',
4f963b583186 "planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/screen_abricate_report commit c27095ceaf23aa2c910e0ea866db9ec8d3e7816b"
public-health-bioinformatics
parents: 0
diff changeset
68 fieldnames=gene_detection_status_fieldnames)
0
b2d56a44a872 "planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/screen_abricate_report commit 1d569fc27b052d1982d82ca19455caaff6386f46"
public-health-bioinformatics
parents:
diff changeset
69 screened_report_writer.writeheader()
b2d56a44a872 "planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/screen_abricate_report commit 1d569fc27b052d1982d82ca19455caaff6386f46"
public-health-bioinformatics
parents:
diff changeset
70 gene_detection_status_writer.writeheader()
b2d56a44a872 "planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/screen_abricate_report commit 1d569fc27b052d1982d82ca19455caaff6386f46"
public-health-bioinformatics
parents:
diff changeset
71
b2d56a44a872 "planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/screen_abricate_report commit 1d569fc27b052d1982d82ca19455caaff6386f46"
public-health-bioinformatics
parents:
diff changeset
72 for gene in screen:
b2d56a44a872 "planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/screen_abricate_report commit 1d569fc27b052d1982d82ca19455caaff6386f46"
public-health-bioinformatics
parents:
diff changeset
73 gene_detection_status = {
b2d56a44a872 "planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/screen_abricate_report commit 1d569fc27b052d1982d82ca19455caaff6386f46"
public-health-bioinformatics
parents:
diff changeset
74 'gene_name': gene['gene_name'],
b2d56a44a872 "planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/screen_abricate_report commit 1d569fc27b052d1982d82ca19455caaff6386f46"
public-health-bioinformatics
parents:
diff changeset
75 'detected': False
b2d56a44a872 "planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/screen_abricate_report commit 1d569fc27b052d1982d82ca19455caaff6386f46"
public-health-bioinformatics
parents:
diff changeset
76 }
b2d56a44a872 "planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/screen_abricate_report commit 1d569fc27b052d1982d82ca19455caaff6386f46"
public-health-bioinformatics
parents:
diff changeset
77 for abricate_report_row in abricate_report_reader:
3
2262e531c50b "planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/screen_abricate_report commit 50a464c3e6f87ca8d2c874842cbcee370d8aa9c4"
public-health-bioinformatics
parents: 1
diff changeset
78 if detect_gene(abricate_report_row, gene['regex'], args.min_coverage, args.min_identity):
0
b2d56a44a872 "planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/screen_abricate_report commit 1d569fc27b052d1982d82ca19455caaff6386f46"
public-health-bioinformatics
parents:
diff changeset
79 gene_detection_status['detected'] = True
b2d56a44a872 "planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/screen_abricate_report commit 1d569fc27b052d1982d82ca19455caaff6386f46"
public-health-bioinformatics
parents:
diff changeset
80 screened_report_writer.writerow(abricate_report_row)
b2d56a44a872 "planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/screen_abricate_report commit 1d569fc27b052d1982d82ca19455caaff6386f46"
public-health-bioinformatics
parents:
diff changeset
81 gene_detection_status_writer.writerow(gene_detection_status)
1
4f963b583186 "planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/screen_abricate_report commit c27095ceaf23aa2c910e0ea866db9ec8d3e7816b"
public-health-bioinformatics
parents: 0
diff changeset
82 f1.seek(0) # return file pointer to start of abricate report
3
2262e531c50b "planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/screen_abricate_report commit 50a464c3e6f87ca8d2c874842cbcee370d8aa9c4"
public-health-bioinformatics
parents: 1
diff changeset
83 next(abricate_report_reader)
0
b2d56a44a872 "planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/screen_abricate_report commit 1d569fc27b052d1982d82ca19455caaff6386f46"
public-health-bioinformatics
parents:
diff changeset
84
b2d56a44a872 "planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/screen_abricate_report commit 1d569fc27b052d1982d82ca19455caaff6386f46"
public-health-bioinformatics
parents:
diff changeset
85
b2d56a44a872 "planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/screen_abricate_report commit 1d569fc27b052d1982d82ca19455caaff6386f46"
public-health-bioinformatics
parents:
diff changeset
86 if __name__ == '__main__':
b2d56a44a872 "planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/screen_abricate_report commit 1d569fc27b052d1982d82ca19455caaff6386f46"
public-health-bioinformatics
parents:
diff changeset
87 parser = argparse.ArgumentParser()
b2d56a44a872 "planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/screen_abricate_report commit 1d569fc27b052d1982d82ca19455caaff6386f46"
public-health-bioinformatics
parents:
diff changeset
88 parser.add_argument("abricate_report", help="Input: Abricate report to screen (tsv)")
b2d56a44a872 "planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/screen_abricate_report commit 1d569fc27b052d1982d82ca19455caaff6386f46"
public-health-bioinformatics
parents:
diff changeset
89 parser.add_argument("--screening_file", help="Input: List of genes to screen for (tsv)")
3
2262e531c50b "planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/screen_abricate_report commit 50a464c3e6f87ca8d2c874842cbcee370d8aa9c4"
public-health-bioinformatics
parents: 1
diff changeset
90 parser.add_argument("--screened_report",
2262e531c50b "planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/screen_abricate_report commit 50a464c3e6f87ca8d2c874842cbcee370d8aa9c4"
public-health-bioinformatics
parents: 1
diff changeset
91 help=("Output: Screened abricate report, including only genes of interest (tsv)"))
2262e531c50b "planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/screen_abricate_report commit 50a464c3e6f87ca8d2c874842cbcee370d8aa9c4"
public-health-bioinformatics
parents: 1
diff changeset
92 parser.add_argument("--gene_detection_status",
2262e531c50b "planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/screen_abricate_report commit 50a464c3e6f87ca8d2c874842cbcee370d8aa9c4"
public-health-bioinformatics
parents: 1
diff changeset
93 help=("Output: detection status for all genes listed in the screening file (tsv)"))
2262e531c50b "planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/screen_abricate_report commit 50a464c3e6f87ca8d2c874842cbcee370d8aa9c4"
public-health-bioinformatics
parents: 1
diff changeset
94 parser.add_argument("--min_coverage", type=float, default=90.0,
2262e531c50b "planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/screen_abricate_report commit 50a464c3e6f87ca8d2c874842cbcee370d8aa9c4"
public-health-bioinformatics
parents: 1
diff changeset
95 choices=Range(0.0, 100.0), help=("Minimum percent coverage"))
2262e531c50b "planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/screen_abricate_report commit 50a464c3e6f87ca8d2c874842cbcee370d8aa9c4"
public-health-bioinformatics
parents: 1
diff changeset
96 parser.add_argument("--min_identity", type=float, default=90.0,
2262e531c50b "planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/screen_abricate_report commit 50a464c3e6f87ca8d2c874842cbcee370d8aa9c4"
public-health-bioinformatics
parents: 1
diff changeset
97 choices=Range(0.0, 100.0), help=("Minimum percent identity"))
0
b2d56a44a872 "planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/screen_abricate_report commit 1d569fc27b052d1982d82ca19455caaff6386f46"
public-health-bioinformatics
parents:
diff changeset
98 args = parser.parse_args()
b2d56a44a872 "planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/screen_abricate_report commit 1d569fc27b052d1982d82ca19455caaff6386f46"
public-health-bioinformatics
parents:
diff changeset
99 main(args)