Package vcf
Class VcfHeader
- java.lang.Object
-
- vcf.VcfHeader
-
public final class VcfHeader extends java.lang.Object
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
Fields Modifier and Type Field Description static java.lang.String
HEADER_PREFIX
A string equal to the first nine tab-delimited fields of a VCF header line that contains sample data.
-
Constructor Summary
Constructors Constructor Description VcfHeader(FileIt<java.lang.String> it)
Constructs a newVcfHeader
object from the VCF meta-information lines and the VCF header line returned by the specifiedFileIterator<String>
.VcfHeader(FileIt<java.lang.String> it, Filter<java.lang.String> sampleFilter)
Constructs a newVcfHeader
object from the VCF meta-information lines and the VCF header line returned by the specifiedFileIterator<String>
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.io.File
file()
Returns the file from which data are read, or returnsnull
if the source is standard input.java.lang.String
headerLine()
Returns the VCF header line.VcfMetaInfo
metaInfoLine(int index)
Returns the specified VCF meta-information line.int
nHeaderFields()
Returns the number of fields in the VCF header line before sample exclusions.int
nMetaInfoLines()
Returns the number of VCF meta-information lines.int
nSamples()
Returns the number of samples after sample exclusions.int
nUnfilteredSamples()
Returns the number of samples before sample exclusions.java.lang.String[]
sampleIds()
Returnsthis.sample().ids()
.Samples
samples()
Return the list of samples after sample exclusions.java.lang.String
toString()
Returns the VCF meta-information lines and the VCF header line used to constructthis
.int
unfilteredSampleIndex(int sample)
Returns the index of the specified sample in the the list original list of samples before sample exclusions.
-
-
-
Field Detail
-
HEADER_PREFIX
public static final java.lang.String HEADER_PREFIX
A string equal to the first nine tab-delimited fields of a VCF header line that contains sample data.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
VcfHeader
public VcfHeader(FileIt<java.lang.String> it)
Constructs a newVcfHeader
object from the VCF meta-information lines and the VCF header line returned by the specifiedFileIterator<String>
. This constructor will advance theFileIterator<String>
to the point before the first VCF record in the file. TheVcfHeader
object will have no excluded samples.- Parameters:
it
- an iterator that returns lines of VCF file- Throws:
java.lang.IllegalArgumentException
- if any of the meta-information lines returned by the specifiedFileIterator<String>
does not conform to the VCF specificationjava.lang.IllegalArgumentException
- if the header lines returned by the specifiedFileIterator<String>
does not conform to the VCF specificationjava.lang.IllegalArgumentException
- if no header line is returned by the specifiedFileIterator<String>
java.lang.NullPointerException
- ifit == null
-
VcfHeader
public VcfHeader(FileIt<java.lang.String> it, Filter<java.lang.String> sampleFilter)
Constructs a newVcfHeader
object from the VCF meta-information lines and the VCF header line returned by the specifiedFileIterator<String>
. This constructor will advance theFileIterator<String>
to the point before the first VCF record in the file.- Parameters:
it
- an iterator that returns lines of a VCF filesampleFilter
- a sample filter ornull
- Throws:
java.lang.IllegalArgumentException
- if any of the meta-information lines returned by the specifiedFileIterator<String>
does not conform to the VCF specificationjava.lang.IllegalArgumentException
- if the header lines returned by the specifiedFileIterator<String>
does not conform to the VCF specificationjava.lang.IllegalArgumentException
- if no header line is returned by the specifiedFileIterator<String>
java.lang.NullPointerException
- ifit == null
-
-
Method Detail
-
file
public java.io.File file()
Returns the file from which data are read, or returnsnull
if the source is standard input.- Returns:
- the file from which data are read, or
null
if the source is standard input
-
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
public VcfMetaInfo metaInfoLine(int index)
Returns the specified VCF meta-information line.- Parameters:
index
- a VCF meta-information line index- Returns:
- the specified VCF meta-information line
- Throws:
java.lang.IndexOutOfBoundsException
- ifindex < 0 || index >= this.nMetaInfoLines()
-
headerLine
public java.lang.String headerLine()
Returns the VCF header line. The VCF header line begins with "#CHROM".- Returns:
- the VCF header line
-
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 the list original list of samples before sample exclusions.- Parameters:
sample
- a sample index- Returns:
- the index of the specified sample in the the list original list of samples before sample exclusions
- Throws:
java.lang.IndexOutOfBoundsException
- ifsample < 0 || sample >= this.nSamples()
-
nSamples
public int nSamples()
Returns the number of samples after sample exclusions.- Returns:
- the number of samples after sample exclusions
-
samples
public Samples samples()
Return the list of samples after sample exclusions.- Returns:
- the list of samples after sample exclusions
-
sampleIds
public java.lang.String[] sampleIds()
Returnsthis.sample().ids()
.- Returns:
this.sample().ids()
-
toString
public java.lang.String toString()
Returns the VCF meta-information lines and the VCF header line used to constructthis
.- Overrides:
toString
in classjava.lang.Object
- Returns:
- the VCF meta-information lines and the VCF header line used to
construct
this
-
-