changeset 2:a5674ddf2ad7 draft

planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/cufflinks/cuffcompare commit eb18f691975ef9539b5ebd4f118343c8ad967a1f
author devteam
date Tue, 07 Feb 2017 18:37:50 -0500
parents 6d8ab54229a0
children 5aac9b9d6f2a
files cuff_macros.xml cuffcompare_wrapper.py cuffcompare_wrapper.xml tool_dependencies.xml
diffstat 4 files changed, 104 insertions(+), 104 deletions(-) [+]
line wrap: on
line diff
--- a/cuff_macros.xml	Tue Oct 13 12:37:24 2015 -0400
+++ b/cuff_macros.xml	Tue Feb 07 18:37:50 2017 -0500
@@ -1,11 +1,13 @@
 <macros>
   <token name="@VERSION@">2.2.1</token>
+
   <xml name="requirements">
     <requirements>
       <requirement type="package" version="2.2.1">cufflinks</requirement>
       <yield />
     </requirements>
   </xml>
+
   <xml name="stdio">
     <stdio>
         <exit_code range="1:" />
@@ -26,21 +28,21 @@
         </param>
         <when value="BAM">
             <repeat name="conditions" title="Condition" min="2">
-                <param name="name" title="Condition name" type="text" label="Name"/>
+                <param name="name" label="Condition name" type="text"/>
                 <param name="samples" label="Replicates" type="data" format="sam,bam" multiple="true"/>
             </repeat>
         </when>
         <when value="CXB">
             <repeat name="conditions" title="Condition" min="2">
-                <param name="name" title="Condition name" type="text" label="Name"/>
+                <param name="name" label="Condition name" type="text"/>
                 <param name="samples" label="Replicates" type="data" format="cxb" multiple="true"/>
             </repeat>
         </when>
         <when value="CONDITION_LIST">
-            <param name="conditions" title="List of Conditions" type="data_collection" collection_type="list" />
+            <param name="conditions" label="List of Conditions" type="data_collection" collection_type="list" />
         </when>
         <when value="CONDITION_REPLICATE_LIST">
-            <param name="conditions" title="List of Conditions" type="data_collection" collection_type="list:list" />
+            <param name="conditions" label="List of Conditions" type="data_collection" collection_type="list:list" />
         </when>
     </conditional>
   </xml>
@@ -48,16 +50,16 @@
             #if $in_type.set_in_type in ['BAM', 'CXB']
                 #for $condition in $in_type.conditions:
                     #set samples = ','.join( [ str( $sample ) for $sample in $condition.samples ] )
-                    $samples
+                    '$samples'
                 #end for
             #elif $in_type.set_in_type == 'CONDITION_LIST'
                 #for $sample in $in_type.conditions:
-                    $sample
+                    '$sample'
                 #end for
             #elif $in_type.set_in_type == 'CONDITION_REPLICATE_LIST'
                 #for $condition_list in $in_type.conditions:
                     #set samples = ','.join( [ str( $sample ) for $sample in $condition_list ] )
-                    $samples
+                    '$samples'
                 #end for
             #end if
   </token>
@@ -79,11 +81,11 @@
   <token name="@CUFFLINKS_GTF_INPUTS@">
             ## Inputs.
             #for $input_file in $inputs:
-                "${input_file}"
+                '${input_file}'
             #end for
             #for $additional_input in $additional_inputs:
                 #for $input_file in $additional_input.additional_inputs:
-                  "${input_file}"
+                    '${input_file}'
                 #end for
             #end for
   </token>
--- a/cuffcompare_wrapper.py	Tue Oct 13 12:37:24 2015 -0400
+++ b/cuffcompare_wrapper.py	Tue Feb 07 18:37:50 2017 -0500
@@ -2,135 +2,133 @@
 
 # Supports Cuffcompare versions v1.3.0 and newer.
 
-import optparse, os, shutil, subprocess, sys, tempfile
+import optparse
+import os
+import shutil
+import subprocess
+import sys
+import tempfile
 
-def stop_err( msg ):
-    sys.stderr.write( '%s\n' % msg )
+
+def stop_err(msg):
+    sys.stderr.write('%s\n' % msg)
     sys.exit()
 
+
 def __main__():
-    #Parse Command Line
     parser = optparse.OptionParser()
