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
Changes from 3 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
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}")