|
@@ -20,14 +20,19 @@ import { CustomPropertyDescriptor } from 'molstar/lib/mol-model/custom-property'
|
|
|
import { arraySetAdd } from 'molstar/lib/mol-util/array';
|
|
|
import { dateToUtcString } from 'molstar/lib/mol-util/date';
|
|
|
|
|
|
-export type AlphaFoldConfidence = PropertyWrapper<{
|
|
|
+export type PLDDTConfidence = PropertyWrapper<{
|
|
|
score: IndexedCustomProperty.Residue<[number, string]>,
|
|
|
category: string[]
|
|
|
}>
|
|
|
|
|
|
-export namespace AlphaFoldConfidence {
|
|
|
+export namespace PLDDTConfidence {
|
|
|
+ const AlphaFoldNamespace = 'AF-';
|
|
|
+ const BakerNamespace = 'MA-BAK-';
|
|
|
+
|
|
|
export function isApplicable(model?: Model): boolean {
|
|
|
if (!model || !MmcifFormat.is(model.sourceData)) return false;
|
|
|
+ const entryId = model.entryId.toUpperCase();
|
|
|
+ if (!entryId.startsWith(AlphaFoldNamespace) && !entryId.startsWith(BakerNamespace)) return false;
|
|
|
return model.sourceData.data.frame.categoryNames.includes('ma_qa_metric_local');
|
|
|
}
|
|
|
|
|
@@ -60,7 +65,7 @@ export namespace AlphaFoldConfidence {
|
|
|
}
|
|
|
|
|
|
|
|
|
- export function fromCif(ctx: CustomProperty.Context, model: Model): AlphaFoldConfidence | undefined {
|
|
|
+ export function fromCif(ctx: CustomProperty.Context, model: Model): PLDDTConfidence | undefined {
|
|
|
const info = tryGetInfoFromCif('ma_qa_metric_local', model);
|
|
|
if (!info) return;
|
|
|
const data = getCifData(model);
|
|
@@ -68,14 +73,14 @@ export namespace AlphaFoldConfidence {
|
|
|
return { info, data: metricMap };
|
|
|
}
|
|
|
|
|
|
- export async function obtain(ctx: CustomProperty.Context, model: Model, _props: AlphaFoldConfidenceProps): Promise<CustomProperty.Data<any>> {
|
|
|
+ export async function obtain(ctx: CustomProperty.Context, model: Model, _props: PLDDTConfidenceProps): Promise<CustomProperty.Data<any>> {
|
|
|
const cif = fromCif(ctx, model);
|
|
|
return { value: cif };
|
|
|
}
|
|
|
|
|
|
export function getConfidenceScore(e: StructureElement.Location): [number, string] {
|
|
|
if (!Unit.isAtomic(e.unit)) return [-1, 'No Score'];
|
|
|
- const prop = AlphaFoldConfidenceProvider.get(e.unit.model).value;
|
|
|
+ const prop = PLDDTConfidenceProvider.get(e.unit.model).value;
|
|
|
if (!prop || !prop.data) return [-1, 'No Score'];
|
|
|
const rI = e.unit.residueIndex[e.element];
|
|
|
return prop.data.score.has(rI) ? prop.data.score.get(rI)! : [-1, 'No Score'];
|
|
@@ -84,7 +89,7 @@ export namespace AlphaFoldConfidence {
|
|
|
const _emptyArray: string[] = [];
|
|
|
export function getCategories(structure?: Structure) {
|
|
|
if (!structure) return _emptyArray;
|
|
|
- const prop = AlphaFoldConfidenceProvider.get(structure.models[0]).value;
|
|
|
+ const prop = PLDDTConfidenceProvider.get(structure.models[0]).value;
|
|
|
if (!prop || !prop.data) return _emptyArray;
|
|
|
return prop.data.category;
|
|
|
}
|
|
@@ -97,26 +102,26 @@ export namespace AlphaFoldConfidence {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-export const AlphaFoldConfidenceParams = {};
|
|
|
-export type AlphaFoldConfidenceParams = typeof AlphaFoldConfidenceParams
|
|
|
-export type AlphaFoldConfidenceProps = PD.Values<AlphaFoldConfidenceParams>
|
|
|
+export const PLDDTConfidenceParams = {};
|
|
|
+export type PLDDTConfidenceParams = typeof PLDDTConfidenceParams
|
|
|
+export type PLDDTConfidenceProps = PD.Values<PLDDTConfidenceParams>
|
|
|
|
|
|
-export const AlphaFoldConfidenceProvider: CustomModelProperty.Provider<AlphaFoldConfidenceParams, AlphaFoldConfidence> = CustomModelProperty.createProvider({
|
|
|
- label: 'AlphaFold Confidence Score',
|
|
|
+export const PLDDTConfidenceProvider: CustomModelProperty.Provider<PLDDTConfidenceParams, PLDDTConfidence> = CustomModelProperty.createProvider({
|
|
|
+ label: 'pLDDT Confidence Score',
|
|
|
descriptor: CustomPropertyDescriptor({
|
|
|
- name: 'af_confidence_score'
|
|
|
+ name: 'plddt_confidence_score'
|
|
|
}),
|
|
|
type: 'static',
|
|
|
- defaultParams: AlphaFoldConfidenceParams,
|
|
|
- getParams: () => AlphaFoldConfidenceParams,
|
|
|
- isApplicable: (data: Model) => AlphaFoldConfidence.isApplicable(data),
|
|
|
- obtain: async (ctx: CustomProperty.Context, data: Model, props: Partial<AlphaFoldConfidenceProps>) => {
|
|
|
- const p = { ...PD.getDefaultValues(AlphaFoldConfidenceParams), ...props };
|
|
|
- return await AlphaFoldConfidence.obtain(ctx, data, p);
|
|
|
+ defaultParams: PLDDTConfidenceParams,
|
|
|
+ getParams: () => PLDDTConfidenceParams,
|
|
|
+ isApplicable: (data: Model) => PLDDTConfidence.isApplicable(data),
|
|
|
+ obtain: async (ctx: CustomProperty.Context, data: Model, props: Partial<PLDDTConfidenceProps>) => {
|
|
|
+ const p = { ...PD.getDefaultValues(PLDDTConfidenceParams), ...props };
|
|
|
+ return await PLDDTConfidence.obtain(ctx, data, p);
|
|
|
}
|
|
|
});
|
|
|
|
|
|
-function createScoreMapFromCif(modelData: Model, residueData: Table<typeof AlphaFoldConfidence.Schema.local_metric_values>): AlphaFoldConfidence['data'] {
|
|
|
+function createScoreMapFromCif(modelData: Model, residueData: Table<typeof PLDDTConfidence.Schema.local_metric_values>): PLDDTConfidence['data'] {
|
|
|
const { label_asym_id, label_seq_id, metric_value, _rowCount } = residueData;
|
|
|
|
|
|
const ret = new Map<ResidueIndex, [number, string]>();
|