view dump_yaml.py @ 9:a62c4a11a67d draft

planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ena_upload commit 6770d277b4136b4068293c4260022d4ae33b2379
author iuc
date Thu, 10 Nov 2022 15:18:00 +0000
parents 6f6537780379
children
line wrap: on
line source

import sys

import yaml


def fetch_table_data(table_path):
    data_dict = {}
    with open(table_path) as table_to_load:
        # load headers
        headers = table_to_load.readline().strip('\n').split('\t')
        row_id = 0
        for line in table_to_load.readlines():
            # print(line)
            line_data = line.strip('\n').split('\t')
            row_dict = {}
            for col_num in range(len(headers)):
                col_name = headers[col_num]
                row_dict[col_name] = line_data[col_num]
            data_dict[row_id] = row_dict
            row_id += 1
        return data_dict


all_data_dict = {}
print('YAML -------------')
studies_table_path = sys.argv[1]
table_data = fetch_table_data(studies_table_path)
all_data_dict['ENA_study'] = table_data
samples_table_path = sys.argv[2]
table_data = fetch_table_data(samples_table_path)
all_data_dict['ENA_sample'] = table_data
experiments_table_path = sys.argv[3]
table_data = fetch_table_data(experiments_table_path)
all_data_dict['ENA_experiment'] = table_data
runs_table_path = sys.argv[4]
table_data = fetch_table_data(runs_table_path)
all_data_dict['ENA_run'] = table_data
# print(all_data_dict)
print(yaml.dump(all_data_dict))
print('YAML -------------')