steineggerlab / foldcomp

Compressing protein structures effectively with torsion angles
GNU General Public License v3.0
152 stars 14 forks source link

`foldcomp.open` - return empty structure string if structure is not found in database #54

Open valentynbez opened 6 months ago

valentynbez commented 6 months ago

https://github.com/steineggerlab/foldcomp/blob/b97c193e3029d861b6ca6b7c2970b562b779a4de/foldcomp/foldcomp.cxx#L333-L434

Current behaviour

Currently, there is no way to programmatically capture missing ids via Python interface. The missing ids are printed into non-capturable stderr .This would be a useful feature, as it will allow to troubleshoot problems. As error might indeed not be the best solution, I think it will be great if missing id's were still returned, but with an empty structure string.

ids = ["valid", "invalid"]
with foldcomp.open(database_path, ids=ids) as db:
    print("Here!") 
    for idx, pdb in db:
        print(idx, pdb)
Skipping entry invalid which is not in the database.
Here! 
valid {pdb_string}

Proposed behaviour

ids = ["invalid"]
with foldcomp.open(database_path, ids=ids) as db:
    print("Here!")
    for idx, pdb in db:
        print(idx, pdb)
Here!
valid {pdb_string}
invalid