annotate uniqprimer-0.5.0/uniqprimer.py @ 3:3249d78ecfc2 draft

Uploaded
author dereeper
date Mon, 03 Jan 2022 09:56:55 +0000
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
1 #!/usr/bin/python
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
2
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
3 '''
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
4 Created on Jan 1, 2011
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
5
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
6 @author: John L. Herndon
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
7 @contact: herndon@cs.colostate.edu
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
8 @organization: Colorado State University
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
9 @group: Computer Science Department, Asa Ben-Hur's laboratory
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
10 '''
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
11
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
12 import exceptions
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
13 import sys
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
14 import time
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
15 import os ## added by Alexis
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
16
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
17 sys.path.append("/gs7k1/home/galaxy/galaxy_env/lib/python2.7/site-packages")
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
18
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
19 import getopt
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
20 from primertools import *
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
21
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
22 version="0.5.0"
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
23
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
24
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
25 class UniqPrimerFinder( object ):
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
26
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
27 def __init__( self, includeFiles, excludeFiles, crossValidate, eprimerOptions):
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
28
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
29 utils.logMessage( "UniqPrimerFinder::__init__()", "Initializing UniqPrimerFinder" )
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
30 self.includeFiles = includeFiles
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
31 self.includeFileManager = includefilemanager.IncludeFileManager( )
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
32
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
33 self.excludeFiles = excludeFiles
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
34 self.excludeFileManager= excludefilemanager.ExcludeFileManager( )
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
35
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
36 self.primerManager = primermanager.PrimerManager( eprimerOptions )
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
37
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
38 self.crossValidate = crossValidate
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
39
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
40
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
41 utils.logMessage( "UniqPrimerFinder::__init__()", "Initializing UniqPrimerFinder - complete" )
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
42
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
43 def writeOutputFile( self, primers, outputFileName, maxresults = 100 ):
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
44 '''
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
45 primers: a list of PrimerSet obs
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
46 '''
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
47 ##outputFileName = uPrimer ##Mau: defined this..
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
48 outputFile = open( outputFileName, 'w' )
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
49
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
50 i = 0
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
51 for primer in primers:
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
52 i += 1
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
53
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
54 outputFile.write( "{0}\t{1}\t{2}\t{3}\n".format( i, primer.forwardPrimer, primer.reversePrimer, primer.productSize ) )
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
55
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
56 if i > maxresults:
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
57 break
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
58
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
59 utils.logMessage( "UniqPrimerFinder::writeOutputFile()", "output file written." )
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
60
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
61
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
62 def findPrimers( self, outputFile = "uPrimer.txt" ):
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
63 outputFile = uPrimer ## Mau adds to overwrite the above value
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
64
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
65
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
66 utils.logMessage( "UniqPrimerFinder::findPrimers()", "Finding primers for include files" )
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
67 startTime = time.time( )
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
68 #generate the combined sequence fasta file for all exclude sequences
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
69 utils.printProgressMessage( "*** Creating Combined Fasta File for Exclude Files ***" )
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
70 for excludeFile in self.excludeFiles:
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
71 self.excludeFileManager.addExcludeFile( excludeFile )
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
72
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
73 self.excludeFileManager.exportSequences( )
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
74
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
75 self.includeFileManager.setExcludeFile( self.excludeFileManager.getOutputFileName( ) )
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
76
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
77 utils.printProgressMessage( "*** Finding Sequences Unique to Target Genome ***" )
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
78
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
79 #run nucmer program on all include files
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
80 for includeFile in self.includeFiles:
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
81 self.includeFileManager.processIncludeFile( includeFile )
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
82
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
83 #get the sequences found in include files, but no the exclude file.
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
84 uniqueSequences = self.includeFileManager.getUniqueSequences( )
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
85
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
86 utils.printProgressMessage( "*** Finding Primers ***" )
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
87
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
88 primers = self.primerManager.getPrimers( uniqueSequences )
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
89
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
90 if self.crossValidate == True:
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
91 utils.printProgressMessage( "*** Cross Validating Primers ***" )
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
92 primers = self.primerManager.crossValidatePrimers( primers, self.excludeFileManager.getOutputFileName( ) )
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
93 # added by Alexis, primersearch also against all include files
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
94 #run primersearch program on all include files
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
95 j=0
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
96 for includeFile in self.includeFiles: # added by Alexis
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
97 j = j + 1
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
98 primers = self.primerManager.crossValidatePrimers2( primers, includeFile, j) # added by Alexis
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
99
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
100
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
101 utils.logMessage( "UniqPrimerFinder::findPrimers( )", "found {0} unique sequences".format( len( primers ) ) )
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
102
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
103 self.writeOutputFile( primers, outputFile )
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
104
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
105 utils.logMessage( "UniqPrimerFinder::findPrimers()", "Finished finding primers" )
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
106 endTime = time.time()
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
107 elapsedMinutes = int( ( endTime - startTime ) / 60 )
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
108 elapsedSeconds = int( ( endTime - startTime ) % 60 )
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
109 print "*** Time Elapsed: {0} minutes, {1} seconds ***".format( elapsedMinutes, elapsedSeconds )
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
110 print "*** Output Written to {0} ***".format( outputFile )
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
111
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
112
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
113 def printUsageAndQuit( ):
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
114 global version
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
115 print "uniqprimer - finds primers unique to a genome"
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
116 print "Version: " + str( version )
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
117 print "Summary of Options."
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
118 print "Required Arguments:"
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
119 print " -i <filename>: use <filename> as an include file. Primers will be identified for this genome"
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
120 print " -x <filename>: use <filename> as an exclude file. Primers for this genome will be excluded"
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
121 print " -o <filename>: specify the name of the unique primer output file (default is uPrimer.txt)" ## Mau added..
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
122 print " -l <filename>: specify the name of the log output file" ## Mau added..
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
123 print " -f <filename>: specify the name of the Fasta of differential sequences" ## Alexis added..
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
124
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
125 print "\nOptional Arguments:"
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
126 print " --productsizerage: set a range for the desired size of PCR product (default=200-250). Example: ./uniqprimer -productsizerage 100-150"
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
127 print " --primersize: set the desired primer size (default=20)"
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
128 print " --minprimersize: set the minimum primer size (default=27)"
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
129 print " --maxprimersize: set the maximum primer size (default=18)"
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
130 print " --crossvalidate: force the program to cross validate primers against exclude files for extra certainty"
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
131 print " --keeptempfiles: force the program to keep temporary files"
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
132
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
133 print "\n\nExample:"
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
134 print "uniqprimer -i <includefile1> -i <includefile2> ... -i <includefileN> -x <excludefile1> -x <excludefile2> ... -x <excludefileN> -o primers.txt -l logfile.txt -f seqForPrimer3.fa"
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
135 utils.shutdownLogging( )
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
136 sys.exit( )
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
137
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
138
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
139 opts = 'i:x:h:o:l:f:' # Mau added :o & :l for outfile specification, Alexis added :f
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
140 longopts=[ "productsizerange=", "primersize=", "minprimersize=", "maxprimersize=", "crossvalidate", "keeptempfiles" ]
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
141
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
142 def parseArgs( args ):
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
143
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
144
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
145 global uPrimer ## Mau added lf, brute force...
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
146 global lf # Mau added lf, brute force...
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
147 global fastaDiff # Alexis added fastaDiff
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
148 #uPrimer = "uPrimer.txt" ##the default value...
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
149
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
150 crossValidate = False
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
151 cleanup = True
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
152 optlist, args = getopt.getopt( args, opts, longopts )
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
153
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
154 includeFiles = [ ]
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
155 excludeFiles = [ ]
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
156 eprimerOptions = utils.EPrimerOptions( )
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
157
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
158 verbose = False
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
159 for opt in optlist:
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
160 if opt[ 0 ] == '-i':
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
161 includeFiles.append( opt[ 1 ] )
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
162 elif opt[ 0 ] == '-x':
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
163 excludeFiles.append( opt[ 1] )
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
164 elif opt[ 0 ] == '-v':
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
165 verbose = True
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
166 elif opt[ 0 ] == '-o': ## Mau added, if -o...
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
167 uPrimer = str(opt[1]) ## Mau added, then get filename for outfile after -o
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
168 elif opt[ 0 ] == '-l': ## Mau added, if -l...
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
169 lf = str(opt[1]) ## Mau added, then get filename for logfile after -l
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
170 elif opt[ 0 ] == '-f': ## Alexis added, if -f
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
171 fastaDiff = str(opt[1]) ## Alexis added, then get filename for fasta file after -f
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
172 elif opt[ 0 ] == '--productsizerange':
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
173 eprimerOptions.setProductRange( opt[ 1 ] )
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
174 productsizerange = opt[ 1 ]
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
175 elif opt[ 0 ] == '--primersize':
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
176 eprimerOptions.setPrimerSize( opt[1 ] )
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
177 elif opt[ 0 ] == '--minprimersize':
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
178 eprimerOptions.setMinPrimerSize( opt[1 ] )
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
179 elif opt[ 0 ] == '--maxprimersize':
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
180 eprimerOptions.setMaxPrimerSize( opt[1 ] )
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
181 elif opt[ 0 ] == '--crossvalidate':
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
182 crossValidate = True
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
183 elif opt[ 0 ] == '--crossvalidate':
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
184 crossValidate = True
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
185 elif opt[ 0 ] == '--keeptempfiles':
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
186 cleanup = False
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
187 elif opt[ 0 ] == '-h':
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
188 printUsageAndQuit( )
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
189 else:
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
190 print "Unknown option: " + str( opt[ 0 ] )
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
191 printUsageAndQuit( )
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
192 #print "uPrimer: " + uPrimer + " log file name: " + lf + "\n"
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
193 if len( includeFiles ) == 0 or len( excludeFiles ) == 0:
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
194
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
195 print "You must specify at least one include file and at least one exclude file"
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
196 printUsageAndQuit( )
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
197
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
198 return includeFiles, excludeFiles, crossValidate, cleanup, verbose, eprimerOptions, lf , uPrimer, fastaDiff #Mau: add lf, uPrime
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
199
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
200 def main( args, debug = False):
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
201 #parse the command line arguments for include and exclude files
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
202
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
203 includeFiles, excludeFiles, crossValidate, cleanup, verbose, eprimerOptions, lf, uPrimer, fastaDiff = parseArgs( args ) ##Mau add: lf
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
204 utils.initialize( True, cleanup, lf) ##Mau: add lf
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
205 #find primers for the include sequences
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
206
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
207 tmpdir = utils.getTemporaryDirectory() ## added by Alexis
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
208 command = "cp -rf " + tmpdir + "/sequenceForEprimer.fasta" + " " + fastaDiff
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
209
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
210 try:
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
211 utils.logMessage( "uniqprimer::Main( )", "Logging include files: " )
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
212 utils.logList( "uniqprimer::Main( )", includeFiles )
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
213 utils.logMessage( "uniqprimer::Main( )", "Logging exclude files: " )
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
214 utils.logList( "uniqprimer::Main( )", excludeFiles)
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
215 print "*** Finding Primers ***"
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
216 uniqPrimer = UniqPrimerFinder( includeFiles, excludeFiles, crossValidate, eprimerOptions)
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
217 uniqPrimer.findPrimers( )
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
218 except utils.NoFileFoundException as nfe:
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
219 print "File not found: " + str( nfe.filename )
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
220 printUsageAndQuit( )
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
221 except utils.ProgramNotFoundException as pnfe:
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
222 print str( pnfe.programName ) + ": program is not installed or is not in your path."
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
223 print str( pnfe.details )
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
224 except utils.NoPrimersExistException as npe:
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
225 print "Failure: No unique primers exist for this combination"
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
226 except exceptions.BaseException as e:
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
227 print "It appears that an unknown sequence of events has resulted in the internal explosion of this program. Please send the file called \'log_uniqprimer.txt\' to herndon@cs.colostate.edu and tell that bonehead John to fix it!"
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
228 print "Details:"
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
229 print e
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
230
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
231 os.system("cp -rf " + tmpdir + "/sequenceForEprimer.fasta" + " " + fastaDiff)
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
232 utils.shutdown( )
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
233
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
234 print "*** Finished ***"
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
235
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
236 if __name__ == '__main__':
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
237
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
238 #temp_args = "-i data/testdata/smallinclude.ffn -x data/testdata/smallexclude.ffn".split( )
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
239
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
240 #temp_args = "-i data/XOO_MAI1_scaffolds.fas -x data/KACC.ffn".split( )
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
241 if len( sys.argv ) == 1:
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
242 printUsageAndQuit( )
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
243 main( sys.argv[ 1: ], debug = True )
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
244
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
245
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
246
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
247
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
248
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
249
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
250
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
251
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
252
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
253
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
254
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
255
3249d78ecfc2 Uploaded
dereeper
parents:
diff changeset
256