Possible race condition in main.run_propka()
bradakta opened this issue · 3 comments
While working on a project I received the error:
"Unexpected number (3) of atoms in residue ILE XXX X in conformation 1A"
.
This was strange because examination of the input showed all ILE atoms were present and matched other ILE residues that were successfully parsed. Digging further it became apparent that no atoms beyond the third atom in that residue were being parsed (I added a print statement to propka.input.get_atom_lines_from_pdb()
to verify). Checking the file handle I realized this was coming from a temporary file that was traced back to the following code in pdb2pqr/main.py:
with NamedTemporaryFile("wt", suffix=".pdb") as pdb_file:
for line in lines:
pdb_file.write(line)
pdb_path = pdb_file.name
parameters = pk_in.read_parameter_file(args.parameters, Parameters())
molecule = MolecularContainer(parameters, args)
molecule = pk_in.read_molecule_file(pdb_path, molecule)
It appears that a type of race condition might be occurring where file writing does not keep up with file reading. I'll reserve judgement as to whether or not this is a good way to move PDB data, but it appears to fail reliably, at least on python 3.10 (maybe this is version dependent?). I was able to fix the behavior by inserting a pdb_file.flush()
statement immediately after the for
loop.
Thank you for sharing this. Could you provide the command-line options you used to generate this error?
That's great - sorry, I was trying a bunch of stuff and it looks like I didn't encounter this via the command-line, but rather while using the python API to include it in my own script. However, I think I reproduced a similar error with:
pdb2pqr30 --ff PARSE --ffout AMBER --with-ph 7.4 --titration-state-method propka