From: Sasha Sherstnev Date: Mon, 25 Nov 2013 11:04:31 +0000 (+0000) Subject: Merge branch 'servlets' X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=92420f700bca908529b5dc0e0e998dd2a7f98bc2;hp=8a0caa40d0fa288a0ad23f6af2aab1b0de0d50cd;p=proteocache.git Merge branch 'servlets' Conflicts: datadb/compbio/cassandra/StructureProteinPrediction.java server/compbio/statistic/CassandraRequester.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 b527738..6e3587b 100644 --- a/datadb/compbio/cassandra/CassandraReader.java +++ b/datadb/compbio/cassandra/CassandraReader.java @@ -97,7 +97,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); @@ -108,10 +108,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)); if (structure.getPrediction().containsKey("jnetpred")) structure.setJnetpred(structure.getPrediction().get("jnetpred")); @@ -128,7 +128,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); @@ -139,12 +139,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/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 afba67b..410a722 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(); @@ -158,38 +158,7 @@ public class CassandraRequester { System.out.println("StatisticsProt.readLength: total number of dates = " + query.size()); return query; } - - /* - * query: jobs and sequence at date - */ - public List readJobByDay (String date) { - System.out.println(date); - if (null == date) { - return null; - } - if (!isThisDateValid(date, formatDDMMYY)) { - System.out.println("Wrong date: point 3"); - return null; - } - SetDateRange(); - long day = DateParsing(date, formatDDMMYY); - System.out.println(day); - if (day < earlestDate || day > currentDate) - return null; - List> res = db.ReadProteinData(day); - if (res == null) - return null; - query = new ArrayList(); - for (Pair entry : res) { - DataBase bean = new DataBase(); - bean.setDate(date); - bean.setId(entry.getElement0()); - bean.setProt(entry.getElement1()); - query.add(bean); - } - System.out.println("StatisticsProt.readLength: total number of dates = " + query.size()); - return query; - } + /* * query: protein sequence * */ @@ -198,26 +167,26 @@ public class CassandraRequester { return null; System.out.println(protIn.length()); query = new ArrayList(); - List res; + List res; if (flag.equals("whole")) res = db.ReadWholeSequence(protIn); else res = (protIn.length() > 0) ? db.ReadPartOfSequence(protIn) : null; if (res == null) return null; - for (StructureProteinPrediction entry : res) { - DataBase bean = new DataBase(); - bean.setProt(entry.getSequence()); - bean.setId(entry.getJobid()); - bean.setJpred(entry.getJnetpred()); - if (flag.equals("part")) - bean.setSubProt(CreateSubprot (entry.getSequence(), protIn)); - query.add(bean); - + 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..b7632d7 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,34 @@ - + - + - - - + + + + - - - + + + + + + + - + - - - + + + + + +
${res.totalId}${res.prot} + + ${res.prot}
IDPredictions
Job IDannotationSequence
${res.id}
${res.id}
Protein Sequence
+
\ No newline at end of file