# Class Fields

java.lang.Object
org.snpsift.annotate.mem.Fields

All Implemented Interfaces:
  `Serializable, Iterable<org.snpeff.vcf.VcfHeaderInfo>`

public class Fields extends Object implements Iterable<org.snpeff.vcf.VcfHeaderInfo>, Serializable
The Fields class represents a collection of VCF (Variant Call Format) header information fields. These Fields are stored in VariantDatabase / VariantDataFrame objects, that are used to annotate VCF files. It provides methods to manipulate and retrieve field values from VCF entries. This class implements the Iterable interface to allow iteration over VcfHeaderInfo objects. It also implements Serializable to allow instances to be serialized and deserialized. Fields are stored in a Map with their names as keys and VcfHeaderInfo objects as values. The class provides methods to add fields, retrieve field values, and save/load the Fields object to/from a file. Limitations: - The class cannot use REF/ALT fields directly because they are used to separate variant types in the database. - INFO and FORMAT fields are not appropriate to be stuffed into an INFO field. - The class assumes that certain VCF columns (e.g., CHROM, POS, ID, QUAL, FILTER) are implicitly present and handles them separately. - The getFieldValue method handles different VCF info types (Flag, Integer, Float, Character, String) and converts values accordingly. - The class does not handle all possible VCF info types and throws a RuntimeException for unimplemented types.

See Also:
  - Serialized Form

## Field Summary

Fields
Modifier and Type
Field
Description
`static final Set<String>`
`VCF_COLUMN_FIELD_NAMES`

## Constructor Summary

Constructors
Constructor
Description
`Fields()`

## Method Summary

Modifier and Type
Method
Description
`void`
`add(org.snpeff.vcf.VcfHeaderInfo field)`
`org.snpeff.vcf.VcfHeaderInfo`
`get(String name)`
`static Object`
`getFieldValue(org.snpeff.vcf.VcfHeaderInfo vcfHeaderInfo, org.snpeff.vcf.VariantVcfEntry varVcfEntry)`
Get a field value from a VCF entry
`static String`
`getFieldValueString(String fieldName, org.snpeff.vcf.VcfEntry vcfEntry)`
Get a field value (string) from a VCF entry
`String[]`
`getNames()`
`Iterator<org.snpeff.vcf.VcfHeaderInfo>`
`iterator()`
`static Fields`
`load(String fileName)`
`void`
`save(String fileName)`
Save to file
`Collection<org.snpeff.vcf.VcfHeaderEntry>`
`vcfHeaders(String prefix)`
Get VCF headers

### Methods inherited from class Object

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

### Methods inherited from interface Iterable

`forEach, spliterator`

## Field Details

### VCF_COLUMN_FIELD_NAMES

public static final Set<String> VCF_COLUMN_FIELD_NAMES

## Constructor Details

### Fields

public Fields()

## Method Details

### getFieldValue

public static Object getFieldValue(org.snpeff.vcf.VcfHeaderInfo vcfHeaderInfo, org.snpeff.vcf.VariantVcfEntry varVcfEntry)
Get a field value from a VCF entry

### getFieldValueString

public static String getFieldValueString(String fieldName, org.snpeff.vcf.VcfEntry vcfEntry)
Get a field value (string) from a VCF entry

### load

public static Fields load(String fileName)

### add

public void add(org.snpeff.vcf.VcfHeaderInfo field)

### get

public org.snpeff.vcf.VcfHeaderInfo get(String name)

### getNames

public String[] getNames()

### iterator

public Iterator<org.snpeff.vcf.VcfHeaderInfo> iterator()

Specified by:
  `iterator` in interface `Iterable<org.snpeff.vcf.VcfHeaderInfo>`

### save

public void save(String fileName)
Save to file

### vcfHeaders

public Collection<org.snpeff.vcf.VcfHeaderEntry> vcfHeaders(String prefix)
Get VCF headers