summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--application.rb14
-rw-r--r--views/predict.haml2
2 files changed, 9 insertions, 7 deletions
diff --git a/application.rb b/application.rb
index 9c9cabb..d77842d 100644
--- a/application.rb
+++ b/application.rb
@@ -259,12 +259,14 @@ post '/predict/?' do
# validate identifier input
# transfered input
if !params[:identifier].blank?
- @identifier = params[:identifier]
- begin
- # get compound from SMILES
- @compound = Compound.from_smiles @identifier
- rescue
- @error_report = "Attention, '#{params[:identifier]}' is not a valid SMILES string."
+ # remove whitespaces they terminate a SMILES string
+ # can result in wrong conversion for compound object
+ @identifier = params[:identifier].gsub(/\s+/, "")
+ $logger.debug "input:#{@identifier}"
+ # get compound from SMILES
+ @compound = Compound.from_smiles @identifier
+ if @compound.blank?
+ @error_report = "Attention, '#{@identifier}' is not a valid SMILES string."
return haml :error
end
diff --git a/views/predict.haml b/views/predict.haml
index a4fa080..7f19071 100644
--- a/views/predict.haml
+++ b/views/predict.haml
@@ -24,7 +24,7 @@
});
function getInput(){
- identifier = document.getElementById("identifier").value;
+ identifier = document.getElementById("identifier").value.trim();
fileselect = document.getElementById("fileselect").value;
if (fileselect != ""){
return 1;