@@ -71,6 +71,37 @@ def _23andme_exome(path):
71
71
yield SNP (name = r .ID , chromosome = r .CHROM , position = r .POS ,
72
72
genotype = sample .gt_bases .replace ("/" , "" ))
73
73
74
+ def _23andme_ancestry (path ):
75
+ handle = csv .DictReader (open (path , "r" ),
76
+ fieldnames = ["name" , "chromosome" , "position" , "allele1" , "allele2" ],
77
+ delimiter = "\t " )
78
+ for row in handle :
79
+ if not row ["name" ].startswith (("#" , "rsid" )):
80
+ row ["genotype" ] = "{}{}" .format (row .pop ("allele1" ), row .pop ("allele2" ))
81
+ yield SNP (** row )
82
+
83
+ def _genes_for_good (path ):
84
+ if vcf is None :
85
+ raise RuntimeError ("PyVCF not available, please 'easy_install' it." )
86
+
87
+ try :
88
+ for r in vcf .VCFReader (open (path , "rb" ), compressed = True ):
89
+ if not r .is_snp :
90
+ continue # XXX Is it even possible?
91
+ for sample in r .samples :
92
+ yield SNP (name = r .ID , chromosome = r .CHROM , position = r .POS ,
93
+ genotype = sample .gt_bases .replace ("/" , "" ))
94
+ except OSError :
95
+ # the gfg format is is likely version 1.1
96
+ for snp in _23andme (path ):
97
+ yield snp
98
+
99
+ def _iyg (path ):
100
+ handle = csv .DictReader (open (path , "r" ),
101
+ fieldnames = ["name" , "genotype" ], delimiter = "\t " )
102
+ for row in handle :
103
+ yield SNP (name = row ["name" ], chromosome = None , position = 0 ,
104
+ genotype = row ["genotype" ])
74
105
75
106
def decodeme (path ):
76
107
handle = csv .DictReader (open (path , "r" ),
@@ -124,6 +155,9 @@ def parse(path, source=None):
124
155
try :
125
156
handler = {"23andme" : _23andme ,
126
157
"23andme-exome-vcf" : _23andme_exome ,
158
+ "ancestry" : _23andme_ancestry ,
159
+ "genes-for-good" : _genes_for_good ,
160
+ "IYG" : _iyg ,
127
161
"ftdna-illumina" : ftdna ,
128
162
"decodeme" : decodeme ,
129
163
"vcf" : _23andme_exome ,
0 commit comments