Skip to content

Commit faa75db

Browse files
committed
clean up and update
1 parent 2b0cbb2 commit faa75db

File tree

9 files changed

+198
-370
lines changed

9 files changed

+198
-370
lines changed

Dockerfile

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,11 @@ RUN go mod download
1212

1313
# Copy the source code
1414
COPY main.go ./
15-
COPY /data/conversions.csv /app/data/conversions.csv
15+
16+
# Download conversions.csv from OSCEM GitHub repository
17+
RUN mkdir -p /app/data && \
18+
curl -L https://raw.githubusercontent.com/osc-em/Converter/main/csv/pdb_conversions.csv -o /app/data/conversions.csv
19+
1620
COPY /data/mmcif_pdbx_v50.dic /app/data/mmcif_pdbx_v50.dic
1721
COPY depositions/onedep ./depositions/onedep
1822
COPY docs ./docs
@@ -70,7 +74,7 @@ RUN pip install --upgrade pip && \
7074
WORKDIR /app
7175

7276
ENV PORT=8080
73-
ENV ALLOW_ORIGINS=http://localhost:4201
77+
ENV ALLOW_ORIGINS=http://localhost:4200
7478
ENV RCSBROOT=/app/scripts/packages/maxit-v11.300-prod-src
7579

7680
EXPOSE 8080

depositions/onedep/config.go

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,13 @@ const (
1818
)
1919

2020
type RequestCreate struct {
21-
Email string `json:"email" binding:"required,email"`
22-
OrcidIds []string `json:"orcidIds" binding:"required"`
23-
Password string `json:"password" binding:"-"`
24-
Country string `json:"country" binding:"required"`
25-
Method string `json:"method" binding:"required"`
26-
JWTToken string `json:"jwtToken" binding:"required"`
21+
Email string `json:"email" binding:"required,email"`
22+
OrcidIds []string `json:"orcidIds" binding:"required"`
23+
Password string `json:"password"`
24+
Country string `json:"country" binding:"required"`
25+
Method string `json:"method" binding:"required"`
26+
JWTToken string `json:"jwtToken" binding:"required"`
27+
Coordinates bool `json:"coordinates"`
2728
}
2829

