-
Now
vcf
(the instance ofcyvcf2.VCF
is allowed to be passed as 2nd argument tocontinuous
andcategorical
macros (#45).from vcfstats.macros import cont @cont def GLOBAL_POS(variant, vcf): chrom = variant.CHROM.replace("chr", "") chridx = 23 if chrom == "X" else 24 if chrom == "Y" else int(chrom) prev_chrom_lens = sum(vcf.seqlens[:(chridx-1)] return prev_chrom_lens + variant.POS
Check the API documentation of cyvcf2 to see what information we can get from vcf.