Skip to content
Open
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
8 changes: 8 additions & 0 deletions modules/nf-core/matlock/bam2juicer/environment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
# yaml-language-server: $schema=https://raw.githubusercontent.com/nf-core/modules/master/modules/environment-schema.json
channels:
- conda-forge
- bioconda
dependencies:
- bioconda::matlock=20181227
- bioconda::samtools=1.21
59 changes: 59 additions & 0 deletions modules/nf-core/matlock/bam2juicer/main.nf
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
process MATLOCK_BAM2JUICER {
tag "$meta.id"
label 'process_single'

// WARN: Version information not provided by tool on CLI. Please update the VERSION variable when bumping
conda "${moduleDir}/environment.yml"
container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ?
'https://community-cr-prod.seqera.io/docker/registry/v2/blobs/sha256/59/59df5236cc790cac47380a5654f39052a1cb3f9c7868ed397e4b3205a9fb2776/data':
'community.wave.seqera.io/library/matlock_samtools:3c30bc2808902fde' }"

input:
tuple val(meta), path(input_file)
tuple val(meta2), path(fasta), path(fai)

output:
tuple val(meta), path("*.links.txt") , emit: links_txt
tuple val("${task.process}"), val('samtools'), eval("samtools version | sed '1!d;s/.* //'"), topic: versions, emit: versions_samtools
tuple val("${task.process}"), val('matlock'), val('20181227'), topic: versions, emit: versions_matlock
// WARN: Version information not provided by tool on CLI. Please update the VERSION variable when bumping

when:
task.ext.when == null || task.ext.when

script:
def prefix = task.ext.prefix ?: "${meta.id}.links"
def args2 = task.ext.args2 ?: ''
def input_ext = input_file.extension
def reference = fasta ? "--reference ${fasta}" : ""
def filter_cmd = args2 != '' ? "samtools view --threads $task.cpus $args2 -Sb $input_file $reference > ${prefix}.juicer.bam" : ''
def juicer_input = args2 != '' ? "${prefix}.juicer.${input_ext}" : "$input_file"
def bam_del_cmd = args2 != '' ? "rm ${prefix}.juicer.bam" : ''
"""
$filter_cmd

matlock \\
bam2 \\
juicer \\
$juicer_input \\
${prefix}.txt

$bam_del_cmd
"""

stub:
def prefix = task.ext.prefix ?: "${meta.id}.links"
def args2 = task.ext.args2 ?: ''
def input_ext = input_file.extension
def reference = fasta ? "--reference ${fasta}" : ""
def filter_cmd = args2 != '' ? "samtools view --threads $task.cpus $args2 -Sb $input_file $reference > ${prefix}.juicer.bam" : ''
def juicer_input = args2 != '' ? "${prefix}.juicer.${input_ext}" : "$input_file"
def bam_del_cmd = args2 != '' ? "rm ${prefix}.juicer.bam" : ''
"""
echo "filter command: $filter_cmd"
echo "juicer input: $juicer_input"
echo "bam delete command: $bam_del_cmd"

touch ${prefix}.txt
"""
}
54 changes: 54 additions & 0 deletions modules/nf-core/matlock/bam2juicer/meta.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# yaml-language-server: $schema=https://raw.githubusercontent.com/nf-core/modules/master/modules/meta-schema.json
name: "matlock_bam2juicer"
description: Converts a BAM file to Juicer links format
keywords:
- BAM
- HiC
- juicer
tools:
- "matlock":
description: "Simple tools for working with Hi-C data"
homepage: "https://github.com/phasegenomics/matlock"
documentation: "https://github.com/phasegenomics/matlock"
tool_dev_url: "https://github.com/phasegenomics/matlock"
licence: ["GNU Affero General Public License v3"]
identifier: ""

input:
- - meta:
type: map
description: |
Groovy Map containing sample information
e.g. `[ id:'sample1' ]`
- bam:
type: file
description: Sorted BAM/CRAM/SAM file
pattern: "*.{bam,cram,sam}"
ontologies:
- edam: "http://edamontology.org/format_25722"
- edam: "http://edamontology.org/format_2573"
- edam: "http://edamontology.org/format_3462"

