VcfWriter
in package
implements
VcfWriterInterface
VCF 4.3 : "##fileformat=VCFv4.3", the extra meta lines, "#CHROM POS ID REF ALT QUAL FILTER INFO", then a tab-separated line per variant. A missing value (no ID, no ALT, no QUAL, no FILTER, no INFO) is ".". The ALT alleles are joined by commas, the INFO entries by semicolons, a flag written by its key alone, and an INFO value has its ";", "=", ":", "%" and line or tab characters percent-encoded (the reader decodes the same set) - its commas are not, since they separate the items of a list.
Positions are written as they are held, 1-based. VcfReader reads back what this writes. Class VcfWriter
Tags
Table of Contents
Interfaces
- VcfWriterInterface
- Interface VcfWriterInterface - the counterpart of VcfReaderInterface : writes VcfVariant instances as a VCF file with its eight fixed columns (no FORMAT, no sample genotype).
Constants
- COLUMNS : mixed = "#CHROM\tPOS\tID\tREF\tALT\tQUAL\tFILTER\tINFO"
- FILE_FORMAT : mixed = "##fileformat=VCFv4.3"
- INFO_ENCODING : array<string|int, string> = ["%" => "%25", ":" => "%3A", ";" => "%3B", "="...
- MISSING : mixed = "."
Methods
- write() : string
- assertOneLine() : void
- encodeInfoValue() : string
- A "%2C" is left as it is : VcfReader keeps an encoded comma encoded, so a value read from a file holds "%2C" for it, and encoding its "%" again would write "%252C", the text "%2C" instead of a comma.
- writeInfo() : string
- writeVariant() : string
Constants
COLUMNS
private
mixed
COLUMNS
= "#CHROM\tPOS\tID\tREF\tALT\tQUAL\tFILTER\tINFO"
FILE_FORMAT
private
mixed
FILE_FORMAT
= "##fileformat=VCFv4.3"
INFO_ENCODING
private
array<string|int, string>
INFO_ENCODING
= ["%" => "%25", ":" => "%3A", ";" => "%3B", "=" => "%3D", "\r" => "%0D", "\n" => "%0A", "\t" => "%09"]
What strtr() replaces in one pass, so a code it adds is never encoded again
MISSING
private
mixed
MISSING
= "."
Methods
write()
public
write(array<string|int, VcfVariant> $aVariants[, array<string|int, string> $aMetaLines = [] ]) : string
Parameters
- $aVariants : array<string|int, VcfVariant>
- $aMetaLines : array<string|int, string> = []
Return values
stringassertOneLine()
private
assertOneLine(string $sLine, string $sWhat) : void
Parameters
- $sLine : string
- $sWhat : string
Tags
encodeInfoValue()
A "%2C" is left as it is : VcfReader keeps an encoded comma encoded, so a value read from a file holds "%2C" for it, and encoding its "%" again would write "%252C", the text "%2C" instead of a comma.
private
encodeInfoValue(string $sValue) : string
Parameters
- $sValue : string
Return values
stringwriteInfo()
private
writeInfo(array<string, string|bool> $aInfo) : string
Parameters
- $aInfo : array<string, string|bool>
Return values
stringwriteVariant()
private
writeVariant(VcfVariant $oVariant) : string
Parameters
- $oVariant : VcfVariant
Return values
string —The variant's tab-separated line, without its newline