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
|
TODO - figure out what this function does. |
|
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. |
- 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,
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
streamargument, should be a path to the file to be read.mol_container –
MolecularContainerobject.stream – optional filestream handle. If
None, then openfilenameas a local file for reading.
- Returns
updated
MolecularContainerobject.- 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 aMolecularContainerobject 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.StringIOclass, instance. This is done by passing the object via thestreamargument. Since file-like objects do not usually have an associated file name, an appropirate file name should be passed to thefilenameargument. In this case,filenameis not opened for reading, but instead is used to help recognise the file type (based on the extension being .pdb) and also uses that givenfilenameto assign a name to the inputMolecularContainerobject.>>> 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.