changeset 6:878f18249f76 draft

"planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc/tree/master/tools/qc commit 21d348651ca466563cc507b9e3a3fbd6c2b0a016"
author sanbi-uwc
date Mon, 12 Apr 2021 12:28:41 +0000
parents 499b71c93c5d
children 6bdec8c62aec
files qc.py qc.xml
diffstat 2 files changed, 14 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/qc.py	Wed Apr 07 22:07:00 2021 +0000
+++ b/qc.py	Mon Apr 12 12:28:41 2021 +0000
@@ -6,6 +6,7 @@
 import pandas as pd
 import matplotlib.pyplot as plt
 import shlex
+import json
 
 """
 This script can incorporate as many QC checks as required
@@ -156,7 +157,12 @@
         writer = csv.DictWriter(csvfile, fieldnames=header)
         writer.writeheader()
         writer.writerow(qc_line)
-
+    
+    # write a json file from the dict
+    json_file = args.outfile + '.json'
+    with open(args.outfile, 'w') as jsonfile:
+       json.dump(qc_line, json_file)
+    
     N_density = sliding_window_N_density(fasta)
     make_qc_plot(depth_pos, N_density, args.sample)
 
--- a/qc.xml	Wed Apr 07 22:07:00 2021 +0000
+++ b/qc.xml	Mon Apr 12 12:28:41 2021 +0000
@@ -11,8 +11,9 @@
             --sample 'sample'
             --ref '$input_ref' 
             --bam '$input_bam' 
-            --fasta '$input_cons_fasta' && 
-        mv sample.depth.png '$output2'
+            --fasta '$input_cons_fasta' &&
+        mv '$output1'.json  '$output2' &&
+        mv sample.depth.png '$output3'
     ]]></command>
     <inputs>
         <conditional name="qc_type_conditional">
@@ -27,7 +28,8 @@
     </inputs>
     <outputs>
         <data name="output1" format="csv" label="${tool.name} on ${on_string}: tubular output"/>
-        <data name="output2" format="png" label="${tool.name} on ${on_string}: depth and density"/>
+        <data name="output2" format="json" label="${tool.name} on ${on_string}: json output"/>
+        <data name="output3" format="png" label="${tool.name} on ${on_string}: depth and density"/>
     </outputs>
     <tests>
         <test>
@@ -36,7 +38,8 @@
             <param name="input_bam" value="sample.bam"/>
             <param name="input_cons_fasta" value="sample_consensus.fasta"/>
             <output name="output1" file="test_sample.qc.csv"/>
-            <output name="output2" file="test_sample.depth.png"/>
+            <output name="output2" file="test_sample.qc.json"/>
+            <output name="output3" file="test_sample.depth.png"/>
         </test>
     </tests>
     <help><![CDATA[