annotate SMART/Java/Python/runRandomJobs.py @ 6:769e306b7933

Change the repository level.
author yufei-luo
date Fri, 18 Jan 2013 04:54:14 -0500
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
6
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1 import unittest
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
2 import os
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
3 import time
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
4 from optparse import OptionParser
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
5 from SMART.Java.Python.ncList.test.MockFindOverlaps_randomExample import MockFindOverlaps_randomExample
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
6 from SMART.Java.Python.FindOverlapsOptim import FindOverlapsOptim
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
7
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
8 if __name__ == '__main__':
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
9 description = "runRandomJobs: create random ref/query files (with size given), and run the jobs on cluster with help of runJobs.sh"
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
10
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
11 parser = OptionParser(description = description)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
12 parser.add_option("-i", "--inputRef", dest="inputRefGff3FileName", action="store", type="string", help="Reference input file [compulsory] [format: file in gff3 format]")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
13 parser.add_option("-j", "--inputQuery", dest="inputQueryGff3FileName", action="store", type="string", help="Query input file [compulsory] [format: file in gff3 format]")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
14 parser.add_option("-m", "--inputRefSize", dest="numberOfRefReads", action="store", type="int", help="The number of Reference")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
15 parser.add_option("-n", "--inputQuerySize", dest="numberOfQReads", action="store", type="int", help="The number of Query")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
16 parser.add_option("-o", "--output", dest="outputGff3FileName", action="store", type="string", help="output file [compulsory] [format: output file in gff3 format]")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
17 (options, args) = parser.parse_args()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
18
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
19 outputDataName = 'timeResult.dat'
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
20 fTime = open(outputDataName, 'w')
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
21 fTime.write('NbRef\tNbQuery\tNbOverlap\ttime\n')
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
22 chromSize = 100000
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
23 print 'ref size = %d, query size = %d' %(options.numberOfRefReads, options.numberOfQReads)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
24 iMFOR_ref = MockFindOverlaps_randomExample(options.inputRefGff3FileName, 'ref', options.numberOfRefReads, chromSize)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
25 iMFOR_ref.write()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
26 cmd_ref = 'sort -f -n -k4 -k5.4rn -o %s %s' % (options.inputRefGff3FileName, options.inputRefGff3FileName)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
27 os.system(cmd_ref)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
28 iMFOR_query = MockFindOverlaps_randomExample(options.inputQueryGff3FileName,'q', options.numberOfQReads, chromSize)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
29 iMFOR_query.write()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
30 cmd_query = 'sort -f -n -k4 -k5.4rn -o %s %s' % (options.inputQueryGff3FileName, options.inputQueryGff3FileName)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
31 os.system(cmd_query)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
32 iFOO = FindOverlaps_optim(options.inputRefGff3FileName, options.inputQueryGff3FileName)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
33 iFOO.setOutputGff3FileName(options.outputGff3FileName)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
34
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
35 startTime_optim = time.time()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
36 iFOO.run()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
37 iFOO.close()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
38 nbOverlap = iFOO.getNbOverlap()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
39 endTime_optim = time.time()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
40 cmd = 'sort -f -n -k4 -k5.4rn -k9.5 -t ";" -o %s %s' % (options.outputGff3FileName, options.outputGff3FileName)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
41 os.system(cmd)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
42 totalTime_optim = endTime_optim - startTime_optim
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
43 print 'we take %s second.' % (totalTime_optim)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
44 fTime.write('%d\t%d\t%d\t%.2f\n'%(options.numberOfRefReads, options.numberOfQReads, nbOverlap, totalTime_optim))
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
45 iFOO.deletIntermediateFiles()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
46 fTime.close()