4.2.1. propka.input¶
4.2.1.1. Input handling¶
Input routines.
Functions
|
TODO - figure out what this function does. |
|
Get atom lines from a PROPKA input file. |
|
Get atom lines from PDB file. |
|
Open file or file-like stream for reading. |
|
Read input file or stream (PDB or PROPKA) for a molecular container |
|
Read a parameter file. |
|
Parse a PDB file. |
|
Read PROPKA input file for molecular container. |
-
propka.input.
get_atom_lines_from_input
(input_file, tags=['ATOM ', 'HETATM'])[source]¶ Get atom lines from a PROPKA input file.
- Parameters
input_file – input file
tags – tags defining atom lines
- Yields
conformation container, list of atoms
-
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)[source]¶ Open file or file-like stream for reading.
TODO - convert this to a context manager
- Parameters
input_file – path to file or file-like object. If file-like object,
will attempt seek (then) –
-
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_container –
MolecularContainer
object.stream – optional filestream handle. If
None
, then openfilename
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 aMolecularContainer
object namedmol_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 thestream
argument. Since file-like objects do not usually have an associated file name, an appropirate file name should be passed to thefilename
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 either .pdb or .propka_input) and also uses that givenfilename
to assign a name to the inputMolecularContainer
object.>>> read_molecule_file('test.pdb', mol_container, stream=string_io_object) <propka.molecular_container.MolecularContainer at 0x7f6e0c8f2310>
-
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