Skip to content

Commit

Permalink
Adding conformations ui
Browse files Browse the repository at this point in the history
  • Loading branch information
JaktensTid committed Dec 3, 2023
1 parent c601edf commit a4f63be
Show file tree
Hide file tree
Showing 5 changed files with 371 additions and 205 deletions.
28 changes: 24 additions & 4 deletions src/server/api_handlers/conformations.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from flask import Request

#from src.server.services.conformations.conformations_pipeline import permute_simulation
from src.server.services.conformations.conformations_pipeline import pipeline
from src.server.services.experiments_structure_loader import ConformationsExperimentsLoader
from src.server.api_handlers.api_handler import ApiHandler

Expand Down Expand Up @@ -41,15 +41,35 @@ def inference(self, request: Request) -> dict:
protein_files = request.files.getlist('proteinFileInput')
experiment_name = request.form['experimentName']
experiment_id = request.form['experimentId']
total_frames = int(request.form['totalFramesInput'])
system_temp = float(request.form['tempInput'])
take_frame_every = int(request.form['takeFrameEveryInput'])
step_size = float(request.form['stepSizeInput'])
replace_nonstandard_residues = True if request.form['replaceNonstandardResiduesInput'] == 'on' else False
integrator = request.form['integratorSelect']
friction_coeff = float(request.form['frictionCoeffInput'])
add_missing_hydrogens = True if request.form['addMissingHydrogensCheckbox'] == 'on' else False
add_missing_atoms = True if request.form['addMissingAtomsCheckbox'] == 'on' else False
ignore_missing_atoms = True if request.form['ignoreMissingAtomsCheckbox'] == 'on' else False

#simulation_result = permute_simulation(protein_files[0])
simulation_result = ''
(simulation_result, errors) = pipeline(pdb_content=protein_files[0],
total_frames=total_frames,
take_frame_every=take_frame_every,
integrator=integrator,
friction_coeff=friction_coeff,
step_size=step_size,
temperature_kelvin=system_temp,
replace_nonstandard_residues=replace_nonstandard_residues,
add_missing_atoms=add_missing_atoms,
add_missing_hydrogens=add_missing_hydrogens,
ignore_missing=ignore_missing_atoms)
if simulation_result:
self.experiments_loader.store_experiment(experiment_id, simulation_result)
self.experiments_loader.save_experiment_metadata(experiment_id, experiment_name)

