kripodb.pharmacophores

kripodb.pharmacophores.FEATURE_TYPES = [{'color': 'ff33cc', 'element': 'He', 'key': 'LIPO', 'label': 'Hydrophobe'}, {'color': 'ff9933', 'element': 'P', 'key': 'POSC', 'label': 'Positive charge'}, {'color': '376092', 'element': 'Ne', 'key': 'NEGC', 'label': 'Negative charge'}, {'color': 'bfbfbf', 'element': 'As', 'key': 'HACC', 'label': 'H-bond acceptor'}, {'color': '00ff00', 'element': 'O', 'key': 'HDON', 'label': 'H-bond donor'}, {'color': '00ffff', 'element': 'Rn', 'key': 'AROM', 'label': 'Aromatic'}]

Types of pharmacophore feature types. List of dictionaries with the following keys

  • key, short identifier of type
  • label, human readable label
  • color, hex rrggbb color
  • element, Element used in kripo pharmacophore sdfile for this type
class kripodb.pharmacophores.PharmacophorePointsTable(h5file, expectedrows=0)[source]

Wrapper around pytables table to store pharmacohpore points

Parameters:
  • h5file (tables.File) – Pytables hdf5 file object which contains the pharmacophores table
  • expectedrows (int) – Expected number of pharmacophores. Required when hdf5 file is created, helps optimize compression

Pharmacophore points of a fragment can be retrieved using:

points = table['frag_id1']

points is a list of points, each point is a tuple with following columns feature type key, x, y and z coordinate. The feature type key is defined in FEATURE_TYPES.

Number of pharmacophore points can be requested using:

nr_points = len(table)

To check whether fragment identifier is contained use:

'frag_id1' in table
add_dir(startdir)[source]

Find *_pphore.sd.gz *_pphores.txt file pairs recursively in start directory and add them.

Parameters:startdir (str) – Path to a start directory
read_phar(infile)[source]

Read phar formatted file and add pharmacophore to self

Parameters:infile – File object of phar formatted file
class kripodb.pharmacophores.PharmacophoresDb(filename, mode='r', expectedrows=0, **kwargs)[source]

Database for pharmacophores of fragments aka sub-pockets.

Parameters:
  • filename (str) – File name of hdf5 file to write or read pharmacophores to/from
  • mode (str) – Can be ‘r’ for reading or ‘w’ for writing or ‘a’ for appending
  • expectedrows (int) – Expected number of pharmacophores. Required when hdf5 file is created, helps optimize compression
  • **kwargs – Passed to tables.open_file

Pharmacophore points of a fragment can be retrieved using:

points = db['frag_id1']

points is a list of points, each point is a tuple with following columns feature type key, x, y and z coordinate. The feature type key is defined in FEATURE_TYPES.

h5file

tables.File – Object representing an open hdf5 file

points

PharmacophorePointsTable – HDF5 table that contains pharmacophore points

add_dir(startdir)[source]

Find *_pphore.sd.gz *_pphores.txt file pairs recursively in start directory and add them.

Parameters:startdir (str) – Path to a start directory
append(other)[source]

Append pharmacophores in other db to self

Parameters:other (PharmacophoresDb) – The other pharmacophores database
close()[source]

Closes the hdf5file

Instead of calling close() explicitly, use context manager:

with PharmacophoresDb('data/pharmacophores.h5') as db:
    points = db['frag_id1']
read_phar(infile)[source]

Read phar formatted file and add pharmacophore to self

Parameters:infile – File object of phar formatted file
write_phar(outfile, frag_id=None)[source]

Write pharmacophore of frag_id as phar format to outfile

Parameters:
  • outfile (file) – File object to write to
  • frag_id (str) – Fragment identifier, if None all pharmacophores are written
kripodb.pharmacophores.as_phar(frag_id, points)[source]

Return pharmacophore in *.phar format.

See align-it for format description.

Parameters:
  • frag_id (str) – Fragment identifier
  • points (list) – List of points where each point is (key,x,y,z)
Returns:

Pharmacophore is *.phar format

Return type:

str

kripodb.pharmacophores.read_fragtxtfile(fragtxtfile)[source]

Read a fragment text file

Parameters:fragtxtfile – Filename of fragment text file
Returns:Dictionary where key is fragment identifier and value is a list of pharmacophore point indexes.
Return type:dict
kripodb.pharmacophores.read_fragtxtfile_as_file(fileobject)[source]

Read a fragment text file object which contains the pharmacophore point indexes for each fragment identifier.

File format is a fragment on each line, the line is space separated with fragment_identifier followed by the pharmacophore point indexes.

Parameters:fileobject (file) – File object to read
Returns:Dictionary where key is fragment identifier and value is a list of pharmacophore point indexes.
Return type:dict
kripodb.pharmacophores.read_pphore_gzipped_sdfile(sdfile)[source]

Read a gzipped sdfile which contains pharmacophore points as atoms

Parameters:sdfile (string) – Path to filename
Returns:List of Pharmacophore points
Return type:list
kripodb.pharmacophores.read_pphore_sdfile(sdfile)[source]

Read a sdfile which contains pharmacophore points as atoms

Parameters:sdfile (file) – File object with sdfile contents
Returns:List of pharmacophore points
Return type:list