Skip to content
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

WIP: Next steps #1488

Merged
merged 21 commits into from
Oct 10, 2015
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 4 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@ before_install:
# Update conda itself
- conda update --yes conda
# Downloading and setting up ascp for EBI testing
- if [ ${TRAVIS_PULL_REQUEST} == "false" ]; then sh setup_acsp.sh; fi
- wget ftp://ftp.microbio.me/pub/qiita/ascp-install-3.5.4.102989-linux-64-qiita.sh -O ascp-install-3.5.4.102989-linux-64-qiita.sh
- chmod +x ascp-install-3.5.4.102989-linux-64-qiita.sh
- ./ascp-install-3.5.4.102989-linux-64-qiita.sh
- if [ ${TRAVIS_PULL_REQUEST} == "false" ]; then openssl aes-256-cbc -K $encrypted_e698cf0e691c_key -iv $encrypted_e698cf0e691c_iv -in qiita_core/support_files/config_test_travis.cfg.enc -out qiita_core/support_files/config_test_travis.cfg -d; fi
install:
# install a few of the dependencies that pip would otherwise try to install
# when intalling scikit-bio
Expand Down
7 changes: 0 additions & 7 deletions qiita_core/configuration_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,16 +78,12 @@ class ConfigurationManager(object):
smtp_email : str
The email address that mail will be sent from when sending mail from
the SMTP server
ebi_access_key : str
The access key issued by EBI for REST submissions
ebi_seq_xfer_user : str
The user to use when submitting to EBI
ebi_seq_xfer_pass : str
The password for the ebi_seq_xfer_user
ebi_seq_xfer_url : str
The URL of EBI's sequence portal site
ebi_skip_curl_cert : bool
Whether or not to skip the certificate check when curling the metadata
ebi_center_name : str
The name of the sequencing center to use when doing EBI submissions
ebi_organization_prefix : str
Expand Down Expand Up @@ -213,14 +209,11 @@ def _get_smtp(self, config):

def _get_ebi(self, config):
sec_get = partial(config.get, 'ebi')
sec_getbool = partial(config.getboolean, 'ebi')

self.ebi_access_key = sec_get('EBI_ACCESS_KEY')
self.ebi_seq_xfer_user = sec_get('EBI_SEQ_XFER_USER')
self.ebi_seq_xfer_pass = sec_get('EBI_SEQ_XFER_PASS')
self.ebi_seq_xfer_url = sec_get('EBI_SEQ_XFER_URL')
self.ebi_dropbox_url = sec_get('EBI_DROPBOX_URL')
self.ebi_skip_curl_cert = sec_getbool('EBI_SKIP_CURL_CERT')
self.ebi_center_name = sec_get('EBI_CENTER_NAME')
self.ebi_organization_prefix = sec_get('EBI_ORGANIZATION_PREFIX')

Expand Down
9 changes: 1 addition & 8 deletions qiita_core/support_files/config_test.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,6 @@ ADMIN_PASSWORD =

# ----------------------------- EBI settings -----------------------------
[ebi]
# The access key issued by EBI for REST submissions
EBI_ACCESS_KEY =

# The user to use when submitting to EBI
EBI_SEQ_XFER_USER = Webin-41528

Expand All @@ -117,12 +114,8 @@ EBI_SEQ_XFER_URL = webin.ebi.ac.uk
# testing URL
EBI_DROPBOX_URL = https://www-test.ebi.ac.uk/ena/submit/drop-box/submit/

# Skip acertificate check when calling curl (necessary for using the EBI test
# dropbox URL)
EBI_SKIP_CURL_CERT = True

# The name of the sequencing center to use when doing EBI submissions
EBI_CENTER_NAME = CCME-COLORADO
EBI_CENTER_NAME = qiita-test

# This string (with an underscore) will be prefixed to your EBI submission and
# study aliases
Expand Down
Binary file modified qiita_core/support_files/config_test_travis.cfg.enc
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ These are the columns required for successfully submit your data to EBI:
+----------------------------------+----------------------+----------------------------------------------------------------------------------------------------------+
| ``taxon_id`` | integer | NCBI's taxon id for the sample |
+----------------------------------+----------------------+----------------------------------------------------------------------------------------------------------+
| ``description`` | free text | Description of the sample. |
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The rendering is a little bit off, would you mind having a look at the formatting?

