Mercurial > repos > iuc > ena_upload
comparison dump_yaml.py @ 7:ae2d35b56645 draft
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ena_upload commit 9961f24acebb17f837238df6541e1af59df1163b"
| author | iuc |
|---|---|
| date | Thu, 24 Feb 2022 18:20:02 +0000 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| 6:1c79c7ee82c4 | 7:ae2d35b56645 |
|---|---|
| 1 import sys | |
| 2 | |
| 3 import yaml | |
| 4 | |
| 5 | |
| 6 def fetch_table_data(table_path): | |
| 7 data_dict = {} | |
| 8 with open(table_path) as table_to_load: | |
| 9 # load headers | |
| 10 headers = table_to_load.readline().strip('\n').split('\t') | |
| 11 row_id = 0 | |
| 12 for line in table_to_load.readlines(): | |
| 13 # print(line) | |
| 14 line_data = line.strip('\n').split('\t') | |
| 15 row_dict = {} | |
| 16 for col_num in range(len(headers)): | |
| 17 col_name = headers[col_num] | |
| 18 row_dict[col_name] = line_data[col_num] | |
| 19 data_dict[row_id] = row_dict | |
| 20 row_id += 1 | |
| 21 return data_dict | |
| 22 | |
| 23 | |
| 24 all_data_dict = {} | |
| 25 print('YAML -------------') | |
| 26 studies_table_path = sys.argv[1] | |
| 27 table_data = fetch_table_data(studies_table_path) | |
| 28 all_data_dict['ENA_study'] = table_data | |
| 29 samples_table_path = sys.argv[2] | |
| 30 table_data = fetch_table_data(samples_table_path) | |
| 31 all_data_dict['ENA_sample'] = table_data | |
| 32 experiments_table_path = sys.argv[3] | |
| 33 table_data = fetch_table_data(experiments_table_path) | |
| 34 all_data_dict['ENA_experiment'] = table_data | |
| 35 runs_table_path = sys.argv[4] | |
| 36 table_data = fetch_table_data(runs_table_path) | |
| 37 all_data_dict['ENA_run'] = table_data | |
| 38 # print(all_data_dict) | |
| 39 print(yaml.dump(all_data_dict)) | |
| 40 print('YAML -------------') |
