Ejemplo n.º 1
0
def pipeline(task, wkname, conf=None):
    logindent(2)
    # Points to npr parameters according to task properties
    
    if not task:
        source_seqtype = "aa" if "aa" in GLOBALS["seqtypes"] else "nt"
        npr_conf = IterConfig(conf, wkname,
                              len(GLOBALS["target_species"]),
                              source_seqtype)
        cogconf, cogclass = npr_conf.cog_selector
        initial_task = cogclass(GLOBALS["target_species"], set(),
                                source_seqtype, conf, cogconf)

        initial_task.main_tree = main_tree = None
        initial_task.threadid = generate_runid()
        initial_task.configid = initial_task.threadid
        initial_task.target_wkname = wkname
        # Register node 
        db.add_node(initial_task.threadid, initial_task.nodeid,
                    initial_task.cladeid, initial_task.targets,
                    initial_task.outgroups)
        
        new_tasks = [initial_task]
    else:
        conf = GLOBALS[task.configid]
        npr_conf = IterConfig(conf, wkname, task.size, task.seqtype)
        new_tasks  = process_task(task, wkname, npr_conf, conf['_nodeinfo'])

    process_new_tasks(task, new_tasks, conf)
    logindent(-2)
    
    return new_tasks
Ejemplo n.º 2
0
 def __init__(self, nodeid, task_type, task_name, base_args=None, extra_args=None):
     # I want every tree merge instance to be unique (avoids recycling and
     # undesired collisions between trees from different threads containing
     # the same topology, so I create a random checksum to compute taskid
     extra_args = {} if not extra_args else dict(extra_args)
     extra_args["_treechecksum"] = generate_runid()
     Task.__init__(self, nodeid, task_type, task_name, base_args, extra_args)
Ejemplo n.º 3
0
def pipeline(task, wkname, conf=None):
    logindent(2)

    if not task: # in this case, conf is expected
        source_seqtype = "aa" if "aa" in GLOBALS["seqtypes"] else "nt"
        all_seqs = GLOBALS["target_sequences"]
        initial_task = Msf(set(all_seqs), set(),
                           seqtype=source_seqtype)
            
        initial_task.main_tree = None
        initial_task.threadid = generate_runid()
        initial_task.configid = initial_task.threadid
        initial_task.target_wkname = wkname
        # Register node 
        db.add_node(initial_task.threadid, initial_task.nodeid,
                    initial_task.cladeid, initial_task.target_seqs,
                    initial_task.out_seqs)
        
        new_tasks = [initial_task]
    else:
        conf = GLOBALS[task.configid]                
        npr_conf = IterConfig(conf, wkname, task.size, task.seqtype)
        new_tasks  = process_task(task, wkname, npr_conf, conf["_nodeinfo"])

    process_new_tasks(task, new_tasks, conf)
    logindent(-2)
  
    return new_tasks
Ejemplo n.º 4
0
 def load_jobs(self):
     # I want a single phylognetic tree for each cog
     from nprlib.workflow.genetree import pipeline
     
     for co in self.cogs:
         # Register a new msf task for each COG, using the same
         # config file but opening an new tree reconstruction
         # thread.
         job = Msf(set(co), set(), seqtype = self.seqtype)
         job.main_tree = None
         job.threadid = generate_runid()
         job.configid = self.conf["_configid"]
         # This converts the job in a workflow job. As soon as a
         # task is done, it will be automatically processed and the
         # new tasks will be registered as new jobs.
         job.task_processor = pipeline
         job.target_wkname = self.genetree_workflow
         self.jobs.append(job)
         self.cog_ids.add(job.nodeid)