GOVCF
govcf的Python项目详细描述
govcf-变量调用文件“call”生成器
这是一个专有包,可以从GenomOncology获得,可以工作 用我们的Knowledge Management System。
有关许可的详细信息,请与我们联系:
可通过pypi下载的其他专有项目包括:
我们的开源项目包括:
概述
建立在VCF解析器之上的Genomology变量调用文件(VCF)生成器
在pysam项目中。生成器生成两种记录类型,如
__type__
字典属性:
- 头(每个vcf文件一个)
- 调用(每个唯一示例alt一个)
标题包含以下信息:
__child__
:头后面的记录类型。config
:提供给生成器的任何配置字段。file_path
:vcf的文件位置。formats
:标题中格式字段的元数据。info
:头中信息字段的元数据。types
:在信息或格式中找到的所有字段的字段类型。
调用是给定样本的单个alt等位基因的表示。这个 通过迭代每个示例和 为gt(基因型)字段指定的每个唯一alt索引生成调用。
呼叫包括以下字段:
alt
:交替等位基因chr
:染色体filters
:提供了筛选器,不包括“.”的筛选器。info
:信息值字段is_het
:当等位基因为杂合子时为真的布尔值(例如0/1)is_phased
:布尔值,指示是分段()还是非分段(/)quality
:质量值ref
:参考等位基因rs_id
:id字段sample_name
:示例列的名称start
:开始位置
这个包还有一个名为BedFilter
的类,可以将其传递到
按染色体和起始位置过滤记录的迭代器函数
并且只产生在bed文件指定范围内的调用。
快速示例
下面的示例是对顶部提供的示例的解析 VCF规范文件的以下内容:
https://samtools.github.io/hts-specs/VCFv4.2.pdf
这是VCF:
##fileformat=VCFv4.2 ##fileDate=20090805 ##source=myImputationProgramV3.1 ##reference=file:///seq/references/1000GenomesPilot-NCBI36.fasta ##contig=<ID=20,length=62435964,assembly=B36,md5=f126cdf8a6e0c7f379d618ff66beb2da,species="Homo sapiens",taxonomy=x> ##phasing=partial ##INFO=<ID=NS,Number=1,Type=Integer,Description="Number of Samples With Data"> ##INFO=<ID=DP,Number=1,Type=Integer,Description="Total Depth"> ##INFO=<ID=AF,Number=A,Type=Float,Description="Allele Frequency"> ##INFO=<ID=AA,Number=1,Type=String,Description="Ancestral Allele"> ##INFO=<ID=DB,Number=0,Type=Flag,Description="dbSNP membership, build 129"> ##INFO=<ID=H2,Number=0,Type=Flag,Description="HapMap2 membership"> ##FILTER=<ID=q10,Description="Quality below 10"> ##FILTER=<ID=s50,Description="Less than 50% of samples have data"> ##FORMAT=<ID=GT,Number=1,Type=String,Description="Genotype"> ##FORMAT=<ID=GQ,Number=1,Type=Integer,Description="Genotype Quality"> ##FORMAT=<ID=DP,Number=1,Type=Integer,Description="Read Depth"> ##FORMAT=<ID=HQ,Number=2,Type=Integer,Description="Haplotype Quality"> #CHROM POS ID REF ALT QUAL FILTER INFO FORMAT NA00001 NA00002 NA00003 20 14370 rs6054257 G A 29 PASS NS=3;DP=14;AF=0.5;DB;H2 GT:GQ:DP:HQ 0|0:48:1:51,51 1|0:48:8:51,51 1/1:43:5:.,. 20 17330 . T A 3 q10 NS=3;DP=11;AF=0.017 GT:GQ:DP:HQ 0|0:49:3:58,50 0|1:3:5:65,3 0/0:41:3 20 1110696 rs6040355 A G,T 67 PASS NS=2;DP=10;AF=0.333,0.667;AA=T;DB GT:GQ:DP:HQ 1|2:21:6:23,27 2|1:2:0:18,2 2/2:35:4 20 1230237 . T . 47 PASS NS=3;DP=13;AA=T GT:GQ:DP:HQ 0|0:54:7:56,60 0|0:48:4:51,51 0/0:61:2 20 1234567 microsat1 GTC G,GTCT 50 PASS NS=3;DP=9;AA=G;H2 GT:GQ:DP 0/1:35:4 0/2:17:2 1/1:40:3
下面是一些示例python代码:
fromgovcfimportiterate_vcf_calls,BEDFilterfrompprintimportpprintbed_filter=BEDFilter("panel.bed")forrecordiniterate_vcf_calls("tests/vcfs/spec.vcf",bed_filter=bed_filter):pprint(record)
产生以下结果:
{'__child__': 'CALL',
'__type__': 'HEADER',
'config': {'include_vaf': True},
'file_path': '/Users/ian/code/govcf/tests/vcfs/spec.vcf',
'formats': {'DP': {'description': 'Read Depth',
'id': 2,
'name': 'DP',
'number': 1,
'type': 'Integer'},
'GQ': {'description': 'Genotype Quality',
'id': 10,
'name': 'GQ',
'number': 1,
'type': 'Integer'},
'GT': {'description': 'Genotype',
'id': 9,
'name': 'GT',
'number': 1,
'type': 'String'},
'HQ': {'description': 'Haplotype Quality',
'id': 11,
'name': 'HQ',
'number': 2,
'type': 'Integer'}},
'info': {'AA': {'description': 'Ancestral Allele',
'id': 4,
'name': 'AA',
'number': 1,
'type': 'String'},
'AF': {'description': 'Allele Frequency',
'id': 3,
'name': 'AF',
'number': 'A',
'type': 'Float'},
'DB': {'description': 'dbSNP membership, build 129',
'id': 5,
'name': 'DB',
'number': 0,
'type': 'Flag'},
'DP': {'description': 'Total Depth',
'id': 2,
'name': 'DP',
'number': 1,
'type': 'Integer'},
'H2': {'description': 'HapMap2 membership',
'id': 6,
'name': 'H2',
'number': 0,
'type': 'Flag'},
'NS': {'description': 'Number of Samples With Data',
'id': 1,
'name': 'NS',
'number': 1,
'type': 'Integer'}},
'types': {'AA': 'string',
'AF': 'float',
'DB': 'boolean',
'DP': 'int',
'GQ': 'int',
'H2': 'boolean',
'HQ': 'mint',
'NS': 'int'}}
{'__type__': 'CALL',
'alt': 'A',
'chr': '20',
'filters': ['PASS'],
'info': {'AF': 0.5,
'DB': True,
'DP': 8,
'GQ': 48,
'H2': True,
'HQ': (51, 51),
'NS': 3},
'is_het': True,
'is_phased': True,
'quality': 29.0,
'ref': 'G',
'rs_id': 'rs6054257',
'sample_name': 'NA00002',
'start': 14370}
{'__type__': 'CALL',
'alt': 'A',
'chr': '20',
'filters': ['PASS'],
'info': {'AF': 0.5,
'DB': True,
'DP': 5,
'GQ': 43,
'H2': True,
'HQ': (None, None),
'NS': 3},
'is_het': False,
'is_phased': False,
'quality': 29.0,
'ref': 'G',
'rs_id': 'rs6054257',
'sample_name': 'NA00003',
'start': 14370}
{'__type__': 'CALL',
'alt': 'A',
'chr': '20',
'filters': ['q10'],
'info': {'AF': 0.017000000923871994,
'DP': 5,
'GQ': 3,
'HQ': (65, 3),
'NS': 3},
'is_het': True,
'is_phased': True,
'quality': 3.0,
'ref': 'T',
'rs_id': None,
'sample_name': 'NA00002',
'start': 17330}
{'__type__': 'CALL',
'alt': 'G',
'chr': '20',
'filters': ['PASS'],
'info': {'AA': 'T',
'AF': 0.3330000042915344,
'DB': True,
'DP': 6,
'GQ': 21,
'HQ': (23, 27),
'NS': 2},
'is_het': True,
'is_phased': True,
'quality': 67.0,
'ref': 'A',
'rs_id': 'rs6040355',
'sample_name': 'NA00001',
'start': 1110696}
{'__type__': 'CALL',
'alt': 'T',
'chr': '20',
'filters': ['PASS'],
'info': {'AA': 'T',
'AF': 0.6669999957084656,
'DB': True,
'DP': 6,
'GQ': 21,
'HQ': (23, 27),
'NS': 2},
'is_het': True,
'is_phased': True,
'quality': 67.0,
'ref': 'A',
'rs_id': 'rs6040355',
'sample_name': 'NA00001',
'start': 1110696}
{'__type__': 'CALL',
'alt': 'G',
'chr': '20',
'filters': ['PASS'],
'info': {'AA': 'T',
'AF': 0.3330000042915344,
'DB': True,
'DP': 0,
'GQ': 2,
'HQ': (18, 2),
'NS': 2},
'is_het': True,
'is_phased': True,
'quality': 67.0,
'ref': 'A',
'rs_id': 'rs6040355',
'sample_name': 'NA00002',
'start': 1110696}
{'__type__': 'CALL',
'alt': 'T',
'chr': '20',
'filters': ['PASS'],
'info': {'AA': 'T',
'AF': 0.6669999957084656,
'DB': True,
'DP': 0,
'GQ': 2,
'HQ': (18, 2),
'NS': 2},
'is_het': True,
'is_phased': True,
'quality': 67.0,
'ref': 'A',
'rs_id': 'rs6040355',
'sample_name': 'NA00002',
'start': 1110696}
{'__type__': 'CALL',
'alt': 'T',
'chr': '20',
'filters': ['PASS'],
'info': {'AA': 'T',
'AF': 0.6669999957084656,
'DB': True,
'DP': 4,
'GQ': 35,
'HQ': (None,),
'NS': 2},
'is_het': False,
'is_phased': False,
'quality': 67.0,
'ref': 'A',
'rs_id': 'rs6040355',
'sample_name': 'NA00003',
'start': 1110696}
{'__type__': 'CALL',
'alt': 'G',
'chr': '20',
'filters': ['PASS'],
'info': {'AA': 'G', 'DP': 4, 'GQ': 35, 'H2': True, 'NS': 3},
'is_het': True,
'is_phased': False,
'quality': 50.0,
'ref': 'GTC',
'rs_id': 'microsat1',
'sample_name': 'NA00001',
'start': 1234567}
{'__type__': 'CALL',
'alt': 'GTCT',
'chr': '20',
'filters': ['PASS'],
'info': {'AA': 'G', 'DP': 2, 'GQ': 17, 'H2': True, 'NS': 3},
'is_het': True,
'is_phased': False,
'quality': 50.0,
'ref': 'GTC',
'rs_id': 'microsat1',
'sample_name': 'NA00002',
'start': 1234567}
{'__type__': 'CALL',
'alt': 'G',
'chr': '20',
'filters': ['PASS'],
'info': {'AA': 'G', 'DP': 3, 'GQ': 40, 'H2': True, 'NS': 3},
'is_het': False,
'is_phased': False,
'quality': 50.0,
'ref': 'GTC',
'rs_id': 'microsat1',
'sample_name': 'NA00003',
'start': 1234567}