Newer
Older
<div>

raghosh
committed
<div class="inline-block bg-red-500 no-underline font-bold mb-4" />
<table
:id="id"
class="table table-striped table-bordered table-hover"
width="100%"
<the-action-modal
v-if="toggleActionModal"
:protein-uniprot="uniprotId"
:show="toggleActionModal"
:pubmed="pubmed"
:canonical-id="canonicaliD"
:protein-evidence-score="proteinConfidenceScore"

raghosh
committed
:protein-functional-type="proteinFunctionalTypeData"
:protein-experimental-evidence="proteinExperimentalEvidenceData"
:protein-driver-criterion="proteinDriverCriterionData"
@close="closeModal"
/>
<the-delete-modal
v-if="toggleDeleteModal"
:show="toggleDeleteModal"
:canonical-id="canonicalId"
:uniprot-id="uniprotId"
@cancel="closeDeleteModal"
/>
</div>
import TheActionModal from './UI/TheActionModal.vue';
import TheDeleteModal from './UI/TheDeleteModal.vue';
const _ = require('lodash');
const $ = (window.jQuery = require('jquery'));
require('./js/clipboard');
require('@/components/js/datatable');
let table;
const scoreMap = {
'http://llps.biocuckoo.cn/': 1,
'http://db.phasep.pro/browse/highthroughput/': 2,
'http://db.phasep.pro/browse/reviewed/': 4,
'http://db.phasep.pro/browse/uniprotreviewed/': 4,
'http://bio-comp.org.cn/llpsdb/': 4,
'https://phasepro.elte.hu/': 4,
'https://pubmed.ncbi.nlm.nih.gov/': 4,
'https://ddcode.org/': 5,
};
function getStartWith(url) {
_.forEach(_.keys(scoreMap), (i) => {
if (url.startsWith(i)) {
ret = i;
}
});
return ret;
}
function getRating(data) {
const r = ['<div style="white-space: nowrap;">'];
for (let i = 0; i < 5; i++) {
if (i < rating) {
if (rating - i === 0.5) {
r.push('<span class="fa fa-star-half-o checked"/>');
} else {
r.push('<span class="fa fa-star checked"/>');
}
} else {
r.push('<span class="fa fa-star"/>');
return r;
}
export default {
props: [
'id',
'data',
'map',
'pubmed',
'dbTags',
'isExperimental',
'canonicalId',
'proteinDriverCriterion',
'proteinExperimentalEvidence',
'proteinFunctionalType',
],
data() {
return {
toggleActionModal: false,
toggleDeleteModal: false,
proteinConfidenceScore: 0,
proteinFunctionalTypeData: '',
proteinExperimentalEvidenceData: '',
proteinDriverCriterionData: '',
};
},
mounted() {
const vm = this;
vm.createTable(vm.id, vm.data);
},
methods: {
closeModal() {
this.toggleActionModal = false;
},
closeDeleteModal() {
this.toggleDeleteModal = false;
},
fetchProtein(uniprot_id) {
const vm = this;
// eslint-disable-next-line
const url = `/protein/${uniprot_id}`;
// // eslint-disable-next-line
// console.log(url)
// this.$router.push(url)
// window.open(url);
vm.$router.push(url)
},
forwardUniprot(uniprot_id) {
const vm = this;
// eslint-disable-next-line
const url = `https://www.uniprot.org/uniprot/${uniprot_id}`;
// // eslint-disable-next-line
// console.log(url)
// window.open(url);
vm.$router.push(url)
},
createLink(link) {
return `<a href="${link}" class="external-link tooltipped tooltipped-n tooltipped-multiline"
aria-label="Clicking this link opens Evidence page." target="_blank"> ${link}
</a>`;
},
createPubMedLink(item) {
return `<a id="${item}" href="https://pubmed.ncbi.nlm.nih.gov/${item}" class="pubmed-link tooltipped tooltipped-n tooltipped-multiline"
target="_blank">
${item}
<i class="glyphicon glyphicon-link"></i>
</a>`;
},
fetchPubMedId(item) {
// console.log(item)
if (item) {
const url =
'https://eutils.ncbi.nlm.nih.gov/entrez/eutils/esummary.fcgi?db=pubmed&retmode=json&id=';
const request = url + item;
fetch(request)
.then((response) => response.json())
.then((response) => {
setTimeout(() => {
const res = response.result[item];
$(`a[id="${item}"]`).each(function () {
$(this).attr(
`${res.title}\n\n${_.map(res.authors, (a) => a.name).join(
)}`
);

moon
committed
});
}, 0);
});
}
},
createTable(id, data) {
const vm = this;
_.forEach(data, (d) => {
d.DT_RowID = `${d.n}`;
});
const columns = vm.isExperimental
? [
{
title: 'UniProt',
data: 'uniprot_id',
className: 'text-nowrap',
fnCreatedCell: (nTd, sData, oData) => {
$(nTd).html(`<a href="" class="protein-link"> ${sData} </a>`);
},
fnCreatedCell: (nTd, sData, oData) => {
if (sData) {
$(nTd).html(`<a href="" class="protein-link"> ${sData}</a>`);
} else {
$(nTd).html(`<a href="" class="protein-link"> N/A</a>`);
}
},
fnCreatedCell: (nTd, sData, oData) => {
if (sData) {
$(nTd).html(`<a href="" class="protein-link"> ${sData}</a>`);
} else {
$(nTd).html(
`<a href="" class="protein-link"> ${oData.uniprot_id}</a>`
);
},
},
// {
// title: 'Name',
// data: 'name',
// fnCreatedCell: (nTd, sData, oData) => {
// if (sData) {
// $(nTd).html(`<a href="" class="protein-link"> ${sData}</a>`);
// } else {
// $(nTd).html(
// `<a href="" class="protein-link"> ${oData.uniprot_id}</a>`
// );
// }
// },
// },
// {
// title: 'Species',
// data: 'species_name',
// className: "text-nowrap"
// },
// {
// title: 'Evidences',
// data: 'species_name',
// className: "text-nowrap",
// fnCreatedCell: (nTd, sData, oData) => {
// // console.log(sData)
// let data = vm.map[oData.uniprot_id];
// if(data) {
// // $(nTd).html(data.filter(a => a.startsWith('http')).join('\n'));
// $(nTd).html(data.map(i => vm.createLink(i)).join('<br/>'));
// } else {
// $(nTd).html('')
// }
// }
// },
{
title: 'Pubmed',
data: 'uniprot_id',
className: 'text-nowrap',
render: function (data, type, row, meta) {
if (vm.pubmed) {
let dat = vm.pubmed[row.uniprot_id];
if (dat) {
} else {
}

HongKee Moon
committed
} else {

HongKee Moon
committed
}
},
fnCreatedCell: (nTd, sData, oData) => {
// console.log(sData)
if (vm.pubmed) {
let data = vm.pubmed[oData.uniprot_id];
if (data) {
// $(nTd).html(data.filter(a => a.startsWith('http')).join('\n'));
// $(nTd).html(data.map(i => vm.createLink(i)).join('<br/>'));
$(nTd).html(
);
} else {
}
} else {
}
},
},

raghosh
committed
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
// {
// title: 'Functional Type',
// data: 'protein_functional_type',
// className: 'whitespace-normal',
// defaultContent: '<i>No data</i>',
// render: function (data, type, row, meta) {
// // console.log(_.flatMap(row.condensates, c => c.data_sources))
// if(!vm.proteinFunctionalType){
// return;
// }
// let dat = vm.proteinFunctionalType[row.uniprot_id];
// if (dat) {
// return dat;
// } else{
// return '';
// }
// },
// },
// {
// title: 'Experimental Evidence',
// data: 'protein_exp_evidence',
// className: 'whitespace-normal',
// defaultContent: '<i>No data</i>',
// render: function (data, type, row, meta) {
// // console.log(_.flatMap(row.condensates, c => c.data_sources))
// if(!vm.proteinExperimentalEvidence){
// return;
// }
// let dat = vm.proteinExperimentalEvidence[row.uniprot_id];
// if (dat) {
// return dat.join(', ');
// }
// return '';
// },
// },
// {
// title: 'Driver Criterion',
// data: 'driver_criterion',
// className: 'whitespace-normal',
// defaultContent: '<i>No data</i>',
// render: function (data, type, row, meta) {
// // console.log(_.flatMap(row.condensates, c => c.data_sources))
// if(!vm.proteinDriverCriterion){
// return
// }
// let dat = vm.proteinDriverCriterion[row.uniprot_id];
// if (dat) {
// return dat.join(', ');
// }
// return '';
// },
// },
render: function (data, type, row, meta) {
// console.log(_.flatMap(row.condensates, c => c.data_sources))
let dat = vm.dbTags[row.uniprot_id];
if (dat) {
},
},
// {
// title: 'Evidence',
// data: 'uniprot_id',
// className: "text-nowrap",
// fnCreatedCell: (nTd, sData, oData) => {
// $(nTd).html(`${vm.map[oData.uniprot_id]}`);
// },
// },
// {
// title: 'Sequence',
// data: 'sequence',
// className: "text-nowrap",
// fnCreatedCell: (nTd, sData, oData) => {
// $(nTd).html(`<input type="text" value="${sData}">
// <button class="copy-button" name="${oData.uniprot_id}" id="${oData.uniprot_id}" data-clipboard-text="${sData}"><i class="glyphicon glyphicon-copy"></i> </button>`);
// },
// }
{
render: function (data, type, row, meta) {
// console.log(_.flatMap(row.condensates, c => c.data_sources))
let dat = vm.map[row.uniprot_id];
if (dat) {
},
fnCreatedCell: (nTd, sData, oData) => {
// console.log(sData)

raghosh
committed
let data = vm.map[oData.uniprot_id];
if (data) {
}
},
},

raghosh
committed
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
// {
// title: 'Action',
// data: 'uniprot_id',
// className: 'text-nowrap',
// fnCreatedCell: (nTd, sData, oData) => {
// $(nTd).html(
// `<button class="btn btn-primary edit-link btn-outline font-bold" style="font-weight:bold">
// <i class="fa fa-edit" style="font-weight:bold"></i>
// </button>
// <button class="btn btn-danger delete-link btn-outline font-bold" style="font-weight:bold">
// <i class="fa fa-trash" style="font-weight:bold"></i>
// </button>
// `
// );
// },
// // render: function (data, type, row, meta) {
// // if (this.$store.getters["User/userRole"] === "Maintainer") {
// // $(nTd).html(
// // `<button class="btn btn-primary btn-outline font-bold" style="font-weight:bold">Edit
// // <i class="fa ml-2 fa-edit" style="font-weight:bold"></i>
// // </button>`
// // );
// // } else {
// // return "";
// // }
// // },
// },
{
title: 'UniProt',
data: 'uniprot_id',
className: 'whitespace-normal',
fnCreatedCell: (nTd, sData, oData) => {
$(nTd).html(`<a href="" class="protein-link"> ${sData} </a>`);
},
title: 'Gene Name',
data: 'gene_name',
className: 'whitespace-normal',
fnCreatedCell: (nTd, sData, oData) => {
if (sData) {
$(nTd).html(`<a href="" class="protein-link"> ${sData}</a>`);
} else {
$(nTd).html(`<a href="" class="protein-link"> N/A</a>`);
title: 'Name',
data: 'name',
className: 'whitespace-normal break-all',
fnCreatedCell: (nTd, sData, oData) => {
if (sData) {
$(nTd).html(`<a href="" class="protein-link"> ${sData}</a>`);
} else {
$(nTd).html(
`<a href="" class="protein-link"> ${oData.uniprot_id}</a>`
);
// {
// title: 'Evidences',
// data: 'uniprot_id',
// className: "text-nowrap",
// fnCreatedCell: (nTd, sData, oData) => {
// // console.log(sData)
// let data = vm.map[oData.uniprot_id];
//
// if(data) {
// // $(nTd).html(data.filter(a => a.startsWith('http')).join('\n'));
// $(nTd).html(data.map(i => vm.createLink(i)).join('<br/>'));
// } else {
// $(nTd).html('')
// }
// }
// },
title: 'Pubmed',
data: 'uniprot_id',
className: 'whitespace-normal',
render: function (data, type, row, meta) {
if (vm.pubmed) {
let dat = vm.pubmed[row.uniprot_id];
if (dat) {
} else {
}
} else {
}
},
fnCreatedCell: (nTd, sData, oData) => {
// console.log(sData)
if (vm.pubmed) {
if (data) {
// $(nTd).html(data.filter(a => a.startsWith('http')).join('\n'));
// $(nTd).html(data.map(i => vm.createLink(i)).join('<br/>'));
$(nTd).html(
);
},
title: 'Functional Type',
data: 'protein_functional_type',
className: 'whitespace-nowrap',
defaultContent: '<i>No data</i>',

raghosh
committed
render: function (data, type, row, meta) {
// console.log(_.flatMap(row.condensates, c => c.data_sources))

raghosh
committed
if (!vm.proteinFunctionalType) {

raghosh
committed
return;
}
let dat = vm.proteinFunctionalType[row.uniprot_id];
if (dat) {
return dat;

raghosh
committed
} else {

raghosh
committed
}
},
},
{
title: 'Experimental Evidence',
data: 'protein_exp_evidence',
className: 'whitespace-nowrap',
defaultContent: '<i>No data</i>',

raghosh
committed
render: function (data, type, row, meta) {
// console.log(_.flatMap(row.condensates, c => c.data_sources))

raghosh
committed
if (!vm.proteinExperimentalEvidence) {

raghosh
committed
let dat = vm.proteinExperimentalEvidence[row.uniprot_id];

raghosh
committed

raghosh
committed
if (dat) {

raghosh
committed
}

raghosh
committed
},
},
{
title: 'Driver Criterion',
data: 'driver_criterion',
className: 'whitespace-nowrap',
defaultContent: '<i>No data</i>',

raghosh
committed
render: function (data, type, row, meta) {
// console.log(_.flatMap(row.condensates, c => c.data_sources))

raghosh
committed
if (!vm.proteinDriverCriterion) {
return;

raghosh
committed
let dat = vm.proteinDriverCriterion[row.uniprot_id];
if (dat) {

raghosh
committed
}

raghosh
committed
},
title: 'DB',
data: 'uniprot_id',
className: 'whitespace-normal',
render: function (data, type, row, meta) {
// console.log(_.flatMap(row.condensates, c => c.data_sources))
let dat = vm.dbTags[row.uniprot_id];
if (dat) {
},
},
// {
// title: 'Evidence',
// data: 'uniprot_id',
// className: "text-nowrap",
// fnCreatedCell: (nTd, sData, oData) => {
// $(nTd).html(`${vm.map[oData.uniprot_id]}`);
// },
// },
// {
// title: 'Sequence',
// data: 'sequence',
// className: "text-nowrap",
// fnCreatedCell: (nTd, sData, oData) => {
// $(nTd).html(`<input type="text" value="${sData}">
// <button class="copy-button" name="${oData.uniprot_id}" id="${oData.uniprot_id}" data-clipboard-text="${sData}"><i class="glyphicon glyphicon-copy"></i> </button>`);
// },
// }
render: function (data, type, row, meta) {
// console.log(_.flatMap(row.condensates, c => c.data_sources))
let dat = vm.map[row.uniprot_id];
if (dat) {
// console.log(getRatingValue(vm.map[row.uniprot_id]))
},
fnCreatedCell: (nTd, sData, oData) => {
let data = vm.map[oData.uniprot_id];
if (data) {
},
},
{
title: 'Action',
data: 'uniprot_id',
name: 'action',
className: 'text-nowrap',
fnCreatedCell: (nTd, sData, oData) => {
$(nTd).html(

raghosh
committed
`<button class="rounded-md bg-transparent hover:bg-blue-600 text-blue-700
hover:text-white
border border-blue-500
hover:border-transparent
focus:ring-2 focus:ring-blue-300
items-center
px-4
py-2
text-center
edit-link
">
Edit
</button>

raghosh
committed
<button class="rounded-md bg-transparent hover:bg-red-600 text-red-700
hover:text-white
border border-red-500
hover:border-transparent
focus:ring-2 focus:ring-red-300
items-center
px-4
py-2
font-bold
text-center delete-link">
Remove
</button>
`
);
},
// render: function (data, type, row, meta) {
// if (this.$store.getters["User/userRole"] === "Maintainer") {
// $(nTd).html(
// `<button class="btn btn-primary btn-outline font-bold" style="font-weight:bold">Edit
// <i class="fa ml-2 fa-edit" style="font-weight:bold"></i>
// </button>`
// );
// } else {
// return "";
// }
// },
},
const nTableOptions = {
columns,
// aaSorting: [[ 0, 'asc' ]],
lengthMenu: [
[10, 25, 50, -1],
],
paging: true,
searching: true,
info: false,
data,
order: [], // order: [[0, 'asc']],
bDestroy: true, // Add this property to new setting,
oLanguage: {
},
dom: '<"row"<"col-sm-2"l><"col-sm-2"f><"col-sm-8"p>><"row"t><"row"<"col-sm-4"i><"col-sm-8"p>>',

raghosh
committed
// initComplete: function () {
// this.api().columns().every( function () {
// var column = this;
// var select = $('<select><option value=""></option></select>')
// .appendTo( $(column.header()).empty() )
// .on( 'change', function () {
// var val = $.fn.dataTable.util.escapeRegex(
// $(this).val()
// );
// column
// .search( val ? '^'+val+'$' : '', true, false )
// .draw();
// } );
// column.data().unique().sort().each( function ( d, j ) {
// select.append( '<option value="'+d+'">'+d+'</option>' )
// } );
// } );
// }
};
const tableId = `#${id}`;
if (table) {
table.destroy();
$(tableId).empty();
}
table = $(tableId).DataTable(nTableOptions);
if (
!this.$store.getters['User/userRole'] ||
this.$store.getters['User/userRole'] === 'Administrator' ||
this.$store.getters['User/userRole'] === 'Authenticated'
) {

raghosh
committed
var colIndex;
table.columns().every(function () {

raghosh
committed
// ... do something with data(), or this.nodes(), etc
});
table.column(colIndex).visible(false);
}
const tableBody = `${tableId} tbody`;
e.preventDefault();
const tr = $(e.target).parent().parent();
const row = table.row(tr);
vm.fetchProtein(row.data().uniprot_id);
});
e.preventDefault();
const tr = $(e.target).parent().parent();
const row = table.row(tr);
vm.forwardUniprot(row.data().uniprot_id);
});
e.preventDefault();
const tr = $(e.target).parent().parent();
const row = table.row(tr);
const id = row.data().uniprot_id;
let findScore;

raghosh
committed
for (let score in vm.map) {
if (score === id) {
findScore = vm.map[score];
}
}

raghosh
committed
let findProteinFunctionalType;
for (let type in vm.proteinFunctionalType) {
if (type === id) {
findProteinFunctionalType = vm.proteinFunctionalType[type];
}
}
let proteinExpEvi;
for (let exp in vm.proteinExperimentalEvidence) {
if (exp === id) {
proteinExpEvi = vm.proteinExperimentalEvidence[exp];
}
}

raghosh
committed
for (let driverCri in vm.proteinDriverCriterion) {
if (driverCri === id) {
proteinDriCri = vm.proteinDriverCriterion[driverCri];

raghosh
committed

raghosh
committed
vm.proteinFunctionalTypeData = findProteinFunctionalType;
vm.proteinExperimentalEvidenceData = proteinExpEvi;
vm.proteinDriverCriterionData = proteinDriCri;
vm.proteinConfidenceScore = findScore;
vm.selectedRowData = row.data();

raghosh
committed
vm.uniprotId = id;
vm.canonicaliD = vm.canonicalId;
vm.toggleActionModal = true;
// vm.$router.push(`/protein/editDetails/${id}`);
// vm.fetchPubMedId(e.target.id);
});
e.preventDefault();
const tr = $(e.target).parent().parent();
const row = table.row(tr);
const id = row.data().uniprot_id;
vm.uniprotId = id;
vm.toggleDeleteModal = true;
// vm.$router.push(`/protein/editDetails/${id}`);
// vm.fetchPubMedId(e.target.id);
});
e.preventDefault();
// console.log(e.target.id)
vm.fetchPubMedId(e.target.id);
});
exportTsv() {
// const vm = this;
},
};
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
table.dataTable.row-border > tbody > tr:first-child > th,
table.dataTable.row-border > tbody > tr:first-child > td,
table.dataTable.display > tbody > tr:first-child > th,
table.dataTable.display > tbody > tr:first-child > td {
border-top: none;
}
table.dataTable.row-border > tbody > tr > th,
table.dataTable.row-border > tbody > tr > td,
table.dataTable.display > tbody > tr > th,
table.dataTable.display > tbody > tr > td {
border-top: 1px solid #ddd;
}
table.dataTable > tbody > tr {
background-color: #ffffff;
}
table.dataTable.row-border > tbody > tr:hover,
table.dataTable.display > tbody > tr:hover {
background-color: #f6f6f6;
}
select.form-control {
font-size: 12px;
padding: 3px 12px;
}
ul.pagination {
font-size: 1rem;
}
.form-inline .form-control {
height: 25px;
line-height: 25px;
vertical-align: middle;
}
.protein-link {
font-weight: bold;
color: #0065b9;
}
.uniprot-link {
font-weight: bold;
color: #0065b9;
}
.pubmed-link {
font-weight: bold;
color: #0065b9;
}
.external-link {
font-weight: bold;
color: #0065b9;
}
.pagination {
font-size: 1.2rem;
}