mirror of
https://github.com/LCPQ/QUESTDB_website.git
synced 2025-01-12 14:08:28 +01:00
Merge branch 'readXYZ'
This commit is contained in:
commit
7bfa5b6f03
@ -25,6 +25,11 @@ draft: false
|
|||||||
<script src="/js/indexDB.js"></script>
|
<script src="/js/indexDB.js"></script>
|
||||||
<script src="/js/ArrayExtensions.js"></script>
|
<script src="/js/ArrayExtensions.js"></script>
|
||||||
<script src="/js/mhchemCE.js"></script>
|
<script src="/js/mhchemCE.js"></script>
|
||||||
|
<link rel="stylesheet" href="/css/ChemDoodleWeb.css" type="text/css">
|
||||||
|
<script type="text/javascript" src="/js/ChemDoodleWeb.js"></script>
|
||||||
|
<script src="/js/Geometry.js"></script>
|
||||||
|
<script src="/js/GeometriesLoader.js"></script>
|
||||||
|
<script src="/js/GeometryParseMetadataExtension.js"></script>
|
||||||
<script>
|
<script>
|
||||||
function adjustSticky() {
|
function adjustSticky() {
|
||||||
const height = $("nav").height()
|
const height = $("nav").height()
|
||||||
@ -135,6 +140,15 @@ draft: false
|
|||||||
})
|
})
|
||||||
processingIndicator.isActive = false
|
processingIndicator.isActive = false
|
||||||
reloadCustomFiles()
|
reloadCustomFiles()
|
||||||
|
reloadGeoms()
|
||||||
|
}
|
||||||
|
async function reloadGeoms(){
|
||||||
|
window.geoms = await GeometriesLoader.loadForAsync(uniq(window.defaultDats.map(d=>{
|
||||||
|
return {
|
||||||
|
set:d.set.name,
|
||||||
|
molecule:d.molecule
|
||||||
|
}
|
||||||
|
})))
|
||||||
}
|
}
|
||||||
async function reloadCustomFiles() {
|
async function reloadCustomFiles() {
|
||||||
window.dats = window.defaultDats;
|
window.dats = window.defaultDats;
|
||||||
|
30
static/css/ChemDoodleWeb.css
Normal file
30
static/css/ChemDoodleWeb.css
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
/*
|
||||||
|
//
|
||||||
|
// ChemDoodle Web Components 9.1.0
|
||||||
|
//
|
||||||
|
// https://web.chemdoodle.com
|
||||||
|
//
|
||||||
|
// Copyright 2009-2020 iChemLabs, LLC. All rights reserved.
|
||||||
|
//
|
||||||
|
// The ChemDoodle Web Components library is licensed under version 3
|
||||||
|
// of the GNU GENERAL PUBLIC LICENSE.
|
||||||
|
//
|
||||||
|
// You may redistribute it and/or modify it under the terms of the
|
||||||
|
// GNU General Public License as published by the Free Software Foundation,
|
||||||
|
// either version 3 of the License, or (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU General Public License
|
||||||
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
//
|
||||||
|
// Please contact iChemLabs <https://www.ichemlabs.com/contact-us> for
|
||||||
|
// alternate licensing options.
|
||||||
|
//
|
||||||
|
*/
|
||||||
|
canvas.ChemDoodleWebComponent {
|
||||||
|
border: 1px solid black;
|
||||||
|
}
|
@ -6,4 +6,13 @@ if (!Array.prototype.findAsync) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (!Array.prototype.findAllIndexes) {
|
||||||
|
Array.prototype.findAllIndexes = function (Callback) {
|
||||||
|
return this.reduce(function(a, e, i) {
|
||||||
|
if (Callback(e))
|
||||||
|
a.push(i)
|
||||||
|
return a
|
||||||
|
}, [])
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
852
static/js/ChemDoodleWeb.js
Normal file
852
static/js/ChemDoodleWeb.js
Normal file
File diff suppressed because one or more lines are too long
16
static/js/GeometriesLoader.js
Normal file
16
static/js/GeometriesLoader.js
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
class GeometriesLoader{
|
||||||
|
static async loadForAsync(array){
|
||||||
|
var xyzs=[]
|
||||||
|
for (const item of array) {
|
||||||
|
const mymol=mhchemCE.extract(item.molecule).toLowerCase().replace(" ","_")
|
||||||
|
const myset=item.set.split("#").join("")
|
||||||
|
try {
|
||||||
|
const mol=await Geometry.loadXYZAsync(`/${myset}/${mymol}.xyz`)
|
||||||
|
xyzs.push(mol)
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Geometry not found",item)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return xyzs.flat()
|
||||||
|
}
|
||||||
|
}
|
35
static/js/Geometry.js
Normal file
35
static/js/Geometry.js
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
class Geometry {
|
||||||
|
constructor(molecule, comment) {
|
||||||
|
this.molecule = molecule
|
||||||
|
this.comment = comment
|
||||||
|
}
|
||||||
|
static async loadXYZAsync(file) {
|
||||||
|
switch (trueTypeOf(file)) {
|
||||||
|
case String.name:
|
||||||
|
file = getFullDataPath("/structures/"+file)
|
||||||
|
var str = await getTextFromFileUrlAsync(file)
|
||||||
|
break;
|
||||||
|
case File.name:
|
||||||
|
var str = await getTextFromUploadedFileAsync(file)
|
||||||
|
break
|
||||||
|
}
|
||||||
|
var xyz = this.loadXYZString(str);
|
||||||
|
xyz.sourceFile = new websiteFile(file)
|
||||||
|
return xyz
|
||||||
|
}
|
||||||
|
static loadXYZString(text) {
|
||||||
|
var lines = text.split("\n")
|
||||||
|
var indexes = lines.findAllIndexes((line) => {
|
||||||
|
return line.match(/^\d+$/)
|
||||||
|
})
|
||||||
|
indexes.push(lines.length)
|
||||||
|
var geoms = []
|
||||||
|
for (let i = 0; i < indexes.length - 1; i++) {
|
||||||
|
const mollines = lines.slice(indexes[i], indexes[i + 1])
|
||||||
|
const comment = mollines[1]
|
||||||
|
const molecule = ChemDoodle.readXYZ(mollines.join("\n"))
|
||||||
|
geoms.push(new Geometry(molecule, comment))
|
||||||
|
}
|
||||||
|
return geoms
|
||||||
|
}
|
||||||
|
}
|
20
static/js/GeometryParseMetadataExtension.js
Normal file
20
static/js/GeometryParseMetadataExtension.js
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
if (!Geometry.prototype.parseMetadata) {
|
||||||
|
Geometry.prototype.parseMetadata = function () {
|
||||||
|
const Ametadata = this.comment.split(",")
|
||||||
|
const molecule = Ametadata[0]
|
||||||
|
const stateRegExp = /^\^(\d+)(.+)$/
|
||||||
|
const m = Ametadata[1].match(stateRegExp)
|
||||||
|
const mul = m[1]
|
||||||
|
const sym = m[2]
|
||||||
|
var meth = null
|
||||||
|
if (Ametadata.length>2) {
|
||||||
|
meth = new method(Ametadata[2],Ametadata[3])
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
molecule:molecule,
|
||||||
|
multiplicity:mul,
|
||||||
|
symmetry:sym,
|
||||||
|
method:meth
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -228,6 +228,34 @@ class dataFileBase {
|
|||||||
//metadata RegExp (start with #; maybe somme spaces; : ; maybe somme space; datas)
|
//metadata RegExp (start with #; maybe somme spaces; : ; maybe somme space; datas)
|
||||||
return /^#\s*([A-Za-z_]+)\s*:\s*(.*)$/;
|
return /^#\s*([A-Za-z_]+)\s*:\s*(.*)$/;
|
||||||
}
|
}
|
||||||
|
async getGeometryAsync(state = null) {
|
||||||
|
var text = await getTextFromFileUrlAsync(`/data/structures/${this.set.name.replace("#", "")}/${this.molecule.toLowerCase()}.xyz`)
|
||||||
|
var lines = text.split("\n")
|
||||||
|
var indexes = lines.findAllIndexes((line) => {
|
||||||
|
return line.match(/^\d+$/)
|
||||||
|
})
|
||||||
|
indexes.push(lines.length)
|
||||||
|
var molsstr = []
|
||||||
|
for (let i = 0; i < indexes.length - 1; i++) {
|
||||||
|
molsstr.push(lines.slice(indexes[i], indexes[i + 1]).join('\n'))
|
||||||
|
}
|
||||||
|
molsstr.filter((molstr) => {
|
||||||
|
var params = molstr.split("\n")[1].split(",")
|
||||||
|
return (state === null || params[0] === `^${state.multiplicity}${state.symetry}`) && params[1] == `${this.method.name},${this.method.basis}`
|
||||||
|
})
|
||||||
|
return molsstr.map((molstr) => {
|
||||||
|
var params = molstr.split("\n")[1].split(",")
|
||||||
|
var regex=/^\^(\d+)(.+)$/
|
||||||
|
var m=params[1].match(regex)
|
||||||
|
return {
|
||||||
|
name: this.molecule,
|
||||||
|
multiplicity:m[1],
|
||||||
|
symmetry:m[2],
|
||||||
|
method:this.geometry,
|
||||||
|
geometry:ChemDoodle.readXYZ(molstr)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
CopyExcitationsTypeFrom(data) {
|
CopyExcitationsTypeFrom(data) {
|
||||||
for (const ex of this.excitations) {
|
for (const ex of this.excitations) {
|
||||||
const ex2 = data.excitations.find((e) => {
|
const ex2 = data.excitations.find((e) => {
|
||||||
|
Loading…
Reference in New Issue
Block a user