public class VCF
extends java.lang.Object
Constructor | Description |
---|---|
VCF(java.io.File f) |
Constructor from a VCF file
|
VCF(java.io.File f,
java.util.List<PositionFilter> filters) |
Constructor from a file, filtering positions at read time.
|
VCF(java.io.File f,
java.util.List<PositionFilter> preFilters,
java.util.List<PositionChanger> positionChangers,
java.util.List<GenotypeChanger> genotypeChangers,
java.util.List<PositionFilter> filters,
java.util.List<java.lang.String> requiredFormats) |
Constructor from a file, filtering positions at read time and changing
genotypes read in.
|
VCF(Meta meta,
java.util.List<Position> positions) |
Create a VCF object from data rather than a file
|
Modifier and Type | Method | Description |
---|---|---|
<V> V[][] |
asArray(java.lang.String format,
Mapper<V> mapper) |
Gets data from the genotypes in the VCF as an array
|
<V> V[][] |
asArrayTransposed(java.lang.String format,
Mapper<V> mapper) |
Gets data from the genotypes in the VCF as a transposed array
|
byte[][] |
asByteArray(java.lang.String format,
ByteMapper mapper) |
Gets data from the genotypes in the VCF as a byte array
|
byte[][] |
asByteArrayTransposed(java.lang.String format,
ByteMapper mapper) |
Gets data from the genotypes in the VCF as a transposed byte array
|
double[][] |
asDoubleArray(java.lang.String format,
DoubleMapper mapper) |
Gets data from the genotypes in the VCF as a double array
|
double[][] |
asDoubleArrayTransposed(java.lang.String format,
DoubleMapper mapper) |
Gets data from the genotypes in the VCF as a transposed double array
|
int[][] |
asIntegerArray(java.lang.String format,
IntegerMapper mapper) |
Gets data from the genotypes in the VCF as an integer array
|
int[][] |
asIntegerArrayTransposed(java.lang.String format,
IntegerMapper mapper) |
Gets data from the genotypes in the VCF as a transposed integer array
|
void |
filterPositions(PositionFilter filter) |
Filter the positions based on the given filter.
|
void |
filterSamples(SampleFilter filter) |
Filter the samples based on the given filter.
|
java.util.stream.Stream<Genotype> |
genotypesByPositionStream() |
Gets a stream of genotypes by position.
|
java.util.stream.Stream<Genotype> |
genotypesBySampleStream() |
Gets a stream of genotypes by sample.
|
java.util.stream.Stream<Genotype> |
genotypeStream() |
Gets a stream of genotypes.
|
Meta |
getMeta() |
Get the meta information for this VCF
|
PositionMeta[] |
getPositions() |
Get a stream of position meta data
|
java.lang.String[] |
getSamples() |
Get a stream of sample names
|
void |
limitToPositions(java.util.List<PositionMeta> keep) |
Limits the VCF to the given position.
|
void |
limitToSamples(java.util.List<java.lang.String> keep) |
Limits the VCF to the given samples.
|
int |
numberPositions() |
Returns the number of (visible) positions in the VCF
|
static int |
numberPositionsFromFile(java.io.File f) |
Utility function that returns the number of positions in a file
without reading in any data
|
int |
numberSamples() |
Returns the number of (visible) samples in the VCF
|
static int |
numberSamplesFromFile(java.io.File f) |
Utility function that returns the number of samples in a file
without reading in any data
|
java.util.stream.Stream<Position> |
positionStream() |
Returns a stream of positions in the VCF
|
void |
resetVisible() |
Resets all samples and positions to be visible, that is the state
immediately after the VCF was constructed.
|
java.util.stream.Stream<Sample> |
sampleStream() |
Returns a stream of samples in the VCF
|
Position |
singlePosition(PositionMeta position) |
Returns the data for a single position
|
Sample |
singleSample(java.lang.String sample) |
Returns the data for a single sample
|
void |
writeFile(java.io.File f) |
Writes the VCF to a file.
|
public VCF(java.io.File f) throws VCFException
f
- The VCF fileVCFException
- If there is a problem with the VCF file
or the data in it.public VCF(java.io.File f, java.util.List<PositionFilter> filters) throws VCFException
f
- The filefilters
- The position filters to applyVCFException
- If there is a problem with the VCF file
or the data in it.public VCF(java.io.File f, java.util.List<PositionFilter> preFilters, java.util.List<PositionChanger> positionChangers, java.util.List<GenotypeChanger> genotypeChangers, java.util.List<PositionFilter> filters, java.util.List<java.lang.String> requiredFormats) throws VCFException
f
- The filepreFilters
- A list of filters to be applied before any changes are
applied (e.g. to filter out snps without the required data)positionChangers
- List of changers to apply to the positionsgenotypeChangers
- List of changers to apply to the genotypesfilters
- The position filters to apply (after the changers)requiredFormats
- A list of formats required to be in the VCFVCFException
- If there is a problem with the VCF file
or the data in itpublic VCF(Meta meta, java.util.List<Position> positions) throws VCFDataException
meta
- The meta data for the VCFpositions
- The positions for the VCF (which includes information
on samples and genotypes).VCFDataException
- If there is a problem with the passed in list of positionspublic java.util.stream.Stream<Genotype> genotypeStream()
public java.util.stream.Stream<Genotype> genotypesByPositionStream()
public java.util.stream.Stream<Genotype> genotypesBySampleStream()
public Position singlePosition(PositionMeta position)
position
- The position meta data to return the data forpublic Sample singleSample(java.lang.String sample)
sample
- The string representing the sample to return the data forpublic java.util.stream.Stream<Position> positionStream()
public java.util.stream.Stream<Sample> sampleStream()
public Meta getMeta()
public void filterSamples(SampleFilter filter) throws VCFDataException
filter
- The sample filter to be applied.VCFDataException
- If there is a problem with the
data in the VCFpublic void filterPositions(PositionFilter filter) throws VCFDataException
filter
- The position filter to be applied.VCFDataException
- If there is a problem with the
data in the VCFpublic void limitToPositions(java.util.List<PositionMeta> keep)
keep
- The positions to keep.public void limitToSamples(java.util.List<java.lang.String> keep)
keep
- The positions to keep.public int numberPositions()
public int numberSamples()
public void writeFile(java.io.File f) throws java.io.IOException
f
- The file to write tojava.io.IOException
- If there is an IO problempublic <V> V[][] asArray(java.lang.String format, Mapper<V> mapper) throws VCFDataException
V
- The type of data returnedformat
- The format in the genotype data to get the data frommapper
- A mapper mapping from the string (in the VCF) to the
required typeVCFDataException
- If there is a problem with the
data in the VCFpublic <V> V[][] asArrayTransposed(java.lang.String format, Mapper<V> mapper) throws VCFDataException
V
- The type of data returnedformat
- The format in the genotype data to get the data frommapper
- A mapper mapping from the string (in the VCF) to the
required typeVCFDataException
- If there is a problem with the
data in the VCFpublic int[][] asIntegerArray(java.lang.String format, IntegerMapper mapper) throws VCFDataException
format
- The format in the genotype data to get the data frommapper
- A mapper mapping from the string (in the VCF) to an integerVCFDataException
- If there is a problem with the
data in the VCFpublic int[][] asIntegerArrayTransposed(java.lang.String format, IntegerMapper mapper) throws VCFDataException
format
- The format in the genotype data to get the data frommapper
- A mapper mapping from the string (in the VCF) to an integerVCFDataException
- If there is a problem with the
data in the VCFpublic double[][] asDoubleArray(java.lang.String format, DoubleMapper mapper) throws VCFDataException
format
- The format in the genotype data to get the data frommapper
- A mapper mapping from the string (in the VCF) to a doubleVCFDataException
- If there is a problem with the
data in the VCFpublic double[][] asDoubleArrayTransposed(java.lang.String format, DoubleMapper mapper) throws VCFDataException
format
- The format in the genotype data to get the data frommapper
- A mapper mapping from the string (in the VCF) to a doubleVCFDataException
- If there is a problem with the
data in the VCFpublic byte[][] asByteArray(java.lang.String format, ByteMapper mapper) throws VCFDataException
format
- The format in the genotype data to get the data frommapper
- A mapper mapping from the string (in the VCF) to a byteVCFDataException
- If there is a problem with the
data in the VCFpublic byte[][] asByteArrayTransposed(java.lang.String format, ByteMapper mapper) throws VCFDataException
format
- The format in the genotype data to get the data frommapper
- A mapper mapping from the string (in the VCF) to a byteVCFDataException
- If there is a problem with the
data in the VCFpublic java.lang.String[] getSamples()
public PositionMeta[] getPositions()
public void resetVisible()
public static int numberPositionsFromFile(java.io.File f) throws VCFInputException
f
- The VCF fileVCFInputException
- If there is a problem with reading
the VCFpublic static int numberSamplesFromFile(java.io.File f) throws java.io.IOException
f
- The VCF filejava.io.IOException
- If there is an IO problem