Skip to content

Commit

Permalink
Merge pull request #124 from drpatelh/fixes
Browse files Browse the repository at this point in the history
Fix #114
  • Loading branch information
drpatelh authored Nov 7, 2022
2 parents 42aeaf3 + 12e8b85 commit 44901cf
Showing 3 changed files with 71 additions and 46 deletions.
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Enhancements & fixes

- [#111](https://github.com/nf-core/fetchngs/issues/111) - Change input mimetype to csv
- [#114](https://github.com/nf-core/fetchngs/issues/114) - Final samplesheet is not created when `--skip_fastq_download` is provided
- [#118](https://github.com/nf-core/fetchngs/issues/118) - Allow input pattern validation for csv/tsv/txt
- [#121](https://github.com/nf-core/fetchngs/issues/121) - Add `tower.yml` to render samplesheet as Report in Tower
- Fetch `SRR` and `DRR` metadata from ENA API instead of NCBI API to bypass frequent breaking changes
- Updated pipeline template to [nf-core/tools 2.6](https://github.com/nf-core/tools/releases/tag/2.6)

@@ -26,7 +30,6 @@ This downloads a text file called `SRR_Acc_List.txt` that can be directly provid

### Enhancements & fixes

- [#121](https://github.com/nf-core/fetchngs/pull/123) - Add `tower.yml` to render Reports in Tower
- [#97](https://github.com/nf-core/fetchngs/pull/97) - Add support for generating nf-core/taxprofiler compatible samplesheets.
- [#99](https://github.com/nf-core/fetchngs/issues/99) - SRA_IDS_TO_RUNINFO fails due to bad request
- Add `enum` field for `--nf_core_pipeline` to parameter schema so only accept supported pipelines are accepted
26 changes: 13 additions & 13 deletions modules/local/sra_to_samplesheet.nf
Original file line number Diff line number Diff line change
@@ -6,9 +6,9 @@ process SRA_TO_SAMPLESHEET {
memory 100.MB

input:
tuple val(meta), path(fastq)
val pipeline
val mapping_fields
val meta
val pipeline
val mapping_fields

output:
tuple val(meta), path("*samplesheet.csv"), emit: samplesheet
@@ -20,19 +20,19 @@ process SRA_TO_SAMPLESHEET {
//

// Remove custom keys needed to download the data
def meta_map = meta.clone()
meta_map.remove("id")
meta_map.remove("fastq_1")
meta_map.remove("fastq_2")
meta_map.remove("md5_1")
meta_map.remove("md5_2")
meta_map.remove("single_end")
def meta_clone = meta.clone()
meta_clone.remove("id")
meta_clone.remove("fastq_1")
meta_clone.remove("fastq_2")
meta_clone.remove("md5_1")
meta_clone.remove("md5_2")
meta_clone.remove("single_end")

// Add relevant fields to the beginning of the map
pipeline_map = [
sample : "${meta.id.split('_')[0..-2].join('_')}",
fastq_1 : "${params.outdir}/fastq/${fastq[0]}",
fastq_2 : meta.single_end ? '' : "${params.outdir}/fastq/${fastq[1]}"
fastq_1 : meta.fastq_1,
fastq_2 : meta.fastq_2
]

// Add nf-core pipeline specific entries
@@ -43,7 +43,7 @@ process SRA_TO_SAMPLESHEET {
pipeline_map << [ fasta: '' ]
}
}
pipeline_map << meta_map
pipeline_map << meta_clone

// Create a samplesheet
samplesheet = pipeline_map.keySet().collect{ '"' + it + '"'}.join(",") + '\n'
86 changes: 54 additions & 32 deletions workflows/sra.nf
Original file line number Diff line number Diff line change
@@ -80,19 +80,27 @@ workflow SRA {
.splitCsv(header:true, sep:'\t')
.map {
meta ->
meta.single_end = meta.single_end.toBoolean()
[ meta, [ meta.fastq_1, meta.fastq_2 ] ]
def meta_clone = meta.clone()
meta_clone.single_end = meta_clone.single_end.toBoolean()
return meta_clone
}
.unique()
.branch {
ftp: it[0].fastq_1 && !params.force_sratools_download
sra: !it[0].fastq_1 || params.force_sratools_download
}
.set { ch_sra_reads }
.set { ch_sra_metadata }
ch_versions = ch_versions.mix(SRA_RUNINFO_TO_FTP.out.versions.first())

if (!params.skip_fastq_download) {

ch_sra_metadata
.map {
meta ->
[ meta, [ meta.fastq_1, meta.fastq_2 ] ]
}
.branch {
ftp: it[0].fastq_1 && !params.force_sratools_download
sra: !it[0].fastq_1 || params.force_sratools_download
}
.set { ch_sra_reads }

//
// MODULE: If FTP link is provided in run information then download FastQ directly via FTP and validate with md5sums
//
@@ -109,33 +117,47 @@ workflow SRA {
)
ch_versions = ch_versions.mix(SRAFASTQ.out.versions.first())

//
// MODULE: Stage FastQ files downloaded by SRA together and auto-create a samplesheet
//
SRA_TO_SAMPLESHEET (
SRA_FASTQ_FTP.out.fastq.mix(SRAFASTQ.out.reads),
params.nf_core_pipeline ?: '',
params.sample_mapping_fields
)
SRA_FASTQ_FTP
.out
.fastq
.mix(SRAFASTQ.out.reads)
.map {
meta, fastq ->
def reads = meta.single_end ? [ fastq ] : fastq
def meta_clone = meta.clone()
meta_clone.fastq_1 = reads[0] ? "${params.outdir}/fastq/${reads[0].getName()}" : ''
meta_clone.fastq_2 = reads[1] && !meta.single_end ? "${params.outdir}/fastq/${reads[1].getName()}" : ''
return meta_clone
}
.set { ch_sra_metadata }
}

//
// MODULE: Create a merged samplesheet across all samples for the pipeline
//
SRA_MERGE_SAMPLESHEET (
SRA_TO_SAMPLESHEET.out.samplesheet.collect{it[1]},
SRA_TO_SAMPLESHEET.out.mappings.collect{it[1]}
)
ch_versions = ch_versions.mix(SRA_MERGE_SAMPLESHEET.out.versions)
//
// MODULE: Stage FastQ files downloaded by SRA together and auto-create a samplesheet
//
SRA_TO_SAMPLESHEET (
ch_sra_metadata,
params.nf_core_pipeline ?: '',
params.sample_mapping_fields
)

//
// MODULE: Create a MutiQC config file with sample name mappings
//
if (params.sample_mapping_fields) {
MULTIQC_MAPPINGS_CONFIG (
SRA_MERGE_SAMPLESHEET.out.mappings
)
ch_versions = ch_versions.mix(MULTIQC_MAPPINGS_CONFIG.out.versions)
}
//
// MODULE: Create a merged samplesheet across all samples for the pipeline
//
SRA_MERGE_SAMPLESHEET (
SRA_TO_SAMPLESHEET.out.samplesheet.collect{it[1]},
SRA_TO_SAMPLESHEET.out.mappings.collect{it[1]}
)
ch_versions = ch_versions.mix(SRA_MERGE_SAMPLESHEET.out.versions)

//
// MODULE: Create a MutiQC config file with sample name mappings
//
if (params.sample_mapping_fields) {
MULTIQC_MAPPINGS_CONFIG (
SRA_MERGE_SAMPLESHEET.out.mappings
)
ch_versions = ch_versions.mix(MULTIQC_MAPPINGS_CONFIG.out.versions)
}

//

0 comments on commit 44901cf

Please sign in to comment.