Skip to content

Commit 7603b0f

Browse files
committed
feat: sunburst plot (ChemOnt)
1 parent 19f22ae commit 7603b0f

File tree

14 files changed

+4453
-628
lines changed

14 files changed

+4453
-628
lines changed

Dockerfile-server

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@ COPY api/schemas ./swagger-ui/schemas
1616
COPY entrypoint-mb3server.sh ./entrypoint-mb3server.sh
1717

1818
EXPOSE 8080
19-
ENTRYPOINT sh entrypoint-mb3server.sh "${MB3_API_URL}"
19+
ENTRYPOINT ["sh", "entrypoint-mb3server.sh", "${MB3_API_URL}"]

api/openapi.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ paths:
138138

139139
/metadata:
140140
get:
141-
summary: Get the metadata of the database and the current dataset in use. It includes the version, timestamp, git commit hash, unique spectra count (SPLASH), unique compound count (InChI) and all compound classes with counts.
141+
summary: Get the metadata of the database and the current dataset in use. It includes the version, timestamp, git commit hash, unique spectra count (SPLASH), unique compound count (InChI) and compound classes (free text/ChemOnt) with counts.
142142
operationId: getMetadata
143143
responses:
144144
"200":

api/schemas/FilterOptions.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,3 +86,13 @@ components:
8686
count:
8787
type: integer
8888
minimum: 1
89+
compound_class_chemont:
90+
type: array
91+
items:
92+
type: object
93+
properties:
94+
name:
95+
type: string
96+
count:
97+
type: integer
98+
minimum: 1

pkg/database/postgres.go

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ func (p *PostgresSQLDB) GetMetadata() (*massbank.MbMetaData, error) {
287287
result.SpectraCount = spectraCount
288288
result.CompoundCount = compoundCount
289289

290-
// compound classes
290+
// compound classes (free text)
291291
query = "SELECT class, COUNT(class) as count FROM compound_class GROUP BY class ORDER BY class;"
292292
stmt, err = p.database.Prepare(query)
293293
if err != nil {
@@ -314,6 +314,33 @@ func (p *PostgresSQLDB) GetMetadata() (*massbank.MbMetaData, error) {
314314
}
315315
}
316316

317+
// compound classes (ClassyFire)
318+
query = "SELECT identifier, COUNT(identifier) as count FROM compound_link WHERE database = 'ChemOnt' GROUP BY identifier ORDER BY count DESC;"
319+
stmt, err = p.database.Prepare(query)
320+
if err != nil {
321+
return nil, err
322+
}
323+
rows, err = stmt.Query()
324+
stmt.Close()
325+
if err == nil {
326+
result.CompoundClassChemOnt = []string{}
327+
result.CompoundClassCountChemOnt = []uint{}
328+
for rows.Next() {
329+
var class string
330+
var count uint
331+
if err := rows.Scan(&class, &count); err != nil {
332+
return nil, err
333+
}
334+
result.CompoundClassChemOnt = append(result.CompoundClassChemOnt, class)
335+
result.CompoundClassCountChemOnt = append(result.CompoundClassCountChemOnt, count)
336+
}
337+
rows.Close()
338+
} else {
339+
if err != sql.ErrNoRows {
340+
return nil, err
341+
}
342+
}
343+
317344
return result, nil
318345
}
319346

pkg/massbank/model.go

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,17 @@ import (
55
)
66

77
type MbMetaData struct {
8-
GitCommit string `json:"git_commit"`
9-
Version string `json:"Version"`
10-
Timestamp string `json:"timestamp"`
11-
SpectraCount uint `json:"spectra_count"`
12-
CompoundCount uint `json:"compound_count"`
13-
CompoundName []string `json:"compound_name"`
14-
CompoundNameCount []uint `json:"compound_name_count"`
15-
CompoundClass []string `json:"compound_class"`
16-
CompoundClassCount []uint `json:"compound_class_count"`
8+
GitCommit string `json:"git_commit"`
9+
Version string `json:"Version"`
10+
Timestamp string `json:"timestamp"`
11+
SpectraCount uint `json:"spectra_count"`
12+
CompoundCount uint `json:"compound_count"`
13+
CompoundName []string `json:"compound_name"`
14+
CompoundNameCount []uint `json:"compound_name_count"`
15+
CompoundClass []string `json:"compound_class"`
16+
CompoundClassCount []uint `json:"compound_class_count"`
17+
CompoundClassChemOnt []string `json:"compound_class_chemont"`
18+
CompoundClassCountChemOnt []uint `json:"compound_class_count_chemont"`
1719
}
1820

1921
type SubtagProperty struct {

pkg/mb3server/api-impl.go

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -618,12 +618,13 @@ func GetMetadata() (*Metadata, error) {
618618
}
619619

620620
result := Metadata{
621-
Version: metadata.Version,
622-
Timestamp: metadata.Timestamp,
623-
GitCommit: metadata.GitCommit,
624-
SpectraCount: int32(metadata.SpectraCount),
625-
CompoundCount: int32(metadata.CompoundCount),
626-
CompoundClass: []MetadataCompoundClassInner{},
621+
Version: metadata.Version,
622+
Timestamp: metadata.Timestamp,
623+
GitCommit: metadata.GitCommit,
624+
SpectraCount: int32(metadata.SpectraCount),
625+
CompoundCount: int32(metadata.CompoundCount),
626+
CompoundClass: []MetadataCompoundClassInner{},
627+
CompoundClassChemont: []MetadataCompoundClassInner{},
627628
}
628629

629630
for i, compoundClass := range metadata.CompoundClass {
@@ -632,6 +633,12 @@ func GetMetadata() (*Metadata, error) {
632633
Count: int32(metadata.CompoundClassCount[i]),
633634
})
634635
}
636+
for i, compoundClassChemOnt := range metadata.CompoundClassChemOnt {
637+
result.CompoundClassChemont = append(result.CompoundClassChemont, MetadataCompoundClassInner{
638+
Name: compoundClassChemOnt,
639+
Count: int32(metadata.CompoundClassCountChemOnt[i]),
640+
})
641+
}
635642

636643
return &result, nil
637644
}

pkg/mb3server/api_default.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/mb3server/model_metadata.go

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)