-
Notifications
You must be signed in to change notification settings - Fork 34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for generating mag samplesheet #544
Open
sofstam
wants to merge
27
commits into
nf-core:dev
Choose a base branch
from
sofstam:generate-samplesheet
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
b0b37eb
Add chaining samplesheet with mag
sofstam 590f9b1
Filter out correctly
sofstam 738837e
Rename parameters
sofstam 3d19176
Fix linting
sofstam 80bed68
Fix linting
sofstam 4a9fa88
Use same schema as createtaxdb
sofstam a3dea86
Use correct name of argument
sofstam b0ceef7
Add function
sofstam b5fe3db
Update nextflow_schema.json
sofstam a1cab25
Apply review suggestions
sofstam c315cae
Update docs/output.md
sofstam cd136d7
Review suggestions
sofstam 7acbc4b
Merge branch 'generate-samplesheet' of https://github.com/sofstam/tax…
sofstam 263c7d3
[automated] Fix code linting
nf-core-bot e3fa0ee
Add pattern to nextflow_schema.json
sofstam c6ac0cb
Prettier
sofstam aff979e
Review suggestions and new function
sofstam 67f33e5
Update docs/output.md
sofstam 94a28f4
Update docs/output.md
sofstam 892b428
Remove tests folder
sofstam e0e83c3
Merge branch 'generate-samplesheet' of https://github.com/sofstam/tax…
sofstam 0abfdf7
Use the same function as detaxizer
sofstam 1e00c4c
LintinG
sofstam f79fc7d
[automated] Fix code linting
nf-core-bot 7a25178
Apply suggestions from code review
jfy133 b729483
Get the samplesheet generate to generate se reads
jfy133 6eeb982
Fix run column
jfy133 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,64 +7,62 @@ workflow SAMPLESHEET_MAG { | |
ch_processed_reads | ||
|
||
main: | ||
format = 'csv' // most common format in nf-core | ||
format_sep = ',' | ||
format = 'csv' | ||
|
||
ch_list_for_samplesheet = ch_processed_reads.view() | ||
.map { | ||
meta, sample_id, instrument_platform,fastq_1,fastq_2,fasta -> | ||
def sample = meta.id | ||
def run = meta.run_accession //this should be optional | ||
def group = "" | ||
def short_reads_1 = file(params.outdir).toString() + '/' + meta.id + '/' + fastq_1.getName() | ||
def short_reads_2 = meta.single_end ? "" : file(params.outdir).toString() + '/' + meta.id + '/' + fastq_2.getName() | ||
def long_reads = meta.is_fasta ? file(params.outdir).toString() + '/' + meta.id + '/' + fasta.getName() : "" | ||
[sample: sample, run: run, group: group, short_reads_1: short_reads_1, short_reads_2: short_reads_2, long_reads: long_reads] | ||
ch_list_for_samplesheet = ch_processed_reads | ||
.dump() | ||
.map { meta, reads -> | ||
def sample = meta.id | ||
def run = params.perform_runmerging ? '' : meta.run_accession | ||
def group = "0" | ||
//this should be optional | ||
def short_reads_1 = meta.is_fasta ? "" : file(params.outdir).toString() + '/analysis_ready_fastqs/' + reads[0].getName() | ||
def short_reads_2 = meta.is_fasta || meta.single_end ? "" : file(params.outdir).toString() + '/analysis_ready_fastqs/' + reads[1].getName() | ||
def long_reads = meta.is_fasta ? file(params.outdir).toString() + '/analysis_ready_fastqs/' + reads[0].getName() : "" | ||
|
||
[sample: sample, run: run, group: group, short_reads_1: short_reads_1, short_reads_2: short_reads_2, long_reads: long_reads] | ||
} | ||
.view() | ||
.tap{ ch_list_for_samplesheet_all } | ||
.filter{ it.short_reads_1 != "" } | ||
.branch{ | ||
.tap { ch_list_for_samplesheet_all } | ||
.filter { it.short_reads_1 != "" } | ||
.branch { | ||
se: it.short_reads_2 == "" | ||
pe: true | ||
} | ||
pe: it.short_reads_2 != "" | ||
unknown: true | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is the |
||
} | ||
|
||
// Throw a warning that only long reads are not supported yet by MAG | ||
ch_list_for_samplesheet_all | ||
.filter{ it.long_reads != "" && it.short_reads_1 == "" } | ||
.collect{ log.warn("[nf-core/taxprofiler] WARNING: Standalone long reads are not yet supported by the nf-core/mag pipeline and will not be in present in `mag-*.csv`. Sample: ${it.sample}" )} | ||
.filter { it.long_reads != "" && it.short_reads_1 == "" } | ||
.collect { log.warn("[nf-core/taxprofiler] WARNING: Standalone long reads are not yet supported by the nf-core/mag pipeline and will not be in present in `mag-*.csv`. Sample: ${it.sample}") } | ||
|
||
channelToSamplesheet(ch_list_for_samplesheet.pe,"${params.outdir}/downstream_samplesheets/mag-pe", format) | ||
channelToSamplesheet(ch_list_for_samplesheet.pe, "${params.outdir}/downstream_samplesheets/mag-pe", format) | ||
channelToSamplesheet(ch_list_for_samplesheet.se, "${params.outdir}/downstream_samplesheets/mag-se", format) | ||
|
||
} | ||
|
||
workflow GENERATE_DOWNSTREAM_SAMPLESHEETS { | ||
|
||
take: | ||
ch_processed_reads | ||
|
||
main: | ||
def downstreampipeline_names = params.generate_pipeline_samplesheets.split(",") | ||
|
||
if ( downstreampipeline_names.contains('mag') && params.save_analysis_ready_fastqs) { | ||
if (downstreampipeline_names.contains('mag') && params.save_analysis_ready_fastqs) { | ||
SAMPLESHEET_MAG(ch_processed_reads) | ||
} | ||
|
||
} | ||
|
||
// Constructs the header string and then the strings of each row, and | ||
def channelToSamplesheet(ch_list_for_samplesheet, path, format) { | ||
format_sep = ["csv":",", "tsv":"\t", "txt":"\t"][format] | ||
def format_sep = [csv: ",", tsv: "\t", txt: "\t"][format] | ||
|
||
ch_header = ch_list_for_samplesheet | ||
def ch_header = ch_list_for_samplesheet | ||
|
||
ch_header | ||
.first() | ||
.map{ it.keySet().join(format_sep) } | ||
.concat( ch_list_for_samplesheet.map{ it.values().join(format_sep) }) | ||
.map { it.keySet().join(format_sep) } | ||
.concat(ch_list_for_samplesheet.map { it.values().join(format_sep) }) | ||
.collectFile( | ||
name:"${path}.${format}", | ||
name: "${path}.${format}", | ||
newLine: true, | ||
sort: false | ||
) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cannot make a suggestion but:
teh
mag-se.csv
. -> themag-se.csv
.