From 1835d87d090291da1db317c27c7463191bfb54c4 Mon Sep 17 00:00:00 2001 From: Sasha Sherstnev Date: Fri, 22 Nov 2013 18:25:37 +0000 Subject: [PATCH 1/1] Improve presentation of job on the web (servlet ServletSequenceProtein) --- .../cassandra/AnnotatedProteinSequenceBean.java | 39 ++++++++++++++ datadb/compbio/cassandra/CassandraReader.java | 12 ++--- datadb/compbio/cassandra/DataBase.java | 22 +++++--- .../cassandra/StructureProteinPrediction.java | 28 ---------- .../compbio/listeners/ServletSequenceProtein.java | 10 +++- server/compbio/statistic/CassandraRequester.java | 27 +++++----- website/ReportSequenceProtein.jsp | 57 +++++++++++--------- 7 files changed, 111 insertions(+), 84 deletions(-) create mode 100644 datadb/compbio/cassandra/AnnotatedProteinSequenceBean.java delete mode 100644 datadb/compbio/cassandra/StructureProteinPrediction.java diff --git a/datadb/compbio/cassandra/AnnotatedProteinSequenceBean.java b/datadb/compbio/cassandra/AnnotatedProteinSequenceBean.java new file mode 100644 index 0000000..9289407 --- /dev/null +++ b/datadb/compbio/cassandra/AnnotatedProteinSequenceBean.java @@ -0,0 +1,39 @@ +package compbio.cassandra; + +import java.util.Map; + +public class AnnotatedProteinSequenceBean { + private String sequence; + private String jobid; + private Map predictions; + private int size; + + public AnnotatedProteinSequenceBean (String seq, String id, Map 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 getPredictions () { + return predictions; + } + + public void setPredictions (Map predictions) { + this.predictions = predictions; + this.size = predictions.size(); + } + +} diff --git a/datadb/compbio/cassandra/CassandraReader.java b/datadb/compbio/cassandra/CassandraReader.java index 250c705..28641db 100644 --- a/datadb/compbio/cassandra/CassandraReader.java +++ b/datadb/compbio/cassandra/CassandraReader.java @@ -73,7 +73,7 @@ public class CassandraReader { /* * getting whole protein sequence from the db ProteinRow */ - public List ReadWholeSequence(String queryProtein) { + public List 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 rows = results.all(); System.out.println("Query time is " + (queryTime - startTime) + " msec"); System.out.println(" rows analysed, " + rows.size()); - List res = new ArrayList(); + List res = new ArrayList(); 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 ReadPartOfSequence(String queryProtein) { + public List 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 rows = results.all(); System.out.println("Query time is " + (queryTime - startTime) + " msec"); System.out.println(" rows analysed, " + rows.size()); - List res = new ArrayList(); + List res = new ArrayList(); 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; diff --git a/datadb/compbio/cassandra/DataBase.java b/datadb/compbio/cassandra/DataBase.java index d0586e7..c6777fc 100644 --- a/datadb/compbio/cassandra/DataBase.java +++ b/datadb/compbio/cassandra/DataBase.java @@ -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 timeRez; private List 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 index 936a67a..0000000 --- a/datadb/compbio/cassandra/StructureProteinPrediction.java +++ /dev/null @@ -1,28 +0,0 @@ -package compbio.cassandra; - -import java.util.Map; - -public class StructureProteinPrediction { - private String sequence; - private String jobid; - private Map prediction; - - public StructureProteinPrediction (String seq, String id, Map pred) { - this.sequence = seq; - this.jobid = id; - this.prediction = pred; - } - - public String getSequence () { - return sequence; - } - - public String getJobid () { - return jobid; - } - - public Map getPrediction () { - return prediction; - } - -} diff --git a/server/compbio/listeners/ServletSequenceProtein.java b/server/compbio/listeners/ServletSequenceProtein.java index 94df90c..ef7353f 100644 --- a/server/compbio/listeners/ServletSequenceProtein.java +++ b/server/compbio/listeners/ServletSequenceProtein.java @@ -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 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 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)); diff --git a/server/compbio/statistic/CassandraRequester.java b/server/compbio/statistic/CassandraRequester.java index ec74c6f..214bf6f 100755 --- a/server/compbio/statistic/CassandraRequester.java +++ b/server/compbio/statistic/CassandraRequester.java @@ -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 readProteins(String protIn, String flag) { query = new ArrayList(); - List res; + List res; if (flag.equals("whole")) res = db.ReadWholeSequence(protIn); else res = db.ReadPartOfSequence(protIn); if (res == null) return null; - for (StructureProteinPrediction entry : res) { - Map 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 */ diff --git a/website/ReportSequenceProtein.jsp b/website/ReportSequenceProtein.jsp index 88cd29f..c7473a2 100644 --- a/website/ReportSequenceProtein.jsp +++ b/website/ReportSequenceProtein.jsp @@ -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"%> + -

Dundee ProteoCache query result for jobs more than ${counter}

+

Dundee ProteoCache query results for jobs more than ${counter}

-

Dundee ProteoCache query result

+

Dundee ProteoCache query results

Time execution: ${timeExecution} ms

- -

No jobs for sequence ${prot}

-
- - - + +

No jobs for sequence ${prot}

+
+ + + @@ -31,32 +31,35 @@ - + - + - - + + + - + + - + + + + + - + - - - + + + + + +
${res.totalId}${res.prot} + + ${res.prot}
IDPredictionsJob IDannotationSequence
${res.id}${res.id}
Protein Sequence
+
\ No newline at end of file -- 1.7.10.2