def test_fromvcfinfo_override_fields(): # default array a = vcfarray.fromvcfinfo('fixture/example-4.1.vcf', fields=['CHROM', 'POS', 'DP']).view(np.recarray) eq_('20', a.CHROM[0]) eq_(14370, a.POS[0]) eq_(14, a.DP[0]) for f in ('ID', 'REF', 'ALT', 'QUAL', 'FILTER', 'NS', 'AF', 'DB', 'H2'): assert not hasattr(a, f), 'unexpected attribute on array: %s' % f
def test_fromvcfinfo_default(): # default array a = vcfarray.fromvcfinfo('fixture/example-4.1.vcf').view(np.recarray) # check fixed fields eq_('20', a.CHROM[0]) eq_(14370, a.POS[0]) eq_('rs6054257', a.ID[0]) eq_('G', a.REF[0]) eq_('A', a.ALT[0]) eq_(29, a.QUAL[0]) # check FILTER field eq_(True, a.FILTER.PASS[0]) eq_(False, a.FILTER.PASS[1]) eq_(False, a.FILTER.q10[0]) eq_(True, a.FILTER.q10[1]) # check other attributes eq_(True, a.is_snp[0]) eq_(False, a.is_indel[0]) eq_(False, a.is_deletion[0]) eq_(True, a.is_transition[0]) eq_(3, a.num_called[0]) eq_(0, a.num_unknown[0]) eq_(1., a.call_rate[0]) # check special attributes eq_(2, a.num_alleles[0]) eq_(3, a.num_alleles[2]) # check INFO fields eq_(3, a.NS[0]) eq_(14, a.DP[0]) eq_(.5, a.AF[0]) eq_(True, a.DB[0]) eq_(True, a.H2[0])
def profile(): a = vcfarray.fromvcfinfo(sys.argv[1])