Write a VCF file
BRAF V600E, the most frequent mutation of melanoma, and three structural variants taken from the VCF 4.3 specification: a 205 bp deletion written as a symbolic allele, and the two breakends of a translocation between chromosomes 2 and 17. The semicolon of the NOTE is percent-encoded, as the specification requires.
1
Starting code
This is the PHP code used by this example.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | public function writeVcf(VcfWriterInterface $vcfWriter, VcfReaderInterface $vcfReader) { $aVariants = [ // BRAF V600E, the most frequent mutation of melanoma (GRCh38) new VcfVariant("7", 140753336, "rs113488022", "A", ["T"], null, "PASS", ["GENE" => "BRAF", "HGVSP" => "p.Val600Glu", "NOTE" => "c.1799T>A; on the minus strand"]), // A deletion of 205 bp, written as a symbolic allele (VCF 4.3 specification) new VcfVariant("2", 321682, null, "T", ["<DEL>"], 6.0, "PASS", ["SVTYPE" => "DEL", "END" => "321887", "SVLEN" => "-205", "IMPRECISE" => true]), // A translocation between chromosomes 2 and 17: two breakends, each naming its mate new VcfVariant("2", 321681, "bnd_W", "G", ["G]17:198982]"], 6.0, "PASS", ["SVTYPE" => "BND", "MATEID" => "bnd_Y"]), new VcfVariant("17", 198982, "bnd_Y", "A", ["A]2:321681]"], 6.0, "PASS", ["SVTYPE" => "BND", "MATEID" => "bnd_W"]), ]; $sVcf = $vcfWriter->write($aVariants, [ "##reference=GRCh38", '##INFO=<ID=GENE,Number=1,Type=String,Description="Gene symbol">', ]); // Read back, every variant comes out as it went in $aReadBack = $vcfReader->read(explode("\n", $sVcf))->getVariants(); $bIdentical = $aReadBack == $aVariants; return $this->render('default/variantsWriteVcf.html.twig', [ 'vcf' => $sVcf, 'readBack' => $this->describe($aReadBack), 'identical' => $bIdentical, ]); } |
2
Result
Result returned by BioPHP for the demonstration data.
VCF written
##fileformat=VCFv4.3 ##reference=GRCh38 ##INFO=<ID=GENE,Number=1,Type=String,Description="Gene symbol"> #CHROM POS ID REF ALT QUAL FILTER INFO 7 140753336 rs113488022 A T . PASS GENE=BRAF;HGVSP=p.Val600Glu;NOTE=c.1799T>A%3B on the minus strand 2 321682 . T <DEL> 6 PASS SVTYPE=DEL;END=321887;SVLEN=-205;IMPRECISE 2 321681 bnd_W G G]17:198982] 6 PASS SVTYPE=BND;MATEID=bnd_Y 17 198982 bnd_Y A A]2:321681] 6 PASS SVTYPE=BND;MATEID=bnd_W
Read back
| CHROM | POS | ID | REF | ALT | QUAL | FILTER | INFO |
|---|---|---|---|---|---|---|---|
| 7 | 140753336 | rs113488022 | A |
T (SNV) |
. | ✓ PASS |
GENE=BRAFHGVSP=p.Val600GluNOTE=c.1799T>A; on the minus strand |
| 2 | 321682 | . | T |
<DEL> (structural variant, symbolic allele) |
6 | ✓ PASS |
SVTYPE=DELEND=321887SVLEN=-205IMPRECISE |
| 2 | 321681 | bnd_W | G |
G]17:198982] (breakend) |
6 | ✓ PASS |
SVTYPE=BNDMATEID=bnd_Y |
| 17 | 198982 | bnd_Y | A |
A]2:321681] (breakend) |
6 | ✓ PASS |
SVTYPE=BNDMATEID=bnd_W |
Every variant read back is identical to the one written.
The code above is the one actually executed by this page. Find the other examples in the left-hand column, or the tools in BioTools.