2930
type FileMetadata struct {
@@ -44,8 +45,11 @@ type UploadedFile struct {
4445
FileID string `json:"FileID"`
4546
}
4647
type EmMethod struct {
47-
Type string `json:"type"`
48-
Subtype string `json:"subtype,omitempty"`
48+
Type string `json:"type"`
49+
Subtype string `json:"subtype,omitempty"`
50+
Coordinates bool `json:"coordinates"`
51+
SfOnly bool `json:"sf_only"`
52+
RelatedEmdb string `json:"related_emdb,omitempty"`
4953
}
5054
type EmMethodExtended struct {
5155
Type string `json:"type"`
@@ -71,10 +75,10 @@ type UserInfo struct {
7175
}
7276

7377
type FileUpload struct {
74-
Name string `json:"name"`
75-
Type string `json:"type"`
76-
Contour float32 `json:"contour"`
77-
Details string `json:"details"`
78+
Name string `json:"name"`
79+
Type OneDepType `json:"type"`
80+
Contour float32 `json:"contour"`
81+
Details string `json:"details"`
7882
}
7983

8084
type DepositionFile struct {
@@ -126,6 +130,7 @@ type OneDepType string
126130
const (
127131
ADD_MAP OneDepType = "add-map"
128132
CO_CIF OneDepType = "co-cif"
133+
MD_CIF OneDepType = "md-cif"
129134
CO_PDB OneDepType = "co-pdb"
130135
FSC_XML OneDepType = "fsc-xml"
131136
HALF_MAP OneDepType = "half-map"

depositions/onedep/onedep.go

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,13 @@ func CreateDeposition(client *http.Client, userInput UserInfo, token string) (De
8181

8282
// creates a new instance of DepositionFile
8383
func NewDepositionFile(depositionID string, fileUpload FileUpload) *DepositionFile {
84-
fD := DepositionFile{depositionID, 0, fileUpload.Name, fileUpload.Type, [3]float32{}, fileUpload.Contour, fileUpload.Details}
84+
fD := DepositionFile{depositionID,
85+
0,
86+
fileUpload.Name,
87+
string(fileUpload.Type),
88+
[3]float32{},
89+
fileUpload.Contour,
90+
fileUpload.Details}
8591
return &fD
8692
}
8793

@@ -335,19 +341,18 @@ func ProcessDeposition(client *http.Client, deposition string, token string) (st
335341
if err != nil {
336342
return "", fmt.Errorf("errored when sending request to the server: %v", err)
337343
}
344+
defer resp.Body.Close()
345+
338346
statusCode := resp.StatusCode
339-
err = resp.Body.Close()
340-
if err != nil {
341-
return "", fmt.Errorf("error closing response body: %v", err)
342-
}
343347
if statusCode == 200 || statusCode == 201 {
344348
return "success", nil
345-
} else {
346-
body, err := io.ReadAll(resp.Body)
347-
if err != nil {
348-
return "", fmt.Errorf("create: failed to create new deposition: status code %v, status %s, unreadable body", resp.StatusCode, resp.Status)
349-
}
350-
return "", fmt.Errorf("create: failed to create new deposition: status code %v, status %s, body %s", resp.StatusCode, resp.Status, string(body))
351349
}
352350

351+
// Read error response body before it's closed
352+
body, err := io.ReadAll(resp.Body)
353+
if err != nil {
354+
return "", fmt.Errorf("process: failed to process deposition: status code %v, status %s, unreadable body", resp.StatusCode, resp.Status)
355+
}
356+
return "", fmt.Errorf("process: failed to process deposition: status code %v, status %s, body %s", resp.StatusCode, resp.Status, string(body))
357+
353358
}

docs/docs.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -676,6 +676,7 @@ const docTemplate = `{
676676
"enum": [
677677
"add-map",
678678
"co-cif",
679+
"md-cif",
679680
"co-pdb",
680681
"fsc-xml",
681682
"half-map",
@@ -710,6 +711,7 @@ const docTemplate = `{
710711
"x-enum-varnames": [
711712
"ADD_MAP",
712713
"CO_CIF",
714+
"MD_CIF",
713715
"CO_PDB",
714716
"FSC_XML",
715717
"HALF_MAP",
@@ -752,6 +754,9 @@ const docTemplate = `{
752754
"orcidIds"
753755
],
754756
"properties": {
757+
"coordinates": {
758+
"type": "boolean"
759+
},
755760
"country": {
756761
"type": "string"
757762
},

docs/swagger.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -668,6 +668,7 @@
668668
"enum": [
669669
"add-map",
670670
"co-cif",
671+
"md-cif",
671672
"co-pdb",
672673
"fsc-xml",
673674
"half-map",
@@ -702,6 +703,7 @@
702703
"x-enum-varnames": [
703704
"ADD_MAP",
704705
"CO_CIF",
706+
"MD_CIF",
705707
"CO_PDB",
706708
"FSC_XML",
707709
"HALF_MAP",
@@ -744,6 +746,9 @@
744746
"orcidIds"
745747
],
746748
"properties": {
749+
"coordinates": {
750+
"type": "boolean"
751+
},
747752
"country": {
748753
"type": "string"
749754
},

docs/swagger.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ definitions:
110110
enum:
111111
- add-map
112112
- co-cif
113+
- md-cif
113114
- co-pdb
114115
- fsc-xml
115116
- half-map
@@ -144,6 +145,7 @@ definitions:
144145
x-enum-varnames:
145146
- ADD_MAP
146147
- CO_CIF
148+
- MD_CIF
147149
- CO_PDB
148150
- FSC_XML
149151
- HALF_MAP
@@ -176,6 +178,8 @@ definitions:
176178
- XS_MTZ
177179
onedep.RequestCreate:
178180
properties:
181+
coordinates:
182+
type: boolean
179183
country:
180184
type: string
181185
email:

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ toolchain go1.23.8
77
require (
88
github.com/gin-contrib/cors v1.7.3
99
github.com/gin-gonic/gin v1.10.0
10-
github.com/osc-em/converter-OSCEM-to-mmCIF v1.1.6
10+
github.com/osc-em/converter-OSCEM-to-mmCIF v1.1.8
1111
github.com/swaggo/files v1.0.1
1212
github.com/swaggo/gin-swagger v1.6.0
1313
github.com/swaggo/swag v1.16.4

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@ github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w
6565
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
6666
github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M=
6767
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
68-
github.com/osc-em/converter-OSCEM-to-mmCIF v1.1.6 h1:OxIRwRl5+/B13iSJc9/Z55ai1Q8GuK0I76ycublB+XE=
69-
github.com/osc-em/converter-OSCEM-to-mmCIF v1.1.6/go.mod h1:DO+6haNZuJjZgNwafIZdznFWzXPWazSG5iSKjhdBKPw=
68+
github.com/osc-em/converter-OSCEM-to-mmCIF v1.1.8 h1:ZT9usrIWucBG6GxiVVFHutdp6M761vVsX6FCNJyl4mA=
69+
github.com/osc-em/converter-OSCEM-to-mmCIF v1.1.8/go.mod h1:DO+6haNZuJjZgNwafIZdznFWzXPWazSG5iSKjhdBKPw=
7070
github.com/pelletier/go-toml/v2 v2.2.3 h1:YmeHyLY8mFWbdkNWwpr+qIL2bEqT0o95WSdkNHvL12M=
7171
github.com/pelletier/go-toml/v2 v2.2.3/go.mod h1:MfCQTFTvCcUyyvvwm1+G6H/jORL20Xlb6rzQu9GuUkc=
7272
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=

0 commit comments

Comments
 (0)