screen shot 2015-10-09 at 10 09 59 am

+----------------------------------+----------------------+----------------------------------------------------------------------------------------------------------+
| ``scientific_name`` | free text | NCBI's scientific name for the provided taxon ID |
+----------------------------------+----------------------+----------------------------------------------------------------------------------------------------------+

Expand All @@ -52,8 +54,6 @@ the centralized `Qiita server <http://qiita.microbio.me>`__:
+===================================+======================================================================+=============================================================================================================================================================================================================================================+
| ``sample_type`` | free text | Description of the type of sample. |
+-----------------------------------+----------------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| ``description`` | free text | Description of the sample. |
+-----------------------------------+----------------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| ``physical_specimen_remaining`` | ``y`` or ``n`` | Is there still physical sample (e.g., soil, not DNA) available? |
+-----------------------------------+----------------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| ``dna_extracted`` | ``y`` or ``n`` | Has DNA already been extracted for this sample? |
Expand Down
82 changes: 45 additions & 37 deletions qiita_ware/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,20 @@
from shutil import rmtree
from tarfile import open as taropen
from tempfile import mkdtemp

from os import environ
from traceback import format_exc
from moi.job import system_call

from qiita_db.study import Study
from qiita_db.data import PreprocessedData
from qiita_db.metadata_template import PrepTemplate, SampleTemplate
from qiita_db.logger import LogEntry
from qiita_core.qiita_settings import qiita_config
from qiita_ware.ebi import EBISubmission
from qiita_ware.exceptions import ComputeError, EBISubmissionError
from traceback import format_exc
from os import environ


def submit_EBI(preprocessed_data_id, action, send, fastq_dir_fp=None):
def submit_EBI(preprocessed_data_id, action, send):
"""Submit a preprocessed data to EBI

Parameters
Expand All @@ -34,27 +34,19 @@ def submit_EBI(preprocessed_data_id, action, send, fastq_dir_fp=None):
The action to perform with this data
send : bool
True to actually send the files
fastq_dir_fp : str, optional
The fastq filepath

Notes
-----
If fastq_dir_fp is passed, it must not contain any empty files, or
gzipped empty files
"""
# step 1: init and validate
ebi_submission = EBISubmission(preprocessed_data_id, action)

# step 2: generate demux fastq files
ebi_submission.preprocessed_data.update_insdc_status('demuxing samples')
ebi_submission.study.ebi_submission_status = 'submitting'
try:
ebi_submission.generate_demultiplexed_fastq()
except:
error_msg = format_exc()
if isdir(ebi_submission.ebi_dir):
rmtree(ebi_submission.ebi_dir)
ebi_submission.preprocessed_data.update_insdc_status(
'failed: %s' % error_msg)
if isdir(ebi_submission.full_ebi_dir):
rmtree(ebi_submission.full_ebi_dir)
ebi_submission.study.ebi_submission_status = 'failed: %s' % error_msg
LogEntry.create('Runtime', error_msg,
info={'ebi_submission': preprocessed_data_id})
raise
Expand All @@ -66,49 +58,65 @@ def submit_EBI(preprocessed_data_id, action, send, fastq_dir_fp=None):
# step 4: sending sequences
old_ascp_pass = environ.get('ASPERA_SCP_PASS', '')
environ['ASPERA_SCP_PASS'] = qiita_config.ebi_seq_xfer_pass
seqs_cmds = ebi_submission.generate_send_sequences_cmd()

