Skip to content

Commit

Permalink
Multiple complementarity rules added and tested.
Browse files Browse the repository at this point in the history
  • Loading branch information
agalitsyna committed Mar 20, 2022
1 parent 18b5dba commit 1a387b4
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 14 deletions.
17 changes: 11 additions & 6 deletions modules/rklib/rk_check_complementary/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ options = initOptions(params.options)
def VERSION = '0.0'

process RKLIB_CHECK_COMPLEMENTARY {
tag "$meta.id"
tag "$meta.id $meta_compl.id"
label 'process_low'
publishDir "${params.outdir}",
mode: params.publish_dir_mode,
Expand All @@ -22,13 +22,14 @@ process RKLIB_CHECK_COMPLEMENTARY {
val(meta_compl)

output:
tuple val(meta), path("*.complHits.tsv"), emit: hits
tuple val(meta), path("*.tsv"), emit: hits
path "*.version.txt" , emit: version


script:
def software = getSoftwareName(task.process)
def prefix = options.suffix ? "${meta.id}${options.suffix}" : "${meta.id}"
def complName = meta_compl.getOrDefault("id", "compl")

def rna_compl_length = meta_compl.length as Integer
def extraN = "N"*(500+3*rna_compl_length)
Expand Down Expand Up @@ -87,13 +88,17 @@ process RKLIB_CHECK_COMPLEMENTARY {
# Merge two tabular outputs:
# 1. Design header
head -n 1 ${prefix}.hits_compl.R1.tsv \\
| sed 's/\\t/_compl_R1\\t/g' | sed 's/\$/_compl_R1/' | sed 's/#//g' | tr '\\n' '\\t' > ${prefix}.complHits.tsv
| sed 's/\\t/_${complName}_R1\\t/g' | sed 's/\$/_${complName}_R1/' | sed 's/#//g' | tr '\\n' '\\t' > ${prefix}.${complName}.tsv
head -n 1 ${prefix}.hits_compl.R2.tsv \\
| sed 's/\\t/_compl_R2\\t/g' | sed 's/\$/_compl_R2/' | sed 's/#//g' | tr '\\n' '\\t' >> ${prefix}.complHits.tsv
sed -i "s/\\t\$/\\n/" ${prefix}.complHits.tsv
| sed 's/\\t/_${complName}_R2\\t/g' | sed 's/\$/_${complName}_R2/' | sed 's/#//g' | tr '\\n' '\\t' >> ${prefix}.${complName}.tsv
sed -i "s/\\t\$/\\n/" ${prefix}.${complName}.tsv
# 2. Write to the body
paste <(tail -n +2 ${prefix}.hits_compl.R1.tsv) \\
<(tail -n +2 ${prefix}.hits_compl.R2.tsv) >> ${prefix}.complHits.tsv
<(tail -n +2 ${prefix}.hits_compl.R2.tsv) >> ${prefix}.${complName}.tsv
# Remove temporary files:
rm ${prefix}.hits_compl.R1.tsv
rm ${prefix}.hits_compl.R2.tsv
echo $VERSION > ${software}.version.txt
"""
Expand Down
28 changes: 21 additions & 7 deletions params-redc.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
input: 'samplesheet_redc.csv' # required
input: 'samplesheet_test.csv' # required
cache: 'lenient'
outdir: "output_redc/"
enable_conda: true
Expand Down Expand Up @@ -106,6 +106,10 @@ oligos:
expected_length: 16
right_to_left: true # Search right-to-left (3'-5') instead of regular left-to-right (5'-3')

# The output of "short_oligos" section will be added to the output stats as:
# oligo_<title>_at_35
# for example:
# oligo_ga_at_35
short_oligos:
ga:
sequence: 'GA'
Expand All @@ -120,13 +124,23 @@ short_oligos:
# position: 0
# side: 2

# The output of the "complementary" section will be added to the output stats as:
# start_hit_<title>_R1, end_hit_<title>_R1, start_hit_<title>_R2, end_hit_<title>_R2
# for example:
# start_hit_compl_R1, end_hit_compl_R1, start_hit_compl_R2, end_hit_compl_R2
complementary:
length: 14
left_side: 1
left_reference_oligo: bridge_forward
right_side: 2
right_reference_oligo: ggg

compl:
length: 14
left_side: 1
left_reference_oligo: bridge_forward
right_side: 2
right_reference_oligo: ggg
# compl_additional:
# length: 8
# left_side: 1
# left_reference_oligo: bridge_forward
# right_side: 2
# right_reference_oligo: ggg

fragments:
# dna_noext:
Expand Down
10 changes: 9 additions & 1 deletion subworkflows/local/oligos_map.nf
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,15 @@ workflow OLIGOS_MAP {
HitsComplementary = Channel.empty()
} else {
/* Step 1: Collect information about left and right side of complementary regions */
ComplementaryInput = Channel.from(params.complementary)
ComplementaryInput = Channel
.from( params.complementary.keySet().withIndex() )
.map { it, idx -> [it, idx, params.complementary[it]] } // meta for each complementary fragment
.map { compl_name, idx, meta ->
meta.id = compl_name
meta.idx = idx
meta.single_end = true
[meta]
}.view()

InputComplementary = TableChunks
.combine(IndexedFastqs)
Expand Down

0 comments on commit 1a387b4

Please sign in to comment.