Select a chain
nataliarosa9 opened this issue · comments
I'm trying to select a chain in the query using Mol-script language. I can do it when the query is like this:
Script.getStructureSelection(Q => Q.struct.generator.atomGroups({
"chain-test": Q.core.rel.eq([MolScriptBuilder.struct.atomProperty.macromolecular.auth_asym_id(), 'A']),
'residue-test': Q.core.set.has([Q.set(positions), Q.ammp('auth_seq_id')]),
'group-by': Q.struct.atomProperty.macromolecular.residueKey(),
}), dta);
But I need to figure out how to do it in this scenario.
// Set script language
const language = 'mol-script';
// Create params object
const params = {
layers: []
};
// Add layers to params object
for (let i = 0; i < positions.length; i++) {
const start = positions[i];
const stop = positions[i];
params.layers.push({
script: Script(
`(sel.atom.res (in-range atom.resno ${start} ${stop}))`,
language
),
color: Color(0xf0e68c),
clear: false
});
}
What are you trying to achieve?
I want to repaint a specific section of the structure on a particular chain.
...
// Get polymer representation
const cartoon = structure.representation.representations.polymer;
// Create and apply custom representation
const reprParamsStructureResetColor = createStructureRepresentationParams(plugin, undefined, {
type: 'cartoon',
color: 'uniform',
colorParams: { value: ColorNames.gray }
});
const update = await plugin
.build()
.to(cartoon)
.update(reprParamsStructureResetColor);
// Set script language
const language = 'mol-script';
// Create params object
const params = {
layers: []
};
// Add layers to params object
for (let i = 0; i < positions.length; i++) {
const start = positions[i];
const stop = positions[i];
const chain = 'B';
params.layers.push({
script: Script(
`(sel.atom.res (in-range atom.resno ${start} ${stop}))`,
language
),
color: Color(0xf0e68c),
clear: false
});
}
// Apply yellow color
const update2 = plugin.build();
update
.to(cartoon)
.apply(StateTransforms.Representation.OverpaintStructureRepresentation3DFromScript, params);
await update.commit();
await update2.commit();
...
Something like (untested)
(sel.atom.atom-groups
:chain-test (= atom.auth_asym_id A)
:residue-test (set.has (set 1 2 3 4) atom.auth_seq_id)
)
You can src\mol-script\script\mol-script\symbols.ts to see how the builder maps to the script