Skip to content

Commit

Permalink
enable binary-matrix-type data
Browse files Browse the repository at this point in the history
  • Loading branch information
jodyphelan committed Jan 25, 2024
1 parent be24cdb commit 6e1bbb5
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions itol_configs/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def load_data(input_file: str, id_column: str) -> Dict[str,dict]:
data[column] = {row[id_column]:row[column] for row in rows}
return data

def load_matrix_data(input_file: str, id_column: str) -> Dict[str,dict]:
def load_binary_matrix_data(input_file: str, id_column: str) -> Dict[str,dict]:
"""
Load data from a csv file.
Expand All @@ -81,7 +81,10 @@ def load_matrix_data(input_file: str, id_column: str) -> Dict[str,dict]:
for row in csv.DictReader(open(input_file,encoding="utf-8-sig")):
index = row[id_column]
del row[id_column]
print(set(row.values()))
assert set(row.values()).issubset(set(["0","1"])), "Binary matrix must contain only 0s and 1s"
data[index] = row


return data

Expand All @@ -104,7 +107,7 @@ def main(args):
colour_conf = {}

if args.type in matrix_interface_types:
data = load_matrix_data(args.input,args.id)
data = load_binary_matrix_data(args.input,args.id)
writer = get_config_writer(args.type,data,args.output,colour_conf)
writer.write(args.output + ".txt")
else:
Expand Down

0 comments on commit 6e1bbb5

Please sign in to comment.