Open Babel: Difference between revisions
No edit summary |
|||
(20 intermediate revisions by 3 users not shown) | |||
Line 1: | Line 1: | ||
[[Category:Software]][[Category:ComputationalChemistry]] | <languages /> | ||
[[Category:Software]][[Category:ComputationalChemistry]] | |||
<translate> | |||
== General == <!--T:1--> | |||
[https://openbabel.org/ Open Babel] is a chemical toolbox designed to speak the many languages of chemical data. | [https://openbabel.org/ Open Babel] is a chemical toolbox designed to speak the many languages of chemical data. | ||
It's an open, collaborative project allowing anyone to search, convert, analyze, or store data from molecular modeling, chemistry, solid-state materials, biochemistry, or related areas. | It's an open, collaborative project allowing anyone to search, convert, analyze, or store data from molecular modeling, chemistry, solid-state materials, biochemistry, or related areas. | ||
<!--T:2--> | |||
For further information on how to use Open Babel, please refer to the | |||
[https://openbabel.org/docs/ Open Babel User Guide]. | |||
== <code>openbabel</code> == | <!--T:3--> | ||
This is the serial version of Open Babel which can safely be used even on login | On our clusters we have two kinds of modules for Open Babel installed: | ||
== <code>openbabel</code> == <!--T:4--> | |||
This is the serial version of Open Babel which can safely be used even on login nodes to convert chemical structure files between different formats. | |||
This is the right module for most users. | This is the right module for most users. | ||
Example: | ==== Example ==== <!--T:5--> | ||
{{Commands | |||
| prompt=[user@login1]$ | |||
| module load openbabel | |||
| wget "https://www.chemspider.com/FilesHandler.ashx?type{{=}}str&3d{{=}}yes&id{{=}}171" -O acetic_acid.mol | |||
| obabel -i mol acetic_acid.mol -o pdb -O acetic_acid.pdb | |||
}} | |||
Notes: | |||
* The <code>wget</code> command downloads <code>acetic_acid.mol</code> as an example file. | |||
* The <code>obabel</code> command converts the molecule described in 'acetic_acid.mol' from <code>.mol</code> format to <code>.pdb</code> format. | |||
== <code>openbabel-omp</code> == | == <code>openbabel-omp</code> == <!--T:6--> | ||
This is the | This is the version of Open Babel which has OpenMP parallelization enabled. | ||
{{box|<b>This module should not be used on login | <!--T:7--> | ||
{{box|<b>This module should not be used on login nodes,</b><br> | |||
because even for simple tasks it will create as many threads | because even for simple tasks it will create as many threads | ||
as it detects CPUs on the machine, in turn | as it detects CPUs on the machine, in turn causing load-spikes which will be disruptive for other users.}} | ||
<!--T:8--> | |||
The parallel version of Open Babel is useful when converting very large numbers of molecule structures or | |||
calculating large numbers of cheminformatics descriptors for multiple molecules. | |||
<!--T:9--> | |||
Make sure to set the environment variable <code>OMP_NUM_THREADS</code> | |||
in order to tell Open Babel how many CPUs it is allowed to use. | in order to tell Open Babel how many CPUs it is allowed to use. | ||
==== Example ==== <!--T:10--> | |||
which in this case should contain a database with many molecules and | The following job takes the [https://en.wikipedia.org/wiki/Chemical_table_file#SDF Structural Data File] <code>many_molecules.sdf</code>, | ||
for each of them, using two CPU-cores. | which in this case should contain a database with many molecules, and generates Canonical [https://en.wikipedia.org/wiki/Simplified_molecular-input_line-entry_system SMILES] representations for each of them, using two CPU-cores. | ||
{{File | {{File | ||
|name=parallel_openbabel_job.sh | |name=parallel_openbabel_job.sh | ||
Line 44: | Line 59: | ||
export OMP_NUM_THREADS="${SLURM_CPUS_PER_TASK:-1}" | export OMP_NUM_THREADS="${SLURM_CPUS_PER_TASK:-1}" | ||
obabel | <!--T:11--> | ||
obabel -i sdf many_molecules.sdf -o can -O many_canonical_smiles.txt | |||
}} | }} | ||
== Python == | == Python == <!--T:12--> | ||
Open Babel's functionality can be used from other languages such as Python. | Open Babel's functionality can be used from other languages such as Python. | ||
The [https://openbabel.org/docs/UseTheLibrary/Python.html Python interface for Open Babel] has been added to the both <code>openbabel</code> and <code>openbabel-omp</code> modules as extensions. | The [https://openbabel.org/docs/UseTheLibrary/Python.html Python interface for Open Babel] has been added to the both <code>openbabel</code> and <code>openbabel-omp</code> modules as extensions. | ||
Therefore both the <code>openbabel</code> and <code>pybel</code> packages can be used after loading both openbabel and a compatible Python module. | Therefore both the <code>openbabel</code> and <code>pybel</code> packages can be used after loading both <code>openbabel</code> and a compatible Python module. | ||
==== Example ==== <!--T:13--> | |||
$ module load python/3.11 openbabel/3.1.1 | <!--T:14--> | ||
$ module load python/3.11 openbabel/3.1.1 | |||
$ python | $ python | ||
Python 3.11.5 (main, Sep 19 2023, 19:49:15) [GCC 11.3.0] on linux | Python 3.11.5 (main, Sep 19 2023, 19:49:15) [GCC 11.3.0] on linux | ||
Line 63: | Line 80: | ||
>>> | >>> | ||
</translate> | |||
Latest revision as of 21:57, 4 March 2024
General[edit]
Open Babel is a chemical toolbox designed to speak the many languages of chemical data. It's an open, collaborative project allowing anyone to search, convert, analyze, or store data from molecular modeling, chemistry, solid-state materials, biochemistry, or related areas.
For further information on how to use Open Babel, please refer to the Open Babel User Guide.
On our clusters we have two kinds of modules for Open Babel installed:
openbabel
[edit]
This is the serial version of Open Babel which can safely be used even on login nodes to convert chemical structure files between different formats. This is the right module for most users.
Example[edit]
[user@login1]$ module load openbabel
[user@login1]$ wget "https://www.chemspider.com/FilesHandler.ashx?type=str&3d=yes&id=171" -O acetic_acid.mol
[user@login1]$ obabel -i mol acetic_acid.mol -o pdb -O acetic_acid.pdb
Notes:
- The
wget
command downloadsacetic_acid.mol
as an example file. - The
obabel
command converts the molecule described in 'acetic_acid.mol' from.mol
format to.pdb
format.
openbabel-omp
[edit]
This is the version of Open Babel which has OpenMP parallelization enabled.
This module should not be used on login nodes, |
The parallel version of Open Babel is useful when converting very large numbers of molecule structures or calculating large numbers of cheminformatics descriptors for multiple molecules.
Make sure to set the environment variable OMP_NUM_THREADS
in order to tell Open Babel how many CPUs it is allowed to use.
Example[edit]
The following job takes the Structural Data File many_molecules.sdf
,
which in this case should contain a database with many molecules, and generates Canonical SMILES representations for each of them, using two CPU-cores.
#!/bin/bash
#SBATCH --time=00:15:00
#SBATCH --cpus-per-task=2
#SBATCH --mem-per-cpu=1000M
module load openbabel-omp
export OMP_NUM_THREADS="${SLURM_CPUS_PER_TASK:-1}"
obabel -i sdf many_molecules.sdf -o can -O many_canonical_smiles.txt
Python[edit]
Open Babel's functionality can be used from other languages such as Python.
The Python interface for Open Babel has been added to the both openbabel
and openbabel-omp
modules as extensions.
Therefore both the openbabel
and pybel
packages can be used after loading both openbabel
and a compatible Python module.
Example[edit]
$ module load python/3.11 openbabel/3.1.1
$ python
Python 3.11.5 (main, Sep 19 2023, 19:49:15) [GCC 11.3.0] on linux
>>> import openbabel
>>> print(openbabel.__version__)
3.1.1.1
>>> from openbabel import pybel
>>>