Skip to content

Commit 1dbb79f

Browse files
committed
Merge branch 'add-fit-flag'
2 parents d021dfe + 642a122 commit 1dbb79f

11 files changed

Lines changed: 1096 additions & 206 deletions

File tree

.github/workflows/test.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: Go Tests
2+
3+
on:
4+
push:
5+
branches:
6+
- '**'
7+
pull_request:
8+
9+
jobs:
10+
test:
11+
name: Test
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- name: Checkout
16+
uses: actions/checkout@v4
17+
18+
- name: Setup Go
19+
uses: actions/setup-go@v5
20+
with:
21+
go-version-file: go.mod
22+
cache: true
23+
24+
- name: Run tests
25+
run: go test ./...

README.md

Lines changed: 93 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
**A comprehensive Go implementation of the EnzymeML data exchange format for enzymatic data**
66

7-
[![Go Version](https://img.shields.io/badge/Go-1.19+-00ADD8?style=flat-square&logo=go)](https://golang.org/)
7+
[![Go Version](https://img.shields.io/badge/Go-1.25+-00ADD8?style=flat-square&logo=go)](https://golang.org/)
88
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg?style=flat-square)](https://opensource.org/licenses/MIT)
99

1010
---
@@ -22,6 +22,7 @@
2222
- [Requirements](#requirements)
2323
- [📖 Usage](#-usage)
2424
- [Quick Start](#quick-start)
25+
- [🌐 Start v2 REST API](#-start-v2-rest-api)
2526
- [🗄️ Database Example](#️-database-example)
2627
- [🤝 Contributing](#-contributing)
2728
- [📄 License](#-license)
@@ -50,12 +51,12 @@ EnzymeML Go implements the complete **EnzymeML v2 specification**, providing you
5051
Get started with EnzymeML Go in seconds:
5152

5253
```bash
53-
go get github.com/enzymeml-go
54+
go get github.com/EnzymeML/enzymeml-go
5455
```
5556

5657
### Requirements
5758

58-
- **Go 1.19+** - Ensure you have a recent version of Go installed
59+
- **Go 1.25+** - Ensure you have a recent version of Go installed
5960
- **Modern Go modules** - This package uses Go modules for dependency management
6061

6162
## 📖 Usage
@@ -67,28 +68,112 @@ package main
6768

6869
import (
6970
"fmt"
70-
"github.com/enzymeml-go"
71+
enzymeml_v2 "github.com/EnzymeML/enzymeml-go/src"
7172
)
7273

7374
func main() {
74-
// Your EnzymeML Go code here
75-
fmt.Println("Welcome to EnzymeML Go!")
75+
doc := enzymeml_v2.EnzymeMLDocument{Name: "Example"}
76+
fmt.Println(doc.Name)
7677
}
7778
```
7879

80+
### 🌐 Start v2 REST API
81+
82+
Create a `main.go`:
83+
84+
```go
85+
package main
86+
87+
import (
88+
"log"
89+
"net/http"
90+
91+
apiv2 "github.com/EnzymeML/enzymeml-go/src/api/v2"
92+
enzymeml_v2 "github.com/EnzymeML/enzymeml-go/src"
93+
database "github.com/EnzymeML/enzymeml-go/src/database/v2"
94+
)
95+
96+
func main() {
97+
models := []interface{}{
98+
&enzymeml_v2.EnzymeMLDocument{},
99+
&enzymeml_v2.Creator{},
100+
&enzymeml_v2.Vessel{},
101+
&enzymeml_v2.Protein{},
102+
&enzymeml_v2.Complex{},
103+
&enzymeml_v2.SmallMolecule{},
104+
&enzymeml_v2.Reaction{},
105+
&enzymeml_v2.ReactionElement{},
106+
&enzymeml_v2.ModifierElement{},
107+
&enzymeml_v2.Equation{},
108+
&enzymeml_v2.Variable{},
109+
&enzymeml_v2.Parameter{},
110+
&enzymeml_v2.Measurement{},
111+
&enzymeml_v2.MeasurementData{},
112+
&enzymeml_v2.UnitDefinition{},
113+
&enzymeml_v2.BaseUnit{},
114+
}
115+
116+
dbManager, err := database.NewDBManager("enzymeml.db", models)
117+
if err != nil {
118+
log.Fatalf("failed to init DB: %v", err)
119+
}
120+
defer dbManager.Close()
121+
122+
handler, err := apiv2.NewHandler(dbManager)
123+
if err != nil {
124+
log.Fatalf("failed to build API handler: %v", err)
125+
}
126+
127+
log.Println("v2 API listening on :8080")
128+
log.Fatal(http.ListenAndServe(":8080", handler))
129+
}
130+
```
131+
132+
Run:
133+
134+
```bash
135+
go run .
136+
```
137+
138+
Example CRUD for documents:
139+
140+
```bash
141+
curl -X POST http://localhost:8080/v2/documents \
142+
-H "Content-Type: application/json" \
143+
-d '{"name":"my-doc","version":"2.0.0"}'
144+
145+
curl http://localhost:8080/v2/documents
146+
curl http://localhost:8080/v2/documents/1
147+
148+
curl -X PUT http://localhost:8080/v2/documents/1 \
149+
-H "Content-Type: application/json" \
150+
-d '{"name":"my-doc-updated","version":"2.0.1"}'
151+
152+
curl -X DELETE http://localhost:8080/v2/documents/1
153+
```
154+
155+
The API exposes CRUD for all v2 resources under `/v2`:
156+
`documents`, `creators`, `vessels`, `proteins`, `complexes`, `small-molecules`, `reactions`, `reaction-elements`, `modifier-elements`, `equations`, `variables`, `parameters`, `measurements`, `measurement-data`, `unit-definitions`, `base-units`.
157+
158+
With Huma, docs/spec are available automatically:
159+
160+
- `http://localhost:8080/v2/docs`
161+
- `http://localhost:8080/v2/openapi.json`
162+
- `http://localhost:8080/v2/openapi.yaml`
163+
79164
### 🗄️ Database Example
80165

81166
For a comprehensive example of how to use EnzymeML Go to create an enzymatic data database and power web applications, check out our detailed example:
82167

83168
**👉 [Database Example](./examples/database_example/)**
84169

85170
This example demonstrates:
171+
86172
- Setting up an EnzymeML-compliant database
87173
- Storing and retrieving enzymatic data
88174
- Web application integration
89175
- Best practices for data management
90176

91-
92177
## 🤝 Contributing
93178

94179
We welcome contributions from the community! Please feel free to submit a pull request.
@@ -101,4 +186,4 @@ This project is licensed under the **MIT License** - see the [LICENSE](LICENSE)
101186

102187
<div align="center">
103188
<strong>Made with ❤️ by the EnzymeML Team</strong>
104-
</div>
189+
</div>
Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,30 @@
1-
# Database Example
1+
# v2 API Example
22

3-
This example demonstrates how to:
3+
This example starts the EnzymeML v2 REST API using SQLite.
44

5-
1. Set up a SQLite database for EnzymeML documents
6-
2. Create and store a sample EnzymeML document with:
7-
- Creator information
8-
- Reaction vessel specifications
9-
- Proteins (enzymes)
10-
- Small molecules (substrates and products)
11-
- Reaction definitions
12-
- Measurement conditions
5+
## Run
136

14-
## Prerequisites
7+
```bash
8+
go run main.go
9+
```
10+
11+
The server starts at `http://localhost:8080`.
1512

16-
- Go 1.20 or later
17-
- SQLite 3.41 or later
18-
- EnzymeML Go package
13+
Interactive docs and OpenAPI:
1914

20-
## Run the example
15+
- `http://localhost:8080/v2/docs`
16+
- `http://localhost:8080/v2/openapi.json`
17+
- `http://localhost:8080/v2/openapi.yaml`
18+
19+
## Quick check
2120

2221
```bash
23-
go run main.go
22+
curl -X POST http://localhost:8080/v2/documents \
23+
-H "Content-Type: application/json" \
24+
-d '{"name":"my-doc","version":"2.0.0"}'
25+
26+
curl http://localhost:8080/v2/documents
27+
curl http://localhost:8080/v2/openapi.json
2428
```
29+
30+
The API includes CRUD endpoints for all v2 resources under `/v2`.
0 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)