changeset 14:6a6717a5f421 draft

"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tool_collections/cufflinks/cuffmerge commit a0b0845a9d1b3e7ecdeacd1e606133617e3918bd"
author iuc
date Tue, 16 Jun 2020 13:00:53 -0400
parents cf747d1bd79a
children 86285ddd4512
files cuff_macros.xml cuffmerge_wrapper.py cuffmerge_wrapper.xml
diffstat 3 files changed, 27 insertions(+), 119 deletions(-) [+]
line wrap: on
line diff
--- a/cuff_macros.xml	Sun Feb 19 12:12:38 2017 -0500
+++ b/cuff_macros.xml	Tue Jun 16 13:00:53 2020 -0400
@@ -66,20 +66,26 @@
   </token>
   <xml name="cufflinks_gtf_inputs">
     <param format="gtf" name="inputs" type="data" label="GTF file(s) produced by Cufflinks" help="" multiple="true" />
-    <repeat name="additional_inputs" title="Additional GTF Inputs (Lists)">
-      <param format="gtf" name="additional_inputs" type="data_collection" label="GTF file(s) produced by Cufflinks" help="" />
-    </repeat>
   </xml>
+  <token name="@CUFFLINKS_LINK_GTF_INPUTS@"><![CDATA[
+            ## Inputs.
+            #for $i, $input_file in enumerate($inputs):
+                ln -s '${input_file}' input_$i &&
+            #end for
+  ]]></token>
   <token name="@CUFFLINKS_GTF_INPUTS@">
             ## Inputs.
-            #for $input_file in $inputs:
-                '${input_file}'
-            #end for
-            #for $additional_input in $additional_inputs:
-                #for $input_file in $additional_input.additional_inputs:
-                    '${input_file}'
-                #end for
+            #for $i, $input_file in enumerate($inputs):
+                'input_$i'
             #end for
   </token>
   <token name="@HAS_MULTIPLE_INPUTS@">getattr(inputs, "__len__", [].__len__)() >= 2</token>
+
+  <xml name="citations">
+    <citations>
+        <citation type="doi">10.1038/nbt.1621</citation>
+        <yield/>
+    </citations>
+  </xml>
+
 </macros>
