Skip to content
Snippets Groups Projects
Commit 41135331 authored by David Sehnal's avatar David Sehnal
Browse files

better el symb cache

parent 64b724ea
No related branches found
No related tags found
No related merge requests found
......@@ -7,10 +7,27 @@
import BitFlags from 'mol-base/utils/bit-flags'
const _esCache = Object.create(null);
const _esCache = (function () {
const cache = Object.create(null);
const letters: string[] = [];
for (let i = 'A'.charCodeAt(0); i <= 'Z'.charCodeAt(0); i++) letters[letters.length] = String.fromCharCode(i);
for (let i = 'a'.charCodeAt(0); i <= 'z'.charCodeAt(0); i++) letters[letters.length] = String.fromCharCode(i);
for (let i = '0'.charCodeAt(0); i <= '9'.charCodeAt(0); i++) letters[letters.length] = String.fromCharCode(i);
for (const k of letters) {
cache[k] = k.toUpperCase();
for (const l of letters) {
cache[k + l] = (k + l).toUpperCase();
for (const m of letters) {
cache[k + l + m] = (k + l + m).toUpperCase();
}
}
}
return cache;
}());
export interface ElementSymbol extends String { '@type': 'element-symbol' }
export function ElementSymbol(s: string): ElementSymbol {
return _esCache[s] || (_esCache[s] = s.toUpperCase());
return _esCache[s] || s.toUpperCase();
}
export const enum EntityType {
......
......@@ -237,8 +237,8 @@ export namespace PropertyAccess {
// }
export async function run() {
const { structures, models } = await readCIF('./examples/1cbs_full.bcif');
//const { structures, models } = await readCIF('e:/test/quick/1jj2_full.bcif');
//const { structures, models } = await readCIF('./examples/1cbs_full.bcif');
const { structures, models } = await readCIF('e:/test/quick/3j3q_full.bcif');
//const { structures, models } = await readCIF('e:/test/quick/3j3q_updated.cif');
// console.log(toMmCIFString('test', structures[0]));
......@@ -280,8 +280,8 @@ export namespace PropertyAccess {
chainTest: Q.pred.inSet(P.chain.auth_asym_id, ['A', 'B', 'C', 'D']),
residueTest: Q.pred.eq(P.residue.auth_comp_id, 'ALA')
});
const q0r = q(structures[0]);
console.log(toMmCIFString('test', Selection.union(q0r)));
// const q0r = q(structures[0]);
// console.log(toMmCIFString('test', Selection.union(q0r)));
console.time('q1')
q1(structures[0]);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment