Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ on:
push:
branches: [main]
pull_request:
branches: [main]

jobs:
# pixi test
Expand Down
32 changes: 16 additions & 16 deletions workflow/rules/apply-model.smk
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ rule fire:
output:
cram="results/{sm}/{sm}-fire-{v}-filtered.cram",
crai="results/{sm}/{sm}-fire-{v}-filtered.cram.crai",
benchmark:
"results/{sm}/additional-outputs-{v}/benchmarks/{sm}-fire-bam.txt"
conda:
DEFAULT_ENV
threads: 32
resources:
mem_mb=32 * 1024,
Expand All @@ -17,10 +21,6 @@ rule fire:
min_ave_msp_size=config.get("min_ave_msp_size", 10),
use_ont=USE_ONT,
flag=FILTER_FLAG,
benchmark:
"results/{sm}/additional-outputs-{v}/benchmarks/{sm}-fire-bam.txt"
conda:
DEFAULT_ENV
shell:
"""
samtools view -@ {threads} -u -F {params.flag} {input.bam} \
Expand All @@ -37,7 +37,7 @@ rule fire:
--input-fmt-option required_fields=0x1bff \
--write-index -o {output.cram}

# check if the cram file has zero reads
# check if the cram file has zero reads
reads_in_header=$(samtools view {output.cram} | head | wc -l || true)
if [ $reads_in_header -eq 0 ]; then
printf "\nNo reads passed filters exiting...\n\nPlease review https://fiberseq.github.io/quick-start.html to make sure the input BAM has been correctly processed.\n\n"
Expand All @@ -51,9 +51,9 @@ rule fire_sites_chrom:
cram=rules.fire.output.cram,
output:
bed=temp("temp/{sm}/chrom/{v}-{chrom}.sorted.bed.gz"),
threads: 4
conda:
DEFAULT_ENV
threads: 4
resources:
mem_mb=16 * 1024,
params:
Expand All @@ -62,13 +62,13 @@ rule fire_sites_chrom:
"""
samtools view -@ {threads} -u {input.cram} {wildcards.chrom} \
| {FT_EXE} fire -t {threads} --extract - \
| LC_ALL=C sort --parallel={threads} \
-k1,1 -k2,2n -k3,3n -k4,4 \
| bioawk -tc hdr '$10<={params.min_fdr}' \
| (grep '\\S' || true) \
| (grep -v '^#' || true) \
| bgzip -@ {threads} \
> {output.bed}
| LC_ALL=C sort --parallel={threads} \
-k1,1 -k2,2n -k3,3n -k4,4 \
| bioawk -tc hdr '$10<={params.min_fdr}' \
| (grep '\\S' || true) \
| (grep -v '^#' || true) \
| bgzip -@ {threads} \
>{output.bed}
"""


Expand All @@ -79,12 +79,12 @@ rule fire_sites:
),
output:
bed="results/{sm}/additional-outputs-{v}/fire-peaks/{sm}-{v}-fire-elements.bed.gz",
threads: 1
conda:
DEFAULT_ENV
threads: 1
shell:
"""
cat {input.beds} > {output.bed}
cat {input.beds} >{output.bed}
"""


Expand All @@ -93,9 +93,9 @@ rule fire_sites_index:
bed=rules.fire_sites.output.bed,
output:
tbi=rules.fire_sites.output.bed + ".tbi",
threads: 1
conda:
DEFAULT_ENV
threads: 1
shell:
"""
tabix -p bed {input.bed}
Expand Down
46 changes: 23 additions & 23 deletions workflow/rules/coverages.smk
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,18 @@ rule genome_bedgraph:
output:
bg=temp("temp/{sm}/coverage/{sm}-{v}.bed.gz"),
tbi=temp("temp/{sm}/coverage/{sm}-{v}.bed.gz.tbi"),
threads: 16
shadow:
"minimal"
conda:
DEFAULT_ENV
threads: 16
shell:
"""
"""
mosdepth -F 4 -f {input.ref} -t {threads} tmp {input.cram}
bgzip -cd tmp.per-base.bed.gz \
| LC_ALL=C sort --parallel={threads} -k1,1 -k2,2n -k3,3n -k4,4 \
| LC_ALL=C sort --parallel={threads} -k1,1 -k2,2n -k3,3n -k4,4 \
| bgzip -@ {threads} \
> {output.bg}
>{output.bg}
tabix -f -p bed {output.bg}
"""

Expand All @@ -33,13 +33,13 @@ rule coverage:
cov="results/{sm}/additional-outputs-{v}/coverage/{sm}-{v}-median-coverage.txt",
minimum="results/{sm}/additional-outputs-{v}/coverage/{sm}-{v}-minimum-coverage.txt",
maximum="results/{sm}/additional-outputs-{v}/coverage/{sm}-{v}-maximum-coverage.txt",
benchmark:
"results/{sm}/additional-outputs-{v}/benchmarks/coverage/{sm}.txt"
conda:
"../envs/python.yaml"
threads: 1
resources:
mem_mb=64 * 1024,
benchmark:
"results/{sm}/additional-outputs-{v}/benchmarks/coverage/{sm}.txt"
params:
coverage_within_n_sd=COVERAGE_WITHIN_N_SD,
min_coverage=MIN_COVERAGE,
Expand All @@ -57,18 +57,18 @@ rule fiber_locations_chromosome:
crai=rules.fire.output.crai,
output:
bed=temp("temp/{sm}/coverage/{v}-{chrom}.fiber-locations.bed.gz"),
threads: 4
conda:
DEFAULT_ENV
threads: 4
shell:
"""
# get fiber locations
(samtools view -@ {threads} -u {input.cram} {wildcards.chrom} \
| {FT_EXE} extract -t {threads} -s --all - \
| hck -F '#ct' -F st -F en -F fiber -F strand -F HP ) \
| hck -F '#ct' -F st -F en -F fiber -F strand -F HP) \
| (grep -v "^#" || true) \
| bgzip -@ {threads} \
> {output.bed}
>{output.bed}
"""


Expand All @@ -91,24 +91,24 @@ rule fiber_locations:
filtered_tbi=temp(
"temp/{sm}/coverage/filtered-for-coverage/{v}-fiber-locations.bed.gz.tbi"
),
threads: 4
conda:
DEFAULT_ENV
threads: 4
params:
max_frac_overlap=0.2,
shell:
"""
cat {input.fibers} > {output.bed}
cat {input.fibers} >{output.bed}
tabix -f -p bed {output.bed}

