Closed IAlibay closed 4 years ago
Related to #57
In propka 3.1, passing a "Named Stream" i.e. a Stream-like object that also provides a mocked filename that can be read via pathlib.Path (see: MDAnalysis.lib.util.NamedStream) instead of a path of an input PDB file would work.
Example (based on https://github.com/Becksteinlab/propkatraj):
import propka.run as pk import MDAnalysis as mda from MDAnalysisTests.datafiles import PSF, DCD u = mda.Universe(PSF, DCD) pstream = pstream = mda.lib.util.NamedStream(StringIO(), 'input.pdb') u.atoms.write(pstream) pstream.reset() mol = pk.single(pstream, optargs=['--quiet'])
As detailed in #82 using propka.run.single does not seem to currently work, however we would expect the following to work (it does not):
# based on test_basic_regression from propka.parameters import Parameters from propka.molecular_container import MolecularContainer from propka.input import read_parameter_file, read_molecule_file from propka.lib import loadOptions options = ['--quiet'] options += [str(Path(pstream))] args = loadOptions(options) parameters = read_parameter_file('propka.cfg', Parameters()) molecule = MolecularContainer(parameters, args) molecule = read_molecule_file(pstream, molecule) molecule.calculate_pka()
As far as I could tell, there are two main causes for this:
1) read_pdb passes input_path instead of input_file:
read_pdb
input_path
input_file
https://github.com/jensengroup/propka/blob/01debbf63dd51a7edac38e18d96b406abd532351/propka/input.py#L55-L56
2) open_file_for_reading does not work as expected.
open_file_for_reading
seek
Switching fseek -> seek and input_path -> input_file fixes things and does not seem to cause any issues in the regression tests.
fseek
Related issues
Related to #57
Expected behaviour
In propka 3.1, passing a "Named Stream" i.e. a Stream-like object that also provides a mocked filename that can be read via pathlib.Path (see: MDAnalysis.lib.util.NamedStream) instead of a path of an input PDB file would work.
Example (based on https://github.com/Becksteinlab/propkatraj):
Actual behaviour
As detailed in #82 using propka.run.single does not seem to currently work, however we would expect the following to work (it does not):
Causes
As far as I could tell, there are two main causes for this:
1)
read_pdb
passesinput_path
instead ofinput_file
:https://github.com/jensengroup/propka/blob/01debbf63dd51a7edac38e18d96b406abd532351/propka/input.py#L55-L56
2)
open_file_for_reading
does not work as expected.seek
.Possible fix
Switching
fseek
->seek
andinput_path
->input_file
fixes things and does not seem to cause any issues in the regression tests.