Skip to content
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

Enable PointMutationExecutor input of solvated pdbs #967

Merged
merged 9 commits into from
Mar 29, 2022

Conversation

zhang-ivy
Copy link
Contributor

Description

Allow the PointMutationExecutor to accept solvated PDBs (previously, it only accepted solute PDBs)

Motivation and context

Resolves #???

How has this been tested?

Change log


@codecov
Copy link

codecov bot commented Mar 15, 2022

Codecov Report

Merging #967 (9f11c3e) into main (2c1ea09) will decrease coverage by 0.90%.
The diff coverage is 44.64%.

@@ -141,6 +144,8 @@ def __init__(self,
map of new to old sidechain atom indices to add to the default map (by default, we only map backbone atoms and CBs)
demap_CBs : bool, default False
whether to remove CBs from the mapping
solvate : bool, default True
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you clarify when solvation happens. perses does solvate protein and protein:ligand systems. i think the difference is when you are solvating, or rather, whether you have provided a pre-solvated pdb/structure file. perhaps this should change the name of the argument you are using. can you put into the docs that if False, it should be pre-solvated. Also, i was going to suggest adding a sanity check that will check if there are waters in the struct file/topology and raise an error if there are waters, but one has already specified solvate=True. Then again, if the pdb contains xtal waters that are important, that error would be erroneous. maybe adding a sanity exception error if there are lots of waters in the pdb structure.

Copy link
Contributor Author

@zhang-ivy zhang-ivy Mar 15, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you put into the docs that if False, it should be pre-solvated.

yes

Also, i was going to suggest adding a sanity check that will check if there are waters in the struct file/topology and raise an error if there are waters, but one has already specified solvate=True. Then again, if the pdb contains xtal waters that are important, that error would be erroneous.

Yes, I thought about throwing an error like this, but like you said, if there are crystal waters present, but the PDB is not actually solvated, the error would still be present, which we don't want.

complex_positions = unit.Quantity(value=complex_positions_vec3, unit=unit.nanometer)
else:
complex_topology = ligand_topology
complex_positions = ligand_positions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the exception for pre-existing waters could go here i guess?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, that's the whole point of the else part of this logical branch. if the topology is already solvated, we're assuming its the full complex (not just the ligand), so we don't need to combine topologies anymore.

ionic_strength, box_dimensions)
else:
solvated_topology = topology
solvated_positions = unit.quantity.Quantity(value=np.array(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there might be an issue here associated with the solvate function giving a tuple of posits rather than a list, but we'll see what the test says

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the tests pass, so i don't think there is any problem with this.


return solvated_topology, solvated_positions, solvated_system
return solvated_topology, solvated_positions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changing the returnable can be problematic. can you return the solvated system, too?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you elaborate on why you think changing the returned variables is problematic? This _solvate() function is only ever called in the __init__ of PointMutationExecutor, and I made sure to properly adjust the code in the __init__ to account for the change in returned variables. Therefore, I don't think its a problem.

I moved the code for creating the system to be outside of the _solvate function (see line 269). This way, if the users specifies a presolvated PDB as input, a system can still be generated without calling _solvate.

@@ -13,7 +13,7 @@ def test_PointMutationExecutor():
ionic_strength=0.15 * unit.molar,
flatten_torsions=True,
flatten_exceptions=True,
conduct_endstate_validation=False,
conduct_endstate_validation=False
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why remove the trailing comma here?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -13,7 +13,7 @@ def test_PointMutationExecutor():
ionic_strength=0.15 * unit.molar,
flatten_torsions=True,
flatten_exceptions=True,
conduct_endstate_validation=False,
conduct_endstate_validation=False
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

perses/tests/test_relative_point_mutation_setup.py Outdated Show resolved Hide resolved
perses/tests/test_relative_point_mutation_setup.py Outdated Show resolved Hide resolved
@mikemhenry
Copy link
Contributor

mikemhenry commented Mar 22, 2022

Oh my, I do not know how my review got posted so many times! @zhang-ivy the only small nit I have is to keep the trailing comma, the reason it is nice to have a trailing comma is that when later you add another argument or something, the diff is cleaner since you then won't have (as part of the diff) adding a comma to the line above.

@zhang-ivy
Copy link
Contributor Author

@mikemhenry : Ah thanks for the clarification -- I was wondering why you had left that in. I removed it because it seemed like you left it in by accident / syntactically its unnecessary to leave an extra comma when there are no arguments after. But if you'd prefer us to keep the comma in, feel free to add a suggested commit?

@mikemhenry
Copy link
Contributor

@dominicrufa are you happy with this PR or do you have more questions?

@mikemhenry
Copy link
Contributor

@mikemhenry : Ah thanks for the clarification -- I was wondering why you had left that in. I removed it because it seemed like you left it in by accident / syntactically its unnecessary to leave an extra comma when there are no arguments after. But if you'd prefer us to keep the comma in, feel free to add a suggested commit?

Done! Adding the comma makes the diffs cleaner/more obvious on what is being added to a function call/signature, but you are correct that they don't do anything functional AST wise!

@zhang-ivy
Copy link
Contributor Author

@mikemhenry : Thanks! Just messaged @dominicrufa on slack and he said this is ok to merge -- please merge when you get a chance!

@mikemhenry mikemhenry enabled auto-merge (squash) March 29, 2022 05:44
@mikemhenry mikemhenry merged commit 59c77fb into main Mar 29, 2022
@mikemhenry mikemhenry deleted the enable-solvated-input branch March 29, 2022 06:04
@mikemhenry mikemhenry mentioned this pull request Mar 31, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants