bobleesj / cifkit

High-throughput .cif analysis made easy. Visit: https://bobleesj.github.io/cifkit/
https://bobleesj.github.io/cifkit/
MIT License
11 stars 0 forks source link

Error computing polyhedron metrics: index 4 is out of bounds for axis 0 with size 4 #10

Closed bobleesj closed 1 month ago

bobleesj commented 1 month ago

Checklist

Describe the bug

Consider 261629.cif
Error computing polyhedron metrics: index 4 is out of bounds for axis 0 with size 4

Currently, I am investigating what the issue is

bobleesj commented 1 month ago

The problem is fixed when the minimum number of points for polyhedron is 5 in src/cifkit/coordination/filter.py within the function of find_best_polyhedron.

# Only if there are 5 or more points in the polyhedron
            if len(connection_data) > 4:
                for connection in connection_data:
                    polyhedron_points.append(connection[3])
            else:
                continue
bobleesj commented 1 month ago

It appears that the issue is not solved.

The following error message is acquired with a different size value.

Processing 1421162.cif with 1782 atoms (134/152)
Error computing polyhedron metrics: index 6 is out of bounds for axis 0 with size 6

The problem is not observed during my pytest run in my local machine: https://github.com/bobleesj/cif-bond-analyzer/actions/runs/9824087665/job/27122684319

but it appears that the issue occurs in CI.

This needs a further investigation.

bobleesj commented 1 month ago

Another file:

3795 1831430.cif CN values: 12 Error computing polyhedron metrics: index 7 is out of bounds for axis 0 with size 7

bobleesj commented 1 month ago

Fixed the problem! In src/cifkit/coordination/filter.py, the issue was that when there is a problem with computing the polyhedron metrics with a specific method, it returns None. Now, I have added continue for the None case and it skips the method to be considered as one of the best methods.

# Returns none if ther eis any error
polyhedron_metrics = compute_polyhedron_metrics(
    polyhedron_points, hull
)

# If there is no metrics, then skip the mthod
if polyhedron_metrics is None:
    continue