nf-test plugin to support VCF files.
- nf-test version 0.7.0 or higher
To use this plugin you need to activate the nft-vcf
plugin in your nf-test.config
file:
config {
plugins {
load "[email protected]"
}
}
nft-vcf extends path
by a vcf
property that can be used to read VCF files. It returns VCF lines in String format and makes extensive use of HTSJDK.
def vcfFile = path("${outputDir}/chr20.dose.vcf.gz").vcf
assert vcfFile.chromosomes == ['20'] as Set
assert vcfFile.sampleCount == 51
assert vcfFile.phased
assert vcfFile.variantCount == 7824
//output first chromosome
assert vcfFile.chromosome == "20"
//or
with(path(filename).vcf) {
assert chromosomes == ['20'] as Set
assert sampleCount == 51
assert phased
assert variantCount == 7824
//output first chromosome
assert chromosome == "20"
}
Returns the VCF Header instance and allows you to access all available methods.
assert path("file.vcf.gz").vcf.header.getColumnCount() == 4
Returns VCF summary attributes (chromosomes, variantCount, sampleCount, phasing status).
path("file.vcf.gz").vcf.summary
Returns all chromosomes as a set of Strings.
path("file.vcf.gz").vcf.chromosomes == ['20'] as Set
Returns the first chromosome as a String.
path("file.vcf.gz").vcf.chromosome == '20'
Returns a VariantContext instance and allows you to access all available methods.
path("file.vcf.gz").vcf.getVariant("chr20",123)
path("file.vcf.gz").vcf.getVariant("chr20",123).getContig()
path("file.vcf.gz").vcf.getVariant("chr20",123).getHetCount()
path("file.vcf.gz").vcf.getVariant("chr20",123).getAttribute("XX")
Returns an array of VariantContext instances and allows you to access all available methods.
path("file.vcf.gz").vcf.variants.size()
Returns an array of n VariantContext instances and allows you to access all available methods.
path("file.vcf.gz").vcf.getVariants(100).size()
Returns a String array including n lines.
path("file.vcf.gz").vcf.getVariantsAsStrings(100).size()
Returns the MD5 hashsum of all variants.
path("file.vcf.gz").vcf.variantsMD5
Returns an array of VariantContext instances and allows you to access all available methods.
path("file.vcf.gz").vcf.getVariantsRange("chr20", 1, 10)
Returns the INFO R2 double value of a specific variant.
path("file.vcf.gz").vcf.getInfoR2("chr20", 1)
Returns the specified INFO field String value of a specific variant.
path("file.vcf.gz").vcf.getInfoTag("R2", "chr20", 1)
Create a tabix index for the specified VCF file.
path("file.vcf.gz").vcf.createIndex()