Skip to content

Conversation

@lindenb
Copy link
Contributor

@lindenb lindenb commented Jan 17, 2025

Hi all,

This is a PR for a new plugin vcf2table which is the C version of my tool https://jvarkit.readthedocs.io/en/latest/VcfToTable/ .

This tool reads a VCF and output the variants as a set of ascii table.

eg:

bcftools +vcf2table ./test/merge.4.b.vcf

(...)
<<< 1:3000002:C (n. 5)

# Variant
┌────────┬─────────┐
│ KEY    │ VALUE   │
├────────┼─────────┤
│ CHROM  │ 1       │
│ POS    │ 3000002 │
│ ID     │ .       │
│ REF    │ C       │
│ ALT    │ A       │
│ QUAL   │ 59.2    │
│ FILTER │ PASS    │
└────────┴─────────┘

# INFO
┌─────┬─────┬───────┐
│ KEY │ IDX │ VALUE │
├─────┼─────┼───────┤
│ AN  │     │ 4     │
│ AC  │     │ 2     │
└─────┴─────┴───────┘

# GENOTYPE TYPES
┌──────┬───────┬─────┐
│ Type │ Count │ %   │
├──────┼───────┼─────┤
│ HET  │ 2     │ 100 │
└──────┴───────┴─────┘

# GENOTYPES
┌────────┬───────┬─────┬─────┐
│ SAMPLE │ GTYPE │ GT  │ GQ  │
├────────┼───────┼─────┼─────┤
│ C      │ HET   │ 0/1 │ 245 │
│ D      │ HET   │ 0/1 │ 245 │
└────────┴───────┴─────┴─────┘

>>> 1:3000002:C (n. 5)





bcftools +vcf2table test/split-vep.2.vcf 


<<< 1:14464:A (n. 1)

# Variant
+--------+---------+
| KEY    | VALUE   |
+--------+---------+
| CHROM  | 1       |
| POS    | 14464   |
| ID     | .       |
| REF    | A       |
| ALT    | T       |
| QUAL   | 2235.88 |
| FILTER | PASS    |
+--------+---------+

# INFO
+-----+-----+-------+
| KEY | IDX | VALUE |
+-----+-----+-------+
| AF  |     | 1     |
+-----+-----+-------+

# VEP/CSQ
+--------+------------------------------------+----------+---------+-----------------+-------------------+-----------------+------------------------+-------+-----------------------------+---------------+--------------------+------------+----------+--------+---------------+---------------+---------+-----------+--------+--------+--------+--------+--------+--------+--------+-------------+
| Allele | Consequence                        | IMPACT   | SYMBOL  | Gene            | Feature_type      | Feature         | BIOTYPE                | EXON  | HGVSc                       | cDNA_position | Existing_variation | ALLELE_NUM | DISTANCE | STRAND | VARIANT_CLASS | SYMBOL_SOURCE | HGNC_ID | CANONICAL | AF     | AFR_AF | AMR_AF | EAS_AF | EUR_AF | SAS_AF | MAX_AF | MAX_AF_POPS |
+--------+------------------------------------+----------+---------+-----------------+-------------------+-----------------+------------------------+-------+-----------------------------+---------------+--------------------+------------+----------+--------+---------------+---------------+---------+-----------+--------+--------+--------+--------+--------+--------+--------+-------------+
| T      | non_coding_transcript_exon_variant | MODIFIER | WASH7P  | ENSG00000227232 | Transcript        | ENST00000423562 | unprocessed_pseudogene | 10/10 | ENST00000423562.1:n.1568T>A | 1568          | rs546169444        | 1          |          | -1     | SNV           | HGNC          | 38034   |           | 0.0958 | 0.0144 | 0.1138 | 0.005  | 0.1859 | 0.1943 | 0.1943 | SAS         |
| T      | non_coding_transcript_exon_variant | MODIFIER | WASH7P  | ENSG00000227232 | Transcript        | ENST00000438504 | unprocessed_pseudogene | 12/12 | ENST00000438504.2:n.1682T>A | 1682          | rs546169444        | 1          |          | -1     | SNV           | HGNC          | 38034   | YES       | 0.0958 | 0.0144 | 0.1138 | 0.005  | 0.1859 | 0.1943 | 0.1943 | SAS         |
| T      | downstream_gene_variant            | MODIFIER | DDX11L1 | ENSG00000223972 | Transcript        | ENST00000456328 | processed_transcript   |       |                             |               | rs546169444        | 1          | 55       | 1      | SNV           | HGNC          | 37102   | YES       | 0.0958 | 0.0144 | 0.1138 | 0.005  | 0.1859 | 0.1943 | 0.1943 | SAS         |
| T      | non_coding_transcript_exon_variant | MODIFIER | WASH7P  | ENSG00000227232 | Transcript        | ENST00000488147 | unprocessed_pseudogene | 11/11 | ENST00000488147.1:n.1291T>A | 1291          | rs546169444        | 1          |          | -1     | SNV           | HGNC          | 38034   |           | 0.0958 | 0.0144 | 0.1138 | 0.005  | 0.1859 | 0.1943 | 0.1943 | SAS         |
| T      | non_coding_transcript_exon_variant | MODIFIER | WASH7P  | ENSG00000227232 | Transcript        | ENST00000538476 | unprocessed_pseudogene | 13/13 | ENST00000538476.1:n.1530T>A | 1530          | rs546169444        | 1          |          | -1     | SNV           | HGNC          | 38034   |           | 0.0958 | 0.0144 | 0.1138 | 0.005  | 0.1859 | 0.1943 | 0.1943 | SAS         |
| T      | non_coding_transcript_exon_variant | MODIFIER | WASH7P  | ENSG00000227232 | Transcript        | ENST00000541675 | unprocessed_pseudogene | 9/9   | ENST00000541675.1:n.1315T>A | 1315          | rs546169444        | 1          |          | -1     | SNV           | HGNC          | 38034   |           | 0.0958 | 0.0144 | 0.1138 | 0.005  | 0.1859 | 0.1943 | 0.1943 | SAS         |
| T      | regulatory_region_variant          | MODIFIER |         |                 | RegulatoryFeature | ENSR00000000002 | open_chromatin_region  |       |                             |               | rs546169444        | 1          |          |        | SNV           |               |         |           | 0.0958 | 0.0144 | 0.1138 | 0.005  | 0.1859 | 0.1943 | 0.1943 | SAS         |
+--------+------------------------------------+----------+---------+-----------------+-------------------+-----------------+------------------------+-------+-----------------------------+---------------+--------------------+------------+----------+--------+---------------+---------------+---------+-----------+--------+--------+--------+--------+--------+--------+--------+-------------+

# BCSQ
+-------------+--------+------------------------+
| Consequence | gene   | biotype                |
+-------------+--------+------------------------+
| non_coding  | WASH7P | unprocessed_pseudogene |
+-------------+--------+------------------------+

>>> 1:14464:A (n. 1)
(...)

Thank you for considering this PR.

@pd3
Copy link
Member

pd3 commented Feb 24, 2025

Hi, we can add this. Can you add tests please?

@lindenb
Copy link
Contributor Author

lindenb commented Feb 24, 2025

@pd3 Cool, thanks !

I found a memory leak and added the two examples above in test/test.pl . There are still some problems with win32 but as far as I understand, the problem is unrelated to my plugin.

Back to you. Thanks !

@pd3 pd3 merged commit 8e0867e into samtools:develop Mar 5, 2025
7 of 8 checks passed
@pd3
Copy link
Member

pd3 commented Mar 5, 2025

Thank you

@lindenb lindenb deleted the pl_vcf2table branch March 5, 2025 13:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants