-
Notifications
You must be signed in to change notification settings - Fork 259
add findSurfaceResiduesListCharged.py #132
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
Conversation
Thanks @speleo3 , I forwarded the feedback to Teddy. He replied with some changes and a new file/API: https://pymolwiki.org/index.php/FindSurfaceCharge |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doesn't run properly if there are multiple objects in the selection (e.g. multiple objects in the workspace and you run the command without any provided arguments). Perhaps this should first detect the objects in the selection first and provide the charge for each object surface.
findSurfaceCharge.py
Outdated
cmd.iterate(selName, "exposed.add((resv))", space=locals()) | ||
cmd.delete(selName) | ||
|
||
selNameRes = cmd.get_unused_name("exposed_res_") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unused variable?
findSurfaceCharge.py
Outdated
cmd.iterate(allRes, "first.add((resv))", space=locals()) | ||
cmd.delete(allRes) | ||
|
||
selNameRes = cmd.get_unused_name("exposed_res_") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unused variable?
findSurfaceCharge.py
Outdated
|
||
first=sorted(first)[0] #firstRes | ||
#gets all charged amino acids on the surface | ||
reslist= [] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
reslist
appended, but never used?
findSurfaceCharge.py
Outdated
return selName | ||
|
||
|
||
def findSurfaceCharge(pH=7.0, folded=True, selection="all", cutoff=2.5): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might be helpful to also return the charge so that it's easier for the caller to obtain.
findSurfaceCharge.py
Outdated
cutoff = float(cutoff) | ||
|
||
selName = findSurfaceAtoms(selection, cutoff) | ||
|
||
exposed = set() | ||
cmd.iterate(selName, "exposed.add((resv))", space=locals()) | ||
cmd.delete(selName) | ||
|
||
selNameRes = cmd.get_unused_name("exposed_res_") | ||
|
||
exposed=sorted(exposed) #list of exposed residues |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
readability: would probably pull out to another function
get_exposed_residues(selection: str, cutoff: float) -> set:
or similar.
findSurfaceCharge.py
Outdated
first = set() | ||
allRes = findSurfaceAtoms(selection, 0) | ||
cmd.iterate(allRes, "first.add((resv))", space=locals()) | ||
cmd.delete(allRes) | ||
|
||
selNameRes = cmd.get_unused_name("exposed_res_") | ||
|
||
first=sorted(first)[0] #firstRes |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
readability: might be more readable to pull this out into its own func.
get_first_residue(selection: str) -> int:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks OK to me.
Some optional improvements:
- add type hints
- auto-format code (yapf, black, ...)
- add module docstring which points to the wiki page
folded
argument is not really needed since the user can passcutoff=0
Tests would be nice, but I understand that there is no infrastructure in place in the repo.
Merged. As separate commit 4fcf977 since Github doesn't seem to specific commit author to someone else if one performs a squash merge. |
Adding this script on behalf of Teddy Warner from MIT.
Script page on the Wiki: https://pymolwiki.org/index.php/FindSurfaceResiduesListCharged