79100374

Date: 2024-10-18 02:52:54
Score: 2.5
Natty:
Report link

After researching many sources such as chemistry and github and stackoverflow, I have not found a way to add codes to the exist script in order to redirect pybel warnings to a log file. However, I can provide you a possible solution here by using script. By modifying your code:

import pybel

smiles = pybel.readfile('smi', 'smiles.txt')
converted = []
for mol in smiles:
    print(mol)
    smiles_str = mol.write('smiles')
    inchikey_str = mol.write('inchikey')

with a command run:

script -c "python smiles2sdf.py" log.txt

It will output everything shown on terminal during executing to log.txt. This feature makes us be careful to choose what will be appeared on screen.

Further information about this package is here.

Hope this help.

p.s: I also want to capture pybel warnings programmatically. If there is a possible method to do that, please provide me. Thank you very much.

Reasons:
  • Blacklisted phrase (0.5): Thank you
  • Blacklisted phrase (1): stackoverflow
  • Whitelisted phrase (-1): Hope this help
  • RegEx Blacklisted phrase (2.5): please provide me
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Low reputation (0.5):
Posted by: M.Vu