diff --git a/.groovylintrc.json b/.groovylintrc.json index a62439d..2bcd13c 100644 --- a/.groovylintrc.json +++ b/.groovylintrc.json @@ -9,6 +9,9 @@ }, "DuplicateStringLiteral": { "enabled": false + }, + "UnnecessaryGetter": { + "enabled": false } } } diff --git a/CHANGELOG.md b/CHANGELOG.md index ca011a9..ae8910d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +## 0.2.4 + +1. Fixed samplesheets being empty in 0.2.3 +2. Added a filter for rnafusion samplesheets. Samples with less than 1 million reads will now be put in a `nfcore_rnafusion_samplesheet_failed.yaml` file + ## 0.2.3 Added `tissue` samples to the vivar samplesheet diff --git a/build.gradle b/build.gradle index 8f54124..bea53e1 100644 --- a/build.gradle +++ b/build.gradle @@ -6,7 +6,7 @@ dependencies { implementation 'com.squareup.okhttp3:okhttp:5.3.2' } -version = '0.2.3' +version = '0.2.4' nextflowPlugin { nextflowVersion = '25.10.0' diff --git a/src/main/groovy/nfcmgg/plugin/samplesheets/PipelineObserver.groovy b/src/main/groovy/nfcmgg/plugin/samplesheets/PipelineObserver.groovy index bf5cced..1bb9857 100644 --- a/src/main/groovy/nfcmgg/plugin/samplesheets/PipelineObserver.groovy +++ b/src/main/groovy/nfcmgg/plugin/samplesheets/PipelineObserver.groovy @@ -95,12 +95,10 @@ class PipelineObserver implements TraceObserverV2 { * @return the sample name for the given base path */ protected String safeGetSample(String inputBasePath) { - String basePath + String basePath = inputBasePath // Make sure SNP tracking data will be added to the correct sample if (basePath.startsWith('snp_')) { basePath = inputBasePath.replaceFirst('snp_', '') - } else { - basePath = inputBasePath } List possibleSamples = samples .findAll { sample -> basePath.startsWith(sample) }.toList() as List diff --git a/src/main/groovy/nfcmgg/plugin/samplesheets/PreprocessingObserver.groovy b/src/main/groovy/nfcmgg/plugin/samplesheets/PreprocessingObserver.groovy index 1c1272f..2c70bb4 100644 --- a/src/main/groovy/nfcmgg/plugin/samplesheets/PreprocessingObserver.groovy +++ b/src/main/groovy/nfcmgg/plugin/samplesheets/PreprocessingObserver.groovy @@ -38,6 +38,23 @@ class PreprocessingObserver extends PipelineObserver { void onFilePublish(FilePublishEvent event) { String targetName = event.target.name String targetPath = event.target.toUriString() + + // Get metrics after demultiplexing + if (targetPath.endsWith('_SAV_data') && event.source.isDirectory()) { + Path bysamples = event.source.resolve('multiqc_bclconvert_bysample.txt') + if (bysamples.exists()) { + List sampleMetrics = bysamples.splitCsv(header:true, sep:'\t') + sampleMetrics.each { metric -> + String sample = metric['Sample'] + String yield = metric['yield_'] + if (entries.containsKey(sample)) { + entries[sample].add('yield', yield) + } + } + } + } + + // Get specific files switch (targetName) { case ~/^snp_.*\.cram$/: entries[safeGetSample(targetName)].add('snp_cram', targetPath) @@ -103,24 +120,44 @@ class PreprocessingObserver extends PipelineObserver { // // nf-core/rnafusion samplesheet // + + Map rnafusionEntries = entries + .findAll { entry -> + // Only create samplesheet for RNAseqMDG runs of RNA samples that have FASTQ output + entry.value.get('sample_type')?.toLowerCase() == 'rna' && + entry.value.get('tag')?.toLowerCase() == 'rnaseqmdg' && + entry.value.get('fastq_1') + } + List rnafusionKeys = [ + ['id', 'sample'], + 'fastq_1', + 'fastq_2', + 'strandedness', + ['yield', 'reads'] + ] + + // Passed data creator.dump( - entries + rnafusionEntries .findAll { entry -> - // Only create samplesheet for RNAseqMDG runs of RNA samples that have FASTQ output - entry.value.get('sample_type')?.toLowerCase() == 'rna' && - entry.value.get('tag')?.toLowerCase() == 'rnaseqmdg' && - entry.value.get('fastq_1') + entry.value.get('yield').toInteger() >= 1000000 } .values() - *.subKeys([ - ['id', 'sample'], - 'fastq_1', - 'fastq_2', - 'strandedness' - ]), + *.subKeys(rnafusionKeys), location.resolve('nfcore_rnafusion_samplesheet.yaml') ) + // Failed data + creator.dump( + rnafusionEntries + .findAll { entry -> + entry.value.get('yield').toInteger() < 1000000 + } + .values() + *.subKeys(rnafusionKeys), + location.resolve('nfcore_rnafusion_samplesheet_failed.yaml') + ) + // // nf-cmgg/vivar samplesheet // @@ -209,6 +246,7 @@ class PreprocessingObserver extends PipelineObserver { 'library': sampleData.get('library', null), 'sex': sampleData.get('sex', 'U'), 'exomecnv_batch': (sampleData.get('library', null) as String) + '_' + sampleData.get('sex', 'U'), + 'yield': -1 ] }