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 newBasicMarker
instance from the specified data.BasicMarker(int chrom, int pos, java.lang.String[] ids, java.lang.String[] alleles, int end)
Constructs a newBasicMarker
instance from the specified data.BasicMarker(java.lang.String vcfRecord)
Constructs a newBasicMarker
instance from the specified string VCF record prefix.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.String
allele(int index)
Returns the specified allele.java.lang.String[]
alleles()
Returns the alleles.int
bitsPerAllele()
Returns the minimum number of bits required to store a non-missing allele.java.lang.String
chrom()
Returns the chromosome.int
chromIndex()
Returns the chromosome index.int
compareTo(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.int
end()
Returns the INFO END field, or -1 if there is no INFO END field.boolean
equals(java.lang.Object obj)
Returnstrue
if the specified object is aMarker
with the same chromosome, position, allele lists, and INFO END field, and returnsfalse
otherwise.static java.lang.String
flipStrand(java.lang.String allele)
Returns the string allele obtained by changing the specified allele to the opposite chromosome strandstatic 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.int
hashCode()
Returns the hash code value for this object.java.lang.String
id()
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.String
id(int index)
Returns the specified marker identifier.int
nAlleles()
Returns the number of alleles for the marker, including the REF allele.int
nGenotypes()
Returns the number of distinct genotypes, which equalsthis.nAlleles()*(1 + this.nAlleles())/2
.int
nIds()
Returns the number of marker identifiers.int
pos()
Returns the chromosome position coordinate.java.lang.String
toString()
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 newBasicMarker
instance 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 specifiedids
array or if any allele identifier in the specifiedalleles
array 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 == null
or if any element ofids
isnull
java.lang.NullPointerException
- ifalleles == null
or if any element ofalleles
isnull
-
BasicMarker
public BasicMarker(int chrom, int pos, java.lang.String[] ids, java.lang.String[] alleles, int end)
Constructs a newBasicMarker
instance from the specified data. The JVM will exit with an error message if any marker identifier in the specifiedids
array does not conform to the VCF specification, if any allele identifier in the specifiedalleles
array 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 == null
or if any element ofids
isnull
java.lang.NullPointerException
- ifalleles == null
or if any element ofalleles
isnull
-
BasicMarker
public BasicMarker(java.lang.String vcfRecord)
Constructs a newBasicMarker
instance 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:Marker
Returns the chromosome.
-
chromIndex
public int chromIndex()
Description copied from interface:Marker
Returns the chromosome index.- Specified by:
chromIndex
in interfaceMarker
- Returns:
- the chromosome index
-
pos
public int pos()
Description copied from interface:Marker
Returns the chromosome position coordinate.
-
nIds
public int nIds()
Description copied from interface:Marker
Returns the number of marker identifiers.
-
id
public java.lang.String id(int index)
Description copied from interface:Marker
Returns the specified marker identifier.
-
id
public java.lang.String id()
Description copied from interface:Marker
Returns 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:Marker
Returns the number of alleles for the marker, including the REF allele.
-
allele
public java.lang.String allele(int index)
Description copied from interface:Marker
Returns the specified allele. The reference allele has index 0.
-
alleles
public java.lang.String[] alleles()
Description copied from interface:Marker
Returns the alleles. Thek
-th element of the returned array is equal tothis.allele(k)
.
-
nGenotypes
public int nGenotypes()
Description copied from interface:Marker
Returns the number of distinct genotypes, which equalsthis.nAlleles()*(1 + this.nAlleles())/2
.- Specified by:
nGenotypes
in interfaceMarker
- Returns:
- the number of distinct genotypes
-
end
public int end()
Description copied from interface:Marker
Returns the INFO END field, or -1 if there is no INFO END field.
-
bitsPerAllele
public int bitsPerAllele()
Description copied from interface:Marker
Returns the minimum number of bits required to store a non-missing allele.- Specified by:
bitsPerAllele
in interfaceMarker
- Returns:
- the minimum number of bits required to store a non-missing allele
-
toString
public java.lang.String toString()
Description copied from interface:Marker
Returns 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:Marker
Returns 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:Marker
Returnstrue
if the specified object is aMarker
with the same chromosome, position, allele lists, and INFO END field, and returnsfalse
otherwise. Equality does not depend on value of the VCF record ID field.
-
compareTo
public int compareTo(Marker other)
Description copied from interface:Marker
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. 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:
compareTo
in interfacejava.lang.Comparable<Marker>
- Specified by:
compareTo
in interfaceMarker
- Parameters:
other
- theMarker
to 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
-
-