comparison tools/protein_analysis/promoter2.py @ 9:e52220a9ddad draft

Uploaded v0.1.2 Use the new <stdio> settings in the XML wrappers to catch errors. Obeys SGE style XNSLOTS environment variable for thread count (otherwise default to 4).
author peterjc
date Fri, 25 Jan 2013 06:08:31 -0500
parents 976a5f2833cd
children eb6ac44d4b8e
comparison
equal deleted inserted replaced
8:976a5f2833cd 9:e52220a9ddad
28 """ 28 """
29 import sys 29 import sys
30 import os 30 import os
31 import commands 31 import commands
32 import tempfile 32 import tempfile
33 from seq_analysis_utils import stop_err, split_fasta, run_jobs 33 from seq_analysis_utils import stop_err, split_fasta, run_jobs, thread_count
34 34
35 FASTA_CHUNK = 500 35 FASTA_CHUNK = 500
36 36
37 if len(sys.argv) != 4: 37 if len(sys.argv) != 4:
38 stop_err("Require three arguments, number of threads (int), input DNA FASTA file & output tabular file. " 38 stop_err("Require three arguments, number of threads (int), input DNA FASTA file & output tabular file. "
39 "Got %i arguments." % (len(sys.argv)-1)) 39 "Got %i arguments." % (len(sys.argv)-1))
40 try:
41 num_threads = int(sys.argv[1])
42 except:
43 num_threads = 1 #Default, e.g. used "$NSLOTS" and environment variable not defined
44 if num_threads < 1:
45 stop_err("Threads argument %s is not a positive integer" % sys.argv[1])
46 40
41 num_threads = thread_count(sys.argv[3],default=4)
47 fasta_file = os.path.abspath(sys.argv[2]) 42 fasta_file = os.path.abspath(sys.argv[2])
48 tabular_file = os.path.abspath(sys.argv[3]) 43 tabular_file = os.path.abspath(sys.argv[3])
49 44
50 tmp_dir = tempfile.mkdtemp() 45 tmp_dir = tempfile.mkdtemp()
51 46