API Documentation for barcodes

class BarcodeGenerator(df)

Generates binary barcodes representing the presence of interactions across MD frames.

Parameters:

df (pd.DataFrame) – DataFrame containing all interactions extracted from PLIP analysis.

Variables:

interactions (dict) – Dictionary mapping interaction types to their corresponding columns in the DataFrame.

generate_barcode(interaction)

Generates barcodes for a given interaction.

Parameters:

interaction (str) – Name of the interaction to generate a barcode for.

Returns:

Binary array with 1 representing the interaction is present in the corresponding frame.

Return type:

np.ndarray

interacting_water_ids(waterbridge_interactions)

Generates a list of all water ids that form water bridge interactions.

Parameters:

waterbridge_interactions (list) – list containing the names of all water bridge interactions.

Returns:

Unique water IDs that form waterbridge interactions.

Return type:

list

_generate_waterids_barcode(interaction)

Generates a barcode containing corresponding water ids for a given interaction.

Parameters:

interaction (str) – Name of the interaction to generate a barcode for.

Returns:

List with water IDs for frames where interaction is present, 0 otherwise.

Return type:

list

Note

Water IDs are obtained from the “WATER_IDX” column in the DataFrame.

_gather_interactions()

Gathers interaction column names grouped by the corresponding interaction type.

Returns:

Dictionary where the keys are interaction types and values are lists of corresponding column names.

Return type:

dict

class BarcodePlotter(df_all)

Visualizes interaction barcodes and waterbridge statistics using bar plots and pie charts.

Parameters:

df_all (pd.DataFrame) – Full interaction dataframe passed for plotting.

Variables:

barcode_gen (BarcodeGenerator) – Instance of BarcodeGenerator used to compute barcodes from interaction data.

plot_waterbridge_piechart(waterbridge_barcodes, waterbridge_interactions, fig_type)

Generates and saves pie charts showing the frequency of each of the water IDs participating in waterbridge interactions.

Parameters:
  • waterbridge_barcodes (dict) – Dictionary of waterbridge interaction barcodes.

  • waterbridge_interactions (list) – List of interaction column names related to waterbridge interactions.

  • fig_type (str) – Image file format for saving (e.g., ‘png’, ‘svg’).

Returns:

None. This function writes out a figure and does not return anything.

Return type:

None

plot_barcodes_grouped(interactions, interaction_type, fig_type)

Groups barcodes by ligand atom, plots individual and grouped barcodes, and saves them.

Parameters:
  • interactions (list) – List of interaction names to be grouped and visualized.

  • interaction_type (str) – The type of interaction (e.g., ‘donor’, ‘acceptor’, ‘waterbridge’).

  • fig_type (str) – Image file format for saving (e.g., ‘png’, ‘svg’).

Returns:

None. This function writes out a figure and does not return anything.

Return type:

None

_plot_barcodes(barcodes, save_path)

Plots barcodes of the interactions depending on the presence of the interaction.

Parameters:
  • barcodes (dict) – Dictionary where keys are interaction names and values are 1D numpy arrays (barcodes).

  • save_path (str) – Path to save the generated barcode plot image.

Returns:

None. This function writes out a figure and does not return anything.

Return type:

None