return {
'id': experiment_id,
'name': experiment_name,
'data': {'pdb': simulation_result}
'data': {'pdb': simulation_result},
'errors': errors
}
1 change: 1 addition & 0 deletions src/server/frontend/src/storage.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ const store = createStore({
},
async conformations_inference({ commit }, { payload }) {
const { form, experiment } = payload;
debugger;
const formData = new FormData(form);
formData.append('experimentId', experiment.id ?? '');
formData.append('experimentName', experiment.name);
Expand Down
104 changes: 95 additions & 9 deletions src/server/frontend/src/views/ConformationsFormView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,110 @@ export default {
</script>

<template>
<form enctype="multipart/form-data" id="inferenceInputFormConformations"
v-on:submit.prevent="onFormSubmit">
<div class="row justify-content-center">
<div class="col-md-6">
<label for="proteinFileInput" class="col-form-label fs-4">.pdb file with molecule conformations</label>
<input type="file" multiple="multiple" accept="text/x-pdb" class="form-control" id="proteinFileInput"
name="proteinFileInput">
<form enctype="multipart/form-data" id="inferenceInputFormConformations" class="row" v-on:submit.prevent="onFormSubmit">
<div class="justify-content-center col-md-5">
<label for="proteinFileInput" class="col-form-label fs-4">.pdb file with molecule conformations</label>
<input type="file" required multiple="multiple" accept="text/x-pdb" class="form-control" id="proteinFileInput"
name="proteinFileInput">
</div>
<div class="justify-content-center col-md-7 mt-2">
<h4>Simulation parameters</h4>
<div class="form-group row">
<label for="totalFramesInput" class="col-sm-4 col-form-label">Total frames</label>
<div class="col-sm-8">
<input type="number" required min="0" step="1" class="form-control" id="totalFramesInput"
name="totalFramesInput"
aria-describedby="totalFramesInputHelp" placeholder="Total frames" value="20000">
</div>
</div>
<div class="mt-1 form-group row">
<label for="takeFrameEveryInput" class="col-sm-4 col-form-label">Take frame every</label>
<div class="col-sm-8">
<input type="number" required min="0" step="1" class="form-control" id="takeFrameEveryInput"
name="takeFrameEveryInput"
aria-describedby="takeFrameEveryInputHelp" placeholder="Total frames" value="1000">
</div>
</div>
<div class="mt-1 form-group row">
<label for="integratorSelect" class="col-sm-4 col-form-label">Integrator</label>
<div class="col-sm-8">
<select class="form-select" required aria-label="Default select example" id="integratorSelect"
name="integratorSelect">
<option selected value="LangevinIntegator">Langevin integator</option>
<option value="LangevinMiddleIntegrator">Langevin middle integator</option>
<option value="NoseHooverIntegrator">Nose hoover integrator</option>
<option value="BrownianIntegrator">Brownian integrator</option>
<option value="VariableVerletIntegrator">Variable verlet integrator</option>
</select>
</div>
</div>
<div class="mt-1 form-group row">
<label for="frictionCoeffInput" class="col-sm-4 col-form-label">Friction coeff / 10<sup>-12</sup></label>
<div class="col-sm-8">
<input type="number" min="0" required step="0.01" class="form-control" id="frictionCoeffInput"
name="frictionCoeffInput"
aria-describedby="takeFrameEveryInputHelp" placeholder="Friction coeff" value="1">
</div>
</div>
<div class="mt-1 form-group row">
<label for="stepSizeInput" class="col-sm-4 col-form-label">Step size / 10<sup>-12</sup></label>
<div class="col-sm-8">
<input type="number" min="0" required step="0.001" class="form-control" id="stepSizeInput"
name="stepSizeInput"
aria-describedby="takeFrameEveryInputHelp" placeholder="Simulation step size" value="0.002">
</div>
</div>
<div class="mt-1 form-group row">
<label for="tempInput" class="col-sm-4 col-form-label">System temp in K</label>
<div class="col-sm-8">
<input type="number" min="0" required step="0.001" class="form-control" id="tempInput"
name="tempInput"
aria-describedby="takeFrameEveryInputHelp" placeholder="Simulation step size" value="273.15">
</div>
</div>
<div class="mt-1 form-group row">
<label for="replaceNonstandardResiduesInput" class="col-sm-4 col-form-label">Replace nonstandard residues</label>
<div class="col-sm-8">
<input type="checkbox" class="form-check-input" id="replaceNonstandardResiduesInput"
name="replaceNonstandardResiduesInput"
aria-describedby="takeFrameEveryInputHelp" placeholder="Simulation step size" checked>
</div>
</div>
<div class="mt-1 form-group row">
<label for="addMissingAtomsCheckbox" class="col-sm-4 col-form-label">Add missing atoms</label>
<div class="col-sm-8">
<input type="checkbox" class="form-check-input" id="addMissingAtomsCheckbox"
name="addMissingAtomsCheckbox"
aria-describedby="takeFrameEveryInputHelp" placeholder="Simulation step size" checked>
</div>
</div>
<div class="mt-1 form-group row">
<label for="addMissingHydrogensCheckbox" class="col-sm-4 col-form-label">Add missing hydrogens</label>
<div class="col-sm-8">
<input type="checkbox" class="form-check-input" id="addMissingHydrogensCheckbox"
name="addMissingHydrogensCheckbox"
aria-describedby="takeFrameEveryInputHelp" placeholder="Simulation step size" checked>
</div>
</div>
<div class="mt-1 form-group row">
<label for="ignoreMissingAtomsCheckbox" class="col-sm-4 col-form-label">Ignore missing atoms</label>
<div class="col-sm-8">
<input type="checkbox" class="form-check-input" id="ignoreMissingAtomsCheckbox"
name="ignoreMissingAtomsCheckbox"
aria-describedby="takeFrameEveryInputHelp" placeholder="Simulation step size" checked>
</div>
</div>
</div>
<div class="row justify-content-center m-4">
<div class="col-md-4">
<div class="btn-group mt-4" role="group"
aria-label="Basic checkbox toggle button group">
<div class="btn-group mt-4" role="group" aria-label="Basic checkbox toggle button group">
<button type="submit" id="submitInference" class="btn btn-lg btn-primary">
Submit
</button>
</div>
</div>
</div>
<hr/>

</form>
</template>
2 changes: 1 addition & 1 deletion src/server/frontend/src/views/ConformationsLab.vue
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export default {
<template>
<ExperimentsView :state="experimentsState" :api="experimentsApi">
<template v-slot:labTitle>
<h4>Conformations lab (pre-alpha)</h4>
<h2>Conformations lab (pre-alpha)</h2>
</template>
<template v-slot:labForm="labForm">
<ConformationsFormView :onFormSubmit="labForm.onFormSubmit"/>
Expand Down
Loading

0 comments on commit a4f63be

Please sign in to comment.