Newer
Older
<EntityReportCard
:report-card-structure="reportCardStructure"
:item-i-d="itemID"
:store-module-name="storeModuleName"
:entity-i-d="entityID"
import { mapState } from 'vuex'
import RequestNotifications from '@/web-components-submodule/utils/RequestNotifications.js'
import EntityReportCard from '~/web-components-submodule/components/common/ReportCards/EntityReportCard.vue'
import CompoundReportCardGenerator from '~/report_cards_structure/CompoundReportCardGenerator.js'
import EntityNames from '~/web-components-submodule/standardisation/EntityNames.js'
import ESProxyService from '~/web-components-submodule/services/ESProxyService.js'
import IndexNames from '~/web-components-submodule/standardisation/IndexNames.js'
import ObjectPropertyAccess from '~/web-components-submodule/utils/ObjectPropertyAccess.js'
import ErrorTracking from '~/web-components-submodule/tracking/ErrorTracking.js'
export default {
components: {
props: {
itemID: {
type: String,
default: () => undefined,
},
},
entityID: EntityNames.EubopenCompound.entityID,
reportCardStructure(state) {
return state[this.storeModuleName].reportCardStructure
},

David Mendez
committed
async mounted() {
try {
const paramsFromCompound = await this.getOptionalSectionsParams()

David Mendez
committed
const chemblID = await this.getChEMBLID()
const showCellHeatlhAndViabilityData = await this.hasCellHeatlhAndViabilityData(
chemblID
)
const showQualityControlData = await this.hasQualityControlData(chemblID)
const showActivityProfileData = await this.hasActivityProfileData(
chemblID
)

David Mendez
committed
const reportCardStructure = CompoundReportCardGenerator.generateReportCardStructure(
{

David Mendez
committed
itemID: this.itemID,
chemblID,
prefName: paramsFromCompound.prefName,

David Mendez
committed
isChemicalProbe: paramsFromCompound.isChemicalProbe,
isNegativeControl: paramsFromCompound.isNegativeControl,
showCellHeatlhAndViabilityData,

David Mendez
committed
showQualityControlData,
showActivityProfileData,

David Mendez
committed
}
)

David Mendez
committed
this.$store.dispatch(
`${this.storeModuleName}/setReportCardStructure`,
reportCardStructure
)

David Mendez
committed
this.$store.dispatch(`${this.storeModuleName}/setStructureReady`, true)
} catch (error) {
ErrorTracking.trackError(error, this)

David Mendez
committed

David Mendez
committed
RequestNotifications.dispatchRequestErrorNotification(
error,
this.$store.dispatch,
`There was an error while loading the page structure`
)
}
},
methods: {
async getOptionalSectionsParams() {
const docSource = [
'pref_name',
'_metadata.eubopen.is_probe',
'_metadata.eubopen.is_control',
]
const entityID = EntityNames.EubopenCompound.entityID
const indexName = IndexNames.getIndexNameFromEntityID(entityID)
const compoundResponse = await ESProxyService.getESDocument(

David Mendez
committed
indexName,
this.itemID,
docSource
)

David Mendez
committed
const compoundData = compoundResponse.data._source

David Mendez
committed
const prefName = ObjectPropertyAccess.getPropertyPalue(
compoundData,
'pref_name',
''
)

David Mendez
committed
const isChemicalProbe = ObjectPropertyAccess.getPropertyPalue(
compoundData,
'_metadata.eubopen.is_probe',
false
)

David Mendez
committed
const isNegativeControl = ObjectPropertyAccess.getPropertyPalue(
compoundData,
'_metadata.eubopen.is_control',
false
)

David Mendez
committed
return {
prefName,
isChemicalProbe,
isNegativeControl,
}
},

David Mendez
committed
async getChEMBLID() {

David Mendez
committed
const chemblIDResponse = await ESProxyService.getESDocument(
IndexNames.getIndexNameFromEntityID(
EntityNames.EubopenCompound.entityID
),
this.itemID,
['molecule_chembl_id']
)

David Mendez
committed
return chemblIDResponse.data._source.molecule_chembl_id
},
async hasCellHeatlhAndViabilityData(chemblID) {

David Mendez
committed
const cellHeatlhAndViabilityDataPath = `/eubopen/visualisations/compound/cell_viability_and_health_data/${chemblID}`
const cellHealthAndViabilityData = await ESProxyService.getGenericData(
cellHeatlhAndViabilityDataPath
)

David Mendez
committed
const numDataPoints = cellHealthAndViabilityData.data.num_datapoints
return numDataPoints > 0
},

David Mendez
committed
async hasQualityControlData(chemblID) {
const entityID = EntityNames.EubopenActivity.entityID
const indexName = IndexNames.getIndexNameFromEntityID(entityID)
const query = {
size: 0,
query: {
bool: {
must: [
{ terms: { molecule_chembl_id: [chemblID] } },
{
terms: {
'_metadata.eubopen.assay_type.type.description': [
'Cell Health Data',
'Incucyte cell viability',
'Thermal shift assay QC Liability',
],

David Mendez
committed
},
},
],
},
},
}
const qtData = await ESProxyService.getESData(indexName, query)
const numHits = qtData.data.es_response.hits.total.value
return numHits > 0
},
async hasActivityProfileData(chemblID) {
const entityID = EntityNames.EubopenActivity.entityID
const indexName = IndexNames.getIndexNameFromEntityID(entityID)
const query = {
size: 0,
query: {
bool: {
must: [{ terms: { molecule_chembl_id: [chemblID] } }],
must_not: [

David Mendez
committed
{
terms: {
'_metadata.eubopen.assay_type.type.description': [
'Cell Health Data',
'Incucyte cell viability',
'Thermal shift assay QC Liability',
],

David Mendez
committed
},
},
],
},
},
}
const qtData = await ESProxyService.getESData(indexName, query)
const numHits = qtData.data.es_response.hits.total.value
return numHits > 0
},