Comments (2)
Yes, that's a good idea, thanks! Your code doesn't quite compile like this but I was able to make it work.
Some minor points: To insert a PointWithData into the RTree object the point needs to be an array and the pos
method returns a tuple. That's why I constructed this manually from the x, y and z fields.
I was aware of the atomic_radius
method, in fact I somewhat stole the idea (as you may have recognized). However, I saw the need to implement several different values for the radius
variable in order to check for different levels of "closeness" of all the atoms. What I needed most was a way to check for atoms that are so close that their Lennard-Jones-Potential term will explode in a MM calculation and the atomic radius that's currently defined in pdbtbx is too large for this. For this specific use case I used something completely arbitrary but implementing several radii for several purposes might be worthwhile somewhere down the road.
Otherwise, I'm currently in the process of refactoring what I have to make use of what you wrote as much as possible so I'll make use of the methods you provided as well as I can but it takes a while to change everything. For now I'm trying to get it to work first and then make it more streamlined.
Thanks again for your great work and the help! I really appreciate it!
from pdbtbx.
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 residue.serial_number()
could occur multiple times, if this is a problem you should also use the residue.insertion_code()
. Using this you should be able to rewrite your example to the following:
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.
Please let me know if this works for you, otherwise I will think about something else.
Edit: I took the liberty to colour your code example (by adding rust
after the triple quotes to mark the start of the code block)
from pdbtbx.
Related Issues (20)
- Support pdbML HOT 2
- Add SASA support HOT 14
- Panic in `save/pdb.rs:517:29` at `Option::unwrap()` on a `None` value HOT 3
- Issues with `remove_models_except` implementation HOT 2
- Crates.io new version Request HOT 1
- Bad handling of PDB files containing mixed upper and lower case chains HOT 3
- Maybe make a Discord? HOT 2
- Bad Models in PDB HOT 1
- ReadOptions
- Utilities? HOT 6
- REMARK Line Length Enforcement HOT 2
- Fall back strategy for headerless PDB files. HOT 2
- Read option to only parse `ATOM` records HOT 5
- Finish implementing the `ReadOptions`
- Customize `StrictnessLevel` HOT 9
- Refactor long functions
- Check memory footprint
- Panic while parsing HOT 3
- Unable to load poor-quality PDBs HOT 6
- Allow for the use of compressed files HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pdbtbx.