<classpathentry kind="lib" path="WEB-INF/lib/jackson-core-asl-1.9.13.jar"/>
<classpathentry kind="lib" path="WEB-INF/lib/jackson-mapper-asl-1.9.13.jar"/>
<classpathentry kind="lib" path="WEB-INF/lib/displaytag-1.2.jar"/>
- <classpathentry kind="con" path="org.eclipse.jst.server.core.container/org.eclipse.jst.server.tomcat.runtimeTarget/Apache Tomcat v7.0">
- <attributes>
- <attribute name="owner.project.facets" value="jst.web"/>
- </attributes>
- </classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/jdk1.7.0_45"/>
<classpathentry kind="lib" path="WEB-INF/lib/jstl-1.2.jar"/>
+ <classpathentry kind="con" path="org.eclipse.jst.server.core.container/org.eclipse.jst.server.tomcat.runtimeTarget/Apache Tomcat v7.0"/>
<classpathentry kind="output" path="WEB-INF/classes"/>
</classpath>
import java.util.HashMap;
import java.util.List;
import java.util.ArrayList;
+import java.util.Map;
import com.datastax.driver.core.Cluster;
import com.datastax.driver.core.Host;
System.out.println (c + " rows analysed, execution time is " + (endTime - startTime) + " msec");
return res;
}
+
+ /*
+ * getting data from the db ProteinData
+ */
+ public Integer ReadDateTable(long queryDate) {
+ final long startTime = System.currentTimeMillis();
+ String com = "SELECT jobtime, JobID FROM ProteinKeyspace.ProteinData WHERE jobtime = " + queryDate + ";";
+ 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");
+ return rows.size();
+ }
/*
+ * getting whole protein sequence from the db ProteinRow
+ */
+ public List<StructureProteinPrediction> ReadWholeSequence(String queryProtein) {
+ final long startTime = System.currentTimeMillis();
+ String com = "SELECT JobID, Predictions FROM ProteinKeyspace.ProteinRow WHERE Protein = '" + queryProtein + "';";
+ 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());
+ List<StructureProteinPrediction> res = new ArrayList<StructureProteinPrediction>();
+ int c = 0;
+ for (Row r : rows) {
+ StructureProteinPrediction structure = new StructureProteinPrediction(queryProtein, r.getString("JobID"), r.getMap("Predictions", String.class, String.class));
+ res.add(structure);
+ ++c;
+ }
+ final long endTime = System.currentTimeMillis();
+ System.out.println (c + " rows analysed, execution time is " + (endTime - startTime) + " msec");
+ return res;
+ }
+
+ /*
+ * getting part of protein sequence from the db ProteinRow
+ */
+ public List<StructureProteinPrediction> ReadPartOfSequence(String queryProtein) {
+ final long startTime = System.currentTimeMillis();
+ String com = "SELECT * FROM ProteinKeyspace.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());
+ List<StructureProteinPrediction> res = new ArrayList<StructureProteinPrediction>();
+ int c = 0;
+ for (Row r : rows) {
+ String prot = r.getString("Protein");
+ if (prot.matches("(.*)" + queryProtein + "(.*)")) {
+ // System.out.println(prot);
+ StructureProteinPrediction structure = new StructureProteinPrediction(prot, r.getString("JobID"), r.getMap("Predictions", String.class, String.class));
+ res.add(structure);
+ ++c;
+ }
+ }
+ final long endTime = System.currentTimeMillis();
+ System.out.println (c + " rows analysed, execution time is " + (endTime - startTime) + " msec");
+ return res;
+ }
+
+ /*
+ * getting protein sequences by counter
+ */
+ public List<Pair<String, Integer>> ReadProteinDataByCounter(int counter) {
+ final long startTime = System.currentTimeMillis();
+ String com = "SELECT DISTINCT Protein FROM ProteinKeyspace.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());
+ List<Pair<String, Integer>> res = new ArrayList<Pair<String, Integer>>();
+ int c = 0;
+ for (Row r : rows) {
+ String prot = r.getString("Protein");
+
+ }
+ final long endTime = System.currentTimeMillis();
+ System.out.println (c + " rows analysed, execution time is " + (endTime - startTime) + " msec");
+ return res;
+ }
+
+ /*
* getting earlest date of jobs from the db
*/
public long getEarliestDateInDB() {
final long startTime = System.currentTimeMillis();
- String com = "SELECT jobtime FROM ProteinKeyspace.ProteinData;";
+ String com = "SELECT jobtime,JobID FROM ProteinKeyspace.ProteinData;";
System.out.println("Command: " + com);
ResultSet results = session.execute(com);
final long queryTime = System.currentTimeMillis();
- System.out.println ("Query time is " + (queryTime - startTime) + " msec");
+ System.out.println ("Query time is " + (queryTime - startTime) + " msec");
Calendar cal = Calendar.getInstance();
long res = cal.getTimeInMillis();
public class DataBase {
private String date;
private int total;
+ private int totalJobs;
private int totalId;
private String id;
private String prot;
return total;
}
+
+ public void setTotalJobs(int totalJobs) {
+ this.totalJobs = totalJobs;
+ }
+
+ public int getTotalJobs() {
+ return totalJobs;
+ }
+
public void setTotalId(int totId) {
this.totalId = totId;
}
import javax.servlet.http.HttpServletResponse;
import compbio.cassandra.DataBase;
+import compbio.statistic.CassandraRequester;
import compbio.statistic.StatisticsProt;
-@WebServlet("/QueryServlet")
-public class QueryServlet extends HttpServlet {
+@WebServlet("/ServletJobsByDate")
+public class ServletJobsByDate extends HttpServlet {
private static final long serialVersionUID = 1L;
/**
final long startTime = System.currentTimeMillis();
String date1 = request.getParameter("data1");
String date2 = request.getParameter("data2");
- StatisticsProt sp = new StatisticsProt();
+ CassandraRequester cr = new CassandraRequester();
if (null != request.getParameter("option")) {
Calendar cal = Calendar.getInstance();
- date1 = StatisticsProt.DateFormatYYMMDD(sp.earliestDate());
+ date1 = StatisticsProt.DateFormatYYMMDD(cr.earliestDate());
date2 = cal.get(Calendar.YEAR) + "/" + (cal.get(Calendar.MONTH) + 1) + "/" + cal.get(Calendar.DAY_OF_MONTH);
}
request.setAttribute("data1", date1);
request.setAttribute("data2", date2);
- List<DataBase> res = sp.readDetails(date1, date2);
+ List<DataBase> res = cr.countJobs(date1, date2);
request.setAttribute("result", res);
final long endTime = System.currentTimeMillis();
request.setAttribute("timeExecution", (endTime - startTime));
System.out.println ("QueryServlet.doGet: total number of dates = " + res.size());
request.setAttribute("flag", request.getParameter("option"));
- RequestDispatcher rd = request.getRequestDispatcher("/ReportNew.jsp");
+ RequestDispatcher rd = request.getRequestDispatcher("/ReportJobsByDate.jsp");
rd.forward(request, response);
}
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
+import compbio.statistic.CassandraRequester;
import compbio.statistic.StatisticsProt;
/**
* Servlet implementation class ProtServlet
*/
-@WebServlet("/ProtServlet")
-public class ProtServlet extends HttpServlet {
+@WebServlet("/ServletSequenceProtein")
+public class ServletSequenceProtein extends HttpServlet {
private static final long serialVersionUID = 1L;
/**
String prot = request.getParameter("prot");
String search = request.getParameter("Search");
int counter = Integer.parseInt(request.getParameter("counterJob"));
- StatisticsProt sp = new StatisticsProt();
+ CassandraRequester cr = new CassandraRequester();
if (search.equals("Search counter")) {
- request.setAttribute("result", sp.readProtID(counter));
+ // request.setAttribute("result", sp.readProtID(counter));
} else {
- if (flag.equals("whole"))
- request.setAttribute("result", sp.readProteins(prot));
- else
- request.setAttribute("result", sp.readPart(prot));
+ request.setAttribute("result", cr.readProteins(prot, flag));
}
final long endTime = System.currentTimeMillis();
request.setAttribute("timeExecution", (endTime - startTime));
request.setAttribute("flag", flag);
request.setAttribute("search", search);
request.setAttribute("counter", counter);
- RequestDispatcher rd = request.getRequestDispatcher("/ReportProt.jsp");
+ RequestDispatcher rd = request.getRequestDispatcher("/ReportSequenceProtein.jsp");
rd.forward(request, response);
}
/**
* Servlet implementation class LengthServlet
*/
-@WebServlet("/LengthServlet")
-public class LengthServlet extends HttpServlet {
+@WebServlet("/ServletTimeExecution")
+public class ServletTimeExecution extends HttpServlet {
private static final long serialVersionUID = 1L;
/**
request.setAttribute("flag", request.getParameter("option"));
final long endTime = System.currentTimeMillis();
request.setAttribute("timeExecution", (endTime - startTime));
- RequestDispatcher rd = request.getRequestDispatcher("/ReportLength.jsp");
+ RequestDispatcher rd = request.getRequestDispatcher("/ReportTimeExecution.jsp");
rd.forward(request, response);
}
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
+import java.util.Iterator;
import java.util.List;
+import java.util.Map;
import compbio.cassandra.CassandraNativeConnector;
import compbio.cassandra.DataBase;
import compbio.cassandra.Pair;
+import compbio.cassandra.StructureProteinPrediction;
public class CassandraRequester {
private CassandraNativeConnector DBInstance = new CassandraNativeConnector();
System.out.println("StatisticsProt.readLength: total number of dates = " + query.size());
return query;
}
+
+ /*
+ * query: total number of jobs for the period from date1 till date2
+ */
+ public List<DataBase> countJobs(String date1, String date2) {
+ if (null == date1) {
+ date1 = "1970/1/1";
+ }
+ if (null == date2) {
+ date1 = "2100/1/1";
+ }
+ if (!isThisDateValid(date1) || !isThisDateValid(date2)) {
+ System.out.println("Wrong date: point 3");
+ return null;
+ }
+ SetDateRange();
+ long dateStart = DateParsing(date1);
+ long dateEnd = DateParsing(date2);
+ if (dateEnd < earlestDate || dateStart > currentDate || dateStart > dateEnd)
+ return null;
+ if (dateStart < earlestDate)
+ dateStart = earlestDate;
+ if (dateEnd > currentDate)
+ dateStart = currentDate;
+ Calendar start = Calendar.getInstance();
+ start.setTime(new Date(dateStart));
+ Calendar end = Calendar.getInstance();
+ end.setTime(new Date(dateEnd));
+ query = new ArrayList<DataBase>();
+ for (Date date = start.getTime(); !start.after(end); start.add(Calendar.DATE, 1), date = start.getTime()) {
+ Integer res = DBInstance.ReadDateTable(date.getTime());
+ if (res == null)
+ continue;
+ DataBase db = new DataBase();
+ db.setTotal(res);
+ db.setDate(DateFormat(date.getTime()));
+ query.add(db);
+ }
+ 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;
+ if (flag.equals("whole"))
+ res = DBInstance.ReadWholeSequence(protIn);
+ else
+ res = DBInstance.ReadPartOfSequence(protIn);
+ 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);
+ }
+ }
+ return query;
+ }
+
+ /*
+ * query protein sequences with number of jobs
+ * */
+ public List<DataBase> readProteinByCounter(int counter) {
+ query = new ArrayList<DataBase>();
+ // List<Pair<String, String>> res = DBInstance.ReadProteinDataByCounter(counter);
+
+ return query;
+ }
+
+
+ private static List<String> CreateSubprot (String protein, String subprot) {
+ List<String> sub = new ArrayList<String>();
+ String subStr = protein;
+ while (subStr.length() > 0 && subStr.contains(subprot)) {
+ String first = subStr.substring(0, subStr.indexOf(subprot));
+ if (first.length() > 0)
+ sub.add(first);
+ sub.add(subprot);
+ subStr = subStr.substring(subStr.indexOf(subprot) + subprot.length(), subStr.length());
+ }
+ if (subStr.length() > 0)
+ sub.add(subStr);
+ return sub;
+ }
/*
* convert String date into long date (miliseconds since the epoch start)
*/
earlestDate = DBInstance.getEarliestDateInDB();
return earlestDate;
}
+
}
<%
String query = request.getParameter("query");
if (query.equals("date"))
- response.sendRedirect("Sample.jsp");
+ response.sendRedirect("QueryJobsByDate.jsp");
else if (query.equals("length"))
- response.sendRedirect("JobLength.jsp");
+ response.sendRedirect("QueryTimeExecition.jsp");
else if (query.equals("protein"))
- response.sendRedirect("Sequence.jsp");
+ response.sendRedirect("QuerySequenceProtein.jsp");
else if (query.equals("log"))
response.sendRedirect("LogQuery.jsp");
%>
\ No newline at end of file
<title>Date period</title>
</head>
<body>
- <form method="post" action="QueryServlet">
+ <form method="post" action="ServletJobsByDate">
<h3>Enter time period</h3>
<% Calendar cal = Calendar.getInstance();
String datecalBegin = cal.get(Calendar.YEAR) + "/" + (cal.get(Calendar.MONTH) + 1) + "/1";
</head>
<body>
<br/>
- <form method="get" action="ProtServlet">
+ <form method="get" action="ServletSequenceProtein">
<h3>Enter protein sequence</h3>
<p><textarea rows="14" cols="80" name="prot">ABCDE</textarea></p>
- <input type="radio" name="protein" value="part" Checked>search<br/>
+ <input type="radio" name="protein" value="whole" Checked>search whole<br/>
+ <input type="radio" name="protein" value="part">search part<br/>
<input type="submit" name="Search" value="Search sequence"/><br/><br/>
<h3>Enter minimum number of jobs per protein</h3>
<input type="text" name="counterJob" value = 3><br/>
<title>Date interval</title>
</head>
<body>
- <form method="post" action="LengthServlet">
+ <form method="post" action="ServletTimeExecution">
<h3>Enter time period</h3>
<%
Calendar cal = Calendar.getInstance();
<td style="text-align: right">0</td>
</tr>
- <c:set var="sum" value="0" />
<c:forEach items="${result}" var="res">
<tr>
<td>${res.date}</td>