Skip to content

Commit

Permalink
[MODIF] fix pairtools subwkflow
Browse files Browse the repository at this point in the history
  • Loading branch information
nservant committed Dec 22, 2023
1 parent fbb7680 commit 66d4791
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 40 deletions.
77 changes: 47 additions & 30 deletions conf/modules.config
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,6 @@ process {
[
path: { "${params.outdir}/hicpro/valid_pairs" },
mode: 'copy',
saveAs: { filename -> filename.equals('versions.yml') ? null : filename },
pattern: "*Pairs"
]
]
Expand All @@ -152,7 +151,6 @@ process {
withName: 'MERGE_STATS' {
publishDir = [
path: { "${params.outdir}/hicpro/stats/${meta.id}" },
saveAs: { filename -> filename.equals('versions.yml') ? null : filename },
mode: 'copy',
pattern: "*stat"
]
Expand Down Expand Up @@ -190,14 +188,17 @@ process {
publishDir = [
path: { "${params.outdir}/bwa" },
saveAs: { filename -> filename.equals('versions.yml') ? null : filename },
mode: 'copy'
mode: 'copy',
enabled: params.save_aligned_intermediates
]
ext.args = params.bwa_opts ?: ''
}

withName: 'PAIRTOOLS_PARSE' {
publishDir = [
enabled: false
path: { "${params.outdir}/pairtools/stats/" },
mode: 'copy',
pattern: "*pairsam.stat"
]
ext.args = { [
'--add-columns mapq',
Expand Down Expand Up @@ -226,49 +227,64 @@ process {
withName: 'PAIRTOOLS_MERGE' {
publishDir = [
enabled: false
]
]
ext.prefix = { "${meta.id}_merged" }
}

withName: 'PAIRTOOLS_DEDUP' {
withName: 'PAIRTOOLS_SPLIT' {
publishDir = [
enabled: false
path: { "${params.outdir}/pairtools" },
saveAs: { filename -> filename.equals('versions.yml') ? null : filename },
mode: 'copy',
pattern: "*pairs.gz",
enabled: params.save_pairs_intermediates
]
ext.args = { "--mark-dups" }
ext.prefix = { "${meta.id}_dedup" }
ext.when = !params.keep_dups
ext.args = { params.save_interaction_bam ? "--output-sam ${meta.id}_pairtools.bam" : '' }
}

withName: 'SAMTOOLS_SORT' {
publishDir = [
path: { "${params.outdir}/pairtools" },
saveAs: { filename -> filename.equals('versions.yml') ? null : filename },
mode: 'copy',
enabled: params.save_pairs_intermediates
]
ext.prefix = { "${meta.id}_pairtools_sorted" }
}

withName: 'PAIRTOOLS_SPLIT' {
publishDir = [
withName: 'SAMTOOLS_INDEX' {
publishDir = [
path: { "${params.outdir}/pairtools" },
saveAs: { filename -> filename.equals('versions.yml') ? null : filename },
mode: 'copy',
enabled: params.save_pairs_intermediates
]
ext.args = { params.save_interaction_bam ? "--output-sam ${meta.id}_pairtools.bam" : '' }
}

withName: 'PAIRTOOLS_DEDUP' {
publishDir = [
path: { "${params.outdir}/pairtools/stats/" },
mode: 'copy',
pattern: "*.pairs.stat"
]
ext.args = { "--mark-dups" }
ext.prefix = { "${meta.id}_dedup" }
ext.when = !params.keep_dups
}

withName: 'PAIRTOOLS_SELECT' {
publishDir = [
[
path: { "${params.outdir}/pairtools/" },
saveAs: { filename -> filename.equals('versions.yml') ? null : filename },
mode: 'copy',
pattern: "*pairs.gz"
],
[
path: { "${params.outdir}/pairtools/stats/" },
mode: 'copy',
pattern: "*stats.txt"
]
path: { "${params.outdir}/pairtools/" },
saveAs: { filename -> filename.equals('versions.yml') ? null : filename },
mode: 'copy',
pattern: "*pairs.gz"
]
ext.args = { [
params.min_mapq > 0 ? "(mapq1>${params.min_mapq} and mapq2>${params.min_mapq})" : '',
params.min_cis_dist > 0 ? " and (abs(pos1-pos2) > ${params.min_cis_dist})" : '',
params.keep_multi ? " and ((pair_type=='UU') or (pair_type=='UR') or (pair_type=='RU') or (pair_type=='MM') or (pair_type=='MU'))" :
" and ((pair_type=='UU') or (pair_type=='UR') or (pair_type=='RU'))",
params.dnase ? '' : " and (abs(int(rfrag1) - int(rfrag2)) > 1)",
params.min_cis_dist > 0 ? " and ((chrom1==chrom2 and abs(pos1-pos2) > ${params.min_cis_dist}) or chrom1!=chrom2)" : '',
params.keep_multi ? " and ((pair_type.upper()=='UU') or (pair_type.upper()=='UR') or (pair_type.upper()=='RU') or (pair_type.upper()=='MM') or (pair_type.upper()=='MU'))" :
" and ((pair_type.upper()=='UU') or (pair_type.upper()=='UR') or (pair_type.upper()=='RU'))",
params.dnase ? '' : " and ((chrom1==chrom2 and abs(int(rfrag1) - int(rfrag2)) > 1) or chrom1!=chrom2)",
//params.min_insert_size > 0 ? " and ( (rfrag_end1 - r1pos) + (rfrag_end2 - r2pos)) > ${params.min_insert_size}" : '',
//params.max_insert_size > 0 ? " and ( (rfrag_end1 - r1pos) + (rfrag_end2 - r2pos)) < ${params.max_insert_size}" : '',
//params.min_restriction_fragment_size > 0 ? " -t ${params.min_restriction_fragment_size}" : '',
Expand All @@ -278,10 +294,11 @@ process {

withName: 'PAIRTOOLS_STATS' {
publishDir = [
path: { "${params.outdir}/pairtools/stats/" },
path: { "${params.outdir}/pairtools/stats/" },
mode: 'copy',
pattern: "*stats.txt"
saveAs: { filename -> filename.equals('versions.yml') ? null : filename }
]
ext.prefix = { "${meta.id}_select.pairs.stat" }
}

withName: 'PAIRIX' {
Expand Down
22 changes: 12 additions & 10 deletions subworkflows/local/pairtools.nf
Original file line number Diff line number Diff line change
Expand Up @@ -68,17 +68,12 @@ workflow PAIRTOOLS {
ch_valid_pairs.multiple
)

PAIRTOOLS_MERGE.out.pairs.mix(ch_valid_pairs.single).view()

PAIRTOOLS_DEDUP(
PAIRTOOLS_MERGE.out.pairs.mix(ch_valid_pairs.single)
)

ch_pairsam2split = params.keep_dups ? PAIRTOOLS_MERGE.out.pairs.mix(ch_valid_pairs.single) : PAIRTOOLS_DEDUP.out.pairs
// Separate pairs/bam files
PAIRTOOLS_SPLIT(
ch_pairsam2split
PAIRTOOLS_MERGE.out.pairs.mix(ch_valid_pairs.single)
)

// Manage BAM files
SAMTOOLS_SORT(
PAIRTOOLS_SPLIT.out.bam
)
Expand All @@ -87,12 +82,19 @@ workflow PAIRTOOLS {
SAMTOOLS_SORT.out.bam
)

PAIRTOOLS_SELECT(
// TODO - add samtools flagstat

PAIRTOOLS_DEDUP(
PAIRTOOLS_SPLIT.out.pairs
)

ch_pairselect = params.keep_dups ? PAIRTOOLS_SPLIT.out.pairs : PAIRTOOLS_DEDUP.out.pairs
PAIRTOOLS_SELECT(
ch_pairselect
)

PAIRTOOLS_STATS(
PAIRTOOLS_SPLIT.out.pairs
PAIRTOOLS_SELECT.out.selected
)

PAIRIX(
Expand Down

0 comments on commit 66d4791

Please sign in to comment.