Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Issue #22 #33

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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

Expand Down
13 changes: 7 additions & 6 deletions xyz2mol.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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",
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure what the intended default behaviour is since the previous options where pointing in opposite directions... SDF or SMILES?

choices=["sdf", "smiles", "smi"],
help="Output format")
parser.add_argument('-c', '--charge',
action="store",
metavar="int",
Expand Down Expand Up @@ -815,11 +814,13 @@ def main():
if args.output_format == "sdf":
txt = Chem.MolToMolBlock(mol)
print(txt)

else:
elif args.output_format in ["smiles", "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:
# This should never happen if parser's choices are set correctly
raise ValueError(f"Unsupported output format: {args.output_format}")