Repository 'cufflinks'
hg clone https://toolshed.g2.bx.psu.edu/repos/devteam/cufflinks

Changeset 0:b50aacc8ae49 (2013-10-01)
Next changeset 1:b01956f26c36 (2013-10-01)
Commit message:
Uploaded tool tarball.
added:
cufflinks_wrapper.py
cufflinks_wrapper.xml
test-data/cufflinks_in.bam
test-data/cufflinks_out1.gtf
test-data/cufflinks_out2.fpkm_tracking
test-data/cufflinks_out3.fpkm_tracking
test-data/cufflinks_out4.txt
tool_dependencies.xml
b
diff -r 000000000000 -r b50aacc8ae49 cufflinks_wrapper.py
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/cufflinks_wrapper.py Tue Oct 01 12:55:37 2013 -0400
[
b'@@ -0,0 +1,227 @@\n+#!/usr/bin/env python\n+\n+# Supports Cufflinks versions 1.3 and newer.\n+\n+import optparse, os, shutil, subprocess, sys, tempfile\n+from galaxy import eggs\n+from galaxy.datatypes.util.gff_util import parse_gff_attributes, gff_attributes_to_str\n+\n+def stop_err( msg ):\n+    sys.stderr.write( "%s\\n" % msg )\n+    sys.exit()\n+    \n+# Copied from sam_to_bam.py:\n+def check_seq_file( dbkey, cached_seqs_pointer_file ):\n+    seq_path = \'\'\n+    for line in open( cached_seqs_pointer_file ):\n+        line = line.rstrip( \'\\r\\n\' )\n+        if line and not line.startswith( \'#\' ) and line.startswith( \'index\' ):\n+            fields = line.split( \'\\t\' )\n+            if len( fields ) < 3:\n+                continue\n+            if fields[1] == dbkey:\n+                seq_path = fields[2].strip()\n+                break\n+    return seq_path\n+\t\n+def __main__():\n+    #Parse Command Line\n+    parser = optparse.OptionParser()\n+    parser.add_option( \'-1\', \'--input\', dest=\'input\', help=\' file of RNA-Seq read alignments in the SAM format. SAM is a standard short read alignment, that allows aligners to attach custom tags to individual alignments, and Cufflinks requires that the alignments you supply have some of these tags. Please see Input formats for more details.\' )\n+    parser.add_option( \'-s\', \'--inner-dist-std-dev\', dest=\'inner_dist_std_dev\', help=\'The standard deviation for the distribution on inner distances between mate pairs. The default is 20bp.\' )\n+    parser.add_option( \'-I\', \'--max-intron-length\', dest=\'max_intron_len\', help=\'The minimum intron length. Cufflinks will not report transcripts with introns longer than this, and will ignore SAM alignments with REF_SKIP CIGAR operations longer than this. The default is 300,000.\' )\n+    parser.add_option( \'-F\', \'--min-isoform-fraction\', dest=\'min_isoform_fraction\', help=\'After calculating isoform abundance for a gene, Cufflinks filters out transcripts that it believes are very low abundance, because isoforms expressed at extremely low levels often cannot reliably be assembled, and may even be artifacts of incompletely spliced precursors of processed transcripts. This parameter is also used to filter out introns that have far fewer spliced alignments supporting them. The default is 0.05, or 5% of the most abundant isoform (the major isoform) of the gene.\' )\n+    parser.add_option( \'-j\', \'--pre-mrna-fraction\', dest=\'pre_mrna_fraction\', help=\'Some RNA-Seq protocols produce a significant amount of reads that originate from incompletely spliced transcripts, and these reads can confound the assembly of fully spliced mRNAs. Cufflinks uses this parameter to filter out alignments that lie within the intronic intervals implied by the spliced alignments. The minimum depth of coverage in the intronic region covered by the alignment is divided by the number of spliced reads, and if the result is lower than this parameter value, the intronic alignments are ignored. The default is 5%.\' )\n+    parser.add_option( \'-p\', \'--num-threads\', dest=\'num_threads\', help=\'Use this many threads to align reads. The default is 1.\' )\n+    parser.add_option( \'-m\', \'--inner-mean-dist\', dest=\'inner_mean_dist\', help=\'This is the expected (mean) inner distance between mate pairs. \\\n+                                                                                For, example, for paired end runs with fragments selected at 300bp, \\\n+                                                                                where each end is 50bp, you should set -r to be 200. The default is 45bp.\')\n+    parser.add_option( \'-G\', \'--GTF\', dest=\'GTF\', help=\'Tells Cufflinks to use the supplied reference annotation to estimate isoform expression. It will not assemble novel transcripts, and the program will ignore alignments not structurally compatible with any reference transcript.\' )\n+    parser.add_option( \'-g\', \'--GTF-guide\', dest=\'GTFguide\', help=\'use reference transcript annotation to guide assembly\' )\n+    parser.add_option( \'-u\', \''..b'" % int ( options.max_mle_iterations ) )\n+    if options.do_normalization:\n+        cmd += ( " -N" )\n+    if options.do_bias_correction:\n+        cmd += ( " -b %s" % seq_path )\n+    if options.no_effective_length_correction:\n+        cmd += ( " --no-effective-length-correction" )\n+        \n+    # Debugging.\n+    print cmd\n+        \n+    # Add input files.\n+    cmd += " " + options.input\n+    \n+    #\n+    # Run command and handle output.\n+    #\n+    try:\n+        #\n+        # Run command.\n+        #\n+        tmp_name = tempfile.NamedTemporaryFile( dir="." ).name\n+        tmp_stderr = open( tmp_name, \'wb\' )\n+        proc = subprocess.Popen( args=cmd, shell=True, stderr=tmp_stderr.fileno() )\n+        returncode = proc.wait()\n+        tmp_stderr.close()\n+        \n+        # Error checking.\n+        if returncode != 0:\n+            raise Exception, "return code = %i" % returncode\n+        \n+        #\n+        # Handle output.\n+        # \n+        \n+        # Read standard error to get total map/upper quartile mass.\n+        total_map_mass = -1\n+        tmp_stderr = open( tmp_name, \'r\' )\n+        for line in tmp_stderr:\n+            if line.lower().find( "map mass" ) >= 0 or line.lower().find( "upper quartile" ) >= 0:\n+                total_map_mass = float( line.split(":")[1].strip() )\n+                break\n+        tmp_stderr.close()\n+        \n+        #\n+        # If there\'s a global model provided, use model\'s total map mass\n+        # to adjust FPKM + confidence intervals.\n+        #\n+        if options.global_model_file:        \n+            # Global model is simply total map mass from original run.\n+            global_model_file = open( options.global_model_file, \'r\' )\n+            global_model_total_map_mass = float( global_model_file.readline() )\n+            global_model_file.close()\n+        \n+            # Ratio of global model\'s total map mass to original run\'s map mass is\n+            # factor used to adjust FPKM.\n+            fpkm_map_mass_ratio = total_map_mass / global_model_total_map_mass\n+        \n+            # Update FPKM values in transcripts.gtf file.\n+            transcripts_file = open( "transcripts.gtf", \'r\' )\n+            tmp_transcripts = tempfile.NamedTemporaryFile( dir="." ).name\n+            new_transcripts_file = open( tmp_transcripts, \'w\' )\n+            for line in transcripts_file:\n+                fields = line.split( \'\\t\' )\n+                attrs = parse_gff_attributes( fields[8] )\n+                attrs[ "FPKM" ] = str( float( attrs[ "FPKM" ] ) * fpkm_map_mass_ratio )\n+                attrs[ "conf_lo" ] = str( float( attrs[ "conf_lo" ] ) * fpkm_map_mass_ratio )\n+                attrs[ "conf_hi" ] = str( float( attrs[ "conf_hi" ] ) * fpkm_map_mass_ratio )\n+                fields[8] = gff_attributes_to_str( attrs, "GTF" )\n+                new_transcripts_file.write( "%s\\n" % \'\\t\'.join( fields ) )\n+            transcripts_file.close()\n+            new_transcripts_file.close()\n+            shutil.copyfile( tmp_transcripts, "transcripts.gtf" )\n+            \n+        # TODO: update expression files as well.\n+                    \n+        # Set outputs. Transcript and gene expression handled by wrapper directives.\n+        shutil.copyfile( "transcripts.gtf" , options.assembled_isoforms_output_file )\n+        if total_map_mass > -1:\n+            f = open( "global_model.txt", \'w\' )\n+            f.write( "%f\\n" % total_map_mass )\n+            f.close()\n+    except Exception, e:\n+        # Read stderr so that it can be reported:\n+        tmp_stderr = open( tmp_name, \'rb\' )\n+        stderr = \'\'\n+        buffsize = 1048576\n+        try:\n+            while True:\n+                stderr += tmp_stderr.read( buffsize )\n+                if not stderr or len( stderr ) % buffsize != 0:\n+                    break\n+        except OverflowError:\n+            pass\n+        tmp_stderr.close()\n+        \n+        stop_err( \'Error running cufflinks.\\n%s\\n%s\' % ( str( e ), stderr ) )\n+\n+if __name__=="__main__": __main__()\n'
b
diff -r 000000000000 -r b50aacc8ae49 cufflinks_wrapper.xml
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/cufflinks_wrapper.xml Tue Oct 01 12:55:37 2013 -0400
b
b'@@ -0,0 +1,235 @@\n+<tool id="cufflinks" name="Cufflinks" version="0.0.6">\n+    <!-- Wrapper supports Cufflinks versions v1.3.0 and newer -->\n+    <description>transcript assembly and FPKM (RPKM) estimates for RNA-Seq data</description>\n+    <requirements>\n+        <requirement type="package" version="2.1.1">cufflinks</requirement>\n+    </requirements>\n+    <version_command>cufflinks 2>&amp;1 | head -n 1</version_command>\n+    <command interpreter="python">\n+        cufflinks_wrapper.py \n+            --input=$input\n+            --assembled-isoforms-output=$assembled_isoforms\n+            --num-threads="4"\n+            -I $max_intron_len\n+            -F $min_isoform_fraction\n+            -j $pre_mrna_fraction\n+            $effective_length_correction\n+            \n+            ## Include reference annotation?\n+            #if $reference_annotation.use_ref == "Use reference annotation":\n+                -G $reference_annotation.reference_annotation_file\n+            #end if\n+            #if $reference_annotation.use_ref == "Use reference annotation guide":\n+\t\t        -g $reference_annotation.reference_annotation_guide_file\n+            #end if\n+\n+            ## Normalization?\n+            #if str($do_normalization) == "Yes":\n+            -N\n+            #end if\n+            \n+            ## Bias correction?\n+            #if $bias_correction.do_bias_correction == "Yes":\n+\t           -b\n+                #if $bias_correction.seq_source.index_source == "history":\n+                    --ref_file=$bias_correction.seq_source.ref_file\n+                #else:\n+                    --ref_file="None"\n+                #end if\n+                --dbkey=${input.metadata.dbkey} \n+                --index_dir=${GALAXY_DATA_INDEX_DIR}\n+            #end if\n+\n+            ## Multi-read correct?\n+            #if str($multiread_correct) == "Yes":\n+            -u\n+            #end if\n+\n+            ## Include global model if available.\n+            #if $global_model:\n+                --global_model=$global_model\n+            #end if\n+    </command>\n+    <inputs>\n+        <param format="sam,bam" name="input" type="data" label="SAM or BAM file of aligned RNA-Seq reads" help=""/>\n+        <param name="max_intron_len" type="integer" value="300000" min="1" max="600000" label="Max Intron Length" help=""/>\n+        <param name="min_isoform_fraction" type="float" value="0.10" min="0" max="1" label="Min Isoform Fraction" help=""/>\n+        <param name="pre_mrna_fraction" type="float" value="0.15" min="0" max="1" label="Pre MRNA Fraction" help=""/>\n+        <param name="do_normalization" type="select" label="Perform quartile normalization" help="Removes top 25% of genes from FPKM denominator to improve accuracy of differential expression calls for low abundance transcripts.">\n+            <option value="No" selected="true">No</option>\n+            <option value="Yes">Yes</option>\n+        </param>\n+        <conditional name="reference_annotation">\n+            <param name="use_ref" type="select" label="Use Reference Annotation">\n+                <option value="No" selected="true">No</option>\n+                <option value="Use reference annotation">Use reference annotation</option>\n+                <option value="Use reference annotation guide">Use reference annotation as guide</option>\n+            </param>\n+            <when value="No"></when>\n+            <when value="Use reference annotation">\n+                <param format="gff3,gtf" name="reference_annotation_file" type="data" label="Reference Annotation" help="Gene annotation dataset in GTF or GFF3 format."/>\n+            \t</when>\n+\t        <when value="Use reference annotation guide">\n+                <param format="gff3,gtf" name="reference_annotation_guide_file" type="data" label="Reference Annotation" help="Gene annotation dataset in GTF or GFF3 format."/>\n+                </when>\n+        </conditional>\n+        <conditional name="bias_correction">\n+            <param name="do_bias_correction" type="s'..b'       .           Cufflinks does not predict where the start and stop codons (if any) are located within each transcript, so this field is not used.\n+  8               attributes    See below\n+  \n+Each GTF record is decorated with the following attributes::\n+\n+  Attribute       Example       Description\n+  -----------------------------------------\n+  gene_id         CUFF.1        Cufflinks gene id\n+  transcript_id   CUFF.1.1      Cufflinks transcript id\n+  FPKM            101.267       Isoform-level relative abundance in Reads Per Kilobase of exon model per Million mapped reads\n+  frac            0.7647        Reserved. Please ignore, as this attribute may be deprecated in the future\n+  conf_lo         0.07          Lower bound of the 95% confidence interval of the abundance of this isoform, as a fraction of the isoform abundance. That is, lower bound = FPKM * (1.0 - conf_lo)\n+  conf_hi         0.1102        Upper bound of the 95% confidence interval of the abundance of this isoform, as a fraction of the isoform abundance. That is, upper bound = FPKM * (1.0 + conf_lo)\n+  cov             100.765       Estimate for the absolute depth of read coverage across the whole transcript\n+  \n+\n+Transcripts only:\n+  This file is simply a tab delimited file containing one row per transcript and with columns containing the attributes above. There are a few additional attributes not in the table above, but these are reserved for debugging, and may change or disappear in the future.\n+    \n+Genes only:\n+This file contains gene-level coordinates and expression values.\n+    \n+-------\n+\n+**Cufflinks settings**\n+\n+All of the options have a default value. You can change any of them. Most of the options in Cufflinks have been implemented here.\n+\n+------\n+\n+**Cufflinks parameter list**\n+\n+This is a list of implemented Cufflinks options::\n+\n+  -m INT    This is the expected (mean) inner distance between mate pairs. For, example, for paired end runs with fragments selected at 300bp, where each end is 50bp, you should set -r to be 200. The default is 45bp.\n+  -s INT    The standard deviation for the distribution on inner distances between mate pairs. The default is 20bp.\n+  -I INT    The minimum intron length. Cufflinks will not report transcripts with introns longer than this, and will ignore SAM alignments with REF_SKIP CIGAR operations longer than this. The default is 300,000.\n+  -F \t    After calculating isoform abundance for a gene, Cufflinks filters out transcripts that it believes are very low abundance, because isoforms expressed at extremely low levels often cannot reliably be assembled, and may even be artifacts of incompletely spliced precursors of processed transcripts. This parameter is also used to filter out introns that have far fewer spliced alignments supporting them. The default is 0.05, or 5% of the most abundant isoform (the major isoform) of the gene.\n+  -j        Some RNA-Seq protocols produce a significant amount of reads that originate from incompletely spliced transcripts, and these reads can confound the assembly of fully spliced mRNAs. Cufflinks uses this parameter to filter out alignments that lie within the intronic intervals implied by the spliced alignments. The minimum depth of coverage in the intronic region covered by the alignment is divided by the number of spliced reads, and if the result is lower than this parameter value, the intronic alignments are ignored. The default is 5%.\n+  -G\t    Tells Cufflinks to use the supplied reference annotation to estimate isoform expression. It will not assemble novel transcripts, and the program will ignore alignments not structurally compatible with any reference transcript.  \n+  -N        With this option, Cufflinks excludes the contribution of the top 25 percent most highly expressed genes from the number of mapped fragments used in the FPKM denominator. This can improve robustness of differential expression calls for less abundant genes and transcripts.\n+    </help>\n+</tool>\n'
b
diff -r 000000000000 -r b50aacc8ae49 test-data/cufflinks_in.bam
b
Binary file test-data/cufflinks_in.bam has changed
b
diff -r 000000000000 -r b50aacc8ae49 test-data/cufflinks_out1.gtf
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test-data/cufflinks_out1.gtf Tue Oct 01 12:55:37 2013 -0400
b
@@ -0,0 +1,4 @@
+test_chromosome Cufflinks transcript 53 550 1000 + . gene_id "CUFF.1"; transcript_id "CUFF.1.1"; FPKM "10679134.4063403048"; frac "1.000000"; conf_lo "8543307.525072"; conf_hi "12814961.287608"; cov "145.770185";
+test_chromosome Cufflinks exon 53 250 1000 + . gene_id "CUFF.1"; transcript_id "CUFF.1.1"; exon_number "1"; FPKM "10679134.4063403048"; frac "1.000000"; conf_lo "8543307.525072"; conf_hi "12814961.287608"; cov "145.770185";
+test_chromosome Cufflinks exon 351 400 1000 + . gene_id "CUFF.1"; transcript_id "CUFF.1.1"; exon_number "2"; FPKM "10679134.4063403048"; frac "1.000000"; conf_lo "8543307.525072"; conf_hi "12814961.287608"; cov "145.770185";
+test_chromosome Cufflinks exon 501 550 1000 + . gene_id "CUFF.1"; transcript_id "CUFF.1.1"; exon_number "3"; FPKM "10679134.4063403048"; frac "1.000000"; conf_lo "8543307.525072"; conf_hi "12814961.287608"; cov "145.770185";
b
diff -r 000000000000 -r b50aacc8ae49 test-data/cufflinks_out2.fpkm_tracking
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test-data/cufflinks_out2.fpkm_tracking Tue Oct 01 12:55:37 2013 -0400
b
@@ -0,0 +1,2 @@
+tracking_id class_code nearest_ref_id gene_id gene_short_name tss_id locus length coverage FPKM FPKM_conf_lo FPKM_conf_hi FPKM_status
+CUFF.1.1 - - CUFF.1 - - test_chromosome:52-550 298 142.855 1.04656e+07 8.35119e+06 1.25799e+07 OK
b
diff -r 000000000000 -r b50aacc8ae49 test-data/cufflinks_out3.fpkm_tracking
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test-data/cufflinks_out3.fpkm_tracking Tue Oct 01 12:55:37 2013 -0400
b
@@ -0,0 +1,2 @@
+tracking_id class_code nearest_ref_id gene_id gene_short_name tss_id locus length coverage FPKM FPKM_conf_lo FPKM_conf_hi FPKM_status
+CUFF.1 - - CUFF.1 - - test_chromosome:52-550 - - 1.04656e+07 8.35119e+06 1.25799e+07 OK
b
diff -r 000000000000 -r b50aacc8ae49 test-data/cufflinks_out4.txt
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test-data/cufflinks_out4.txt Tue Oct 01 12:55:37 2013 -0400
b
@@ -0,0 +1,1 @@
+100.000000
b
diff -r 000000000000 -r b50aacc8ae49 tool_dependencies.xml
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tool_dependencies.xml Tue Oct 01 12:55:37 2013 -0400
b
@@ -0,0 +1,6 @@
+<?xml version="1.0"?>
+<tool_dependency>
+    <package name="cufflinks" version="2.1.1">
+        <repository changeset_revision="394b13717223" name="package_cufflinks_2_1_1" owner="devteam" toolshed="http://toolshed.g2.bx.psu.edu" />
+    </package>
+</tool_dependency>