diff --git a/mess/workflow/rules/preflight/functions.smk b/mess/workflow/rules/preflight/functions.smk index edf0a4a..202e88e 100644 --- a/mess/workflow/rules/preflight/functions.smk +++ b/mess/workflow/rules/preflight/functions.smk @@ -114,24 +114,6 @@ def get_value(value, wildcards): return df.loc[vals, value] -fa_table_cache = {} -def get_random_start(wildcards): - table = checkpoints.split_contigs.get(**wildcards).output[0] - if table not in fa_table_cache: - df = pd.read_csv( - table, - sep="\t", - index_col=["fasta","contig","n"] - ) - fa_table_cache[table] = df - vals=(f"{wildcards.fasta}",f"{wildcards.contig}",int(wildcards.n)) - df = fa_table_cache[table] - return df.loc[vals, "random_start"] - - - - - def get_asm_summary(wildcards): try: table = checkpoints.download_assemblies.get(**wildcards).output[0] diff --git a/mess/workflow/rules/processing/fastas.smk b/mess/workflow/rules/processing/fastas.smk index c24014c..48ef289 100644 --- a/mess/workflow/rules/processing/fastas.smk +++ b/mess/workflow/rules/processing/fastas.smk @@ -64,17 +64,19 @@ if ROTATE > 1: rule rotate_contigs: input: - fa=os.path.join(dir.out.processing, "split", "{fasta}_{contig}.fna"), - df=get_cov_table, + os.path.join(dir.out.processing, "split", "{fasta}_{contig}.fna"), output: - os.path.join(dir.out.processing, "rotate", "{fasta}_{contig}_{n}.fna"), + os.path.join( + dir.out.processing, "rotate", "{sample}", "{fasta}_{contig}_{n}.fna" + ), params: - get_random_start, + lambda wildcards: get_value("random_start", wildcards), log: os.path.join( dir.out.logs, "seqkit", "restart", + "{sample}", "{fasta}_{contig}_{n}.log", ), resources: @@ -88,7 +90,6 @@ if ROTATE > 1: containers.seqkit shell: """ - seqkit restart -i {params} {input.fa} | \ - seqkit seq -i | \ + seqkit restart -i {params} {input} | \\ seqkit replace -p .+ -r {wildcards.contig}_{wildcards.n} > {output} """ diff --git a/mess/workflow/rules/simulate/long_reads.smk b/mess/workflow/rules/simulate/long_reads.smk index c6e4e46..f386d5e 100644 --- a/mess/workflow/rules/simulate/long_reads.smk +++ b/mess/workflow/rules/simulate/long_reads.smk @@ -2,7 +2,9 @@ prefix = os.path.join(dir.out.long, "{sample}", "{fasta}", "{contig}") fasta = os.path.join(dir.out.processing, "split", "{fasta}_{contig}.fna") if ROTATE > 1: prefix = os.path.join(dir.out.long, "{sample}", "{fasta}", "{contig}_{n}") - fasta = os.path.join(dir.out.processing, "rotate", "{fasta}_{contig}_{n}.fna") + fasta = os.path.join( + dir.out.processing, "rotate", "{sample}", "{fasta}_{contig}_{n}.fna" + ) id_prefix = os.path.basename(prefix) if PASSES > 1: diff --git a/mess/workflow/rules/simulate/short_reads.smk b/mess/workflow/rules/simulate/short_reads.smk index 7d60e2a..d1398c1 100644 --- a/mess/workflow/rules/simulate/short_reads.smk +++ b/mess/workflow/rules/simulate/short_reads.smk @@ -38,7 +38,9 @@ if not PAIRED: fasta = os.path.join(dir.out.processing, "split", "{fasta}_{contig}.fna") if ROTATE > 1: - fasta = os.path.join(dir.out.processing, "rotate", "{fasta}_{contig}_{n}.fna") + fasta = os.path.join( + dir.out.processing, "rotate", "{sample}", "{fasta}_{contig}_{n}.fna" + ) rule art_illumina: @@ -56,7 +58,7 @@ rule art_illumina: prefix=fq_prefix, log: os.path.join(dir.out.logs, "art", "{sample}", "{fasta}", "{contig}.log") - if ROTATE == 1 + if not ROTATE == 1 else os.path.join( dir.out.logs, "art", "{sample}", "{fasta}", "{contig}_{n}.log" ),