コード例 #1
0
ファイル: views.py プロジェクト: yassineS/scout
def variant(institute_id, case_id, variant_id):
    """View a single variant in a single case."""
    institute = validate_user(current_user, institute_id)
    case_model = store.case(institute_id, case_id)
    variant_model = store.variant(document_id=variant_id)

    comments = store.events(institute, case=case_model, variant_id=variant_model.variant_id, comments=True)
    events = store.events(institute, case=case_model, variant_id=variant_model.variant_id)

    individuals = {individual.individual_id: individual for individual in case_model.individuals}

    prev_variant = store.previous_variant(document_id=variant_id)
    next_variant = store.next_variant(document_id=variant_id)
    return dict(
        institute=institute,
        institute_id=institute_id,
        case=case_model,
        case_id=case_id,
        variant=variant_model,
        variant_id=variant_id,
        comments=comments,
        events=events,
        prev_variant=prev_variant,
        next_variant=next_variant,
        manual_rank_options=Variant.manual_rank.choices,
        individuals=individuals,
    )
コード例 #2
0
ファイル: views.py プロジェクト: BadSeby/scout
def variant(institute_id, case_id, variant_id):
    """View a single variant in a single case."""
    institute = validate_user(current_user, institute_id)
    case_model = store.case(institute_id, case_id)
    variant_model = store.variant(document_id=variant_id)

    comments = store.events(institute,
                            case=case_model,
                            variant_id=variant_model.variant_id,
                            comments=True)
    events = store.events(institute,
                          case=case_model,
                          variant_id=variant_model.variant_id)

    prev_variant = store.previous_variant(document_id=variant_id)
    next_variant = store.next_variant(document_id=variant_id)

    return dict(institute=institute,
                institute_id=institute_id,
                case=case_model,
                case_id=case_id,
                variant=variant_model,
                variant_id=variant_id,
                comments=comments,
                events=events,
                prev_variant=prev_variant,
                next_variant=next_variant,
                manual_rank_options=Variant.manual_rank.choices)
コード例 #3
0
ファイル: views.py プロジェクト: 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)
コード例 #4
0
ファイル: views.py プロジェクト: yassineS/scout
def unpin_variant(institute_id, case_id, variant_id):
    """Pin or unpin a variant from the list of suspects."""
    institute = validate_user(current_user, institute_id)
    case_model = store.case(institute_id, case_id)
    variant_model = store.variant(document_id=variant_id)
    link = url_for(".variant", institute_id=institute_id, case_id=case_id, variant_id=variant_id)
    store.unpin_variant(institute, case_model, current_user, link, variant_model)
    return redirect(request.args.get("next") or request.referrer or link)
コード例 #5
0
ファイル: views.py プロジェクト: yassineS/scout
def mark_causative(institute_id, case_id, variant_id):
    """Mark a variant as confirmed causative."""
    institute = validate_user(current_user, institute_id)
    case_model = store.case(institute_id, case_id)
    variant_model = store.variant(document_id=variant_id)
    link = url_for(".variant", institute_id=institute_id, case_id=case_id, variant_id=variant_id)
    case_url = url_for(".case", institute_id=institute_id, case_id=case_id)

    store.mark_causative(institute, case_model, current_user, link, variant_model)

    # send the user back to the case the was marked as solved
    return redirect(case_url)
コード例 #6
0
ファイル: views.py プロジェクト: BadSeby/scout
def unpin_variant(institute_id, case_id, variant_id):
    """Pin or unpin a variant from the list of suspects."""
    institute = validate_user(current_user, institute_id)
    case_model = store.case(institute_id, case_id)
    variant_model = store.variant(document_id=variant_id)
    link = url_for('.variant',
                   institute_id=institute_id,
                   case_id=case_id,
                   variant_id=variant_id)
    store.unpin_variant(institute, case_model, current_user, link,
                        variant_model)
    return redirect(request.args.get('next') or request.referrer or link)
コード例 #7
0
ファイル: views.py プロジェクト: yassineS/scout
def unmark_causative(institute_id, case_id, variant_id):
    """Remove a variant as confirmed causative for a case."""
    # very basic security check
    institute = validate_user(current_user, institute_id)
    case_model = store.case(institute_id, case_id)
    case_url = url_for(".case", institute_id=institute_id, case_id=case_id)

    # skip the host part of the URL to make it more flexible
    link = request.referrer.replace(request.host_url, "/")
    variant_model = store.variant(document_id=variant_id)
    store.unmark_causative(institute, case_model, current_user, link, variant_model)

    # send the user back to the case the was marked as solved
    return redirect(request.referrer or case_url)
コード例 #8
0
ファイル: views.py プロジェクト: BadSeby/scout
def mark_causative(institute_id, case_id, variant_id):
    """Mark a variant as confirmed causative."""
    institute = validate_user(current_user, institute_id)
    case_model = store.case(institute_id, case_id)
    variant_model = store.variant(document_id=variant_id)
    link = url_for('.variant',
                   institute_id=institute_id,
                   case_id=case_id,
                   variant_id=variant_id)
    case_url = url_for('.case', institute_id=institute_id, case_id=case_id)

    store.mark_causative(institute, case_model, current_user, link,
                         variant_model)

    # send the user back to the case the was marked as solved
    return redirect(case_url)
コード例 #9
0
ファイル: views.py プロジェクト: BadSeby/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)