Skip to content

Commit

Permalink
Add selection for prediction model for the user-uploaded structures
Browse files Browse the repository at this point in the history
  • Loading branch information
luk27official committed Apr 10, 2024
1 parent 6c0c70f commit 13e2b94
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 45 deletions.
54 changes: 34 additions & 20 deletions frontend/client/index/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,15 @@ <h1 class="text-center">
Use original structure
</label>
</div>
<div class="form-check">
<input class="form-check-input" type="checkbox" id="conservation-pdb"
title="If checked, a model that exploits conservation will be used to classify protein binding sites."
checked="checked">
<label class="form-check-label" for="conservation-pdb">
Use
<a href="./help#conservation" target="_blank">conservation</a>
</label>
</div>
<div id="pdb-chains" style="display: none">
<input id="pdb-chains-store" style="display: none">
<div id="pdb-chains-label">
Expand All @@ -81,9 +90,25 @@ <h1 class="text-center">
placeholder="A,B" title="Optional. Comma separated list of chains to analyze.">
</div>
<div>
<input class="form-check-input" type="checkbox" id="alphafold-user-model"
title="If checked, an AlphaFold model will be used to classify protein binding sites.">
<label for="user-alphafold" class="form-label">Custom AlphaFold structure</label>
<input type="radio" name="user-input-model" id="user-input-model-1" value="default"
title="If selected, a default prediction model will be used.">
<label for="user-input-model-1" class="form-label">Default prediction model</label><br>

<input type="radio" name="user-input-model" id="user-input-model-2" value="conservation_hmm"
checked="checked"
title="If selected, a default prediction model with conservation will be used.">
<label for="user-input-model-2" class="form-label">Default model with
<a href="./help#conservation" target="_blank">conservation</a></label><br>

<input type="radio" name="user-input-model" id="user-input-model-3" value="alphafold"
title="If selected, an AlphaFold prediction model will be used.">
<label for="user-input-model-3" class="form-label">AlphaFold model</label><br>

<input type="radio" name="user-input-model" id="user-input-model-4"
value="alphafold_conservation_hmm"
title="If selected, an AlphaFold prediction model with conservation will be used.">
<label for="user-input-model-4" class="form-label">AlphaFold model with
<a href="./help#conservation" target="_blank">conservation</a></label><br>
</div>
</div>
<div id="input-uniprot-block" style="display: none">
Expand All @@ -92,32 +117,21 @@ <h1 class="text-center">
<input type="text" class="form-control" id="uniprot-code" name="uniprotCode"
placeholder="Q5VSL9" title="PrankWeb will use AlphaFold predicted structure.">
</div>
</div>
</div>
<div class="card-footer" id="message" style="display: none">
<!-- Messages are here. -->
</div>
</div>

<div class="card" id="conservation-block">
<div class="card-header">
Conservation
</div>
<div class="card-body">
<div>
<div class="form-check-inline">
<input class="form-check-input" type="checkbox" id="conservation"
<div class="form-check">
<input class="form-check-input" type="checkbox" id="conservation-uniprot"
title="If checked, a model that exploits conservation will be used to classify protein binding sites."
checked="checked">
<label class="form-check-label" for="conservation">
<label class="form-check-label" for="conservation-uniprot">
Use
<a href="./help#conservation" target="_blank">conservation</a>
</label>
</div>
</div>
</div>
<div class="card-footer" id="message" style="display: none">
<!-- Messages are here. -->
</div>
</div>

<div>
<button type="submit" class="btn btn-primary float-md-end" id="submit-button">
Submit
Expand Down
26 changes: 17 additions & 9 deletions frontend/client/index/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ class View {
this.uniprotSection = document.getElementById("input-uniprot-block");
this.uniprotCode = document.getElementById("uniprot-code");
this.message = document.getElementById("message");
this.conservation = document.getElementById("conservation");
this.alphaFoldUserModel = document.getElementById("alphafold-user-model");
this.conservationPdb = document.getElementById("conservation-pdb");
this.conservationUniprot = document.getElementById("conservation-uniprot");
this.submit = document.getElementById("submit-button");
//
this.controller = null;
Expand Down Expand Up @@ -263,11 +263,21 @@ class View {
}

getConservation() {
return this.conservation.checked;
// this does not apply to user uploaded files, those are treated differently as the user
// selects the model directly
switch (this.getInputSection()) {
case View.PDB_VIEW:
return this.conservationPdb.checked;
case View.UNIPROT_VIEW:
return this.conservationUniprot.checked;
default:
return false;
}
}

getAlphaFoldUserModel() {
return this.alphaFoldUserModel.checked;
getModelUserUpload() {
const selectedModel = document.querySelector('input[name="user-input-model"]:checked');
return selectedModel.value;
}
}

Expand Down Expand Up @@ -458,8 +468,7 @@ class Submit {
submitUserFile(view) {
const structure = view.getUserFileObject();
const chains = view.getUserChains();
const conservation = view.getConservation();
const alphaFoldUserModel = view.getAlphaFoldUserModel();
const model = view.getModelUserUpload();
const formData = new FormData();
formData.append(
"structure", structure, structure.name);
Expand All @@ -468,8 +477,7 @@ class Submit {
this.asJsonBlob({
"chains": chains,
"structure-sealed": chains.length === 0,
"compute-conservation": conservation,
"use-alphafold-model": alphaFoldUserModel
"prediction-model": model,
}),
"configuration.json");
this.sendPostRequest("./api/v2/prediction/v3-user-upload", formData);
Expand Down
24 changes: 8 additions & 16 deletions web-server/src/database_v3.py
Original file line number Diff line number Diff line change
Expand Up @@ -296,36 +296,28 @@ def _create_identifier():
return today + "-" + str(uuid.uuid4()).upper()


def _get_p2rank_configuration(conservation: bool, alphaFoldModel: bool):
if alphaFoldModel:
if conservation:
return "alphafold_conservation_hmm"
else:
return "alphafold"

if conservation:
return "conservation_hmm"

return "default"

def _configuration_to_prediction(
root_directory: str, identifier: str, database: str,
user_configuration, structure_file: str):
chains = list({
chain.upper()
for chain in user_configuration.get("chains", [])
})
conservation = user_configuration.get("compute-conservation", False)
alphaFoldModel = user_configuration.get("use-alphafold-model", False)
p2rank_cfg = _get_p2rank_configuration(conservation, alphaFoldModel)

allowed_models = ["default", "alphafold", "conservation_hmm", "alphafold_conservation_hmm"]
model = user_configuration.get("prediction-model", "default")
if model not in allowed_models:
model = "default"

conservation = "conservation" in model

return Prediction(
directory=os.path.join(root_directory, identifier),
identifier=identifier,
database=database,
chains=chains,
structure_sealed=user_configuration.get("structure-sealed", False),
p2rank_configuration=p2rank_cfg,
p2rank_configuration=model,
structure_file=structure_file,
conservation="hmm" if conservation else "none",
metadata={},
Expand Down

0 comments on commit 13e2b94

Please sign in to comment.