public class VCFWriter extends Object
| Modifier and Type | Field and Description |
|---|---|
int |
chromosomeColumnIndex |
static int |
COLUMN_NOT_DEFINED |
protected it.unimi.dsi.fastutil.objects.Object2IntMap<String> |
formatTypeToFormatFieldIndex |
int |
positionColumnIndex |
| Constructor and Description |
|---|
VCFWriter(htsjdk.samtools.util.BlockCompressedOutputStream stream) |
VCFWriter(PrintWriter outWriter)
Contruct a VCFWriter.
|
VCFWriter(Writer writer) |
| Modifier and Type | Method and Description |
|---|---|
void |
addAlternateAllele(String allele) |
it.unimi.dsi.fastutil.objects.ObjectArrayList<String> |
altAlleles() |
void |
clear()
Clear the record without writing to the output and prepare for the next record.
|
void |
clearAlternateAlleles() |
void |
close()
Close the writer.
|
it.unimi.dsi.lang.MutableString |
codeGenotype(String alleles)
Encode the list of alleles as a VCF genotype.
|
protected it.unimi.dsi.lang.MutableString |
codeGenotype(String[] alleles)
Encode the list of alleles as a VCF genotype.
|
protected it.unimi.dsi.lang.MutableString |
codeGenotype(String[] alleles,
it.unimi.dsi.fastutil.objects.ObjectArrayList<String> refAlleles,
it.unimi.dsi.fastutil.objects.ObjectArrayList<String> altAlleles)
Encode the list of alleles as a VCF genotype.
|
int |
defineField(String columnName,
String fieldName,
int numValues,
ColumnType type,
String description)
Define a VCF field for a column.
|
int |
defineField(String columnName,
String fieldName,
int numValues,
ColumnType type,
String description,
String... groups)
Define a VCF field for a column.
|
void |
defineSamples(String[] samples)
Define sample identifiers.
|
void |
defineSchema(Columns columns)
Define the VCF schema from Columns assembled externally.
|
CharSequence |
getChromosome() |
int |
getNumAltAlleles() |
int |
getNumFormatFields()
Get the total number of possible format fields in the FORMAT column.
|
int |
getNumInfoFields()
Returns the number of INFO fields currently defined.
|
int |
getPosition() |
String[] |
getSamples()
Get the list of sample column identifiers.
|
protected CharSequence |
getSampleValue(int formatFieldIndex,
int sampleIndex) |
boolean |
hasAlternateAllele()
Return true if the writer has at least one alternate allele defined at the current record.
|
it.unimi.dsi.fastutil.objects.ObjectArrayList<String> |
refAlleles() |
void |
setAlternateAllele(String value) |
void |
setChromosome(CharSequence chromosome) |
void |
setFilter(CharSequence value) |
void |
setFlag(int infoFlagIndex)
Set a flag to true.
|
void |
setFlag(int infoFlagIndex,
boolean state)
Set a flag to state.
|
void |
setGenotypesPhased(boolean state)
Indicate whether the genotypes should be recorded as phased (true) or unphased (false).
|
void |
setId(String id) |
void |
setInfo(int infoFieldIndex,
CharSequence value)
Set the value of an INFO column field for the current record.
|
void |
setInfo(int infoFieldIndex,
double value)
Set the value of an INFO column field for the current record.
|
void |
setInfo(int infoFieldIndex,
float value)
Set the value of an INFO column field for the current record.
|
void |
setInfo(int infoFieldIndex,
int value)
Set the value of an INFO column field for the current record.
|
void |
setPosition(int position) |
void |
setQual(CharSequence value) |
void |
setReferenceAllele(String allele) |
void |
setSampleValue(int formatFieldIndex,
int sampleIndex,
CharSequence value)
Set a value of a sample column.
|
void |
setSampleValue(int formatFieldIndex,
int sampleIndex,
double value)
Set a value of a sample column.
|
void |
setSampleValue(int formatFieldIndex,
int sampleIndex,
float value)
Set a value of a sample column.
|
void |
setSampleValue(int formatFieldIndex,
int sampleIndex,
int value)
Set a value of a sample column.
|
void |
setSampleValue(String formatToken,
int sampleIndex,
String value) |
void |
setWriteFieldGroupAssociations(boolean writeFieldGroupAssociations)
When this flag is true, writeHeader writes associations between columns and groups.
|
void |
switchSampleValue(int formatFieldIndex,
int sampleIndex,
int newSampleIndex,
String newValueAtSampleIndex)
Move a sample value to a new column, replace the previous value of one of the columns with some new value.
|
void |
writeHeader()
Write the VCF header.
|
void |
writeHeader(String... headerLines)
Write the VCF header.
|
void |
writeRecord()
Append a record.
|
public int chromosomeColumnIndex
public int positionColumnIndex
protected it.unimi.dsi.fastutil.objects.Object2IntMap<String> formatTypeToFormatFieldIndex
public static int COLUMN_NOT_DEFINED
public VCFWriter(Writer writer)
public VCFWriter(htsjdk.samtools.util.BlockCompressedOutputStream stream)
public VCFWriter(PrintWriter outWriter)
outWriter - Where the output will be written.public void setWriteFieldGroupAssociations(boolean writeFieldGroupAssociations)
writeFieldGroupAssociations - True or False.public CharSequence getChromosome()
public void setGenotypesPhased(boolean state)
state - True when the genotypes are phased.public void setId(String id)
public void setPosition(int position)
public void setChromosome(CharSequence chromosome)
public void setReferenceAllele(String allele)
public void clearAlternateAlleles()
public void addAlternateAllele(String allele)
public void writeHeader()
public void writeHeader(String... headerLines)
public void writeRecord()
public void clear()
public void setFlag(int infoFlagIndex)
infoFlagIndex - index of the INFO field corresponding to the flag.public void setFlag(int infoFlagIndex,
boolean state)
infoFlagIndex - index of the INFO field corresponding to the flag.state - state to set the flag to.public it.unimi.dsi.lang.MutableString codeGenotype(String alleles)
alleles - String of the form A/B/C where A,B C are allele that are part of a genotype.codeGenotype(String[] alleles)protected it.unimi.dsi.lang.MutableString codeGenotype(String[] alleles)
alleles - List of alleles included in the genotype.protected it.unimi.dsi.lang.MutableString codeGenotype(String[] alleles, it.unimi.dsi.fastutil.objects.ObjectArrayList<String> refAlleles, it.unimi.dsi.fastutil.objects.ObjectArrayList<String> altAlleles)
alleles - List of alleles included in the genotype.altAlleles - alternate allelesrefAlleles - reference allelespublic void close()
public int defineField(String columnName, String fieldName, int numValues, ColumnType type, String description)
columnName - Name of an existing column.fieldName - Name of the new field.numValues - Number of values in this field.type - Type of data for individual values of the field.description - Description of data represented by the field.public int defineField(String columnName, String fieldName, int numValues, ColumnType type, String description, String... groups)
columnName - Name of an existing column.fieldName - Name of the new field.numValues - Number of values in this field.type - Type of data for individual values of the field.description - Description of data represented by the field.groups - Groups associated with the new field.public void setInfo(int infoFieldIndex,
CharSequence value)
infoFieldIndex - Index returned by definedField("INFO",...)value - Value of the field.public void setInfo(int infoFieldIndex,
double value)
infoFieldIndex - Index returned by definedField("INFO",...)value - Value of the field.public void setInfo(int infoFieldIndex,
float value)
infoFieldIndex - Index returned by definedField("INFO",...)value - Value of the field.public void setInfo(int infoFieldIndex,
int value)
infoFieldIndex - Index returned by definedField("INFO",...)value - Value of the field.public String[] getSamples()
public void defineSamples(String[] samples)
samples - Identifiers of the samplespublic void setSampleValue(int formatFieldIndex,
int sampleIndex,
CharSequence value)
formatFieldIndex - Index of a FORMAT field created with defineField("FORMAT,...)sampleIndex - Index of the samplevalue - Value to set the field to for the current record.protected CharSequence getSampleValue(int formatFieldIndex, int sampleIndex)
public void setSampleValue(int formatFieldIndex,
int sampleIndex,
double value)
formatFieldIndex - Index of a FORMAT field created with defineField("FORMAT,...)sampleIndex - Index of the samplevalue - Value to set the field to for the current record.public void switchSampleValue(int formatFieldIndex,
int sampleIndex,
int newSampleIndex,
String newValueAtSampleIndex)
formatFieldIndex - FORMAT field to modify.sampleIndex - Index of the first column.newSampleIndex - Index of the second columnnewValueAtSampleIndex - New value to fill one of the columns.public void setSampleValue(int formatFieldIndex,
int sampleIndex,
int value)
formatFieldIndex - Index of a FORMAT field created with defineField("FORMAT,...)sampleIndex - Index of the samplevalue - Value to set the field to for the current record.public void setSampleValue(int formatFieldIndex,
int sampleIndex,
float value)
formatFieldIndex - Index of a FORMAT field created with defineField("FORMAT,...)sampleIndex - Index of the samplevalue - Value to set the field to for the current record.public int getNumFormatFields()
public void defineSchema(Columns columns)
columns - public void setAlternateAllele(String value)
public void setFilter(CharSequence value)
public void setQual(CharSequence value)
public int getNumInfoFields()
public int getPosition()
public boolean hasAlternateAllele()
public it.unimi.dsi.fastutil.objects.ObjectArrayList<String> refAlleles()
public it.unimi.dsi.fastutil.objects.ObjectArrayList<String> altAlleles()
public int getNumAltAlleles()
Copyright © 2017 Campagne Laboratory. All rights reserved.