annotate cuffdiff_wrapper.py @ 16:a29a35968ddb default tip

Fix tool_dependencies.xml
author Jim Johnson <jj@umn.edu>
date Fri, 08 Nov 2013 13:37:14 -0600
parents d10befb0867a
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
1 #!/usr/bin/env python
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
2
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
3 # Wrapper supports Cuffdiff versions v1.3.0-v2.0
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
4
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
5 import optparse, os, shutil, subprocess, sys, tempfile
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
6
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
7 def group_callback( option, op_str, value, parser ):
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
8 groups = []
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
9 flist = []
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
10 for arg in parser.rargs:
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
11 arg = arg.strip()
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
12 if arg[0] is "-":
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
13 break
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
14 elif arg[0] is ",":
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
15 groups.append(flist)
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
16 flist = []
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
17 else:
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
18 flist.append(arg)
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
19 groups.append(flist)
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
20
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
21 setattr(parser.values, option.dest, groups)
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
22
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
23 def label_callback( option, op_str, value, parser ):
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
24 labels = []
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
25 for arg in parser.rargs:
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
26 arg = arg.strip()
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
27 if arg[0] is "-":
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
28 break
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
29 else:
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
30 labels.append(arg)
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
31
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
32 setattr(parser.values, option.dest, labels)
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
33
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
34 def stop_err( msg ):
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
35 sys.stderr.write( "%s\n" % msg )
13
4597c429b6fb Return nonzero exit code from cuffdiff_wrapper.py on error
Jim Johnson <jj@umn.edu>
parents: 1
diff changeset
36 sys.exit(1)
1
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
37
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
38 # Copied from sam_to_bam.py:
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
39 def check_seq_file( dbkey, cached_seqs_pointer_file ):
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
40 seq_path = ''
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
41 for line in open( cached_seqs_pointer_file ):
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
42 line = line.rstrip( '\r\n' )
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
43 if line and not line.startswith( '#' ) and line.startswith( 'index' ):
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
44 fields = line.split( '\t' )
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
45 if len( fields ) < 3:
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
46 continue
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
47 if fields[1] == dbkey:
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
48 seq_path = fields[2].strip()
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
49 break
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
50 return seq_path
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
51
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
52 def __main__():
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
53 #Parse Command Line
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
54 parser = optparse.OptionParser()
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
55
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
56 # Cuffdiff options.
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
57 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.' )
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
58 parser.add_option( '-p', '--num-threads', dest='num_threads', help='Use this many threads to align reads. The default is 1.' )
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
59 parser.add_option( '-m', '--inner-mean-dist', dest='inner_mean_dist', help='This is the expected (mean) inner distance between mate pairs. \
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
60 For, example, for paired end runs with fragments selected at 300bp, \
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
61 where each end is 50bp, you should set -r to be 200. The default is 45bp.')
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
62 parser.add_option( '-c', '--min-alignment-count', dest='min_alignment_count', help='The minimum number of alignments in a locus for needed to conduct significance testing on changes in that locus observed between samples. If no testing is performed, changes in the locus are deemed not signficant, and the locus\' observed changes don\'t contribute to correction for multiple testing. The default is 1,000 fragment alignments (up to 2,000 paired reads).' )
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
63 parser.add_option( '--FDR', dest='FDR', help='The allowed false discovery rate. The default is 0.05.' )
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
64 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')
14
d10befb0867a Add library_norm_method and dispersion_method params to cuffdiff tool.
Jim Johnson <jj@umn.edu>
parents: 13
diff changeset
65 parser.add_option( '--library-norm-method', dest='library_norm_method' )
d10befb0867a Add library_norm_method and dispersion_method params to cuffdiff tool.
Jim Johnson <jj@umn.edu>
parents: 13
diff changeset
66 parser.add_option( '--dispersion-method', dest='dispersion_method' )
1
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
67
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
68 # Advanced Options:
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
69 parser.add_option( '--num-importance-samples', dest='num_importance_samples', help='Sets the number of importance samples generated for each locus during abundance estimation. Default: 1000' )
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
70 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' )
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
71
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
72 # Wrapper / Galaxy options.
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
73 parser.add_option( '-f', '--files', dest='groups', action="callback", callback=group_callback, help="Groups to be processed, groups are separated by spaces, replicates in a group comma separated. group1_rep1,group1_rep2 group2_rep1,group2_rep2, ..., groupN_rep1, groupN_rep2" )
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
74 parser.add_option( '-A', '--inputA', dest='inputA', help='A transcript GTF file produced by cufflinks, cuffcompare, or other source.')
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
75 parser.add_option( '-1', '--input1', dest='input1', 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.' )
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
76 parser.add_option( '-2', '--input2', dest='input2', 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.' )
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
77
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
78 # Label options
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
79 parser.add_option('-L', '--labels', dest='labels', action="callback", callback=label_callback, help="Labels for the groups the replicates are in.")
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
80
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
81 # Normalization options.
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
82 parser.add_option( "-N", "--quartile-normalization", dest="do_normalization", action="store_true" )
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
83
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
84 # Bias correction options.
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
85 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.')
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
86 parser.add_option( '', '--dbkey', dest='dbkey', help='The build of the reference dataset' )
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
87 parser.add_option( '', '--index_dir', dest='index_dir', help='GALAXY_DATA_INDEX_DIR' )
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
88 parser.add_option( '', '--ref_file', dest='ref_file', help='The reference dataset from the history' )
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
89
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
90 # Outputs.
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
91 parser.add_option( "--isoforms_fpkm_tracking_output", dest="isoforms_fpkm_tracking_output" )
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
92 parser.add_option( "--genes_fpkm_tracking_output", dest="genes_fpkm_tracking_output" )
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
93 parser.add_option( "--cds_fpkm_tracking_output", dest="cds_fpkm_tracking_output" )
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
94 parser.add_option( "--tss_groups_fpkm_tracking_output", dest="tss_groups_fpkm_tracking_output" )
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
95 parser.add_option( "--isoforms_read_group_tracking_output", dest="isoforms_read_group_tracking_output", default=None)
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
96 parser.add_option( "--genes_read_group_tracking_output", dest="genes_read_group_tracking_output", default=None )
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
97 parser.add_option( "--cds_read_group_tracking_output", dest="cds_read_group_tracking_output", default=None )
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
98 parser.add_option( "--tss_groups_read_group_tracking_output", dest="tss_groups_read_group_tracking_output", default=None )
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
99 parser.add_option( "--isoforms_exp_output", dest="isoforms_exp_output" )
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
100 parser.add_option( "--genes_exp_output", dest="genes_exp_output" )
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
101 parser.add_option( "--tss_groups_exp_output", dest="tss_groups_exp_output" )
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
102 parser.add_option( "--cds_exp_fpkm_tracking_output", dest="cds_exp_fpkm_tracking_output" )
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
103 parser.add_option( "--cds_diff_output", dest="cds_diff_output" )
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
104 parser.add_option( "--isoforms_count_tracking_output", dest="isoforms_count_tracking_output" )
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
105 parser.add_option( "--genes_count_tracking_output", dest="genes_count_tracking_output" )
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
106 parser.add_option( "--cds_count_tracking_output", dest="cds_count_tracking_output" )
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
107 parser.add_option( "--tss_groups_count_tracking_output", dest="tss_groups_count_tracking_output" )
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
108 parser.add_option( "--splicing_diff_output", dest="splicing_diff_output" )
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
109 parser.add_option( "--promoters_diff_output", dest="promoters_diff_output" )
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
110 parser.add_option( "--run_info_output", dest="run_info_output" )
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
111 parser.add_option( "--read_groups_info_output", dest="read_groups_info_output" )
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
112 parser.add_option( "--cuffdatadir", dest="cuffdatadir", default=None)
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
113 parser.add_option( "--cummeRbund_db_output", dest="cummeRbund_db_output", default=None)
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
114
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
115 (options, args) = parser.parse_args()
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
116
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
117 # output version # of tool
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
118 try:
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
119 tmp = tempfile.NamedTemporaryFile().name
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
120 tmp_stdout = open( tmp, 'wb' )
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
121 proc = subprocess.Popen( args='cuffdiff --no-update-check 2>&1', shell=True, stdout=tmp_stdout )
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
122 tmp_stdout.close()
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
123 returncode = proc.wait()
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
124 stdout = None
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
125 for line in open( tmp_stdout.name, 'rb' ):
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
126 if line.lower().find( 'cuffdiff v' ) >= 0:
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
127 stdout = line.strip()
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
128 break
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
129 if stdout:
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
130 sys.stdout.write( '%s\n' % stdout )
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
131 else:
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
132 raise Exception
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
133 except:
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
134 sys.stdout.write( 'Could not determine Cuffdiff version\n' )
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
135
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
136 # Make temp directory for output.
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
137 tmp_output_dir = tempfile.mkdtemp()
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
138 cuffdatadir = options.cuffdatadir if options.cuffdatadir else tmp_output_dir
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
139 if not os.path.exists( cuffdatadir ):
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
140 os.makedirs( cuffdatadir )
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
141
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
142 # If doing bias correction, set/link to sequence file.
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
143 if options.do_bias_correction:
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
144 if options.ref_file != 'None':
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
145 # Sequence data from history.
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
146 # Create symbolic link to ref_file so that index will be created in working directory.
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
147 seq_path = os.path.join( cuffdatadir, "ref.fa" )
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
148 os.symlink( options.ref_file, seq_path )
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
149 else:
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
150 # Sequence data from loc file.
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
151 cached_seqs_pointer_file = os.path.join( options.index_dir, 'sam_fa_indices.loc' )
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
152 if not os.path.exists( cached_seqs_pointer_file ):
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
153 stop_err( 'The required file (%s) does not exist.' % cached_seqs_pointer_file )
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
154 # If found for the dbkey, seq_path will look something like /galaxy/data/equCab2/sam_index/equCab2.fa,
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
155 # and the equCab2.fa file will contain fasta sequences.
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
156 seq_path = check_seq_file( options.dbkey, cached_seqs_pointer_file )
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
157 if seq_path == '':
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
158 stop_err( 'No sequence data found for dbkey %s, so bias correction cannot be used.' % options.dbkey )
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
159
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
160 # Build command.
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
161
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
162 # Base; always use quiet mode to avoid problems with storing log output.
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
163 cmd = "cuffdiff --no-update-check -q"
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
164
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
165 # Add options.
14
d10befb0867a Add library_norm_method and dispersion_method params to cuffdiff tool.
Jim Johnson <jj@umn.edu>
parents: 13
diff changeset
166 if options.library_norm_method:
d10befb0867a Add library_norm_method and dispersion_method params to cuffdiff tool.
Jim Johnson <jj@umn.edu>
parents: 13
diff changeset
167 cmd += ( " --library-norm-method %s" % options.library_norm_method )
d10befb0867a Add library_norm_method and dispersion_method params to cuffdiff tool.
Jim Johnson <jj@umn.edu>
parents: 13
diff changeset
168 if options.dispersion_method:
d10befb0867a Add library_norm_method and dispersion_method params to cuffdiff tool.
Jim Johnson <jj@umn.edu>
parents: 13
diff changeset
169 cmd += ( " --dispersion-method %s" % options.dispersion_method )
1
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
170 if options.inner_dist_std_dev:
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
171 cmd += ( " -s %i" % int ( options.inner_dist_std_dev ) )
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
172 if options.num_threads:
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
173 cmd += ( " -p %i" % int ( options.num_threads ) )
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
174 if options.inner_mean_dist:
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
175 cmd += ( " -m %i" % int ( options.inner_mean_dist ) )
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
176 if options.min_alignment_count:
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
177 cmd += ( " -c %i" % int ( options.min_alignment_count ) )
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
178 if options.FDR:
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
179 cmd += ( " --FDR %f" % float( options.FDR ) )
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
180 if options.multi_read_correct:
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
181 cmd += ( " -u" )
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
182 if options.num_importance_samples:
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
183 cmd += ( " --num-importance-samples %i" % int ( options.num_importance_samples ) )
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
184 if options.max_mle_iterations:
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
185 cmd += ( " --max-mle-iterations %i" % int ( options.max_mle_iterations ) )
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
186 if options.do_normalization:
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
187 cmd += ( " -N" )
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
188 if options.do_bias_correction:
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
189 cmd += ( " -b %s" % seq_path )
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
190
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
191 # Add inputs.
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
192 # For replicate analysis: group1_rep1,group1_rep2 groupN_rep1,groupN_rep2
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
193 if options.groups:
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
194 cmd += " --labels "
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
195 for label in options.labels:
14
d10befb0867a Add library_norm_method and dispersion_method params to cuffdiff tool.
Jim Johnson <jj@umn.edu>
parents: 13
diff changeset
196 cmd += '"%s",' % label
1
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
197 cmd = cmd[:-1]
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
198
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
199 cmd += " " + options.inputA + " "
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
200
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
201 for group in options.groups:
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
202 for filename in group:
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
203 cmd += filename + ","
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
204 cmd = cmd[:-1] + " "
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
205 else:
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
206 cmd += " " + options.inputA + " " + options.input1 + " " + options.input2
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
207
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
208 # Debugging.
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
209 print cmd
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
210
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
211 # Run command.
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
212 try:
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
213 tmp_name = tempfile.NamedTemporaryFile( dir=tmp_output_dir ).name
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
214 tmp_stderr = open( tmp_name, 'wb' )
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
215 proc = subprocess.Popen( args=cmd, shell=True, cwd=cuffdatadir, stderr=tmp_stderr.fileno() )
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
216 returncode = proc.wait()
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
217 tmp_stderr.close()
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
218
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
219 # Get stderr, allowing for case where it's very large.
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
220 tmp_stderr = open( tmp_name, 'rb' )
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
221 stderr = ''
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
222 buffsize = 1048576
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
223 try:
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
224 while True:
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
225 stderr += tmp_stderr.read( buffsize )
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
226 if not stderr or len( stderr ) % buffsize != 0:
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
227 break
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
228 except OverflowError:
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
229 pass
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
230 tmp_stderr.close()
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
231
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
232 # Error checking.
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
233 if returncode != 0:
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
234 raise Exception, stderr
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
235
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
236 # check that there are results in the output file
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
237 if len( open( os.path.join( cuffdatadir, "isoforms.fpkm_tracking" ), 'rb' ).read().strip() ) == 0:
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
238 raise Exception, 'The main output file is empty, there may be an error with your input file or settings.'
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
239 except Exception, e:
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
240 stop_err( 'Error running cuffdiff. ' + str( e ) )
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
241
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
242
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
243 # Copy output files from tmp directory to specified files.
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
244 try:
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
245 try:
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
246 if options.isoforms_fpkm_tracking_output and os.path.exists(os.path.join( cuffdatadir, "isoforms.fpkm_tracking" )):
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
247 shutil.copyfile( os.path.join( cuffdatadir, "isoforms.fpkm_tracking" ), options.isoforms_fpkm_tracking_output )
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
248 if options.genes_fpkm_tracking_output and os.path.exists(os.path.join( cuffdatadir, "genes.fpkm_tracking" )):
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
249 shutil.copyfile( os.path.join( cuffdatadir, "genes.fpkm_tracking" ), options.genes_fpkm_tracking_output )
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
250 if options.cds_fpkm_tracking_output and os.path.exists(os.path.join( cuffdatadir, "cds.fpkm_tracking" )):
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
251 shutil.copyfile( os.path.join( cuffdatadir, "cds.fpkm_tracking" ), options.cds_fpkm_tracking_output )
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
252 if options.tss_groups_fpkm_tracking_output and os.path.exists(os.path.join( cuffdatadir, "tss_groups.fpkm_tracking" )):
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
253 shutil.copyfile( os.path.join( cuffdatadir, "tss_groups.fpkm_tracking" ), options.tss_groups_fpkm_tracking_output )
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
254
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
255 if options.isoforms_read_group_tracking_output and os.path.exists(os.path.join( cuffdatadir, "isoforms.read_group_tracking" )):
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
256 shutil.copyfile( os.path.join( cuffdatadir, "isoforms.read_group_tracking" ), options.isoforms_read_group_tracking_output )
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
257 if options.genes_read_group_tracking_output and os.path.exists(os.path.join( cuffdatadir, "genes.read_group_tracking" )):
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
258 shutil.copyfile( os.path.join( cuffdatadir, "genes.read_group_tracking" ), options.genes_read_group_tracking_output )
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
259 if options.cds_read_group_tracking_output and os.path.exists(os.path.join( cuffdatadir, "cds.read_group_tracking" )):
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
260 shutil.copyfile( os.path.join( cuffdatadir, "cds.read_group_tracking" ), options.cds_read_group_tracking_output )
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
261 if options.tss_groups_read_group_tracking_output and os.path.exists(os.path.join( cuffdatadir, "tss_groups.read_group_tracking" )):
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
262 shutil.copyfile( os.path.join( cuffdatadir, "tss_groups.read_group_tracking" ), options.tss_groups_read_group_tracking_output )
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
263
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
264 if options.isoforms_exp_output and os.path.exists(os.path.join( cuffdatadir, "isoform_exp.diff" )):
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
265 shutil.copyfile( os.path.join( cuffdatadir, "isoform_exp.diff" ), options.isoforms_exp_output )
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
266 if options.genes_exp_output and os.path.exists(os.path.join( cuffdatadir, "gene_exp.diff" )):
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
267 shutil.copyfile( os.path.join( cuffdatadir, "gene_exp.diff" ), options.genes_exp_output )
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
268 if options.cds_exp_fpkm_tracking_output and os.path.exists(os.path.join( cuffdatadir, "cds_exp.diff" )):
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
269 shutil.copyfile( os.path.join( cuffdatadir, "cds_exp.diff" ), options.cds_exp_fpkm_tracking_output )
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
270 if options.tss_groups_exp_output and os.path.exists(os.path.join( cuffdatadir, "tss_group_exp.diff" )):
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
271 shutil.copyfile( os.path.join( cuffdatadir, "tss_group_exp.diff" ), options.tss_groups_exp_output )
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
272
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
273 if options.isoforms_count_tracking_output and os.path.exists(os.path.join( cuffdatadir, "isoforms.count_tracking" )):
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
274 shutil.copyfile( os.path.join( cuffdatadir, "isoforms.count_tracking" ), options.isoforms_count_tracking_output )
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
275 if options.genes_count_tracking_output and os.path.exists(os.path.join( cuffdatadir, "genes.count_tracking" )):
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
276 shutil.copyfile( os.path.join( cuffdatadir, "genes.count_tracking" ), options.genes_count_tracking_output )
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
277 if options.cds_count_tracking_output and os.path.exists(os.path.join( cuffdatadir, "cds.count_tracking" )):
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
278 shutil.copyfile( os.path.join( cuffdatadir, "cds.count_tracking" ), options.cds_count_tracking_output )
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
279 if options.tss_groups_count_tracking_output and os.path.exists(os.path.join( cuffdatadir, "tss_groups.count_tracking" )):
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
280 shutil.copyfile( os.path.join( cuffdatadir, "tss_groups.count_tracking" ), options.tss_groups_count_tracking_output )
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
281
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
282 if options.cds_diff_output and os.path.exists(os.path.join( cuffdatadir, "cds.diff" )):
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
283 shutil.copyfile( os.path.join( cuffdatadir, "cds.diff" ), options.cds_diff_output )
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
284
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
285 if options.splicing_diff_output and os.path.exists(os.path.join( cuffdatadir, "splicing.diff" )):
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
286 shutil.copyfile( os.path.join( cuffdatadir, "splicing.diff" ), options.splicing_diff_output )
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
287 if options.promoters_diff_output and os.path.exists(os.path.join( cuffdatadir, "promoters.diff" )):
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
288 shutil.copyfile( os.path.join( cuffdatadir, "promoters.diff" ), options.promoters_diff_output )
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
289
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
290 if options.run_info_output and os.path.exists(os.path.join( cuffdatadir, "run.info" )):
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
291 shutil.copyfile( os.path.join( cuffdatadir, "run.info" ), options.run_info_output )
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
292 if options.read_groups_info_output and os.path.exists(os.path.join( cuffdatadir, "read_groups.info" )):
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
293 shutil.copyfile( os.path.join( cuffdatadir, "read_groups.info" ), options.read_groups_info_output )
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
294
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
295 except Exception, e:
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
296 stop_err( 'Error in cuffdiff:\n' + str( e ) )
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
297 if options.cummeRbund_db_output:
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
298 try:
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
299 dbFile = 'cuffData.db'
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
300 rscript = tempfile.NamedTemporaryFile( dir=tmp_output_dir,suffix='.r' ).name
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
301 rscript_fh = open( rscript, 'wb' )
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
302 rscript_fh.write('library(cummeRbund)\n')
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
303 if options.inputA and options.ref_file:
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
304 rscript_fh.write('cuff<-readCufflinks(dir = "%s", dbFile = "%s", gtfFile = "%s", genome = "%s", rebuild = T)\n' % (cuffdatadir,dbFile,options.inputA,options.ref_file))
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
305 else:
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
306 rscript_fh.write('cuff<-readCufflinks(dir = "%s", dbFile = "%s", rebuild = T)\n' % (cuffdatadir,dbFile))
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
307 rscript_fh.close()
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
308 cmd = ( "Rscript --vanilla %s" % rscript )
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
309 tmp_name = tempfile.NamedTemporaryFile( dir=tmp_output_dir ).name
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
310 tmp_stderr = open( tmp_name, 'wb' )
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
311 proc = subprocess.Popen( args=cmd, shell=True, stderr=tmp_stderr.fileno() )
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
312 #proc = subprocess.Popen( args=cmd, shell=True)
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
313 returncode = proc.wait()
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
314 tmp_stderr.close()
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
315 if os.path.exists(os.path.join( cuffdatadir, dbFile )):
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
316 shutil.copyfile( os.path.join( cuffdatadir, dbFile ), options.cummeRbund_db_output )
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
317 shutil.rmtree(os.path.join( cuffdatadir, dbFile ))
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
318 except Exception, e:
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
319 stop_err( 'Error generating cummeRbund cuffData.db:\n' + str( e ) )
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
320 finally:
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
321 # Clean up temp dirs
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
322 if os.path.exists( tmp_output_dir ):
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
323 shutil.rmtree( tmp_output_dir )
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
324
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
325 if __name__=="__main__": __main__()