Improve presentation of job on the web (servlet ServletSequenceProtein)
authorSasha Sherstnev <a.sherstnev@dundee.ac.uk>
Fri, 22 Nov 2013 18:25:37 +0000 (18:25 +0000)
committerSasha Sherstnev <a.sherstnev@dundee.ac.uk>
Fri, 22 Nov 2013 18:25:37 +0000 (18:25 +0000)
datadb/compbio/cassandra/AnnotatedProteinSequenceBean.java [new file with mode: 0644]
datadb/compbio/cassandra/CassandraReader.java
datadb/compbio/cassandra/DataBase.java
datadb/compbio/cassandra/StructureProteinPrediction.java [deleted file]
server/compbio/listeners/ServletSequenceProtein.java
server/compbio/statistic/CassandraRequester.java
website/ReportSequenceProtein.jsp

diff --git a/datadb/compbio/cassandra/AnnotatedProteinSequenceBean.java b/datadb/compbio/cassandra/AnnotatedProteinSequenceBean.java
new file mode 100644 (file)
index 0000000..9289407
--- /dev/null
@@ -0,0 +1,39 @@
+package compbio.cassandra;
+
+import java.util.Map;
+
+public class AnnotatedProteinSequenceBean {
+       private String sequence;
+       private String jobid;
+       private Map<String,String> predictions;
+       private int size;
+       
+       public AnnotatedProteinSequenceBean (String seq, String id, Map<String,String> pred) {
+               this.sequence = seq;
+               this.jobid = id;
+               this.predictions = pred;
+               this.size = pred.size();
+       }
+       
+       public String getSequence () {
+               return sequence;
+       }
+       
+       public String getJobid () {
+               return jobid;
+       }
+
+       public int getmapsize () {
+               return size;
+       }
+       
+       public Map<String,String> getPredictions () {
+               return predictions;
+       }
+
+       public void setPredictions (Map<String,String> predictions) {
+               this.predictions = predictions;
+               this.size = predictions.size();
+       }
+
+}
index 250c705..28641db 100644 (file)
@@ -73,7 +73,7 @@ public class CassandraReader {
        /*
         * getting whole protein sequence from the db ProteinRow
         */
-       public List<StructureProteinPrediction> ReadWholeSequence(String queryProtein) {
+       public List<AnnotatedProteinSequenceBean> ReadWholeSequence(String queryProtein) {
                final long startTime = System.currentTimeMillis();
                String com = "SELECT JobID, Predictions FROM ProteinRow WHERE Protein = '" + queryProtein + "';";
                System.out.println("Command: " + com);
@@ -84,10 +84,10 @@ public class CassandraReader {
                List<Row> rows = results.all();
                System.out.println("Query time is " + (queryTime - startTime) + " msec");
                System.out.println(" rows analysed,  " + rows.size());
-               List<StructureProteinPrediction> res = new ArrayList<StructureProteinPrediction>();
+               List<AnnotatedProteinSequenceBean> res = new ArrayList<AnnotatedProteinSequenceBean>();
                int c = 0;
                for (Row r : rows) {
-                       StructureProteinPrediction structure = new StructureProteinPrediction(queryProtein, r.getString("JobID"), r.getMap(
+                       AnnotatedProteinSequenceBean structure = new AnnotatedProteinSequenceBean(queryProtein, r.getString("JobID"), r.getMap(
                                        "Predictions", String.class, String.class));
                        res.add(structure);
                        ++c;
@@ -100,7 +100,7 @@ public class CassandraReader {
        /*
         * getting part of protein sequence from the db ProteinRow
         */
-       public List<StructureProteinPrediction> ReadPartOfSequence(String queryProtein) {
+       public List<AnnotatedProteinSequenceBean> ReadPartOfSequence(String queryProtein) {
                final long startTime = System.currentTimeMillis();
                String com = "SELECT * FROM ProteinRow;";
                System.out.println("Command: " + com);
@@ -111,12 +111,12 @@ public class CassandraReader {
                List<Row> rows = results.all();
                System.out.println("Query time is " + (queryTime - startTime) + " msec");
                System.out.println(" rows analysed,  " + rows.size());
-               List<StructureProteinPrediction> res = new ArrayList<StructureProteinPrediction>();
+               List<AnnotatedProteinSequenceBean> res = new ArrayList<AnnotatedProteinSequenceBean>();
                int c = 0;
                for (Row r : rows) {
                        String prot = r.getString("Protein");
                        if (prot.matches("(.*)" + queryProtein + "(.*)")) {
-                               StructureProteinPrediction structure = new StructureProteinPrediction(prot, r.getString("JobID"), r.getMap("Predictions",
+                               AnnotatedProteinSequenceBean structure = new AnnotatedProteinSequenceBean(prot, r.getString("JobID"), r.getMap("Predictions",
                                                String.class, String.class));
                                res.add(structure);
                                ++c;
index d0586e7..c6777fc 100644 (file)
@@ -6,13 +6,13 @@ import java.util.Collections;
 
 public class DataBase {
        private String date;
-       private int total;                              // total jobs
-       private int totalOK;                        // total jobs with execution status OK
-       private int totalStopped;                        // total jobs with execution status STOPPED
-       private int totalError;                         // total jobs with execution status Jpred ERROR
-       private int totalTimeOut;                       // total jobs with execution status TIMEOUT
+       private int total;                              // total number of jobs
+       private int totalOK;                        // number of jobs with execution status OK
+       private int totalStopped;                        // number of jobs with execution status STOPPED
+       private int totalError;                         // number of jobs with execution status Jpred ERROR
+       private int totalTimeOut;                       // number of jobs with execution status TIMEOUT
        private int totalJobs;
-       private int totalId;                // total jobs for current protein sequence
+       private int totalId;                            // total jobs for current protein sequence
        private String id;
        private String prot;                            // protein sequence
        private String jpred;
@@ -20,7 +20,7 @@ public class DataBase {
        private List<Integer> timeRez;
        private List<Integer> timeTotalExec;
        private StructureJobLog logInfo;
-
+       private AnnotatedProteinSequenceBean predictions;
        public DataBase() {
        }
 
@@ -148,5 +148,13 @@ public class DataBase {
        public StructureJobLog getLogInfo() {
                return logInfo;
        }
+       
+       public void setPredictions(AnnotatedProteinSequenceBean predictions){
+               this.predictions = predictions;
+       }
+       
+       public AnnotatedProteinSequenceBean getPredictions() {
+               return predictions;
+       }
 
 }
diff --git a/datadb/compbio/cassandra/StructureProteinPrediction.java b/datadb/compbio/cassandra/StructureProteinPrediction.java
deleted file mode 100644 (file)
index 936a67a..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-package compbio.cassandra;
-
-import java.util.Map;
-
-public class StructureProteinPrediction {
-       private String sequence;
-       private String jobid;
-       private Map<String,String> prediction;
-       
-       public StructureProteinPrediction (String seq, String id, Map<String,String> pred) {
-               this.sequence = seq;
-               this.jobid = id;
-               this.prediction = pred;
-       }
-       
-       public String getSequence () {
-               return sequence;
-       }
-       
-       public String getJobid () {
-               return jobid;
-       }
-       
-       public Map<String,String> getPrediction () {
-               return prediction;
-       }
-
-}
index 94df90c..ef7353f 100644 (file)
@@ -1,6 +1,7 @@
 package compbio.listeners;
 
 import java.io.IOException;
+import java.util.List;
 
 import javax.servlet.RequestDispatcher;
 import javax.servlet.ServletException;
@@ -9,6 +10,7 @@ import javax.servlet.http.HttpServlet;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
+import compbio.cassandra.DataBase;
 import compbio.statistic.CassandraRequester;
 import compbio.statistic.StatisticsProt;
 
@@ -31,9 +33,13 @@ public class ServletSequenceProtein extends HttpServlet {
                int counter = Integer.parseInt(request.getParameter("counterJob"));
                CassandraRequester cr = new CassandraRequester();
                if (search.equals("Search counter")) {
-                       request.setAttribute("result", cr.readProteinByCounter(counter));
+                       List<DataBase> r = cr.readProteinByCounter(counter);
+                       request.setAttribute("results", r);
+                       System.out.println ("Search counter: " + r.size() + " proteins found");
                } else {
-                               request.setAttribute("result", cr.readProteins(prot, flag));
+                       List<DataBase> r = cr.readProteins(prot, flag);
+                       request.setAttribute("results", r);
+                       System.out.println ("Search sequence: " + r.size() + " proteins found");
                }
                final long endTime = System.currentTimeMillis();
                request.setAttribute("timeExecution", (endTime - startTime));
index ec74c6f..214bf6f 100755 (executable)
@@ -9,12 +9,12 @@ import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 
+import compbio.cassandra.AnnotatedProteinSequenceBean;
 import compbio.cassandra.CassandraNativeConnector;
 import compbio.cassandra.CassandraReader;
 import compbio.cassandra.DataBase;
 import compbio.cassandra.Pair;
 import compbio.cassandra.StructureJobLog;
-import compbio.cassandra.StructureProteinPrediction;
 
 public class CassandraRequester {
        private CassandraReader db = new CassandraReader();
@@ -156,35 +156,32 @@ public class CassandraRequester {
                System.out.println("StatisticsProt.readLength: total number of dates = " + query.size());
                return query;
        }
+
        /* 
         * query: protein sequence
         * */
        public List<DataBase> readProteins(String protIn, String flag) {
                query = new ArrayList<DataBase>();
-               List<StructureProteinPrediction> res;
+               List<AnnotatedProteinSequenceBean> res;
                if (flag.equals("whole")) 
                        res = db.ReadWholeSequence(protIn);
                 else 
                        res = db.ReadPartOfSequence(protIn);
                if (res == null)
                        return null;
-               for (StructureProteinPrediction entry : res) {
-                       Map<String,String> pred = entry.getPrediction();
-                       Iterator it = pred.entrySet().iterator();
-                       while (it.hasNext()) {
-                               DataBase db = new DataBase();
-                               db.setProt(entry.getSequence());
-                               Map.Entry pairs = (Map.Entry)it.next();
-                               db.setId(entry.getJobid());
-                               db.setJpred(pairs.getValue().toString());
-                               if (flag.equals("part"))
-                                       db.setSubProt(CreateSubprot (entry.getSequence(), protIn));                             
-                               query.add(db);
+               for (AnnotatedProteinSequenceBean entry : res) {
+                       DataBase db = new DataBase();
+                       db.setProt(entry.getSequence());
+                       db.setPredictions(entry);
+                       db.setId(entry.getJobid());
+                       if (flag.equals("part")) {
+                               db.setSubProt(CreateSubprot (entry.getSequence(), protIn));
                        }
+                       query.add(db);
                }
                return query;
        }
-       
+
        /* 
         * query protein sequences with number of jobs
         */
index 88cd29f..c7473a2 100644 (file)
@@ -1,28 +1,28 @@
 <%@page import="java.util.ArrayList"%>
-<%@ page trimDirectiveWhitespaces="true"%>
 <%@ 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"%>
 <%@ taglib uri="http://displaytag.sf.net" prefix="dt"%>
+
 <c:choose>
        <c:when test="${search == 'Search counter'}">
-               <h3>Dundee ProteoCache query result for jobs more than ${counter} </h3>
+               <h3>Dundee ProteoCache query results for jobs more than ${counter} </h3>
        </c:when>
        <c:otherwise>
-               <h3>Dundee ProteoCache query result</h3>
+               <h3>Dundee ProteoCache query results</h3>
        </c:otherwise>
 </c:choose>
 <h3>Time execution: ${timeExecution} ms</h3>
 <c:choose>
 
-       <c:when test="${result == null}">
-               <h3>No jobs for sequence ${prot} </h3>
-       </c:when>
-       <c:otherwise>
-       
-       
+<c:when test="${results == null}">
+       <h3>No jobs for sequence ${prot} </h3>
+</c:when>
+<c:otherwise>
+
 <table border="1" style="border-collapse: collapse; white-space: nowrap">
        <c:choose>
+
                <c:when test="${search == 'Search counter'}">
                        <thead>
                                <tr>
                                </tr>
                        </thead>
                        <tbody>
-                               <c:forEach items="${result}" var="res">
+                               <c:forEach items="${results}" var="res">
                                        <tr>
                                                <td>${res.totalId}</td>
-                                               <td
-                                                       style="text-align: left; border-buttom: dotted; font-family: monospace"><a
-                                                       title="Click to view predictions"
-                                                       href="ServletSequenceProtein?prot=${res.prot}&protein=whole&Search=Search+sequence&counterJob=${counter}">${res.prot}</a>
+                                               <td style="text-align: left; border-buttom: dotted; font-family: monospace">
+                                                       <a title="Click to view all jobs" href="ServletSequenceProtein?prot=${res.prot}&protein=whole&Search=Search+sequence&counterJob=${counter}">${res.prot}</a>
                                                </td>
                                        </tr>
                                </c:forEach>
                </c:when>
+
                <c:otherwise>
                        <thead>
                                <tr>
-                                       <th style="text-align: centre">ID</th>
-                                       <th style="text-align: centre">Predictions</th>
+                                       <th style="text-align: centre">Job ID</th>
+                                       <th style="text-align: centre">annotation</th>
+                                       <th style="text-align: centre">Sequence</th>
                                </tr>
                        </thead>
                        <tbody>
-                               <c:forEach items="${result}" var="res" varStatus="status">
+                               <c:forEach items="${results}" var="res" varStatus="status">
+                                       <c:set var="ann" value="${res.predictions}"/>
                                        <tr>
-                                               <td rowspan="2"><a href="ServletLogInfo?IdJob=${res.id}">${res.id}</a></td>
+                                               <th rowspan="${ann.mapsize + 2}"><a title="Click to view the job log" href="ServletLogInfo?IdJob=${res.id}">${res.id}</a></th>
+                                       </tr>
+                                       <tr>
+                                               <td style="text-align: center; font-weight: bold; font-family: monospace" >Protein Sequence</td>
+                                               <!--  <td style="text-align: left; border-buttom: dotted; font-family: monospace"><c:out value="${res.prot}" /></td> -->
                                                <c:if test="${flag == 'whole'}">
-                                                       <td
-                                                               style="text-align: left; border-buttom: dotted; font-family: monospace"><c:out
-                                                                       value="${res.prot}" /></td>
+                                                       <td style="text-align: left; border-buttom: dotted; font-family: monospace"><c:out value="${res.prot}" /></td>
                                                </c:if>
                                                <c:if test="${flag == 'part'}">
                                                        <td
                                                        </td>
                                                </c:if>
                                        </tr>
-                                       <tr>
-                                               <td
-                                                       style="text-align: left; border-top: hidden; font-family: monospace"><c:out
-                                                               value="${res.jpred}" /></td>
-                                       </tr>
+                                       <c:forEach items="${ann.predictions}" var="seq" varStatus="status">
+                                               <tr>
+                                                       <td style="text-align: center; font-weight: bold; font-family: monospace"><c:out value="${seq.key}"/></td>
+                                                       <td style="text-align: left; border-buttom: dotted; font-family: monospace"><c:out value="${seq.value}"/></td>
+                                               </tr>
+                                       </c:forEach>
                                </c:forEach>
                </c:otherwise>
        </c:choose>
        </tbody>
 </table>
 </c:otherwise>
+
 </c:choose>
\ No newline at end of file