Package vcf
Class VcfHeader
java.lang.Object
vcf.VcfHeader
Class VcfHeader represents the Variant Call Format (VCF)
meta-information lines and the Variant Call Format header line
that precede the first Variant Call Format record.
Instances of class VcfHeader are immutable.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringA string equal to the first nine tab-delimited fields of a VCF header line that contains sample data. -
Constructor Summary
ConstructorsConstructorDescriptionReturns a VCF header object for the specified VCF meta information lines and header line.Returns a VCF header object for the specified VCF meta information lines and header line. -
Method Summary
Modifier and TypeMethodDescriptionstatic boolean[]Returns a boolean array whosek-th value istrueif the FORMAT field for thek-th sample in a VCF record contains an allele separator character and returnsfalseotherwise.metaInfoLine(int index) Returns the specified VCF meta-information line.intReturns the number of fields in the VCF header line before sample exclusions.intReturns the number of VCF meta-information lines.intnSamples()Returns the number of samples after sample exclusions.intReturns the number of samples before sample exclusions.String[]Returnsthis.sample().ids().samples()Return the list of samples after sample exclusions.src()Returns the source from which data are read.toString()Returns aStringcontaining the VCF meta-information lines and the post-sample-filtering VCF header line.intunfilteredSampleIndex(int sample) Returns the index of the specified sample in the original list of samples before sample exclusions.
-
Field Details
-
HEADER_PREFIX
A string equal to the first nine tab-delimited fields of a VCF header line that contains sample data.- See Also:
-
-
Constructor Details
-
VcfHeader
Returns a VCF header object for the specified VCF meta information lines and header line. The header line must be the last line in the specifiedlinesarray.- Parameters:
src- a string describing the source of the VCF filelines- the VCF meta-information and header linesisDiploid- a boolean array whosek-th value istrueif thek-th sample is diploid, and isfalseif thek-th sample is haploid- Throws:
IllegalArgumentException- if a format error is encountered in a meta-information line or header lines}NullPointerException- ifsrc==null || lines == null || isDiploid == null
-
VcfHeader
Returns a VCF header object for the specified VCF meta information lines and header line. The header line must be the last line in the specifiedlinesarray.- Parameters:
src- a string describing the source of the VCF filelines- the VCF meta-information and header linesisDiploid- a boolean array whosek-th value istrueif thek-th sample is diploid, and isfalseif thek-th sample is haploidsampleFilter- a sample filter- Throws:
IllegalArgumentException- if a format error is encountered in a meta-information line or header lines}NullPointerException- ifsrc==null || lines == null || isDiploid == null
-
-
Method Details
-
isDiploid
Returns a boolean array whosek-th value istrueif the FORMAT field for thek-th sample in a VCF record contains an allele separator character and returnsfalseotherwise. The contract for this method is undefined of the specified string is not a properly-formatted VCF record.- Parameters:
vcfRec- a VCF record- Returns:
- a boolean array whose
k-th value istrueif the FORMAT field for thek-th sample does not contain an allele separator character - Throws:
NullPointerException- ifvcfHeader == null || rec == null
-
src
Returns the source from which data are read. The string representation of the source is undefined and subject to change.- Returns:
- the source from which data are read
-
nMetaInfoLines
public int nMetaInfoLines()Returns the number of VCF meta-information lines. VCF meta-information lines are lines that precede the VCF header line. A VCF meta-information line must begin with "##".- Returns:
- the number of VCF meta-information lines
-
metaInfoLine
Returns the specified VCF meta-information line.- Parameters:
index- a VCF meta-information line index- Returns:
- the specified VCF meta-information line
- Throws:
IndexOutOfBoundsException- ifindex < 0 || index >= this.nMetaInfoLines()
-
nHeaderFields
public int nHeaderFields()Returns the number of fields in the VCF header line before sample exclusions.- Returns:
- the number of fields in the VCF header line before sample exclusions
-
nUnfilteredSamples
public int nUnfilteredSamples()Returns the number of samples before sample exclusions.- Returns:
- the number of samples before sample exclusions
-
unfilteredSampleIndex
public int unfilteredSampleIndex(int sample) Returns the index of the specified sample in the original list of samples before sample exclusions.- Parameters:
sample- a sample index- Returns:
- the index of the specified sample in the original list of samples before sample exclusions
- Throws:
IndexOutOfBoundsException- ifsample < 0 || sample >= this.size()
-
nSamples
public int nSamples()Returns the number of samples after sample exclusions.- Returns:
- the number of samples after sample exclusions
-
samples
Return the list of samples after sample exclusions.- Returns:
- the list of samples after sample exclusions
-
sampleIds
Returnsthis.sample().ids().- Returns:
this.sample().ids()
-
toString
Returns aStringcontaining the VCF meta-information lines and the post-sample-filtering VCF header line. Each line in theStringis terminated with a line separator.
-