-
Notifications
You must be signed in to change notification settings - Fork 51
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Polymer from PQR #285
base: develop
Are you sure you want to change the base?
Polymer from PQR #285
Conversation
passed from all upper functions
Python Usage at 29b1464 Input: from meeko import Polymer
from meeko import ResidueChemTemplates
from meeko import MoleculePreparation
from meeko import PDBQTWriterLegacy
pqr_fn = "1FAS_dry.pqr"
templates = ResidueChemTemplates.create_from_defaults()
with open(pqr_fn, "r") as f:
pqr_string = f.read()
mk_prep = MoleculePreparation(charge_model="read", charge_atom_prop="PQRCharge")
pol1 = Polymer.from_pqr_string(pqr_string, templates, mk_prep)
pdbqt_name1 = "1FAS_charge_from_pqr.pdbqt"
pdbqt_rigid = PDBQTWriterLegacy.write_from_polymer(pol1)[0]
with open(pdbqt_name1, "w") as f:
f.write(pdbqt_rigid)
mk_prep = MoleculePreparation()
pol2 = Polymer.from_pqr_string(pqr_string, templates, mk_prep)
pdbqt_name2 = "1FAS_charge_default.pdbqt"
pdbqt_rigid = PDBQTWriterLegacy.write_from_polymer(pol2)[0]
with open(pdbqt_name2, "w") as f:
f.write(pdbqt_rigid) Output: |
This comment is outdated. Please see updated version here: #285 (comment) |
To do:
|
The API looks great, but in mk_prepare_receptor.py, the option
|
I let read_pqr override mk_config (same way other arguments override config inputs) because I considered
I did not want to expose But now I understand the concerns you have. I'll think a bit more about this. Thanks again for the review! |
When I designed the function I did not want to support this. PQR file has some limitations (no element column, no alt locations, etc.), and the original PDB is always preferred. I tried to explain this in the help message, maybe it's not clear. There was a message that states the --charge_model and other options will be ignored: mk_prep = MoleculePreparation(charge_model="read", charge_atom_prop="PQRCharge")
print("Reading structures and partial charges from PQR. ")
print("Options --charge_model, --default_altloc and --wanted_altloc will be ignored. ")
The changes in this PR shouldn't override other config options. If so, I didn't intend to. I will do a more thorough check, since it's from a while ago |
messages when --read_pqr is used, corrections for MoleculePreparation from mk_config
962767a has the following changes:
config_group.add_argument(
"--charge_model",
choices=("gasteiger", "espaloma", "zero", "read"),
help="default is gasteiger, 'zero' sets all zeros, 'read' requires --read_pqr",
default=None,
)
# read mk_config if provided
if args.mk_config is not None:
with open(args.mk_config) as f:
mk_config = json.load(f)
else:
mk_config = {}
# update config by inputs from arguments
if args.charge_model is not None:
mk_config["charge_model"]=args.charge_model
if mk_config["charge_model"]=="read":
if args.read_pqr is None:
print("Error: --charge_model read requires --read_pqr")
sys.exit(2)
mk_config["charge_atom_prop"]="PQRCharge"
# initialize MoleculePreparation with config
mk_prep = MoleculePreparation.from_config(mk_config)
|
for charge_model = espaloma that must present during initialization
Please see an updated version below, for a display of help message and usage: Description in help message
Example usage 1: Parsing PQR, and reads charges from PQR[input]
[output] Example usage 2: Parsing PQR, but reads structure only[input]
[output] Example usage 3: Using alternate charge model[input]
|
@diogomart Would 962767a be able to address the issues you pointed out in the previous comment (in #285 (comment))? Sorry this is not the first time I got very confused by how config works and what needs to be set before initializing MoleculePreparation. We discussed this when I was working on mk_prepare_ligand to parse charges from MOL2, but I'm unfamiliar with the config options. I just totally forgot that there are other settings of MoleculePreparation not included in this command line script. |
No worries. Yes, those issues are addressed, thanks. About the charges: the first residue is -NH3+ terminated and thus its net charge is +1 in the test PQR, however it's being made blunt because #301 isn't merged yet and the charge redistribution is modifying the charges resulting in a net charge of zero. We may want to turn off the charge redistribution for charge_model=read in Line 2109 in 07a38f8
|
Hi @diogomart |
On a second thought, we can keep |
Hi @diogomart
Previously stricter matching was difficult with CYS, which can be blunt, cross-linked or deprotonated. I can do some more rewrite of the template matching. But if you have a specific plan of how to do this, please feel free to take over |
It might be because PQR isn't just a structure input. It's more like a partially parameterized polymer. I feel like if we start to support polymer json as input (I did in #277 but I gave up), there will be a similar problem: whether we want to allow updating single residue's or a few atoms' properties on a parameterized polymer, and how to verify the validity of doing that. I gave up on #277 because of the same reason. I couldn't think of a way to reasonably re-parameterize a part of a parameterized polymer. Programmatically, to make the net charges match, In the command line script where there's a streamlined preparation (parameterize is called only once), we can set a combination of flags to forbid template assignment when PQR is the input. Yes, making template matching stricter would be helpful and neccessary. In API, or in the future when integrated with a builder, there isn't a good way to prevent this usage: When there's an incoming assignment or edit, the monomer needs to be re-parameterized. I understand that if the charge model is read and there's no internal mechanism to compute with the same charge model, then the updated charges after the edit can become invalid or inconsistent with the original charge model. |
This is for #264. PQR is a file format similar to PDB and contains Q (charge) and R (radius). The major programs that uses PQR are PDB2PQR and APBS. Being able to parse PQR would allow us to directly get the computed charges for Polymers with available models in PDB2PQR (PARSE, AMBER, etc.).
This PR is adapted from the PQR parser in PDB2PQR and the existing (RDKit-based) method in Meeko to create Polymer from PDB. Specifically, the partial charge will be first parsed into atoms in a monomer's
raw_rdkit_mol
. Next, to transfer it to the monomer'spadded_mol
andmolsetup
, aget_atomprop_from_raw
option is added to functionmonomer.parameterize
. This needs to be a dict, with keys of atom property name and values of corresponding default values. This additional function may be re-used to pass on other properties. Radius from PQR is also parsed, but currently not transferred toraw_rdkit_mol
,padded_mol
ormolsetup
.If more people find it useful, we can add option
--read_pqr
, and expose option--charge_model
tomk_prepare_receptor.py
. Might need #277 to merge first before further edits on the command line scripts.