def _ParallelPCR(counter, abort_event, pcr, mixture_paths):
    parallelize = at_manager(Parallelizer, 'parallelize_work_to_shelf')
    return parallelize(abort_event,
                       False,
                       0.1,
                       run_pcr_from_file(pcr),
                       mixture_paths,
                       counter=counter)
Beispiel #2
0
@author: Allis Tauri <*****@*****.**>
'''

from BioUtils.Tools.Output import simple_timeit
from BioUtils.Tools.UMP import FuncManager, at_manager
from BioUtils.Tools.Multiprocessing import raise_tb_on_error
from BioUtils.Tools.Text import wrap_text, hr

from .PCR_ProductsFinder import PPFManager
from .SearchEngine import mp_better
from .iPCR_Base import iPCR_Base

#manager to isolate forking point in a low-memory process
SearchManager = FuncManager(
    'SearchManager',
    (at_manager(PPFManager, 'find'), at_manager(PPFManager, 'batch_find')))


class iPCR(iPCR_Base):
    '''
    Using PCR_Simulation and SeqDB classes runs PCR simulation with given 
    primers and report results in human readable form in a text file.
    '''
    def __init__(self, *args, **kwargs):
        iPCR_Base.__init__(self, *args, **kwargs)
        self._PCR_Simulation = self._new_PCR_Simulation()
        self._ProductsFinder = self._new_PCR_ProductsFinder()
        self._searcher = SearchManager()
        self._searcher.start()

    #end def
Beispiel #3
0
def _parallel_OV(abort_event, OVCs, mixture_paths):
    parallelize = at_manager(Parallelizer, 'parallelize_both')
    return parallelize(abort_event, False, 0.1, OVCs, mixture_paths)
Beispiel #4
0
    #end def
        
    def __call__(self, mixture_path):
        pcr_results = self._pcr(ShelvedMixture(mixture_path))
        if pcr_results is None: return 1
        return self._compute_prod_C(pcr_results)
#end class

def _parallel_OV(abort_event, OVCs, mixture_paths):
    parallelize = at_manager(Parallelizer, 'parallelize_both')
    return parallelize(abort_event, False, 0.1, OVCs, mixture_paths)
#end def

OVC_Manager   = FuncManager('OVC_Manager', (_parallel_OV,))
SearchManager = FuncManager('SearchManager', 
                            (at_manager(PPFManager, 'matches_to_mixture'), 
                             at_manager(PPFManager, 'find_matches')))


class PCR_Optimizer(iPCR_Base):
    '''
    Repeatedly perform PCR simulation varying parameters 
    to find optimal conditions
    '''

    _PCR_report_suffix = 'PCR-optimization'
    _epsilon = 1e-8 #dx for finite-difference approximation of the gradient
    
    def __init__(self, 
                  abort_event, max_steps, purity, 
                  *args, **kwargs):
Beispiel #5
0
def _ParallelPCR(counter, abort_event, pcr, mixture_paths):
    parallelize = at_manager(Parallelizer, 'parallelize_work_to_shelf')
    return parallelize(abort_event, False, 0.1, run_pcr_from_file(pcr), 
                       mixture_paths, counter=counter)
Beispiel #6
0
def _parallel_OV(abort_event, OVCs, mixture_paths):
    parallelize = at_manager(Parallelizer, 'parallelize_both')
    return parallelize(abort_event, False, 0.1, OVCs, mixture_paths)
Beispiel #7
0
        if pcr_results is None: return 1
        return self._compute_prod_C(pcr_results)


#end class


def _parallel_OV(abort_event, OVCs, mixture_paths):
    parallelize = at_manager(Parallelizer, 'parallelize_both')
    return parallelize(abort_event, False, 0.1, OVCs, mixture_paths)


#end def

OVC_Manager = FuncManager('OVC_Manager', (_parallel_OV, ))
SearchManager = FuncManager('SearchManager', (at_manager(
    PPFManager, 'matches_to_mixture'), at_manager(PPFManager, 'find_matches')))


class PCR_Optimizer(iPCR_Base):
    '''
    Repeatedly perform PCR simulation varying parameters 
    to find optimal conditions
    '''

    _PCR_report_suffix = 'PCR-optimization'
    _epsilon = 1e-8  #dx for finite-difference approximation of the gradient

    def __init__(self, abort_event, max_steps, purity, *args, **kwargs):
        iPCR_Base.__init__(self, abort_event, *args, **kwargs)
        #PCR simulations
        self._PCR_ProductsFinder = self._new_PCR_ProductsFinder()
Beispiel #8
0
@author: Allis Tauri <*****@*****.**>
'''

from BioUtils.Tools.Output import simple_timeit
from BioUtils.Tools.UMP import FuncManager, at_manager
from BioUtils.Tools.Multiprocessing import raise_tb_on_error
from BioUtils.Tools.Text import wrap_text, hr

from .PCR_ProductsFinder import PPFManager
from .SearchEngine import mp_better
from .iPCR_Base import iPCR_Base


#manager to isolate forking point in a low-memory process
SearchManager = FuncManager('SearchManager', 
                            (at_manager(PPFManager, 'find'), 
                             at_manager(PPFManager, 'batch_find')))

class iPCR(iPCR_Base):
    '''
    Using PCR_Simulation and SeqDB classes runs PCR simulation with given 
    primers and report results in human readable form in a text file.
    '''
    
    def __init__(self, *args, **kwargs):
        iPCR_Base.__init__(self, *args, **kwargs)
        self._PCR_Simulation = self._new_PCR_Simulation()
        self._ProductsFinder = self._new_PCR_ProductsFinder()
        self._searcher       = SearchManager()
        self._searcher.start()
    #end def