Package org.snpsift.annotate.mem.database

# Class VariantDatabase

java.lang.Object
org.snpsift.annotate.mem.database.VariantDatabase

public class VariantDatabase extends Object
A database of variant's data used to annotate a VCF file (i.e. VCF entries). The database only loads one chromosome at a time, to speed up the process while fitting in memory. The database is a collection of VariantDatabaseChr objects, one per chromosome. Each 'VariantDatabaseChr' is stored in one file per chromosome. 'VariantDatabase' manages the 'VariantDatabaseChr' files (loading, saving, etc).

## Field Summary

Fields
Modifier and Type
Field
Description
`static final String`
`FIELDS_EXT`
`static final String`
`VARIANT_DATABASE_EXT`
`static final String`
`VARIANT_DATAFRAME_EXT`

## Constructor Summary

Constructors
Constructor
Description
`VariantDatabase()`
`VariantDatabase(String databaseVcfFileName, String dbDir, String[] fieldNamesCreate)`
Constructor used to create a database
`VariantDatabase(String databaseVcfFileName, String dbDir, String[] fieldNamesAnnotate, String prefix, boolean emptyIfNotFound)`
Constructor used to annotate a database

## Method Summary

Modifier and Type
Method
Description
`protected void`
`add(org.snpeff.vcf.VariantVcfEntry variantVcfEntry)`
Add a VCF entry to the database
`int`
`annotate(org.snpeff.vcf.VcfEntry vcfEntry)`
This method is used to annotate a VCF entry The annotations are added to the INFO field of the VCF entry
`boolean`
`checkFields(String[] fieldNames, boolean throwExceptionOnError)`
Check that all `fieldNames` are available in `fields`
`void`
`create()`
Create a database from a VCF file
`void`
`create(String vcfContents)`
Create a database from a VCF file content (as a string) This is used for testing
`static String`
`dbDirFromVcfFileName(String dbFileName)`
Get the database directory name from a "VCF database" file name buy just appending ".snpsift.vardb"
`VariantDataFrame`
`get(String chr)`
Get the database for a chromosome
`String`
`getDatabaseVcfFileName()`
`String`
`getDbDir()`
`Fields`
`getFields()`
`VariantTypeCounters`
`getVariantTypeCounters()`
`void`
`load()`
`protected Fields`
`parseVcfHeaderFields(String databaseVcfFileName)`
Read VCF header and get columns data types
`protected Fields`
`parseVcfHeaderFields(org.snpeff.fileIterator.VcfFileIterator vcfFileIterator)`
Read VCF header and get columns data types
`void`
`save()`
`void`
`setDbDir(String dbDir)`
`void`
`setFieldNamesAnnotate(String[] fieldNamesAnnotate)`
`void`
`setPrefix(String prefix)`
`void`
`setVerbose(boolean verbose)`
`String`
`toString()`
`Collection<org.snpeff.vcf.VcfHeaderEntry>`
`vcfHeaders()`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

## Field Details

### VARIANT_DATABASE_EXT

public static final String VARIANT_DATABASE_EXT

See Also:
  - Constant Field Values

### VARIANT_DATAFRAME_EXT

public static final String VARIANT_DATAFRAME_EXT

See Also:
  - Constant Field Values

### FIELDS_EXT

public static final String FIELDS_EXT

See Also:
  - Constant Field Values

## Constructor Details

### VariantDatabase

public VariantDatabase()

### VariantDatabase

public VariantDatabase(String databaseVcfFileName, String dbDir, String[] fieldNamesCreate)
Constructor used to create a database

### VariantDatabase

public VariantDatabase(String databaseVcfFileName, String dbDir, String[] fieldNamesAnnotate, String prefix, boolean emptyIfNotFound)
Constructor used to annotate a database

## Method Details

### dbDirFromVcfFileName

public static String dbDirFromVcfFileName(String dbFileName)
Get the database directory name from a "VCF database" file name buy just appending ".snpsift.vardb"

### add

protected void add(org.snpeff.vcf.VariantVcfEntry variantVcfEntry)
Add a VCF entry to the database

### annotate

public int annotate(org.snpeff.vcf.VcfEntry vcfEntry)
This method is used to annotate a VCF entry The annotations are added to the INFO field of the VCF entry

### checkFields

public boolean checkFields(String[] fieldNames, boolean throwExceptionOnError)
Check that all `fieldNames` are available in `fields`

Returns:
  true is all fieldsNames are present, false otherwise

### create

public void create(String vcfContents)
Create a database from a VCF file content (as a string) This is used for testing

### create

public void create()
Create a database from a VCF file

### get

public VariantDataFrame get(String chr)
Get the database for a chromosome

### getDatabaseVcfFileName

public String getDatabaseVcfFileName()

### getDbDir

public String getDbDir()

### getFields

public Fields getFields()

### getVariantTypeCounters

public VariantTypeCounters getVariantTypeCounters()

### load

public void load()

### parseVcfHeaderFields

protected Fields parseVcfHeaderFields(String databaseVcfFileName)
Read VCF header and get columns data types

Parameters:
  `databaseVcfFileName` -

### parseVcfHeaderFields

protected Fields parseVcfHeaderFields(org.snpeff.fileIterator.VcfFileIterator vcfFileIterator)
Read VCF header and get columns data types

Parameters:
  `databaseVcfFileName` -

### save

public void save()

### setDbDir

public void setDbDir(String dbDir)

### setFieldNamesAnnotate

public void setFieldNamesAnnotate(String[] fieldNamesAnnotate)

### setPrefix

public void setPrefix(String prefix)

### setVerbose

public void setVerbose(boolean verbose)

### toString

public String toString()

Overrides:
  `toString` in class `Object`

### vcfHeaders

public Collection<org.snpeff.vcf.VcfHeaderEntry> vcfHeaders()