2
|
1 import sys
|
|
2 import yaml
|
|
3
|
|
4 def fetch_table_data(table_path):
|
|
5 data_dict = {}
|
|
6 with open(table_path) as table_to_load:
|
|
7 # load headers
|
|
8 headers = table_to_load.readline().strip('\n').split('\t')
|
|
9 row_id = 0
|
|
10 for line in table_to_load.readlines():
|
|
11 # print(line)
|
|
12 line_data = line.strip('\n').split('\t')
|
|
13 row_dict = {}
|
|
14 for col_num in range(len(headers)):
|
|
15 col_name = headers[col_num]
|
|
16 row_dict[col_name] = line_data[col_num]
|
|
17 data_dict[row_id] = row_dict
|
|
18 row_id += 1
|
|
19 return data_dict
|
|
20
|
|
21 all_data_dict = {}
|
|
22 print('YAML -------------')
|
|
23 studies_table_path = sys.argv[1]
|
|
24 table_data = fetch_table_data(studies_table_path)
|
|
25 all_data_dict['ENA_study'] = table_data
|
|
26 samples_table_path = sys.argv[2]
|
|
27 table_data = fetch_table_data(samples_table_path)
|
|
28 all_data_dict['ENA_sample'] = table_data
|
|
29 experiments_table_path = sys.argv[3]
|
|
30 table_data = fetch_table_data(experiments_table_path)
|
|
31 all_data_dict['ENA_experiment'] = table_data
|
|
32 runs_table_path = sys.argv[4]
|
|
33 table_data = fetch_table_data(runs_table_path)
|
|
34 all_data_dict['ENA_run'] = table_data
|
|
35 # print(all_data_dict)
|
|
36 print(yaml.dump(all_data_dict))
|
|
37 print('YAML -------------')
|