Skip to content

Channel clustering update - additional small changes to channel lining analysis and pymol visualization - #2286

Open
MatthewLicht wants to merge 22 commits into
prody:mainfrom
MatthewLicht:cluster_lining_update
Open

MatthewLicht wants to merge 22 commits into
prody:mainfrom
MatthewLicht:cluster_lining_update

Conversation

@MatthewLicht

@MatthewLicht MatthewLicht commented Nov 12, 2026 •

Copy link
Copy Markdown

Adding the classes ClusterCalculator, ChannelRecord, Cluster, and ClusteringRecord and associated functions to channels.py for clustering analysis of channel objects

Includes:
Functions for calculating distances between channels
Building distance matrices
Clustering data based on the distance matrices
Subclustering of clustered data
Assigning noise to data in agglomerative clustering
Evaluating the Quality of Clustering

Changing how the objectLining functions work so that information besides residues can easily be obtained. Is also slightly faster.
Orientation of residues to channel objects can now be obtained.

Updates to the visualization of cavities with PyMol

Small changes to the Channel class that prevents a bug when using multiprocessing features (cubcic splines were not getting pickled and the channel objects were not getting sent to the workers)

Attached is a jupyter notebook demonstration of the clustering analysis using VMAT (caseStudy2) files which are using in the tutorial for the trajectory analysis.

ChannelClusteringDemoFinal.ipynb

@MatthewLicht
MatthewLicht marked this pull request as draft November 12, 2026 03:03
@MatthewLicht
MatthewLicht marked this pull request as ready for review November 12, 2026 10:10

@karolamik13 karolamik13 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested the clustering functions using 20 frames from the caseStudy2 trajectory (247 channels). Everything worked well, and the PyMOL visualizations look reasonable.

I also noticed a few things in the code that might be worth improving:

  • In clusterChannels(), calc_stats=False seems to be ignored because ClusteringRecords always calls init_stats(). When calc_stats=True, the statistics may also be calculated twice.

  • In writeVoxelOccupancyPQR(), the default min_occupancy=0.0 includes voxels with zero occupancy. Perhaps occupancy > 0 should always be required to avoid writing empty voxels
    [ indices = np.argwhere((occupancy > 0) & (occupancy >= min_occupancy)) ]

  • There is a typo in the generated PyMOL script: "multipleand" should be "multiple and". The visualization worked after correcting it.
    [ if (multiple and clustering_name is not None): ]

  • In getObjectLiningInfo(), callbacks=None is the default, but the function calls callbacks.items() without checking for None. Perhaps a default callback could be assigned.
    [
    if callbacks is None:
    callbacks = {'Residues': getLiningResidues}
    ]

  • In getResidueOrientation(), the side-chain center is calculated as the average of atomic coordinates rather than the mass-weighted center of mass. The documentation should probably say geometric center. Also, residues without side chains (e.g., glycine) are excluded, which may make it difficult to match orientation values to residue indices. Returning NaN for these residues could help.

MatthewLicht and others added 4 commits November 13, 2026 12:02
…mum occupancy 0.2 and raises an error if the minimum occupancy is not greater than 0;fixed multipleand typo;added default callback assignment in getObjectLiningInfo;updated documentation in getResidueOrientation
MatthewLicht and others added 4 commits November 13, 2026 13:05
… into cluster_lining_update

changes on remtoe branch not present in local
…prevent negative numbers from being passed, changed indices argument so that zero-occupancy voxels are not included, but if minimum occupancy is 0.0 then all voxels with any positive occupancy will be included
@MatthewLicht

Copy link
Copy Markdown
Author
  • I removed init_stats so that stats should only be calculated during construction if calc_stats = True
  • In writeVoxelOccupancyPQR I added a check that prevents negative min_occupancy arguments from being passed and changed indices calculation to indices = np.argwhere((occupancy > 0) & (occupancy >= min_occupancy)) so that only non-zero occupancy voxels are ever written to the pqr file
  • multipleand typo is fixed
  • [ if callbacks is None: \n callbacks = {'Residues': getLiningResidues} ] added to getObjectLiningInfo
  • updated getResidueOrientation docstring and added handling for residues without sidechains (glycine)

Also, I see that all checks are failing, but they are failing on a test for calcSignatureCavities or for an InSty function. I have not changed anything with InSty or calcSignatureCavities and am unsure what is causing the checks to fail. Please advise.

@karolamik13 karolamik13 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi Matthew,
I looked through the changes and noticed a few issues that might explain some of the failing CI tests.

First, _infoAsListOfStrings() does not accept **kwargs, but both getSurfaceCavityResidueNames() and getChannelResidueNames() pass additional keyword arguments to it. For example, calcSignatureCavities() calls getSurfaceCavityResidueNames() with distA=4 and one_letter_aa=True, which may result in a TypeError because these arguments are forwarded to _infoAsListOfStrings(). Since they are already handled when calculating the residue information, I think removing **kwargs from the calls to _infoAsListOfStrings() might fix this.

I also noticed two other issues:

  • In _infoAsListOfStrings(), the loop handling multiple frames uses conf, but this variable is not defined.
  • In getSurfaceCavityLiningInfo(), when a cavity has no tetrahedra, the code uses info[key][name] = [], but key is not defined.

I'm not sure whether they also explain the InSty failures, but it would be good to fix these issues first and rerun the tests to see if anything is left.

@MatthewLicht

Copy link
Copy Markdown
Author

Hi Karolina,

You are correct. I fixed the issues with _infoAsListOfStrings(), getSurfaceCavityLiningInfo() and related functions. Originally, I wrote getObjectLiningInfo and getSurfaceCavityLiningInfo to return info as a dictionary of dictionaries, with the keys indicating the channel/cavity index, but later changed it to a list of dictionaries. Some of the issues like info[key][name] = [] are caused I missed a few lines when making the change.

All checks now pass.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants