Documentation

VcfReader implements VcfReaderInterface

A standalone, persistence-independent text reader, the same spirit as GffFeatureReader and BedFeatureReader : "##" meta-information lines and the single "#CHROM..." column-header line are skipped, data lines are tab-separated, a malformed one is reported as a warning and skipped rather than crashing the whole read. Only the 8 mandatory fixed columns (CHROM, POS, ID, REF, ALT, QUAL, FILTER, INFO) are read ; FORMAT and per-sample genotype columns, when present, are ignored - modeling genotypes/samples is a substantially bigger undertaking than a tabular reader, out of scope here the same way BED12's block columns are out of scope for BedFeatureReader.

Class VcfReader

Tags
author

Amélie DUVERNET aka Amelaye amelieonline@gmail.com

Table of Contents

Interfaces

VcfReaderInterface
Interface VcfReaderInterface - reads a VCF file into VcfVariant instances. FORMAT and sample genotype columns (9th column onward) are not modeled ; only the 8 mandatory fixed fields (CHROM through INFO) are read.

Constants

INFO_PERCENT_CODES  : mixed = ["%3A" => ":", "%3B" => ";", "%3D" => "=", "%0D...
VCF 4.3 percent-encoded characters an INFO value may carry, decoded case-insensitively. %2C (",") is deliberately left encoded : a value is kept as one unsplit string, in which a literal comma is the list delimiter, so decoding it would merge an encoded comma into the delimiters.
MINIMUM_COLUMN_COUNT  : mixed = 8
MISSING_VALUE  : mixed = "."

Methods

read()  : VcfImportResult
decodeInfoValue()  : string
mapColumns()  : VcfVariant
parseInfo()  : array<string, string|bool>
Parses the semicolon-separated INFO column into key/value pairs ; a flag-only key (no "=value") maps to true.

Constants

INFO_PERCENT_CODES

VCF 4.3 percent-encoded characters an INFO value may carry, decoded case-insensitively. %2C (",") is deliberately left encoded : a value is kept as one unsplit string, in which a literal comma is the list delimiter, so decoding it would merge an encoded comma into the delimiters.

private mixed INFO_PERCENT_CODES = ["%3A" => ":", "%3B" => ";", "%3D" => "=", "%0D" => "\r", "%0A" => "\n", "%09" => "\t"]

MINIMUM_COLUMN_COUNT

private mixed MINIMUM_COLUMN_COUNT = 8

MISSING_VALUE

private mixed MISSING_VALUE = "."

Methods

decodeInfoValue()

private decodeInfoValue(string $sValue) : string
Parameters
$sValue : string

A raw INFO value

Return values
string —

The value with the VCF 4.3 percent codes decoded, %25 last

mapColumns()

private mapColumns(array<string|int, string> $aColumns) : VcfVariant
Parameters
$aColumns : array<string|int, string>

At least the 8 mandatory VCF columns, in order

Return values
VcfVariant

parseInfo()

Parses the semicolon-separated INFO column into key/value pairs ; a flag-only key (no "=value") maps to true.

private parseInfo(string $sRaw) : array<string, string|bool>
Parameters
$sRaw : string
Return values
array<string, string|bool>
On this page

Search results