created features report
authorNatasha Sherstneva <n.shertneva@gmail.com>
Mon, 16 Dec 2013 09:37:19 +0000 (09:37 +0000)
committerNatasha Sherstneva <n.shertneva@gmail.com>
Mon, 16 Dec 2013 09:37:19 +0000 (09:37 +0000)
conf/Proteocache.properties
datadb/compbio/cassandra/CassandraReader.java
datadb/compbio/cassandra/ProteinBean.java
server/compbio/controllers/SSFeaturesController.java [new file with mode: 0644]
server/compbio/statistic/CassandraRequester.java
webapp/view/fragments/mainmenu.jsp
webapp/view/query/SSFeatures.jsp [new file with mode: 0644]
webapp/view/reportSSFeatures.jsp [new file with mode: 0644]

index b1730f4..8851680 100644 (file)
@@ -9,7 +9,7 @@ cassandra.newtables.update=false
 #################################################################################
 # 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
 
index 00a9f27..1720c48 100644 (file)
@@ -11,6 +11,7 @@ import org.apache.log4j.Logger;
 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 {
@@ -198,6 +199,40 @@ 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() {
index 80f111b..d5e700b 100644 (file)
@@ -7,6 +7,7 @@ import java.util.Map;
 
 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
@@ -19,6 +20,10 @@ public class ProteinBean implements PredictionIndex{
                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>();       
@@ -32,6 +37,17 @@ public class ProteinBean implements PredictionIndex{
                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;
        }
diff --git a/server/compbio/controllers/SSFeaturesController.java b/server/compbio/controllers/SSFeaturesController.java
new file mode 100644 (file)
index 0000000..27015bb
--- /dev/null
@@ -0,0 +1,86 @@
+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";
+               }
+
+       
+
+}
index 1bb0050..f2336e7 100755 (executable)
@@ -5,6 +5,7 @@ import java.text.SimpleDateFormat;
 import java.util.ArrayList;
 import java.util.Calendar;
 import java.util.Date;
+import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
@@ -200,6 +201,24 @@ public class CassandraRequester {
                }
                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
index f310fbf..8f8e403 100644 (file)
@@ -24,6 +24,7 @@
                                        <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')">
diff --git a/webapp/view/query/SSFeatures.jsp b/webapp/view/query/SSFeatures.jsp
new file mode 100644 (file)
index 0000000..59cdc1c
--- /dev/null
@@ -0,0 +1,56 @@
+<!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>
diff --git a/webapp/view/reportSSFeatures.jsp b/webapp/view/reportSSFeatures.jsp
new file mode 100644 (file)
index 0000000..2d885f7
--- /dev/null
@@ -0,0 +1,62 @@
+<%@ 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