Skip to content

Commit

Permalink
refactor cnvkit logic
Browse files Browse the repository at this point in the history
  • Loading branch information
ramprasadn committed Sep 6, 2023
1 parent 44cffd6 commit 7afbbec
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 8 deletions.
1 change: 1 addition & 0 deletions assets/schema_input.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"sample": {
"type": "string",
"pattern": "^\\S+$",
"meta": ["id"],
"errorMessage": "Sample name must be provided and cannot contain spaces"
},
"bam": {
Expand Down
26 changes: 18 additions & 8 deletions workflows/createpanelrefs.nf
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,11 @@ for (param in checkPathParamList) if (param) file(param, checkIfExists: true)
ch_from_samplesheet = Channel.fromSamplesheet("input")

ch_input = ch_from_samplesheet.map{meta, bam, bai, cram, crai ->
if (bam) return [ [id:"panel", data_type:"bam" ], bam ]
if (cram) return [ [id:"panel", data_type:"cram" ], cram ]
}.groupTuple().branch{
bam: it[0].data_type == "bam"
cram: it[0].data_type == "cram"
if (bam) return [ meta + [data_type:"bam"], bam ]
if (cram) return [ meta + [data_type:"cram" ], cram ]
}

// Initialize file channels based on params, defined in the params.genomes[params.genome] scope
ch_fasta = params.fasta ? Channel.fromPath(params.fasta).first() : Channel.empty()
ch_fasta = params.fasta ? Channel.fromPath(params.fasta).map { fasta -> [[id:fasta.baseName],fasta]}.collect() : Channel.empty()

/*
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Expand Down Expand Up @@ -97,7 +93,21 @@ workflow CREATEPANELREFS {
ch_versions = Channel.empty()

if (params.tools && params.tools.split(',').contains('cnvkit')) {
CNVKIT_BATCH ( ch_input.bam.map{meta, bam -> [ meta, [], bam ]}, ch_fasta, [], [], [], true )

ch_input
.map{ meta, bam ->
new_meta = meta + [id:"panel"]
[new_meta, bam]
}
.groupTuple()
.branch{
bam: it[0].data_type == "bam"
}
.bam
.map {meta, bam -> [ meta, [], bam ]}
.set { ch_cnvkit_input }

CNVKIT_BATCH ( ch_cnvkit_input, ch_fasta, [[:],[]], [[:],[]], [[:],[]], true )
ch_versions = ch_versions.mix(CNVKIT_BATCH.out.versions)
}

Expand Down

0 comments on commit 7afbbec

Please sign in to comment.