- 
                Notifications
    You must be signed in to change notification settings 
- Fork 79
Ebi step 3 #1464
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ebi step 3 #1464
Changes from 12 commits
bc86472
              8564165
              664d137
              6320220
              08c7b2b
              40e2abf
              9f05273
              3f938bf
              e813cf0
              31a9f7b
              6286792
              47bb358
              b21fec8
              File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change | 
|---|---|---|
|  | @@ -6,10 +6,8 @@ | |
| # The full license is in the file LICENSE, distributed with this software. | ||
| # ----------------------------------------------------------------------------- | ||
|  | ||
| from os import makedirs | ||
| from os.path import join, isdir | ||
| from shutil import rmtree | ||
| from functools import partial | ||
| from tarfile import open as taropen | ||
| from tempfile import mkdtemp | ||
|  | ||
|  | @@ -43,13 +41,13 @@ def submit_EBI(preprocessed_data_id, action, send, fastq_dir_fp=None): | |
| If fastq_dir_fp is passed, it must not contain any empty files, or | ||
| gzipped empty files | ||
| """ | ||
| # step 1 | ||
| # step 1: init and validate | ||
| ebi_submission = EBISubmission(preprocessed_data_id, action) | ||
|  | ||
| # step 2 | ||
| # step 2: generate demux fastq files | ||
| ebi_submission.preprocessed_data.update_insdc_status('demuxing samples') | ||
| try: | ||
| demux_samples = ebi_submission.generate_demultiplexed_fastq() | ||
| ebi_submission.generate_demultiplexed_fastq() | ||
| except: | ||
| error_msg = format_exc() | ||
| if isdir(ebi_submission.ebi_dir): | ||
|  | @@ -60,46 +58,35 @@ def submit_EBI(preprocessed_data_id, action, send, fastq_dir_fp=None): | |
| info={'ebi_submission': preprocessed_data_id}) | ||
| raise | ||
|  | ||
| # other steps | ||
| output_dir = fastq_dir_fp + '_submission' | ||
| sample_template = ebi_submission.sample_template | ||
| prep_template = ebi_submission.prep_template | ||
| preprocessed_data = ebi_submission.preprocessed_data | ||
|  | ||
| samp_fp = join(fastq_dir_fp, 'sample_metadata.txt') | ||
| prep_fp = join(fastq_dir_fp, 'prep_metadata.txt') | ||
|  | ||
| sample_template.to_file(samp_fp, demux_samples) | ||
| prep_template.to_file(prep_fp, demux_samples) | ||
|  | ||
| # Get specific output directory and set filepaths | ||
| get_output_fp = partial(join, output_dir) | ||
| study_fp = get_output_fp('study.xml') | ||
| sample_fp = get_output_fp('sample.xml') | ||
| experiment_fp = get_output_fp('experiment.xml') | ||
| run_fp = get_output_fp('run.xml') | ||
| submission_fp = get_output_fp('submission.xml') | ||
|  | ||
| if not isdir(output_dir): | ||
| makedirs(output_dir) | ||
| else: | ||
| raise IOError('The output folder already exists: %s' % | ||
| output_dir) | ||
|  | ||
| ebi_submission.write_all_xml_files(study_fp, sample_fp, experiment_fp, | ||
| run_fp, submission_fp, action) | ||
| # step 3: generate and write xml files | ||
| ebi_submission.write_xml_file(ebi_submission.generate_study_xml(), | ||
| 'study_xml_fp', | ||
| ebi_submission.study_xml_fp) | ||
| ebi_submission.write_xml_file(ebi_submission.generate_sample_xml(), | ||
| 'sample_xml_fp', | ||
| ebi_submission.sample_xml_fp) | ||
| ebi_submission.write_xml_file(ebi_submission.generate_experiment_xml(), | ||
| 'experiment_xml_fp', | ||
| ebi_submission.experiment_xml_fp) | ||
| ebi_submission.write_xml_file(ebi_submission.generate_run_xml(), | ||
| 'run_xml_fp', | ||
| ebi_submission.run_xml_fp) | ||
| ebi_submission.write_xml_file(ebi_submission.generate_submission_xml(), | ||
| 'submission_xml_fp', | ||
| ebi_submission.submission_xml_fp) | ||
|  | ||
| # other steps | ||
| if send: | ||
| ebi_submission.send_sequences() | ||
| study_accession, submission_accession = ebi_submission.send_xml() | ||
|  | ||
| if study_accession is None or submission_accession is None: | ||
| There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just to confirm, this block of code is already replicated somewhere else (in your previous PR IIRC), right? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, before we had different folders for different things and now we have 1 single folder. | ||
| preprocessed_data.update_insdc_status('failed') | ||
| ebi_submission.preprocessed_data.update_insdc_status('failed') | ||
|  | ||
| raise ComputeError("EBI Submission failed!") | ||
| else: | ||
| preprocessed_data.update_insdc_status('success', study_accession, | ||
| submission_accession) | ||
| ebi_submission.preprocessed_data.update_insdc_status( | ||
| 'success', study_accession, submission_accession) | ||
| else: | ||
| study_accession, submission_accession = None, None | ||
|  | ||
|  | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of deleting this lines, can you just check that is returning an empty set? I think this was the original idea of this test but got lost when scientific_name become required. This way we will have a test for a template that is not missing anything.