conkit.plot.tools module

Internal utility functions

class ColorDefinitions[source]

Bases: object

A class storing all color definitions for the various plots for fast and easy handling

AA_ENCODING = {'A': '#882D17', 'C': '#F3C300', 'D': '#875692', 'E': '#F38400', 'F': '#A1CAF1', 'G': '#BE0032', 'H': '#C2B280', 'I': '#848482', 'K': '#008856', 'L': '#E68FAC', 'M': '#0067A5', 'N': '#F99379', 'P': '#604E97', 'Q': '#F6A600', 'R': '#B3446C', 'S': '#DCD300', 'T': '#8DB600', 'V': '#654522', 'W': '#E25822', 'X': '#000000', 'Y': '#2B3D26'}
ALIGNED = '#3d8beb'
CORRECT = '#40eef7'
ERROR = '#f54242'
FACTOR1 = '#B5DD2B'
GENERAL = '#000000'
L20CUTOFF = '#B5DD2B'
L5CUTOFF = '#3F4587'
MATCH = '#0F0B2C'
MISALIGNED = '#f7ba40'
MISMATCH = '#DC4869'
PRECISION50 = '#3F4587'
SCORE = '#3299a8'
STRUCTURAL = '#D8D6D6'
calculate_zscore(observed_score, population_scores)[source]

Calculate the Z-Score for a given population of values. Z-Score = (score - mean) / stdev

Parameters:
  • observed_score (float) – The observed score used to calculate the Z-Score
  • population_scores (list) – A list containing the scores observed across the samples in the population
Returns:

The calculated Z-Score

Return type:

float

convolution_smooth_values(x, window=5)[source]

Use convolutions to smooth a list of numeric values

Parameters:
  • x (list, tuple) – A list with the numeric values to be smoothed
  • window (int) – The residue window to be used to smooth values [default: 5]
Returns:

A list with the smoothed numeric values

Return type:

list

find_minima(data, order=1)[source]

Find the minima in a 1-D list

Parameters:
  • data (list, tuple) – A list of values
  • order (int, optional) – The order, i.e. number of points next to point to consider
Returns:

A list of indices for minima

Return type:

list

Warning

For multi-dimensional problems, see argrelmin().

Raises:
get_adjusted_aspect(ax, aspect_ratio)[source]

Adjust the aspect ratio

Parameters:
  • ax (Axes) – A Axes instance
  • aspect_ratio (float) – The desired aspect ratio for Axes
Returns:

The required aspect ratio to achieve the desired one

Return type:

float

Warning

This function only works for non-logarithmic axes.

get_cmap_validation_metrics(model_cmap_dict, predicted_cmap_dict, sequence, absent_residues)[source]

For a given observed contact map and predicted contact map calculate a series of validation metrics at each residue position (Accuracy, FN, FNR, FP, FPR, Sensitivity, Specificity)

Parameters:
  • model_cmap_dict (dict) – Dictionary representation of the contact map observed in the model
  • predicted_cmap_dict (dict) – Dictionary representation of the predicted contact map
  • sequence (Sequence) – The sequence of the model to be validated
  • absent_residues (list, tuple, set) – The residues that are missing from the model
Returns:

Two lists with the raw/smoothed values of each validation metric at each residue position

Return type:

tuple

get_points_on_circle(radius, h=0, k=0)[source]

Calculate points on a circle with even spacing

Parameters:
  • radius (int) – The radius of the circle
  • h (int, optional) – The x coordinate of the origin
  • k (int, optional) – The y coordinate of the origin
Returns:

The list of coordinates for each point

Return type:

list

get_radius_around_circle(p1, p2)[source]

Obtain the radius around a given circle

Parameters:
Returns:

The radius for points so p1 and p2 do not intersect

Return type:

float

get_residue_ranges(numbers)[source]

Given a list of integers, creates a list of ranges with the consecutive numbers found in the list.

Parameters:numbers (list) – A list of integers
Returns:A list with the ranges of consecutive numbers found in the list
Return type:list
get_rmsd(distogram_1, distogram_2, calculate_wrmsd=True)[source]

Calculate the RMSD between two different distograms

Parameters:
  • distogram_1 (Distogram) – Distogram 1
  • distogram_2 (Distogram) – Distogram 2
  • calculate_wrmsd (bool) – If True then the WRMSD is calculated using the confidence scores from distogram 1
Returns:

Two lists with the raw/smoothed RMSD values at each residue position

Return type:

tuple

get_zscores(model_distogram, predicted_cmap_dict, absent_residues, *metrics)[source]

Calculate the Z-Scores for a series of metrics at each residue position using the population of residues within 10A

Parameters:
  • model_distogram (Distogram) – Distogram of the model that will be validated
  • predicted_cmap_dict (dict) – Dictionary representation of the predicted contact map
  • absent_residues (list, tuple, set) – The residues that are missing from the model
  • *metrics (list) – The mertics for which the Z-Scores will be calculated
Returns:

A list of lists where each sublist contains the Z-Scores for the input metrics across all the residues. The sublists containing the Z-Scores are ordered in the same original order as in the input *metrics

Return type:

list

is_executable(executable)[source]

Check if a given program can be executed

Parameters:

executable (str) – The path or name for an executable

Returns:

The absolute path to the executable

Return type:

str

Raises:
parse_map_align_stdout(stdout)[source]

Parse the stdout of map_align and extract the alignment of residues.

Parameters:stdout (str) – Standard output created with map_align
Returns:A dictionary where aligned residue numbers in map_b are the keys and residue numbers in map_a values. Only misaligned regions are included.
Return type:dict