Skip to content

Commit

Permalink
add prefix with bbmap
Browse files Browse the repository at this point in the history
  • Loading branch information
SilasK committed Jul 27, 2023
1 parent 437d313 commit b9c1779
Showing 1 changed file with 13 additions and 22 deletions.
35 changes: 13 additions & 22 deletions workflow/rules/cobinning.smk
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ rule filter_contigs:
temp("Intermediate/cobinning/filtered_contigs/{sample}.fasta"),
params:
min_length=config["cobining_min_contig_length"],
prefix= lambda wc: wc.sample+ config["cobinning_separator"]
log:
"logs/cobinning/filter_contigs/{sample}.log",
conda:
Expand All @@ -22,8 +23,9 @@ rule filter_contigs:
mem=config["simplejob_mem"],
java_mem=int(config["simplejob_mem"] * JAVA_MEM_FRACTION),
shell:
" reformat.sh in={input} "
" fastaminlen={params.min_length} "
" rename.sh in={input} "
" prefix={params.prefix} addprefix=t addunderscore=f"
" minscaf={params.min_length} "
" out={output} "
" overwrite=true "
" -Xmx{resources.java_mem}G 2> {log} "
Expand Down Expand Up @@ -68,22 +70,11 @@ rule combine_contigs:
"Intermediate/cobinning/{bingroup}/combined_contigs.fasta.gz",
log:
"logs/cobinning/{bingroup}/combine_contigs.log",
params:
seperator=config["cobinning_separator"],
samples=get_samples_of_bingroup,
threads: 1
run:
import gzip as gz

with gz.open(output[0], "wt") as fout:
for sample, input_fasta in zip(params.samples, input.fasta):
with open(input_fasta) as fin:
for line in fin:
# if line is a header add sample name
if line[0] == ">":
line = f">{sample}{params.seperator}" + line[1:]
# write each line to the combined file
fout.write(line)
conda:
"../envs/required_packages.yaml"
threads: config["simplejob_threads"],
shell:
" (cat {input} | pigz -p {threads} > {output} ) 2> {log}"


rule minimap_index:
Expand All @@ -95,7 +86,7 @@ rule minimap_index:
index_size="12G",
resources:
mem=config["mem"], # limited num of fatnodes (>200g)
threads: 3
threads: config["simplejob_threads"],
log:
"logs/cobinning/{bingroup}/minimap_index.log",
benchmark:
Expand All @@ -113,7 +104,7 @@ rule samtools_dict:
dict="Intermediate/cobinning/{bingroup}/combined_contigs.dict",
resources:
mem=config["simplejob_mem"],
ttime=config["runtime"]["simplejob"],
time=config["runtime"]["simplejob"],
threads: 1
log:
"logs/cobinning/{bingroup}/samtools_dict.log",
Expand Down Expand Up @@ -240,7 +231,7 @@ rule parse_vamb_output:
input:
expand(rules.run_vamb.output, bingroup=sampleTable.BinGroup.unique()),
output:
renamed_clusters="Intermediate/cobinning/vamb_clusters.tsv.gz",
renamed_clusters="Binning/vamb/vamb_clusters.tsv.gz",
cluster_atributions=expand(vamb_cluster_attribution_path, sample=SAMPLES),
log:
"logs/cobinning/vamb_parse_output.log",
Expand All @@ -257,7 +248,7 @@ rule parse_vamb_output:

rule vamb:
input:
"Intermediate/cobinning/vamb_clusters.tsv.gz",
"Binning/vamb/vamb_clusters.tsv.gz",
expand("{sample}/binning/vamb/cluster_attribution.tsv", sample=SAMPLES),


Expand Down

0 comments on commit b9c1779

Please sign in to comment.