Skip to content

Commit

Permalink
feat: gene to phenotype links file can be gziped (#5)
Browse files Browse the repository at this point in the history
  • Loading branch information
holtgrewe authored Sep 8, 2023
1 parent e537a08 commit 66c48bf
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions cada_prio/train_model.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import csv
import enum
import gzip
import itertools
import json
import os
Expand Down Expand Up @@ -70,8 +71,13 @@ class GeneToPhenotypeRecord:


def load_gene_phenotype_records(path: str) -> typing.Iterable[GenePhenotypeRecord]:
with open(path) as f:
for line in f:
if path.endswith(".gz"):
inputf = gzip.open(path, "rt")
else:
inputf = open(path, "rt")

with inputf:
for line in inputf:
yield cattrs.structure(json.loads(line), GenePhenotypeRecord)


Expand Down

0 comments on commit 66c48bf

Please sign in to comment.