Package main
Class Pedigree
- java.lang.Object
-
- main.Pedigree
-
public class Pedigree extends java.lang.Object
Class
Pedigree
stores parent-offspring relationships in a list of samples. In particular, classPedigree
stores a list of the single individuals in the list of samples, a list of the parent-offspring duos in the list of samples, and a list of the parent-offspring trios in the list of samples. A single individual is an individuals without a parent or offspring in the list of samples.Instances of class
Pedigree
are immutable.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
duoOffspring(int index)
Returns the sample index of the offspring of the specified parent-offspring duo.int
duoParent(int index)
Returns the sample index of the parent of the specified parent-offspring duo.int
father(int sample)
Returns the sample index of the father of the specified sample, or returns-1
if the father is unknown or is not present in the list of samples.int
mother(int sample)
Returns the sample index of the mother of the specified sample, or returns-1
if the mother is unknown or is not present in the list of samples.int
nDuos()
Returns the number of parent-offspring duos in the list of samples.int
nOffspring(int sample)
Returns the number of offspring of the specified sample.int
nSamples()
Returns the number of samples.int
nSingles()
Returns the number of single individuals in the list of samples.int
nTrios()
Returns the number of parent-offspring trios in the list of samples.int
offspring(int sample, int index)
Returns the sample index of the offspring of the specified sample.int[]
relateds()
Returns an array of indices of samples with at least one parent or child in the list or samples.Samples
samples()
Returns the list of samples.int
single(int index)
Returns the sample index of the specified single individual.int[]
singles()
Returns an array of indices of samples with no parents or children in the list of samples.java.lang.String
toString()
Returns a string representation ofthis
.int
trioFather(int index)
Returns the sample index of the father of the specified parent-offspring trio.int
trioMother(int index)
Returns the sample index of the mother of the specified parent-offspring trio.int
trioOffspring(int index)
Returns the sample index of the offspring of the specified parent-offspring trio.
-
-
-
Constructor Detail
-
Pedigree
public Pedigree(Samples samples, java.io.File pedFile)
Constructs a newNuclearFamilies
instance.- Parameters:
samples
- the list of samples.pedFile
- a linkage-format pedigree file, ornull
if no pedigree relationships are known. A pedigree file must have at least 4 white-space delimited columns. The first column of the pedigree file (family ID) is ignored. The second, third, and fourth columns are the individual's ID, the individual's father's ID, and the individual's mother's ID respectively.- Throws:
java.lang.IllegalArgumentException
- if a pedigree file is specified, and if the file has a non-blank line with less than 4 white-space delimited fieldsjava.lang.IllegalArgumentException
- if a pedigree file is specified, and if the file has duplicate individual identifiers in the second white-space delimited columnjava.lang.NullPointerException
- ifsamples == null
-
-
Method Detail
-
samples
public Samples samples()
Returns the list of samples.- Returns:
- the list of samples
-
nSamples
public int nSamples()
Returns the number of samples.- Returns:
- the number of samples
-
nSingles
public int nSingles()
Returns the number of single individuals in the list of samples. A single individual has no parent or offspring in the list of samples.- Returns:
- the number of single individuals in the sample
-
nDuos
public int nDuos()
Returns the number of parent-offspring duos in the list of samples. The offspring of a parent-offspring duo has only one parent in the sample.- Returns:
- the number of parent-offspring duos in the list of samples
-
nTrios
public int nTrios()
Returns the number of parent-offspring trios in the list of samples. The offspring of a parent-offspring trio has two parents in the sample.- Returns:
- the number of parent-offspring trios in the list of samples
-
singles
public int[] singles()
Returns an array of indices of samples with no parents or children in the list of samples.- Returns:
- an array of indices of samples with no parents or children in the list of samples
-
relateds
public int[] relateds()
Returns an array of indices of samples with at least one parent or child in the list or samples.- Returns:
- an array of indices of samples with at least one parent or child in the list or samples
-
single
public int single(int index)
Returns the sample index of the specified single individual. A single individual has no first-degree relative in the list of samples.- Parameters:
index
- the index of a single individual- Returns:
- the sample index of the specified single individual
- Throws:
java.lang.IndexOutOfBoundsException
- ifindex < 0 || index >= this.nSingles()
-
duoParent
public int duoParent(int index)
Returns the sample index of the parent of the specified parent-offspring duo.- Parameters:
index
- the index of a parent-offspring duo- Returns:
- the sample index of the parent of the specified parent-offspring duo
- Throws:
java.lang.IndexOutOfBoundsException
- ifindex < 0 || index >= this.nDuos()
-
duoOffspring
public int duoOffspring(int index)
Returns the sample index of the offspring of the specified parent-offspring duo.- Parameters:
index
- the index of a parent-offspring duo- Returns:
- the sample index of the offspring of the specified parent-offspring duo
- Throws:
java.lang.IndexOutOfBoundsException
- ifindex < 0 || index >= this.nDuos()
-
trioFather
public int trioFather(int index)
Returns the sample index of the father of the specified parent-offspring trio.- Parameters:
index
- the index of a parent-offspring trio- Returns:
- the sample index of the father of the specified parent-offspring trio
- Throws:
java.lang.IndexOutOfBoundsException
- ifindex < 0 || index >= this.nTrios()
-
trioMother
public int trioMother(int index)
Returns the sample index of the mother of the specified parent-offspring trio.- Parameters:
index
- the index of a parent-offspring trio- Returns:
- the sample index of the mother of the specified parent-offspring trio
- Throws:
java.lang.IndexOutOfBoundsException
- ifindex < 0 || index >= this.nTrios()
-
trioOffspring
public int trioOffspring(int index)
Returns the sample index of the offspring of the specified parent-offspring trio.- Parameters:
index
- the index of a parent-offspring trio- Returns:
- the sample index of the offspring of the specified parent-offspring trio
- Throws:
java.lang.IndexOutOfBoundsException
- ifindex < 0 || index >= this.nTrios()
-
father
public int father(int sample)
Returns the sample index of the father of the specified sample, or returns-1
if the father is unknown or is not present in the list of samples.- Parameters:
sample
- a sample index- Returns:
- the sample index of the father of the specified sample,
or
-1
if the father is unknown or is not present in the list of samples - Throws:
java.lang.IndexOutOfBoundsException
- ifsample < 0 || sample >= this.size()()
-
mother
public int mother(int sample)
Returns the sample index of the mother of the specified sample, or returns-1
if the mother is unknown or is not present in the list of samples.- Parameters:
sample
- a sample index- Returns:
- the sample index of the mother of the specified sample,
or
-1
if the mother is unknown or is not present in the list of samples - Throws:
java.lang.IndexOutOfBoundsException
- ifsample < 0 || sample >= this.size()()
-
nOffspring
public int nOffspring(int sample)
Returns the number of offspring of the specified sample.- Parameters:
sample
- a sample index- Returns:
- the number of offspring of the specified sample
- Throws:
java.lang.IndexOutOfBoundsException
- ifsample < 0 || sample >= this.size()()
-
offspring
public int offspring(int sample, int index)
Returns the sample index of the offspring of the specified sample.- Parameters:
sample
- a sample indexindex
- the offspring index- Returns:
- the sample index of the offspring of the specified sample.
- Throws:
java.lang.IndexOutOfBoundsException
- ifsample < 0 || sample >= this.size()()
java.lang.IndexOutOfBoundsException
- ifindex < 0 || index >= this.nOffspring(sample)
-
toString
public java.lang.String toString()
Returns a string representation ofthis
. The exact details of the representation are unspecified and subject to change.- Overrides:
toString
in classjava.lang.Object
- Returns:
- a string representation of
this
-
-