Mercurial > repos > iuc > ena_upload
comparison extract_tables.py @ 10:480d9e9d156b draft
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ena_upload commit dccd4c0668ec8ce1b1c8fd9cef4dcf3a99dc78b3
| author | iuc |
|---|---|
| date | Fri, 27 Oct 2023 19:44:40 +0000 |
| parents | a62c4a11a67d |
| children |
comparison
equal
deleted
inserted
replaced
| 9:a62c4a11a67d | 10:480d9e9d156b |
|---|---|
| 38 dt_oobj = datetime.now(tz=None) | 38 dt_oobj = datetime.now(tz=None) |
| 39 timestamp = dt_oobj.strftime("%Y%m%d_%H:%M:%S") | 39 timestamp = dt_oobj.strftime("%Y%m%d_%H:%M:%S") |
| 40 for study_index, study in enumerate(studies_dict): | 40 for study_index, study in enumerate(studies_dict): |
| 41 study_alias = 'study_' + str(study_index) + '_' + timestamp | 41 study_alias = 'study_' + str(study_index) + '_' + timestamp |
| 42 studies_table.write('\t'.join([study_alias, action, study['title'], | 42 studies_table.write('\t'.join([study_alias, action, study['title'], |
| 43 study['type'], study['abstract'], study['pubmed_id'], | 43 study['type'], study['abstract'], study['pubmed_id']])) |
| 44 ])) | 44 if "host_subject_id" in study['samples'][0].keys(): # sample belongs to a viral sample |
| 45 if "geo_location" in study['samples'][0].keys(): # sample belongs to a viral sample | |
| 46 samples_table.write('\t'.join(['alias', 'status', 'title', 'scientific_name', | 45 samples_table.write('\t'.join(['alias', 'status', 'title', 'scientific_name', |
| 47 'taxon_id', 'sample_description', 'collection date', | 46 'taxon_id', 'sample_description', 'collection date', |
| 48 'geographic location (country and/or sea)', 'host common name', 'host subject id', | 47 'geographic location (country and/or sea)', 'host common name', 'host subject id', |
| 49 'host health state', 'host sex', 'host scientific name', | 48 'host health state', 'host sex', 'host scientific name', |
| 50 'collector name', 'collecting institution', 'isolate', | 49 'collector name', 'collecting institution', 'isolate']) + '\n') |
| 51 ]) + '\n') | |
| 52 else: | 50 else: |
| 53 samples_table.write('\t'.join(['alias', 'status', 'title', 'scientific_name', | 51 samples_table.write('\t'.join(['alias', 'status', 'title', 'scientific_name', |
| 54 'taxon_id', 'sample_description']) + '\n') | 52 'taxon_id', 'sample_description', 'collection date', |
| 53 'geographic location (country and/or sea)']) + '\n') | |
| 55 for sample_index, sample in enumerate(study['samples']): | 54 for sample_index, sample in enumerate(study['samples']): |
| 56 sample_alias = 'sample_' + str(sample_index) + '_' + timestamp | 55 sample_alias = 'sample_' + str(sample_index) + '_' + timestamp |
| 57 if "geo_location" in sample.keys(): # sample belongs to a viral sample | 56 if "host_subject_id" in sample.keys(): # sample belongs to a viral sample |
| 58 if sample['collector_name'] == '': | 57 if sample['collector_name'] == '': |
| 59 sample['collector_name'] = 'unknown' | 58 sample['collector_name'] = 'unknown' |
| 60 samples_table.write('\t'.join([sample_alias, action, sample['title'], | 59 samples_table.write('\t'.join([sample_alias, action, sample['title'], |
| 61 sample['tax_name'], sample['tax_id'], | 60 sample['tax_name'], sample['tax_id'], |
| 62 sample['description'], sample['collection_date'], | 61 sample['description'], sample['collection_date'], |
| 63 sample['geo_location'], sample['host_common_name'], | 62 sample['geo_location'], sample['host_common_name'], |
| 64 sample['host_subject_id'], sample['host_health_state'], | 63 sample['host_subject_id'], sample['host_health_state'], |
| 65 sample['host_sex'], sample['host_scientific_name'], | 64 sample['host_sex'], sample['host_scientific_name'], |
| 66 sample['collector_name'], | 65 sample['collector_name'], |
| 67 sample['collecting_institution'], sample['isolate'], | 66 sample['collecting_institution'], sample['isolate'] |
| 68 ]) + '\n') | 67 ]) + '\n') |
| 69 else: | 68 else: |
| 70 samples_table.write('\t'.join([sample_alias, action, sample['title'], | 69 samples_table.write('\t'.join([sample_alias, action, sample['title'], |
| 71 sample['tax_name'], sample['tax_id'], | 70 sample['tax_name'], sample['tax_id'], |
| 72 sample['description']]) + '\n') | 71 sample['description'], sample['collection_date'], |
| 72 sample['geo_location']]) + '\n') | |
| 73 for exp_index, exp in enumerate(sample['experiments']): | 73 for exp_index, exp in enumerate(sample['experiments']): |
| 74 exp_alias = 'experiment_' + str(exp_index) + '.' + str(sample_index) + '_' + timestamp | 74 exp_alias = 'experiment_' + str(exp_index) + '.' + str(sample_index) + '_' + timestamp |
| 75 lib_alias = 'library_' + str(exp_index) + '_' + str(sample_index) | 75 lib_alias = 'library_' + str(exp_index) + '_' + str(sample_index) |
| 76 experiments_table.write('\t'.join([exp_alias, action, exp['title'], | 76 experiments_table.write('\t'.join([exp_alias, action, exp['title'], |
| 77 study_alias, sample_alias, exp['experiment_design'], | 77 study_alias, sample_alias, exp['experiment_design'], |
| 78 lib_alias, exp['library_strategy'], | 78 lib_alias, exp['library_strategy'], |
| 79 exp['library_source'], exp['library_selection'], | 79 exp['library_source'], exp['library_selection'], |
| 80 exp['library_layout'].lower(), exp['insert_size'], | 80 exp['library_layout'].lower(), exp['insert_size'], |
| 81 exp['library_construction_protocol'], | 81 exp['library_construction_protocol'], |
| 82 exp['platform'], exp['instrument_model'], | 82 exp['platform'], exp['instrument_model']]) + '\n') |
| 83 ]) + '\n') | |
| 84 run_index = 0 | 83 run_index = 0 |
| 85 # exp['runs'] is a list of lists | 84 # exp['runs'] is a list of lists |
| 86 for (base_run, run_files) in exp['runs']: | 85 for (base_run, run_files) in exp['runs']: |
| 87 run_index += 1 | 86 run_index += 1 |
| 88 if base_run != '': | 87 if base_run != '': |
