Public
Edited
Oct 19, 2022
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
customDomain = ['Inactive', 'Not tested', -12, -11, -10, -9, -8, -7, -6, -5, -4, -3]
Insert cell
customColors = ['white', '#c4c4c4', '#f56c3f', '#f58a3f', '#f4a946', '#f6c659', '#f6e072', '#d8e17e', '#bddf93', '#b8e2b3', '#caebd7', '#c4ddd1']
Insert cell
array_compounds = get_unique_elements(dataset, "Compound")
Insert cell
array_assays = ["PC10 AR", "PC10 Era", "PC20 AR-anti", "PC20 ERa-anti"]
Insert cell
array_svg = Promise.all(array_smiles.map(smiles => function_get_svg_from_smiles(smiles.canonical)))
Insert cell
numeric_dataset = clean_to_numeric_dataset()
Insert cell
parseEndpointValue = function(val) {
// check if value is null, then compound was not tested
if (val == null) {
return "Not tested"
} else if (val.startsWith(">")) {
// check if compound is inactive
return "Inactive"
} else {
// otherwise compound was active and return a number
return parseInt(val)
}
}
Insert cell
clean_to_numeric_dataset = function() {
var arr = [];
var i;
for (i = 0; i < dataset.length; i++) {
var obj = dataset[i]
arr.push({
'Compound': obj['Compound'],
'Endpoint': 'PC10 AR',
'Value': parseEndpointValue(obj['PC10 AR']),
'Original value': obj['PC10 AR']
})
arr.push(
{'Compound': obj['Compound'],
'Endpoint': 'PC10 Era',
'Value': parseEndpointValue(obj['PC10 Era']),
'Original value': obj['PC10 Era']
})
arr.push({
'Compound': obj['Compound'],
'Endpoint': 'PC20 AR-anti',
'Value': parseEndpointValue(obj['PC20 AR-anti']),
'Original value': obj['PC20 AR-anti']
})
arr.push({
'Compound': obj['Compound'],
'Endpoint': 'PC20 ERa-anti',
'Value': parseEndpointValue(obj['PC20 ERa-anti']),
'Original value': obj['PC20 ERa-anti']
})
}
return arr
}
Insert cell
clean_dataset= dataset.map(item => { return {
'Compound': item['Compound'],
'Molecular formula': item['Molecular formula'],
'PC10 AR': parseFloat(item['PC10 AR']).toFixed(2),
'PC10 Era': parseFloat(item['PC10 Era']).toFixed(2),
'PC20 AR-anti': parseFloat(item['PC20 AR-anti']).toFixed(2),
'PC20 ERa-anti': parseFloat(item['PC20 ERa-anti']).toFixed(2),
'Similarity': item['SMILES (Canonical)']['similarity'].toFixed(2)
}
})
Insert cell
targetSmiles = {
if (selectedCompound.value == null) {
return smiles
} else {
return selectedCompound.value['SMILES (Canonical)']['canonical']
}
}
Insert cell
query_options = {
return {
method: 'POST',
body: JSON.stringify({
condition: {
gt: [{tanimotoSimilarity: [targetSmiles, { column: ["SMILES (Canonical)"] }]}, tanimoto_threshold]
},
orderBy: [
{expression: {tanimotoSimilarity: [targetSmiles, { column: ["SMILES (Canonical)"] }]}, ordering: "descending"}
]
})
}
}
Insert cell
Insert cell
function_get_svg_from_smiles = function get_svg_from_smiles(smiles) {
const safeSmiles = encodeURIComponent(smiles);
const svg_url = "https://chemidconvert.cloud.douglasconnect.com/v1/asSvg?width=200&height=200&smiles=" + safeSmiles;
return fetch(svg_url).then(response => response.text());
}
Insert cell
array_smiles = get_unique_elements(dataset, "SMILES (Canonical)")
Insert cell
get_unique_elements = function(array, parameter) {
return Array.from(new Set(array.map(item => item[parameter])))
}
Insert cell
dataset = fetch_dataset_to_array(dataset_url, query_options)
Insert cell
full_array_compounds = get_unique_elements(full_dataset, "Compound")
Insert cell
full_array_cas = get_unique_elements(full_dataset, "CAS")
Insert cell
full_dataset = fetch_dataset_to_array(dataset_url, {})
Insert cell
function fetch_dataset_to_array(dataset_url, query_options) {
return fetch(dataset_url, query_options).then(response_dataset => {
if (!response_dataset.ok) throw new Error(response_dataset.status);
return response_dataset.json();}).then(json => json.results.map(x => x.data));
}
Insert cell
dataset_url = base_url_edelweiss + dataset_id + "/versions/latest/data"
Insert cell
dataset_id = "c2603d1f-9d3a-4d91-96aa-10ce675d2b6b"
Insert cell
base_url_edelweiss = 'https://api.edelweissdata.com/datasets/'
Insert cell
// Import libraries for data table rendering
import {render_data_table} from '@info474/utilities'
Insert cell
import {select, textarea, text, slider} from "@jashkenas/inputs"
Insert cell
import {Select, Range, Toggle, Table} from "@observablehq/inputs"
Insert cell
import {vl} from "@vega/vega-lite-api"
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more