annotate cuffcompare_wrapper.py @ 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 d0d26169cc2a
children 5aac9b9d6f2a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
d0d26169cc2a Uploaded
devteam
parents:
diff changeset
1 #!/usr/bin/env python
d0d26169cc2a Uploaded
devteam
parents:
diff changeset
2
d0d26169cc2a Uploaded
devteam
parents:
diff changeset
3 # Supports Cuffcompare versions v1.3.0 and newer.
d0d26169cc2a Uploaded
devteam
parents:
diff changeset
4
2
a5674ddf2ad7 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/cufflinks/cuffcompare commit eb18f691975ef9539b5ebd4f118343c8ad967a1f
devteam
parents: 0
diff changeset
5 import optparse
a5674ddf2ad7 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/cufflinks/cuffcompare commit eb18f691975ef9539b5ebd4f118343c8ad967a1f
devteam
parents: 0
diff changeset
6 import os
a5674ddf2ad7 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/cufflinks/cuffcompare commit eb18f691975ef9539b5ebd4f118343c8ad967a1f
devteam
parents: 0
diff changeset
7 import shutil
a5674ddf2ad7 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/cufflinks/cuffcompare commit eb18f691975ef9539b5ebd4f118343c8ad967a1f
devteam
parents: 0
diff changeset
8 import subprocess
a5674ddf2ad7 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/cufflinks/cuffcompare commit eb18f691975ef9539b5ebd4f118343c8ad967a1f
devteam
parents: 0
diff changeset
9 import sys
a5674ddf2ad7 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/cufflinks/cuffcompare commit eb18f691975ef9539b5ebd4f118343c8ad967a1f
devteam
parents: 0
diff changeset
10 import tempfile
0
d0d26169cc2a Uploaded
devteam
parents:
diff changeset
11
2
a5674ddf2ad7 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/cufflinks/cuffcompare commit eb18f691975ef9539b5ebd4f118343c8ad967a1f
devteam
parents: 0
diff changeset
12
a5674ddf2ad7 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/cufflinks/cuffcompare commit eb18f691975ef9539b5ebd4f118343c8ad967a1f
devteam
parents: 0
diff changeset
13 def stop_err(msg):
a5674ddf2ad7 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/cufflinks/cuffcompare commit eb18f691975ef9539b5ebd4f118343c8ad967a1f
devteam
parents: 0
diff changeset
14 sys.stderr.write('%s\n' % msg)
0
d0d26169cc2a Uploaded
devteam
parents:
diff changeset
15 sys.exit()
d0d26169cc2a Uploaded
devteam
parents:
diff changeset
16
2
a5674ddf2ad7 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/cufflinks/cuffcompare commit eb18f691975ef9539b5ebd4f118343c8ad967a1f
devteam
parents: 0
diff changeset
17
0
d0d26169cc2a Uploaded
devteam
parents:
diff changeset
18 def __main__():
d0d26169cc2a Uploaded
devteam
parents:
diff changeset
19 parser = optparse.OptionParser()
2
a5674ddf2ad7 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/cufflinks/cuffcompare commit eb18f691975ef9539b5ebd4f118343c8ad967a1f
devteam
parents: 0
diff changeset
20 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.')
a5674ddf2ad7 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/cufflinks/cuffcompare commit eb18f691975ef9539b5ebd4f118343c8ad967a1f
devteam
parents: 0
diff changeset
21 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')
a5674ddf2ad7 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/cufflinks/cuffcompare commit eb18f691975ef9539b5ebd4f118343c8ad967a1f
devteam
parents: 0
diff changeset
22 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!)')
0
d0d26169cc2a Uploaded
devteam
parents:
diff changeset
23
2
a5674ddf2ad7 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/cufflinks/cuffcompare commit eb18f691975ef9539b5ebd4f118343c8ad967a1f
devteam
parents: 0
diff changeset
24 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.')
a5674ddf2ad7 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/cufflinks/cuffcompare commit eb18f691975ef9539b5ebd4f118343c8ad967a1f
devteam
parents: 0
diff changeset
25
a5674ddf2ad7 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/cufflinks/cuffcompare commit eb18f691975ef9539b5ebd4f118343c8ad967a1f
devteam
parents: 0
diff changeset
26 parser.add_option('-M', action="store_true", dest='discard_single_exon_all', help='discard (ignore) single-exon transfrags and reference transcript')
a5674ddf2ad7 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/cufflinks/cuffcompare commit eb18f691975ef9539b5ebd4f118343c8ad967a1f
devteam
parents: 0
diff changeset
27 parser.add_option('-N', action="store_true", dest='discard_single_exon_ref', help='discard (ignore) single-exon reference transcripts')
a5674ddf2ad7 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/cufflinks/cuffcompare commit eb18f691975ef9539b5ebd4f118343c8ad967a1f
devteam
parents: 0
diff changeset
28 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')
a5674ddf2ad7 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/cufflinks/cuffcompare commit eb18f691975ef9539b5ebd4f118343c8ad967a1f
devteam
parents: 0
diff changeset
29 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')
a5674ddf2ad7 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/cufflinks/cuffcompare commit eb18f691975ef9539b5ebd4f118343c8ad967a1f
devteam
parents: 0
diff changeset
30 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)')
0
d0d26169cc2a Uploaded
devteam
parents:
diff changeset
31
d0d26169cc2a Uploaded
devteam
parents:
diff changeset
32 # Wrapper / Galaxy options.
2
a5674ddf2ad7 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/cufflinks/cuffcompare commit eb18f691975ef9539b5ebd4f118343c8ad967a1f
devteam
parents: 0
diff changeset
33 parser.add_option('', '--index', dest='index', help='The path of the reference genome')
a5674ddf2ad7 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/cufflinks/cuffcompare commit eb18f691975ef9539b5ebd4f118343c8ad967a1f
devteam
parents: 0
diff changeset
34 parser.add_option('', '--ref_file', dest='ref_file', help='The reference dataset from the history')
a5674ddf2ad7 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/cufflinks/cuffcompare commit eb18f691975ef9539b5ebd4f118343c8ad967a1f
devteam
parents: 0
diff changeset
35
0
d0d26169cc2a Uploaded
devteam
parents:
diff changeset
36 # Outputs.
2
a5674ddf2ad7 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/cufflinks/cuffcompare commit eb18f691975ef9539b5ebd4f118343c8ad967a1f
devteam
parents: 0
diff changeset
37 parser.add_option('', '--combined-transcripts', dest='combined_transcripts')
a5674ddf2ad7 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/cufflinks/cuffcompare commit eb18f691975ef9539b5ebd4f118343c8ad967a1f
devteam
parents: 0
diff changeset
38
0
d0d26169cc2a Uploaded
devteam
parents:
diff changeset
39 (options, args) = parser.parse_args()
2
a5674ddf2ad7 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/cufflinks/cuffcompare commit eb18f691975ef9539b5ebd4f118343c8ad967a1f
devteam
parents: 0
diff changeset
40
0
d0d26169cc2a Uploaded
devteam
parents:
diff changeset
41 # output version # of tool
d0d26169cc2a Uploaded
devteam
parents:
diff changeset
42 try:
2
a5674ddf2ad7 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/cufflinks/cuffcompare commit eb18f691975ef9539b5ebd4f118343c8ad967a1f
devteam
parents: 0
diff changeset
43 with tempfile.NamedTemporaryFile() as tmp_stdout:
a5674ddf2ad7 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/cufflinks/cuffcompare commit eb18f691975ef9539b5ebd4f118343c8ad967a1f
devteam
parents: 0
diff changeset
44 returncode = subprocess.call(args='cuffcompare 2>&1', stdout=tmp_stdout, shell=True)
a5674ddf2ad7 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/cufflinks/cuffcompare commit eb18f691975ef9539b5ebd4f118343c8ad967a1f
devteam
parents: 0
diff changeset
45 stdout = None
a5674ddf2ad7 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/cufflinks/cuffcompare commit eb18f691975ef9539b5ebd4f118343c8ad967a1f
devteam
parents: 0
diff changeset
46 with open(tmp_stdout.name) as tmp_stdout2:
a5674ddf2ad7 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/cufflinks/cuffcompare commit eb18f691975ef9539b5ebd4f118343c8ad967a1f
devteam
parents: 0
diff changeset
47 for line in tmp_stdout2:
a5674ddf2ad7 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/cufflinks/cuffcompare commit eb18f691975ef9539b5ebd4f118343c8ad967a1f
devteam
parents: 0
diff changeset
48 if line.lower().find('cuffcompare v') >= 0:
a5674ddf2ad7 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/cufflinks/cuffcompare commit eb18f691975ef9539b5ebd4f118343c8ad967a1f
devteam
parents: 0
diff changeset
49 stdout = line.strip()
a5674ddf2ad7 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/cufflinks/cuffcompare commit eb18f691975ef9539b5ebd4f118343c8ad967a1f
devteam
parents: 0
diff changeset
50 break
0
d0d26169cc2a Uploaded
devteam
parents:
diff changeset
51 if stdout:
2
a5674ddf2ad7 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/cufflinks/cuffcompare commit eb18f691975ef9539b5ebd4f118343c8ad967a1f
devteam
parents: 0
diff changeset
52 sys.stdout.write('%s\n' % stdout)
0
d0d26169cc2a Uploaded
devteam
parents:
diff changeset
53 else:
d0d26169cc2a Uploaded
devteam
parents:
diff changeset
54 raise Exception
d0d26169cc2a Uploaded
devteam
parents:
diff changeset
55 except:
2
a5674ddf2ad7 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/cufflinks/cuffcompare commit eb18f691975ef9539b5ebd4f118343c8ad967a1f
devteam
parents: 0
diff changeset
56 sys.stdout.write('Could not determine Cuffcompare version\n')
a5674ddf2ad7 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/cufflinks/cuffcompare commit eb18f691975ef9539b5ebd4f118343c8ad967a1f
devteam
parents: 0
diff changeset
57
0
d0d26169cc2a Uploaded
devteam
parents:
diff changeset
58 # Set/link to sequence file.
d0d26169cc2a Uploaded
devteam
parents:
diff changeset
59 if options.use_seq_data:
d0d26169cc2a Uploaded
devteam
parents:
diff changeset
60 if options.ref_file:
d0d26169cc2a Uploaded
devteam
parents:
diff changeset
61 # Sequence data from history.
d0d26169cc2a Uploaded
devteam
parents:
diff changeset
62 # Create symbolic link to ref_file so that index will be created in working directory.
d0d26169cc2a Uploaded
devteam
parents:
diff changeset
63 seq_path = "ref.fa"
2
a5674ddf2ad7 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/cufflinks/cuffcompare commit eb18f691975ef9539b5ebd4f118343c8ad967a1f
devteam
parents: 0
diff changeset
64 os.symlink(options.ref_file, seq_path)
0
d0d26169cc2a Uploaded
devteam
parents:
diff changeset
65 else:
2
a5674ddf2ad7 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/cufflinks/cuffcompare commit eb18f691975ef9539b5ebd4f118343c8ad967a1f
devteam
parents: 0
diff changeset
66 if not os.path.exists(options.index):
a5674ddf2ad7 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/cufflinks/cuffcompare commit eb18f691975ef9539b5ebd4f118343c8ad967a1f
devteam
parents: 0
diff changeset
67 stop_err('Reference genome %s not present, request it by reporting this error.' % options.index)
0
d0d26169cc2a Uploaded
devteam
parents:
diff changeset
68 seq_path = options.index
2
a5674ddf2ad7 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/cufflinks/cuffcompare commit eb18f691975ef9539b5ebd4f118343c8ad967a1f
devteam
parents: 0
diff changeset
69
0
d0d26169cc2a Uploaded
devteam
parents:
diff changeset
70 # Build command.
2
a5674ddf2ad7 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/cufflinks/cuffcompare commit eb18f691975ef9539b5ebd4f118343c8ad967a1f
devteam
parents: 0
diff changeset
71
0
d0d26169cc2a Uploaded
devteam
parents:
diff changeset
72 # Base.
d0d26169cc2a Uploaded
devteam
parents:
diff changeset
73 cmd = "cuffcompare -o cc_output "
2
a5674ddf2ad7 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/cufflinks/cuffcompare commit eb18f691975ef9539b5ebd4f118343c8ad967a1f
devteam
parents: 0
diff changeset
74
0
d0d26169cc2a Uploaded
devteam
parents:
diff changeset
75 # Add options.
d0d26169cc2a Uploaded
devteam
parents:
diff changeset
76 if options.ref_annotation:
d0d26169cc2a Uploaded
devteam
parents:
diff changeset
77 cmd += " -r %s " % options.ref_annotation
d0d26169cc2a Uploaded
devteam
parents:
diff changeset
78 if options.ignore_nonoverlap_reference:
d0d26169cc2a Uploaded
devteam
parents:
diff changeset
79 cmd += " -R "
d0d26169cc2a Uploaded
devteam
parents:
diff changeset
80 if options.ignore_nonoverlap_transfrag:
2
a5674ddf2ad7 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/cufflinks/cuffcompare commit eb18f691975ef9539b5ebd4f118343c8ad967a1f
devteam
parents: 0
diff changeset
81 cmd += " -Q "
0
d0d26169cc2a Uploaded
devteam
parents:
diff changeset
82 if options.use_seq_data:
d0d26169cc2a Uploaded
devteam
parents:
diff changeset
83 cmd += " -s %s " % seq_path
d0d26169cc2a Uploaded
devteam
parents:
diff changeset
84 if options.discard_single_exon_all:
2
a5674ddf2ad7 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/cufflinks/cuffcompare commit eb18f691975ef9539b5ebd4f118343c8ad967a1f
devteam
parents: 0
diff changeset
85 cmd += " -M "
0
d0d26169cc2a Uploaded
devteam
parents:
diff changeset
86 if options.discard_single_exon_ref:
2
a5674ddf2ad7 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/cufflinks/cuffcompare commit eb18f691975ef9539b5ebd4f118343c8ad967a1f
devteam
parents: 0
diff changeset
87 cmd += " -N "
0
d0d26169cc2a Uploaded
devteam
parents:
diff changeset
88 if options.max_dist_exon:
2
a5674ddf2ad7 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/cufflinks/cuffcompare commit eb18f691975ef9539b5ebd4f118343c8ad967a1f
devteam
parents: 0
diff changeset
89 cmd += " -e %i " % int(options.max_dist_exon)
0
d0d26169cc2a Uploaded
devteam
parents:
diff changeset
90 if options.max_dist_group:
2
a5674ddf2ad7 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/cufflinks/cuffcompare commit eb18f691975ef9539b5ebd4f118343c8ad967a1f
devteam
parents: 0
diff changeset
91 cmd += " -d %i " % int(options.max_dist_group)
a5674ddf2ad7 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/cufflinks/cuffcompare commit eb18f691975ef9539b5ebd4f118343c8ad967a1f
devteam
parents: 0
diff changeset
92 if options.discard_redundant_intron_transfrags:
a5674ddf2ad7 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/cufflinks/cuffcompare commit eb18f691975ef9539b5ebd4f118343c8ad967a1f
devteam
parents: 0
diff changeset
93 cmd += " -F "
0
d0d26169cc2a Uploaded
devteam
parents:
diff changeset
94 # Add input files.
2
a5674ddf2ad7 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/cufflinks/cuffcompare commit eb18f691975ef9539b5ebd4f118343c8ad967a1f
devteam
parents: 0
diff changeset
95
a5674ddf2ad7 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/cufflinks/cuffcompare commit eb18f691975ef9539b5ebd4f118343c8ad967a1f
devteam
parents: 0
diff changeset
96 # Need to symlink inputs so that output files are written to the current directory.
a5674ddf2ad7 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/cufflinks/cuffcompare commit eb18f691975ef9539b5ebd4f118343c8ad967a1f
devteam
parents: 0
diff changeset
97 for i, arg in enumerate(args):
a5674ddf2ad7 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/cufflinks/cuffcompare commit eb18f691975ef9539b5ebd4f118343c8ad967a1f
devteam
parents: 0
diff changeset
98 input_file_name = "./input%i" % (i + 1)
a5674ddf2ad7 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/cufflinks/cuffcompare commit eb18f691975ef9539b5ebd4f118343c8ad967a1f
devteam
parents: 0
diff changeset
99 os.symlink(arg, input_file_name)
0
d0d26169cc2a Uploaded
devteam
parents:
diff changeset
100 cmd += "%s " % input_file_name
d0d26169cc2a Uploaded
devteam
parents:
diff changeset
101
d0d26169cc2a Uploaded
devteam
parents:
diff changeset
102 # Run command.
2
a5674ddf2ad7 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/cufflinks/cuffcompare commit eb18f691975ef9539b5ebd4f118343c8ad967a1f
devteam
parents: 0
diff changeset
103 try:
a5674ddf2ad7 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/cufflinks/cuffcompare commit eb18f691975ef9539b5ebd4f118343c8ad967a1f
devteam
parents: 0
diff changeset
104 with tempfile.NamedTemporaryFile(dir=".") as tmp_stderr:
a5674ddf2ad7 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/cufflinks/cuffcompare commit eb18f691975ef9539b5ebd4f118343c8ad967a1f
devteam
parents: 0
diff changeset
105 returncode = subprocess.call(args=cmd, stderr=tmp_stderr, shell=True)
a5674ddf2ad7 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/cufflinks/cuffcompare commit eb18f691975ef9539b5ebd4f118343c8ad967a1f
devteam
parents: 0
diff changeset
106
a5674ddf2ad7 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/cufflinks/cuffcompare commit eb18f691975ef9539b5ebd4f118343c8ad967a1f
devteam
parents: 0
diff changeset
107 # Error checking.
a5674ddf2ad7 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/cufflinks/cuffcompare commit eb18f691975ef9539b5ebd4f118343c8ad967a1f
devteam
parents: 0
diff changeset
108 if returncode != 0:
a5674ddf2ad7 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/cufflinks/cuffcompare commit eb18f691975ef9539b5ebd4f118343c8ad967a1f
devteam
parents: 0
diff changeset
109 # Get stderr, allowing for case where it's very large.
a5674ddf2ad7 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/cufflinks/cuffcompare commit eb18f691975ef9539b5ebd4f118343c8ad967a1f
devteam
parents: 0
diff changeset
110 buffsize = 1048576
a5674ddf2ad7 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/cufflinks/cuffcompare commit eb18f691975ef9539b5ebd4f118343c8ad967a1f
devteam
parents: 0
diff changeset
111 stderr = ''
a5674ddf2ad7 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/cufflinks/cuffcompare commit eb18f691975ef9539b5ebd4f118343c8ad967a1f
devteam
parents: 0
diff changeset
112 with open(tmp_stderr.name) as tmp_stderr2:
a5674ddf2ad7 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/cufflinks/cuffcompare commit eb18f691975ef9539b5ebd4f118343c8ad967a1f
devteam
parents: 0
diff changeset
113 try:
a5674ddf2ad7 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/cufflinks/cuffcompare commit eb18f691975ef9539b5ebd4f118343c8ad967a1f
devteam
parents: 0
diff changeset
114 while True:
a5674ddf2ad7 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/cufflinks/cuffcompare commit eb18f691975ef9539b5ebd4f118343c8ad967a1f
devteam
parents: 0
diff changeset
115 stderr += tmp_stderr2.read(buffsize)
a5674ddf2ad7 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/cufflinks/cuffcompare commit eb18f691975ef9539b5ebd4f118343c8ad967a1f
devteam
parents: 0
diff changeset
116 if not stderr or len(stderr) % buffsize != 0:
a5674ddf2ad7 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/cufflinks/cuffcompare commit eb18f691975ef9539b5ebd4f118343c8ad967a1f
devteam
parents: 0
diff changeset
117 break
a5674ddf2ad7 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/cufflinks/cuffcompare commit eb18f691975ef9539b5ebd4f118343c8ad967a1f
devteam
parents: 0
diff changeset
118 except OverflowError:
a5674ddf2ad7 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/cufflinks/cuffcompare commit eb18f691975ef9539b5ebd4f118343c8ad967a1f
devteam
parents: 0
diff changeset
119 pass
a5674ddf2ad7 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/cufflinks/cuffcompare commit eb18f691975ef9539b5ebd4f118343c8ad967a1f
devteam
parents: 0
diff changeset
120 raise Exception(stderr)
a5674ddf2ad7 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/cufflinks/cuffcompare commit eb18f691975ef9539b5ebd4f118343c8ad967a1f
devteam
parents: 0
diff changeset
121
0
d0d26169cc2a Uploaded
devteam
parents:
diff changeset
122 # Copy outputs.
2
a5674ddf2ad7 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/cufflinks/cuffcompare commit eb18f691975ef9539b5ebd4f118343c8ad967a1f
devteam
parents: 0
diff changeset
123 shutil.move("cc_output.combined.gtf", options.combined_transcripts)
a5674ddf2ad7 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/cufflinks/cuffcompare commit eb18f691975ef9539b5ebd4f118343c8ad967a1f
devteam
parents: 0
diff changeset
124
0
d0d26169cc2a Uploaded
devteam
parents:
diff changeset
125 # check that there are results in the output file
d0d26169cc2a Uploaded
devteam
parents:
diff changeset
126 cc_output_fname = "cc_output.stats"
2
a5674ddf2ad7 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/cufflinks/cuffcompare commit eb18f691975ef9539b5ebd4f118343c8ad967a1f
devteam
parents: 0
diff changeset
127 if len(open(cc_output_fname).read().strip()) == 0:
a5674ddf2ad7 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/cufflinks/cuffcompare commit eb18f691975ef9539b5ebd4f118343c8ad967a1f
devteam
parents: 0
diff changeset
128 raise Exception('The main output file is empty, there may be an error with your input file or settings.')
a5674ddf2ad7 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/cufflinks/cuffcompare commit eb18f691975ef9539b5ebd4f118343c8ad967a1f
devteam
parents: 0
diff changeset
129 except Exception as e:
a5674ddf2ad7 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/cufflinks/cuffcompare commit eb18f691975ef9539b5ebd4f118343c8ad967a1f
devteam
parents: 0
diff changeset
130 stop_err('Error running cuffcompare: %s' % e)
a5674ddf2ad7 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/cufflinks/cuffcompare commit eb18f691975ef9539b5ebd4f118343c8ad967a1f
devteam
parents: 0
diff changeset
131
a5674ddf2ad7 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/cufflinks/cuffcompare commit eb18f691975ef9539b5ebd4f118343c8ad967a1f
devteam
parents: 0
diff changeset
132
a5674ddf2ad7 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/cufflinks/cuffcompare commit eb18f691975ef9539b5ebd4f118343c8ad967a1f
devteam
parents: 0
diff changeset
133 if __name__ == "__main__":
a5674ddf2ad7 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/cufflinks/cuffcompare commit eb18f691975ef9539b5ebd4f118343c8ad967a1f
devteam
parents: 0
diff changeset
134 __main__()