pdbe-molstar icon indicating copy to clipboard operation
pdbe-molstar copied to clipboard

How can I obtain detailed information such as the number of chains, the number of residues, and the names of each residue in the protein?

Open ashipiling opened this issue 1 year ago • 1 comments

Thank you for your code implementation. After loading the protein, how can I retrieve detailed information such as the number of chains, the number of residues, and the names of each residue in the protein?

ashipiling avatar Sep 04 '23 11:09 ashipiling

Hi,

A short answer: PDBe Molstar is not designed to retrieve this kind of information.

A long answer: It is technically possible to retrieve this information, but it is not straightforward at all. The following code should get what you want:

viewerInstance.events.loadComplete.subscribe(() => {
    const cells = Array.from(viewerInstance.state.cells.values());
    const structureCell = cells.find(cell => cell.transform.transformer.id === 'ms-plugin.structure-from-model');
    const structure = structureCell?.obj?.data;
    if (structure) {
        console.log('Chains:', Array.from(structure.model.properties.structAsymMap.values()));
        for (const seq of structure.model.sequence.sequences){
            console.log('Entity', seq.entityId);
            console.log(seq.sequence.code.toArray());
            console.log(seq.sequence.compId.toArray());
            console.log(seq.sequence.seqId.toArray());
        }
    }
});

But it assumes you are loading the deposited model structure. If you load assembly structure, it would get more complicated. Also if you want to get any further details, it might be difficult to find out without knowing the guts of Molstar.

midlik avatar Jan 23 '24 11:01 midlik