Skip to content

Commit

Permalink
Check for multiple sample before splitting
Browse files Browse the repository at this point in the history
  • Loading branch information
LouisLeNezet committed Nov 11, 2024
1 parent b5e7d91 commit 01e0927
Show file tree
Hide file tree
Showing 12 changed files with 449 additions and 8 deletions.
5 changes: 5 additions & 0 deletions modules.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@
"installed_by": ["modules"],
"patch": "modules/nf-core/bcftools/pluginsplit/bcftools-pluginsplit.diff"
},
"bcftools/query": {
"branch": "master",
"git_sha": "666652151335353eef2fcd58880bcef5bc2928e1",
"installed_by": ["modules"]
},
"bcftools/stats": {
"branch": "master",
"git_sha": "666652151335353eef2fcd58880bcef5bc2928e1",
Expand Down
5 changes: 5 additions & 0 deletions modules/nf-core/bcftools/query/environment.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

56 changes: 56 additions & 0 deletions modules/nf-core/bcftools/query/main.nf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

67 changes: 67 additions & 0 deletions modules/nf-core/bcftools/query/meta.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

101 changes: 101 additions & 0 deletions modules/nf-core/bcftools/query/tests/main.nf.test

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

55 changes: 55 additions & 0 deletions modules/nf-core/bcftools/query/tests/main.nf.test.snap

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions modules/nf-core/bcftools/query/tests/nextflow.config

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions modules/nf-core/bcftools/query/tests/tags.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 25 additions & 3 deletions subworkflows/local/vcf_split_bcftools/main.nf
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
include { BCFTOOLS_PLUGINSPLIT } from '../../../modules/nf-core/bcftools/pluginsplit'
include { BCFTOOLS_QUERY } from '../../../modules/nf-core/bcftools/query/main'

workflow VCF_SPLIT_BCFTOOLS {
take:
Expand All @@ -8,7 +9,25 @@ workflow VCF_SPLIT_BCFTOOLS {

ch_versions = Channel.empty()

BCFTOOLS_PLUGINSPLIT(ch_vcf, [], [], [], [])
BCFTOOLS_QUERY(ch_vcf, [], [], []) // List samples

BCFTOOLS_QUERY.out.output.splitText().groupTuple().view()

ch_samples = ch_vcf
.join(BCFTOOLS_QUERY.out.output.splitText().groupTuple())
.branch {
one : it[3].size() == 1
multiple : it[3].size() > 1
other : true
}

ch_samples.other.map {
def file = it[1]
def id = it[0].id
error "File ${file} with id : ${id} does not have any samples information"
}

BCFTOOLS_PLUGINSPLIT(ch_samples.multiple.map{it[0..2]}, [], [], [], [])
ch_versions = ch_versions.mix(BCFTOOLS_PLUGINSPLIT.out.versions.first())

ch_vcf_samples = BCFTOOLS_PLUGINSPLIT.out.vcf
Expand All @@ -19,8 +38,11 @@ workflow VCF_SPLIT_BCFTOOLS {
.transpose()
.map{metaITC, tbi -> [metaITC + [id: tbi.getBaseName().tokenize(".")[0]], tbi]}

ch_vcf_tbi_samples = ch_vcf_samples
.join(ch_tbi_samples)
ch_vcf_tbi_samples = ch_samples.one
.map{ it[0..2] }
.mix(ch_vcf_samples
.join(ch_tbi_samples)
)

emit:
vcf_tbi = ch_vcf_tbi_samples // channel: [ [id, chr, tools], vcf, index ]
Expand Down
Loading

0 comments on commit 01e0927

Please sign in to comment.