public class VCFParser extends Object implements Closeable
##INFO=<ID=AF1,Number=1,Type=Float,Description="Max-likelihood ...">This parser can additionally read a Group attribute, such as in:
##INFO=<ID=AF1,Number=1,Type=Float,Group=LIKELIHOODS,Description="Max-likelihood ...">
| Modifier and Type | Class and Description |
|---|---|
class |
VCFParser.SyntaxException |
| Modifier and Type | Field and Description |
|---|---|
static Comparator<ColumnInfo> |
COLUMN_SORT
Sorts columns in increasing columnIndex order.
|
static Comparator<ColumnField> |
FIELD_SORT
Sorts fields in increasing globalFieldIndex order.
|
| Constructor and Description |
|---|
VCFParser(Reader file)
Constructs a VCF parser.
|
VCFParser(String filename)
Constructs a VCF parser.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Releases the IO resources held by this parser.
|
int |
countAllFields()
Returns the total number of fields across all columns.
|
static ColumnInfo[] |
fixedColumn() |
String |
getColumnName(int columnIndex) |
String[] |
getColumnNamesUsingFormat()
Return the sample names, or more specifically, the names of column that use the FORMAT column.
|
Columns |
getColumns()
Return the columns in the file.
|
ColumnType |
getColumnType(int columnIndex) |
CharSequence |
getColumnValue(int columnIndex)
Returns a column value as a CharSequence.
|
String |
getFieldName(int globalFieldIndex)
Return the field name, in the format:
For columns with multiple fields: <column-name>[<field-id>]
For columns with a single field: <column-name>[<field-id>]
|
int |
getFieldNumValues(int globalFieldIndex)
Return the number of values in the specified field.
|
ColumnType |
getFieldType(int globalFieldIndex)
Return the type of the specified field.
|
CharSequence |
getFieldValue(int globalFieldIndex)
Returns the value of the field.
|
int |
getGlobalFieldIndex(String columnName,
String fieldId)
Return a global field index, or -1 if the column or field id are not declared.
|
GroupAssociations |
getGroupAssociations() |
int |
getNumberOfColumns()
Return the number of columns in the file.
|
String |
getStringColumnValue(int columnIndex)
Returns a column value as a String.
|
String |
getStringFieldValue(int globalFieldIndex)
Returns the value of a field.
|
int |
getTsvLinesToScanForColumnType()
When scanning a TSV file to determine column types, this is the number of lines that will be checked.
|
boolean |
hasNextDataLine() |
boolean |
isCacheTsvColumnTypes()
If we should cache the TSV column types to a .colinfo file when parsing TSV files.
|
void |
next() |
void |
readHeader()
Read the header of this file.
|
void |
readTsvColumnTypes()
If parsing a TSV file, this can be called to retrieve the column types map.
|
void |
setCacheFieldPermutation(boolean cacheFieldPermutation) |
void |
setCacheTsvColumnTypes(boolean cacheTsvColumnTypes)
If we should cache the TSV column types to a .colinfo file when parsing TSV files.
|
void |
setTsvLinesToScanForColumnType(int tsvLinesToScanForColumnType)
When scanning a TSV file to determine column types, this is the number of lines that will be checked.
|
public static final Comparator<ColumnInfo> COLUMN_SORT
public static final Comparator<ColumnField> FIELD_SORT
public VCFParser(Reader file)
file - Input to parsepublic VCFParser(String filename) throws IOException
filename - Input to parseIOException - when an error occurs.public void setCacheTsvColumnTypes(boolean cacheTsvColumnTypes)
cacheTsvColumnTypes - new cacheTsvColumnTypes valuepublic boolean isCacheTsvColumnTypes()
public void setTsvLinesToScanForColumnType(int tsvLinesToScanForColumnType)
tsvLinesToScanForColumnType - the new value of tsvLinesToScanForColumnTypepublic int getTsvLinesToScanForColumnType()
public void readTsvColumnTypes()
throws IOException
IOException - if error reading / creating .colinfo cache filepublic int getNumberOfColumns()
public Columns getColumns()
public ColumnType getColumnType(int columnIndex)
public ColumnType getFieldType(int globalFieldIndex)
globalFieldIndex - global field index, from zero to countAllFields()-1public int getFieldNumValues(int globalFieldIndex)
globalFieldIndex - global field index, from zero to countAllFields()-1public String getColumnName(int columnIndex)
public boolean hasNextDataLine()
public void next()
public CharSequence getColumnValue(int columnIndex)
columnIndex - index of the field on a line of input.public int countAllFields()
public CharSequence getFieldValue(int globalFieldIndex)
globalFieldIndex - a global index that runs from zero to countAllFields()public String getStringFieldValue(int globalFieldIndex)
globalFieldIndex - a global index that runs from zero to countAllFields()public String getStringColumnValue(int columnIndex)
columnIndex - index of the field on a line of input.public String getFieldName(int globalFieldIndex)
globalFieldIndex - index of the field across columns.public void readHeader()
throws VCFParser.SyntaxException
VCFParser.SyntaxException - When the syntax of the VCF file is incorrect.public static ColumnInfo[] fixedColumn()
public int getGlobalFieldIndex(String columnName, String fieldId)
columnName - name of column.fieldId - Identifier for field in column.public void close()
throws IOException
close in interface Closeableclose in interface AutoCloseableIOExceptionpublic String[] getColumnNamesUsingFormat()
public void setCacheFieldPermutation(boolean cacheFieldPermutation)
public GroupAssociations getGroupAssociations()
Copyright © 2018 Campagne Laboratory. All rights reserved.