Skip to content

Commit 0e5cb48

Browse files
committed
split to #26
1 parent 15bf58b commit 0e5cb48

File tree

3 files changed

+0
-238
lines changed

3 files changed

+0
-238
lines changed

src/main/groovy/nfcore/plugin/NfUtilsExtension.groovy

Lines changed: 0 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ import nfcore.plugin.nfcore.NfcoreConfigValidator
2323
import nfcore.plugin.nfcore.NfcoreVersionUtils
2424
import nfcore.plugin.nfcore.NfcoreCitationUtils
2525
import nfcore.plugin.nfcore.NfcoreReportingOrchestrator
26-
import nfcore.plugin.ReferencesUtils
2726

2827
/**
2928
* Implements a custom function which can be imported by
@@ -48,20 +47,6 @@ class NfUtilsExtension extends PluginExtensionPoint {
4847
println "Hello, ${target}!"
4948
}
5049

51-
/**
52-
* Get a genome attribute from params.genomes for the selected genome.
53-
* Delegates to ReferencesUtils.getGenomeAttribute().
54-
*
55-
* @param attribute The attribute name to retrieve (e.g. 'fasta', 'gtf')
56-
* @return The attribute value or null
57-
*/
58-
@Function
59-
Object getGenomeAttribute(String attribute) {
60-
Map params = session?.getConfig()?.get('params') as Map
61-
if (!params) params = session?.params as Map
62-
return ReferencesUtils.getGenomeAttribute(params, attribute)
63-
}
64-
6550
// --- Methods from NfcoreExtension ---
6651
/**
6752
* Generate methods description text for MultiQC report
@@ -275,50 +260,6 @@ class NfUtilsExtension extends PluginExtensionPoint {
275260
return NfcoreVersionUtils.workflowVersionToChannel(this.session)
276261
}
277262

278-
/**
279-
* Combine versions from mixed sources into a single YAML string
280-
* Works with both channels and lists
281-
* When given a channel, returns a channel that emits the combined YAML
282-
* When given a list, returns the YAML string directly
283-
*
284-
* Supports multiple calling patterns:
285-
* 1. Named parameters: softwareVersionsToYAML(softwareVersions: channel, nextflowVersion: workflow.nextflow.version)
286-
* 2. Positional: softwareVersionsToYAML(channel)
287-
* 3. Mixed: softwareVersionsToYAML(channel, nextflowVersion: workflow.nextflow.version)
288-
*
289-
* @param versionsOrOptions Either a channel/list of versions, or a Map with 'softwareVersions' and optional 'nextflowVersion' keys
290-
* @param options Optional map with 'nextflowVersion' key
291-
* @return Channel emitting combined YAML string, or String directly if input is a list
292-
*/
293-
@Function
294-
Object softwareVersionsToYAML(Object versionsOrOptions, Map options = [:]) {
295-
// Extract versions channel/list and nextflowVersion
296-
Object versions = null
297-
def nextflowVersion = options?.nextflowVersion
298-
299-
// Handle named parameters: softwareVersionsToYAML(softwareVersions: ch, nextflowVersion: v)
300-
if (versionsOrOptions instanceof Map && versionsOrOptions.containsKey('softwareVersions')) {
301-
versions = versionsOrOptions.softwareVersions
302-
nextflowVersion = versionsOrOptions.nextflowVersion ?: nextflowVersion
303-
}
304-
// Handle positional: softwareVersionsToYAML(ch) or softwareVersionsToYAML(ch, nextflowVersion: v)
305-
else {
306-
versions = versionsOrOptions
307-
}
308-
309-
// If it's a channel, return a mapped channel
310-
if (versions?.getClass()?.getName()?.contains('DataflowBroadcast') ||
311-
versions?.getClass()?.getName()?.contains('DataflowStream') ||
312-
versions?.getClass()?.getName()?.contains('DataflowVariable')) {
313-
return versions.toList().map { versionsList ->
314-
// Call with positional arguments in the correct order
315-
NfcoreVersionUtils.softwareVersionsToYAML(versionsList as List, this.session as Session, nextflowVersion)
316-
}
317-
}
318-
// If it's a list, process directly
319-
return NfcoreVersionUtils.softwareVersionsToYAML(versions as List, this.session as Session, nextflowVersion)
320-
}
321-
322263
// --- Citation Management Functions ---
323264
/**
324265
* Generate citation for a tool from meta.yml at the module level

src/main/groovy/nfcore/plugin/references/ReferencesUtils.groovy

Lines changed: 0 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -32,54 +32,6 @@ class ReferencesUtils {
3232
this.session = session
3333
}
3434

35-
/**
36-
* Instance convenience method that reads params from the initialized Session
37-
* and delegates to the static getGenomeAttribute(Map, String) implementation.
38-
*
39-
* Usage (when ReferencesUtils has been initialized with a Session):
40-
* def utils = new ReferencesUtils()
41-
* utils.init(session)
42-
* utils.getGenomeAttribute('fasta')
43-
*/
44-
Object getGenomeAttribute(String attribute) {
45-
Map params = session?.getConfig()?.get('params') as Map
46-
// Fallback: some Nextflow Session implementations expose params directly
47-
if (!params) params = session?.params as Map
48-
if (params) return ReferencesUtils.getGenomeAttribute(params, attribute)
49-
return null
50-
}
51-
52-
/**
53-
* Return the named attribute for the selected genome in params, or null.
54-
* Returns a single value (not wrapped in a List).
55-
*
56-
* Example:
57-
* def fasta = ReferencesUtils.getGenomeAttribute(params, 'fasta')
58-
*/
59-
static Object getGenomeAttribute(Map params, String attribute) {
60-
if (params == null) return null
61-
62-
final Object genomesObj = params.get('genomes')
63-
final Object genomeKeyObj = params.get('genome')
64-
65-
if (!(genomesObj instanceof Map) || !(genomeKeyObj instanceof String)) {
66-
return null
67-
}
68-
69-
final Map genomes = (Map) genomesObj
70-
final String genomeKey = (String) genomeKeyObj
71-
72-
if (!genomes.containsKey(genomeKey)) return null
73-
74-
final Object genomeObj = genomes.get(genomeKey)
75-
if (!(genomeObj instanceof Map)) return null
76-
77-
final Map genome = (Map) genomeObj
78-
if (!genome.containsKey(attribute)) return null
79-
80-
return genome.get(attribute)
81-
}
82-
8335
/**
8436
* Get references file from a references list or parameters
8537
*

src/test/groovy/nfcore/plugin/references/ReferencesUtilsTest.groovy

Lines changed: 0 additions & 131 deletions
Original file line numberDiff line numberDiff line change
@@ -55,135 +55,4 @@ class ReferencesUtilsTest extends Specification {
5555
result_file == [null]
5656
result_value == [null]
5757
}
58-
59-
def "test getGenomeAttribute with valid params"() {
60-
given:
61-
def params = [
62-
genome: 'GRCh38',
63-
genomes: [
64-
GRCh38: [
65-
fasta: 's3://bucket/genome.fa',
66-
gtf: 's3://bucket/genes.gtf',
67-
star: 's3://bucket/star_index/'
68-
],
69-
GRCh37: [
70-
fasta: 's3://bucket/genome37.fa'
71-
]
72-
]
73-
]
74-
75-
when:
76-
def fasta = ReferencesUtils.getGenomeAttribute(params, 'fasta')
77-
def gtf = ReferencesUtils.getGenomeAttribute(params, 'gtf')
78-
def star = ReferencesUtils.getGenomeAttribute(params, 'star')
79-
80-
then:
81-
fasta == 's3://bucket/genome.fa'
82-
gtf == 's3://bucket/genes.gtf'
83-
star == 's3://bucket/star_index/'
84-
}
85-
86-
def "test getGenomeAttribute with missing attribute"() {
87-
given:
88-
def params = [
89-
genome: 'GRCh38',
90-
genomes: [
91-
GRCh38: [
92-
fasta: 's3://bucket/genome.fa'
93-
]
94-
]
95-
]
96-
97-
when:
98-
def result = ReferencesUtils.getGenomeAttribute(params, 'gtf')
99-
100-
then:
101-
result == null
102-
}
103-
104-
def "test getGenomeAttribute with missing genome"() {
105-
given:
106-
def params = [
107-
genome: 'GRCh99',
108-
genomes: [
109-
GRCh38: [
110-
fasta: 's3://bucket/genome.fa'
111-
]
112-
]
113-
]
114-
115-
when:
116-
def result = ReferencesUtils.getGenomeAttribute(params, 'fasta')
117-
118-
then:
119-
result == null
120-
}
121-
122-
def "test getGenomeAttribute with null params"() {
123-
when:
124-
def result = ReferencesUtils.getGenomeAttribute(null, 'fasta')
125-
126-
then:
127-
result == null
128-
}
129-
130-
def "test getGenomeAttribute with missing genomes map"() {
131-
given:
132-
def params = [
133-
genome: 'GRCh38'
134-
]
135-
136-
when:
137-
def result = ReferencesUtils.getGenomeAttribute(params, 'fasta')
138-
139-
then:
140-
result == null
141-
}
142-
143-
def "test getGenomeAttribute with missing genome key"() {
144-
given:
145-
def params = [
146-
genomes: [
147-
GRCh38: [
148-
fasta: 's3://bucket/genome.fa'
149-
]
150-
]
151-
]
152-
153-
when:
154-
def result = ReferencesUtils.getGenomeAttribute(params, 'fasta')
155-
156-
then:
157-
result == null
158-
}
159-
160-
def "test getGenomeAttribute with different value types"() {
161-
given:
162-
def params = [
163-
genome: 'test',
164-
genomes: [
165-
test: [
166-
string_value: 'some_string',
167-
list_value: ['item1', 'item2'],
168-
map_value: [key: 'value'],
169-
number_value: 42,
170-
boolean_value: true
171-
]
172-
]
173-
]
174-
175-
when:
176-
def string_result = ReferencesUtils.getGenomeAttribute(params, 'string_value')
177-
def list_result = ReferencesUtils.getGenomeAttribute(params, 'list_value')
178-
def map_result = ReferencesUtils.getGenomeAttribute(params, 'map_value')
179-
def number_result = ReferencesUtils.getGenomeAttribute(params, 'number_value')
180-
def boolean_result = ReferencesUtils.getGenomeAttribute(params, 'boolean_value')
181-
182-
then:
183-
string_result == 'some_string'
184-
list_result == ['item1', 'item2']
185-
map_result == [key: 'value']
186-
number_result == 42
187-
boolean_result == true
188-
}
18958
}

0 commit comments

Comments
 (0)