Skip to content
Snippets Groups Projects
ProteinDetailPage.vue 14.3 KiB
Newer Older
<template>
    <div class="d-flex" id="wrapper">

        <!-- Sidebar -->
        <!--<div class="bg-light border-right" id="sidebar-wrapper">-->
            <!--&lt;!&ndash;<div class="sidebar-heading">Menu </div>&ndash;&gt;-->
            <!--<div class="list-group list-group-flush">-->
                <!--<a href="#" class="list-group-item list-group-item-action bg-light">Search</a>-->
                <!--<a href="#" class="list-group-item list-group-item-action bg-light">Columns</a>-->
                <!--<a href="#" class="list-group-item list-group-item-action bg-light">Filters</a>-->
                <!--<a href="#" class="list-group-item list-group-item-action bg-light">Download</a>-->
                <!--<a href="#" class="list-group-item list-group-item-action bg-light">Contacts</a>-->
            <!--</div>-->
        <!--</div>-->
        <!-- /#sidebar-wrapper -->

        <div id="page-content-wrapper" class="main">
            <fetch-protein :protein="protein">
                <template slot-scope="{response, loading}">
                    <slot :response="response" :loading="loading">
                        <div v-if="loading">Loading...</div>
                        <div v-else-if="response !== null">
                          <h2>{{ response.data.gene_name }}</h2>
                            <h4 class="round">General Information</h4>
                            <div class="panel panel-default">
                                <div class="panel-body">
                                    <div class="container-fluid col-md-12">
                                        <div class="row">
                                            <div class="text col-sm-3">Name</div>
                                            <div class="col-sm-9">
                                              <b>Protein {{response.data.name}}</b>
                                            </div>
                                        </div>
                                        <div class="row">
                                            <div class="text col-sm-3">Species</div>
                                            <div class="col-sm-9">
                                                {{response.data.species_name + ' (' + response.data.species_tax_id + ')'}}
                                            </div>
                                        </div>
                                        <div class="row">
                                            <div class="text col-sm-3">Ensembl ID</div>
                                            <div class="col-sm-9">
                                              <div v-if="response.data.ensembl_id">
                                                <a :href="'https://www.ensembl.org/id/' + response.data.ensembl_id" class="uniprot-link" target="_blank">
                                                {{response.data.ensembl_id}}
                                                <i class="glyphicon glyphicon-link"></i></a>
                                            </div>
                                        </div>
                                        <div class="row">
                                            <div class="text col-sm-3">Ensembl Gene ID</div>
                                            <div class="col-sm-9">
                                              <div v-if="response.data.ensembl_gene_id">
                                                <a :href="'https://www.ensembl.org/id/' + response.data.ensembl_gene_id" class="uniprot-link" target="_blank">
                                                {{response.data.ensembl_gene_id}}
                                                <i class="glyphicon glyphicon-link"></i></a>
                                            </div>
                                        </div>
                                        <div class="row">
                                            <div class="text col-sm-3">UniProt</div>
                                            <div class="col-sm-9">
                                              <div v-if="response.data.uniprot_id">
                                                <a :href="'https://www.uniprot.org/uniprot/' + response.data.uniprot_id" class="uniprot-link" target="_blank">
                                                {{response.data.uniprot_id + ' (' + response.data.uniprot_readable_id + ')'}}
                                                <i class="glyphicon glyphicon-link"></i></a>
                                            </div>
                                        </div>
                                        <div class="row">
HongKee Moon's avatar
HongKee Moon committed
                                          <div class="text col-sm-3">Antibodies</div>
                                          <div class="col-sm-9">
                                            <div v-if="response.data.uniprot_id">
                                              <a :href="response.data.antibody_link" class="uniprot-link" target="_blank">
                                                {{response.data.uniprot_id}}
                                                <i class="glyphicon glyphicon-link"></i></a>
                                            </div>
                                          </div>
                                        </div>
                                        <div class="row">
                                          <div class="text col-sm-3">Function</div>
                                          <div class="col-sm-9">
                                            {{response.data.function}}
                                          </div>
                                        </div>
