douweschulte / pdbtbx

A library to open/edit/save (crystallographic) Protein Data Bank (PDB) and mmCIF files in Rust.

Home Page:https://crates.io/crates/pdbtbx

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Human friendly find methods

douweschulte opened this issue · comments

It would be really nice if a 'human friendly' find method could be built in. This should allow for the selection of all matching hierarchies based on the given information. Every level in the hierarchy should have the option to present no information, the index, or any of the info of that level. An additional variant which gives mutable hierarchies is also useful.

//PDB
pub fn find(&'a self, model: ModelFind, chain: ChainFind, residue: ResidueFind, conformer: ConformerFind, atom: AtomFind) ->
 Vec<AtomConformerResidueChainModel<'a>> {
    //find all matching models and dispatch the find code to those models using their comparable find methods
   //integrate the model info in the resulting hierarchies
}

//eg ModelFind
pub enum ModelFind {
    NoInfo,
    Index(usize),
    SerialNumber(usize),
}

With the new implementation the interface is way nicer, many more things are possible, but the definition of terms and searches could be better. I am thinking about a macro like to following, but this should be thought out more.

search!(resname "VAL");
search!(atomser 123 ^ (element "C" & resnum 123));

Also allow for short circuiting to happen at the second term as well as the first. And write tests testing the short circuiting and simplifying behaviour of the code.