chemistry-software d35aaf4db5 README
2024-09-26 13:55:47 +02:00
2024-09-26 13:50:26 +02:00
2024-09-26 13:50:26 +02:00
2024-09-26 13:50:26 +02:00
2024-09-26 09:24:04 +00:00
2024-09-26 13:50:26 +02:00
2024-09-26 13:50:26 +02:00
2024-09-26 13:55:47 +02:00

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:

  1. Import the package in your Go file:
import (
    "fmt"
    "gitea.boner.be/bdnugget/gochem"
)
  1. 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
chem tools
Readme 88 KiB
Languages
C 80.4%
Go 19.6%