Package vcf
Class BasicMarker
- java.lang.Object
-
- vcf.BasicMarker
-
-
Constructor Summary
Constructors Constructor Description BasicMarker(int chrom, int pos, java.lang.String[] ids, java.lang.String[] alleles)Constructs a newBasicMarkerinstance from the specified data.BasicMarker(int chrom, int pos, java.lang.String[] ids, java.lang.String[] alleles, int end)Constructs a newBasicMarkerinstance from the specified data.BasicMarker(java.lang.String vcfRecord)Constructs a newBasicMarkerinstance from the specified string VCF record prefix.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Stringallele(int index)Returns the specified allele.java.lang.String[]alleles()Returns the alleles.intbitsPerAllele()Returns the minimum number of bits required to store a non-missing allele.java.lang.Stringchrom()Returns the chromosome.intchromIndex()Returns the chromosome index.intcompareTo(Marker other)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.intend()Returns the INFO END field, or -1 if there is no INFO END field.booleanequals(java.lang.Object obj)Returnstrueif the specified object is aMarkerwith the same chromosome, position, allele lists, and INFO END field, and returnsfalseotherwise.static java.lang.StringflipStrand(java.lang.String allele)Returns the string allele obtained by changing the specified allele to the opposite chromosome strandstatic MarkerflipStrand(Marker marker)Constructs and returns a new marker obtained from the specified marker by changing the marker's non-symbolic alleles to the alleles on the opposite chromosome strand.inthashCode()Returns the hash code value for this object.java.lang.Stringid()Returns the first marker identifier if there is at least one identifier in the VCF record ID field, and returnsthis.chr() + ":" + this.pos()otherwise.java.lang.Stringid(int index)Returns the specified marker identifier.intnAlleles()Returns the number of alleles for the marker, including the REF allele.intnGenotypes()Returns the number of distinct genotypes, which equalsthis.nAlleles()*(1 + this.nAlleles())/2.intnIds()Returns the number of marker identifiers.intpos()Returns the chromosome position coordinate.java.lang.StringtoString()Returns a string equal to the first five tab-delimited fields of a VCF record corresponding to this marker.
-
-
-
Constructor Detail
-
BasicMarker
public BasicMarker(int chrom, int pos, java.lang.String[] ids, java.lang.String[] alleles)Constructs a newBasicMarkerinstance from the specified data. Theend()method of the new instance will return-1. The JVM will exit with an error message if any marker identifier in the specifiedidsarray or if any allele identifier in the specifiedallelesarray does not conform to the VCF specification.- Parameters:
chrom- a chromosome indexpos- the marker positionids- a list of marker identifiersalleles- a list of alleles beginning with the reference allele- Throws:
java.lang.IllegalArgumentException- ifchrom < 0 || chrom >= ChromIds.instance().size()java.lang.NullPointerException- ifids == nullor if any element ofidsisnulljava.lang.NullPointerException- ifalleles == nullor if any element ofallelesisnull
-
BasicMarker
public BasicMarker(int chrom, int pos, java.lang.String[] ids, java.lang.String[] alleles, int end)Constructs a newBasicMarkerinstance from the specified data. The JVM will exit with an error message if any marker identifier in the specifiedidsarray does not conform to the VCF specification, if any allele identifier in the specifiedallelesarray does not conform to the VCF specification, or if(end != -1 && end < pos).- Parameters:
chrom- a chromosome indexpos- the marker positionids- a list of marker identifiersalleles- a list of alleles beginning with the reference alleleend- the INFO END field, or -1 if there is no INFO END field- Throws:
java.lang.IllegalArgumentException- ifchrom < 0 || chrom >= ChromIds.instance().size()java.lang.NullPointerException- ifids == nullor if any element ofidsisnulljava.lang.NullPointerException- ifalleles == nullor if any element ofallelesisnull
-
BasicMarker
public BasicMarker(java.lang.String vcfRecord)
Constructs a newBasicMarkerinstance from the specified string VCF record prefix.- Parameters:
vcfRecord- a VCF record prefix- Throws:
java.lang.IllegalArgumentException- if the specified VCF record prefix has fewer than 8 tab-delimited fields, or if a format error is detected in the first 8 fields of the specified VCF recordjava.lang.NullPointerException- ifvcfRecord == null
-
-
Method Detail
-
flipStrand
public static Marker flipStrand(Marker marker)
Constructs and returns a new marker obtained from the specified marker by changing the marker's non-symbolic alleles to the alleles on the opposite chromosome strand.- Parameters:
marker- a marker- Returns:
- the equivalent marker on the opposite chromosome strand
- Throws:
java.lang.NullPointerException- ifmarker == null
-
flipStrand
public static java.lang.String flipStrand(java.lang.String allele)
Returns the string allele obtained by changing the specified allele to the opposite chromosome strand- Parameters:
allele- a string allele- Returns:
- the string allele obtained by changing the specified allele to the opposite chromosome strand
- Throws:
java.lang.IllegalArgumentException- if any character in the specified string is not 'A', 'C', 'G', 'T', 'N', or '*'.java.lang.NullPointerException- ifallele == null
-
chrom
public java.lang.String chrom()
Description copied from interface:MarkerReturns the chromosome.
-
chromIndex
public int chromIndex()
Description copied from interface:MarkerReturns the chromosome index.- Specified by:
chromIndexin interfaceMarker- Returns:
- the chromosome index
-
pos
public int pos()
Description copied from interface:MarkerReturns the chromosome position coordinate.
-
nIds
public int nIds()
Description copied from interface:MarkerReturns the number of marker identifiers.
-
id
public java.lang.String id(int index)
Description copied from interface:MarkerReturns the specified marker identifier.
-
id
public java.lang.String id()
Description copied from interface:MarkerReturns the first marker identifier if there is at least one identifier in the VCF record ID field, and returnsthis.chr() + ":" + this.pos()otherwise.
-
nAlleles
public int nAlleles()
Description copied from interface:MarkerReturns the number of alleles for the marker, including the REF allele.
-
allele
public java.lang.String allele(int index)
Description copied from interface:MarkerReturns the specified allele. The reference allele has index 0.
-
alleles
public java.lang.String[] alleles()
Description copied from interface:MarkerReturns the alleles. Thek-th element of the returned array is equal tothis.allele(k).
-
nGenotypes
public int nGenotypes()
Description copied from interface:MarkerReturns the number of distinct genotypes, which equalsthis.nAlleles()*(1 + this.nAlleles())/2.- Specified by:
nGenotypesin interfaceMarker- Returns:
- the number of distinct genotypes
-
end
public int end()
Description copied from interface:MarkerReturns the INFO END field, or -1 if there is no INFO END field.
-
bitsPerAllele
public int bitsPerAllele()
Description copied from interface:MarkerReturns the minimum number of bits required to store a non-missing allele.- Specified by:
bitsPerAllelein interfaceMarker- Returns:
- the minimum number of bits required to store a non-missing allele
-
toString
public java.lang.String toString()
Description copied from interface:MarkerReturns a string equal to the first five tab-delimited fields of a VCF record corresponding to this marker.
-
hashCode
public int hashCode()
Description copied from interface:MarkerReturns the hash code value for this object. The hash code does not depend on value of the VCF record ID field. The hash code is defined by the following calculation:
int hash = 5; hash = 29 * hash + this.chromIndex(); hash = 29 * hash + this.pos(); for (int j=0, n=this.nAlleles(); j<n; ++j) { hash = 29 * hash + alleles[j].hashCode(); } hash = 29 * hash + end();
-
equals
public boolean equals(java.lang.Object obj)
Description copied from interface:MarkerReturnstrueif the specified object is aMarkerwith the same chromosome, position, allele lists, and INFO END field, and returnsfalseotherwise. Equality does not depend on value of the VCF record ID field.
-
compareTo
public int compareTo(Marker other)
Description copied from interface:MarkerCompares 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. Comparison is on chromosome index, position, allele identifier lists, and end value in that order. Allele identifier lists are compared for lexicographical order, and alleles are compared using theString compareTo()method.- Specified by:
compareToin interfacejava.lang.Comparable<Marker>- Specified by:
compareToin interfaceMarker- 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
-
-