changeset 1:4f963b583186 draft

"planemo upload for repository https://github.com/public-health-bioinformatics/galaxy_tools/blob/master/tools/screen_abricate_report commit c27095ceaf23aa2c910e0ea866db9ec8d3e7816b"
author public-health-bioinformatics
date Tue, 12 Nov 2019 21:44:45 -0500
parents b2d56a44a872
children 912a3a3dc082
files screen_abricate_report.py screen_abricate_report.xml
diffstat 2 files changed, 19 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/screen_abricate_report.py	Thu Oct 31 15:43:15 2019 -0400
+++ b/screen_abricate_report.py	Tue Nov 12 21:44:45 2019 -0500
@@ -3,11 +3,9 @@
 from __future__ import print_function
 
 import argparse
-import os
+import csv
 import re
-import sys
-import csv
-from pprint import pprint
+
 
 def parse_screen_file(screen_file):
     screen = []
@@ -17,21 +15,26 @@
             screen.append(row)
     return screen
 
+
 def get_fieldnames(input_file):
     with open(input_file) as f:
         reader = csv.DictReader(f, delimiter="\t", quotechar='"')
         row = next(reader)
     fieldnames = row.keys()
     return fieldnames
-    
+
+
 def main(args):
     screen = parse_screen_file(args.screening_file)
-    abricate_report_fieldnames = get_fieldnames(args.abricate_report)
     gene_detection_status_fieldnames = ['gene_name', 'detected']
-    with open(args.abricate_report, 'r') as f1, open(args.screened_report, 'w') as f2, open(args.gene_detection_status, 'w') as f3:
+    with open(args.abricate_report, 'r') as f1, \
+            open(args.screened_report, 'w') as f2, \
+            open(args.gene_detection_status, 'w') as f3:
         abricate_report_reader = csv.DictReader(f1, delimiter="\t", quotechar='"')
-        screened_report_writer = csv.DictWriter(f2, delimiter="\t", quotechar='"', fieldnames=abricate_report_reader.fieldnames)
-        gene_detection_status_writer = csv.DictWriter(f3, delimiter="\t", quotechar='"', fieldnames=gene_detection_status_fieldnames)
+        screened_report_writer = csv.DictWriter(f2, delimiter="\t", quotechar='"',
+                                                fieldnames=abricate_report_reader.fieldnames)
+        gene_detection_status_writer = csv.DictWriter(f3, delimiter="\t", quotechar='"',
+                                                      fieldnames=gene_detection_status_fieldnames)
         screened_report_writer.writeheader()
         gene_detection_status_writer.writeheader()
 
@@ -45,14 +48,16 @@
                     gene_detection_status['detected'] = True
                     screened_report_writer.writerow(abricate_report_row)
             gene_detection_status_writer.writerow(gene_detection_status)
-            f1.seek(0) # return file pointer to start of abricate report
+            f1.seek(0)  # return file pointer to start of abricate report
 
 
 if __name__ == '__main__':
     parser = argparse.ArgumentParser()
     parser.add_argument("abricate_report", help="Input: Abricate report to screen (tsv)")
     parser.add_argument("--screening_file", help="Input: List of genes to screen for (tsv)")
-    parser.add_argument("--screened_report", help="Output: Screened abricate report including only genes of interest (tsv)")
-    parser.add_argument("--gene_detection_status", help="Output: detection status for all genes listed in the screening file (tsv)")
+    parser.add_argument("--screened_report", help=("Output: Screened abricate report ",
+                                                   "including only genes of interest (tsv)"))
+    parser.add_argument("--gene_detection_status", help=("Output: detection status for all genes ",
+                                                         "listed in the screening file (tsv)"))
     args = parser.parse_args()
     main(args)
--- a/screen_abricate_report.xml	Thu Oct 31 15:43:15 2019 -0400
+++ b/screen_abricate_report.xml	Tue Nov 12 21:44:45 2019 -0500
@@ -18,8 +18,8 @@
 	</param>
     </inputs>
     <outputs>
-        <data name="screened_report" type="data" format="tabular" label="Screened Abricate Report" />
-        <data name="gene_detection_status" type="data" format="tabular" label="Gene Detection Status" />
+        <data name="screened_report" format="tabular" label="Screened Abricate Report" />
+        <data name="gene_detection_status" format="tabular" label="Gene Detection Status" />
     </outputs>
     <tests>
         <test>