Skip to content

nf-test plugin to provide support for VCF files.

License

Notifications You must be signed in to change notification settings

seppinho/nft-vcf

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

38 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

nft-vcf

nf-test plugin to support VCF files.

Requirements

  • nf-test version 0.7.0 or higher

Setup

To use this plugin you need to activate the nft-vcf plugin in your nf-test.config file:

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

Usage

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.

Examples

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"
}

header

Returns the VCF Header instance and allows you to access all available methods.

assert path("file.vcf.gz").vcf.header.getColumnCount() == 4

summary

Returns VCF summary attributes (chromosomes, variantCount, sampleCount, phasing status).

path("file.vcf.gz").vcf.summary

chromosomes()

Returns all chromosomes as a set of Strings.

path("file.vcf.gz").vcf.chromosomes == ['20'] as Set

chromosome()

Returns the first chromosome as a String.

path("file.vcf.gz").vcf.chromosome == '20'

getVariant(String chromosome, String position)

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")

variants

Returns an array of VariantContext instances and allows you to access all available methods.

path("file.vcf.gz").vcf.variants.size()

getVariants(int numberOflines)

Returns an array of n VariantContext instances and allows you to access all available methods.

path("file.vcf.gz").vcf.getVariants(100).size()

getVariantsAsStrings(int numberOflines)

Returns a String array including n lines.

path("file.vcf.gz").vcf.getVariantsAsStrings(100).size()

variantsMD5

Returns the MD5 hashsum of all variants.

path("file.vcf.gz").vcf.variantsMD5

getVariantsByRange(String chromosome, int start, int stop)

Returns an array of VariantContext instances and allows you to access all available methods.

path("file.vcf.gz").vcf.getVariantsRange("chr20", 1, 10)

getInfoR2(String chromosome, int position)

Returns the INFO R2 double value of a specific variant.

path("file.vcf.gz").vcf.getInfoR2("chr20", 1)

getInfoTag(String tag, String chromosome, int position)

Returns the specified INFO field String value of a specific variant.

path("file.vcf.gz").vcf.getInfoTag("R2", "chr20", 1)

createIndex()

Create a tabix index for the specified VCF file.

path("file.vcf.gz").vcf.createIndex()