1+ import csv
2+
13from pronto .utils .io import decompress
24
35from src .babel_utils import make_local_name , pull_via_ftp , pull_via_urllib
@@ -11,19 +13,18 @@ def pull_hgncfamily():
1113 decompress = False ,
1214 subpath = HGNCFAMILY )
1315
14- def pull_labels (infile ,outfile , metadata_yaml ):
15- with open (infile ,'r' ) as inf :
16- data = inf .read ().strip ()
17- lines = data .split ('\n ' )
18- with open (outfile ,'w' ) as outf :
19- #skip header
20- for line in lines [1 :]:
21- parts = line .split (',' )
22- if len (parts ) < 10 :
23- continue
24- i = f"{ HGNCFAMILY } :{ parts [0 ][1 :- 1 ]} "
25- l = parts [2 ][1 :- 1 ]
26- outf .write (f'{ i } \t { l } \n ' )
16+ def pull_labels (infile , labelsfile , descriptionsfile , metadata_yaml ):
17+ with open (infile , 'r' ) as inf , open (labelsfile , 'w' ) as labelsf , open (descriptionsfile , 'w' ) as descriptionsf :
18+ reader = csv .DictReader (inf )
19+ for row in reader :
20+ curie = f"{ HGNCFAMILY } :{ row ['id' ]} "
21+ name = row ['name' ]
22+ description = row ['desc_comment' ]
23+ # There is also a 'desc_label' field, but this seems to be pretty similar to 'name'.
24+ labelsf .write (f'{ curie } \t { name } \n ' )
25+
26+ if description and description != "NULL" :
27+ descriptionsf .write (f'{ curie } \t { description } \n ' )
2728
2829 write_metadata (
2930 metadata_yaml ,
0 commit comments