Skip to content

Commit

Permalink
Add nft-compress and update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
lukfor committed Jun 15, 2024
1 parent 43ddfc9 commit 24ac55d
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 60 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ work
.DS_Store
.nf-test
cloudgene.report.json
.nf-test.log
2 changes: 1 addition & 1 deletion modules/local/compression/compression_encryption_vcf.nf
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ process COMPRESSION_ENCRYPTION_VCF {
if [[ "${params.encryption.enabled}" = true ]]
then
7z a -tzip ${aes} -mmt${task.cpus} -p"${params.encryption_password}" ${zip_name} ${prefix}*
rm *vcf.gz* *info
rm *vcf.gz* *info.gz
fi
if [[ "${params.md5}" = true ]]
Expand Down
1 change: 1 addition & 0 deletions nf-test.config
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ config {

plugins {
load "[email protected]"
load "[email protected]"
}

}
131 changes: 72 additions & 59 deletions tests/main.nf.test
Original file line number Diff line number Diff line change
Expand Up @@ -36,20 +36,19 @@ nextflow_pipeline {
then {
assert workflow.success

def quality_control_log = file("${outputDir}/cloudgene.report.json")
assert quality_control_log.exists()
assert quality_control_log.text.contains("Remaining sites in total: 7,735")
assert !file("${outputDir}/chr_20.zip").exists()
assert !file("${outputDir}/chr20.dose.vcf.gz").exists()

def typed_file = file("${outputDir}/statistics/typed-only.txt")
assert typed_file.exists()

def snps_file = file("${outputDir}/statistics/snps-excluded.txt")
assert snps_file.exists()
def log = file("${outputDir}/cloudgene.report.json")
with(log) {
assert exists()
assert text.contains("Remaining sites in total: 7,735")
}

assert snapshot(
quality_control_log.text,
typed_file.text,
snps_file.text
log.text,
file("${outputDir}/statistics/typed-only.txt").text,
file("${outputDir}/statistics/snps-excluded.txt").text
).match()

}
Expand All @@ -74,23 +73,29 @@ nextflow_pipeline {
then {
assert workflow.success

def quality_control_log = file("${outputDir}/cloudgene.report.json")
assert quality_control_log.exists()
assert quality_control_log.text.contains("Remaining sites in total: 7,735")
with(file("${outputDir}/cloudgene.report.json")) {
assert exists()
assert text.contains("Remaining sites in total: 7,735")
}

assert !file("${outputDir}/chr20.dose.vcf.gz").exists()

def imputed_chr_20 = file("${outputDir}/chr_20.zip");
assert imputed_chr_20.exists()
ZipFile zipFile = new ZipFile(imputed_chr_20, PASSWORD.toCharArray());
zipFile.extractAll("${outputDir}");
def file = path("${outputDir}/chr20.dose.vcf.gz").vcf
assert file.getChromosome() == "20"
assert file.getNoSamples() == 51;
assert file.isPhased()
assert file.getNoSnps() == TOTAL_REFPANEL_CHR20_B37 + ONLY_IN_INPUT
def zip = zip("${outputDir}/chr_20.zip").password(PASSWORD)
with(zip) {
assert isValid()
assert isEncrypted()
}

//check correct number of snps in info.gz file
assert path("${outputDir}/chr20.info.gz").linesGzip.size() == 1 + TOTAL_REFPANEL_CHR20_B37 + ONLY_IN_INPUT

with(zip.extract("chr20.dose.vcf.gz").vcf) {
assert getChromosome() == "20"
assert getNoSamples() == 51;
assert isPhased()
assert getNoSnps() == TOTAL_REFPANEL_CHR20_B37 + ONLY_IN_INPUT
}

with(zip.extract("chr20.info.gz")) {
assert linesGzip.size() == 1 + TOTAL_REFPANEL_CHR20_B37 + ONLY_IN_INPUT
}
}

}
Expand All @@ -114,25 +119,33 @@ nextflow_pipeline {
then {
assert workflow.success

def quality_control_log = file("${outputDir}/cloudgene.report.json")
assert quality_control_log.exists()
assert quality_control_log.text.contains("Remaining sites in total: 7,735")
with(file("${outputDir}/cloudgene.report.json")) {
assert exists()
assert text.contains("Remaining sites in total: 7,735")
}

assert !file("${outputDir}/chr20.dose.vcf.gz").exists()

def imputed_chr_20 = file("${outputDir}/chr_20.zip");
assert imputed_chr_20.exists()
ZipFile zipFile = new ZipFile(imputed_chr_20, PASSWORD.toCharArray());
zipFile.extractAll("${outputDir}");
def file = path("${outputDir}/chr20.dose.vcf.gz").vcf
def fileMeta = path("${outputDir}/chr20.empiricalDose.vcf.gz").vcf
assert fileMeta.getNoSnps() == 7735
assert file.getChromosome() == "20"
assert file.getNoSamples() == 51;
assert file.isPhased()
assert file.getNoSnps() == TOTAL_REFPANEL_CHR20_B37 + ONLY_IN_INPUT
def zip = zip("${outputDir}/chr_20.zip").password(PASSWORD)
with(zip) {
assert isValid()
assert isEncrypted()
}

with(zip.extract("chr20.dose.vcf.gz").vcf) {
assert getChromosome() == "20"
assert getNoSamples() == 51;
assert isPhased()
assert getNoSnps() == TOTAL_REFPANEL_CHR20_B37 + ONLY_IN_INPUT
}

//check correct number of snps in info.gz file
assert path("${outputDir}/chr20.info.gz").linesGzip.size() == 1 + TOTAL_REFPANEL_CHR20_B37 + ONLY_IN_INPUT
with(zip.extract("chr20.empiricalDose.vcf.gz").vcf) {
assert getNoSnps() == 7735
}

with(zip.extract("chr20.info.gz")) {
assert linesGzip.size() == 1 + TOTAL_REFPANEL_CHR20_B37 + ONLY_IN_INPUT
}
}

}
Expand All @@ -154,7 +167,6 @@ nextflow_pipeline {

then {
assert workflow.failed

}

}
Expand Down Expand Up @@ -262,23 +274,25 @@ nextflow_pipeline {
then {
assert workflow.success

def quality_control_log = file("${outputDir}/cloudgene.report.json")
assert quality_control_log.exists()
assert quality_control_log.text.contains("Remaining sites in total: 7,735")
assert snapshot(quality_control_log.text).match()


def imputed_chr_20 = file("${outputDir}/chr_20.zip");
assert !imputed_chr_20.exists()
def log = file("${outputDir}/cloudgene.report.json")
with(log) {
assert exists()
assert text.contains("Remaining sites in total: 7,735")
}
assert snapshot(log.text).match()

def file = path("${outputDir}/chr20.dose.vcf.gz").vcf
assert file.getChromosome() == "20"
assert file.getNoSamples() == 51;
assert file.isPhased()
assert file.getNoSnps() == TOTAL_REFPANEL_CHR20_B37
assert !file("${outputDir}/chr_20.zip").exists()

//check correct number of snps in info.gz file
assert path("${outputDir}/chr20.info.gz").linesGzip.size() == 1 + TOTAL_REFPANEL_CHR20_B37
with(path("${outputDir}/chr20.dose.vcf.gz").vcf) {
assert getChromosome() == "20"
assert getNoSamples() == 51;
assert isPhased()
assert getNoSnps() == TOTAL_REFPANEL_CHR20_B37
}

with(path("${outputDir}/chr20.info.gz")) {
assert linesGzip.size() == 1 + TOTAL_REFPANEL_CHR20_B37
}

}

Expand Down Expand Up @@ -420,7 +434,6 @@ nextflow_pipeline {

then {
assert workflow.failed

}

}
Expand Down

0 comments on commit 24ac55d

Please sign in to comment.