-    parser.add_option( '-r', 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( '-R', action="store_true", dest='ignore_nonoverlap_reference', help='If -r was specified, this option causes cuffcompare to ignore reference transcripts that are not overlapped by any transcript in one of cuff1.gtf,...,cuffN.gtf. Useful for ignoring annotated transcripts that are not present in your RNA-Seq samples and thus adjusting the "sensitivity" calculation in the accuracy report written in the transcripts accuracy file' )
-    parser.add_option( '-Q', action="store_true", dest='ignore_nonoverlap_transfrag', help='If -r was specified, this option causes cuffcompare to consider only the input transcripts that overlap any of the reference transcripts (Sp correction); Warning: this will discard all "novel" loci!)' )
+    parser.add_option('-r', 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('-R', action="store_true", dest='ignore_nonoverlap_reference', help='If -r was specified, this option causes cuffcompare to ignore reference transcripts that are not overlapped by any transcript in one of cuff1.gtf,...,cuffN.gtf. Useful for ignoring annotated transcripts that are not present in your RNA-Seq samples and thus adjusting the "sensitivity" calculation in the accuracy report written in the transcripts accuracy file')
+    parser.add_option('-Q', action="store_true", dest='ignore_nonoverlap_transfrag', help='If -r was specified, this option causes cuffcompare to consider only the input transcripts that overlap any of the reference transcripts (Sp correction); Warning: this will discard all "novel" loci!)')
 
-    parser.add_option( '-s', dest='use_seq_data', action="store_true", help='Causes cuffcompare 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( '-M', action="store_true", dest='discard_single_exon_all', help='discard (ignore) single-exon transfrags and reference transcript')
-    parser.add_option( '-N', action="store_true", dest='discard_single_exon_ref', help='discard (ignore) single-exon reference transcripts')
-    parser.add_option( '-e', dest='max_dist_exon', help='Max. Distance for assessing exon accuracy" help="max. distance (range) allowed from free ends of terminal exons of reference transcripts when assessing exon accuracy. Default: 100')
-    parser.add_option( '-d', dest='max_dist_group', help='Max.Distance for transcript grouping" help="max. distance (range) for grouping transcript start sites. Default: 100')
-    parser.add_option( '-F', action="store_true", dest='discard_redundant_intron_transfrags', help='Discard intron-redundant transfrags if they share the 5-prime end (if they differ only at the 3-prime end)')
+    parser.add_option('-s', dest='use_seq_data', action="store_true", help='Causes cuffcompare 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('-M', action="store_true", dest='discard_single_exon_all', help='discard (ignore) single-exon transfrags and reference transcript')
+    parser.add_option('-N', action="store_true", dest='discard_single_exon_ref', help='discard (ignore) single-exon reference transcripts')
+    parser.add_option('-e', dest='max_dist_exon', help='Max. Distance for assessing exon accuracy" help="max. distance (range) allowed from free ends of terminal exons of reference transcripts when assessing exon accuracy. Default: 100')
+    parser.add_option('-d', dest='max_dist_group', help='Max.Distance for transcript grouping" help="max. distance (range) for grouping transcript start sites. Default: 100')
+    parser.add_option('-F', action="store_true", dest='discard_redundant_intron_transfrags', help='Discard intron-redundant transfrags if they share the 5-prime end (if they differ only at the 3-prime end)')
 
     # 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' )
-    
+    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( '', '--combined-transcripts', dest='combined_transcripts' )
-    
+    parser.add_option('', '--combined-transcripts', dest='combined_transcripts')
+
     (options, args) = parser.parse_args()
-    
+
     # output version # of tool
     try:
-        tmp = tempfile.NamedTemporaryFile().name
-        tmp_stdout = open( tmp, 'wb' )
-        proc = subprocess.Popen( args='cuffcompare 2>&1', shell=True, stdout=tmp_stdout )
-        tmp_stdout.close()
-        returncode = proc.wait()
-        stdout = None
-        for line in open( tmp_stdout.name, 'rb' ):
-            if line.lower().find( 'cuffcompare v' ) >= 0:
-                stdout = line.strip()
-                break
+        with tempfile.NamedTemporaryFile() as tmp_stdout:
+            returncode = subprocess.call(args='cuffcompare 2>&1', stdout=tmp_stdout, shell=True)
+            stdout = None
+            with open(tmp_stdout.name) as tmp_stdout2:
+                for line in tmp_stdout2:
+                    if line.lower().find('cuffcompare v') >= 0:
+                        stdout = line.strip()
+                        break
         if stdout:
-            sys.stdout.write( '%s\n' % stdout )
+            sys.stdout.write('%s\n' % stdout)
         else:
             raise Exception
     except:
-        sys.stdout.write( 'Could not determine Cuffcompare version\n' )
-        
+        sys.stdout.write('Could not determine Cuffcompare version\n')
+
     # 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  )
+            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 )
+            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 = "cuffcompare -o cc_output "
-    
+
     # Add options.
     if options.ref_annotation:
         cmd += " -r %s " % options.ref_annotation
     if options.ignore_nonoverlap_reference:
         cmd += " -R "
     if options.ignore_nonoverlap_transfrag:
-	cmd += " -Q "
+        cmd += " -Q "
     if options.use_seq_data:
         cmd += " -s %s " % seq_path
     if options.discard_single_exon_all:
-	cmd += " -M "
+        cmd += " -M "
     if options.discard_single_exon_ref:
-	cmd += " -N "
+        cmd += " -N "
     if options.max_dist_exon:
-	cmd += " -e %i " % int( options.max_dist_exon )
+        cmd += " -e %i " % int(options.max_dist_exon)
     if options.max_dist_group:
-	cmd += " -d %i " % int( options.max_dist_group )
-    if options.discard_redundant_intron_transfrags: 
-	cmd += " -F "
+        cmd += " -d %i " % int(options.max_dist_group)
+    if options.discard_redundant_intron_transfrags:
+        cmd += " -F "
     # Add input files.
-        
-    # Need to symlink inputs so that output files are written to temp directory.
-    for i, arg in enumerate( args ):
-        input_file_name = "./input%i" % ( i+1 )
-        os.symlink( arg, input_file_name )
+
+    # Need to symlink inputs so that output files are written to the current directory.
+    for i, arg in enumerate(args):
+        input_file_name = "./input%i" % (i + 1)
+        os.symlink(arg, input_file_name)
         cmd += "%s " % input_file_name
 
-    # Debugging.
-    print cmd
-    
     # Run command.
-    try:        
-        tmp_name = tempfile.NamedTemporaryFile( dir="." ).name
-        tmp_stderr = open( tmp_name, 'wb' )
-        proc = subprocess.Popen( args=cmd, shell=True, stderr=tmp_stderr.fileno() )
-        returncode = proc.wait()
-        tmp_stderr.close()
-        
-        # Get stderr, allowing for case where it's very large.
-        tmp_stderr = open( tmp_name, 'rb' )
-        stderr = ''
-        buffsize = 1048576
-        try:
-            while True:
-                stderr += tmp_stderr.read( buffsize )
-                if not stderr or len( stderr ) % buffsize != 0:
-                    break
-        except OverflowError:
-            pass
-        tmp_stderr.close()
-        
-        # Error checking.
-        if returncode != 0:
-            raise Exception, stderr
-            
+    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) 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)
+
         # Copy outputs.
-        shutil.copyfile( "cc_output.combined.gtf" , options.combined_transcripts )    
-            
+        shutil.move("cc_output.combined.gtf", options.combined_transcripts)
+
         # check that there are results in the output file
         cc_output_fname = "cc_output.stats"
-        if len( open( cc_output_fname, 'rb' ).read().strip() ) == 0:
-            raise Exception, 'The main output file is empty, there may be an error with your input file or settings.'
-    except Exception, e:
-        stop_err( 'Error running cuffcompare. ' + str( e ) )
-        
-if __name__=="__main__": __main__()
+        if len(open(cc_output_fname).read().strip()) == 0:
+            raise Exception('The main output file is empty, there may be an error with your input file or settings.')
+    except Exception as e:
+        stop_err('Error running cuffcompare: %s' % e)
+
+
+if __name__ == "__main__":
+    __main__()
--- a/cuffcompare_wrapper.xml	Tue Oct 13 12:37:24 2015 -0400
+++ b/cuffcompare_wrapper.xml	Tue Feb 07 18:37:50 2017 -0500
@@ -1,16 +1,16 @@
 <tool id="cuffcompare" name="Cuffcompare" version="2.2.1.0">
     <description>compare assembled transcripts to a reference annotation and track Cufflinks transcripts across multiple experiments</description>
-    <expand macro="requirements" />
-    <expand macro="stdio" />
     <macros>
       <import>cuff_macros.xml</import>
     </macros>
+    <expand macro="requirements" />
+    <expand macro="stdio" />
     <version_command>cuffcompare 2>&amp;1 | head -n 1</version_command>
-    <command interpreter="python">
-        cuffcompare_wrapper.py 
+    <command>
+        python '$__tool_directory__/cuffcompare_wrapper.py'
             ## Use annotation reference?
             #if $annotation.use_ref_annotation == "Yes":
-                -r $annotation.reference_annotation
+                -r '$annotation.reference_annotation'
                 #if $annotation.ignore_nonoverlapping_reference:
                     -R
                 #end if
@@ -24,9 +24,9 @@
             #if $seq_data.use_seq_data == "Yes":
             -s
                 #if $seq_data.seq_source.index_source == "history":
-                    --ref_file=$seq_data.seq_source.ref_file
+                    --ref_file '$seq_data.seq_source.ref_file'
                 #else:
-                    --index=${seq_data.seq_source.index.fields.path}
+                    --index '${seq_data.seq_source.index.fields.path}'
                 #end if
             #end if
             
@@ -40,7 +40,7 @@
             #end if 
 
             ## Outputs.
-            --combined-transcripts=${transcripts_combined}
+            --combined-transcripts '${transcripts_combined}'
 
             @CUFFLINKS_GTF_INPUTS@
     </command>
--- a/tool_dependencies.xml	Tue Oct 13 12:37:24 2015 -0400
+++ b/tool_dependencies.xml	Tue Feb 07 18:37:50 2017 -0500
@@ -1,6 +1,6 @@
 <?xml version="1.0"?>
 <tool_dependency>
     <package name="cufflinks" version="2.2.1">
-        <repository changeset_revision="8f755957b6a1" name="package_cufflinks_2_2_1" owner="devteam" toolshed="https://testtoolshed.g2.bx.psu.edu" />
+        <repository changeset_revision="87f239da61af" name="package_cufflinks_2_2_1" owner="devteam" toolshed="https://testtoolshed.g2.bx.psu.edu" />
     </package>
 </tool_dependency>