changeset 1:9ce7ccd468aa draft

planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/sequence_format_converter commit dfecfb40f245a3cdb09dd1cfe37be4cb164ad2eb
author artbio
date Fri, 16 Feb 2018 04:55:44 -0500
parents a8aacccd79a3
children f1d59113125a
files sequence_format_converter.py sequence_format_converter.xml test-data/input.fastqsanger.gz
diffstat 3 files changed, 35 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/sequence_format_converter.py	Mon Sep 04 07:13:28 2017 -0400
+++ b/sequence_format_converter.py	Fri Feb 16 04:55:44 2018 -0500
@@ -40,7 +40,7 @@
         try:
             for l in range(4):
                 block.append(input.readline()[:-1])
-        except:
+        except IndexError:
             logging.info("File hasn't at leat four lines !")
             sys.exit("File hasn't at leat four lines !")
         input.close()
@@ -81,7 +81,7 @@
                     if line[0] == '>':
                         int(line.split('_')[-1])
                 return 'fastaw'
-            except:
+            except ValueError:
                 return 'fasta'
         if line1[0] == '@' and line3[0] == '+':
             nucleotides = set([base for base in line2])
@@ -98,7 +98,7 @@
                 sys.exit('No valid format detected')
             try:
                 int(line.split('\t')[-1])
-            except:
+            except ValueError:
                 logging.info("No valid format detected")
                 sys.exit('No valid format detected')
             for nucleotide in line.split('\t')[0]:
@@ -112,22 +112,22 @@
         if format == 'fasta':
             try:
                 self.readfasta(input)
-            except:
+            except Exception:
                 logging.info("an error occured while reading fasta")
         elif format == 'fastaw':
             try:
                 self.readfastaw(input)
-            except:
+            except Exception:
                 logging.info("an error occured while reading fastaw")
         elif format == 'tabular':
             try:
                 self.readtabular(input)
-            except:
+            except Exception:
                 logging.info("an error occured while reading tabular")
         elif format == 'fastq':
             try:
                 self.readfastq(input)
-            except:
+            except Exception:
                 logging.info("an error occured while reading fastq")
         else:
             logging.info("no valid format detected")
--- a/sequence_format_converter.xml	Mon Sep 04 07:13:28 2017 -0400
+++ b/sequence_format_converter.xml	Fri Feb 16 04:55:44 2018 -0500
@@ -1,10 +1,19 @@
-<tool id="sequence_format_converter" name="sequence_format_converter" version="2.0.0">
+<tool id="sequence_format_converter" name="sequence_format_converter" version="2.1.0">
   <description></description>
   <command><![CDATA[
+    #if $input.is_of_type('fastq.gz'):
+      gzip -dc $input > '${input}.tmp';
+      python '$__tool_directory__'/sequence_format_converter.py
+      --input '${input}.tmp'
+      --output '$output'
+      --format '$output_format';
+      rm '${input}.tmp';
+    #else:
       python '$__tool_directory__'/sequence_format_converter.py
       --input '$input'
       --output '$output'
       --format '$output_format'
+    #end if
   ]]></command>
 
 <inputs>
@@ -79,6 +88,24 @@
             <param ftype="fasta" name="input" value="input.fastqsanger" />
             <output file="fastqTofastaw.sorted.faw" name="output" sort="True" />
         </test>
+        <test>
+            <!-- convertion fastq.gz to tabular -->
+            <param name="output_format" value="tabular" />
+            <param ftype="fastq.gz" name="input" value="input.fastqsanger.gz" />
+            <output file="fastqTotabular.sorted.tab" name="output" sort="True" />
+        </test>
+         <test>
+            <!-- convertion fastq.gz to fasta -->
+            <param name="output_format" value="fasta" />
+            <param ftype="fastq.gz" name="input" value="input.fastqsanger.gz" />
+            <output file="fastqTofasta.sorted.fa" name="output" sort="True" />
+        </test>
+        <test>
+            <!-- convertion fastq.gz to fastaw -->
+            <param name="output_format" value="fastaw" />
+            <param ftype="fastq.gz" name="input" value="input.fastqsanger.gz" />
+            <output file="fastqTofastaw.sorted.faw" name="output" sort="True" />
+        </test>
    </tests>
 
 
Binary file test-data/input.fastqsanger.gz has changed