README
This commit is contained in:
parent
0841f1190b
commit
d35aaf4db5
97
README.md
97
README.md
@ -1,24 +1,85 @@
|
||||
# SDF Molfile parser and molecule renderer with Raylib
|
||||
# gochem
|
||||
|
||||
## Compilation
|
||||
```sh
|
||||
zig cc -o test -lraylib -L /usr/local/lib -I /usr/local/include main.c -DDEBUG
|
||||
or
|
||||
gcc $(pkg-config --cflags raylib) -L/usr/local/lib main.c -lraylib -lGL -lm -lpthread -ldl -lrt -lX11 -o ass -DDEBUG
|
||||
```
|
||||
Or without DEBUG flag to omit debug logging
|
||||
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.
|
||||
|
||||
## Example files
|
||||
SDF molfiles of ethanol and methyl vinyl ketone are available. 3D SVG images were generated from these using OpenBabel for comparison with the Raymol output.
|
||||
Conversion command:
|
||||
```sh
|
||||
obabel methyl-vinyl-ketone.sdf -Omethyl-vinyl-ketone.svg -xS
|
||||
## 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
|
||||
```
|
||||
|
||||
## TODO
|
||||
- Drag and drop molfiles [Raylib supporst this nicely](https://www.raylib.com/examples/core/loader.html?name=core_drop_files)
|
||||
- Use meshes instead of DrawSphere/Cylinder for performance (GPU already getting toasty)
|
||||
- Use periodic table data for colors and bond properties etc, made an `Element` struct for this
|
||||
## 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)
|
||||
}
|
||||
```
|
||||
|
||||
## 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)
|
||||
}
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
This project is licensed under the BSD 3-Clause License. See the [LICENSE](LICENSE) file for details.
|
||||
```
|
||||
|
||||
By [@bdnugget](https://t.me/bdnugget)
|
||||
|
Loading…
x
Reference in New Issue
Block a user