-
Notifications
You must be signed in to change notification settings - Fork 16
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
Residue Name and Serial Number in Atom struct #52
Comments
Maybe the easiest would be to add the residue information to your points in the Rtree. Would the following code work for your use case? In this way you will have all information you need while the structures will remain as minimalistic as possible. PointWithData::new(((residue.name(), residue..serial_number()), atom), atom.pos()) For your information the technically the for residue in &pdb.residues() {
for atom in &residue.atoms() {
// The radius code can be simplified (see https://docs.rs/pdbtbx/0.6.1/pdbtbx/struct.Atom.html#method.atomic_radius)
// Also if you feel the name could be better let me know, I am thinking about renaming it to vdw_radius and including other radii as well
let contacts = tree.locate_within_distance(atom.pos(), atom.atomic_radius());
for (other_residue, other_atom) in contacts {
if other_atom < atom // Internally uses the serial number, available since v0.6.0
// This is how testing for residue equality could look
&& other_residue.0 != residue.name()
&& other_residue.1 != residue.serial_number()
// And the protein backbone
&& !(other_residue.0 == Some("C")
&& residue.name() == Some("N")
&& other_residue.1 + 1 == residue.serial_number())
{
table.add_row(row![
bByFd =>
other_atom.serial_number(),
other_atom.name(),
other_residue.0,
atom.serial_number(),
atom.name(),
residue.name(),
format!("{:.2}", atom.distance(other_atom))]);
}
}
}
} I also took the liberty to change some functions to ones I built into pdbtbx, use whatever you like, but I try to include such functions for general use. So if you find yourself define a couple functions like that, please report them so I can include them in the library. Edit: I took the liberty to colour your code example (by adding |
Yes, that's a good idea, thanks! Your code doesn't quite compile like this but I was able to make it work. |
Okay, so I have the following situation:
This function builds an R-Tree from Atoms and uses that to conduct searches for other Points that are spatially nearby. The idea is to use such information to find clashes of atoms that are too close by (had a problem with such a case recently). In order to filter out results from atoms that belong to the same residue (and thus are close to each other by construction) I use the information about the respective residue that I stored in the Atom structs.
During the process of refactoring my code with pdbtbx I couldn't think of a straightforward way to do this. In most cases I can get what I need by just iterating over residues and the atoms within them but here I only have the Points in the R-Tree as results which are Atom structs. I would have to do a separate iteration over the PDB struct to determine which residues these belonged to and then go from there.
So for cases such as this I would propose to add a
residue_serial_number
andresidue_name
field to the Atom struct (or maybe re-add since I think you had something like this at some point). If the respective fields of the Residue struct are kept, this should not break existing code or cause trouble with ownership, yes? I realize this would necessitate changing the instantiation methods and unit test and I tried implementing this myself but failed making the macro errors that cropped up go away...What are your thoughts on this?
The text was updated successfully, but these errors were encountered: