Skip to content

Commit

Permalink
[MODIF] add pairtools nf-core#162
Browse files Browse the repository at this point in the history
  • Loading branch information
nservant committed Jun 15, 2023
1 parent 8d40b36 commit a4a546e
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 9 deletions.
13 changes: 8 additions & 5 deletions bin/digest_genome.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ def replaceN(cs):
"specified."
),
)
parser.add_argument("--extra", default=False, action='store_false', help="Add extra BED columns")
parser.add_argument("-o", "--out", default=None)
args = parser.parse_args()

Expand Down Expand Up @@ -193,8 +194,10 @@ def replaceN(cs):
# allow to remove cases where the enzyme cut at
# the first position of the chromosome
if end > begin:
frag_id += 1
frag_name = "HIC_{}_{}".format(str(chrom_name), int(frag_id))
outfile.write(
"{}\t{}\t{}\t{}\t0\t+\n".format(str(chrom_name), int(begin), int(end), str(frag_name))
)
if args.extra:
frag_id += 1
frag_name = "HIC_{}_{}".format(str(chrom_name), int(frag_id))
outfile.write("{}\t{}\t{}\t{}\t0\t+\n".format(str(chrom_name), int(begin), int(end), str(frag_name)))
else:
outfile.write("{}\t{}\t{}\n".format(str(chrom_name), int(begin), int(end)))

10 changes: 9 additions & 1 deletion conf/modules.config
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ process {
mode: 'copy',
enabled: params.save_reference
]
ext.args = params.processing == "hicpro" ? '--extra' : ''
}

//*******************************************
Expand Down Expand Up @@ -182,8 +183,15 @@ process {
}

withName: 'PAIRTOOLS_PARSE' {
ext.args = { "--min-mapq 40 --walks-policy 5unique --max-inter-align-gap 30 --output-stats ${meta.id}_parse.stats --add-columns mapq --drop-sam --drop-seq" }
ext.args = { [
'--add-columns mapq',
params.save_interaction_bam ? '' : '--drop-sam --drop-seq',
"--walks-policy 5unique --output-stats ${meta.id}_parse.stats"
].join(' ').trim() }
}

withName: 'PAIRTOOLS_RESTRICT' {
ext.prefix = { "${meta.id}_restrict" }
}

withName: 'PAIRTOOLS_DEDUP' {
Expand Down
4 changes: 3 additions & 1 deletion modules/local/hicpro/get_restriction_fragments.nf
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@ process GET_RESTRICTION_FRAGMENTS {
path("versions.yml"), emit: versions

script:
def args = task.ext.args ?: ''
def prefix = task.ext.prefix ?: "restriction_fragments"
"""
digest_genome.py -r ${res_site} -o restriction_fragments.bed ${fasta}
digest_genome.py ${args} -r ${res_site} -o ${prefix}.bed ${fasta}
cat <<-END_VERSIONS > versions.yml
"${task.process}":
Expand Down
10 changes: 8 additions & 2 deletions subworkflows/local/pairtools.nf
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ workflow PAIRTOOLS {
take:
reads // [meta, read1, read2]
index // [meta2, path]
frag
chrsize // path

main:
Expand All @@ -39,16 +40,21 @@ workflow PAIRTOOLS {
BWA_MEM(
reads,
index,
Channel.value("view")
Channel.value("false")
)

PAIRTOOLS_PARSE(
BWA_MEM.out.bam,
chrsize
)

PAIRTOOLS_RESTRICT(
PAIRTOOLS_PARSE.out.pairsam,
frag.map{it->it[1]}
)

PAIRTOOLS_SORT(
PAIRTOOLS_PARSE.out.pairsam
PAIRTOOLS_RESTRICT.out.restrict
)

ch_valid_pairs = PAIRTOOLS_SORT.out.sorted.map{ it -> removeChunks(it)}.groupTuple()
Expand Down
1 change: 1 addition & 0 deletions workflows/hic.nf
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ workflow HIC {
PAIRTOOLS(
INPUT_CHECK.out.reads,
PREPARE_GENOME.out.index,
PREPARE_GENOME.out.res_frag,
PREPARE_GENOME.out.chromosome_size
)
ch_versions = ch_versions.mix(PAIRTOOLS.out.versions)
Expand Down

0 comments on commit a4a546e

Please sign in to comment.