# Class VariantTypeCounter

java.lang.Object
org.snpsift.annotate.mem.variantTypeCounter.VariantTypeCounter

All Implemented Interfaces:
  `Serializable`

public class VariantTypeCounter extends Object implements Serializable
VariantTypeCounter is a class that counts the number of variants in a VCF (Variant Call Format) file. It also keeps track of the total size (in bytes) of specific fields for each variant category. The class works by iterating through VCF entries and counting the number of variants and their sizes. It categorizes variants and maintains counts and sizes for each category. Non-obvious limitations: - The class only tracks the size of fields that are of type String. - The size of the fields is calculated in bytes using UTF-8 encoding. - The class assumes that the VCF file contents are provided as a string for testing purposes. - The class does not handle non-string fields for size calculations. - The class does not handle multi-threaded access and is not thread-safe.

See Also:
  - Serialized Form

## Field Summary

Fields
Modifier and Type
Field
Description
`static final String`
`ALT`
`protected int[]`
`countByCategory`
`protected long`
`countVariants`
`protected long`
`countVcfEntries`
`protected Fields`
`fields`
`protected String[]`
`fieldsString`
`static final String`
`REF`
`protected Map<String,int[]>`
`sizesByField`

## Constructor Summary

Constructors
Constructor
Description
`VariantTypeCounter(Fields fields)`

## Method Summary

Modifier and Type
Method
Description
`void`
`count(org.snpeff.vcf.VcfEntry vcfEntry)`
Count the number of variants in a VCF file
`static VariantTypeCounter`
`countVariants(String vcfLines)`
Count variants in a string of VCF lines (i.e.
`int`
`getCount(VariantCategory variantCategory)`
`int[]`
`getCountByCategory()`
`Fields`
`getFields()`
`int`
`getSize(VariantCategory variantCategory, String field)`
Get total size (in bytes) of a field (only string fields)
`Map<String,int[]>`
`getSizesByField()`
`String`
`toString()`
`protected void`
`updateSizes(VariantCategory variantCategory, String field, String value)`
Update sizes for a field

### Methods inherited from class Object

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

## Field Details

### REF

public static final String REF

See Also:
  - Constant Field Values

### ALT

public static final String ALT

See Also:
  - Constant Field Values

### fields

protected Fields fields

### fieldsString

protected String[] fieldsString

### countByCategory

protected int[] countByCategory

### countVcfEntries

protected long countVcfEntries

### countVariants

protected long countVariants

### sizesByField

protected Map<String,int[]> sizesByField

## Constructor Details

### VariantTypeCounter

public VariantTypeCounter(Fields fields)

## Method Details

### countVariants

public static VariantTypeCounter countVariants(String vcfLines)
Count variants in a string of VCF lines (i.e. a VCF file contents in a string) This is used for testing

### count

public void count(org.snpeff.vcf.VcfEntry vcfEntry)
Count the number of variants in a VCF file

### getCount

public int getCount(VariantCategory variantCategory)

### getCountByCategory

public int[] getCountByCategory()

### getFields

public Fields getFields()

### getSize

public int getSize(VariantCategory variantCategory, String field)
Get total size (in bytes) of a field (only string fields)

Returns:
  Total size (in bytes) or -1 if the field is not found

### getSizesByField

public Map<String,int[]> getSizesByField()

### toString

public String toString()

Overrides:
  `toString` in class `Object`

### updateSizes

protected void updateSizes(VariantCategory variantCategory, String field, String value)
Update sizes for a field