annotate bwa_long/bwa_wrapper.py @ 0:fb4844b6a98e default tip

Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
author juanperin
date Tue, 07 Jun 2011 17:28:32 -0400
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
1 #!/usr/bin/env python
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
2
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
3 """
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
4 Runs BWA on single-end or paired-end data.
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
5 Produces a SAM file containing the mappings.
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
6 Works with BWA version 0.5.3-0.5.5.
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
7
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
8 usage: bwa_wrapper.py [options]
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
9 -t, --threads=t: The number of threads to use
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
10 -r, --ref=r: The reference genome to use or index
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
11 -f, --fastq=f: The (forward) fastq file to use for the mapping
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
12 -F, --rfastq=F: The reverse fastq file to use for mapping if paired-end data
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
13 -u, --output=u: The file to save the output (SAM format)
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
14 -g, --genAlignType=g: The type of pairing (single or paired)
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
15 -p, --params=p: Parameter setting to use (pre_set or full)
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
16 -s, --fileSource=s: Whether to use a previously indexed reference sequence or one from history (indexed or history)
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
17 -n, --maxEditDist=n: Maximum edit distance if integer
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
18 -m, --fracMissingAligns=m: Fraction of missing alignments given 2% uniform base error rate if fraction
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
19 -o, --maxGapOpens=o: Maximum number of gap opens
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
20 -e, --maxGapExtens=e: Maximum number of gap extensions
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
21 -d, --disallowLongDel=d: Disallow a long deletion within specified bps
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
22 -i, --disallowIndel=i: Disallow indel within specified bps
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
23 -l, --seed=l: Take the first specified subsequences
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
24 -k, --maxEditDistSeed=k: Maximum edit distance to the seed
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
25 -M, --mismatchPenalty=M: Mismatch penalty
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
26 -O, --gapOpenPenalty=O: Gap open penalty
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
27 -E, --gapExtensPenalty=E: Gap extension penalty
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
28 -R, --suboptAlign=R: Proceed with suboptimal alignments even if the top hit is a repeat
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
29 -N, --noIterSearch=N: Disable iterative search
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
30 -T, --outputTopN=T: Output top specified hits
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
31 -S, --maxInsertSize=S: Maximum insert size for a read pair to be considered mapped good
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
32 -P, --maxOccurPairing=P: Maximum occurrences of a read for pairings
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
33 -D, --dbkey=D: Dbkey for reference genome
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
34 -H, --suppressHeader=h: Suppress header
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
35 """
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
36
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
37 import optparse, os, shutil, subprocess, sys, tempfile
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
38
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
39 def stop_err( msg ):
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
40 sys.stderr.write( '%s\n' % msg )
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
41 sys.exit()
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
42
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
43 def __main__():
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
44 #Parse Command Line
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
45 parser = optparse.OptionParser()
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
46 parser.add_option( '-t', '--threads', dest='threads', help='The number of threads to use' )
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
47 parser.add_option( '-r', '--ref', dest='ref', help='The reference genome to use or index' )
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
48 parser.add_option( '-f', '--fastq', dest='fastq', help='The (forward) fastq file to use for the mapping' )
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
49 parser.add_option( '-F', '--rfastq', dest='rfastq', help='The reverse fastq file to use for mapping if paired-end data' )
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
50 parser.add_option( '-u', '--output', dest='output', help='The file to save the output (SAM format)' )
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
51 parser.add_option( '-g', '--genAlignType', dest='genAlignType', help='The type of pairing (single or paired)' )
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
52 parser.add_option( '-p', '--params', dest='params', help='Parameter setting to use (pre_set or full)' )
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
53 parser.add_option( '-s', '--fileSource', dest='fileSource', help='Whether to use a previously indexed reference sequence or one form history (indexed or history)' )
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
54 parser.add_option( '-n', '--maxEditDist', dest='maxEditDist', help='Maximum edit distance if integer' )
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
55 parser.add_option( '-m', '--fracMissingAligns', dest='fracMissingAligns', help='Fraction of missing alignments given 2% uniform base error rate if fraction' )
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
56 parser.add_option( '-o', '--maxGapOpens', dest='maxGapOpens', help='Maximum number of gap opens' )
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
57 parser.add_option( '-e', '--maxGapExtens', dest='maxGapExtens', help='Maximum number of gap extensions' )
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
58 parser.add_option( '-d', '--disallowLongDel', dest='disallowLongDel', help='Disallow a long deletion within specified bps' )
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
59 parser.add_option( '-i', '--disallowIndel', dest='disallowIndel', help='Disallow indel within specified bps' )
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
60 parser.add_option( '-l', '--seed', dest='seed', help='Take the first specified subsequences' )
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
61 parser.add_option( '-k', '--maxEditDistSeed', dest='maxEditDistSeed', help='Maximum edit distance to the seed' )
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
62 parser.add_option( '-M', '--mismatchPenalty', dest='mismatchPenalty', help='Mismatch penalty' )
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
63 parser.add_option( '-O', '--gapOpenPenalty', dest='gapOpenPenalty', help='Gap open penalty' )
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
64 parser.add_option( '-E', '--gapExtensPenalty', dest='gapExtensPenalty', help='Gap extension penalty' )
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
65 parser.add_option( '-R', '--suboptAlign', dest='suboptAlign', help='Proceed with suboptimal alignments even if the top hit is a repeat' )
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
66 parser.add_option( '-N', '--noIterSearch', dest='noIterSearch', help='Disable iterative search' )
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
67 parser.add_option( '-T', '--outputTopN', dest='outputTopN', help='Output top specified hits' )
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
68 parser.add_option( '-S', '--maxInsertSize', dest='maxInsertSize', help='Maximum insert size for a read pair to be considered mapped good' )
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
69 parser.add_option( '-P', '--maxOccurPairing', dest='maxOccurPairing', help='Maximum occurrences of a read for pairings' )
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
70 parser.add_option( '-D', '--dbkey', dest='dbkey', help='Dbkey for reference genome' )
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
71 parser.add_option( '-H', '--suppressHeader', dest='suppressHeader', help='Suppress header' )
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
72 (options, args) = parser.parse_args()
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
73 # make temp directory for placement of indices
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
74 tmp_index_dir = tempfile.mkdtemp()
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
75 tmp_dir = tempfile.mkdtemp()
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
76 # index if necessary
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
77 if options.fileSource == 'history':
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
78 ref_file = tempfile.NamedTemporaryFile( dir=tmp_index_dir )
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
79 ref_file_name = ref_file.name
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
80 ref_file.close()
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
81 os.symlink( options.ref, ref_file_name )
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
82 # determine which indexing algorithm to use, based on size
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
83 try:
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
84 size = os.stat( options.ref ).st_size
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
85 if size <= 2**30:
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
86 indexingAlg = 'is'
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
87 else:
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
88 indexingAlg = 'bwtsw'
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
89 except:
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
90 indexingAlg = 'is'
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
91 indexing_cmds = '-a %s' % indexingAlg
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
92 cmd1 = 'bwa index %s %s' % ( indexing_cmds, ref_file_name )
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
93 try:
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
94 tmp = tempfile.NamedTemporaryFile( dir=tmp_index_dir ).name
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
95 tmp_stderr = open( tmp, 'wb' )
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
96 proc = subprocess.Popen( args=cmd1, shell=True, cwd=tmp_index_dir, stderr=tmp_stderr.fileno() )
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
97 returncode = proc.wait()
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
98 tmp_stderr.close()
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
99 # get stderr, allowing for case where it's very large
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
100 tmp_stderr = open( tmp, 'rb' )
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
101 stderr = ''
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
102 buffsize = 1048576
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
103 try:
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
104 while True:
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
105 stderr += tmp_stderr.read( buffsize )
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
106 if not stderr or len( stderr ) % buffsize != 0:
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
107 break
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
108 except OverflowError:
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
109 pass
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
110 tmp_stderr.close()
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
111 if returncode != 0:
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
112 raise Exception, stderr
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
113 except Exception, e:
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
114 # clean up temp dirs
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
115 if os.path.exists( tmp_index_dir ):
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
116 shutil.rmtree( tmp_index_dir )
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
117 if os.path.exists( tmp_dir ):
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
118 shutil.rmtree( tmp_dir )
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
119 stop_err( 'Error indexing reference sequence. ' + str( e ) )
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
120 else:
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
121 ref_file_name = options.ref
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
122 # set up aligning and generate aligning command options
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
123 if options.params == 'pre_set':
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
124 aligning_cmds = '-t %s' % options.threads
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
125 gen_alignment_cmds = ''
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
126 else:
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
127 if options.maxEditDist != '0':
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
128 editDist = options.maxEditDist
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
129 else:
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
130 editDist = options.fracMissingAligns
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
131 if options.seed != '-1':
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
132 seed = '-l %s' % options.seed
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
133 else:
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
134 seed = ''
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
135 if options.suboptAlign == 'true':
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
136 suboptAlign = '-R'
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
137 else:
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
138 suboptAlign = ''
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
139 if options.noIterSearch == 'true':
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
140 noIterSearch = '-N'
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
141 else:
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
142 noIterSearch = ''
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
143 aligning_cmds = '-n %s -o %s -e %s -d %s -i %s %s -k %s -t %s -M %s -O %s -E %s %s %s' % \
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
144 ( editDist, options.maxGapOpens, options.maxGapExtens, options.disallowLongDel,
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
145 options.disallowIndel, seed, options.maxEditDistSeed, options.threads,
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
146 options.mismatchPenalty, options.gapOpenPenalty, options.gapExtensPenalty,
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
147 suboptAlign, noIterSearch )
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
148 if options.genAlignType == 'single':
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
149 gen_alignment_cmds = '-n %s' % options.outputTopN
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
150 elif options.genAlignType == 'paired':
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
151 gen_alignment_cmds = '-a %s -o %s' % ( options.maxInsertSize, options.maxOccurPairing )
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
152 else:
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
153 gen_alignment_cmds = '-n %s' % options.outputTopN
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
154 # set up output files
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
155 tmp_align_out = tempfile.NamedTemporaryFile( dir=tmp_dir )
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
156 tmp_align_out_name = tmp_align_out.name
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
157 tmp_align_out.close()
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
158 tmp_align_out2 = tempfile.NamedTemporaryFile( dir=tmp_dir )
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
159 tmp_align_out2_name = tmp_align_out2.name
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
160 tmp_align_out2.close()
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
161 # prepare actual aligning and generate aligning commands
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
162 cmd2 = 'bwa aln %s %s %s > %s' % ( aligning_cmds, ref_file_name, options.fastq, tmp_align_out_name )
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
163 cmd2b = ''
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
164 if options.genAlignType == 'paired':
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
165 cmd2b = 'bwa aln %s %s %s > %s' % ( aligning_cmds, ref_file_name, options.rfastq, tmp_align_out2_name )
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
166 cmd3 = 'bwa sampe %s %s %s %s %s %s >> %s' % ( gen_alignment_cmds, ref_file_name, tmp_align_out_name, tmp_align_out2_name, options.fastq, options.rfastq, options.output )
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
167 elif options.genAlignType == 'single':
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
168 cmd3 = 'bwa samse %s %s %s %s >> %s' % ( gen_alignment_cmds, ref_file_name, tmp_align_out_name, options.fastq, options.output )
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
169 else:
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
170 cmd2 = 'sleep 1'
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
171 cmd2b = 'sleep 1'
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
172 cmd3 = 'bwa bwasw %s %s %s >> %s' % ( gen_alignment_cmds, ref_file_name, options.fastq, options.output )
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
173 # perform alignments
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
174 buffsize = 1048576
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
175 try:
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
176 # need to nest try-except in try-finally to handle 2.4
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
177 try:
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
178 # align
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
179 try:
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
180 tmp = tempfile.NamedTemporaryFile( dir=tmp_dir ).name
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
181 tmp_stderr = open( tmp, 'wb' )
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
182 proc = subprocess.Popen( args=cmd2, shell=True, cwd=tmp_dir, stderr=tmp_stderr.fileno() )
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
183 returncode = proc.wait()
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
184 tmp_stderr.close()
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
185 # get stderr, allowing for case where it's very large
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
186 tmp_stderr = open( tmp, 'rb' )
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
187 stderr = ''
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
188 try:
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
189 while True:
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
190 stderr += tmp_stderr.read( buffsize )
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
191 if not stderr or len( stderr ) % buffsize != 0:
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
192 break
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
193 except OverflowError:
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
194 pass
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
195 tmp_stderr.close()
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
196 if returncode != 0:
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
197 raise Exception, stderr
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
198 except Exception, e:
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
199 raise Exception, 'Error aligning sequence. ' + str( e )
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
200 # and again if paired data
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
201 try:
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
202 if cmd2b:
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
203 tmp = tempfile.NamedTemporaryFile( dir=tmp_dir ).name
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
204 tmp_stderr = open( tmp, 'wb' )
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
205 proc = subprocess.Popen( args=cmd2b, shell=True, cwd=tmp_dir, stderr=tmp_stderr.fileno() )
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
206 returncode = proc.wait()
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
207 tmp_stderr.close()
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
208 # get stderr, allowing for case where it's very large
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
209 tmp_stderr = open( tmp, 'rb' )
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
210 stderr = ''
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
211 try:
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
212 while True:
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
213 stderr += tmp_stderr.read( buffsize )
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
214 if not stderr or len( stderr ) % buffsize != 0:
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
215 break
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
216 except OverflowError:
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
217 pass
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
218 tmp_stderr.close()
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
219 if returncode != 0:
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
220 raise Exception, stderr
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
221 except Exception, e:
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
222 raise Exception, 'Error aligning second sequence. ' + str( e )
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
223 # generate align
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
224 try:
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
225 tmp = tempfile.NamedTemporaryFile( dir=tmp_dir ).name
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
226 tmp_stderr = open( tmp, 'wb' )
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
227 proc = subprocess.Popen( args=cmd3, shell=True, cwd=tmp_dir, stderr=tmp_stderr.fileno() )
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
228 returncode = proc.wait()
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
229 tmp_stderr.close()
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
230 # get stderr, allowing for case where it's very large
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
231 tmp_stderr = open( tmp, 'rb' )
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
232 stderr = ''
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
233 try:
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
234 while True:
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
235 stderr += tmp_stderr.read( buffsize )
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
236 if not stderr or len( stderr ) % buffsize != 0:
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
237 break
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
238 except OverflowError:
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
239 pass
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
240 tmp_stderr.close()
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
241 if returncode != 0:
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
242 raise Exception, stderr
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
243 except Exception, e:
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
244 raise Exception, 'Error generating alignments. ' + str( e )
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
245 # remove header if necessary
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
246 if options.suppressHeader == 'true':
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
247 tmp_out = tempfile.NamedTemporaryFile( dir=tmp_dir)
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
248 tmp_out_name = tmp_out.name
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
249 tmp_out.close()
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
250 try:
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
251 shutil.move( options.output, tmp_out_name )
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
252 except Exception, e:
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
253 raise Exception, 'Error moving output file before removing headers. ' + str( e )
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
254 fout = file( options.output, 'w' )
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
255 for line in file( tmp_out.name, 'r' ):
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
256 if not ( line.startswith( '@HD' ) or line.startswith( '@SQ' ) or line.startswith( '@RG' ) or line.startswith( '@PG' ) or line.startswith( '@CO' ) ):
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
257 fout.write( line )
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
258 fout.close()
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
259 # check that there are results in the output file
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
260 if os.path.getsize( options.output ) > 0:
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
261 sys.stdout.write( 'BWA run on %s-end data' % options.genAlignType )
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
262 else:
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
263 raise Exception, 'The output file is empty. You may simply have no matches, or there may be an error with your input file or settings.'
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
264 except Exception, e:
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
265 stop_err( 'The alignment failed.\n' + str( e ) )
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
266 finally:
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
267 # clean up temp dir
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
268 if os.path.exists( tmp_index_dir ):
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
269 shutil.rmtree( tmp_index_dir )
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
270 if os.path.exists( tmp_dir ):
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
271 shutil.rmtree( tmp_dir )
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
272
fb4844b6a98e Migrated tool version 1.0.3 from old tool shed archive to new tool shed repository
juanperin
parents:
diff changeset
273 if __name__=="__main__": __main__()