|
@@ -9,35 +9,53 @@ import { Model } from 'mol-model/structure';
|
|
import { StructureQualityReport } from 'mol-model-props/pdbe/structure-quality-report';
|
|
import { StructureQualityReport } from 'mol-model-props/pdbe/structure-quality-report';
|
|
import { fetchRetry } from '../../utils/fetch-retry';
|
|
import { fetchRetry } from '../../utils/fetch-retry';
|
|
import { UUID } from 'mol-util';
|
|
import { UUID } from 'mol-util';
|
|
|
|
+import { PDBePreferredAssembly } from 'mol-model-props/pdbe/preferred-assembly';
|
|
|
|
|
|
const USE_FILE_SOURCE = false;
|
|
const USE_FILE_SOURCE = false;
|
|
|
|
|
|
export function PDBe_structureQualityReport(model: Model, cache: any) {
|
|
export function PDBe_structureQualityReport(model: Model, cache: any) {
|
|
return StructureQualityReport.attachFromCifOrApi(model, {
|
|
return StructureQualityReport.attachFromCifOrApi(model, {
|
|
PDBe_apiSourceJson: USE_FILE_SOURCE
|
|
PDBe_apiSourceJson: USE_FILE_SOURCE
|
|
- ? residuewise_outlier_summary.getDataFromFile
|
|
|
|
|
|
+ ? residuewise_outlier_summary.getDataFromAggregateFile
|
|
: residuewise_outlier_summary.getDataFromApiProvider(cache)
|
|
: residuewise_outlier_summary.getDataFromApiProvider(cache)
|
|
});
|
|
});
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+export function PDBe_preferredAssembly(model: Model, cache: any) {
|
|
|
|
+ return PDBePreferredAssembly.attachFromCifOrApi(model, {
|
|
|
|
+ PDBe_apiSourceJson: USE_FILE_SOURCE
|
|
|
|
+ ? void 0
|
|
|
|
+ : preferred_assembly.getDataFromApiProvider(cache)
|
|
|
|
+ });
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+namespace preferred_assembly {
|
|
|
|
+ export const getDataFromApiProvider = apiQueryProvider('https://www.ebi.ac.uk/pdbe/api/pdb/entry/summary');
|
|
|
|
+}
|
|
|
|
+
|
|
namespace residuewise_outlier_summary {
|
|
namespace residuewise_outlier_summary {
|
|
const json = new Map<string, any>();
|
|
const json = new Map<string, any>();
|
|
|
|
|
|
- export async function getDataFromFile(model: Model) {
|
|
|
|
|
|
+ export async function getDataFromAggregateFile(model: Model) {
|
|
const key = `${model.label[1]}${model.label[2]}`;
|
|
const key = `${model.label[1]}${model.label[2]}`;
|
|
if (!json.has(key)) {
|
|
if (!json.has(key)) {
|
|
const fn = `e:/test/mol-star/model/props/${key}.json`;
|
|
const fn = `e:/test/mol-star/model/props/${key}.json`;
|
|
if (!fs.existsSync(fn)) json.set(key, { });
|
|
if (!fs.existsSync(fn)) json.set(key, { });
|
|
|
|
+ // TODO: use async readFile?
|
|
else json.set(key, JSON.parse(fs.readFileSync(fn, 'utf8')));
|
|
else json.set(key, JSON.parse(fs.readFileSync(fn, 'utf8')));
|
|
}
|
|
}
|
|
return json.get(key)![model.label.toLowerCase()] || { };
|
|
return json.get(key)![model.label.toLowerCase()] || { };
|
|
}
|
|
}
|
|
|
|
|
|
- export function getDataFromApiProvider(cache: any) {
|
|
|
|
|
|
+ export const getDataFromApiProvider = apiQueryProvider('https://www.ebi.ac.uk/pdbe/api/validation/residuewise_outlier_summary/entry');
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+function apiQueryProvider(urlPrefix: string) {
|
|
|
|
+ return (cache: any) => {
|
|
const cacheKey = UUID.create();
|
|
const cacheKey = UUID.create();
|
|
return async (model: Model) => {
|
|
return async (model: Model) => {
|
|
if (cache[cacheKey]) return cache[cacheKey];
|
|
if (cache[cacheKey]) return cache[cacheKey];
|
|
- const rawData = await fetchRetry(`https://www.ebi.ac.uk/pdbe/api/validation/residuewise_outlier_summary/entry/${model.label.toLowerCase()}`, 1500, 5);
|
|
|
|
|
|
+ const rawData = await fetchRetry(`${urlPrefix}/${model.label.toLowerCase()}`, 1500, 5);
|
|
const json = (await rawData.json())[model.label.toLowerCase()] || { };
|
|
const json = (await rawData.json())[model.label.toLowerCase()] || { };
|
|
cache[cacheKey] = json;
|
|
cache[cacheKey] = json;
|
|
return json;
|
|
return json;
|