Package vcf
Class Marker
java.lang.Object
vcf.Marker
- All Implemented Interfaces:
Comparable<Marker>
Class Marker represents a VCF record's CHROM, POS, ID, REF,
ALT, QUAL, FILTER, and INFO fields. The number of alleles in the VCF
record must be less than or equal to Marker.MAX_N_ALLELES.
Instances of class Marker are immutable.
-
Method Summary
Modifier and TypeMethodDescriptionalleles()Returns the tab-separated VCF REF and ALT fieldsvoidAppends the first eight tab-delimited fields of a VCF record for this marker (the CHROM, POS, ID, REF, ALT, QUAL, FILTER, and INFO fields) to the specifiedStringBuilder.voidappendFirst8Fields(StringBuilder sb, int an, int[] alleleCounts) Appends the first eight tab-delimited fields of a VCF record for this marker (the CHROM, POS, ID, REF, ALT, QUAL, FILTER, and INFO fields) and add the specified INFO/AN and INFO/AC fields.intReturns the minimum number of bits required to store a non-missing allele.chrom()Returns the VCF CHROM field.intReturns the chromosome index.intCompares this marker with the specified marker for order, and returns a negative integer, 0, or a positive integer depending on whether this marker is less than, equal to, or greater than the specified marker.endValue()Returns the INFO/END value.booleanReturnstrueif the specified object is aMarkerwith the same chromosome, position, alleles, and INFO/END value, and returnsfalseotherwise.filter()Returns the VCF FILTER field.booleanReturnstrueif the VCF INFO/END field is defined, and returnsfalseotherwise.booleanReturnstrueif the VCF FILTER field has non-missing data, and returnsfalseotherwise.inthashCode()Returns the hash code value for this object.booleanReturnstrueif the VCF ID field has non-missing data, and returnsfalseotherwise.booleanReturnstrueif the VCF INFO field has non-missing data, and returnsfalseotherwise.booleanReturnstrueif the VCF QUAL field has non-missing data, and returnsfalseotherwise.id()Returns the VCF ID field.info()Returns the VCF INFO field.static Markerinstance(String rec, MarkerParser markerParser) Constructs a newMarkerinstance from the data.intnAlleles()Returns the number of alleles for the marker, including the REF allele.intReturns the number of nucleotides in the reference allele.intpos()Returns the VCF POS fieldqual()Returns the VCF QUAL field.static MarkerreadNonPosFields(short chromIndex, int pos, DataInput in) Reads the VCF record ID, REF, ALT, QUAL, FILTER, and INFO fields and returns a marker with these fields and the specified CHROM and POS fields.toString()Returns a string equal to the first five tab-delimited fields of a VCF record corresponding to this marker (the CHROM, POS, ID, REF, and ALT fields).voidWrites a representation of the VCF record ID, REF, ALT, QUAL, FILTER, and INFO fields to the specified output.
-
Method Details
-
instance
Constructs a newMarkerinstance from the data. If the specified VCF record contains an INFO/END field, the INFO/END field will be stored.- Parameters:
rec- a VCF recordmarkerParser- an object that filters and parses a VCF record's ID, QUAL, FILTER, and INFO subfields- Returns:
- a new
Markerinstance - Throws:
IllegalArgumentException- if the specified VCF record does not contain at least 8 tab charactersIllegalArgumentException- if the VCF CHROM field contains whitespaceIllegalArgumentException- if the specified VCF record has more than 255 allelesIndexOutOfBoundsException- if the index of the VCF CHROM field exceedsShort.MAX_VALUENullPointerException- if(vcfRecord == null) || (vcfFields==null)NumberFormatException- if the VCF record POS field is not a parsable integer
-
chrom
Returns the VCF CHROM field.- Returns:
- the VCF CHROM field
-
chromIndex
public int chromIndex()Returns the chromosome index.- Returns:
- the chromosome index
-
pos
public int pos()Returns the VCF POS field- Returns:
- the VCF POS field
-
hasIdData
public boolean hasIdData()Returnstrueif the VCF ID field has non-missing data, and returnsfalseotherwise.- Returns:
trueif the VCF ID field has non-missing data, and returnsfalseotherwise
-
hasQualData
public boolean hasQualData()Returnstrueif the VCF QUAL field has non-missing data, and returnsfalseotherwise.- Returns:
trueif the VCF QUAL field has non-missing data, and returnsfalseotherwise
-
hasFilterData
public boolean hasFilterData()Returnstrueif the VCF FILTER field has non-missing data, and returnsfalseotherwise.- Returns:
trueif the VCF FILTER field has non-missing data, and returnsfalseotherwise
-
hasInfoData
public boolean hasInfoData()Returnstrueif the VCF INFO field has non-missing data, and returnsfalseotherwise.- Returns:
trueif the VCF INFO field has non-missing data, and returnsfalseotherwise
-
hasEndValue
public boolean hasEndValue()Returnstrueif the VCF INFO/END field is defined, and returnsfalseotherwise.- Returns:
trueif the VCF INFO/END field has is defined
-
id
Returns the VCF ID field.- Returns:
- the VCF ID field
-
alleles
Returns the tab-separated VCF REF and ALT fields- Returns:
- the tab-separated VCF REF and ALT fields
-
nRefBases
public int nRefBases()Returns the number of nucleotides in the reference allele.- Returns:
- the number of nucleotides in the reference allele
-
nAlleles
public int nAlleles()Returns the number of alleles for the marker, including the REF allele.- Returns:
- the number of alleles for the marker, including the REF allele
-
bitsPerAllele
public int bitsPerAllele()Returns the minimum number of bits required to store a non-missing allele.- Returns:
- the minimum number of bits required to store a non-missing allele
-
qual
Returns the VCF QUAL field.- Returns:
- the VCF QUAL field
-
filter
Returns the VCF FILTER field.- Returns:
- the VCF FILTER field.
-
info
Returns the VCF INFO field.- Returns:
- the VCF INFO field.
-
endValue
Returns the INFO/END value. Returns "" if the INFO/END value is not defined.- Returns:
- the INFO/END value
-
hashCode
public int hashCode()Returns the hash code value for this object. The hash code is defined by the following calculation:
int hash = 5; hash = 29 * hash + this.chromIndex(); hash = 29 * hash + this.pos(); hash = 29 * hash + this.alleles().hashCode(); hash = 29 * hash + this.endValue().hashCode();
-
equals
Returnstrueif the specified object is aMarkerwith the same chromosome, position, alleles, and INFO/END value, and returnsfalseotherwise. -
compareTo
Compares this marker with the specified marker for order, and returns a negative integer, 0, or a positive integer depending on whether this marker is less than, equal to, or greater than the specified marker. Markers are compared using the values returned by thechromIndex(),pos(),alleles(), andendValue()methods. The returned value is defined by the following calculation:if (this.chromIndex() != other.chromIndex()) { return (this.chromIndex < other.chromIndex()) ? -1 : 1; } if (this.pos() != other.pos()) { return (this.pos < other.pos()) ? -1 : 1; } int value = this.alleles().compareTo(other.alleles()); if (value!=0) { return value; } return this.endValue().compareTo(other.endValue());- Specified by:
compareToin interfaceComparable<Marker>- Parameters:
other- theMarkerto be compared- Returns:
- a negative integer, 0, or a positive integer depending on whether this marker is less than, equal, or greater than the specified marker
-
writeNonPosFields
Writes a representation of the VCF record ID, REF, ALT, QUAL, FILTER, and INFO fields to the specified output. The exact details of the representation are unspecified and subject to change. The written data can be read with theMarker.readNonPosFields()method.- Parameters:
out- the output destination- Throws:
IOException- if an I/O error occursNullPointerException- ifout == null
-
readNonPosFields
Reads the VCF record ID, REF, ALT, QUAL, FILTER, and INFO fields and returns a marker with these fields and the specified CHROM and POS fields. The contract for this method is unspecified ifchromIndexis not a valid chromosome index.- Parameters:
chromIndex- the chromosome indexpos- the chromosome positionin- the input source- Returns:
- a
Marker - Throws:
IOException- if an I/O error occursNullPointerException- ifin == null
-
toString
Returns a string equal to the first five tab-delimited fields of a VCF record corresponding to this marker (the CHROM, POS, ID, REF, and ALT fields). -
appendFirst8Fields
Appends the first eight tab-delimited fields of a VCF record for this marker (the CHROM, POS, ID, REF, ALT, QUAL, FILTER, and INFO fields) to the specifiedStringBuilder.- Parameters:
sb- theStringBuilderto be appended- Throws:
NullPointerException- if(sb == null)
-
appendFirst8Fields
Appends the first eight tab-delimited fields of a VCF record for this marker (the CHROM, POS, ID, REF, ALT, QUAL, FILTER, and INFO fields) and add the specified INFO/AN and INFO/AC fields. If the INFO/AN or iNFO/AC fields exist inthis.info(), the fields will be replaced with the specified INFO/AN and INFO/AC fields.- Parameters:
sb- theStringBuilderto be appendedan- the total number of alleles in called genotypesalleleCounts- an array of lengththis.nAlleles()whosek-thentry is the allele count in called genotypes for thek-th allele- Throws:
IllegalArgumentException- if(this.nAlleles() != alleleCounts.length)NullPointerException- if((sb == null) || (alleleCounts == null))
-