A Go cheminformatics toolkit based on the Indigo library, providing high-performance molecule and reaction processing via CGO bindings.
English | ็ฎไฝไธญๆ
- ๐งช Molecule Processing: Complete molecule loading, editing, and saving
- โ๏ธ Reaction Processing: Chemical reaction loading, analysis, and AAM (Atom-to-Atom Mapping)
- ๐จ Structure Rendering: Render molecules and reactions as images (PNG, SVG, PDF)
- ๐ฌ InChI Support: InChI and InChIKey generation and parsing
- ๐ Molecular Properties: Calculate molecular weight, TPSA, molecular formula, etc.
- ๐๏ธ Molecule Building: Build molecular structures from scratch
- ๐ Format Conversion: Convert between SMILES, MOL, SDF formats
- Go 1.20+
- Indigo Library: Precompiled libraries included
- Windows (x86_64, i386)
- Linux (x86_64, aarch64)
- macOS (x86_64, arm64)
# Clone the repository
git clone https://github.com/cx-luo/go-indigo.git
cd go-indigo
# Set environment variables (Windows example)
set CGO_ENABLED=1
set CGO_CFLAGS=-I%CD%/3rd
set CGO_LDFLAGS=-L%CD%/3rd/windows-x86_64
# Set environment variables (Linux example)
export CGO_ENABLED=1
export CGO_CFLAGS="-I$(pwd)/3rd"
export CGO_LDFLAGS="-L$(pwd)/3rd/linux-x86_64"
export LD_LIBRARY_PATH=$(pwd)/3rd/linux-x86_64:$LD_LIBRARY_PATH
# Run tests to verify installation
go test ./test/molecule/...package main
import (
"github.com/cx-luo/go-indigo/molecule"
"github.com/cx-luo/go-indigo/render"
)
func main() {
// Load molecule from SMILES
mol, err := molecule.LoadMoleculeFromString("c1ccccc1")
if err != nil {
panic(err)
}
defer mol.Close()
// Initialize renderer
renderer := &render.Renderer{}
defer renderer.DisposeRenderer()
// Set render options
opts := &render.RenderOptions{
OutputFormat: "png",
ImageWidth: 800,
ImageHeight: 600,
}
renderer.Options = opts
renderer.Apply()
// Render to PNG
renderer.RenderToFile(mol.Handle, "benzene.png")
}package main
import (
"fmt"
"github.com/cx-luo/go-indigo/molecule"
)
func main() {
// Load ethanol
mol, _ := molecule.LoadMoleculeFromString("CCO")
defer mol.Close()
// Calculate properties
mw, _ := mol.MolecularWeight()
fmt.Printf("Molecular Weight: %.2f\n", mw)
formula, _ := mol.GrossFormula()
fmt.Printf("Formula: %s\n", formula)
tpsa, _ := mol.TPSA(false)
fmt.Printf("TPSA: %.2f\n", tpsa)
// Convert to SMILES
smiles, _ := mol.ToSmiles()
fmt.Printf("SMILES: %s\n", smiles)
}package main
import (
"fmt"
"github.com/cx-luo/go-indigo/molecule"
)
func main() {
// Load molecule
mol, _ := molecule.LoadMoleculeFromString("CC(=O)O")
defer mol.Close()
// Initialize InChI
molecule.InitInChI()
defer molecule.DisposeInChI()
// Generate InChI
inchi, _ := mol.ToInChI()
fmt.Println("InChI:", inchi)
// Generate InChIKey
key, _ := mol.ToInChIKey()
fmt.Println("InChIKey:", key)
}package main
import (
"fmt"
"github.com/cx-luo/go-indigo/reaction"
)
func main() {
// Load reaction
rxn, _ := reaction.LoadReactionFromString("CCO>>CC=O")
defer rxn.Close()
// Get reaction information
nReactants, _ := rxn.CountReactants()
nProducts, _ := rxn.CountProducts()
fmt.Printf("Reactants: %d, Products: %d\n", nReactants, nProducts)
// Automatic atom mapping
rxn.Automap("discard")
// Save as RXN file
rxn.SaveToFile("reaction.rxn")
}- Molecule Processing - Complete molecule operations guide
- Reaction Processing - Chemical reaction handling
- Rendering - Structure rendering features
- Environment Setup - CGO environment configuration
- InChI Implementation - InChI feature details
- API Reference - Complete API documentation
- Examples - Various usage examples
go-indigo/
โโโ 3rd/ # Indigo precompiled libraries
โ โโโ windows-x86_64/ # Windows 64-bit
โ โโโ windows-i386/ # Windows 32-bit
โ โโโ linux-x86_64/ # Linux 64-bit
โ โโโ linux-aarch64/ # Linux ARM64
โ โโโ darwin-x86_64/ # macOS Intel
โ โโโ darwin-aarch64/ # macOS Apple Silicon
โโโ core/ # Core functionality
โ โโโ indigo.go # Indigo core functionality
โ โโโ indigo_helper.go # Indigo helper functionality
โ โโโ indigo_inchi.go # Indigo InChI functionality
โ โโโ indigo_molecule.go # Indigo molecule functionality
โ โโโ indigo_reaction.go # Indigo reaction functionality
โโโ molecule/ # Molecule processing package
โ โโโ README.md # Molecule processing documentation
โ โโโ molecule.go # Core molecule structure
โ โโโ molecule_atom.go # Atom operations
โ โโโ molecule_builder.go # Molecule building
โ โโโ molecule_match.go # Molecule matching
โ โโโ molecule_properties.go # Property calculations
โ โโโ molecule_saver.go # Molecule saving
โโโ reaction/ # Reaction processing package
โ โโโ README.md # Reaction processing documentation
โ โโโ reaction.go # Core reaction structure
โ โโโ reaction_automap.go # Automatic atom mapping
โ โโโ reaction_helpers.go # Reaction helper functions
โ โโโ reaction_iterator.go # Reaction iterator
โ โโโ reaction_loader.go # Reaction loading
โ โโโ reaction_saver.go # Reaction saving
โโโ render/ # Rendering package
โ โโโ README.md # Rendering documentation
โ โโโ render.go # Rendering functionality
โโโ test/ # Test files
โ โโโ molecule/ # Molecule tests
โ โโโ reaction/ # Reaction tests
โ โโโ render/ # Rendering tests
โโโ examples/ # Example code
โ โโโ molecule/ # Molecule examples
โ โโโ reaction/ # Reaction examples
โ โโโ render/ # Rendering examples
โโโ docs/ # Documentation
โโโ README.md # This file
- โ Load from SMILES, MOL, SDF
- โ Save as MOL, SMILES, JSON
- โ Calculate properties (MW, TPSA, formula, etc.)
- โ Add, delete, modify atoms and bonds
- โ Aromatization and dearomatization
- โ Fold and unfold hydrogens
- โ 2D layout and cleanup
- โ Normalization and standardization
- โ Load from Reaction SMILES, RXN files
- โ Save as RXN files
- โ Add reactants, products, catalysts
- โ Automatic atom-to-atom mapping (AAM)
- โ Reaction center detection
- โ Iterate reaction components
- โ PNG, SVG, PDF output
- โ Custom image size and style
- โ Grid rendering (multiple molecules)
- โ Reference atom alignment
- โ Stereochemistry display
- โ Atom/bond label display
- โ Standard InChI generation
- โ InChIKey generation
- โ Load molecule from InChI
- โ Warning and log information
- โ Auxiliary information output
# Run all tests
go test ./test/...
# Run specific package tests
go test ./test/molecule/...
go test ./test/reaction/...
go test ./test/render/...
# Verbose output
go test -v ./test/...
# Specific test
go test ./test/molecule/ -run TestLoadMoleculeFromString- Based on C++ Indigo library for excellent performance
- Minimized CGO call overhead
- Automatic memory management (using runtime.SetFinalizer)
- Supports large-scale molecule processing
Contributions are welcome! Feel free to submit Pull Requests or create Issues.
- Fork this repository
- Create feature branch (
git checkout -b feature/amazing-feature) - Commit changes (
git commit -m 'Add amazing feature') - Push to branch (
git push origin feature/amazing-feature) - Open Pull Request
This project is licensed under Apache License 2.0. See LICENSE file for details.
- Indigo Toolkit: Apache License 2.0
- Copyright ยฉ 2009-Present EPAM Systems
- EPAM Indigo - Excellent cheminformatics toolkit
- All contributors and users
- Author: chengxiang.luo
- Email: chengxiang.luo@foxmail.com
- GitHub: @cx-luo
โญ If this project helps you, please give it a Star!