model.put("date2", date2);
List<DataBase> res = cr.countJobs(date1, date2);
model.put("result", res);
+ model.put("ndays", res.size());
final long endTime = System.currentTimeMillis();
model.put("timeExecution", (endTime - startTime));
model.put("option", option);
package compbio.controllers;
import java.util.Calendar;
+import java.util.List;
import java.util.Map;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
+
import compbio.statistic.CassandraRequester;
+import compbio.cassandra.DataBase;
import compbio.statistic.StatisticsProt;
/**
model.put("date1", date1);
model.put("date2", date2);
model.put("option", option);
- model.put("result", sp.extractExecutionTime(date1, date2));
+ List<DataBase> res = sp.extractExecutionTime(date1, date2);
+ model.put("result", res);
+ model.put("ndays", res.size() - 1);
final long endTime = System.currentTimeMillis();
model.put("timeExecution", (endTime - startTime));
return "/reportTimeExecution";
import java.util.List;
import java.util.Map;
+import java.util.regex.Pattern;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import compbio.cassandra.ProteinBean;
import compbio.cassandra.DataBase;
+import compbio.data.sequence.SequenceUtil;
import compbio.statistic.CassandraRequester;
/**
+ * Spring controller for sequence search. This version works in the servlet style.
+ *
* @author Alexander Sherstnev
* @author Natasha Sherstneva
+ *
+ * @since 0.5
+ * @version 1.0 December 2013
*/
@Controller
public class SequenceController {
+
+ /**
+ * pattern for NON-protein alphabet symbols
+ */
+ private final Pattern NONPROTEIN = Pattern.compile("[^ARNDCQEGHILKMFPSTWYV]+", Pattern.CASE_INSENSITIVE);
@RequestMapping(value = "/sequence/query1", method = RequestMethod.GET)
public String formSequenceQuery(Map<String, Object> model) {
public String findSequence(@RequestParam("sequence") String sequence, @RequestParam("protein") String flag, Map<String, Object> model) {
final long startTime = System.currentTimeMillis();
+ // input checks
String trimmedsequence = sequence.replaceAll("\\s", "");
+ if (trimmedsequence.equalsIgnoreCase("")) {
+ model.put("error", "The sequence cann't be empty");
+ model.put("value", sequence);
+ return "queryProteinSequence";
+ }
+ if (NONPROTEIN.matcher(trimmedsequence).find()) {
+ model.put("error", "The sequence contains symbols not from the standard protein alphabet");
+ model.put("value", sequence);
+ return "queryProteinSequence";
+ }
+
model.put("njobs", 0);
model.put("prot", trimmedsequence);
model.put("flag", flag);
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
+<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<body>
<div class="container">
<jsp:include page="fragments/mainmenu.jsp" />
+ <spring:url value="/sequence/querysequence" var="query"/>
<div class="panel panel-default">
<div class="panel-heading">
<div style="font-weight:bold;">Enter protein sequence</div>
</div>
<div class="panel-body">
- <spring:url value="/sequence/querysequence" var="formurl"/>
- <form method="get" action="${fn:escapeXml(formurl)}">
- <p><textarea class="form-control" rows="3" name="sequence">${value}</textarea></p>
- <p><input type="radio" name="protein" value="whole">search for the whole sequence<br/>
- <input type="radio" name="protein" value="part" Checked>search for partial sequence matching</p>
- <input type="submit" name="Search" value="Search"/>
+ <form method="get" action="${query}">
+ <c:choose>
+ <c:when test="${error == null}">
+ <div class="form-group">
+ <p><textarea class="form-control" rows="3" name="sequence">${value}</textarea></p>
+ <p><input type="radio" name="protein" value="whole">search for the whole sequence<br/>
+ <input type="radio" name="protein" value="part" Checked>search for partial sequence matching</p>
+ <input type="submit" name="Search" value="Search"/>
+ </div>
+ </c:when>
+ <c:otherwise>
+ <div class="form-group has-error">
+ <p><textarea class="form-control" rows="3" name="sequence">${value}</textarea></p>
+ <p class="help-block">${error}</p>
+ <p><input type="radio" name="protein" value="whole">search for the whole sequence<br/>
+ <input type="radio" name="protein" value="part" Checked>search for partial sequence matching</p>
+ <input type="submit" name="Search" value="Search"/>
+ </div>
+ </c:otherwise>
+ </c:choose>
</form>
</div>
</div>
<div class="panel-heading">
<c:choose>
<c:when test="${option == 'AllDates,off'}">
- <p style="font-weight:bold;">Jobs statistics for the whole period</p>
+ <p style="font-weight:bold;">Jobs statistics for the whole period (${ndays} days)</p>
</c:when>
<c:otherwise>
<p style="font-weight:bold;">
- Jobs statistics for the time period: <c:out value="${date1}" /> to <c:out value="${date2}"/>
+ Jobs statistics for the time period: <c:out value="${date1}" /> to <c:out value="${date2}"/> (${ndays} days)
</p>
</c:otherwise>
</c:choose>
<div class="panel-heading">
<c:choose>
<c:when test="${option == 'AllDates,off'}">
- <p style="font-weight:bold;">Time execution for the whole period</p>
+ <p style="font-weight:bold;">Time execution for the whole period (${ndays} days)</p>
</c:when>
<c:otherwise>
- <p style="font-weight:bold;">Time execution for the interval: ${date1} - ${date2}</p>
+ <p style="font-weight:bold;">Time execution for the interval: ${date1} - ${date2} (${ndays} days)</p>
</c:otherwise>
</c:choose>
</div>
<c:when test="${loop.last}">
<tr style="font-weight: bolder;">
<td style="text-align: right">Total numbers:</td>
- <td style="text-align: right">0</td>
+ <c:set var="alldaytotal" value="0"/>
+ <c:forEach items="${res.timeTotalExec}" var="total">
+ <c:set var="alldaytotal" value="${alldaytotal + total}"/>
+ </c:forEach>
+ <td style="text-align: right">${alldaytotal}</td>
<c:forEach items="${res.timeTotalExec}" var="total">
<td style="text-align: right">${total}</td>
</c:forEach>
<c:when test="${not loop.last}">
<tr>
<td style="text-align: center">${res.date}</td>
- <td style="text-align: right">0</td>
+ <c:set var="daytotal" value="0"/>
+ <c:forEach items="${res.timeRez}" var="time">
+ <c:set var="daytotal" value="${daytotal + time}"/>
+ </c:forEach>
+ <td style="text-align: right">${daytotal}</td>
<c:forEach items="${res.timeRez}" var="time">
<td style="text-align: right">${time}</td>
</c:forEach>