io
¶
Functions related to reading and writing data.
-
class
pdb2pqr.io.
DuplicateFilter
[source]¶ Filter duplicate messages.
-
pdb2pqr.io.
dump_apbs
(output_pqr, output_path)[source]¶ Generate and dump APBS input files related to output_pqr.
Parameters:
-
pdb2pqr.io.
get_definitions
(aa_path='AA.xml', na_path='NA.xml', patch_path='PATCHES.xml')[source]¶ Load topology definition files.
Parameters: Returns: topology Definitions object.
Return type:
-
pdb2pqr.io.
get_molecule
(input_path)[source]¶ Get molecular structure information as a series of parsed lines.
Parameters: input_path – structure file PDB ID or path Returns: (list of molecule records, Boolean indicating whether entry is CIF) Return type: ([str], bool) Raises: RuntimeError – problems with structure file
-
pdb2pqr.io.
get_old_header
(pdblist)[source]¶ Get old header from list of
pdb
objects.Parameters: pdblist ([]) – list of pdb
block objectsReturns: old header as string Return type: str
-
pdb2pqr.io.
get_pdb_file
(name)[source]¶ Obtain a PDB file.
First check the path given on the command line - if that file is not available, obtain the file from the PDB webserver at http://www.rcsb.org/pdb/
Todo
This should be a context manager (to close the open file).
Todo
Remove hard-coded parameters.
Parameters: name (str) – name of PDB file (path) or PDB ID Returns: file-like object containing PDB file Return type: file
-
pdb2pqr.io.
print_biomolecule_atoms
(atomlist, chainflag=False, pdbfile=False)[source]¶ Get PDB-format text lines for specified atoms.
Parameters: Returns: list of strings, each representing an atom PDB line
Return type: [str]
-
pdb2pqr.io.
print_pqr_header
(pdblist, atomlist, reslist, charge, force_field, ph_calc_method, ph, ffout, include_old_header=False)[source]¶ Print the header for the PQR file.
Parameters: - pdblist ([str]) – list of lines from original PDB with header
- atomlist ([Atom]) – a list of atoms that were unable to have charges assigned
- reslist ([Residue]) – a list of residues with non-integral charges
- charge (float) – the total charge on the biomolecule
- force_field (str) – the forcefield name
- ph_calc_method (str) – pKa calculation method
- ph (float) – pH value, if any
- ffout (str) – forcefield used for naming scheme
Returns: the header for the PQR file
Return type:
-
pdb2pqr.io.
print_pqr_header_cif
(atomlist, reslist, charge, force_field, ph_calc_method, ph, ffout, include_old_header=False)[source]¶ Print the header for the PQR file in CIF format.
Parameters: - atomlist ([Atom]) – a list of atoms that were unable to have charges assigned
- reslist ([Residue]) – a list of residues with non-integral charges
- charge (float) – the total charge on the biomolecule
- force_field (str) – the forcefield name
- ph_calc_method (str) – pKa calculation method
- ph (float) – pH value, if any
- ffout (str) – forcefield used for naming scheme
Returns: the header for the PQR file
Return type:
-
pdb2pqr.io.
read_dx
(dx_file)[source]¶ Read DX-format volumetric information.
The OpenDX file format is defined at <https://www.idvbook.com/wp-content/uploads/2010/12/opendx.pdf`.
Note
This function is not a general-format OpenDX file parser and makes many assumptions about the input data type, grid structure, etc.
Todo
This function should be moved into the APBS code base.
Parameters: dx_file (file) – file object for DX file, ready for reading as text Returns: dictionary with data from DX file Return type: dict Raises: ValueError – on parsing error
-
pdb2pqr.io.
read_pqr
(pqr_file)[source]¶ Read PQR file.
Parameters: pqr_file (file) – file object ready for reading as text Returns: list of atoms read from file Return type: [Atom]
-
pdb2pqr.io.
read_qcd
(qcd_file)[source]¶ Read QCD (UHDB QCARD format) file.
Parameters: qcd_file (file) – file object ready for reading as text Returns: list of atoms read from file Return type: [Atom]
-
pdb2pqr.io.
setup_logger
(output_pqr, level='DEBUG')[source]¶ Setup the logger.
Setup logger to output the log file to the same directory as PQR output.
Parameters:
-
pdb2pqr.io.
test_dat_file
(name)[source]¶ Test for the forcefield file with a few name permutations.
Parameters: name (str) – the name of the dat file Returns: the path to the file Return type: Path Raises: FileNotFoundError – file not found
-
pdb2pqr.io.
test_for_file
(name, type_)[source]¶ Test for the existence of a file with a few name permutations.
Parameters: Returns: path to file
Raises: FileNotFoundError – if file not found
Return type: Path
-
pdb2pqr.io.
test_names_file
(name)[source]¶ Test for the .names file that contains the XML mapping.
Parameters: name (str) – the name of the forcefield Returns: the path to the file Return type: Path Raises: FileNotFoundError – file not found
-
pdb2pqr.io.
test_xml_file
(name)[source]¶ Test for the XML file with a few name permutations.
Parameters: name (str) – the name of the dat file Returns: the path to the file Return type: Path Raises: FileNotFoundError – file not found
-
pdb2pqr.io.
write_cube
(cube_file, data_dict, atom_list, comment='CPMD CUBE FILE.')[source]¶ Write a Cube-format data file.
Cube file format is defined at <https://docs.chemaxon.com/display/Gaussian_Cube_format.html>.
Todo
This function should be moved into the APBS code base.
Parameters: