Best Python code snippet using green
uniform.py
Source:uniform.py  
...64    result = []65    for i in bam_table:66        tissue, marks, filepath, repID = i[1:]67        _ofprefix = '/home/adam/dnase/encode/data/{0}/{1}/{0}.{1}.{2}'.format(marks, tissue, repID)68        result.append(pool.apply_async(bamtotagalin, (marks, filepath, _ofprefix, )))69        finder_ofprefix = '/home/adam/dnase/encode/finder_data/{0}/{1}/{0}.{1}.{2}'.format(marks, tissue, repID)70        result.append(pool.apply_async(finderbam, (marks, filepath, finder_ofprefix, )))71    for _mark in MARKS[1:]:72        for _tissue in TISSUE:73        for _tissue in ['hindbrain']:74            sppfile='./data/{0}/{1}/{0}.{1}.rep1.filt.nodup.sample.15.tagAlign.gz.spp.ccscores'\75                .format(_mark,_tissue)76            frag=[i.rstrip().split('\t') for i in open(sppfile)]77            frag_len = frag[0][2]78            chip_prefix = '/home/adam/dnase/encode/data/{0}/{1}/{0}.{1}'.format(_mark, _tissue)79            control_prefix='/home/adam/dnase/encode/data/ChIP-seq_Control/{0}/ChIP-seq_Control.{0}'.format(_tissue)80            finder_chip_prefix='/home/adam/dnase/encode/finder_data/{0}/{1}/{0}.{1}'.format(_mark, _tissue)81            finder_control_prefix='/home/adam/dnase/encode/finder_data/ChIP-seq_Control/{0}/ChIP-seq_Control.{0}'.format(_tissue)82            result.append(pool.apply_async(Bcp.histone, (chip_prefix, control_prefix, _mark,_tissue, frag_len, )))83            result.append(pool.apply_async(Macs.histone, (chip_prefix,control_prefix,_mark,_tissue, frag_len, )))84            result.append(pool.apply_async(Hotspot.hotspot, (chip_prefix, _mark, _tissue, )))85            result.append(pool.apply_async(Dfilter.histone, (chip_prefix,control_prefix,_mark,_tissue, frag_len, )))86            result.append(pool.apply_async(Finder.histone, (finder_chip_prefix,finder_control_prefix,_mark,_tissue, )))87            result.append(pool.apply_async(Mosaics.histone, (chip_prefix,control_prefix,_mark,_tissue, )))88            result.append(pool.apply_async(Fseq.fseq, (chip_prefix,_mark,_tissue, )))89            result.append(pool.apply_async(Homer.histone, (chip_prefix,control_prefix,_mark,_tissue, frag_len, )))90            result.append(pool.apply_async(Music.histone, (chip_prefix,control_prefix,_mark,_tissue, frag_len, )))91            result.append(pool.apply_async(Rseg.histone, (chip_prefix,control_prefix,_mark,_tissue, frag_len, )))92            93    for _tissue in TISSUE[:5]:94    95        dnase_prefix = '/home/adam/dnase/encode/data/dnase/{0}/dnase.{0}'.format(_tissue)96        result.append(pool.apply_async(Macs.dnase, (dnase_prefix, _tissue, )))97        result.append(pool.apply_async(Hotspot.hotspot, (dnase_prefix, 'dnase', _tissue, )))98        result.append(pool.apply_async(Dfilter.dnase, (dnase_prefix, _tissue, )))99        result.append(pool.apply_async(Fseq.fseq, (dnase_prefix,'dnase',_tissue, )))100        result.append(pool.apply_async(Homer.dnase, (dnase_prefix,_tissue, )))101        102    pool.close()103    pool.join()...example.py
Source:example.py  
1# This example is about the problem of carrying extra state around2# through callback functions.   To test the examples, this very3# simple code emulates the typical control of a callback.4def apply_async(func, args, *, callback):5    # Compute the result6    result = func(*args)7    # Invoke the callback with the result8    callback(result)9# A simple function for testing10def add(x, y):11    return x + y12# (a) A simple callback example13print('# --- Simple Example')14def print_result(result):15    print("Got:", result)16apply_async(add, (2, 3), callback=print_result)17apply_async(add, ('hello', 'world'), callback=print_result)18# (b) Using a bound method19print('# --- Using a bound-method')20class ResultHandler:21    def __init__(self):22        self.sequence = 023    def handler(self, result):24        self.sequence += 125        print('[{}] Got: {}'.format(self.sequence, result))26r = ResultHandler()27apply_async(add, (2, 3), callback=r.handler)28apply_async(add, ('hello', 'world'), callback=r.handler)29# (c) Using a closure30print('# --- Using a closure')31def make_handler():32    sequence = 033    def handler(result):34        nonlocal sequence35        sequence += 136        print('[{}] Got: {}'.format(sequence, result))37    return handler38handler = make_handler()39apply_async(add, (2, 3), callback=handler)40apply_async(add, ('hello', 'world'), callback=handler)41# (d) Using a coroutine42print('# --- Using a coroutine')43def make_handler():44    sequence = 045    while True:46        result = yield47        sequence += 148        print('[{}] Got: {}'.format(sequence, result))49handler = make_handler()50next(handler)    # Advance to the yield51apply_async(add, (2, 3), callback=handler.send)52apply_async(add, ('hello', 'world'), callback=handler.send)53# (e) Partial function application54print('# --- Using partial')55class SequenceNo:56    def __init__(self):57        self.sequence = 058def handler(result, seq):59    seq.sequence += 160    print('[{}] Got: {}'.format(seq.sequence, result))61seq = SequenceNo()62from functools import partial63apply_async(add, (2, 3), callback=partial(handler, seq=seq))...Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!
