comparison tools/protein_analysis/promoter2.py @ 8:976a5f2833cd draft

Uploaded v0.1.1 of the bundle, which fixes an error in the header of the tabular output produced for Promoter 2.0
author peterjc
date Mon, 30 Jul 2012 12:56:54 -0400
parents 9b45a8743100
children e52220a9ddad
comparison
equal deleted inserted replaced
7:9b45a8743100 8:976a5f2833cd
71 71
72 def make_tabular(raw_handle, out_handle): 72 def make_tabular(raw_handle, out_handle):
73 """Parse text output into tabular, return query count.""" 73 """Parse text output into tabular, return query count."""
74 identifier = None 74 identifier = None
75 queries = 0 75 queries = 0
76 #out.write("#Identifier\tDescription\tPosition\tScore\tLikelihood\n")
77 for line in raw_handle: 76 for line in raw_handle:
78 #print repr(line) 77 #print repr(line)
79 if not line.strip() or line == "Promoter prediction:\n": 78 if not line.strip() or line == "Promoter prediction:\n":
80 pass 79 pass
81 elif line[0] != " ": 80 elif line[0] != " ":
97 "Marginal prediction", 96 "Marginal prediction",
98 "Medium likely prediction", 97 "Medium likely prediction",
99 "Highly likely prediction"]: 98 "Highly likely prediction"]:
100 stop_err("ERROR: Problem with line: %r" % line) 99 stop_err("ERROR: Problem with line: %r" % line)
101 out_handle.write("%s\t%s\t%s\t%s\n" % (identifier, position, score, likelihood)) 100 out_handle.write("%s\t%s\t%s\t%s\n" % (identifier, position, score, likelihood))
102 #out.close()
103 return queries 101 return queries
104 102
105 working_dir, bin = get_path_and_binary() 103 working_dir, bin = get_path_and_binary()
106 104
107 if not os.path.isfile(fasta_file): 105 if not os.path.isfile(fasta_file):
145 143
146 del results 144 del results
147 del jobs 145 del jobs
148 146
149 out_handle = open(tabular_file, "w") 147 out_handle = open(tabular_file, "w")
150 out_handle.write("#Identifier\tDescription\tPosition\tScore\tLikelihood\n") 148 out_handle.write("#Identifier\tPosition\tScore\tLikelihood\n")
151 queries = 0 149 queries = 0
152 for temp in temp_files: 150 for temp in temp_files:
153 data_handle = open(temp) 151 data_handle = open(temp)
154 count = make_tabular(data_handle, out_handle) 152 count = make_tabular(data_handle, out_handle)
155 data_handle.close() 153 data_handle.close()