How to use chunkify method in tempest

Best Python code snippet using tempest_python

chunkify.smk

Source:chunkify.smk Github

copy

Full Screen

1# =================================================================================================2# Chunkify and Unchunkify3# =================================================================================================4# We want the sample names of the output files to fit the naming given by the user.5# In case our input for the samples is a table with two columns, the sample names (first column)6# can be different from the file names. However, the gappa chunkify command uses file names as7# sample names. For now, it is easiest to just symlink to the files to get a list of properly8# named files. In the future, we might add an option to rename samples in gappa chunkify,9# to make this step a bit less convoluted...10rule chunkify_sample_prep:11 input:12 fasta=get_sample_fasta13 output:14 "{outdir}/chunkify/samples/{sample}.fasta"15 shell:16 "ln -s {input.fasta} {output}"17# No need to execute this on the cluster computed nodes.18localrules: chunkify_sample_prep19# The rule to chunkify input fasta samples (query sequences) into chunks of equal size without20# duplicate sequences.21# We need a snakemake checkpoint here, because we cannot predict the number of chunks being produced.22checkpoint chunkify:23 input:24 # Request renamed samples, using the rule above, to get chunkify to use proper sample names.25 expand( "{outdir}/chunkify/samples/{sample}.fasta", outdir=outdir, sample=sample_names )26 output:27 abundances = expand( "{outdir}/chunkify/abundances/abundances_{sample}.json",28 outdir=outdir,29 sample=sample_names30 )31 params:32 chunks_dir = directory("{outdir}/chunkify/chunks"),33 abundances_dir = directory("{outdir}/chunkify/abundances"),34 hashfunction = config["params"]["chunkify"]["hash-function"],35 minabun = config["params"]["chunkify"]["min-abundance"],36 chunksize = config["params"]["chunkify"]["chunk-size"]37 # log:38 # "{outdir}/logs/chunkify.log"39 conda:40 "../envs/gappa.yaml"41 shell:42 "mkdir -p {params.chunks_dir} ;"43 " mkdir -p {params.abundances_dir} ;"44 " gappa prepare chunkify"45 " --fasta-path {input}"46 " --chunks-out-dir {params.chunks_dir}"47 " --abundances-out-dir {params.abundances_dir}"48 " --hash-function {params.hashfunction}"49 " --min-abundance {params.minabun}"50 " --chunk-size {params.chunksize}"51 " > {log} 2>&1"52# Following the documentation tutorial here:53# https://snakemake.readthedocs.io/en/stable/snakefiles/rules.html#data-dependent-conditional-execution54def aggregate_chunkify_chunks(wildcards):55 # Wildcards are ignored here, as the chunkify process is for the whole dataset,56 # so we do not have any wildcards to take into account;57 # but still have to use them in the argument list,58 # because otherwise snakemake complains.59 chunks = checkpoints.chunkify.get().output["chunks"]60 # abundances = checkpoints.chunkify.get().output[1]61 return expand(62 "chunkify/placed/{chunk}.jplace",63 chunk = glob_wildcards( os.path.join(chunks, "{chunk}.fasta")).chunk64 )65rule unchunkify:66 input:67 aggregate_chunkify_chunks,68 expand("{outdir}/chunkify/abundances/abundances_{sample}.json", outdir=outdir, sample=sample_names)69 output:70 protected( expand( "{outdir}/placed/{sample}.jplace", outdir=outdir, sample=sample_names ))71 params:72 hash_function = config["params"]["chunkify"]["hash-function"]73 # log:74 # "{outdir}/logs/unchunkify.log"75 conda:76 "../envs/gappa.yaml"77 shell:78 "gappa prepare unchunkify"79 " --abundances-path {outdir}/chunkify/abundances"80 " --chunk-file-expression {outdir}/chunkify/placed/chunk_@.jplace"81 " --hash-function {params.hash_function}"82 " --out-dir {outdir}/placed"...

Full Screen

Full Screen

chunkify.py

Source:chunkify.py Github

copy

Full Screen

1def chunkify(lst, s):2 n=[lst[(i-1)*s:i*s] for i in range(1,len(lst)+1)]3 return [i for i in n if i]4print(chunkify([2, 3, 4, 5], 2), [[2, 3], [4, 5]])5print(chunkify([2, 3, 4, 5, 6], 2), [[2, 3], [4, 5], [6]])6print(chunkify([2, 3, 4, 5, 6, 7], 3), [[2, 3, 4], [5, 6, 7]])7print(chunkify([2, 3, 4, 5, 6, 7], 1), [[2], [3], [4], [5], [6], [7]] )8print(chunkify([2, 3, 4, 5, 6, 7], 7), [[2, 3, 4, 5, 6, 7]] )9print(chunkify([2, 3, 4, 5], 3), [[2, 3, 4], [5]])10print(chunkify([2, 3, 4, 5, 6, 7, 8], 3), [[2, 3, 4], [5, 6, 7], [8]])...

Full Screen

Full Screen

Automation Testing Tutorials

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.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run tempest automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful