molstar icon indicating copy to clipboard operation
molstar copied to clipboard

How do I get the corresponding Atom loci ?

Open webtop1 opened this issue 2 years ago • 4 comments

I have an SDF Data, as follows: image

How do I get the corresponding Atom loci ? I try do this:

const data = this.plugin.managers.structure.hierarchy.current.structures[0]?.cell.obj?.data; if (!data) return; const sel = Script.getStructureSelection(Q => Q.struct.generator.atomGroups({ "atom-test":Q.core.rel.eq([Q.struct.atomProperty.macromolecular.id, 1]), "group-by": Q.struct.atomProperty.macromolecular.label_entity_id() }), data); const loci = StructureSelection.toLociWithSourceUnits(sel); this.plugin.managers.camera.focusLoci(loci);

webtop1 avatar Aug 08 '22 07:08 webtop1

same question

Dimitri-WEI-Lingfeng avatar Aug 09 '22 10:08 Dimitri-WEI-Lingfeng

I think

const loci = Structure.toStructureElementLoci(data);

should be what you are looking for.

dsehnal avatar Aug 14 '22 17:08 dsehnal

I think

const loci = Structure.toStructureElementLoci(data);

should be what you are looking for.

Thank you very much. I'll try

webtop1 avatar Aug 15 '22 02:08 webtop1

I think

const loci = Structure.toStructureElementLoci(data);

should be what you are looking for.

I feel like I'm getting a little complicated. Maybe there's a simpler way to do this. What I want is: when the mouse moves over one atom, the other atom is highlighted. I'm going to use the method "camera.focusloci".

		this.plugin.canvas3d!.input.move.subscribe((obj) => {
			const { x, y } = obj;
			const pickingId = this.plugin.canvas3d!.identify(x, y)?.id;
			//todo: Gets the current source data, return:[40.5922,17.4164,12.4629]
			const getPickingSourceData = getPickingSourceData(pickingId);
			//todo: Finding Associated Data,return :[43.4349,13.9762,16.5152]
			const associatedData = findAssociatedData(getPickingSourceData);
			const anotherPickingId = Structure.toStructureElementLoci(associatedData);
			this.plugin.managers.camera.focusLoci(anotherPickingId);
		});

Can you give me some advice? Thank you very much!

webtop1 avatar Aug 15 '22 09:08 webtop1