# `utilities`

Utilities for the PDB2PQR software suite.

Code author: Todd Dolinsky

Code author: Yong Huang

Code author: Nathan Baker

Add one 3-dimensional point to another.

Parameters:
Returns:

list of coordinates equal to coords2 + coords1

Return type:

numpy.ndarray

pdb2pqr.utilities.analyze_connectivity(map_, key)[source]

Analyze the connectivity of a given map using the key value.

Parameters:
• map (dict) – map to analyze

• key (str) – key value

Returns:

list of connected values to the key

Return type:

list

pdb2pqr.utilities.angle(coords1, coords2, coords3)[source]

Get the angle between three coordinates.

Parameters:
Returns:

angle between the atoms (in degrees)

Return type:

float

pdb2pqr.utilities.cross(coords1, coords2)[source]

Find the cross-product of one 3-dimensional point with another.

Parameters:
Returns:

list of coordinates equal to coords2 cross coords1

Return type:

numpy.ndarray

pdb2pqr.utilities.dihedral(coords1, coords2, coords3, coords4)[source]

Calculate the dihedral angle from four atoms’ coordinates.

Parameters:
• coords1 ([float, float, float]) – one of four coordinates of form [x,y,z]

• coords2 ([float, float, float]) – one of four coordinates of form [x,y,z]

• coords3 ([float, float, float]) – one of four coordinates of form [x,y,z]

• coords4 ([float, float, float]) – one of four coordinates of form [x,y,z]

Returns:

the angle (in degrees)

Return type:

float

pdb2pqr.utilities.distance(coords1, coords2)[source]

Calculate the distance between two coordinates.

Parameters:
Returns:

distance between the two coordinates

Return type:

float

pdb2pqr.utilities.dot(coords1, coords2)[source]

Find the dot-product of one 3-dimensional point with another.

Parameters:
Returns:

list of coordinates equal to the inner product of coords2 with coords1

Return type:

numpy.ndarray

pdb2pqr.utilities.factorial(num)[source]

Returns the factorial of the given number.

Parameters:

num (int) – number for which to compute factorial

Returns:

factorial of number

Return type:

int

pdb2pqr.utilities.noninteger_charge(charge, error_tol=0.001) str[source]

Test whether a charge is an integer.

Parameters:
• charge (float) – value to test

• error_tol (float) – absolute error tolerance

Returns:

string with descripton of problem or empty string if no problem

pdb2pqr.utilities.normalize(coords)[source]

Normalize a set of coordinates to unit vector.

Parameters:

coords ([float, float, float]) – coordinates of form [x,y,z]

Returns:

normalized coordinates

Return type:

numpy.ndarray

pdb2pqr.utilities.shortest_path(graph, start, end, path=[])[source]

Find the shortest path between two nodes.

Uses recursion to find the shortest path from one node to another in an unweighted graph. Adapted from http://www.python.org/doc/essays/graphs.html

Parameters:
• graph (dict) – a mapping of the graph to analyze, of the form {0: [1,2], 1:[3,4], …} . Each key has a list of edges.

• start (str) – the ID of the key to start the analysis from

• end (str) – the ID of the key to end the analysis

• path (list) – optional argument used during the recursive step to keep the current path up to that point

Returns:

list of the shortest path or `None` if start and end are not connected

Return type:

list

pdb2pqr.utilities.sort_dict_by_value(inputdict)[source]

Sort a dictionary by its values.

Parameters:

inputdict (dict) – the dictionary to sort

Returns:

list of keys sorted by value

Return type:

list

pdb2pqr.utilities.subtract(coords1, coords2)[source]

Suntract one 3-dimensional point from another.

Parameters:
Returns:

list of coordinates equal to coords2 - coords1

Return type:

numpy.ndarray