Skip to content

Commit ffc27ca

Browse files
committed
handles genes for good format gt files
1 parent d32513d commit ffc27ca

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

sn.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,22 @@ def _23andme_ancestry(path):
8080
row["genotype"] = "{}{}".format(row.pop("allele1"), row.pop("allele2"))
8181
yield SNP(**row)
8282

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+
yield _23andme(path)
97+
98+
8399
def decodeme(path):
84100
handle = csv.DictReader(open(path, "r"),
85101
fieldnames=["name", "variation", "chromosome", "position",
@@ -133,6 +149,7 @@ def parse(path, source=None):
133149
handler = {"23andme": _23andme,
134150
"23andme-exome-vcf": _23andme_exome,
135151
"ancestry": _23andme_ancestry,
152+
"genes-for-good": _genes_for_good,
136153
"ftdna-illumina": ftdna,
137154
"decodeme": decodeme,
138155
"vcf": _23andme_exome,

0 commit comments

Comments
 (0)