Comments (7)
Maybe this is worth looking at in this context: https://docs.rs/rayon/1.5.0/rayon/index.html
Although I assume you're aware of this.
from pdbtbx.
Thanks for explaining! What I mostly didn't get was the fact that the chains
method that was called in the closure is the one implemented for the model
struct. I didn't realize at first because all these methods for all structs have the same name.
Now I've implemented parallel versions of these iterator constructor methods for all hierarchies using rayon
but so far I see little difference in preliminary tests. I'll look into it some more.
from pdbtbx.
Another comment: Since this library is built around iterators of the various structs, it might be a good idea to implement parallel variants of these with rayon
which itself provides high-level parallel iterator alternatives.
This should not be too hard to implement (I think) and leaves the choice whether or not to use those to the user. Since multithreading comes with some overhead, it would require some benchmarking to see if the typical iterator size generated from PDB files is worth doing this in parallel.
What are your thoughts on this?
from pdbtbx.
Those are exactly my thoughts, in this way I hope to provide multithreading to users when and only if they want to use it. I will have to figure out a bit more how to exactly get to that on the source code level, but that will be fixed in due time. If you are interested feel free to open a PR ;-)
from pdbtbx.
I've been wanting to add something to the library, however, I'm still in the process of learning Rust. The project that ended up using this library is the first (and only) nontrivial piece of code I've written in this language so far.
With that said, I'd be glad to help but will probably have to ask a couple of stupid questions along the way. For example, I don't understand how this method (and others like it) works:
pub fn chains(&self) -> impl DoubleEndedIterator<Item = &Chain> + '_ {
self.models.iter().flat_map(|a| a.chains())
}
It is supposed to return a double-ended Iterator with the items being references to a Chain
type. But inside the flat_map
the method calls itself?
from pdbtbx.
It is no problem for me to help you get started, I would be glad to help other people learn Rust. So if you feel like it feel free to get started!
The abovementioned method works in the following way. The flat_map
can be seen as a dedicated map(|a| ...).flatten()
method invocation. The map
method works the same in many other languages, it takes a n iterator of type A and runs a function on it to return type B, in this case type B is Iterator<Item=&Chain> by calling the chain
method on a single model (the method is independent on how this method in implemented on the model struct). The flatten
method then effectively iterates over all iterators in an iterator and so turns a type like Iterator<Item=Iterator<Item=A>> to Iterator<Item=A>, which gives the desired result of an Iterator<Item=&Chain> in this case.
I hope my explanation makes some sense, feel free to ask more question and to look at the documentation of this method in the rust docs https://doc.rust-lang.org/std/iter/trait.Iterator.html#method.flat_map.
If you feel like you want to talk a bit about Rust code or anything related to this PR more directly feel free to email me at the email address provided on my profile page.
Good luck and I look forward to answering more of your questions!
from pdbtbx.
Closed by #62.
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.