|
46 | 46 | order_atoms_in_mol_list, |
47 | 47 | remove_dummies, |
48 | 48 | rmg_mol_from_inchi, |
| 49 | + sort_xyz_using_indices, |
49 | 50 | str_to_xyz, |
50 | 51 | translate_to_center_of_mass, |
51 | 52 | xyz_from_data, |
52 | 53 | xyz_to_str, |
| 54 | + kabsch, |
53 | 55 | ) |
54 | 56 | from arc.species.perceive import perceive_molecule_from_xyz, is_mol_valid |
55 | 57 | from arc.species.vectors import calculate_angle, calculate_distance, calculate_dihedral_angle |
@@ -2142,6 +2144,27 @@ def get_bonds(self) -> List[tuple]: |
2142 | 2144 | for atom2, bond12 in atom1.edges.items(): |
2143 | 2145 | bonds.append(tuple(sorted((self.mol.atoms.index(atom1), self.mol.atoms.index(atom2))))) |
2144 | 2146 | return list(set(bonds)) |
| 2147 | + |
| 2148 | + def kabsch(self, other: 'ARCSpecies', map_: list) -> float: |
| 2149 | + """ |
| 2150 | + Calculate the Kabsch RMSD between this species and another species. |
| 2151 | +
|
| 2152 | + Args: |
| 2153 | + other (ARCSpecies): The other species to compare to. |
| 2154 | + map_ (list): A list of atom indices mapping atoms from this species to the other species. (i.e., if |
| 2155 | + this species has atoms [A, B, C] and the other species has atoms [C, A, B], then map_ would be [1, 2, 0] |
| 2156 | + Returns: |
| 2157 | + float: The Kabsch RMSD value. |
| 2158 | + """ |
| 2159 | + if not isinstance(other, ARCSpecies): |
| 2160 | + raise SpeciesError(f'Other must be an ARCSpecies instance, got {type(other)}.\n' |
| 2161 | + f'If you meant to use the XYZ coordinates directly, use arc.species.converter.kabsch.') |
| 2162 | + |
| 2163 | + if len(map_) != self.number_of_atoms: |
| 2164 | + raise SpeciesError(f'The map_ list must have the same length as the number of atoms in {self.label} ' |
| 2165 | + f'({self.number_of_atoms}), got {len(map_)}.') |
| 2166 | + |
| 2167 | + return kabsch(self.get_xyz(), sort_xyz_using_indices(other.get_xyz(), map_)) |
2145 | 2168 |
|
2146 | 2169 |
|
2147 | 2170 | class TSGuess(object): |
|
0 commit comments