HongKee Moon's avatar
HongKee Moon committed
                                        <div class="row">
HongKee Moon's avatar
HongKee Moon committed
                                          <div class="text col-sm-3">Primary Datasource</div>
HongKee Moon's avatar
HongKee Moon committed
                                          <div class="col-sm-9">
                                            {{dbNames[response.data.primary_data_source]}}
HongKee Moon's avatar
HongKee Moon committed
                                          </div>
                                        </div>
HongKee Moon's avatar
HongKee Moon committed
                                        <div class="row">
                                          <div class="text col-sm-3">Evidence Stars</div>
                                          <div class="col-sm-9">
                                            <span v-for="(item, index) in getRating(response.data.condensates)" :class="item" v-bind:key="index"/>
                                          </div>
                                        </div>
                                        <div class="row">
                                          <div class="text col-sm-3">Sequence</div>
                                          <div class="col-sm-9">
                                            <input type="text" :value="response.data.sequence">
                                            <button class="copy-button" :name="'sequence'" :id="'sequence'" :data-clipboard-text="response.data.sequence"><i class="glyphicon glyphicon-copy"></i> </button>
                                          </div>
                                        </div>
                                      </div>
                            <div v-if="response.data.iupred_score !== null">
HongKee Moon's avatar
HongKee Moon committed
                            <iu-pred2-chart :x="response.data.sequence" :score="response.data.iupred_score"></iu-pred2-chart>
HongKee Moon's avatar
HongKee Moon committed
                            <barcode-plot :x="response.data.sequence"></barcode-plot>
HongKee Moon's avatar
HongKee Moon committed
                            <div v-show="response.data.llps_ptms !== null && response.data.llps_ptms.length > 0">
                              <h4 class="round">PTMs affecting condensate formation</h4>
HongKee Moon's avatar
HongKee Moon committed
                              <div class="panel panel-default">
                                  <table class="csi table table-hover table-responsive">
                                      <thead>
                                      <tr class="active">
                                          <th>Name</th>
                                          <th>Type</th>
                                          <th>Enzyme</th>
HongKee Moon's avatar
HongKee Moon committed
                                          <th>Position</th>
HongKee Moon's avatar
HongKee Moon committed
                                          <th>Description</th>
                                      </tr>
                                      </thead>
                                      <tbody>
                                      <tr v-for="(item, index) in response.data.llps_ptms" v-bind:key="index">
                                          <td>{{item.name}}</td>
                                          <td>{{item.effect_type}}</td>
                                          <td class="text-nowrap">{{item.enzyme}}</td>
HongKee Moon's avatar
HongKee Moon committed
                                          <td>{{item.position}}</td>
HongKee Moon's avatar
HongKee Moon committed
                                          <td>{{item.effect_description}}</td>
                                      </tr>
                                      </tbody>
                                  </table>
                              </div>
                            </div>

                            <div v-show="response.data.condensates !== null && response.data.condensates.length > 0">
                              <h4 class="round">Condensates</h4>
                              <div class="panel panel-default">
                                <table class="csi table table-hover table-responsive">
HongKee Moon's avatar
HongKee Moon committed
                                  <thead>
                                  <tr class="active">
                                    <th>Name</th>
                                    <th>Data Sources</th>
                                    <th>No. of Proteins</th>
                                    <th>Evidence Stars</th>
HongKee Moon's avatar
HongKee Moon committed
                                    <th>Species</th>
                                  </tr>
                                  </thead>
                                  <tbody>
                                  <tr v-for="(item, index) in response.data.condensates" v-bind:key="index">
                                    <td>
                                      <a :href="'/condensate/' + item.unique_name" class="uniprot-link" target="_blank">{{item.name}}</a>
                                    </td>
                                    <td>{{getDbNames(item.data_sources)}}</td>
HongKee Moon's avatar
HongKee Moon committed
                                    <td>{{item.proteins.length}}</td>
                                    <td>
                                      <span v-for="(item, index) in getSingleRating(item.data_sources)" :class="item" v-bind:key="index"/>
                                    </td>
