gochem/README.md

86 lines
1.5 KiB
Markdown
Raw Normal View History

2024-09-26 13:55:47 +02:00
# gochem
2024-09-26 09:24:04 +00:00
2024-09-26 13:55:47 +02:00
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:
```bash
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:
```go
import (
"fmt"
"gitea.boner.be/bdnugget/gochem"
)
```
2. Parse a molecule file:
```go
func main() {
mol, err := gochem.ParseMolfile("path/to/yourfile.mol")
if err != nil {
fmt.Println("Error:", err)
return
}
fmt.Println(mol)
}
2024-09-26 13:50:26 +02:00
```
2024-09-26 13:55:47 +02:00
## Command Line Usage
You can read an SDF or MOL file from the command line by passing the file path as an argument:
```bash
go run main.go path/to/yourfile.sdf
```
In your `main.go`, ensure that you retrieve the argument like this:
```go
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)
}
2024-09-26 13:50:26 +02:00
```
2024-09-26 13:55:47 +02:00
## License
2024-09-26 13:50:26 +02:00
2024-09-26 13:55:47 +02:00
This project is licensed under the BSD 3-Clause License. See the [LICENSE](LICENSE) file for details.
```
2024-09-26 13:50:26 +02:00