PatWalters / rd_filters

A script to run structural alerts using the RDKit and ChEMBL
MIT License
125 stars 37 forks source link

inelegant exit for smiles file with no names #9

Open MikeBowerReverie opened 4 years ago

MikeBowerReverie commented 4 years ago

using a *.smi file which contains smiles strings but no names causes an inelegant error.

benzene.smi = c1ccccc1

rd_filters filter --in benzene.smi --prefix foo using 8 cores Using alerts from Inpharmatica Wrote SMILES for molecules passing filters to foo.smi Wrote detailed data to foo.csv Traceback (most recent call last): File "/Users/mikebower/anaconda3/envs/reverie_env/bin/rd_filters", line 8, in sys.exit(main()) File "/Users/mikebower/anaconda3/envs/reverie_env/lib/python3.6/site-packages/rd_filters/rd_filters.py", line 202, in main fraction_passed = "%.1f" % (num_output_rows / num_input_rows * 100.0) ZeroDivisionError: division by zero

but benzene.smi = c1ccccc1 benzene

rd_filters filter --in benzene.smi --prefix foo using 8 cores Using alerts from Inpharmatica Wrote SMILES for molecules passing filters to foo.smi Wrote detailed data to foo.csv 1 of 1 passed filters 100.0% Elapsed time 0.31 seconds

people who have worked with your code before will know to have the compound id or name there, but others may not understand what the error comes from.

hyoo commented 4 years ago

I had the same issue. If the test.smi was given or error message was clear to the real source of the problem, I would find the solution a lot easier.

UnixJunkie commented 2 years ago

Or, maybe, a crash-proof behavior. Such as: if a SMILES has no name, use the SMILES itself as a default name.

PatWalters commented 2 years ago

Good idea, I'll make this change