HongKee Moon's avatar
HongKee Moon committed
                                    <td>{{item.species_name}}</td>
                                  </tr>
                                  </tbody>
                                </table>
HongKee Moon's avatar
HongKee Moon committed
                              </div>
HongKee Moon's avatar
HongKee Moon committed

                        </div>
                    </slot>
                </template>
            </fetch-protein>
        </div>
    </div>
    <!-- /#wrapper -->
</template>

<script>
  import fetchProtein from '@/components/DDCODE/fetchProtein.vue'
HongKee Moon's avatar
HongKee Moon committed
  import IuPred2Chart from "@/components/IUPred2Chart";
HongKee Moon's avatar
HongKee Moon committed
  import BarcodePlot from "@/components/BarcodePlot";
  const _ = require('lodash')
  require('./js/clipboard')

  export default {
    name: 'LandingPage',
    components: {
HongKee Moon's avatar
HongKee Moon committed
      fetchProtein, IuPred2Chart, BarcodePlot
    },
    props: ['proteinId'],
    data() {
      return {
        protein: this.$route.params.protein,
        dbNames: require('./js/const').db
      }
    },
    computed: {
    },
    methods: {
      getDbNames(names) {
        return _.map(names, i => this.dbNames[i]).join(', ')
      },
HongKee Moon's avatar
HongKee Moon committed
      getRating(data) {
        const scoreMap = {'hungarian': 5, 'blue': 5, 'pink': 1, 'grey': 1}
        let r = []
        _.each(data, c => {
          r.push(_.max(_.map(c.data_sources, i => scoreMap[i])));
        })

        const rating = _.max(r);
        r = []
        for (let i = 0; i < 5; i++) {
          if (i < rating) {
            r.push('fa fa-star checked')
          } else {
            r.push('fa fa-star')
          }
        }
        return r;
      },
      getSingleRating(data) {
        const scoreMap = {'hungarian': 5, 'blue': 5, 'pink': 1, 'grey': 1}

        const rating = _.max(_.map(data, i => scoreMap[i]));
        let r = []
        for (let i = 0; i < 5; i++) {
          if (i < rating) {
            r.push('fa fa-star checked')
          } else {
            r.push('fa fa-star')
          }
        }
        return r;
HongKee Moon's avatar
HongKee Moon committed
      }
  }
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style>
    @import url('~@/assets/bootstrap.css');
    @import url('~@/assets/datatable.css');
    @import url('~@/assets/tooltip.css');

    .main {
        /*margin-left: 200px;*/
        margin-left: 20px;
    }

    h3 {
        margin: 40px 0 0;
    }

    a {
        color: #42b983;
    }

    #wrapper {
        overflow-x: hidden;
    }

    #sidebar-wrapper {
        min-height: 100vh;
        margin-left: -15rem;
        -webkit-transition: margin .25s ease-out;
        -moz-transition: margin .25s ease-out;
        -o-transition: margin .25s ease-out;
        transition: margin .25s ease-out;

        position: absolute;
        z-index: 1; /* Stay on top */
        left: 0;
    }

    #sidebar-wrapper .sidebar-heading {
        padding: 0.875rem 1.25rem;
        font-size: 1.2rem;
    }

    #sidebar-wrapper .list-group {
        position: -webkit-sticky;
        position: sticky;
        top: 0;
        width: 15rem;
    }

    #page-content-wrapper {
        min-width: 100vw;
    }

    #wrapper.toggled #sidebar-wrapper {
        margin-left: 0;
    }

    @media (min-width: 768px) {
        #sidebar-wrapper {
            margin-left: 0;
        }

        #page-content-wrapper {
            min-width: 0;
            width: 100%;
        }

        #wrapper.toggled #sidebar-wrapper {
            margin-left: -15rem;
        }
    }

    .uniprot-link {
        font-weight: bold;
        color: #0065b9;
    }

HongKee Moon's avatar
HongKee Moon committed
    .checked {
      color: orange;
    }

    .d-flex {
        display: -ms-flexbox !important;
        display: flex !important;
    }

    .panel {
        font-size: 1.2rem;
    }
</style>