diff extract_tables.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 480d9e9d156b
line wrap: on
line diff
--- a/extract_tables.py	Wed May 04 17:06:42 2022 +0000
+++ b/extract_tables.py	Thu Nov 10 15:18:00 2022 +0000
@@ -19,19 +19,19 @@
 with open(args.studies_json_path, 'r') as studies_json_file:
     studies_dict = json.load(studies_json_file)
 studies_table = open(pathlib.Path(args.out_path) / 'studies.tsv', 'w')
-studies_table.write('\t'.join(['alias', 'status', 'accession', 'title', 'study_type',
-                               'study_abstract', 'pubmed_id', 'submission_date']) + '\n')
+studies_table.write('\t'.join(['alias', 'status', 'title', 'study_type',
+                               'study_abstract', 'pubmed_id']) + '\n')
 samples_table = open(pathlib.Path(args.out_path) / 'samples.tsv', 'w')
 experiments_table = open(pathlib.Path(args.out_path) / 'experiments.tsv', 'w')
-experiments_table.write('\t'.join(['alias', 'status', 'accession', 'title', 'study_alias',
+experiments_table.write('\t'.join(['alias', 'status', 'title', 'study_alias',
                                    'sample_alias', 'design_description', 'library_name',
                                    'library_strategy', 'library_source', 'library_selection',
                                    'library_layout', 'insert_size',
                                    'library_construction_protocol', 'platform', 'instrument_model',
-                                   'submission_date']) + '\n')
+                                   ]) + '\n')
 runs_table = open(pathlib.Path(args.out_path) / 'runs.tsv', 'w')
-runs_table.write('\t'.join(['alias', 'status', 'accession', 'experiment_alias', 'file_name',
-                            'file_format', 'file_checksum', 'submission_date']) + '\n')
+runs_table.write('\t'.join(['alias', 'status', 'experiment_alias', 'file_name',
+                            'file_format']) + '\n')
 
 action = args.action
 
@@ -39,25 +39,25 @@
 timestamp = dt_oobj.strftime("%Y%m%d_%H:%M:%S")
 for study_index, study in enumerate(studies_dict):
     study_alias = 'study_' + str(study_index) + '_' + timestamp
-    studies_table.write('\t'.join([study_alias, action, 'ENA_accession', study['title'],
+    studies_table.write('\t'.join([study_alias, action, study['title'],
                                    study['type'], study['abstract'], study['pubmed_id'],
-                                   'ENA_submission_data']))
+                                   ]))
     if "geo_location" in study['samples'][0].keys():           # sample belongs to a viral sample
-        samples_table.write('\t'.join(['alias', 'status', 'accession', 'title', 'scientific_name',
+        samples_table.write('\t'.join(['alias', 'status', 'title', 'scientific_name',
                                        'taxon_id', 'sample_description', 'collection date',
                                        'geographic location (country and/or sea)', 'host common name', 'host subject id',
                                        'host health state', 'host sex', 'host scientific name',
                                        'collector name', 'collecting institution', 'isolate',
-                                       'submission_date']) + '\n')
+                                       ]) + '\n')
     else:
-        samples_table.write('\t'.join(['alias', 'status', 'accession', 'title', 'scientific_name',
-                                       'taxon_id', 'sample_description', 'submission_date']) + '\n')
+        samples_table.write('\t'.join(['alias', 'status', 'title', 'scientific_name',
+                                       'taxon_id', 'sample_description']) + '\n')
     for sample_index, sample in enumerate(study['samples']):
         sample_alias = 'sample_' + str(sample_index) + '_' + timestamp
         if "geo_location" in sample.keys():  # sample belongs to a viral sample
             if sample['collector_name'] == '':
                 sample['collector_name'] = 'unknown'
-            samples_table.write('\t'.join([sample_alias, action, 'ena_accession', sample['title'],
+            samples_table.write('\t'.join([sample_alias, action, sample['title'],
                                            sample['tax_name'], sample['tax_id'],
                                            sample['description'], sample['collection_date'],
                                            sample['geo_location'], sample['host_common_name'],
@@ -65,22 +65,22 @@
                                            sample['host_sex'], sample['host_scientific_name'],
                                            sample['collector_name'],
                                            sample['collecting_institution'], sample['isolate'],
-                                           'ENA_submission_date']) + '\n')
+                                           ]) + '\n')
         else:
-            samples_table.write('\t'.join([sample_alias, action, 'ena_accession', sample['title'],
+            samples_table.write('\t'.join([sample_alias, action, sample['title'],
                                            sample['tax_name'], sample['tax_id'],
-                                           sample['description'], 'ENA_submission_date']) + '\n')
+                                           sample['description']]) + '\n')
         for exp_index, exp in enumerate(sample['experiments']):
             exp_alias = 'experiment_' + str(exp_index) + '.' + str(sample_index) + '_' + timestamp
             lib_alias = 'library_' + str(exp_index) + '_' + str(sample_index)
-            experiments_table.write('\t'.join([exp_alias, action, 'accession_ena', exp['title'],
+            experiments_table.write('\t'.join([exp_alias, action, exp['title'],
                                                study_alias, sample_alias, exp['experiment_design'],
                                                lib_alias, exp['library_strategy'],
                                                exp['library_source'], exp['library_selection'],
                                                exp['library_layout'].lower(), exp['insert_size'],
                                                exp['library_construction_protocol'],
                                                exp['platform'], exp['instrument_model'],
-                                               'submission_date_ENA']) + '\n')
+                                               ]) + '\n')
             run_index = 0
             # exp['runs'] is a list of lists
             for (base_run, run_files) in exp['runs']:
@@ -92,9 +92,8 @@
                     run_alias = '_'.join(['run_' + str(run_index), str(exp_index),
                                           str(sample_index)]) + '_' + timestamp
                 for file_entry in run_files:
-                    runs_table.write('\t'.join([run_alias, action, 'ena_run_accession', exp_alias,
-                                                file_entry, FILE_FORMAT, 'file_checksum',
-                                                'submission_date_ENA']) + '\n')
+                    runs_table.write('\t'.join([run_alias, action, exp_alias,
+                                                file_entry, FILE_FORMAT]) + '\n')
 
 studies_table.close()
 samples_table.close()