annotate dump_yaml.py @ 14:5cb6146337d8 draft default tip

planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ena_upload commit ab38fa3d5ec06729c1efa86240ec57b8143b21ed
author iuc
date Wed, 12 Jun 2024 16:01:11 +0000
parents 6f6537780379
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
7
6f6537780379 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ena_upload commit 9961f24acebb17f837238df6541e1af59df1163b"
iuc
parents:
diff changeset
1 import sys
6f6537780379 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ena_upload commit 9961f24acebb17f837238df6541e1af59df1163b"
iuc
parents:
diff changeset
2
6f6537780379 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ena_upload commit 9961f24acebb17f837238df6541e1af59df1163b"
iuc
parents:
diff changeset
3 import yaml
6f6537780379 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ena_upload commit 9961f24acebb17f837238df6541e1af59df1163b"
iuc
parents:
diff changeset
4
6f6537780379 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ena_upload commit 9961f24acebb17f837238df6541e1af59df1163b"
iuc
parents:
diff changeset
5
6f6537780379 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ena_upload commit 9961f24acebb17f837238df6541e1af59df1163b"
iuc
parents:
diff changeset
6 def fetch_table_data(table_path):
6f6537780379 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ena_upload commit 9961f24acebb17f837238df6541e1af59df1163b"
iuc
parents:
diff changeset
7 data_dict = {}
6f6537780379 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ena_upload commit 9961f24acebb17f837238df6541e1af59df1163b"
iuc
parents:
diff changeset
8 with open(table_path) as table_to_load:
6f6537780379 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ena_upload commit 9961f24acebb17f837238df6541e1af59df1163b"
iuc
parents:
diff changeset
9 # load headers
6f6537780379 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ena_upload commit 9961f24acebb17f837238df6541e1af59df1163b"
iuc
parents:
diff changeset
10 headers = table_to_load.readline().strip('\n').split('\t')
6f6537780379 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ena_upload commit 9961f24acebb17f837238df6541e1af59df1163b"
iuc
parents:
diff changeset
11 row_id = 0
6f6537780379 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ena_upload commit 9961f24acebb17f837238df6541e1af59df1163b"
iuc
parents:
diff changeset
12 for line in table_to_load.readlines():
6f6537780379 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ena_upload commit 9961f24acebb17f837238df6541e1af59df1163b"
iuc
parents:
diff changeset
13 # print(line)
6f6537780379 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ena_upload commit 9961f24acebb17f837238df6541e1af59df1163b"
iuc
parents:
diff changeset
14 line_data = line.strip('\n').split('\t')
6f6537780379 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ena_upload commit 9961f24acebb17f837238df6541e1af59df1163b"
iuc
parents:
diff changeset
15 row_dict = {}
6f6537780379 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ena_upload commit 9961f24acebb17f837238df6541e1af59df1163b"
iuc
parents:
diff changeset
16 for col_num in range(len(headers)):
6f6537780379 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ena_upload commit 9961f24acebb17f837238df6541e1af59df1163b"
iuc
parents:
diff changeset
17 col_name = headers[col_num]
6f6537780379 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ena_upload commit 9961f24acebb17f837238df6541e1af59df1163b"
iuc
parents:
diff changeset
18 row_dict[col_name] = line_data[col_num]
6f6537780379 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ena_upload commit 9961f24acebb17f837238df6541e1af59df1163b"
iuc
parents:
diff changeset
19 data_dict[row_id] = row_dict
6f6537780379 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ena_upload commit 9961f24acebb17f837238df6541e1af59df1163b"
iuc
parents:
diff changeset
20 row_id += 1
6f6537780379 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ena_upload commit 9961f24acebb17f837238df6541e1af59df1163b"
iuc
parents:
diff changeset
21 return data_dict
6f6537780379 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ena_upload commit 9961f24acebb17f837238df6541e1af59df1163b"
iuc
parents:
diff changeset
22
6f6537780379 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ena_upload commit 9961f24acebb17f837238df6541e1af59df1163b"
iuc
parents:
diff changeset
23
6f6537780379 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ena_upload commit 9961f24acebb17f837238df6541e1af59df1163b"
iuc
parents:
diff changeset
24 all_data_dict = {}
6f6537780379 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ena_upload commit 9961f24acebb17f837238df6541e1af59df1163b"
iuc
parents:
diff changeset
25 print('YAML -------------')
6f6537780379 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ena_upload commit 9961f24acebb17f837238df6541e1af59df1163b"
iuc
parents:
diff changeset
26 studies_table_path = sys.argv[1]
6f6537780379 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ena_upload commit 9961f24acebb17f837238df6541e1af59df1163b"
iuc
parents:
diff changeset
27 table_data = fetch_table_data(studies_table_path)
6f6537780379 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ena_upload commit 9961f24acebb17f837238df6541e1af59df1163b"
iuc
parents:
diff changeset
28 all_data_dict['ENA_study'] = table_data
6f6537780379 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ena_upload commit 9961f24acebb17f837238df6541e1af59df1163b"
iuc
parents:
diff changeset
29 samples_table_path = sys.argv[2]
6f6537780379 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ena_upload commit 9961f24acebb17f837238df6541e1af59df1163b"
iuc
parents:
diff changeset
30 table_data = fetch_table_data(samples_table_path)
6f6537780379 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ena_upload commit 9961f24acebb17f837238df6541e1af59df1163b"
iuc
parents:
diff changeset
31 all_data_dict['ENA_sample'] = table_data
6f6537780379 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ena_upload commit 9961f24acebb17f837238df6541e1af59df1163b"
iuc
parents:
diff changeset
32 experiments_table_path = sys.argv[3]
6f6537780379 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ena_upload commit 9961f24acebb17f837238df6541e1af59df1163b"
iuc
parents:
diff changeset
33 table_data = fetch_table_data(experiments_table_path)
6f6537780379 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ena_upload commit 9961f24acebb17f837238df6541e1af59df1163b"
iuc
parents:
diff changeset
34 all_data_dict['ENA_experiment'] = table_data
6f6537780379 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ena_upload commit 9961f24acebb17f837238df6541e1af59df1163b"
iuc
parents:
diff changeset
35 runs_table_path = sys.argv[4]
6f6537780379 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ena_upload commit 9961f24acebb17f837238df6541e1af59df1163b"
iuc
parents:
diff changeset
36 table_data = fetch_table_data(runs_table_path)
6f6537780379 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ena_upload commit 9961f24acebb17f837238df6541e1af59df1163b"
iuc
parents:
diff changeset
37 all_data_dict['ENA_run'] = table_data
6f6537780379 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ena_upload commit 9961f24acebb17f837238df6541e1af59df1163b"
iuc
parents:
diff changeset
38 # print(all_data_dict)
6f6537780379 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ena_upload commit 9961f24acebb17f837238df6541e1af59df1163b"
iuc
parents:
diff changeset
39 print(yaml.dump(all_data_dict))
6f6537780379 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ena_upload commit 9961f24acebb17f837238df6541e1af59df1163b"
iuc
parents:
diff changeset
40 print('YAML -------------')