Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add iterative searcher to Foldseek #97

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion backend/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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") {
Expand All @@ -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()
Expand All @@ -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")
}

Expand All @@ -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)
Expand Down
15 changes: 10 additions & 5 deletions backend/structuresearchjob.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand All @@ -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))
}
Expand All @@ -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,
}
Expand Down
4 changes: 4 additions & 0 deletions backend/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,10 @@ mv -f -- "${BASE}/query.lookup_tmp" "${BASE}/query.lookup"
parameters = append(parameters, "0")
}

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}
Expand Down
50 changes: 41 additions & 9 deletions frontend/Search.vue
Original file line number Diff line number Diff line change
Expand Up @@ -55,17 +55,27 @@
<template v-else>
DBs
</template>
&amp; search settings
</template>
<div slot="content">
<databases
:selected="database"
:all-databases="databases"
@update:selected="database = $event"
@update:all-databases="databases = $event"
:hideEmail="hideEmail"
></databases>

:selected="database"
:all-databases="databases"
@update:selected="database = $event"
@update:all-databases="databases = $event"
:hideEmail="hideEmail"
></databases>
</div>
</panel>
<panel collapsible collapsed render-collapsed>
<template slot="header">
<template v-if="!$vuetify.breakpoint.smAndDown">
Search Parameters
</template>
<template v-else>
Params
</template>
</template>
<div slot="content">
<v-radio-group v-model="mode">
<v-tooltip open-delay="300" top>
<template v-slot:activator="{ on }">
Expand All @@ -83,6 +93,21 @@

<TaxonomyAutocomplete v-model="taxFilter"></TaxonomyAutocomplete>

<v-radio-group v-model="iterativeSearch">
<v-tooltip open-delay="300" top>
<template v-slot:activator="{ on }">
<label v-on="on">
Iterative search
<v-icon color="#FFFFFFB3" style="margin-top:-3px" small v-on="on">{{ $MDI.HelpCircleOutline }}</v-icon>
</label>
</template>
<span>Improve sensitivity of search by performing an iterative search (--num-iterations 3).</span>
</v-tooltip>

<v-radio label="On" :value="true"></v-radio>
<v-radio label="Off" :value="false"></v-radio>
</v-radio-group>

<v-tooltip v-if="!$ELECTRON && !hideEmail" open-delay="300" top>
<template v-slot:activator="{ on }">
<v-text-field v-on="on" label="Notification Email (Optional)" placeholder="[email protected]" v-model="email"></v-text-field>
Expand Down Expand Up @@ -119,7 +144,7 @@
({{
databases.filter(db => database.includes(db.path)).map(db => db.name).sort().join(", ")
}})
</template> with {{ $STRINGS.APP_NAME }} in <strong>{{ modes[mode] }}</strong> mode.
</template> with {{ $STRINGS.APP_NAME }} in <strong>{{ modes[mode] }}</strong> mode<span v-if="iterativeSearch"><strong> iterative</strong></span>.
<div v-if="errorMessage != ''" class="v-alert v-alert--outlined warning--text mt-2">
<span>{{ errorMessage }}</span>
</div>
Expand Down Expand Up @@ -176,6 +201,7 @@ export default {
query: "",
database: JSON.parse(storage.getItem('database') || '[]'),
databases: JSON.parse(storage.getItem('databases') || '[]'),
iterativeSearch: JSON.parse(storage.getItem('iterativeSearch') || false),
taxFilter: JSON.parse(storage.getItem('taxFilter') || 'null'),
predictable: false,
accessionLoading: false,
Expand Down Expand Up @@ -235,6 +261,9 @@ export default {
databases(value) {
storage.setItem('databases', JSON.stringify(value));
},
iterativeSearch(value) {
storage.setItem('iterativeSearch', JSON.stringify(value));
},
taxFilter(value) {
storage.setItem('taxFilter', JSON.stringify(value));
},
Expand Down Expand Up @@ -265,6 +294,9 @@ export default {
if (this.taxFilter) {
request.taxfilter = this.taxFilter.value;
}
if (this.iterativeSearch) {
request.iterativesearch = this.iterativeSearch.value;
}
try {
this.inSearch = true;
const response = await this.$axios.post("api/ticket", convertToQueryUrl(request), {
Expand Down