1 package compbio.controllers;
5 import org.springframework.stereotype.Controller;
6 import org.springframework.web.bind.annotation.RequestMapping;
7 import org.springframework.web.bind.annotation.RequestMethod;
8 import org.springframework.web.bind.annotation.RequestParam;
10 import compbio.statistic.CassandraRequester;
13 * Spring controller for sequence queries. This version works in the servlet
16 * @author Alexander Sherstnev
17 * @author Natasha Sherstneva
20 * @version 1.0 December 2013
23 @RequestMapping("/features")
24 public class SSFeaturesController extends BasicController {
26 @RequestMapping(value = "query", method = RequestMethod.GET)
27 public String formCounterQuery(Map<String, Object> model) {
28 model.put("username", getPrincipalName());
29 model.put("type", 'E');
30 model.put("value", 50);
31 return "query/SSFeatures";
34 @RequestMapping(value = "features/results", method = RequestMethod.GET)
35 public String countSequences(@RequestParam("TypeFeatures") String typeFeature, @RequestParam("Percent") String percent,
36 Map<String, Object> model) {
37 model.put("username", getPrincipalName());
38 final long startTime = System.currentTimeMillis();
40 if (percent.equals("")) {
41 model.put("error", "The value must not be empty");
42 model.put("type", typeFeature);
43 model.put("value", percent);
44 return "query/SSFeatures";
49 realpercent = Integer.parseInt(percent.trim());
50 } catch (NumberFormatException e) {
51 model.put("error", "The value must be an integer number");
52 model.put("value", percent);
53 return "query/SSFeatures";
56 if (realpercent < 1) {
57 model.put("error", "The value must be greater than 0");
58 model.put("value", percent);
59 return "query/SSFeatures";
62 if (realpercent > 100) {
63 model.put("error", "The value must be less than 100");
64 model.put("value", percent);
65 return "query/SSFeatures";
68 CassandraRequester cr = new CassandraRequester();
69 Map<String, String> r = cr.readProteinsPrediction(typeFeature, realpercent);
70 model.put("results", r);
71 model.put("njobs", 0);
73 model.put("njobs", r.size());
75 final long endTime = System.currentTimeMillis();
76 model.put("timeExecution", (endTime - startTime));
77 model.put("feature", typeFeature);
78 model.put("percent", realpercent);
79 return "reportSSFeatures";