samirelanduk / atomium

Python macromolecular parsing (with .pdb/.cif/.mmtf parsing and production)
https://atomium.bio
MIT License
102 stars 19 forks source link

Error with save #42

Open emarsh25 opened 1 year ago

emarsh25 commented 1 year ago

I am attempting to save a model I created from a set of atoms I got using the .atoms_in_sphere() function. This is the code and the traceback I am getting.

pdb = atomium.open(pdb_path) pdb.model.optimise_distances()

pocket_atoms = pdb.model.atoms_in_sphere((25.55,13.88,-29.54), 8)

pocket = atomium.structures.Residue(*pocket_atoms, id='A', name='A') x = set() x.add(pocket)

new_chain = atomium.Chain(id='A', *x) new_model = atomium.Model(new_chain) new_model.save("test.pdb")

Traceback (most recent call last): File "/home/ray/Pocket-Prediction/src/describe_pocket.py", line 182, in describe_pockets('./data/4bcf.pdb') File "/home/ray/Pocket-Prediction/src/describe_pocket.py", line 178, in describe_pockets get_pocket_atoms(pdb_path) File "/home/ray/Pocket-Prediction/src/describe_pocket.py", line 129, in get_pocket_atoms new_model.save("pocket_ctsb_test.pdb") File "/home/ray/anaconda3/lib/python3.8/site-packages/atomium/structures.py", line 231, in save string = structure_to_pdb_string(self) File "/home/ray/anaconda3/lib/python3.8/site-packages/atomium/pdb.py", line 565, in structure_to_pdb_string atom_to_atom_line(atom, lines) File "/home/ray/anaconda3/lib/python3.8/site-packages/atomium/pdb.py", line 606, in atom_to_atom_line residueid = int("".join([c for c in id if c.isdigit() or c == "-"])) ValueError: invalid literal for int() with base 10: ''

samirelanduk commented 1 year ago

It's expecting the residue ID to have at least some numeric component, but it's just 'A' here. If you change the line to:

pocket = atomium.structures.Residue(*pocket_atoms, id='1', name='A')

...instead it should work.

atomium 2.0 will be out soon, which won't have this requirement.