output:
links_txt:
- - meta:
type: map
description: |
Groovy Map containing sample information
e.g. `[ id:'sample1' ]`
- "*.links.txt":
type: file
description: Juicer links file
pattern: "*links.txt"
ontologies: []
versions:
- versions.yml:
type: file
description: File containing software versions
pattern: "versions.yml"
ontologies:
- edam: http://edamontology.org/format_3750 # YAML
authors:
- "@GallVp"
maintainers:
- "@GallVp"
94 changes: 94 additions & 0 deletions modules/nf-core/matlock/bam2juicer/tests/main.nf.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
nextflow_process {

name "Test Process MATLOCK_BAM2JUICER"
script "../main.nf"
config "./nextflow.config"
process "MATLOCK_BAM2JUICER"

tag "modules"
tag "modules_nfcore"
tag "matlock"
tag "matlock/bam2juicer"

test("hongyang - hic - bam - filter") {

when {
params {
filter_args = '-F 3852'
}
process {
"""
input[0] = [
[ id:'test' ], // meta map
file('https://github.com/Plant-Food-Research-Open/assemblyqc/raw/eef371b57bda38fb0ff8167f7a547325c8211c3f/tests/hic/testdata/HYh1h2_Chr01_6000000_6015000.bam', checkIfExists: true),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't really like external data, is there not a suitable bam file in the test-datasets already?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @SPPearce for the review.

This has to be a BAM file from HiC reads. There are HiC reads under nf-core/test-datasets/tree/hic/data. We have two options,

  1. Add a BWA/MEM step under nf-test to first map the reads.
  2. I map locally and upload the BAM to nf-core/test-datasets/tree/modules

I guess the easier solution is 1 but that will add an unnecessary test dependency on BWA/MEM which is a widely used and regularly updated tool. Its maintainer will have to carry the burden of maintaining this module as well.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could just copy this bam into test-datasets, that would also work.

]
input[1] = [ [], [], [] ]
"""
}
}

then {
assertAll(
{ assert process.success },
{ assert snapshot(process.out).match() }
)
}

}

test("hongyang - hic - bam - stub") {

options '-stub'

when {
params {
filter_args = ''
}
process {
"""
input[0] = [
[ id:'test' ], // meta map
file('https://github.com/Plant-Food-Research-Open/assemblyqc/raw/eef371b57bda38fb0ff8167f7a547325c8211c3f/tests/hic/testdata/HYh1h2_Chr01_6000000_6015000.bam', checkIfExists: true),
]
input[1] = [ [], [], [] ]
"""
}
}

then {
assertAll(
{ assert process.success },
{ assert snapshot(process.out).match() }
)
}

}

test("hongyang - hic - bam - filter - stub") {
options '-stub'

when {
params {
filter_args = '-F 3852'
}
process {
"""
input[0] = [
[ id:'test' ], // meta map
file('https://github.com/Plant-Food-Research-Open/assemblyqc/raw/eef371b57bda38fb0ff8167f7a547325c8211c3f/tests/hic/testdata/HYh1h2_Chr01_6000000_6015000.bam', checkIfExists: true),
]
input[1] = [ [], [], [] ]
"""
}
}

then {
assertAll(
{ assert process.success },
{ assert snapshot(process.out).match() }
)
}

}

}
167 changes: 167 additions & 0 deletions modules/nf-core/matlock/bam2juicer/tests/main.nf.test.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
{
"hongyang - hic - bam - filter - stub": {
"content": [
{
"0": [
[
{
"id": "test"
},
"test.links.txt:md5,d41d8cd98f00b204e9800998ecf8427e"
]
],
"1": [
[
"MATLOCK_BAM2JUICER",
"samtools",
"1.21"
]
],
"2": [
[
"MATLOCK_BAM2JUICER",
"matlock",
"20181227"
]
],
"links_txt": [
[
{
"id": "test"
},
"test.links.txt:md5,d41d8cd98f00b204e9800998ecf8427e"
]
],
"versions_matlock": [
[
"MATLOCK_BAM2JUICER",
"matlock",
"20181227"
]
],
"versions_samtools": [
[
"MATLOCK_BAM2JUICER",
"samtools",
"1.21"
]
]
}
],
"meta": {
"nf-test": "0.9.3",
"nextflow": "25.10.4"
},
"timestamp": "2026-03-04T12:27:35.175427"
},
"hongyang - hic - bam - filter": {
"content": [
{
"0": [
[
{
"id": "test"
},
"test.links.txt:md5,567eac1531683649c20d6ed2ef3fa711"
]
],
"1": [
[
"MATLOCK_BAM2JUICER",
"samtools",
"1.21"
]
],
"2": [
[
"MATLOCK_BAM2JUICER",
"matlock",
"20181227"
]
],
"links_txt": [
[
{
"id": "test"
},
"test.links.txt:md5,567eac1531683649c20d6ed2ef3fa711"
]
],
"versions_matlock": [
[
"MATLOCK_BAM2JUICER",
"matlock",
"20181227"
]
],
"versions_samtools": [
[
"MATLOCK_BAM2JUICER",
"samtools",
"1.21"
]
]
}
],
"meta": {
"nf-test": "0.9.3",
"nextflow": "25.10.4"
},
"timestamp": "2026-03-04T12:25:18.772447"
},
"hongyang - hic - bam - stub": {
"content": [
{
"0": [
[
{
"id": "test"
},
"test.links.txt:md5,d41d8cd98f00b204e9800998ecf8427e"
]
],
"1": [
[
"MATLOCK_BAM2JUICER",
"samtools",
"1.21"
]
],
"2": [
[
"MATLOCK_BAM2JUICER",
"matlock",
"20181227"
]
],
"links_txt": [
[
{
"id": "test"
},
"test.links.txt:md5,d41d8cd98f00b204e9800998ecf8427e"
]
],
"versions_matlock": [
[
"MATLOCK_BAM2JUICER",
"matlock",
"20181227"
]
],
"versions_samtools": [
[
"MATLOCK_BAM2JUICER",
"samtools",
"1.21"
]
]
}
],
"meta": {
"nf-test": "0.9.3",
"nextflow": "25.10.4"
},
"timestamp": "2026-03-04T12:27:29.566833"
}
}
5 changes: 5 additions & 0 deletions modules/nf-core/matlock/bam2juicer/tests/nextflow.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
process {
withName: 'MATLOCK_BAM2JUICER' {
ext.args2 = params.filter_args
}
}
Loading