Skip to content

Commit

Permalink
add unmerged into analysis and suport reverse library
Browse files Browse the repository at this point in the history
  • Loading branch information
y9c committed Jun 15, 2023
1 parent c78d8b9 commit cbc0a7b
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 10 deletions.
26 changes: 16 additions & 10 deletions Snakefile
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,12 @@ for s, v2 in config["samples"].items():
else os.path.relpath(os.path.expanduser(v4), WORKDIR)
for k4, v4 in v3.items()
}
if not v2.get("forward_stranded", config["forward_stranded"]):
# swap R1 and R2
SAMPLE2RUN[s][r]["R1"], SAMPLE2RUN[s][r]["R2"] = (
SAMPLE2RUN[s][r]["R2"],
SAMPLE2RUN[s][r]["R1"],
)
for k, v3 in v2.get("bam", {}).items():
SAMPLE2BAM[s][k] = (
os.path.expanduser(v3)
Expand All @@ -107,32 +113,32 @@ rule join_pairend_reads:
input:
lambda wildcards: SAMPLE2RUN[wildcards.sample][wildcards.rn].values(),
output:
m=temp(os.path.join(TEMPDIR, "merged_reads/{sample}_{rn}.fq.gz")),
fq=temp(os.path.join(TEMPDIR, "merged_reads/{sample}_{rn}.fq.gz")),
html="report_reads/joining/{sample}_{rn}.fastp.html",
json="report_reads/joining/{sample}_{rn}.fastp.json",
u1="discarded_reads/{sample}_{rn}_un1.fq.gz"
if config["keep_discarded"]
else temp("discarded_reads/{sample}_{rn}_un1.fq.gz"),
u2="discarded_reads/{sample}_{rn}_un2.fq.gz"
if config["keep_discarded"]
else temp("discarded_reads/{sample}_{rn}_un2.fq.gz"),
params:
m=os.path.join(TEMPDIR, "merged_reads/{sample}_{rn}_merge.fq.gz"),
u1=os.path.join(TEMPDIR, "merged_reads/{sample}_{rn}_u1.fq.gz"),
u2=os.path.join(TEMPDIR, "merged_reads/{sample}_{rn}_u2.fq.gz"),
path_fastp=config["path"]["fastp"],
path_joinFastq=config["path"]["joinFastq"],
threads: 10
run:
if len(input) == 2:
shell(
"""
{params.path_fastp} --thread {threads} \
--disable_adapter_trimming --merge --correction --overlap_len_require 10 --overlap_diff_percent_limit 20 \
-i {input[0]} -I {input[1]} --merged_out {output.m} --out1 {output.u1} --out2 {output.u2} -h {output.html} -j {output.json}
-i {input[0]} -I {input[1]} --merged_out {params.m} --out1 {params.u1} --out2 {params.u2} -h {output.html} -j {output.json}
{params.path_joinFastq} {params.m} {params.u1} {params.u2} {output.fq}
rm -f {params.m} {params.u1} {params.u2}
"""
)
else:
shell(
"""
ln -sfr {input[0]} {output[0]}
touch {output.html} {output.json} {output.u1} {output.u2}
ln -sfr {input[0]} {output.fq}
touch {output.html} {output.json}
"""
)

Expand Down
Binary file added bin/joinFastq
Binary file not shown.
4 changes: 4 additions & 0 deletions config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ trim_polyA: false
# Whether clip match on contamination / gene reference
greedy_mapping: false

# If the library is forward_stranded, true mean the R1 is in the same orientation as RNA
forward_stranded: true

### build in args ###
# if you change build in args, add the whole block rather than some records!!

Expand Down Expand Up @@ -69,6 +72,7 @@ path:
bedtools: /pipeline/micromamba/bin/bedtools
multiqc: /pipeline/micromamba/bin/multiqc
umicollapse: /bin/umicollapse.jar
joinFastq: /pipeline/bin/joinFastq
delfilter: /pipeline/bin/deletionFilter
samfilter: /pipeline/bin/samFilter
cpup: /pipeline/bin/cpup
Expand Down

0 comments on commit cbc0a7b

Please sign in to comment.