LogEntry.create('Runtime',
("Submitting sequences for pre_processed_id: "
"%d" % preprocessed_data_id))
try:
# place holder for moi call see #1477
pass
except:
LogEntry.create('Fatal', seqs_cmds,
info={'ebi_submission': preprocessed_data_id})
else:
LogEntry.create('Runtime',
('Submission of sequences of pre_processed_id: '
'%d completed successfully' %
preprocessed_data_id))
environ['ASPERA_SCP_PASS'] = old_ascp_pass
for cmd in ebi_submission.generate_send_sequences_cmd():
try:
stdout, stderr, _ = system_call(cmd)
except Exception as e:
stdout = ''
stderr = str(e)
ebi_submission.study.ebi_submission_status = (
"failed: ASCP - %s" % stderr)
LogEntry.create('Fatal', stderr,
info={
'ebi_submission': preprocessed_data_id,
'fail': cmd})
raise
finally:
open(ebi_submission.ascp_reply, 'a').write(
'stdout:\n%s\n\nstderr: %s' % (stdout, stderr))
finally:
environ['ASPERA_SCP_PASS'] = old_ascp_pass
LogEntry.create('Runtime',
('Submission of sequences of pre_processed_id: '
'%d completed successfully' %
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this activate the fireworks at the top of BRF2? 😃

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nop, cause this time it actually works well (or at least we hope!) vs. giving you the impression via fireworks that it does.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So the lack of fireworks is the celebration of success, as this is real
success? ... so postmodern.

On (Oct-09-15|10:19), Antonio Gonzalez wrote:

  •    for cmd in ebi_submission.generate_send_sequences_cmd():
    
  •        cmd_pieces = shsplit(cmd)
    
  •        try:
    
  •            call(cmd_pieces, stdout=open(ebi_submission.ascp_reply, 'a'))
    
  •        except:
    
  •            with open(ebi_submission.ascp_reply, 'r') as f:
    
  •                content = f.read()
    
  •            ebi_submission.study.ebi_submission_status = (
    
  •                "failed: ASCP - %s" % content)
    
  •            LogEntry.create('Fatal', content,
    
  •                            info={
    
  •                                'ebi_submission': preprocessed_data_id,
    
  •                                'fail': cmd})
    
  •    LogEntry.create('Runtime',
    
  •                    ('Submission of sequences of pre_processed_id: '
    
  •                     '%d completed successfully' %
    

Nop, cause this time it actually works well (or at least we hope!) vs. giving you the impression via fireworks that it does.


Reply to this email directly or view it on GitHub:
https://github.com/biocore/qiita/pull/1488/files#r41654914

preprocessed_data_id))

# step 5: sending xml and parsing answer
xmls_cmds = ebi_submission.generate_curl_command()
LogEntry.create('Runtime',
("Submitting XMLs for pre_processed_id: "
"%d" % preprocessed_data_id))
try:
# place holder for moi call see #1477
xmls_cmds_moi = xmls_cmds
except:
# handle exception
LogEntry.create('Fatal', seqs_cmds,
info={'ebi_submission': preprocessed_data_id})
xml_content, stderr, _ = system_call(xmls_cmds)

except Exception as e:
error = str(e)
LogEntry.create('Fatal', error,
info={'ebi_submission': preprocessed_data_id,
'fail': cmd})
else:
LogEntry.create('Runtime',
('Submission of sequences of pre_processed_id: '
'%d completed successfully' %
preprocessed_data_id))
finally:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If system_call raises, xml_content is not defined, and stderr doesn't contain the value from such call (it will have the value from the above call to system_call in the loop.

open(ebi_submission.curl_reply, 'w').write(
'stdout:\n%s\n\nstderr: %s' % (xml_content, stderr))

try:
st_acc, sa_acc, bio_acc, ex_acc, run_acc = \
ebi_submission.parse_EBI_reply(xmls_cmds_moi)
ebi_submission.parse_EBI_reply(xml_content)
except EBISubmissionError as e:
le = LogEntry.create(
'Fatal', "Command: %s\nError: %s\n" % (xmls_cmds_moi, str(e)),
'Fatal', "Command: %s\nError: %s\n" % (xml_content, str(e)),
info={'ebi_submission': preprocessed_data_id})
ebi_submission.preprocessed_data.update_insdc_status('failed')
ebi_submission.study.ebi_submission_status = (
"failed: XML submission, log id: %d" % le.id)
raise ComputeError("EBI Submission failed! Log id: %d" % le.id)

ebi_submission.study.ebi_submission_status = 'submitted'
Expand Down
6 changes: 1 addition & 5 deletions qiita_ware/dispatchable.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,7 @@ def preprocessor(study_id, prep_template_id, param_id, param_constructor):

def submit_to_ebi(preprocessed_data_id, submission_type):
"""Submit a study to EBI"""
study_acc, submission_acc = submit_EBI(preprocessed_data_id,
submission_type,
True)

return study_acc, submission_acc
submit_EBI(preprocessed_data_id, submission_type, True)


def submit_to_VAMPS(preprocessed_data_id):
Expand Down