10
0
mirror of https://github.com/LCPQ/QUESTDB_website.git synced 2024-11-04 13:13:55 +01:00

Remove DOI class

This commit is contained in:
Mickaël Véril 2020-09-04 14:59:39 +02:00
parent e21750c8b0
commit 0b09a98713
3 changed files with 16 additions and 34 deletions

View File

@ -99,12 +99,12 @@ draft: false
var data = await loadAllData() var data = await loadAllData()
window.defaultDats = [] window.defaultDats = []
for (const sub of Object.values(data)) { for (const sub of Object.values(data)) {
for (const doi of uniq(sub.map(d => (d.DOI == null ? "" : d.DOI.string)))) { for (const doi of new Set(sub.map(d => d.DOI))) {
const subdoi = sub.filter(d => (d.DOI == null ? "" : d.DOI.string) === doi) const subdoi = sub.filter(d => (d.DOI == null ? "" : d.DOI) === doi)
for (mol of uniq(subdoi.map(d => d.molecule))) { for (mol of uniq(subdoi.map(d => d.molecule))) {
const submol = subdoi.filter(d => d.molecule === mol) const submol = subdoi.filter(d => d.molecule === mol)
const source = submol.find((d) => { const source = submol.find((d) => {
if ((d.DOI == null ? "" : d.DOI.string) === "10.1021/acs.jctc.8b01205") { if ((d.DOI == null ? "" : d.DOI) === "10.1021/acs.jctc.8b01205") {
return d.method.name === "CASPT2" && d.method.basis === "aug-cc-pVDZ" return d.method.name === "CASPT2" && d.method.basis === "aug-cc-pVDZ"
} else { } else {
return d.method.isTBE return d.method.isTBE
@ -120,7 +120,7 @@ draft: false
window.defaultDats = window.defaultDats.concat(sub) window.defaultDats = window.defaultDats.concat(sub)
} }
await doiCache.addRange(Array.from(new Set(window.defaultDats.filter(d => d.DOI !== null).map(d => d.DOI.string)))) await doiCache.addRange(Array.from(new Set(window.defaultDats.filter(d => d.DOI !== null).map(d => d.DOI))))
window.defaultDats = window.defaultDats.sort((datfa, datfb) => { window.defaultDats = window.defaultDats.sort((datfa, datfb) => {
const DOIa = datfa.DOI const DOIa = datfa.DOI
const DOIb = datfb.DOI const DOIb = datfb.DOI
@ -134,8 +134,8 @@ draft: false
return -1 return -1
} }
else { else {
const puba = doiCache.get(DOIa.string).format('data', { format: 'object' })[0] const puba = doiCache.get(DOIa).format('data', { format: 'object' })[0]
const pubb = doiCache.get(DOIb.string).format('data', { format: 'object' })[0] const pubb = doiCache.get(DOIb).format('data', { format: 'object' })[0]
return pubUtils.getIssuedDate(puba) - pubUtils.getIssuedDate(pubb) return pubUtils.getIssuedDate(puba) - pubUtils.getIssuedDate(pubb)
} }
}) })
@ -290,7 +290,7 @@ draft: false
case "basis": case "basis":
return data.method.basis return data.method.basis
case "DOI": case "DOI":
return data.DOI === null ? "" : data.DOI.string return data.DOI === null ? "" : data.DOI
default: default:
return data[name] return data[name]
break; break;
@ -306,7 +306,7 @@ draft: false
var sdatdic = new Map() var sdatdic = new Map()
for (const d of window.filtData) { for (const d of window.filtData) {
const key = JSON.stringify(d.method) const key = JSON.stringify(d.method)
const doi = (d.DOI == null ? "" : d.DOI.string) const doi = (d.DOI == null ? "" : d.DOI)
const SetName = publis.findSetNameFromDOI(doi,true) const SetName = publis.findSetNameFromDOI(doi,true)
if (!(sdatdic.has(key))) { if (!(sdatdic.has(key))) {
sdatdic.set(key, new Map()) sdatdic.set(key, new Map())
@ -423,7 +423,7 @@ draft: false
}) })
}) })
window.T1ref = new Map() window.T1ref = new Map()
var dois = new Set(window.filtData.map((d) => d.DOI === null ? "" : d.DOI.string)) var dois = new Set(window.filtData.map((d) => d.DOI === null ? "" : d.DOI))
var mols = new Set(window.filtData.map((d) => d.molecule)) var mols = new Set(window.filtData.map((d) => d.molecule))
await window.doiCache.addRange(dois) await window.doiCache.addRange(dois)
for (const doi of dois) { for (const doi of dois) {
@ -431,7 +431,7 @@ draft: false
window.T1ref.set(setName, new Map()) window.T1ref.set(setName, new Map())
for (const mol of mols) { for (const mol of mols) {
window.T1ref.get(setName).set(mol, new Map()) window.T1ref.get(setName).set(mol, new Map())
var TBESortdat = window.dats.filter(d => (d.DOI === null ? "" : d.DOI.string) === doi && d.molecule === mol).sort((d1, d2) => { var TBESortdat = window.dats.filter(d => (d.DOI === null ? "" : d.DOI) === doi && d.molecule === mol).sort((d1, d2) => {
if (d1.method.isTBE && !d2.method.isTBE) { if (d1.method.isTBE && !d2.method.isTBE) {
return -1 return -1
} else if (!d1.method.isTBE && d2.method.isTBE) { } else if (!d1.method.isTBE && d2.method.isTBE) {
@ -455,7 +455,7 @@ draft: false
} }
} }
$(sel_ref).empty() $(sel_ref).empty()
for (const el of uniq(window.filtData.map(d => [d.method, (d.DOI === null ? null : d.DOI.string)]))) { for (const el of uniq(window.filtData.map(d => [d.method, (d.DOI === null ? null : d.DOI)]))) {
op = $("<option/>", { op = $("<option/>", {
value: JSON.stringify(el) value: JSON.stringify(el)
}).text(el[0]) }).text(el[0])
@ -474,7 +474,7 @@ draft: false
var CurrentsetName = undefined var CurrentsetName = undefined
for (const doi of doiCache.keys()) { for (const doi of doiCache.keys()) {
paperdata = window.filtData.filter((d) => { paperdata = window.filtData.filter((d) => {
return (d.DOI === null ? "" : d.DOI.string) == doi return (d.DOI === null ? "" : d.DOI) == doi
}) })
var methods = uniq(paperdata.map(d => d.method)) var methods = uniq(paperdata.map(d => d.method))
const sortedMethods = methods.sort((a, b) => { const sortedMethods = methods.sort((a, b) => {
@ -515,7 +515,7 @@ draft: false
adjustSticky(); adjustSticky();
datadic = new Map() datadic = new Map()
for (const dat of paperdata) { for (const dat of paperdata) {
const doi = (dat.DOI == null ? "" : dat.DOI.string) const doi = (dat.DOI == null ? "" : dat.DOI)
const setName = publis.findSetNameFromDOI(doi) const setName = publis.findSetNameFromDOI(doi)
const key1 = dat.molecule; const key1 = dat.molecule;
const myT1s = T1ref.get(setName).get(dat.molecule) const myT1s = T1ref.get(setName).get(dat.molecule)

View File

@ -20,7 +20,7 @@ draft: false
window.onload = async function () { window.onload = async function () {
var div = document.getElementById("publis_div") var div = document.getElementById("publis_div")
const Cite = require("citation-js") const Cite = require("citation-js")
const sdois = uniq(Object.values(await loadAllData()).flat().filter(d => d.DOI !== null).map(d => d.DOI.string)) const sdois = uniq(Object.values(await loadAllData()).flat().filter(d => d.DOI !== null).map(d => d.DOI))
const spubliscite = await Cite.async(sdois) const spubliscite = await Cite.async(sdois)
const uospublis = spubliscite.format('data', { format: 'object' }) const uospublis = spubliscite.format('data', { format: 'object' })
const spublis = uospublis.sort((puba, pubb) => pubUtils.getIssuedDate(puba) - pubUtils.getIssuedDate(pubb)) const spublis = uospublis.sort((puba, pubb) => pubUtils.getIssuedDate(puba) - pubUtils.getIssuedDate(pubb))

View File

@ -115,24 +115,6 @@ class state {
return tex; return tex;
}; };
} }
class DOI {
constructor(doistring) {
this.string = doistring
};
static fromString(str) {
return new DOI(str)
}
toString() {
var str = this.string;
if (this.IsSupporting) {
str += " " + "(SI)"
}
return str
};
get url() {
return new URL(this.string, 'https://doi.org').toString()
}
}
class excitationBase { class excitationBase {
constructor(initial, final, type = '', T1 = null) { constructor(initial, final, type = '', T1 = null) {
@ -247,7 +229,7 @@ class dataFileBase {
this.method = method.fromString(value) this.method = method.fromString(value)
break; break;
case "doi": case "doi":
this.DOI = DOI.fromString(value); this.DOI = value
break; break;
} }
} }
@ -320,7 +302,7 @@ class dataFileBase {
} }
}); });
console.assert(double.length === 0, "Double found", double, dat.molecule, dat.method.toString()) console.assert(double.length === 0, "Double found", double, dat.molecule, dat.method.toString())
if (dat.DOI!== null && dat.DOI.string !== "10.1021/acs.jctc.8b01205") { if (dat.DOI!== null && dat.DOI !== "10.1021/acs.jctc.8b01205") {
for (const ex of dat.excitations) { for (const ex of dat.excitations) {
console.assert(Number.isNaN(ex.T1.valueOf()) | ex.T1 > 50 | ex.isUnsafe == true, "Must be unsafe", dat, ex) console.assert(Number.isNaN(ex.T1.valueOf()) | ex.T1 > 50 | ex.isUnsafe == true, "Must be unsafe", dat, ex)
} }