Skip to content

0.6.0: ✨ Allow passing vcf as 2nd arg to macros (#45) (#46)

Latest
Compare
Choose a tag to compare
@pwwang pwwang released this 27 Sep 22:09
da19dc3
  • Now vcf (the instance of cyvcf2.VCF is allowed to be passed as 2nd argument to continuous and categorical 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.