Package vcf
Class VcfRec
java.lang.Object
vcf.VcfRec
Class VcfRec represents a VCF record. If one allele in a
diploid genotype is missing, then both alleles are set to missing.
Instances of class VcfRec are immutable.
-
Constructor Summary
ConstructorsConstructorDescriptionVcfRec(VcfHeader vcfHeader, String vcfRecord, MarkerParser markerParser) Constructs a newVcfRecinstance from a VCF record. -
Method Summary
Modifier and TypeMethodDescriptionfilter()Returns the FILTER field.format()Returns the FORMAT field.String[]formatData(String formatCode) Returns an array of lengththis.size()containing the specified FORMAT subfield data for each sample.intformatIndex(String formatCode) Returns the index of the specified FORMAT subfield if the specified subfield is defined for this VCF record, and returns -1 otherwise.formatSubfield(int subfieldIndex) Returns the specified FORMAT subfield.intget(int hap) Returns the specified allele for the specified haplotype or -1 if the allele is missing.static intgtIndex(int a1, int a2) Returns the VCF genotype index for the specified pair of alleles.booleanReturnstrueif the specified FORMAT subfield is present, and returnsfalseotherwise.info()Returns the INFO field.booleanisPhased()Returnstrueif every genotype for each sample is a phased, non-missing genotype, and returnsfalseotherwise.booleanisPhased(int sample) Returnstrueif the genotype for the specified sample has non-missing alleles and is either haploid or diploid with a phased allele separator, and returnsfalseotherwise.marker()Returns the marker.intReturns the number of FORMAT subfields.qual()Returns the QUAL field.sampleData(int sample) Returns the data for the specified sample.sampleData(int sample, int subfieldIndex) Returns the specified data for the specified sample.sampleData(int sample, String formatCode) Returns the specified data for the specified sample.samples()Returns the list of samples.intsize()Returns the number of haplotypes.toString()Returns the VCF record.Returns the VCF meta-information lines and the VCF header line.
-
Constructor Details
-
VcfRec
Constructs a newVcfRecinstance from a VCF record.- Parameters:
vcfHeader- meta-information lines and header line for the specified VCF record.vcfRecord- a VCF record with a GL format field corresponding to the specifiedvcfHeaderobjectmarkerParser- a filter for a VCF record's ID, QUAL, FILTER, and INFO subfields- Throws:
IllegalArgumentException- if the VCF record does not have a GT format fieldIllegalArgumentException- if a VCF record format error is detectedIllegalArgumentException- if there are notvcfHeader.nHeaderFields()tab-delimited fields in the specified VCF recordNullPointerException- if(vcfHeader == null) || (vcfRecord == null) || (markerParser == null)
-
-
Method Details
-
gtIndex
public static int gtIndex(int a1, int a2) Returns the VCF genotype index for the specified pair of alleles.- Parameters:
a1- the first allelea2- the second allele- Returns:
- the VCF genotype index for the specified pair of alleles
- Throws:
IllegalArgumentException- ifa1 < 0 || a2 < 0
-
qual
Returns the QUAL field.- Returns:
- the QUAL field
-
filter
Returns the FILTER field.- Returns:
- the FILTER field
-
info
Returns the INFO field.- Returns:
- the INFO field
-
format
Returns the FORMAT field. Returns the empty string ("") if the FORMAT field is missing.- Returns:
- the FORMAT field
-
nFormatSubfields
public int nFormatSubfields()Returns the number of FORMAT subfields.- Returns:
- the number of FORMAT subfields
-
formatSubfield
Returns the specified FORMAT subfield.- Parameters:
subfieldIndex- a FORMAT subfield index- Returns:
- the specified FORMAT subfield
- Throws:
IndexOutOfBoundsException- ifsubfieldIndex < 0 || subfieldIndex >= this.nFormatSubfields()
-
hasFormat
Returnstrueif the specified FORMAT subfield is present, and returnsfalseotherwise.- Parameters:
formatCode- a FORMAT subfield code- Returns:
trueif the specified FORMAT subfield is present
-
formatIndex
Returns the index of the specified FORMAT subfield if the specified subfield is defined for this VCF record, and returns -1 otherwise.- Parameters:
formatCode- the format subfield code- Returns:
- the index of the specified FORMAT subfield if the
specified subfield is defined for this VCF record, and
-1otherwise
-
sampleData
Returns the data for the specified sample.- Parameters:
sample- a sample index- Returns:
- the data for the specified sample
- Throws:
IndexOutOfBoundsException- ifsample < 0 || sample >= this.size()
-
sampleData
Returns the specified data for the specified sample.- Parameters:
sample- a sample indexformatCode- a FORMAT subfield code- Returns:
- the specified data for the specified sample
- Throws:
IllegalArgumentException- ifthis.hasFormat(formatCode)==falseIndexOutOfBoundsException- ifsample < 0 || sample >= this.size()
-
sampleData
Returns the specified data for the specified sample.- Parameters:
sample- a sample indexsubfieldIndex- a FORMAT subfield index- Returns:
- the specified data for the specified sample
- Throws:
IndexOutOfBoundsException- iffield < 0 || field >= this.nFormatSubfields()IndexOutOfBoundsException- ifsample < 0 || sample >= this.size()
-
formatData
Returns an array of lengththis.size()containing the specified FORMAT subfield data for each sample. Thek-th element of the array is the specified FORMAT subfield data for thek-th sample.- Parameters:
formatCode- a format subfield code- Returns:
- an array of length
this.size()containing the specified FORMAT subfield data for each sample - Throws:
IllegalArgumentException- ifthis.hasFormat(formatCode) == false
-
samples
Description copied from interface:GTRecReturns the list of samples. -
vcfHeader
Returns the VCF meta-information lines and the VCF header line.- Returns:
- the VCF meta-information lines and the VCF header line
-
marker
Description copied from interface:GTRecReturns the marker. -
get
public int get(int hap) Description copied from interface:GTRecReturns the specified allele for the specified haplotype or -1 if the allele is missing. The two alleles for a sample at a marker are arbitrarily ordered ifthis.unphased(marker, hap/2) == false. -
isPhased
public boolean isPhased(int sample) Description copied from interface:GTRecReturnstrueif the genotype for the specified sample has non-missing alleles and is either haploid or diploid with a phased allele separator, and returnsfalseotherwise. -
isPhased
public boolean isPhased()Description copied from interface:GTRecReturnstrueif every genotype for each sample is a phased, non-missing genotype, and returnsfalseotherwise. -
size
public int size()Description copied from interface:GTRecReturns the number of haplotypes. -
toString
Returns the VCF record.
-