How to change the residues of a sequence chain in structure?
Hi, thanks for creating a powerful library!
I want to mask some residues of the structure sequence, basically just replace the residues with X and the label_comp_id with UNK.
What I have done so far are:
- Retrieving the structure selection using
StructureSelectionQuery() - Creating a new structure from the selected residues with
plugin.builders.structure.tryCreateComponentFromSelection()
But I could not find a way to replace the selected residue.
Another option I tried: Parsing CIF text file to CifFile, I can access to the raw data here.
In each category of the CifFile, I can use getField() to get the values but I can't find a way to edit it and save the CifFile back to text file.
const text = await file.text() ?? '';
const res = await plugin.runTask(parseCifText(text));
const result = res?.result as CifFile;
// result.blocks[0].categories.atom_site.getField('label_comp_id').toStringArray()
The CIF parser currently gives you a view-only version. What you are describing is something we would like to eventually support out of the box, but have no specific ETA.
Closest to what you need would likely be to use extensions/json-cif, which is a JSON encoding of the CIF structure which is easily editable. The use case of that was to be able to implement examples/ligand-editor, so you would have to add more functionality to it (converting any CIF to JSON-CIF, and possibly back; currently it only works via the to_mmCIF on Structure object and I haven't tested it on proteins).