MOL2, PDB, and SDF are all file formats used to represent molecular structures.
- MOL2 is a molecular structure file format developed by Tripos Inc. It provides a simple and flexible way to represent molecular structures and associated information, such as atom and bond data, molecular charges, and partial charges.
- PDB (Protein Data Bank) is a widely used file format for storing 3D structural information of proteins and nucleic acids. It provides a standard way of representing the atomic coordinates and other information about a molecule, including residue names, chain identifiers, and atom names.
- SDF (Structure-Data File) is a widely used file format for representing molecular structures and associated data. It provides a simple and flexible way to store molecular structure information, as well as other information such as chemical properties, 3D coordinates, and various descriptors.
These file formats are widely used in the fields of chemistry, biochemistry, and computational biology, and they can be converted with Open Babel library.
Here is an example of Python code using Open Babel to convert between PDB, MOL2, and SDF file formats:
import pybel
def convert_format(input_file, output_file, output_format):
# Load the input file using Pybel
mol = pybel.readfile(input_file.split('.')[-1], input_file).next()
# Write the molecule to the desired output format
mol.write(output_format, output_file, overwrite=True)
# Example usage:
input_file = "molecule.pdb"
output_file = "molecule.mol2"
output_format = "mol2"
convert_format(input_file, output_file, output_format)
input_file = "molecule.mol2"
output_file = "molecule.sdf"
output_format = "sdf"
convert_format(input_file, output_file, output_format)
This code uses the Pybel module from Open Babel to perform the file format conversions. The convert_format function takes in the input file name, the desired output file name, and the desired output format. It then uses the Pybel readfile function to load the input file, and the Pybel write function to write the molecule to the desired output format.
You can easily modify this code to convert between other file formats supported by Open Babel, such as PDB and SDF, by changing the input file name and format, and the desired output file name and format.