forked from arq5x/gemini
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathped.py
More file actions
executable file
·27 lines (23 loc) · 893 Bytes
/
Copy pathped.py
File metadata and controls
executable file
·27 lines (23 loc) · 893 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
default_ped_fields = ["family_id", "name", "paternal_id", "maternal_id",
"sex", "phenotype"]
def get_ped_fields(ped_file):
if not ped_file:
return default_ped_fields
with open(ped_file) as in_handle:
possible_header = in_handle.readline()
if possible_header.startswith("#"):
header = possible_header.replace("#", "").split()
# rename the standard fields to a common name
header = default_ped_fields + header[len(default_ped_fields):]
return possible_header.replace("#", "").split()
else:
return default_ped_fields
def load_ped_file(ped_file):
ped_dict = {}
header = get_ped_fields(ped_file)
for line in open(ped_file, 'r'):
if line.startswith("#") or len(line) == 0:
continue
fields = line.split()
ped_dict[fields[1]] = fields
return ped_dict