annotate cufflinks_wrapper.py @ 2:a6f581469476 draft

planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/cufflinks/cufflinks commit eb18f691975ef9539b5ebd4f118343c8ad967a1f
author devteam
date Tue, 07 Feb 2017 18:38:16 -0500
parents b9d29fdd1190
children 3afd198a1cf0
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
1fffcfe2fb35 Uploaded
devteam
parents:
diff changeset
1 #!/usr/bin/env python
1fffcfe2fb35 Uploaded
devteam
parents:
diff changeset
2
1
b9d29fdd1190 planemo upload commit 33927a87ba2eee9bf0ecdd376a66241b17b3d734
devteam
parents: 0
diff changeset
3 import optparse
b9d29fdd1190 planemo upload commit 33927a87ba2eee9bf0ecdd376a66241b17b3d734
devteam
parents: 0
diff changeset
4 import os
b9d29fdd1190 planemo upload commit 33927a87ba2eee9bf0ecdd376a66241b17b3d734
devteam
parents: 0
diff changeset
5 import shutil
b9d29fdd1190 planemo upload commit 33927a87ba2eee9bf0ecdd376a66241b17b3d734
devteam
parents: 0
diff changeset
6 import subprocess
b9d29fdd1190 planemo upload commit 33927a87ba2eee9bf0ecdd376a66241b17b3d734
devteam
parents: 0
diff changeset
7 import sys
b9d29fdd1190 planemo upload commit 33927a87ba2eee9bf0ecdd376a66241b17b3d734
devteam
parents: 0
diff changeset
8 import tempfile
2
a6f581469476 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/cufflinks/cufflinks commit eb18f691975ef9539b5ebd4f118343c8ad967a1f
devteam
parents: 1
diff changeset
9
a6f581469476 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/cufflinks/cufflinks commit eb18f691975ef9539b5ebd4f118343c8ad967a1f
devteam
parents: 1
diff changeset
10 from galaxy.datatypes.util.gff_util import gff_attributes_to_str, parse_gff_attributes
0
1fffcfe2fb35 Uploaded
devteam
parents:
diff changeset
11
1
b9d29fdd1190 planemo upload commit 33927a87ba2eee9bf0ecdd376a66241b17b3d734
devteam
parents: 0
diff changeset
12
2
a6f581469476 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/cufflinks/cufflinks commit eb18f691975ef9539b5ebd4f118343c8ad967a1f
devteam
parents: 1
diff changeset
13 def stop_err(msg):
a6f581469476 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/cufflinks/cufflinks commit eb18f691975ef9539b5ebd4f118343c8ad967a1f
devteam
parents: 1
diff changeset
14 sys.exit("%s\n" % msg)
1
b9d29fdd1190 planemo upload commit 33927a87ba2eee9bf0ecdd376a66241b17b3d734
devteam
parents: 0
diff changeset
15
b9d29fdd1190 planemo upload commit 33927a87ba2eee9bf0ecdd376a66241b17b3d734
devteam
parents: 0
diff changeset
16
0
1fffcfe2fb35 Uploaded
devteam
parents:
diff changeset
17 def __main__():
1fffcfe2fb35 Uploaded
devteam
parents:
diff changeset
18 parser = optparse.OptionParser()
2
a6f581469476 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/cufflinks/cufflinks commit eb18f691975ef9539b5ebd4f118343c8ad967a1f
devteam
parents: 1
diff changeset
19 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.')
a6f581469476 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/cufflinks/cufflinks commit eb18f691975ef9539b5ebd4f118343c8ad967a1f
devteam
parents: 1
diff changeset
20 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.')
a6f581469476 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/cufflinks/cufflinks commit eb18f691975ef9539b5ebd4f118343c8ad967a1f
devteam
parents: 1
diff changeset
21 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.')
a6f581469476 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/cufflinks/cufflinks commit eb18f691975ef9539b5ebd4f118343c8ad967a1f
devteam
parents: 1
diff changeset
22 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%.')
a6f581469476 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/cufflinks/cufflinks commit eb18f691975ef9539b5ebd4f118343c8ad967a1f
devteam
parents: 1
diff changeset
23 parser.add_option('-p', '--num-threads', dest='num_threads', help='Use this many threads to align reads. The default is 1.')
a6f581469476 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/cufflinks/cufflinks commit eb18f691975ef9539b5ebd4f118343c8ad967a1f
devteam
parents: 1
diff changeset
24 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.')
1
b9d29fdd1190 planemo upload commit 33927a87ba2eee9bf0ecdd376a66241b17b3d734
devteam
parents: 0
diff changeset
25 parser.add_option("--compatible-hits-norm", dest='compatible_hits_norm', action="store_true", help='Count hits compatible with reference RNAs only')
2
a6f581469476 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/cufflinks/cufflinks commit eb18f691975ef9539b5ebd4f118343c8ad967a1f
devteam
parents: 1
diff changeset
26 parser.add_option('-g', '--GTF-guide', dest='GTFguide', help='use reference transcript annotation to guide assembly')
1
b9d29fdd1190 planemo upload commit 33927a87ba2eee9bf0ecdd376a66241b17b3d734
devteam
parents: 0
diff changeset
27 parser.add_option("--3-overhang-tolerance", dest='three_overhang_tolerance', help='The number of bp allowed to overhang the 3prime end of a reference transcript when determining if an assembled transcript should be merged with it (ie, the assembled transcript is not novel). The default is 600 bp.')
b9d29fdd1190 planemo upload commit 33927a87ba2eee9bf0ecdd376a66241b17b3d734
devteam
parents: 0
diff changeset
28 parser.add_option("--intron-overhang-tolerance", dest='intron_overhang_tolerance', help='The number of bp allowed to enter the intron of a reference transcript when determining if an assembled transcript should be merged with it (ie, the assembled transcript is not novel). The default is 50 bp.')
b9d29fdd1190 planemo upload commit 33927a87ba2eee9bf0ecdd376a66241b17b3d734
devteam
parents: 0
diff changeset
29 parser.add_option("--no-faux-reads", dest='no_faux_reads', help='This option disables tiling of the reference transcripts with faux reads. Use this if you only want to use sequencing reads in assembly but do not want to output assembled transcripts that lay within reference transcripts. All reference transcripts in the input annotation will also be included in the output.')
2
a6f581469476 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/cufflinks/cufflinks commit eb18f691975ef9539b5ebd4f118343c8ad967a1f
devteam
parents: 1
diff changeset
30 parser.add_option('-u', '--multi-read-correct', dest='multi_read_correct', action="store_true", help='Tells Cufflinks to do an initial estimation procedure to more accurately weight reads mapping to multiple locations in the genome')
1
b9d29fdd1190 planemo upload commit 33927a87ba2eee9bf0ecdd376a66241b17b3d734
devteam
parents: 0
diff changeset
31
0
1fffcfe2fb35 Uploaded
devteam
parents:
diff changeset
32 # Normalization options.
2
a6f581469476 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/cufflinks/cufflinks commit eb18f691975ef9539b5ebd4f118343c8ad967a1f
devteam
parents: 1
diff changeset
33 parser.add_option("--no-effective-length-correction", dest="no_effective_length_correction", action="store_true")
a6f581469476 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/cufflinks/cufflinks commit eb18f691975ef9539b5ebd4f118343c8ad967a1f
devteam
parents: 1
diff changeset
34 parser.add_option("--no-length-correction", dest="no_length_correction", action="store_true")
0
1fffcfe2fb35 Uploaded
devteam
parents:
diff changeset
35
1fffcfe2fb35 Uploaded
devteam
parents:
diff changeset
36 # Wrapper / Galaxy options.
2
a6f581469476 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/cufflinks/cufflinks commit eb18f691975ef9539b5ebd4f118343c8ad967a1f
devteam
parents: 1
diff changeset
37 parser.add_option('-A', '--assembled-isoforms-output', dest='assembled_isoforms_output_file', help='Assembled isoforms output file; formate is GTF.')
0
1fffcfe2fb35 Uploaded
devteam
parents:
diff changeset
38
1
b9d29fdd1190 planemo upload commit 33927a87ba2eee9bf0ecdd376a66241b17b3d734
devteam
parents: 0
diff changeset
39 # Advanced Options:
2
a6f581469476 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/cufflinks/cufflinks commit eb18f691975ef9539b5ebd4f118343c8ad967a1f
devteam
parents: 1
diff changeset
40 parser.add_option("--library-type", dest="library_type", help=' library prep used for input reads, default fr-unstranded')
a6f581469476 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/cufflinks/cufflinks commit eb18f691975ef9539b5ebd4f118343c8ad967a1f
devteam
parents: 1
diff changeset
41 parser.add_option('-M', '--mask-file', dest='mask_file', help='Tells Cufflinks to ignore all reads that could have come from transcripts in this GTF file. \
0
1fffcfe2fb35 Uploaded
devteam
parents:
diff changeset
42 We recommend including any annotated rRNA, mitochondrial transcripts other abundant transcripts \
1fffcfe2fb35 Uploaded
devteam
parents:
diff changeset
43 you wish to ignore in your analysis in this file. Due to variable efficiency of mRNA enrichment \
1fffcfe2fb35 Uploaded
devteam
parents:
diff changeset
44 methods and rRNA depletion kits, masking these transcripts often improves the overall robustness \
1fffcfe2fb35 Uploaded
devteam
parents:
diff changeset
45 of transcript abundance estimates.')
2
a6f581469476 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/cufflinks/cufflinks commit eb18f691975ef9539b5ebd4f118343c8ad967a1f
devteam
parents: 1
diff changeset
46 parser.add_option('-m', '--inner-mean-dist', dest='inner_mean_dist', help='This is the expected (mean) inner distance between mate pairs. \
0
1fffcfe2fb35 Uploaded
devteam
parents:
diff changeset
47 For, example, for paired end runs with fragments selected at 300bp, \
1
b9d29fdd1190 planemo upload commit 33927a87ba2eee9bf0ecdd376a66241b17b3d734
devteam
parents: 0
diff changeset
48 where each end is 50bp, you should set -r to be 200. The default is 45bp.') # cufflinks: --frag-len-mean
0
1fffcfe2fb35 Uploaded
devteam
parents:
diff changeset
49
2
a6f581469476 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/cufflinks/cufflinks commit eb18f691975ef9539b5ebd4f118343c8ad967a1f
devteam
parents: 1
diff changeset
50 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.') # cufflinks: --frag-len-std-dev
a6f581469476 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/cufflinks/cufflinks commit eb18f691975ef9539b5ebd4f118343c8ad967a1f
devteam
parents: 1
diff changeset
51 parser.add_option('--max-mle-iterations', dest='max_mle_iterations', help='Sets the number of iterations allowed during maximum likelihood estimation of abundances. Default: 5000')
a6f581469476 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/cufflinks/cufflinks commit eb18f691975ef9539b5ebd4f118343c8ad967a1f
devteam
parents: 1
diff changeset
52 parser.add_option('--junc-alpha', dest='junc_alpha', help='Alpha value for the binomial test used during false positive spliced alignment filtration. Default: 0.001')
a6f581469476 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/cufflinks/cufflinks commit eb18f691975ef9539b5ebd4f118343c8ad967a1f
devteam
parents: 1
diff changeset
53 parser.add_option('--small-anchor-fraction', dest='small_anchor_fraction', help='Spliced reads with less than this percent of their length on each side of\
a6f581469476 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/cufflinks/cufflinks commit eb18f691975ef9539b5ebd4f118343c8ad967a1f
devteam
parents: 1
diff changeset
54 the junction are considered suspicious and are candidates for filtering prior to assembly. Default: 0.09.')
a6f581469476 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/cufflinks/cufflinks commit eb18f691975ef9539b5ebd4f118343c8ad967a1f
devteam
parents: 1
diff changeset
55 parser.add_option('--overhang-tolerance', dest='overhang_tolerance', help='The number of bp allowed to enter the intron of a transcript when determining if a \
a6f581469476 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/cufflinks/cufflinks commit eb18f691975ef9539b5ebd4f118343c8ad967a1f
devteam
parents: 1
diff changeset
56 read or another transcript is mappable to/compatible with it. The default is 8 bp based on the default bowtie/TopHat parameters.')
a6f581469476 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/cufflinks/cufflinks commit eb18f691975ef9539b5ebd4f118343c8ad967a1f
devteam
parents: 1
diff changeset
57 parser.add_option('--max-bundle-length', dest='max_bundle_length', help='Maximum genomic length of a given bundle" help="Default: 3,500,000bp')
a6f581469476 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/cufflinks/cufflinks commit eb18f691975ef9539b5ebd4f118343c8ad967a1f
devteam
parents: 1
diff changeset
58 parser.add_option('--max-bundle-frags', dest='max_bundle_frags', help='Sets the maximum number of fragments a locus may have before being skipped. Skipped loci are listed in skipped.gtf. Default: 1,000,000')
a6f581469476 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/cufflinks/cufflinks commit eb18f691975ef9539b5ebd4f118343c8ad967a1f
devteam
parents: 1
diff changeset
59 parser.add_option('--min-intron-length', dest='min_intron_length', help='Minimal allowed intron size. Default: 50')
a6f581469476 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/cufflinks/cufflinks commit eb18f691975ef9539b5ebd4f118343c8ad967a1f
devteam
parents: 1
diff changeset
60 parser.add_option('--trim-3-avgcov-thresh', dest='trim_three_avgcov_thresh', help='Minimum average coverage required to attempt 3prime trimming. Default: 10')
a6f581469476 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/cufflinks/cufflinks commit eb18f691975ef9539b5ebd4f118343c8ad967a1f
devteam
parents: 1
diff changeset
61 parser.add_option('--trim-3-dropoff-frac', dest='trim_three_dropoff_frac', help='The fraction of average coverage below which to trim the 3prime end of an assembled transcript. Default: 0.1')
0
1fffcfe2fb35 Uploaded
devteam
parents:
diff changeset
62
1fffcfe2fb35 Uploaded
devteam
parents:
diff changeset
63 # Bias correction options.
2
a6f581469476 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/cufflinks/cufflinks commit eb18f691975ef9539b5ebd4f118343c8ad967a1f
devteam
parents: 1
diff changeset
64 parser.add_option('-b', dest='do_bias_correction', action="store_true", help='Providing Cufflinks with a multifasta file via this option instructs it to run our new bias detection and correction algorithm which can significantly improve accuracy of transcript abundance estimates.')
a6f581469476 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/cufflinks/cufflinks commit eb18f691975ef9539b5ebd4f118343c8ad967a1f
devteam
parents: 1
diff changeset
65 parser.add_option('', '--index', dest='index', help='The path of the reference genome')
a6f581469476 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/cufflinks/cufflinks commit eb18f691975ef9539b5ebd4f118343c8ad967a1f
devteam
parents: 1
diff changeset
66 parser.add_option('', '--ref_file', dest='ref_file', help='The reference dataset from the history')
1
b9d29fdd1190 planemo upload commit 33927a87ba2eee9bf0ecdd376a66241b17b3d734
devteam
parents: 0
diff changeset
67
0
1fffcfe2fb35 Uploaded
devteam
parents:
diff changeset
68 # Global model (for trackster).
2
a6f581469476 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/cufflinks/cufflinks commit eb18f691975ef9539b5ebd4f118343c8ad967a1f
devteam
parents: 1
diff changeset
69 parser.add_option('', '--global_model', dest='global_model_file', help='Global model used for computing on local data')
1
b9d29fdd1190 planemo upload commit 33927a87ba2eee9bf0ecdd376a66241b17b3d734
devteam
parents: 0
diff changeset
70
0
1fffcfe2fb35 Uploaded
devteam
parents:
diff changeset
71 (options, args) = parser.parse_args()
1
b9d29fdd1190 planemo upload commit 33927a87ba2eee9bf0ecdd376a66241b17b3d734
devteam
parents: 0
diff changeset
72
0
1fffcfe2fb35 Uploaded
devteam
parents:
diff changeset
73 # output version # of tool
1fffcfe2fb35 Uploaded
devteam
parents:
diff changeset
74 try:
2
a6f581469476 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/cufflinks/cufflinks commit eb18f691975ef9539b5ebd4f118343c8ad967a1f
devteam
parents: 1
diff changeset
75 with tempfile.NamedTemporaryFile() as tmp_stdout:
a6f581469476 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/cufflinks/cufflinks commit eb18f691975ef9539b5ebd4f118343c8ad967a1f
devteam
parents: 1
diff changeset
76 returncode = subprocess.call(args='cufflinks --no-update-check 2>&1', stdout=tmp_stdout, shell=True)
a6f581469476 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/cufflinks/cufflinks commit eb18f691975ef9539b5ebd4f118343c8ad967a1f
devteam
parents: 1
diff changeset
77 stdout = None
a6f581469476 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/cufflinks/cufflinks commit eb18f691975ef9539b5ebd4f118343c8ad967a1f
devteam
parents: 1
diff changeset
78 with open(tmp_stdout.name) as tmp_stdout2:
a6f581469476 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/cufflinks/cufflinks commit eb18f691975ef9539b5ebd4f118343c8ad967a1f
devteam
parents: 1
diff changeset
79 for line in tmp_stdout2:
a6f581469476 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/cufflinks/cufflinks commit eb18f691975ef9539b5ebd4f118343c8ad967a1f
devteam
parents: 1
diff changeset
80 if line.lower().find('cufflinks v') >= 0:
a6f581469476 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/cufflinks/cufflinks commit eb18f691975ef9539b5ebd4f118343c8ad967a1f
devteam
parents: 1
diff changeset
81 stdout = line.strip()
a6f581469476 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/cufflinks/cufflinks commit eb18f691975ef9539b5ebd4f118343c8ad967a1f
devteam
parents: 1
diff changeset
82 break
0
1fffcfe2fb35 Uploaded
devteam
parents:
diff changeset
83 if stdout:
2
a6f581469476 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/cufflinks/cufflinks commit eb18f691975ef9539b5ebd4f118343c8ad967a1f
devteam
parents: 1
diff changeset
84 sys.stdout.write('%s\n' % stdout)
0
1fffcfe2fb35 Uploaded
devteam
parents:
diff changeset
85 else:
1fffcfe2fb35 Uploaded
devteam
parents:
diff changeset
86 raise Exception
1fffcfe2fb35 Uploaded
devteam
parents:
diff changeset
87 except:
2
a6f581469476 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/cufflinks/cufflinks commit eb18f691975ef9539b5ebd4f118343c8ad967a1f
devteam
parents: 1
diff changeset
88 sys.stdout.write('Could not determine Cufflinks version\n')
1
b9d29fdd1190 planemo upload commit 33927a87ba2eee9bf0ecdd376a66241b17b3d734
devteam
parents: 0
diff changeset
89
0
1fffcfe2fb35 Uploaded
devteam
parents:
diff changeset
90 # If doing bias correction, set/link to sequence file.
1fffcfe2fb35 Uploaded
devteam
parents:
diff changeset
91 if options.do_bias_correction:
1fffcfe2fb35 Uploaded
devteam
parents:
diff changeset
92 if options.ref_file:
1fffcfe2fb35 Uploaded
devteam
parents:
diff changeset
93 # Sequence data from history.
1fffcfe2fb35 Uploaded
devteam
parents:
diff changeset
94 # Create symbolic link to ref_file so that index will be created in working directory.
1fffcfe2fb35 Uploaded
devteam
parents:
diff changeset
95 seq_path = "ref.fa"
2
a6f581469476 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/cufflinks/cufflinks commit eb18f691975ef9539b5ebd4f118343c8ad967a1f
devteam
parents: 1
diff changeset
96 os.symlink(options.ref_file, seq_path)
0
1fffcfe2fb35 Uploaded
devteam
parents:
diff changeset
97 else:
2
a6f581469476 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/cufflinks/cufflinks commit eb18f691975ef9539b5ebd4f118343c8ad967a1f
devteam
parents: 1
diff changeset
98 if not os.path.exists(options.index):
a6f581469476 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/cufflinks/cufflinks commit eb18f691975ef9539b5ebd4f118343c8ad967a1f
devteam
parents: 1
diff changeset
99 stop_err('Reference genome %s not present, request it by reporting this error.' % options.index)
0
1fffcfe2fb35 Uploaded
devteam
parents:
diff changeset
100 seq_path = options.index
1fffcfe2fb35 Uploaded
devteam
parents:
diff changeset
101
1fffcfe2fb35 Uploaded
devteam
parents:
diff changeset
102 # Build command.
1
b9d29fdd1190 planemo upload commit 33927a87ba2eee9bf0ecdd376a66241b17b3d734
devteam
parents: 0
diff changeset
103
0
1fffcfe2fb35 Uploaded
devteam
parents:
diff changeset
104 # Base; always use quiet mode to avoid problems with storing log output.
1fffcfe2fb35 Uploaded
devteam
parents:
diff changeset
105 cmd = "cufflinks -q --no-update-check"
1
b9d29fdd1190 planemo upload commit 33927a87ba2eee9bf0ecdd376a66241b17b3d734
devteam
parents: 0
diff changeset
106
0
1fffcfe2fb35 Uploaded
devteam
parents:
diff changeset
107 # Add options.
1fffcfe2fb35 Uploaded
devteam
parents:
diff changeset
108 if options.max_intron_len:
2
a6f581469476 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/cufflinks/cufflinks commit eb18f691975ef9539b5ebd4f118343c8ad967a1f
devteam
parents: 1
diff changeset
109 cmd += (" -I %i" % int(options.max_intron_len))
0
1fffcfe2fb35 Uploaded
devteam
parents:
diff changeset
110 if options.min_isoform_fraction:
2
a6f581469476 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/cufflinks/cufflinks commit eb18f691975ef9539b5ebd4f118343c8ad967a1f
devteam
parents: 1
diff changeset
111 cmd += (" -F %f" % float(options.min_isoform_fraction))
0
1fffcfe2fb35 Uploaded
devteam
parents:
diff changeset
112 if options.pre_mrna_fraction:
2
a6f581469476 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/cufflinks/cufflinks commit eb18f691975ef9539b5ebd4f118343c8ad967a1f
devteam
parents: 1
diff changeset
113 cmd += (" -j %f" % float(options.pre_mrna_fraction))
0
1fffcfe2fb35 Uploaded
devteam
parents:
diff changeset
114 if options.num_threads:
2
a6f581469476 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/cufflinks/cufflinks commit eb18f691975ef9539b5ebd4f118343c8ad967a1f
devteam
parents: 1
diff changeset
115 cmd += (" -p %i" % int(options.num_threads))
0
1fffcfe2fb35 Uploaded
devteam
parents:
diff changeset
116 if options.GTF:
2
a6f581469476 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/cufflinks/cufflinks commit eb18f691975ef9539b5ebd4f118343c8ad967a1f
devteam
parents: 1
diff changeset
117 cmd += (" -G %s" % options.GTF)
0
1fffcfe2fb35 Uploaded
devteam
parents:
diff changeset
118 if options.compatible_hits_norm:
2
a6f581469476 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/cufflinks/cufflinks commit eb18f691975ef9539b5ebd4f118343c8ad967a1f
devteam
parents: 1
diff changeset
119 cmd += (" --compatible-hits-norm")
0
1fffcfe2fb35 Uploaded
devteam
parents:
diff changeset
120 if options.GTFguide:
2
a6f581469476 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/cufflinks/cufflinks commit eb18f691975ef9539b5ebd4f118343c8ad967a1f
devteam
parents: 1
diff changeset
121 cmd += (" -g %s" % options.GTFguide)
a6f581469476 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/cufflinks/cufflinks commit eb18f691975ef9539b5ebd4f118343c8ad967a1f
devteam
parents: 1
diff changeset
122 cmd += (" --3-overhang-tolerance %i" % int(options.three_overhang_tolerance))
a6f581469476 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/cufflinks/cufflinks commit eb18f691975ef9539b5ebd4f118343c8ad967a1f
devteam
parents: 1
diff changeset
123 cmd += (" --intron-overhang-tolerance %i" % int(options.intron_overhang_tolerance))
0
1fffcfe2fb35 Uploaded
devteam
parents:
diff changeset
124 if options.no_faux_reads:
2
a6f581469476 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/cufflinks/cufflinks commit eb18f691975ef9539b5ebd4f118343c8ad967a1f
devteam
parents: 1
diff changeset
125 cmd += (" --no-faux-reads")
0
1fffcfe2fb35 Uploaded
devteam
parents:
diff changeset
126 if options.multi_read_correct:
2
a6f581469476 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/cufflinks/cufflinks commit eb18f691975ef9539b5ebd4f118343c8ad967a1f
devteam
parents: 1
diff changeset
127 cmd += (" -u")
0
1fffcfe2fb35 Uploaded
devteam
parents:
diff changeset
128
1fffcfe2fb35 Uploaded
devteam
parents:
diff changeset
129 if options.library_type and options.library_type != 'auto':
2
a6f581469476 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/cufflinks/cufflinks commit eb18f691975ef9539b5ebd4f118343c8ad967a1f
devteam
parents: 1
diff changeset
130 cmd += (" --library-type %s" % options.library_type)
0
1fffcfe2fb35 Uploaded
devteam
parents:
diff changeset
131 if options.mask_file:
2
a6f581469476 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/cufflinks/cufflinks commit eb18f691975ef9539b5ebd4f118343c8ad967a1f
devteam
parents: 1
diff changeset
132 cmd += (" --mask-file %s" % options.mask_file)
0
1fffcfe2fb35 Uploaded
devteam
parents:
diff changeset
133 if options.inner_mean_dist:
2
a6f581469476 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/cufflinks/cufflinks commit eb18f691975ef9539b5ebd4f118343c8ad967a1f
devteam
parents: 1
diff changeset
134 cmd += (" -m %i" % int(options.inner_mean_dist))
0
1fffcfe2fb35 Uploaded
devteam
parents:
diff changeset
135 if options.inner_dist_std_dev:
2
a6f581469476 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/cufflinks/cufflinks commit eb18f691975ef9539b5ebd4f118343c8ad967a1f
devteam
parents: 1
diff changeset
136 cmd += (" -s %i" % int(options.inner_dist_std_dev))
0
1fffcfe2fb35 Uploaded
devteam
parents:
diff changeset
137 if options.max_mle_iterations:
2
a6f581469476 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/cufflinks/cufflinks commit eb18f691975ef9539b5ebd4f118343c8ad967a1f
devteam
parents: 1
diff changeset
138 cmd += (" --max-mle-iterations %i" % int(options.max_mle_iterations))
0
1fffcfe2fb35 Uploaded
devteam
parents:
diff changeset
139 if options.junc_alpha:
2
a6f581469476 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/cufflinks/cufflinks commit eb18f691975ef9539b5ebd4f118343c8ad967a1f
devteam
parents: 1
diff changeset
140 cmd += (" --junc-alpha %f" % float(options.junc_alpha))
0
1fffcfe2fb35 Uploaded
devteam
parents:
diff changeset
141 if options.small_anchor_fraction:
2
a6f581469476 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/cufflinks/cufflinks commit eb18f691975ef9539b5ebd4f118343c8ad967a1f
devteam
parents: 1
diff changeset
142 cmd += (" --small-anchor-fraction %f" % float(options.small_anchor_fraction))
0
1fffcfe2fb35 Uploaded
devteam
parents:
diff changeset
143 if options.overhang_tolerance:
2
a6f581469476 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/cufflinks/cufflinks commit eb18f691975ef9539b5ebd4f118343c8ad967a1f
devteam
parents: 1
diff changeset
144 cmd += (" --overhang-tolerance %i" % int(options.overhang_tolerance))
0
1fffcfe2fb35 Uploaded
devteam
parents:
diff changeset
145 if options.max_bundle_length:
2
a6f581469476 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/cufflinks/cufflinks commit eb18f691975ef9539b5ebd4f118343c8ad967a1f
devteam
parents: 1
diff changeset
146 cmd += (" --max-bundle-length %i" % int(options.max_bundle_length))
0
1fffcfe2fb35 Uploaded
devteam
parents:
diff changeset
147 if options.max_bundle_frags:
2
a6f581469476 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/cufflinks/cufflinks commit eb18f691975ef9539b5ebd4f118343c8ad967a1f
devteam
parents: 1
diff changeset
148 cmd += (" --max-bundle-frags %i" % int(options.max_bundle_frags))
0
1fffcfe2fb35 Uploaded
devteam
parents:
diff changeset
149 if options.min_intron_length:
2
a6f581469476 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/cufflinks/cufflinks commit eb18f691975ef9539b5ebd4f118343c8ad967a1f
devteam
parents: 1
diff changeset
150 cmd += (" --min-intron-length %i" % int(options.min_intron_length))
0
1fffcfe2fb35 Uploaded
devteam
parents:
diff changeset
151 if options.trim_three_avgcov_thresh:
2
a6f581469476 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/cufflinks/cufflinks commit eb18f691975ef9539b5ebd4f118343c8ad967a1f
devteam
parents: 1
diff changeset
152 cmd += (" --trim-3-avgcov-thresh %i" % int(options.trim_three_avgcov_thresh))
0
1fffcfe2fb35 Uploaded
devteam
parents:
diff changeset
153 if options.trim_three_dropoff_frac:
2
a6f581469476 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/cufflinks/cufflinks commit eb18f691975ef9539b5ebd4f118343c8ad967a1f
devteam
parents: 1
diff changeset
154 cmd += (" --trim-3-dropoff-frac %f" % float(options.trim_three_dropoff_frac))
0
1fffcfe2fb35 Uploaded
devteam
parents:
diff changeset
155
1fffcfe2fb35 Uploaded
devteam
parents:
diff changeset
156 if options.do_bias_correction:
2
a6f581469476 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/cufflinks/cufflinks commit eb18f691975ef9539b5ebd4f118343c8ad967a1f
devteam
parents: 1
diff changeset
157 cmd += (" -b %s" % seq_path)
0
1fffcfe2fb35 Uploaded
devteam
parents:
diff changeset
158 if options.no_effective_length_correction:
2
a6f581469476 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/cufflinks/cufflinks commit eb18f691975ef9539b5ebd4f118343c8ad967a1f
devteam
parents: 1
diff changeset
159 cmd += (" --no-effective-length-correction")
0
1fffcfe2fb35 Uploaded
devteam
parents:
diff changeset
160 if options.no_length_correction:
2
a6f581469476 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/cufflinks/cufflinks commit eb18f691975ef9539b5ebd4f118343c8ad967a1f
devteam
parents: 1
diff changeset
161 cmd += (" --no-length-correction")
1
b9d29fdd1190 planemo upload commit 33927a87ba2eee9bf0ecdd376a66241b17b3d734
devteam
parents: 0
diff changeset
162
0
1fffcfe2fb35 Uploaded
devteam
parents:
diff changeset
163 # Add input files.
1fffcfe2fb35 Uploaded
devteam
parents:
diff changeset
164 cmd += " " + options.input
1
b9d29fdd1190 planemo upload commit 33927a87ba2eee9bf0ecdd376a66241b17b3d734
devteam
parents: 0
diff changeset
165
0
1fffcfe2fb35 Uploaded
devteam
parents:
diff changeset
166 # Run command and handle output.
1fffcfe2fb35 Uploaded
devteam
parents:
diff changeset
167 try:
1fffcfe2fb35 Uploaded
devteam
parents:
diff changeset
168 # Run command.
2
a6f581469476 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/cufflinks/cufflinks commit eb18f691975ef9539b5ebd4f118343c8ad967a1f
devteam
parents: 1
diff changeset
169 with tempfile.NamedTemporaryFile(dir=".") as tmp_stderr:
a6f581469476 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/cufflinks/cufflinks commit eb18f691975ef9539b5ebd4f118343c8ad967a1f
devteam
parents: 1
diff changeset
170 returncode = subprocess.call(args=cmd, stderr=tmp_stderr, shell=True)
1
b9d29fdd1190 planemo upload commit 33927a87ba2eee9bf0ecdd376a66241b17b3d734
devteam
parents: 0
diff changeset
171
2
a6f581469476 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/cufflinks/cufflinks commit eb18f691975ef9539b5ebd4f118343c8ad967a1f
devteam
parents: 1
diff changeset
172 # Error checking.
a6f581469476 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/cufflinks/cufflinks commit eb18f691975ef9539b5ebd4f118343c8ad967a1f
devteam
parents: 1
diff changeset
173 if returncode != 0:
a6f581469476 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/cufflinks/cufflinks commit eb18f691975ef9539b5ebd4f118343c8ad967a1f
devteam
parents: 1
diff changeset
174 # Get stderr, allowing for case where it's very large.
a6f581469476 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/cufflinks/cufflinks commit eb18f691975ef9539b5ebd4f118343c8ad967a1f
devteam
parents: 1
diff changeset
175 buffsize = 1048576
a6f581469476 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/cufflinks/cufflinks commit eb18f691975ef9539b5ebd4f118343c8ad967a1f
devteam
parents: 1
diff changeset
176 stderr = ''
a6f581469476 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/cufflinks/cufflinks commit eb18f691975ef9539b5ebd4f118343c8ad967a1f
devteam
parents: 1
diff changeset
177 with open(tmp_stderr.name) as tmp_stderr2:
a6f581469476 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/cufflinks/cufflinks commit eb18f691975ef9539b5ebd4f118343c8ad967a1f
devteam
parents: 1
diff changeset
178 try:
a6f581469476 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/cufflinks/cufflinks commit eb18f691975ef9539b5ebd4f118343c8ad967a1f
devteam
parents: 1
diff changeset
179 while True:
a6f581469476 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/cufflinks/cufflinks commit eb18f691975ef9539b5ebd4f118343c8ad967a1f
devteam
parents: 1
diff changeset
180 stderr += tmp_stderr2.read(buffsize)
a6f581469476 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/cufflinks/cufflinks commit eb18f691975ef9539b5ebd4f118343c8ad967a1f
devteam
parents: 1
diff changeset
181 if not stderr or len(stderr) % buffsize != 0:
a6f581469476 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/cufflinks/cufflinks commit eb18f691975ef9539b5ebd4f118343c8ad967a1f
devteam
parents: 1
diff changeset
182 break
a6f581469476 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/cufflinks/cufflinks commit eb18f691975ef9539b5ebd4f118343c8ad967a1f
devteam
parents: 1
diff changeset
183 except OverflowError:
a6f581469476 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/cufflinks/cufflinks commit eb18f691975ef9539b5ebd4f118343c8ad967a1f
devteam
parents: 1
diff changeset
184 pass
a6f581469476 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/cufflinks/cufflinks commit eb18f691975ef9539b5ebd4f118343c8ad967a1f
devteam
parents: 1
diff changeset
185 raise Exception(stderr)
1
b9d29fdd1190 planemo upload commit 33927a87ba2eee9bf0ecdd376a66241b17b3d734
devteam
parents: 0
diff changeset
186
2
a6f581469476 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/cufflinks/cufflinks commit eb18f691975ef9539b5ebd4f118343c8ad967a1f
devteam
parents: 1
diff changeset
187 # Read standard error to get total map/upper quartile mass.
a6f581469476 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/cufflinks/cufflinks commit eb18f691975ef9539b5ebd4f118343c8ad967a1f
devteam
parents: 1
diff changeset
188 total_map_mass = -1
a6f581469476 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/cufflinks/cufflinks commit eb18f691975ef9539b5ebd4f118343c8ad967a1f
devteam
parents: 1
diff changeset
189 with open(tmp_stderr.name, 'r') as tmp_stderr2:
a6f581469476 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/cufflinks/cufflinks commit eb18f691975ef9539b5ebd4f118343c8ad967a1f
devteam
parents: 1
diff changeset
190 for line in tmp_stderr2:
a6f581469476 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/cufflinks/cufflinks commit eb18f691975ef9539b5ebd4f118343c8ad967a1f
devteam
parents: 1
diff changeset
191 if line.lower().find("map mass") >= 0 or line.lower().find("upper quartile") >= 0:
a6f581469476 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/cufflinks/cufflinks commit eb18f691975ef9539b5ebd4f118343c8ad967a1f
devteam
parents: 1
diff changeset
192 total_map_mass = float(line.split(":")[1].strip())
a6f581469476 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/cufflinks/cufflinks commit eb18f691975ef9539b5ebd4f118343c8ad967a1f
devteam
parents: 1
diff changeset
193 break
1
b9d29fdd1190 planemo upload commit 33927a87ba2eee9bf0ecdd376a66241b17b3d734
devteam
parents: 0
diff changeset
194
0
1fffcfe2fb35 Uploaded
devteam
parents:
diff changeset
195 # If there's a global model provided, use model's total map mass
1fffcfe2fb35 Uploaded
devteam
parents:
diff changeset
196 # to adjust FPKM + confidence intervals.
1
b9d29fdd1190 planemo upload commit 33927a87ba2eee9bf0ecdd376a66241b17b3d734
devteam
parents: 0
diff changeset
197 if options.global_model_file:
0
1fffcfe2fb35 Uploaded
devteam
parents:
diff changeset
198 # Global model is simply total map mass from original run.
2
a6f581469476 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/cufflinks/cufflinks commit eb18f691975ef9539b5ebd4f118343c8ad967a1f
devteam
parents: 1
diff changeset
199 with open(options.global_model_file, 'r') as global_model_file:
a6f581469476 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/cufflinks/cufflinks commit eb18f691975ef9539b5ebd4f118343c8ad967a1f
devteam
parents: 1
diff changeset
200 global_model_total_map_mass = float(global_model_file.readline())
1
b9d29fdd1190 planemo upload commit 33927a87ba2eee9bf0ecdd376a66241b17b3d734
devteam
parents: 0
diff changeset
201
0
1fffcfe2fb35 Uploaded
devteam
parents:
diff changeset
202 # Ratio of global model's total map mass to original run's map mass is
1fffcfe2fb35 Uploaded
devteam
parents:
diff changeset
203 # factor used to adjust FPKM.
1fffcfe2fb35 Uploaded
devteam
parents:
diff changeset
204 fpkm_map_mass_ratio = total_map_mass / global_model_total_map_mass
1
b9d29fdd1190 planemo upload commit 33927a87ba2eee9bf0ecdd376a66241b17b3d734
devteam
parents: 0
diff changeset
205
0
1fffcfe2fb35 Uploaded
devteam
parents:
diff changeset
206 # Update FPKM values in transcripts.gtf file.
2
a6f581469476 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/cufflinks/cufflinks commit eb18f691975ef9539b5ebd4f118343c8ad967a1f
devteam
parents: 1
diff changeset
207 with open("transcripts.gtf", 'r') as transcripts_file:
a6f581469476 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/cufflinks/cufflinks commit eb18f691975ef9539b5ebd4f118343c8ad967a1f
devteam
parents: 1
diff changeset
208 with tempfile.NamedTemporaryFile(dir=".", delete=False) as new_transcripts_file:
a6f581469476 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/cufflinks/cufflinks commit eb18f691975ef9539b5ebd4f118343c8ad967a1f
devteam
parents: 1
diff changeset
209 for line in transcripts_file:
a6f581469476 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/cufflinks/cufflinks commit eb18f691975ef9539b5ebd4f118343c8ad967a1f
devteam
parents: 1
diff changeset
210 fields = line.split('\t')
a6f581469476 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/cufflinks/cufflinks commit eb18f691975ef9539b5ebd4f118343c8ad967a1f
devteam
parents: 1
diff changeset
211 attrs = parse_gff_attributes(fields[8])
a6f581469476 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/cufflinks/cufflinks commit eb18f691975ef9539b5ebd4f118343c8ad967a1f
devteam
parents: 1
diff changeset
212 attrs["FPKM"] = str(float(attrs["FPKM"]) * fpkm_map_mass_ratio)
a6f581469476 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/cufflinks/cufflinks commit eb18f691975ef9539b5ebd4f118343c8ad967a1f
devteam
parents: 1
diff changeset
213 attrs["conf_lo"] = str(float(attrs["conf_lo"]) * fpkm_map_mass_ratio)
a6f581469476 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/cufflinks/cufflinks commit eb18f691975ef9539b5ebd4f118343c8ad967a1f
devteam
parents: 1
diff changeset
214 attrs["conf_hi"] = str(float(attrs["conf_hi"]) * fpkm_map_mass_ratio)
a6f581469476 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/cufflinks/cufflinks commit eb18f691975ef9539b5ebd4f118343c8ad967a1f
devteam
parents: 1
diff changeset
215 fields[8] = gff_attributes_to_str(attrs, "GTF")
a6f581469476 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/cufflinks/cufflinks commit eb18f691975ef9539b5ebd4f118343c8ad967a1f
devteam
parents: 1
diff changeset
216 new_transcripts_file.write("%s\n" % '\t'.join(fields))
a6f581469476 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/cufflinks/cufflinks commit eb18f691975ef9539b5ebd4f118343c8ad967a1f
devteam
parents: 1
diff changeset
217 shutil.move(new_transcripts_file.name, "transcripts.gtf")
1
b9d29fdd1190 planemo upload commit 33927a87ba2eee9bf0ecdd376a66241b17b3d734
devteam
parents: 0
diff changeset
218
0
1fffcfe2fb35 Uploaded
devteam
parents:
diff changeset
219 # TODO: update expression files as well.
1
b9d29fdd1190 planemo upload commit 33927a87ba2eee9bf0ecdd376a66241b17b3d734
devteam
parents: 0
diff changeset
220
0
1fffcfe2fb35 Uploaded
devteam
parents:
diff changeset
221 # Set outputs. Transcript and gene expression handled by wrapper directives.
2
a6f581469476 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/cufflinks/cufflinks commit eb18f691975ef9539b5ebd4f118343c8ad967a1f
devteam
parents: 1
diff changeset
222 shutil.move("transcripts.gtf", options.assembled_isoforms_output_file)
0
1fffcfe2fb35 Uploaded
devteam
parents:
diff changeset
223 if total_map_mass > -1:
2
a6f581469476 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/cufflinks/cufflinks commit eb18f691975ef9539b5ebd4f118343c8ad967a1f
devteam
parents: 1
diff changeset
224 with open("global_model.txt", 'w') as f:
a6f581469476 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/cufflinks/cufflinks commit eb18f691975ef9539b5ebd4f118343c8ad967a1f
devteam
parents: 1
diff changeset
225 f.write("%f\n" % total_map_mass)
a6f581469476 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/cufflinks/cufflinks commit eb18f691975ef9539b5ebd4f118343c8ad967a1f
devteam
parents: 1
diff changeset
226 except Exception as e:
a6f581469476 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/cufflinks/cufflinks commit eb18f691975ef9539b5ebd4f118343c8ad967a1f
devteam
parents: 1
diff changeset
227 stop_err('Error running cufflinks: %s' % e)
a6f581469476 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/cufflinks/cufflinks commit eb18f691975ef9539b5ebd4f118343c8ad967a1f
devteam
parents: 1
diff changeset
228
0
1fffcfe2fb35 Uploaded
devteam
parents:
diff changeset
229
1
b9d29fdd1190 planemo upload commit 33927a87ba2eee9bf0ecdd376a66241b17b3d734
devteam
parents: 0
diff changeset
230 if __name__ == "__main__":
b9d29fdd1190 planemo upload commit 33927a87ba2eee9bf0ecdd376a66241b17b3d734
devteam
parents: 0
diff changeset
231 __main__()