diff --git a/conformations/Dockerfile b/conformations/Dockerfile index 8b19fdf8..02708732 100644 --- a/conformations/Dockerfile +++ b/conformations/Dockerfile @@ -25,4 +25,4 @@ RUN conda init zsh RUN conda create --name conformations RUN conda install -n conformations -c conda-forge -y --file requirements.txt -ENTRYPOINT ["conda", "run", "--no-capture-output", "-n", "conformations", "python", "conformations_microservice.py", "--host=0.0.0.0", "--port=5785"] \ No newline at end of file +ENTRYPOINT ["conda", "run", "--no-capture-output", "-n", "conformations", "python", "-u", "conformations_microservice.py", "--host=0.0.0.0", "--port=5785"] \ No newline at end of file diff --git a/conformations/conformations_microservice.py b/conformations/conformations_microservice.py index d416c569..27d35bda 100644 --- a/conformations/conformations_microservice.py +++ b/conformations/conformations_microservice.py @@ -10,36 +10,30 @@ @app.route('/conformations', methods=['POST']) def conformations(): - try: - data = request.get_json() - pdb_content = data.get('pdb_content') - total_frames = data.get('total_frames', 10000) - take_frame_every = data.get('take_frame_every', 1000) - integrator = data.get('integrator', 'LangevinIntegator') - friction_coeff = data.get('friction_coeff', 1.0) - step_size = data.get('step_size', 0.002) - temperature_kelvin = data.get('temperature_kelvin', 273.15) - replace_nonstandard_residues = data.get('replace_nonstandard_residues', True) - add_missing_atoms = data.get('add_missing_atoms', True) - add_missing_hydrogens = data.get('add_missing_hydrogens', True) - ignore_missing = data.get('ignore_missing', False) - simulation_result = pipeline.pipeline(pdb_content, - total_frames, - take_frame_every, - integrator, - friction_coeff, - step_size, - temperature_kelvin, - replace_nonstandard_residues, - add_missing_atoms, - add_missing_hydrogens, - ignore_missing) - return jsonify({'simulation_result': simulation_result}) - - except Exception as e: - print(str(e)) - response = {'status': 'error', 'message': str(e)} - return jsonify(response), 500 + data = request.get_json() + pdb_content = data.get('pdb_content') + total_frames = data.get('total_frames', 10000) + take_frame_every = data.get('take_frame_every', 1000) + integrator = data.get('integrator', 'LangevinIntegator') + friction_coeff = data.get('friction_coeff', 1.0) + step_size = data.get('step_size', 0.002) + temperature_kelvin = data.get('temperature_kelvin', 273.15) + replace_nonstandard_residues = data.get('replace_nonstandard_residues', True) + add_missing_atoms = data.get('add_missing_atoms', True) + add_missing_hydrogens = data.get('add_missing_hydrogens', True) + ignore_missing = data.get('ignore_missing', False) + simulation_result = pipeline.pipeline(pdb_content, + total_frames, + take_frame_every, + integrator, + friction_coeff, + step_size, + temperature_kelvin, + replace_nonstandard_residues, + add_missing_atoms, + add_missing_hydrogens, + ignore_missing) + return jsonify({'simulation_result': simulation_result}) if __name__ == '__main__': diff --git a/conformations/conformations_pipeline.py b/conformations/conformations_pipeline.py index 8d98c21c..3c9f0e8f 100644 --- a/conformations/conformations_pipeline.py +++ b/conformations/conformations_pipeline.py @@ -28,8 +28,8 @@ class LogsFilter(logging.Filter): def filter(self, record): global last_log if record.levelno == logging.INFO: - logs_url = urljoin(settings.MAIN_SERVICE_URL, '/conformations/logs') - requests.post(logs_url, json={'get-logs', record.msg}) + logs_url = urljoin(settings.MAIN_SERVICE_URL, 'logging/conformations/logs') + requests.post(logs_url, json={'get-logs': record.msg}) return True @@ -37,8 +37,8 @@ class ErrorsFilter(logging.Filter): def filter(self, record): global last_error if record.levelno == logging.ERROR: - logs_url = urljoin(settings.MAIN_SERVICE_URL, '/conformations/errors') - requests.post(logs_url, json={'conformations-errors', record.msg}) + logs_url = urljoin(settings.MAIN_SERVICE_URL, 'logging/conformations/errors') + requests.post(logs_url, json={'conformations-errors': record.msg}) return True @@ -104,7 +104,7 @@ def pipeline(pdb_content: str, meaningful_errors_cache = set() friction_coeff = friction_coeff / picosecond - step_size = step_size / picoseconds + step_size = step_size * picoseconds def integrator_factory(): if integrator == 'LangevinIntegator': @@ -358,7 +358,7 @@ def inner(): return pdb_output else: conformations_errors_logger.info('') - logger.info('Unable to generate conformations for this .pdb file') + logger.error('Unable to generate conformations for this .pdb file') return finally: remove_conformations_backups() diff --git a/src/server/frontend/src/views/ConformationsInferenceView.vue b/src/server/frontend/src/views/ConformationsInferenceView.vue index 29800112..79bf81f5 100644 --- a/src/server/frontend/src/views/ConformationsInferenceView.vue +++ b/src/server/frontend/src/views/ConformationsInferenceView.vue @@ -20,21 +20,14 @@ export default { return { views: views, viewsItems: Object.keys(views), - selectedView: views.default, - stage: null, - pdbComponent: null + selectedView: views.default } }, methods: { setView(evt) { const viewKey = evt.target.value; this.selectedView = this.views[viewKey]; - if (this.selectedView === this.views.default) { - this.render(); - return; - } - this.pdbComponent.removeAllRepresentations(); - this.pdbComponent.addRepresentation(this.selectedView.key); + this.render(); }, cleanStage() { if (this.stage) @@ -50,7 +43,16 @@ export default { stage.setParameters({ backgroundColor: 'white' }); const proteinFileContentBlob = new Blob([experiment.data.pdb], { type: 'text/plain' }); const proteinFile = new File([proteinFileContentBlob], 'protein.pdb', { type: 'text/plain' }); - stage.loadFile(proteinFile, { defaultRepresentation: true, asTrajectory: true }).then(function(component) { + + let params = {} + if(this.selectedView === this.views.default){ + params = { defaultRepresentation: true, asTrajectory: true } + } + else{ + params = { asTrajectory: true } + } + + stage.loadFile(proteinFile, params).then((component) => { var traj = component.addTrajectory().trajectory var player = new NGL.TrajectoryPlayer(traj, { step: 1, @@ -63,6 +65,10 @@ export default { direction: "bounce" }); player.play(); + + if(this.selectedView !== this.views.default){ + component.addRepresentation(this.selectedView.key); + } component.autoView(); }); @@ -76,7 +82,7 @@ export default {