From 116d57452195b66b8760ad3a551824ed1bf99600 Mon Sep 17 00:00:00 2001 From: Martin Steinegger Date: Wed, 25 Dec 2024 01:37:21 +0700 Subject: [PATCH 1/4] Add iterative searches to worker.go --- backend/worker.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/backend/worker.go b/backend/worker.go index 55f3583..9679ec9 100644 --- a/backend/worker.go +++ b/backend/worker.go @@ -405,6 +405,11 @@ mv -f -- "${BASE}/query.lookup_tmp" "${BASE}/query.lookup" parameters = append(parameters, "0") } + if job.Mode == "iterative" { + parameters = append(parameters, "--num-iterations") + parameters = append(parameters, "3") + } + cmd, done, err := execCommand(config.Verbose, parameters...) if err != nil { errChan <- &JobExecutionError{err} From a0401b92874466f0748d655a841e99bf3d2f3814 Mon Sep 17 00:00:00 2001 From: Martin Steinegger Date: Wed, 25 Dec 2024 15:25:56 +0700 Subject: [PATCH 2/4] Add iterative searches to Foldseek --- backend/server.go | 5 +- backend/structuresearchjob.go | 15 +- backend/worker.go | 7 +- frontend/Search.vue | 619 ++++++++++++++++++++++------------ 4 files changed, 427 insertions(+), 219 deletions(-) diff --git a/backend/server.go b/backend/server.go index 2bc5f0c..827f461 100644 --- a/backend/server.go +++ b/backend/server.go @@ -264,6 +264,7 @@ func server(jobsystem JobSystem, config ConfigRoot) { var dbs []string var mode string var email string + var iterativesearch bool var taxfilter string if strings.HasPrefix(req.Header.Get("Content-Type"), "multipart/form-data") { @@ -285,6 +286,7 @@ func server(jobsystem JobSystem, config ConfigRoot) { dbs = req.Form["database[]"] mode = req.FormValue("mode") email = req.FormValue("email") + iterativesearch = req.FormValue("iterativesearch") == "true" taxfilter = req.FormValue("taxfilter") } else { err := req.ParseForm() @@ -296,6 +298,7 @@ func server(jobsystem JobSystem, config ConfigRoot) { dbs = req.Form["database[]"] mode = req.FormValue("mode") email = req.FormValue("email") + iterativesearch = req.FormValue("iterativesearch") == "true" taxfilter = req.FormValue("taxfilter") } @@ -315,7 +318,7 @@ func server(jobsystem JobSystem, config ConfigRoot) { modeWithoutComplex := strings.Join(append(modes[:modeIdx], modes[modeIdx+1:]...), "-") request, err = NewComplexSearchJobRequest(query, dbs, databases, modeWithoutComplex, config.Paths.Results, email, taxfilter) } else { - request, err = NewStructureSearchJobRequest(query, dbs, databases, mode, config.Paths.Results, email, taxfilter) + request, err = NewStructureSearchJobRequest(query, dbs, databases, mode, config.Paths.Results, email, iterativesearch, taxfilter) } } else { http.Error(w, "Job type not supported by this server", http.StatusBadRequest) diff --git a/backend/structuresearchjob.go b/backend/structuresearchjob.go index 32d4837..33866c9 100644 --- a/backend/structuresearchjob.go +++ b/backend/structuresearchjob.go @@ -10,10 +10,11 @@ import ( ) type StructureSearchJob struct { - Size int `json:"size" validate:"required"` - Database []string `json:"database" validate:"required"` - Mode string `json:"mode" validate:"oneof=3di tmalign 3diaa"` - TaxFilter string `json:"taxfilter"` + Size int `json:"size" validate:"required"` + Database []string `json:"database" validate:"required"` + Mode string `json:"mode" validate:"oneof=3di tmalign 3diaa"` + IterativeSearch bool `json:"iterativesearch"` + TaxFilter string `json:"taxfilter" query string } @@ -22,6 +23,9 @@ func (r StructureSearchJob) Hash() Id { h.Write(([]byte)(JobStructureSearch)) h.Write([]byte(r.query)) h.Write([]byte(r.Mode)) + if r.IterativeSearch { + h.Write([]byte("Iterative")) + } if r.TaxFilter != "" { h.Write([]byte(r.TaxFilter)) } @@ -48,11 +52,12 @@ func (r StructureSearchJob) WritePDB(path string) error { return nil } -func NewStructureSearchJobRequest(query string, dbs []string, validDbs []Params, mode string, resultPath string, email string, taxfilter string) (JobRequest, error) { +func NewStructureSearchJobRequest(query string, dbs []string, validDbs []Params, mode string, resultPath string, email string, iterativeSearch bool, taxfilter string) (JobRequest, error) { job := StructureSearchJob{ max(strings.Count(query, "HEADER"), 1), dbs, mode, + iterativeSearch, taxfilter, query, } diff --git a/backend/worker.go b/backend/worker.go index 9679ec9..4840384 100644 --- a/backend/worker.go +++ b/backend/worker.go @@ -405,11 +405,10 @@ mv -f -- "${BASE}/query.lookup_tmp" "${BASE}/query.lookup" parameters = append(parameters, "0") } - if job.Mode == "iterative" { - parameters = append(parameters, "--num-iterations") - parameters = append(parameters, "3") + if job.IterativeSearch { + parameters = append(parameters, "--num-iterations") + parameters = append(parameters, "3") } - cmd, done, err := execCommand(config.Verbose, parameters...) if err != nil { errChan <- &JobExecutionError{err} diff --git a/frontend/Search.vue b/frontend/Search.vue index b1f21e8..59e1cc6 100644 --- a/frontend/Search.vue +++ b/frontend/Search.vue @@ -1,200 +1,287 @@