starling.structure.coordinates.distance_matrix_to_3d_structure_gd

distance_matrix_to_3d_structure_gd(original_distance_matrix, num_iterations=5000, learning_rate=0.001, device='cuda:0', verbose=True)[source]

Function to reconstruct a 3D structure from a distance matrix using gradient descent.

Parameters:
  • original_distance_matrix (torch.Tensor or numpy.ndarray) – The original distance matrix.

  • num_iterations (int, optional) – Number of iterations for gradient descent, by default 5000.

  • learning_rate (float, optional) – Learning rate for the optimizer, by default 1e-3.

  • device (str, optional) – Device to which tensors are moved, by default “cuda:0”.

  • verbose (bool, optional) – Whether to print progress, by default True.

Returns:

  • numpy.ndarray – The reconstructed 3D coordinates.

  • NB (As of Nov 2024, Apple MPS does not support float64 tensors, so we cast)

  • tensors to float32 in the case of MPS being used. Note that this is actually

  • slower than using CPU, but we provide support for this in case someone wants

  • it and/or it gets faster in the future…