# get filtered fiber locations
MIN=$(cat {input.minimum})
MAX=$(cat {input.maximum})
bedtools intersect -header -sorted -v -f {params.max_frac_overlap} \
-a {output.bed} \
-b <(bgzip -cd {input.bg} | awk -v MAX="$MAX" -v MIN="$MIN" '$4 <= MIN || $4 >= MAX') \
| bgzip -@ {threads} \
> {output.filtered}
| bgzip -@ {threads} \
>{output.filtered}
tabix -f -p bed {output.filtered}
"""

Expand All @@ -122,9 +122,9 @@ rule exclude_from_shuffle:
fai=ancient(FAI),
output:
bed="results/{sm}/additional-outputs-{v}/coverage/exclude-from-shuffles.bed.gz",
threads: 4
conda:
DEFAULT_ENV
threads: 4
params:
exclude=lambda wc: " ".join(EXCLUDES) if EXCLUDES else "",
shell:
Expand All @@ -139,7 +139,7 @@ rule exclude_from_shuffle:
| bedtools sort \
| bedtools merge \
| bgzip -@ {threads} \
> {output.bed}
>{output.bed}
"""


Expand All @@ -154,12 +154,12 @@ rule unreliable_coverage_regions:
bed_tbi="results/{sm}/additional-outputs-{v}/coverage/unreliable-coverage-regions.bed.gz.tbi",
tmp=temp("temp/{sm}/additional-outputs-{v}/unreliable-coverage-regions.bed"),
bb="results/{sm}/trackHub-{v}/bb/unreliable-coverage-regions.bb",
conda:
DEFAULT_ENV
threads: 4
params:
min_len=MIN_UNRELIABLE_COVERAGE_LEN,
bed3_as=workflow.source_path("../templates/bed3.as"),
conda:
DEFAULT_ENV
shell:
"""
MIN=$(cat {input.minimum})
Expand All @@ -170,15 +170,15 @@ rule unreliable_coverage_regions:
| bedtools merge -i - \
| awk '$3-$2 >= {params.min_len}' \
| bgzip -@ {threads} \
> {output.bed}
>{output.bed}

# bigbed
# for some reason bigtools gives a too many files open error when reading from stdin
bedtools merge -i {output.bed} > {output.tmp}
bedtools merge -i {output.bed} >{output.tmp}
bigtools bedtobigbed \
-s start -a {params.bed3_as} \
{output.tmp} {input.fai} {output.bb}
-s start -a {params.bed3_as} \
{output.tmp} {input.fai} {output.bb}

# index
# index
tabix -f -p bed {output.bed}
"""
20 changes: 10 additions & 10 deletions workflow/rules/decorated-reads.smk
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,20 @@ rule decorate_fibers_chromosome:
output:
bed=temp("temp/{sm}/decorate/{v}-{chrom}.bed.gz"),
decorated=temp("temp/{sm}/decorate/{v}-{chrom}.dec.bed.gz"),
threads: 4
resources:
mem_mb=get_mem_mb,
# the following steps can take a while so this helps the pipeline start this earlier.
priority: 10
conda:
DEFAULT_ENV
threads: 4
resources:
mem_mb=get_mem_mb,
shell:
"""
samtools view -@ {threads} -u {input.cram} {wildcards.chrom} \
| {FT_EXE} track-decorators -t {threads} --bed12 {output.bed} \
| sort -k1,1 -k2,2n -k3,3n -k4,4 \
| bgzip -@ {threads} \
> {output.decorated}
>{output.decorated}
"""


Expand All @@ -41,12 +41,12 @@ rule decorate_fibers_1:
bb="results/{sm}/trackHub-{v}/bb/fire-fibers.bb",
benchmark:
"results/{sm}/additional-outputs-{v}/benchmarks/decorate_fibers_1/{sm}.txt"
threads: 8
resources:
runtime=240,
priority: 10
conda:
DEFAULT_ENV
threads: 8
resources:
runtime=240,
params:
bed_as=workflow.source_path("../templates/bed12_filter.as"),
nzooms=NZOOMS,
Expand Down Expand Up @@ -79,12 +79,12 @@ rule decorate_fibers_2:
#bed=temp("temp/{sm}/trackHub-{v}/bb/fire-fiber-decorators.bed.gz"),
benchmark:
"results/{sm}/additional-outputs-{v}/benchmarks/decorate_fibers_2/{sm}.txt"
threads: 8
resources:
runtime=60 * 16,
priority: 10
conda:
DEFAULT_ENV
threads: 8
resources:
runtime=60 * 16,
params:
dec_as=workflow.source_path("../templates/decoration.as"),
nzooms=NZOOMS,
Expand Down
Loading
Loading