Skip to content

Instantly share code, notes, and snippets.

@nazavode
Created September 6, 2023 21:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nazavode/a68ef80a9ebc607631f178245e85507d to your computer and use it in GitHub Desktop.
Save nazavode/a68ef80a9ebc607631f178245e85507d to your computer and use it in GitHub Desktop.
Compute optimal RMSD between two molecular structures
#!/usr/bin/env python3
from rdkit.Chem.rdmolfiles import MolFromMol2File
from rdkit.Chem.rdMolAlign import AlignMol
import argparse
if __name__ == "__main__":
PARSER = argparse.ArgumentParser(
description="""Compute optimal RMSD of two structures.
Atom order is not changed, and no matching is attempted. For details refer to:
https://www.rdkit.org/docs/source/rdkit.Chem.rdMolAlign.html#module-rdkit.Chem.rdMolAlign
""",
formatter_class=argparse.RawDescriptionHelpFormatter,
)
PARSER.add_argument(
"file_a",
metavar="PATH_A",
help="path to the first structure in TRIPOS mol2 format",
)
PARSER.add_argument(
"file_b",
metavar="PATH_B",
help="path to the second structure in TRIPOS mol2 format",
)
args = PARSER.parse_args()
a = MolFromMol2File(args.file_a)
b = MolFromMol2File(args.file_b)
res = AlignMol(a, b)
print(res)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment