Thank you all for your responses.
In fact, I have a list of 900 samples. And it would be easier for me to access the GT from the sample name rather than the sample index. But if it doesn't exist, no problem, I'll use the index.
• 0 views
•
link
vcf.samples? (I have not tried it myself, therefore I leave this as a comment).it's useful to get a list of all sample names ;o)
Get all the genotypes with
variant.genotypes. It will return a list containing the allele and phasing information for each sample. Access the sample-specific data with the respective index.Ref: https://brentp.github.io/cyvcf2/docstrings.html#cyvcf2.cyvcf2.Variant.genotypes