#################################################################################
# Jpred sources
# real Jpred web-server
-cassandra.jpred.web.update=true
+cassandra.jpred.web.update=false
cassandra.jpred.web.inidelay=0
cassandra.jpred.web.updaterate=30
import com.datastax.driver.core.Row;
import com.datastax.driver.core.Session;
import com.datastax.driver.core.ResultSet;
+
import compbio.engine.JobStatus;
public class CassandraReader {
}
/*
+ * getting protein sequence from the db ProteinRow
+ */
+ public Map<String, String> ReadProtein() {
+ final long startTime = System.currentTimeMillis();
+ String com = "SELECT * FROM ProteinRow;";
+ System.out.println("Command: " + com);
+ ResultSet results = session.execute(com);
+ if (results.isExhausted())
+ return null;
+ final long queryTime = System.currentTimeMillis();
+ List<Row> rows = results.all();
+ System.out.println("Query time is " + (queryTime - startTime) + " msec");
+ System.out.println(" rows analysed, " + rows.size());
+ Map<String, String> res = new HashMap<String, String>();
+ int c = 0;
+ for (Row r : rows) {
+ String prot = r.getString("Protein");
+ String prediction = findJnetpred(r.getMap("Predictions", String.class, String.class));
+ if (prot != null || prediction != null)
+ res.put(prot, prediction);
+ }
+ final long endTime = System.currentTimeMillis();
+ System.out.println(c + " rows analysed, execution time is " + (endTime - startTime) + " msec");
+ return res;
+ }
+
+ private String findJnetpred (Map<String,String> pred) {
+ if (pred != null) {
+ if (pred.containsKey("jnetpred"))
+ return pred.get("jnetpred");
+ }
+ return null;
+ }
+ /*
* getting protein sequences by counter
*/
public Map<String, Integer> ReadProteinSequenceByCounter() {
public class ProteinBean implements PredictionIndex{
private String sequence;
+ private String jnetpred;
private List<String> jobid;
private LinkedHashMap<String,String> predictions;
private List<String> subProt; // protein sequence divided by several parts for highlighting the particular part
setPredictions(pred);
}
+ public void setSequence (String seq) {
+ this.sequence = seq;
+ }
+
public void setPredictions(Map<String,String> pred) {
if (predictions == null)
predictions = new LinkedHashMap<String,String>();
return sequence;
}
+ public String getJnetpred () {
+ return jnetpred;
+ }
+
+ public void setJnetpred (Map<String,String> pred) {
+ if (pred != null) {
+ if (pred.containsKey("jnetpred"))
+ jnetpred = pred.get("jnetpred");
+ }
+ }
+
public List<String> getJobid () {
return jobid;
}
--- /dev/null
+package compbio.controllers;
+
+import java.util.List;
+import java.util.Map;
+
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RequestParam;
+
+import compbio.cassandra.ProteinBean;
+import compbio.cassandra.TotalByCounterBean;
+import compbio.statistic.CassandraRequester;
+
+/**
+ * Spring controller for sequence queries. This version works in the servlet
+ * style.
+ *
+ * @author Alexander Sherstnev
+ * @author Natasha Sherstneva
+ *
+ * @since 0.5
+ * @version 1.0 December 2013
+ */
+@Controller
+@RequestMapping("/features")
+public class SSFeaturesController extends BasicController {
+
+ @RequestMapping(value = "query", method = RequestMethod.GET)
+ public String formCounterQuery(Map<String, Object> model) {
+ model.put("username", getPrincipalName());
+ model.put("type", 'E');
+ model.put("value", 80);
+ return "query/SSFeatures";
+ }
+
+ @RequestMapping(value = "features/results", method = RequestMethod.GET)
+ public String countSequences(@RequestParam("TypeFeatures") String typeFeature, @RequestParam("Percent") String percent,Map<String, Object> model) {
+ model.put("username", getPrincipalName());
+ final long startTime = System.currentTimeMillis();
+
+ if (percent.equals("")) {
+ model.put("error", "The value must not be empty");
+ model.put("type", typeFeature);
+ model.put("value", percent);
+ return "query/SSFeatures";
+ }
+
+ int realpercent;
+ try {
+ realpercent = Integer.parseInt(percent.trim());
+ } catch (NumberFormatException e) {
+ model.put("error", "The value must be an integer number");
+ model.put("value", percent);
+ return "query/SSFeatures";
+ }
+
+ if (realpercent < 1) {
+ model.put("error", "The value must be greater than 0");
+ model.put("value", percent);
+ return "query/SSFeatures";
+ }
+
+ if (realpercent > 100) {
+ model.put("error", "The value must be less than 100");
+ model.put("value", percent);
+ return "query/SSFeatures";
+ }
+
+ CassandraRequester cr = new CassandraRequester();
+ Map<String, String> r = cr.readProteinsPrediction(typeFeature, realpercent);
+ model.put("results", r);
+ model.put("njobs", 0);
+ if (null != r) {
+ model.put("njobs", r.size());
+ }
+ final long endTime = System.currentTimeMillis();
+ model.put("timeExecution", (endTime - startTime));
+ model.put("feature", typeFeature);
+ model.put("percent", realpercent);
+ return "reportSSFeatures";
+ }
+
+
+
+}
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
+import java.util.HashMap;
import java.util.List;
import java.util.Map;
}
return result;
}
+
+ /*
+ * query: protein feature
+ */
+ public Map<String, String> readProteinsPrediction(String feature, int percent) {
+ Map<String, String> result = db.ReadProtein();;
+ if (result == null)
+ return null;
+ Map<String, String> query = new HashMap<String, String>();
+ for (Map.Entry<String, String> entry : result.entrySet()) {
+ String pred = entry.getValue();
+ if (pred.replaceAll("[^"+feature+"]", "").length() > pred.length() * percent / 100 && (!entry.getKey().equals(""))) {
+ // if (!entry.getKey().equals(""))
+ query.put(entry.getKey(), pred);
+ }
+ }
+ return query;
+ }
/*
* query protein sequences with number of jobs
<li><a href="<spring:url value="/stat/exectime/query" htmlEscape="true" />">Job Time Execution</a></li>
<li><a href="<spring:url value="/admin/ip/counts/query" htmlEscape="true" />">IPs by Job count</a></li>
<li><a href="<spring:url value="/sequence/counts/query" htmlEscape="true" />">Proteins by Job count</a></li>
+ <li><a href="<spring:url value="/features/query" htmlEscape="true" />">Proteins by SS Features</a></li>
</ul>
</li>
<sec:authorize access="hasRole('ROLE_ADMIN')">
--- /dev/null
+<!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 uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
+<%@ 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" %>
+
+<html>
+<jsp:include page="../fragments/header.jsp" />
+<body>
+ <div class="container">
+ <jsp:include page="../fragments/mainmenu.jsp" />
+ <spring:url value="/features/features/results" var="query"/>
+
+ <div class="panel panel-default">
+ <div class="panel-heading">
+ <div style="font-weight:bold;">Proteins with features</div>
+ </div>
+ <div class="panel-body">
+ <form method="get" action="${query}">
+ <div class="col-xs-2"> <!-- make the field shorter -->
+ <c:choose>
+ <c:when test="${error == null}">
+ <div class="form-group">
+ <label for="TypeFeatures">Type of SS feature </label>
+ <select name = TypeFeatures>
+ <option value="H">H</option>
+ <option value="E">E</option>
+ </select>
+ <label for="SSFeatureValue">Percent of SS feature </label>
+ <input class="form-control" type="text" name="Percent" value ="${value}" id="SSFeatureValue">
+ </div>
+ </c:when>
+ <c:otherwise>
+ <div class="form-group has-error">
+ <label for="SSFeature">Type of SS feature </label>
+ <select name = TypeFeatures>
+ <option value="H">H</option>
+ <option value="E">E</option>
+ </select>
+ <label for="SSFeatureValue">Percent of SS feature </label>
+ <input class="form-control" type="text" name="Percent" value ="${value}" id="SSFeatureValue">
+ <p class="help-block">${error}</p>
+ </div>
+ </c:otherwise>
+ </c:choose>
+ <input type="submit" name="Search" value="Search"/>
+ </div>
+ </form>
+ </div>
+ </div>
+ <jsp:include page="../fragments/footer.jsp"/>
+ </div>
+</body>
+</html>
--- /dev/null
+<%@ page language="java" contentType="text/html; charset=UTF-8"
+ pageEncoding="UTF-8"%>
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+
+<%@ taglib uri="http://www.springframework.org/tags" prefix="spring"%>
+<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
+<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
+<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
+<%@page import="java.util.ArrayList"%>
+
+<html>
+<jsp:include page="fragments/header.jsp" />
+<body>
+ <div class="container">
+ <jsp:include page="fragments/mainmenu.jsp" />
+ <spring:url value="/sequence/sequence/results" var="sequence_query" />
+
+ <div class="panel panel-default">
+ <div class="panel-heading">
+ <div style="font-weight:bold;">Jobs Statistics</div>
+ </div>
+ <div class="panel-body">
+
+ <c:choose>
+ <c:when test="${njobs == 0}">
+ <p>No proteins with features ${feature} more then ${percent} % found</p>
+ </c:when>
+ <c:otherwise>
+ <p>${njobs} proteins with features ${feature} more then ${percent} % found</p>
+ <div class="table-responsive">
+ <table class="table table-striped table-hover table-bordered">
+ <thead>
+ <tr>
+ <th style="text-align: centre">N</th>
+ <th style="text-align: left">Protein/Prediction</th>
+ </tr>
+ </thead>
+ <tbody>
+ <c:set var="count" value="0" scope="page" />
+ <c:forEach items="${results}" var="res">
+ <c:set var="count" value="${count + 1}" scope="page"/>
+ <tr>
+ <td rowspan = 2>${count}
+ <td style="text-align: left; border-buttom: dotted; font-family: monospace">
+ <a title="Click to view all jobs" href="${sequence_query}?sequence=${res.key}&searchtype=whole">${res.key}</a></td>
+ </tr>
+ <tr>
+ <td style="text-align: left; border-buttom: dotted; font-family: monospace">${res.value}</td>
+ </tr>
+ </c:forEach>
+ </tbody>
+ </table>
+ </div>
+ </c:otherwise>
+ </c:choose>
+ </div>
+ </div>
+
+ <jsp:include page="fragments/footer.jsp" />
+ </div>
+</body>
+</html>
\ No newline at end of file