conkit.core.distogram module

Distogram container used throughout ConKit

class Distogram(id)[source]

Bases: conkit.core.contactmap.ContactMap

A distogram object to store all associated information. This class inherits methods and attributes from ContactMap

Examples

>>> import numpy as np
>>> from conkit.core import Distance
>>> from conkit.core import Distogram
>>> distogram = Distogram("example")
>>> distogram.add(Distance(1, 25, (0.25, 0.45, 0.25, 0.05), ((0, 4), (4, 6), (6, 8), (8, np.inf))))
>>> distogram.add(Distance(7, 19, (0.15, 0.15, 0.60, 0.1), ((0, 4), (4, 6), (6, 8), (8, np.inf))))
>>> print(distogram)
Distogram(id="example" ndistances=2)
id

A unique identifier

Type:str
original_file_format

The original file format used to create the Distogram instance

Type:str
ndistances

The number of Distance instances in the Distogram

Type:int
as_array(seq_len=None, get_weigths=False)[source]
Transform the Distogram instance into a :obj:numpy.array instance with shape
(seq_len, seq_len) where each element represents the predicted distance between residues
Parameters:
  • seq_len (int, optional) – Sequence length. If not provided, it will be pulled from sequence [default: None]
  • get_weigths (bool, optional) – If True the resulting array contains the confidence for each predicted distance rather than actual distances [default: False]
Returns:

numpy.array instance that represents the distogram. Note: change of residue indexing, now starts in 0

Return type:

numpy.array

Raises:

ValueError – No seq_len was provided and sequence is not defined

as_contactmap(distance_cutoff=8)[source]

Create a ContactMap instance with the contacts present in this Distogram instance.

Parameters:distance_cutoff (int, float) – The distance cutoff used to consider a residue pair within contact of each other
Returns:A contactmap with the contacts present in this distogram instance.
Return type:ContactMap
static calculate_rmsd(prediction, model, seq_len=None, calculate_wrmsd=False)[source]

Calculate the RMSD between two Distogram instances.

Parameters:
  • prediction (Distogram) – A ConKit Distogram used as the prediction for the RMSD
  • model (Distogram) – A ConKit Distogram used as the model to calculate the RMSD
  • seq_len (int, optional) – Sequence length. If not provided, it will be pulled from sequence [default: None]
  • calculate_wrmsd (bool) – If set to True wRMSD is calculated using distance confidence scores [default: False]
Returns:

A list of floats with the RMSD values along the sequence

Return type:

list

Raises:

ValueError – other is not a Distogram instance.

find_residues_within(resnum, distance_cutoff)[source]

Find all residues within a given distance of a given residue

Parameters:
  • resnum (int) – The residue number of the residue of interest
  • distance_cutoff (int, float) – The distance cutoff used to find residues
Returns:

A set with the residue numbers of residues within the given distance

Return type:

set

get_absent_residues(seq_len=None)[source]

Get residues not represented by any Distance instance

Parameters:seq_len (int, optional) – Sequence length. If not provided, it will be pulled from sequence [default: None]
Returns:A list of absent residues
Return type:list
Raises:ValueError – No seq_len was provided and sequence is not defined
get_unique_distances(inplace=False)[source]

Filter the Distance instances so that each residue pairs is present only once

Parameters:inplace (bool, optional) – Replace stored distances with the unique distances in the current instance [default: False]
Returns:ContactMap instance, regardless of inplace
Return type:ContactMap
static merge_arrays(distogram_1, distogram_2)[source]

Take two Distogram instances and merge them together into the same numpy.array instance. Each half square in this array will correspond with the predicted distances at each hierarchy

Parameters:
  • distogram_1 (Distogram) – First Distogram instance, used to populate top half square of the array
  • distogram_2 (Distogram) – Second Distogram instance, used to populate lower half square of the array
Returns:

numpy.array instance that represents the combined distograms.

Return type:

numpy.array

Raises:
ndistances

The number of Distance instances

Returns:The number of distance pairs in the Distogram
Return type:int
original_file_format

The original file format used to create the Distogram instance

reshape_bins(new_bins)[source]

Reshape the predicted distance bins for all Distance instances. This will update distance_scores and distance_bins to fit the new bins.

Parameters:new_bins (tuple) – A tuple of tuples, where each element corresponds with the upper and lower edges of the intervals for the new distance bins
Raises:ValueError – The new distance bins are not valid