Skip to content

Commit d989e5a

Browse files
authored
Skip shapeRegex matching if ssuf is empty (#141)
* add shape test * dont match on empty `ssuf` * add empty shape test
1 parent 12cf072 commit d989e5a

File tree

2 files changed

+32
-6
lines changed

2 files changed

+32
-6
lines changed

dataset/dataset.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -386,9 +386,11 @@ func LoadDataset(projectDir string, pdbList string, rsuf string, lsuf string, ss
386386
ligand = fullPath
387387
}
388388

389-
ShapeMatch := shapeRegex.MatchString(basePath)
390-
if ShapeMatch {
391-
shape = fullPath
389+
if ssuf != "" {
390+
ShapeMatch := shapeRegex.MatchString(basePath)
391+
if ShapeMatch {
392+
shape = fullPath
393+
}
392394
}
393395

394396
if entry, ok := m[root]; !ok {

dataset/dataset_test.go

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -160,17 +160,21 @@ func TestLoadDataset(t *testing.T) {
160160
"some/path/structure5_target.pdb\n"+
161161
"some/path/structure5something_r_u.pdb\n"+
162162
"some/path/structure5something_l_u.pdb\n"+
163-
"some/path/structure5something_target.pdb\n"), 0644)
163+
"some/path/structure5something_target.pdb\n"+
164+
"some/path/structure6_r_u.pdb\n"+
165+
"some/path/structure6_l_u.pdb\n"+
166+
"some/path/structure6_shape.pdb\n"), 0644)
167+
164168
defer os.Remove("pdb.list")
165169

166170
// Pass by loading a valid dataset
167171

168-
tArr, errData := LoadDataset(projectDir, "pdb.list", "_r_u", "_l_u", "")
172+
tArr, errData := LoadDataset(projectDir, "pdb.list", "_r_u", "_l_u", "_shape")
169173
if errData != nil {
170174
t.Errorf("Failed to load dataset: %s", err.Error())
171175
}
172176

173-
if len(tArr) != 6 {
177+
if len(tArr) != 7 {
174178
t.Errorf("Failed to load dataset: %d", len(tArr))
175179
}
176180

@@ -189,6 +193,9 @@ func TestLoadDataset(t *testing.T) {
189193
t.Errorf("Failed: Not all toppar files were loaded")
190194
}
191195
}
196+
if len(v.Shape) != 0 {
197+
t.Errorf("Failed: Shape wrongly loaded")
198+
}
192199
}
193200
if v.ID == "structure3" {
194201
if len(v.Receptor) != 3 {
@@ -200,6 +207,23 @@ func TestLoadDataset(t *testing.T) {
200207
t.Errorf("Failed: More than one miscpdb was loaded")
201208
}
202209
}
210+
if v.ID == "structure6" {
211+
if len(v.Shape) != 1 {
212+
t.Errorf("Failed: Shape not identified")
213+
}
214+
}
215+
}
216+
217+
// Pass by not loading an empty shape
218+
tArr, errData = LoadDataset(projectDir, "pdb.list", "_r_u", "_l_u", "")
219+
if errData != nil {
220+
t.Errorf("Failed to load dataset: %s", err.Error())
221+
}
222+
223+
for _, v := range tArr {
224+
if len(v.Shape) != 0 {
225+
t.Error("Failed: Shape wrongly loaded")
226+
}
203227
}
204228

205229
// Fail by loading a dataset with a wrong file

0 commit comments

Comments
 (0)