comparison cuffmerge_wrapper.py @ 10:b6e3849293b1 draft

Uploaded
author devteam
date Fri, 19 Dec 2014 11:59:06 -0500
parents 5b285b6e4ee3
children 1707a530e598
comparison
equal deleted inserted replaced
9:424d49834830 10:b6e3849293b1
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2
3 # Supports Cuffmerge versions 1.3 and newer.
4 2
5 import optparse, os, shutil, subprocess, sys, tempfile 3 import optparse, os, shutil, subprocess, sys, tempfile
6 4
7 def stop_err( msg ): 5 def stop_err( msg ):
8 sys.stderr.write( '%s\n' % msg ) 6 sys.stderr.write( '%s\n' % msg )
13 parser = optparse.OptionParser() 11 parser = optparse.OptionParser()
14 parser.add_option( '-g', 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.' ) 12 parser.add_option( '-g', 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.' )
15 parser.add_option( '-s', dest='use_seq_data', action="store_true", help='Causes cuffmerge 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.') 13 parser.add_option( '-s', dest='use_seq_data', action="store_true", help='Causes cuffmerge 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.')
16 parser.add_option( '-p', '--num-threads', dest='num_threads', help='Use this many threads to align reads. The default is 1.' ) 14 parser.add_option( '-p', '--num-threads', dest='num_threads', help='Use this many threads to align reads. The default is 1.' )
17 15
18
19 # Wrapper / Galaxy options. 16 # Wrapper / Galaxy options.
20 parser.add_option( '', '--index', dest='index', help='The path of the reference genome' ) 17 parser.add_option( '', '--index', dest='index', help='The path of the reference genome' )
21 parser.add_option( '', '--ref_file', dest='ref_file', help='The reference dataset from the history' ) 18 parser.add_option( '', '--ref_file', dest='ref_file', help='The reference dataset from the history' )
22 19
23 # Outputs. 20 # Outputs.
24 parser.add_option( '', '--merged-transcripts', dest='merged_transcripts' ) 21 parser.add_option( '', '--merged-transcripts', dest='merged_transcripts' )
22 parser.add_option( '--min-isoform-fraction', dest='min_isoform_fraction' )
25 23
26 (options, args) = parser.parse_args() 24 (options, args) = parser.parse_args()
27 25
28 # output version # of tool 26 # output version # of tool
29 try: 27 try:
66 cmd += ( " -p %i " % int ( options.num_threads ) ) 64 cmd += ( " -p %i " % int ( options.num_threads ) )
67 if options.ref_annotation: 65 if options.ref_annotation:
68 cmd += " -g %s " % options.ref_annotation 66 cmd += " -g %s " % options.ref_annotation
69 if options.use_seq_data: 67 if options.use_seq_data:
70 cmd += " -s %s " % seq_path 68 cmd += " -s %s " % seq_path
71 69 if options.min_isoform_fraction:
70 cmd += " --min-isoform-fraction %s " % (options.min_isoform_fraction)
72 # Add input files to a file. 71 # Add input files to a file.
73 inputs_file_name = tempfile.NamedTemporaryFile( dir="." ).name 72 inputs_file_name = tempfile.NamedTemporaryFile( dir="." ).name
74 inputs_file = open( inputs_file_name, 'w' ) 73 inputs_file = open( inputs_file_name, 'w' )
75 for arg in args: 74 for arg in args:
76 inputs_file.write( arg + "\n" ) 75 inputs_file.write( arg + "\n" )