From 64caf36a62c9fbe3872b1775bbe51aa2662e1eab Mon Sep 17 00:00:00 2001 From: Rocco Meli Date: Tue, 1 Mar 2022 18:15:01 +0000 Subject: [PATCH 1/4] remove spurious --sdf --- xyz2mol.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/xyz2mol.py b/xyz2mol.py index ecd904d..051022e 100644 --- a/xyz2mol.py +++ b/xyz2mol.py @@ -747,9 +747,6 @@ def main(): parser = argparse.ArgumentParser(usage='%(prog)s [options] molecule.xyz') parser.add_argument('structure', metavar='structure', type=str) - parser.add_argument('-s', '--sdf', - action="store_true", - help="Dump sdf file") parser.add_argument('--ignore-chiral', action="store_true", help="Ignore chiral centers") @@ -768,7 +765,9 @@ def main(): parser.add_argument('-o', '--output-format', action="store", type=str, - help="Output format [smiles,sdf] (default=sdf)") + default="sdf", + choices=["sdf", "smiles", "smi"], + help="Output format") parser.add_argument('-c', '--charge', action="store", metavar="int", From f4ba0f19fad914bd1239f862fe246fe2f4c3e831 Mon Sep 17 00:00:00 2001 From: Rocco Meli Date: Tue, 1 Mar 2022 18:15:48 +0000 Subject: [PATCH 2/4] use output_format, default to sdf --- xyz2mol.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/xyz2mol.py b/xyz2mol.py index 051022e..2169974 100644 --- a/xyz2mol.py +++ b/xyz2mol.py @@ -814,11 +814,12 @@ def main(): if args.output_format == "sdf": txt = Chem.MolToMolBlock(mol) print(txt) - - else: + elif args.output_format == "smiles" or args.output_format == "smi": # Canonical hack isomeric_smiles = not args.ignore_chiral smiles = Chem.MolToSmiles(mol, isomericSmiles=isomeric_smiles) m = Chem.MolFromSmiles(smiles) smiles = Chem.MolToSmiles(m, isomericSmiles=isomeric_smiles) print(smiles) + else: + raise ValueError(f"Unsupported output format: {args.output_format}") From ad323276939029d93c3c5ff898840796bf154a13 Mon Sep 17 00:00:00 2001 From: Rocco Meli Date: Tue, 1 Mar 2022 18:20:10 +0000 Subject: [PATCH 3/4] small improvements --- xyz2mol.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/xyz2mol.py b/xyz2mol.py index 2169974..385a3ca 100644 --- a/xyz2mol.py +++ b/xyz2mol.py @@ -814,7 +814,7 @@ def main(): if args.output_format == "sdf": txt = Chem.MolToMolBlock(mol) print(txt) - elif args.output_format == "smiles" or args.output_format == "smi": + elif args.output_format in ["smiles", "smi"]: # Canonical hack isomeric_smiles = not args.ignore_chiral smiles = Chem.MolToSmiles(mol, isomericSmiles=isomeric_smiles) @@ -822,4 +822,5 @@ def main(): smiles = Chem.MolToSmiles(m, isomericSmiles=isomeric_smiles) print(smiles) else: + # This should never happen if parser's choices are set correctly raise ValueError(f"Unsupported output format: {args.output_format}") From b00326ab7c3d648887a413d4dda1d897d560c48a Mon Sep 17 00:00:00 2001 From: Rocco Meli Date: Tue, 1 Mar 2022 18:29:35 +0000 Subject: [PATCH 4/4] squeeze in some readme typo fixes --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 4fbc058..0488aee 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ Depends on `rdkit`, `numpy`, and `networkx`. Easiest to setup via anaconda/conda `conda install -c conda-forge xyz2mol` -Setup for a standalone enviroment is avaliable via `Makefile`. To setup and test simply clone the project and make. +Setup for a standalone environment is available via `Makefile`. To setup and test simply clone the project and make. git clone https://github.com/jensengroup/xyz2mol @@ -31,7 +31,7 @@ Note, it is also possible to run the code without the `networkx` dependencies, b ## Example usage -Read in xyz file and print out the SMILES, but don't incode the chirality. +Read in xyz file and print out the SMILES, but don't encode the chirality. xyz2mol.py examples/chiral_stereo_test.xyz --ignore-chiral