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
20 changes: 11 additions & 9 deletions modules/nf-core/custom/orfnormalise/templates/orfnormalise.py
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,8 @@ def _parse_ribotish_genpos(s):
m = _RIBOTISH_GENPOS_RE.match(s.strip())
if not m:
return None
return m.group(1), int(m.group(2)) - 1, int(m.group(3)), m.group(4)
# GenomePos is 0-based half-open (BED-style).
return m.group(1), int(m.group(2)), int(m.group(3)), m.group(4)


def parse_ribotish(path, transcripts, fields):
Expand Down Expand Up @@ -551,15 +552,16 @@ def parse_ribotish(path, transcripts, fields):
continue
chrom, start, end, strand = gp

blocks = parse_intervals(row.get("Blocks", ""), seps=(":", "-"))
if not blocks:
tx = transcripts.get(tid)
if tx is None:
# ribotish predict reports one genomic span (GenomePos), not
# per-exon blocks, so the exon structure is recovered by
# intersecting that span with the transcript's exons.
tx = transcripts.get(tid)
if tx is None:
blocks = [(start, end)]
else:
blocks = [(max(start, gs), min(end, ge)) for gs, ge in tx.exons if min(end, ge) > max(start, gs)]
if not blocks:
blocks = [(start, end)]
else:
blocks = [(max(start, gs), min(end, ge)) for gs, ge in tx.exons if min(end, ge) > max(start, gs)]
if not blocks:
blocks = [(start, end)]

rows.append(
{
Expand Down
22 changes: 16 additions & 6 deletions modules/nf-core/custom/orfnormalise/tests/main.nf.test
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ nextflow_process {
"""
input[0] = channel.of([
[id: 'sample1'],
file('https://raw.githubusercontent.com/pinin4fjords/test-datasets/add-orf-prediction-fixtures/data/genomics/homo_sapiens/riboseq_expression/orf_predictions/sample1.ribocode.txt', checkIfExists: true),
file(params.modules_testdata_base_path + 'genomics/homo_sapiens/riboseq_expression/orf_predictions/sample1.ribocode.txt', checkIfExists: true),
'ribocode'
])
input[1] = channel.of([
Expand All @@ -39,6 +39,8 @@ nextflow_process {
assertAll(
{ assert process.success },
{ assert snapshot(process.out).match() },
// every ORF must span a whole number of codons (frame guard)
{ assert path(process.out.bed12[0][1]).text.readLines().findAll { it.trim() }.every { it.split('\t')[10].split(',').findAll { s -> s }.collect { s -> s.toInteger() }.sum() % 3 == 0 } },
{ assert rows.size() > 0 },
{ assert rows.every { it[aa].toInteger() > 0 } },
{ assert rows.every { it[score] && it[score] != '' } },
Expand All @@ -57,7 +59,7 @@ nextflow_process {
"""
input[0] = channel.of([
[id: 'sample1'],
file('https://raw.githubusercontent.com/pinin4fjords/test-datasets/add-orf-prediction-fixtures/data/genomics/homo_sapiens/riboseq_expression/orf_predictions/sample1.ribotish.pred.txt', checkIfExists: true),
file(params.modules_testdata_base_path + 'genomics/homo_sapiens/riboseq_expression/orf_predictions/sample1.ribotish.pred.txt', checkIfExists: true),
'ribotish'
])
input[1] = channel.of([
Expand All @@ -80,6 +82,8 @@ nextflow_process {
assertAll(
{ assert process.success },
{ assert snapshot(process.out).match() },
// every ORF must span a whole number of codons (frame guard)
{ assert path(process.out.bed12[0][1]).text.readLines().findAll { it.trim() }.every { it.split('\t')[10].split(',').findAll { s -> s }.collect { s -> s.toInteger() }.sum() % 3 == 0 } },
{ assert rows.size() > 0 },
{ assert rows.every { it[aa].toInteger() > 0 } },
{ assert rows.every { it[score] && it[score] != '' } },
Expand All @@ -95,7 +99,7 @@ nextflow_process {
"""
input[0] = channel.of([
[id: 'sample1'],
file('https://raw.githubusercontent.com/pinin4fjords/test-datasets/add-orf-prediction-fixtures/data/genomics/homo_sapiens/riboseq_expression/orf_predictions/sample1.ribotricer.tsv', checkIfExists: true),
file(params.modules_testdata_base_path + 'genomics/homo_sapiens/riboseq_expression/orf_predictions/sample1.ribotricer.tsv', checkIfExists: true),
'ribotricer'
])
input[1] = channel.of([
Expand Down Expand Up @@ -123,6 +127,8 @@ nextflow_process {
assertAll(
{ assert process.success },
{ assert snapshot(process.out).match() },
// every ORF must span a whole number of codons (frame guard)
{ assert path(process.out.bed12[0][1]).text.readLines().findAll { it.trim() }.every { it.split('\t')[10].split(',').findAll { s -> s }.collect { s -> s.toInteger() }.sum() % 3 == 0 } },
{ assert rows.size() > 0 },
{ assert rows.every { it[aa].toInteger() > 0 } },
{ assert rows.every { it[score] && it[score] != '' } },
Expand All @@ -139,7 +145,7 @@ nextflow_process {
"""
input[0] = channel.of([
[id: 'sample1'],
file('https://raw.githubusercontent.com/pinin4fjords/test-datasets/add-orf-prediction-fixtures/data/genomics/homo_sapiens/riboseq_expression/orf_predictions/sample1.rpbp.predicted-orfs.bed.gz', checkIfExists: true),
file(params.modules_testdata_base_path + 'genomics/homo_sapiens/riboseq_expression/orf_predictions/sample1.rpbp.predicted-orfs.bed.gz', checkIfExists: true),
'rpbp'
])
input[1] = channel.of([
Expand All @@ -162,6 +168,8 @@ nextflow_process {
assertAll(
{ assert process.success },
{ assert snapshot(process.out).match() },
// every ORF must span a whole number of codons (frame guard)
{ assert path(process.out.bed12[0][1]).text.readLines().findAll { it.trim() }.every { it.split('\t')[10].split(',').findAll { s -> s }.collect { s -> s.toInteger() }.sum() % 3 == 0 } },
{ assert rows.size() > 0 },
{ assert rows.every { it[aa].toInteger() > 0 } },
{ assert rows.every { it[score] && it[score] != '' && it[score].toDouble() > 0 } },
Expand All @@ -179,7 +187,7 @@ nextflow_process {
"""
input[0] = channel.of([
[id: 'cohort'],
file('https://raw.githubusercontent.com/pinin4fjords/test-datasets/add-orf-prediction-fixtures/data/genomics/homo_sapiens/riboseq_expression/orf_predictions/cohort.price.orfs.tsv', checkIfExists: true),
file(params.modules_testdata_base_path + 'genomics/homo_sapiens/riboseq_expression/orf_predictions/cohort.price.orfs.tsv', checkIfExists: true),
'price'
])
input[1] = channel.of([
Expand All @@ -206,6 +214,8 @@ nextflow_process {
assertAll(
{ assert process.success },
{ assert snapshot(process.out).match() },
// every ORF must span a whole number of codons (frame guard)
{ assert path(process.out.bed12[0][1]).text.readLines().findAll { it.trim() }.every { it.split('\t')[10].split(',').findAll { s -> s }.collect { s -> s.toInteger() }.sum() % 3 == 0 } },
{ assert rows.size() > 0 },
{ assert rows.every { it[aa].toInteger() > 0 } },
{ assert rows.collect { it[cls] }.toSet().any { it != 'other' } },
Expand All @@ -222,7 +232,7 @@ nextflow_process {
"""
input[0] = channel.of([
[id: 'sample1'],
file('https://raw.githubusercontent.com/pinin4fjords/test-datasets/add-orf-prediction-fixtures/data/genomics/homo_sapiens/riboseq_expression/orf_predictions/sample1.ribotish.pred.txt', checkIfExists: true),
file(params.modules_testdata_base_path + 'genomics/homo_sapiens/riboseq_expression/orf_predictions/sample1.ribotish.pred.txt', checkIfExists: true),
'ribotish'
])
input[1] = channel.of([
Expand Down
32 changes: 16 additions & 16 deletions modules/nf-core/custom/orfnormalise/tests/main.nf.test.snap
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,11 @@
]
}
],
"timestamp": "2026-06-12T13:07:41.301245",
"meta": {
"nf-test": "0.9.5",
"nextflow": "25.10.4"
}
},
"timestamp": "2026-06-12T13:07:41.301245"
},
"homo_sapiens [chr20] - rpbp": {
"content": [
Expand Down Expand Up @@ -91,11 +91,11 @@
]
}
],
"timestamp": "2026-06-12T13:07:53.372563",
"meta": {
"nf-test": "0.9.5",
"nextflow": "25.10.4"
}
},
"timestamp": "2026-06-12T13:07:53.372563"
},
"homo_sapiens [chr20] - ribocode": {
"content": [
Expand Down Expand Up @@ -140,11 +140,11 @@
]
}
],
"timestamp": "2026-06-12T13:07:17.199267",
"meta": {
"nf-test": "0.9.5",
"nextflow": "25.10.4"
}
},
"timestamp": "2026-06-12T13:07:17.199267"
},
"homo_sapiens [chr20] - ribotish": {
"content": [
Expand All @@ -154,15 +154,15 @@
{
"id": "sample1"
},
"sample1.normalised.bed12:md5,83e35410ce60f5289a4956016ea81534"
"sample1.normalised.bed12:md5,1b3cb2249df360840aa062001653a85e"
]
],
"1": [
[
{
"id": "sample1"
},
"sample1.normalised.tsv:md5,b0ec626bdb9a80f7ae8450067fe059c8"
"sample1.normalised.tsv:md5,5b52abd1e50bab3722b50e4bbf379902"
]
],
"2": [
Expand All @@ -173,27 +173,27 @@
{
"id": "sample1"
},
"sample1.normalised.bed12:md5,83e35410ce60f5289a4956016ea81534"
"sample1.normalised.bed12:md5,1b3cb2249df360840aa062001653a85e"
]
],
"tsv": [
[
{
"id": "sample1"
},
"sample1.normalised.tsv:md5,b0ec626bdb9a80f7ae8450067fe059c8"
"sample1.normalised.tsv:md5,5b52abd1e50bab3722b50e4bbf379902"
]
],
"versions": [
"versions.yml:md5,e7fc396424c69f0969daec4a45c3de70"
]
}
],
"timestamp": "2026-06-12T13:07:28.989952",
"meta": {
"nf-test": "0.9.5",
"nextflow": "25.10.4"
}
"nf-test": "0.9.3",
"nextflow": "25.04.8"
},
"timestamp": "2026-06-26T13:34:16.887667785"
},
"homo_sapiens [chr19+chr22] - price": {
"content": [
Expand Down Expand Up @@ -238,10 +238,10 @@
]
}
],
"timestamp": "2026-06-12T13:07:59.997149",
"meta": {
"nf-test": "0.9.5",
"nextflow": "25.10.4"
}
},
"timestamp": "2026-06-12T13:07:59.997149"
}
}
Loading