propka.input

Input handling

Input routines.

Changed in version 3.4.0: Methods to read PROPKA input files (read_propka() and get_atom_lines_from_input()) have been removed.

Functions

conformation_sorter(conf)

TODO - figure out what this function does.

get_atom_lines_from_pdb(pdb_file[, ...])

Get atom lines from PDB file.

open_file_for_reading(input_file)

Open file or file-like stream for reading.

read_molecule_file(filename, mol_container)

Read input file or stream (PDB or PROPKA) for a molecular container

read_parameter_file(input_file, parameters)

Read a parameter file.

read_pdb(pdb_file, parameters, molecule)

Parse a PDB file.

propka.input.conformation_sorter(conf)[source]

TODO - figure out what this function does.

propka.input.get_atom_lines_from_pdb(pdb_file, ignore_residues=[], keep_protons=False, tags=['ATOM  ', 'HETATM'], chains=None)[source]

Get atom lines from PDB file.

Parameters
  • pdb_file – PDB file to parse

  • ignore_residues – list of residues to ignore

  • keep_protons – bool to keep/ignore protons

  • tags – tags of lines that include atoms

  • chains – list of chains

propka.input.open_file_for_reading(input_file: Union[str, pathlib.Path, TextIO]) AbstractContextManager[TextIO][source]

Open file or file-like stream for reading.

Parameters
  • input_file – path to file or file-like object. If file-like object,

  • seek (then will attempt) –

propka.input.read_molecule_file(filename: str, mol_container, stream=None)[source]

Read input file or stream (PDB or PROPKA) for a molecular container

Parameters
  • filename (str) – name of input file. If not using a filestream via the stream argument, should be a path to the file to be read.

  • mol_containerMolecularContainer object.

  • stream – optional filestream handle. If None, then open filename as a local file for reading.

Returns

updated MolecularContainer object.

Raises

ValuError – if invalid input given

Examples

There are two main cases for using read_molecule_file. The first (and most common) is to pass the input file (filename) as a string which gives the path of the molecule file to be read (here we also pass a MolecularContainer object named mol_container).

>>> read_molecule_file('test.pdb', mol_container)
<propka.molecular_container.MolecularContainer at 0x7f6e0c8f2310>

The other use case is when passing a file-like object, e.g. a io.StringIO class, instance. This is done by passing the object via the stream argument. Since file-like objects do not usually have an associated file name, an appropirate file name should be passed to the filename argument. In this case, filename is not opened for reading, but instead is used to help recognise the file type (based on the extension being .pdb) and also uses that given filename to assign a name to the input MolecularContainer object.

>>> read_molecule_file('test.pdb', mol_container,
                       stream=string_io_object)
<propka.molecular_container.MolecularContainer at 0x7f6e0c8f2310>

Changed in version 3.4.0: PROPKA input files (extension: .propka_input) are no longer read.

propka.input.read_parameter_file(input_file, parameters)[source]

Read a parameter file.

Parameters
  • input_file – input file to read

  • parameters – Parameters object

Returns

updated Parameters object

propka.input.read_pdb(pdb_file, parameters, molecule)[source]

Parse a PDB file.

Parameters
  • pdb_file – file to read

  • parameters – parameters to guide parsing

  • molecule – molecular container

Returns

  1. list of conformations

  2. list of names

Return type

list with elements