Example #1
0
File: views.py Project: gpcr/scout
def open_research(institute_id, case_id):
  """Open the research list for a case."""
  institute = validate_user(current_user, institute_id)
  case_model = store.case(institute_id, case_id)

  # send email to trigger manual load of research variants
  main_recipient = current_app.config['RESEARCH_MODE_RECIPIENT']

  # this should send a JSON document to the SuSy API in the future
  html = """
    <p>{institute}: {case} ({case_id})</p>
    <p>Requested by: {name}</p>
  """.format(institute=institute.display_name, case=case_model.display_name,
             case_id=case_model.id, name=current_user.name)

  # compose and send the email message
  msg = Message(subject=("SCOUT: open research mode for {}"
                         .format(case_model.display_name)),
                html=html,
                sender=current_app.config['MAIL_USERNAME'],
                recipients=[main_recipient],
                # cc the sender of the email for confirmation
                cc=[current_user.email])
  mail.send(msg)

  link = url_for('.case', institute_id=institute_id, case_id=case_id)
  store.open_research(institute, case_model, current_user, link)

  return redirect(url_for('.case', institute_id=institute_id, case_id=case_id))
Example #2
0
def open_research(institute_id, case_id):
    """Open the research list for a case."""
    institute = validate_user(current_user, institute_id)
    case_model = store.case(institute_id, case_id)

    # send email to trigger manual load of research variants
    main_recipient = current_app.config['RESEARCH_MODE_RECIPIENT']

    # this should send a JSON document to the SuSy API in the future
    html = """
    <p>{institute}: {case} ({case_id})</p>
    <p>Requested by: {name}</p>
  """.format(institute=institute.display_name,
             case=case_model.display_name,
             case_id=case_model.id,
             name=current_user.name)

    # compose and send the email message
    msg = Message(
        subject=("SCOUT: open research mode for {}".format(
            case_model.display_name)),
        html=html,
        sender=current_app.config['MAIL_USERNAME'],
        recipients=[main_recipient],
        # cc the sender of the email for confirmation
        cc=[current_user.email])
    mail.send(msg)

    link = url_for('.case', institute_id=institute_id, case_id=case_id)
    store.open_research(institute, case_model, current_user, link)

    return redirect(
        url_for('.case', institute_id=institute_id, case_id=case_id))
Example #3
0
File: views.py Project: gpcr/scout
def email_sanger(institute_id, case_id, variant_id):
  # very basic security check
  institute = validate_user(current_user, institute_id)
  case_model = store.case(institute_id, case_id)
  variant_model = store.variant(document_id=variant_id)

  recipients = institute.sanger_recipients
  if len(recipients) == 0:
    flash('No sanger recipients added to the institute.')
    return abort(403)

  # build variant page URL
  variant_url = url_for('.variant', institute_id=institute_id,
                        case_id=case_id, variant_id=variant_id)

  hgnc_symbol = ', '.join(variant_model.hgnc_symbols)
  functions = ["<li>{}</li>".format(function) for function in
               variant_model.protein_changes]
  gtcalls = ["<li>{}: {}</li>".format(individual.display_name,
                                      individual.genotype_call)
             for individual in variant_model.samples]

  html = """
    <p>Case {case_id}: <a href='{url}'>{variant_id}</a></p>
    <p>HGNC symbol: {hgnc_symbol}</p>
    <p>Database: {database_id}</p>
    <p>Chr position: {chromosome_position}</p>
    <p>Amino acid change(s): <br> <ul>{functions}</ul></p><br>
    <p>GT-call: <br> <ul>{gtcalls}</ul></p><br>
    <p>Ordered by: {name}</p>
  """.format(
    case_id=case_id,
    url=variant_url,
    variant_id=variant_id,
    hgnc_symbol=hgnc_symbol,
    database_id='coming soon',
    chromosome_position=variant_model.display_name,
    functions=''.join(functions),
    gtcalls=''.join(gtcalls),
    name=current_user.name
  )

  kwargs = dict(
    subject="SCOUT: Sanger sequencing of %s" % hgnc_symbol,
    html=html,
    sender=current_app.config['MAIL_USERNAME'],
    recipients=recipients,
    # cc the sender of the email for confirmation
    cc=[current_user.email]
  )

  # compose and send the email message
  msg = Message(**kwargs)
  mail.send(msg)

  link = url_for('.case', institute_id=institute_id, case_id=case_id)
  store.order_sanger(institute, case_model, current_user, link, variant_model)

  return redirect(variant_url)
Example #4
0
def email_sanger(institute_id, case_id, variant_id):
    # very basic security check
    institute = validate_user(current_user, institute_id)
    case_model = store.case(institute_id, case_id)
    variant_model = store.variant(document_id=variant_id)

    recipients = institute.sanger_recipients
    if len(recipients) == 0:
        flash('No sanger recipients added to the institute.')
        return abort(403)

    # build variant page URL
    variant_url = url_for('.variant',
                          institute_id=institute_id,
                          case_id=case_id,
                          variant_id=variant_id)

    hgnc_symbol = ', '.join(variant_model.hgnc_symbols)
    functions = [
        "<li>{}</li>".format(function)
        for function in variant_model.protein_changes
    ]
    gtcalls = [
        "<li>{}: {}</li>".format(individual.display_name,
                                 individual.genotype_call)
        for individual in variant_model.samples
    ]

    html = """
    <p>Case {case_id}: <a href='{url}'>{variant_id}</a></p>
    <p>HGNC symbol: {hgnc_symbol}</p>
    <p>Database: {database_id}</p>
    <p>Chr position: {chromosome_position}</p>
    <p>Amino acid change(s): <br> <ul>{functions}</ul></p><br>
    <p>GT-call: <br> <ul>{gtcalls}</ul></p><br>
    <p>Ordered by: {name}</p>
  """.format(case_id=case_id,
             url=variant_url,
             variant_id=variant_id,
             hgnc_symbol=hgnc_symbol,
             database_id='coming soon',
             chromosome_position=variant_model.display_name,
             functions=''.join(functions),
             gtcalls=''.join(gtcalls),
             name=current_user.name)

    kwargs = dict(
        subject="SCOUT: Sanger sequencing of %s" % hgnc_symbol,
        html=html,
        sender=current_app.config['MAIL_USERNAME'],
        recipients=recipients,
        # cc the sender of the email for confirmation
        cc=[current_user.email])

    # compose and send the email message
    msg = Message(**kwargs)
    mail.send(msg)

    link = url_for('.case', institute_id=institute_id, case_id=case_id)
    store.order_sanger(institute, case_model, current_user, link,
                       variant_model)

    return redirect(variant_url)