Package vcf
Class PlinkGenMap
- java.lang.Object
-
- vcf.PlinkGenMap
-
- All Implemented Interfaces:
GeneticMap
public final class PlinkGenMap extends java.lang.Object implements GeneticMap
Class
PlinkGenMap
represents a genetic map derived from a PLINK map file with map positions in cM units for one or more chromosomes.Instances of class
PlinkGenMap
are immutable.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description int
basePos(int chrom, double geneticPosition)
Returns the base position corresponding to the specified genetic map position.int
closestIndex(int chrom, int basePosition)
Returns the index of the genetic map position that is closest to the specified base position.static PlinkGenMap
fromPlinkMapFile(java.io.File mapFile)
Constructs and returns a newPlinkGenMap
instance from the data in the specified file.static PlinkGenMap
fromPlinkMapFile(java.io.File mapFile, java.lang.String chrom)
Constructs and returns a newPlinkGenMap
instance from the data in the specified file.double
genPos(int chrom, int basePosition)
Returns the genetic map position of the specified genome coordinate.double
genPos(Marker marker)
Returns the genetic map position of the specified marker.int
index2BasePos(int chrom, int index)
Returns the specified base positiondouble
index2GenPos(int chrom, int index)
Returns the specified genetic map positionint
nMapPositions(int chrom)
Returns the number of mapped loci in this genetic map.java.lang.String
toString()
Returns a string representation of this genetic map.
-
-
-
Method Detail
-
fromPlinkMapFile
public static PlinkGenMap fromPlinkMapFile(java.io.File mapFile)
Constructs and returns a newPlinkGenMap
instance from the data in the specified file.- Parameters:
mapFile
- a genetic map file in PLINK format with genetic map positions in cM units- Returns:
- a new
PlinkGenMap
instance - Throws:
java.lang.IllegalArgumentException
- if any map position is infinite orNaN
java.lang.NullPointerException
- ifmapFile == null
java.lang.NumberFormatException
- if the base position on any line of the map file is not a parsable integerjava.lang.NumberFormatException
- if the genetic map position on any line of the map file is not a parsable doublejava.lang.IllegalArgumentException
- if a non-empty line of the specified genetic map file does not contain 4 fieldsjava.lang.IllegalArgumentException
- if the map positions on each chromosome are not sorted in ascending orderjava.lang.IllegalArgumentException
- if there are duplicate base positions on a chromosomejava.lang.IllegalArgumentException
- if all base positions on a chromosome have the same genetic map position
-
fromPlinkMapFile
public static PlinkGenMap fromPlinkMapFile(java.io.File mapFile, java.lang.String chrom)
Constructs and returns a newPlinkGenMap
instance from the data in the specified file. The returned genetic map will contain only positions on the specified chromosome- Parameters:
mapFile
- a genetic map file in PLINK format with genetic map positions in cM unitschrom
- a chromosome- Returns:
- a new
PlinkGenMap
instance - Throws:
java.lang.IllegalArgumentException
- if any map position is infinite orNaN
.java.lang.NullPointerException
- ifmapFile == null || chrom == null
java.lang.NumberFormatException
- if the base position on a line of the map file that corresponds to the specified chromosome is not a parsable integerjava.lang.NumberFormatException
- if the genetic map position on a line of the map file that corresponds to the specified chromosome is not a parsable doublejava.lang.IllegalArgumentException
- if a non-empty line of the specified genetic map file does not contain 4 fieldsjava.lang.IllegalArgumentException
- if the map positions on the specified chromosome are not sorted in ascending orderjava.lang.IllegalArgumentException
- if there are duplicate base positions on the specified chromosomejava.lang.IllegalArgumentException
- if all base positions on the specified chromosome have the same genetic map positionjava.lang.IllegalArgumentException
- if the specified chromosome does not have at least two distinct positions in the genetic map
-
nMapPositions
public int nMapPositions(int chrom)
Returns the number of mapped loci in this genetic map.- Parameters:
chrom
- a chromosome index- Returns:
- the number of mapped loci in this genetic map
- Throws:
java.lang.IllegalArgumentException
- if this genetic map has no map positions for the specified chromosomejava.lang.IndexOutOfBoundsException
- ifchrom < 0 || chrom >= ChromIds.instance().size()
-
index2BasePos
public int index2BasePos(int chrom, int index)
Returns the specified base position- Parameters:
chrom
- a chromosome indexindex
- a map position index- Returns:
- the specified base position
- Throws:
java.lang.IllegalArgumentException
- if this genetic map has no map positions for the specified chromosomejava.lang.IndexOutOfBoundsException
- ifchrom < 0 || chrom >= ChromIds.instance().size()
java.lang.IndexOutOfBoundsException
- ifindex < 0 || index >= this.nMapPositions(chrom)
-
index2GenPos
public double index2GenPos(int chrom, int index)
Returns the specified genetic map position- Parameters:
chrom
- a chromosome indexindex
- a map position index- Returns:
- the specified genetic map position
- Throws:
java.lang.IllegalArgumentException
- if this genetic map has no map positions for the specified chromosomejava.lang.IndexOutOfBoundsException
- ifchrom < 0 || chrom >= ChromIds.instance().size()
java.lang.IndexOutOfBoundsException
- ifindex < 0 || index >= this.nMapPositions(chrom)
-
closestIndex
public int closestIndex(int chrom, int basePosition)
Returns the index of the genetic map position that is closest to the specified base position.- Parameters:
chrom
- a chromosome indexbasePosition
- a base position- Returns:
- the genetic map position index that is closes to the specified base position.
- Throws:
java.lang.IllegalArgumentException
- if this genetic map has no map positions for the specified chromosomejava.lang.IndexOutOfBoundsException
- ifchrom < 0 || chrom >= ChromIds.instance().size()
-
genPos
public double genPos(Marker marker)
Description copied from interface:GeneticMap
Returns the genetic map position of the specified marker. The genetic map position is estimated using linear interpolation.- Specified by:
genPos
in interfaceGeneticMap
- Parameters:
marker
- a genetic marker- Returns:
- the genetic map position of the specified marker
-
genPos
public double genPos(int chrom, int basePosition)
Description copied from interface:GeneticMap
Returns the genetic map position of the specified genome coordinate. The genetic map position is estimated using linear interpolation.- Specified by:
genPos
in interfaceGeneticMap
- Parameters:
chrom
- the chromosome indexbasePosition
- the base coordinate on the chromosome- Returns:
- the genetic map position of the specified genome coordinate
-
basePos
public int basePos(int chrom, double geneticPosition)
Description copied from interface:GeneticMap
Returns the base position corresponding to the specified genetic map position. If the genetic position is not a map position then the base position is estimated from the nearest genetic map positions using linear interpolation.- Specified by:
basePos
in interfaceGeneticMap
- Parameters:
chrom
- the chromosome indexgeneticPosition
- the genetic position on the chromosome- Returns:
- the base position corresponding to the specified genetic map position
-
toString
public java.lang.String toString()
Description copied from interface:GeneticMap
Returns a string representation of this genetic map. The exact details of the representation are unspecified and subject to change.- Specified by:
toString
in interfaceGeneticMap
- Overrides:
toString
in classjava.lang.Object
- Returns:
- a string representation of this genetic map
-
-