Mercurial > repos > iuc > ena_upload
comparison extract_tables.py @ 1:57251c760cab draft
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ena_upload commit ffea061c1ad6e7291abfe220230dbdbe8d19a2bd"
author | iuc |
---|---|
date | Fri, 30 Apr 2021 12:09:25 +0000 |
parents | 382518f24d6d |
children | 6f6537780379 |
comparison
equal
deleted
inserted
replaced
0:382518f24d6d | 1:57251c760cab |
---|---|
1 import argparse | 1 import argparse |
2 import json | 2 import json |
3 import pathlib | 3 import pathlib |
4 from datetime import datetime | 4 from datetime import datetime |
5 | |
6 """ | |
7 Parse the configfile generated by the Galaxy tool. | |
8 This file is JSON-formatted and should be converted to a set of tabular files. | |
9 """ | |
5 | 10 |
6 FILE_FORMAT = 'fastq' | 11 FILE_FORMAT = 'fastq' |
7 | 12 |
8 parser = argparse.ArgumentParser() | 13 parser = argparse.ArgumentParser() |
9 parser.add_argument('--studies', dest='studies_json_path', required=True) | 14 parser.add_argument('--studies', dest='studies_json_path', required=True) |
76 exp['library_construction_protocol'], | 81 exp['library_construction_protocol'], |
77 exp['platform'], exp['instrument_model'], | 82 exp['platform'], exp['instrument_model'], |
78 'submission_date_ENA']) + '\n') | 83 'submission_date_ENA']) + '\n') |
79 run_index = 0 | 84 run_index = 0 |
80 # exp['runs'] is a list of lists | 85 # exp['runs'] is a list of lists |
81 for run in exp['runs']: | 86 for (base_run, run_files) in exp['runs']: |
82 run_index += 1 | 87 run_index += 1 |
83 run_alias = '.'.join(['run_' + str(run_index), str(exp_index), str(sample_index)]) \ | 88 if base_run != '': |
84 + '_' + timestamp | 89 run_alias = base_run |
85 for file_entry in run: | 90 else: |
91 # no alias provided, generated a unique one | |
92 run_alias = '_'.join(['run_' + str(run_index), str(exp_index), | |
93 str(sample_index)]) + '_' + timestamp | |
94 for file_entry in run_files: | |
86 runs_table.write('\t'.join([run_alias, action, 'ena_run_accession', exp_alias, | 95 runs_table.write('\t'.join([run_alias, action, 'ena_run_accession', exp_alias, |
87 file_entry, FILE_FORMAT, 'file_checksum', | 96 file_entry, FILE_FORMAT, 'file_checksum', |
88 'submission_date_ENA']) + '\n') | 97 'submission_date_ENA']) + '\n') |
89 | 98 |
90 studies_table.close() | 99 studies_table.close() |