gochem
gochem is a Go package that parses SDF (Structure-Data File) and MOL files to extract molecular data, converting it into structured Go types for further use in your applications.
Features
- Parse molecular structures from SDF and MOL files
- Extract atom and bond data
- Easily generate Go structs for molecule representation
- Lightweight and fast
Installation
To install gochem, simply run:
go get gitea.boner.be/bdnugget/gochem
Usage
Here's how to use gochem to parse a MOL or SDF file:
- Import the package in your Go file:
import (
"fmt"
"gitea.boner.be/bdnugget/gochem"
)
- Parse a molecule file:
func main() {
mol, err := gochem.ParseMolfile("path/to/yourfile.mol")
if err != nil {
fmt.Println("Error:", err)
return
}
fmt.Println(mol)
}
Command Line Usage
You can read an SDF or MOL file from the command line by passing the file path as an argument:
go run main.go path/to/yourfile.sdf
In your main.go
, ensure that you retrieve the argument like this:
import (
"fmt"
"os"
"gitea.boner.be/bdnugget/gochem"
)
func main() {
if len(os.Args) < 2 {
fmt.Println("Usage: go run main.go <path-to-molfile>")
return
}
filePath := os.Args[1]
mol, err := gochem.ParseMolfile(filePath)
if err != nil {
fmt.Println("Error:", err)
return
}
fmt.Println(mol)
}
License
This project is licensed under the BSD 3-Clause License. See the LICENSE file for details.
Description
Languages
C
80.4%
Go
19.6%