--- a/cuffmerge_wrapper.py	Sun Feb 19 12:12:38 2017 -0500
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,94 +0,0 @@
-#!/usr/bin/env python
-
-import optparse
-import os
-import shutil
-import subprocess
-import sys
-import tempfile
-
-
-def stop_err(msg):
-    sys.stderr.write('%s\n' % msg)
-    sys.exit()
-
-
-def __main__():
-    parser = optparse.OptionParser()
-    parser.add_option('-g', dest='ref_annotation', help='An optional "reference" annotation GTF. Each sample is matched against this file, and sample isoforms are tagged as overlapping, matching, or novel where appropriate. See the refmap and tmap output file descriptions below.')
-    parser.add_option('-s', dest='use_seq_data', action="store_true", help='Causes cuffmerge to look into for fasta files with the underlying genomic sequences (one file per contig) against which your reads were aligned for some optional classification functions. For example, Cufflinks transcripts consisting mostly of lower-case bases are classified as repeats. Note that <seq_dir> must contain one fasta file per reference chromosome, and each file must be named after the chromosome, and have a .fa or .fasta extension.')
-    parser.add_option('-p', '--num-threads', dest='num_threads', help='Use this many threads to align reads. The default is 1.')
-
-    # Wrapper / Galaxy options.
-    parser.add_option('', '--index', dest='index', help='The path of the reference genome')
-    parser.add_option('', '--ref_file', dest='ref_file', help='The reference dataset from the history')
-
-    # Outputs.
-    parser.add_option('', '--merged-transcripts', dest='merged_transcripts')
-    parser.add_option('--min-isoform-fraction', dest='min_isoform_fraction')
-
-    (options, args) = parser.parse_args()
-
-    # Set/link to sequence file.
-    if options.use_seq_data:
-        if options.ref_file:
-            # Sequence data from history.
-            # Create symbolic link to ref_file so that index will be created in working directory.
-            seq_path = "ref.fa"
-            os.symlink(options.ref_file, seq_path)
-        else:
-            if not os.path.exists(options.index):
-                stop_err('Reference genome %s not present, request it by reporting this error.' % options.index)
-            seq_path = options.index
-
-    # Build command.
-
-    # Base.
-    cmd = "cuffmerge -o cm_output "
-
-    # Add options.
-    if options.num_threads:
-        cmd += (" -p %i " % int(options.num_threads))
-    if options.ref_annotation:
-        cmd += " -g %s " % options.ref_annotation
-    if options.use_seq_data:
-        cmd += " -s %s " % seq_path
-    if options.min_isoform_fraction:
-        cmd += " --min-isoform-fraction %s " % (options.min_isoform_fraction)
-    # Add input files to a file.
-    with tempfile.NamedTemporaryFile(mode='w', dir=".", delete=False) as inputs_file:
-        for arg in args:
-            inputs_file.write(arg + "\n")
-    cmd += inputs_file.name
-
-    # Run command.
-    try:
-        with tempfile.NamedTemporaryFile(dir=".") as tmp_stderr:
-            returncode = subprocess.call(args=cmd, stderr=tmp_stderr, shell=True)
-
-            # Error checking.
-            if returncode != 0:
-                # Get stderr, allowing for case where it's very large.
-                buffsize = 1048576
-                stderr = ''
-                with open(tmp_stderr.name, 'r') as tmp_stderr2:
-                    try:
-                        while True:
-                            stderr += tmp_stderr2.read(buffsize)
-                            if not stderr or len(stderr) % buffsize != 0:
-                                break
-                    except OverflowError:
-                        pass
-                raise Exception(stderr)
-
-        if len(open("cm_output/merged.gtf", 'r').read().strip()) == 0:
-            raise Exception('The output file is empty, there may be an error with your input file or settings.')
-
-        # Copy outputs.
-        shutil.move("cm_output/merged.gtf", options.merged_transcripts)
-    except Exception as e:
-        stop_err('Error running cuffmerge: %s' % e)
-
-
-if __name__ == "__main__":
-    __main__()
--- a/cuffmerge_wrapper.xml	Sun Feb 19 12:12:38 2017 -0500
+++ b/cuffmerge_wrapper.xml	Tue Jun 16 13:00:53 2020 -0400
@@ -1,14 +1,16 @@
-<tool id="cuffmerge" name="Cuffmerge" version="@VERSION@.1">
+<tool id="cuffmerge" name="Cuffmerge" version="@VERSION@.2">
     <description>merge together several Cufflinks assemblies</description>
     <macros>
       <import>cuff_macros.xml</import>
     </macros>
     <expand macro="requirements" />
-     <version_command>cuffmerge -v</version_command>
-    <command detect_errors="aggressive">
-        python '$__tool_directory__/cuffmerge_wrapper.py'
+    <version_command>cuffmerge -v</version_command>
+    <command detect_errors="aggressive"><![CDATA[
+        @CUFFLINKS_LINK_GTF_INPUTS@
+        echo @CUFFLINKS_GTF_INPUTS@ | sed 's/\s\+/\n/' > assembly_GTF_list.txt &&
+        cuffmerge 
+            -o output
             --num-threads="\${GALAXY_SLOTS:-4}"
-            
             ## Use annotation reference?
             #if $annotation.use_ref_annotation == "Yes":
                 -g '${annotation.reference_annotation}'
@@ -25,12 +27,8 @@
             #end if
 
             --min-isoform-fraction="${min_isoform_fraction}"
-
-            ## Outputs.
-            --merged-transcripts '${merged_transcripts}'
-
-            @CUFFLINKS_GTF_INPUTS@
-    </command>
+            assembly_GTF_list.txt
+    ]]></command>
     <inputs>
         <expand macro="cufflinks_gtf_inputs" />
         <conditional name="annotation">
@@ -74,7 +72,7 @@
     </inputs>
 
     <outputs>
-        <data format="gtf" name="merged_transcripts" label="${tool.name} on ${on_string}: merged transcripts"/>
+        <data format="gtf" name="merged_transcripts" label="${tool.name} on ${on_string}: merged transcripts" from_work_dir="output/merged.gtf"/>
     </outputs>
 
     <tests>
@@ -127,7 +125,5 @@
 
 Cuffmerge produces a GTF file that contains an assembly that merges together the input assemblies.
     </help>
-    <citations>
-        <citation type="doi">10.1038/nbt.1621</citation>
-    </citations>
+    <expand macro="citations"/>
 </tool>