5
$\begingroup$

I'm trying to convert .xyz to .sdf with Open Babel on Ubuntu 22.04, but I am getting an error message "Cannot open orca.sdf".

obabel "orca.xyz" -osdf orca.sdf
orca
 OpenBabel10232319413D
...
$$$$
==============================
*** Open Babel Error  in OpenAndSetFormat
  Cannot open orca.sdf
1 molecule converted

The molecule is in the output, so it is reading for sure. But some issue with write/conversion.

The input and output files are in the same directory. I tried giving permissions to all with chmod -R 777 /path/to/directory but it didn't stop the error.

ls -l
total 3760
-rwxrwxrwx 1 frank frank 3843856 Oct 23 19:18 orca.out
-rwxrwxrwx 1 frank frank    1845 Oct 23 19:20 orca.xyz

I'm in a Conda environment. I tried echo $BABEL_DATADIR but it was not set strangely. So I set it manually with export BABEL_DATADIR=$CONDA_PREFIX/share/openbabel/3.1.0, but this also did not help.

I also tried this command, but it did not help:

conda update -c conda-forge openbabel
Retrieving notices: ...working... done
Channels:
 - conda-forge
 - defaults
 - conda-forge/label/libint_dev
 - pyscf
Platform: linux-64
Collecting package metadata (repodata.json): done
Solving environment: done

# All requested packages already installed.
```
$\endgroup$

1 Answer 1

6
$\begingroup$

The obabel program doesn't have the same semantics as babel because it was becoming hard to parse all the command line options.

  • If you want to specify an output file, use -O orca.sdf
  • If you want to specify an output format, use -osdf (e.g., output to stdout)

You can of course combine them, for example if you want to specify a filename that has a different extension (e.g. -O orca.inp -oorcainp)

Since you didn't specify -O, the orca.sdf is assumed to be another input file (e.g., a batch operation). So obabel is confused because you didn't set an output file.

See https://open-babel.readthedocs.io/en/latest/Command-line_tools/babel.html for more details.

FYI - there's an Open Babel mailing list / forum for more help and suggestions.

$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .