def __init__(self, nodeid, alg_phylip_file, constrain_id, model, seqtype, conf, confname, parts_id=None): GLOBALS["citator"].add(PHYML_CITE) base_args = OrderedDict({ "--model": "", "--no_memory_check": "", "--quiet": "", "--constraint_tree": ""}) self.confname = confname self.conf = conf self.constrain_tree = None if constrain_id: self.constrain_tree = db.get_dataid(constrain_id, DATATYPES.constrain_tree) self.alg_phylip_file = alg_phylip_file TreeTask.__init__(self, nodeid, "tree", "Phyml", base_args, conf[confname]) if seqtype == "aa": self.model = model or conf[confname]["_aa_model"] elif seqtype == "nt": self.model = model or conf[confname]["_nt_model"] self.seqtype = seqtype self.lk = None self.init()
def __init__(self, nodeid, alg_file, constrain_id, model, seqtype, conf, confname, parts_id=None): GLOBALS["citator"].add(FASTTREE_CITE) self.confname = confname self.conf = conf self.alg_phylip_file = alg_file self.constrain_tree = None if constrain_id: self.constrain_tree = db.get_dataid(constrain_id, DATATYPES.constrain_alg) self.alg_basename = basename(self.alg_phylip_file) self.seqtype = seqtype self.tree_file = "" if model: log.warning("FastTree does not support model selection") self.model = None self.lk = None base_args = OrderedDict() base_args["-nopr"] = "" if self.seqtype == "nt": base_args["-gtr -nt"] = "" elif self.seqtype == "aa": pass else: raise ValueError("Unknown seqtype %s" % self.seqtype) TreeTask.__init__(self, nodeid, "tree", "FastTree", base_args, self.conf[confname]) self.init()
def __init__(self, nodeid, alg_file, constrain_id, model, seqtype, conf, confname, parts_id=None): GLOBALS["citator"].add(RAXML_CITE) base_args = OrderedDict() self.bootstrap = conf[confname].get("_bootstrap", None) model = model or conf[confname]["_aa_model"] self.confname = confname self.conf = conf self.alg_phylip_file = alg_file try: self.constrain_tree = db.get_dataid(constrain_id, DATATYPES.constrain_tree) except ValueError: self.constrain_tree = None self.partitions_file = parts_id TreeTask.__init__(self, nodeid, "tree", "RaxML", base_args, conf[confname]) max_cores = GLOBALS["_max_cores"] appname = conf[confname]["_app"] if max_cores > 1: threads = conf["threading"].get("raxml-pthreads") if threads > 1: appname = appname.replace("raxml", "raxml-pthreads") raxml_bin = conf["app"][appname] else: appname = appname.replace("raxml-pthreads", "raxml") threads = 1 raxml_bin = conf["app"][appname] self.raxml_bin = raxml_bin self.threads = threads self.seqtype = seqtype # Process raxml options method = conf[confname].get("_method", "GAMMA").upper() if seqtype.lower() == "aa": self.model_string = 'PROT%s%s' %(method, model.upper()) self.model = model elif seqtype.lower() == "nt": self.model_string = 'GTR%s' %method self.model = "GTR" else: raise ValueError("Unknown seqtype %s", seqtype) #inv = conf[confname].get("pinv", "").upper() #freq = conf[confname].get("ebf", "").upper() self.init()
def finish(self): lks = [] j = self.jobs[0] tree_file = os.path.join(j.jobdir, self.alg_phylip_file+"_phyml_tree.txt") stats_file = os.path.join(j.jobdir, self.alg_phylip_file+"_phyml_stats.txt") m = re.search('Log-likelihood:\s+(-?\d+\.\d+)', open(stats_file).read()) lk = float(m.groups()[0]) stats = {"lk": lk} tree = PhyloTree(tree_file) TreeTask.store_data(self, tree.write(), stats)
def finish(self): node_info = self.conf["_nodeinfo"][self.nodeid] target_seqs = node_info.get("target_seqs", set()) out_seqs = node_info.get("out_seqs", set()) all_seqs = list(target_seqs | out_seqs) if len(all_seqs) == 1: newick = "%s;" %(all_seqs[0]) elif len(all_seqs) == 2: newick = "(%s, %s);" %(all_seqs[0], all_seqs[1]) else: newick = "(%s, (%s));" %(all_seqs[0], ','.join(all_seqs[1:])) TreeTask.store_data(self, newick, {})
def __init__(self, nodeid, alg_file, constrain_id, model, seqtype, conf, confname, parts_id=None): self.confname = confname self.conf = conf self.alg_phylip_file = alg_file self.constrain_tree = None if constrain_id: self.constrain_tree = db.get_dataid(constrain_id, DATATYPES.constrain_alg) self.alg_basename = basename(self.alg_phylip_file) self.seqtype = seqtype self.tree_file = "" self.model = None self.lk = None TreeTask.__init__(self, nodeid, "tree", "DummyTree", {}, {}) self.init()
def finish(self): #first job is the raxml tree def parse_alrt(match): dist = match.groups()[0] support = float(match.groups()[1])/100.0 return "%g:%s" %(support, dist) if self.bootstrap == "alrt": alrt_tree_file = os.path.join(self.alrt_job.jobdir, "RAxML_fastTreeSH_Support." + self.alrt_job.args["-n"]) raw_nw = open(alrt_tree_file).read() try: nw, nsubs = re.subn(":(\d+\.\d+)\[(\d+)\]", parse_alrt, raw_nw, flags=re.MULTILINE) except TypeError: raw_nw = raw_nw.replace("\n","") nw, nsubs = re.subn(":(\d+\.\d+)\[(\d+)\]", parse_alrt, raw_nw) if nsubs == 0: log.warning("alrt values were not detected in raxml tree!") tree = Tree(nw) elif self.bootstrap == "alrt_phyml": alrt_tree_file = os.path.join(self.alrt_job.jobdir, self.alg_phylip_file +"_phyml_tree.txt") tree = Tree(alrt_tree_file) else: alrt_tree_file = os.path.join(self.bootd_job.jobdir, "RAxML_bipartitions." + self.bootd_job.args["-n"]) nw = open(alrt_tree_file).read() tree = Tree(nw) tree.support = 100 for n in tree.traverse(): if n.support >1: n.support /= 100. else: n.support = 0 TreeTask.store_data(self, tree.write(), {})
def finish(self): job = self.jobs[-1] t = Tree(job.stdout_file) TreeTask.store_data(self, t.write(), {})