def merge_results(self): assert isinstance(self.root_problem,SeppProblem) '''Generate single extended alignment''' fullExtendedAlignment = ExtendedAlignment(self.root_problem.fragments.keys()) #self.root_problem.get_children()[0].jobs[get_placement_job_name(0)].get_attribute("full_extended_alignment_object") for pp in self.root_problem.get_children(): for i in range(0,self.root_problem.fragment_chunks): align_input = open(pp.jobs[get_placement_job_name(i)].full_extended_alignment_file,'rb') extended_alignment = pickle.load(align_input) align_input.close() fullExtendedAlignment.merge_in(extended_alignment,convert_to_string=True) self.results = fullExtendedAlignment mergeinput = [] '''Append main tree to merge input''' mergeinput.append("%s;" %(self.root_problem.subtree.compose_newick(labels = True))) jsons = [] for pp in self.root_problem.get_children(): assert isinstance(pp,SeppProblem) for i in range(0,self.root_problem.fragment_chunks): if (pp.get_job_result_by_name(get_placement_job_name(i)) is None): continue '''Append subset trees and json locations to merge input''' mergeinput.append("%s;\n%s" %(pp.subtree.compose_newick(labels = True), pp.get_job_result_by_name(get_placement_job_name(i)))) mergeinput.append("") mergeinput.append("") meregeinputstring = "\n".join(mergeinput) mergeJsonJob = self.get_merge_job(meregeinputstring) mergeJsonJob.run()
def build_jobs(self): assert isinstance(self.root_problem, SeppProblem) for placement_problem in self.root_problem.get_children(): ''' Create placer jobs''' for i in range(0, self.root_problem.fragment_chunks): if self.placer == "pplacer": pj = PplacerJob() pj.partial_setup_for_subproblem(placement_problem, self.options.info_file, i) elif self.placer == "epa": raise ValueError("EPA Currently not supported") # pj = EPAJob() # pj.partial_setup_for_subproblem( # placement_problem, self.molecule, i) placement_problem.add_job(get_placement_job_name(i), pj) '''For each alignment subproblem, ...''' for alg_problem in placement_problem.children: assert isinstance(alg_problem, SeppProblem) ''' create the build model job''' bj = HMMBuildJob() bj.setup_for_subproblem(alg_problem, molecule=self.molecule) alg_problem.add_job(bj.job_type, bj) ''' create the search jobs''' for fc_problem in alg_problem.get_children(): sj = HMMSearchJob() sj.partial_setup_for_subproblem(fc_problem.fragments, fc_problem, self.elim, self.filters) fc_problem.add_job(sj.job_type, sj) ''' create the align job''' aj = HMMAlignJob() fc_problem.add_job(aj.job_type, aj) aj.partial_setup_for_subproblem(fc_problem, molecule=self.molecule)
def merge_results(self): assert isinstance(self.root_problem, SeppProblem) '''Generate single extended alignment''' fullExtendedAlignment = ExtendedAlignment( self.root_problem.fragments.keys()) # self.root_problem.get_children()[0].jobs[get_placement_job_name(0)]\ # .get_attribute("full_extended_alignment_object") for pp in self.root_problem.get_children(): for i in range(0, self.root_problem.fragment_chunks): align_input = open( pp.jobs[get_placement_job_name(i)] .full_extended_alignment_file, 'rb') extended_alignment = pickle.load(align_input) align_input.close() fullExtendedAlignment.merge_in( extended_alignment, convert_to_string=True) self.results = fullExtendedAlignment mergeinput = [] '''Append main tree to merge input''' mergeinput.append("%s;" % ( self.root_problem.subtree.compose_newick(labels=True))) for pp in self.root_problem.get_children(): assert isinstance(pp, SeppProblem) for i in range(0, self.root_problem.fragment_chunks): if (pp.get_job_result_by_name( get_placement_job_name(i)) is None): continue '''Append subset trees and json locations to merge input''' mergeinput.append( "%s;\n%s" % ( pp.subtree.compose_newick(labels=True), pp.get_job_result_by_name(get_placement_job_name(i)))) mergeinput.append("") mergeinput.append("") meregeinputstring = "\n".join(mergeinput) mergeJsonJob = self.get_merge_job(meregeinputstring) mergeJsonJob.run()
def perform(self): pp = self.placement_problem fullExtendedAlignments = self.merge_subalignments() for i in range(0, self.root_problem.fragment_chunks): fullExtendedAlignment = fullExtendedAlignments[i] # Split the backbone alignment and query sequences into # separate files queryExtendedAlignment = \ fullExtendedAlignment.get_fragments_readonly_alignment() base_alignment = fullExtendedAlignment.\ get_base_readonly_alignment() pj = pp.jobs[get_placement_job_name(i)] if queryExtendedAlignment.is_empty(): pj.fake_run = True if self.placer == "pplacer": assert isinstance(pj, PplacerJob) # Write out the extended alignments, split into query and # full-length for pplacer queryExtendedAlignment.write_to_path( pj.extended_alignment_file) base_alignment.write_to_path(pj.backbone_alignment_file) elif self.placer == "epa": # assert isinstance(pj, EPAJob) raise ValueError("EPA Currently not supported") # Write out the extended alignments in phylip for EPA # fullExtendedAlignment.write_to_path( # pj.extended_alignment_file, schema="PHYLIP") # keep the extended alignment on everything # pj.set_attribute("full_extended_alignment_object", # fullExtendedAlignment) # TODO: Removed this, as it can cause unexpected lockups output = open(pj.full_extended_alignment_file, 'wb') pickle.dump(fullExtendedAlignment, output) output.close() # Enqueue the placement job JobPool().enqueue_job(pj)
def perform(self): pp = self.placement_problem fullExtendedAlignments = self.merge_subalignments() for i in range(0, self.root_problem.fragment_chunks): fullExtendedAlignment = fullExtendedAlignments[i] # Split the backbone alignment and query sequences into # separate files queryExtendedAlignment = \ fullExtendedAlignment.get_fragments_readonly_alignment() baseAlignment = fullExtendedAlignment.get_base_readonly_alignment() pj = pp.jobs[get_placement_job_name(i)] if (queryExtendedAlignment.is_empty()): pj.fake_run = True if self.placer == "pplacer": assert isinstance(pj, PplacerJob) # Write out the extended alignments, split into query and # full-length for pplacer queryExtendedAlignment.write_to_path( pj.extended_alignment_file) baseAlignment.write_to_path(pj.backbone_alignment_file) elif self.placer == "epa": # assert isinstance(pj, EPAJob) raise ValueError("EPA Currently not supported") # Write out the extended alignments in phylip for EPA fullExtendedAlignment.write_to_path( pj.extended_alignment_file, schema="PHYLIP") # keep the extended alignment on everything # pj.set_attribute("full_extended_alignment_object", # fullExtendedAlignment) # TODO: Removed this, as it can cause unexpected lockups output = open(pj.full_extended_alignment_file, 'wb') pickle.dump(fullExtendedAlignment, output) output.close() # Enqueue the placement job JobPool().enqueue_job(pj)
def build_jobs(self): assert isinstance(self.root_problem, SeppProblem) for placement_problem in self.root_problem.get_children(): ''' Create placer jobs''' for i in range(0, self.root_problem.fragment_chunks): if self.placer == "pplacer": pj = PplacerJob() pj.partial_setup_for_subproblem( placement_problem, self.options.info_file, i) elif self.placer == "epa": raise ValueError("EPA Currently not supported") # pj = EPAJob() # pj.partial_setup_for_subproblem( # placement_problem, self.molecule, i) placement_problem.add_job(get_placement_job_name(i), pj) '''For each alignment subproblem, ...''' for alg_problem in placement_problem.children: assert isinstance(alg_problem, SeppProblem) ''' create the build model job''' bj = HMMBuildJob() bj.setup_for_subproblem(alg_problem, molecule=self.molecule) alg_problem.add_job(bj.job_type, bj) ''' create the search jobs''' for fc_problem in alg_problem.get_children(): sj = HMMSearchJob() sj.partial_setup_for_subproblem( fc_problem.fragments, fc_problem, self.elim, self.filters) fc_problem.add_job(sj.job_type, sj) ''' create the align job''' aj = HMMAlignJob() fc_problem.add_job(aj.job_type, aj) aj.partial_setup_for_subproblem( fc_problem, molecule=self.molecule)