def get(self): study_id = self.get_argument('study_id') study = to_int(study_id) res = study_get_req(study, self.current_user.id) study_info = res['study_info'] pdoi = [doi_linkifier([p]) for p in study_info['publication_doi']] ppid = [pubmed_linkifier([p]) for p in study_info['publication_pid']] email = '<a href="mailto:{email}">{name} ({affiliation})</a>' pi = email.format(**study_info['principal_investigator']) if study_info['lab_person']: contact = email.format(**study_info['lab_person']) else: contact = None share_access = (self.current_user.id in study_info['shared_with'] or self.current_user.id == study_info['owner']) ebi_info = study_info['ebi_submission_status'] ebi_study_accession = study_info['ebi_study_accession'] if ebi_study_accession: links = ''.join([ EBI_LINKIFIER.format(a) for a in ebi_study_accession.split(',') ]) ebi_info = '%s (%s)' % (links, study_info['ebi_submission_status']) self.render('study_ajax/base_info.html', study_info=study_info, publications=', '.join(pdoi + ppid), pi=pi, contact=contact, editable=res['editable'], share_access=share_access, ebi_info=ebi_info)
def get(self): study_id = self.get_argument('study_id') study = to_int(study_id) res = study_get_req(study, self.current_user.id) study_info = res['study_info'] pdoi = [doi_linkifier([p]) for p in study_info['publication_doi']] ppid = [pubmed_linkifier([p]) for p in study_info['publication_pid']] email = '<a href="mailto:{email}">{name} ({affiliation})</a>' pi = email.format(**study_info['principal_investigator']) if study_info['lab_person']: contact = email.format(**study_info['lab_person']) else: contact = None share_access = (self.current_user.id in study_info['shared_with'] or self.current_user.id == study_info['owner']) ebi_info = study_info['ebi_submission_status'] ebi_study_accession = study_info['ebi_study_accession'] if ebi_study_accession: links = ''.join([EBI_LINKIFIER.format(a) for a in ebi_study_accession.split(',')]) ebi_info = '%s (%s)' % (links, study_info['ebi_submission_status']) self.render('study_ajax/base_info.html', study_info=study_info, publications=', '.join(pdoi + ppid), pi=pi, contact=contact, editable=res['editable'], share_access=share_access, ebi_info=ebi_info)
def _check_permissions(self, sid): # Check general access to study study_info = study_get_req(sid, self.current_user.id) if study_info['status'] != 'success': raise HTTPError(405, "%s: %s, %s" % (study_info['message'], self.current_user.email, sid)) return Study(sid)
def get(self): study_id = self.get_argument('study_id') study = to_int(study_id) res = study_get_req(study, self.current_user.id) study_info = res['study_info'] study_doi = ' '.join( [doi_linkifier(p) for p in study_info['publications']]) email = '<a href="mailto:{email}">{name} ({affiliation})</a>' pi = email.format(**study_info['principal_investigator']) if study_info['lab_person']: contact = email.format(**study_info['lab_person']) else: contact = None share_access = (self.current_user.id in study_info['shared_with'] or self.current_user.id == study_info['owner']) ebi_info = study_info['ebi_submission_status'] if ebi_info == 'submitted': ebi_info = ''.join([ ('<a href="https://www.ebi.ac.uk/ena/data/view/{0}">{0}' '</a></br>'.format(acc)) for acc in study_info['ebi_study_accession'].split(',') ]) self.render('study_ajax/base_info.html', study_info=study_info, publications=study_doi, pi=pi, contact=contact, editable=res['editable'], share_access=share_access, ebi_info=ebi_info)
def get(self): study_id = self.get_argument('study_id') study = to_int(study_id) res = study_get_req(study, self.current_user.id) study_info = res['study_info'] study_doi = ' '.join( [doi_linkifier(p) for p in study_info['publications']]) email = '<a href="mailto:{email}">{name} ({affiliation})</a>' pi = email.format(**study_info['principal_investigator']) if study_info['lab_person']: contact = email.format(**study_info['lab_person']) else: contact = None share_access = (self.current_user.id in study_info['shared_with'] or self.current_user.id == study_info['owner']) ebi_info = study_info['ebi_submission_status'] if ebi_info == 'submitted': ebi_info = ''.join([ ('<a href="https://www.ebi.ac.uk/ena/data/view/{0}">{0}' '</a></br>'.format(acc)) for acc in study_info['ebi_study_accession'].split(',')]) self.render('study_ajax/base_info.html', study_info=study_info, publications=study_doi, pi=pi, contact=contact, editable=res['editable'], share_access=share_access, ebi_info=ebi_info)
def get(self, study_id): study = to_int(study_id) study_info = study_get_req(study, self.current_user.id) if study_info['status'] != 'success': raise HTTPError(404, study_info['message']) self.render("study_base.html", **study_info)
def get(self, study_id): study = to_int(study_id) level = self.get_argument('level', '') message = self.get_argument('message', '') study_info = study_get_req(study, self.current_user.id) if study_info['status'] != 'success': raise HTTPError(404, study_info['message']) if message != '' and level != '': study_info['level'] = level study_info['message'] = message self.render("study_base.html", **study_info)
def get(self): study_id = self.get_argument('study_id') study = to_int(study_id) res = study_get_req(study, self.current_user.id) study_info = res['study_info'] study_doi = ' '.join( [doi_linkifier(p) for p in study_info['publications']]) email = '<a href="mailto:{email}">{name} ({affiliation})</a>' pi = email.format(**study_info['principal_investigator']) if study_info['lab_person']: contact = email.format(**study_info['lab_person']) else: contact = None self.render('study_ajax/base_info.html', study_info=study_info, publications=study_doi, pi=pi, contact=contact, editable=res['editable'])
def get(self, study_id): study_id = int(study_id) # Check access to study study_info = study_get_req(study_id, self.current_user.id) if study_info['status'] != 'success': raise HTTPError( 405, "%s: %s, %s" % (study_info['message'], self.current_user.email, str(study_id))) study = Study(study_id) basedir = get_db_files_base_dir() basedir_len = len(basedir) + 1 # loop over artifacts and retrieve those that we have access to to_download = [] for a in study.artifacts(): if a.artifact_type == 'BIOM': for i, (fid, path, data_type) in enumerate(a.filepaths): # ignore if tgz as they could create problems and the # raw data is in the folder if data_type == 'tgz': continue if data_type == 'directory': # If we have a directory, we actually need to list # all the files from the directory so NGINX can # actually download all of them for dp, _, fps in walk(path): for fname in fps: fullpath = join(dp, fname) spath = fullpath if fullpath.startswith(basedir): spath = fullpath[basedir_len:] to_download.append((fullpath, spath, spath)) elif path.startswith(basedir): spath = path[basedir_len:] to_download.append((path, spath, spath)) else: # We are not aware of any case that can trigger this # situation, but we wanted to be overly cautious # There is no test for this line cause we don't know # how to trigger it to_download.append((path, path, path)) for pt in a.prep_templates: qmf = pt.qiime_map_fp if qmf is not None: sqmf = qmf if qmf.startswith(basedir): sqmf = qmf[basedir_len:] to_download.append( (qmf, sqmf, 'mapping_files/%s_mapping_file.txt' % a.id)) # If we don't have nginx, write a file that indicates this all_files = '\n'.join([ "- %s /protected/%s %s" % (getsize(fp), sfp, n) for fp, sfp, n in to_download ]) self.write("%s\n" % all_files) zip_fn = 'study_%d_%s.zip' % (study_id, datetime.now().strftime('%m%d%y-%H%M%S')) self.set_header('Content-Description', 'File Transfer') self.set_header('Expires', '0') self.set_header('Cache-Control', 'no-cache') self.set_header('X-Archive-Files', 'zip') self.set_header('Content-Disposition', 'attachment; filename=%s' % zip_fn) self.finish()