def __init__(self, callback, queries, genefamily_id, alignment, tree, identity, overlap) : super(PaganJob, self).__init__(callback) self._queries = queries self._genefamily = genefamily_id self._alignment = alignment self._tree = tree self.identity = identity self.overlap = overlap self.pagan = Pagan() self.query_fname = None self.out_fname = None self.alignment_fname = None self.tree_fname = None
class PaganJob(Job) : def __init__(self, callback, queries, genefamily_id, alignment, tree, identity, overlap) : super(PaganJob, self).__init__(callback) self._queries = queries self._genefamily = genefamily_id self._alignment = alignment self._tree = tree self.identity = identity self.overlap = overlap self.pagan = Pagan() self.query_fname = None self.out_fname = None self.alignment_fname = None self.tree_fname = None @property def input(self) : return self._queries @property def genefamily(self) : return self._genefamily @property def nucleotide_alignment(self) : return self.pagan.nucleotide_alignment @property def protein_alignment(self) : return self.pagan.protein_alignment def _get_filenames(self) : #return self.pagan.output_filenames(self.out_fname) return [self.query_fname, self.alignment_fname, self.tree_fname] + self.pagan.output_filenames(self.out_fname) def _run(self) : global DEBUG self.query_fname = tmpfasta_orfs(self._queries, strand=True) #self.query_fname = tmpfasta(self._queries) self.out_fname = tmpfile() self.alignment_fname = tmpfasta(self._alignment) # tmpfasta_kill_n(self._alignment) self.tree_fname = tmpfile(self._tree) if self._tree else None start_time = time.time() result = self.pagan.run(self.query_fname, self.out_fname, self.alignment_fname, self.tree_fname, self.identity, self.overlap) elapsed_time = time.time() - start_time q_count, q_sum, q_min, q_max, q_mean, q_sd = fasta_stats(self.query_fname) a_count, a_sum, a_min, a_max, a_mean, a_sd = fasta_stats(self.alignment_fname) if DEBUG : threadsafe_io('pagan_stats.txt', "%s %d %d %d %d %d %.3f %.3f %d %d %d %d %.3f %.3f %d" % \ (self._genefamily, result, \ q_count, q_sum, q_min, q_max, q_mean, q_sd, \ a_count, a_sum, a_min, a_max, a_mean, a_sd, \ elapsed_time)) return result