first nosql version
authorSasha Sherstnev <a.sherstnev@dundee.ac.uk>
Sat, 12 Oct 2013 12:56:45 +0000 (13:56 +0100)
committerSasha Sherstnev <a.sherstnev@dundee.ac.uk>
Sat, 12 Oct 2013 12:56:45 +0000 (13:56 +0100)
48 files changed:
webservices/compbio/nosql/.classpath [new file with mode: 0644]
webservices/compbio/nosql/.gitignore [new file with mode: 0644]
webservices/compbio/nosql/.project [new file with mode: 0644]
webservices/compbio/nosql/.settings/.jsdtscope [new file with mode: 0644]
webservices/compbio/nosql/.settings/org.eclipse.jdt.core.prefs [new file with mode: 0644]
webservices/compbio/nosql/.settings/org.eclipse.wst.common.component [new file with mode: 0644]
webservices/compbio/nosql/.settings/org.eclipse.wst.common.project.facet.core.xml [new file with mode: 0644]
webservices/compbio/nosql/.settings/org.eclipse.wst.jsdt.ui.superType.container [new file with mode: 0644]
webservices/compbio/nosql/.settings/org.eclipse.wst.jsdt.ui.superType.name [new file with mode: 0644]
webservices/compbio/nosql/.settings/org.jboss.ide.eclipse.as.core.prefs [new file with mode: 0644]
webservices/compbio/nosql/WebContent/AllReports.jsp [new file with mode: 0644]
webservices/compbio/nosql/WebContent/Index.jsp [new file with mode: 0644]
webservices/compbio/nosql/WebContent/JobLength.jsp [new file with mode: 0644]
webservices/compbio/nosql/WebContent/META-INF/MANIFEST.MF [new file with mode: 0644]
webservices/compbio/nosql/WebContent/PrintResult.jsp [new file with mode: 0644]
webservices/compbio/nosql/WebContent/ReportLength.jsp [new file with mode: 0644]
webservices/compbio/nosql/WebContent/ReportNew.jsp [new file with mode: 0644]
webservices/compbio/nosql/WebContent/ReportProt.jsp [new file with mode: 0644]
webservices/compbio/nosql/WebContent/Sample.jsp [new file with mode: 0644]
webservices/compbio/nosql/WebContent/Sequence.jsp [new file with mode: 0644]
webservices/compbio/nosql/WebContent/StatisticsProtein.jsp [new file with mode: 0644]
webservices/compbio/nosql/WebContent/WEB-INF/lib/cassandra-all-1.2.4.jar [new file with mode: 0644]
webservices/compbio/nosql/WebContent/WEB-INF/lib/cassandra-clientutil-1.2.4.jar [new file with mode: 0644]
webservices/compbio/nosql/WebContent/WEB-INF/lib/cassandra-thrift-1.2.4.jar [new file with mode: 0644]
webservices/compbio/nosql/WebContent/WEB-INF/lib/commons-lang-2.4.jar [new file with mode: 0644]
webservices/compbio/nosql/WebContent/WEB-INF/lib/displaytag-1.2.jar [new file with mode: 0644]
webservices/compbio/nosql/WebContent/WEB-INF/lib/google-collections-0.8.jar [new file with mode: 0644]
webservices/compbio/nosql/WebContent/WEB-INF/lib/hector-0.7.0-20-sources.jar [new file with mode: 0644]
webservices/compbio/nosql/WebContent/WEB-INF/lib/hector-core-1.0-5.jar [new file with mode: 0644]
webservices/compbio/nosql/WebContent/WEB-INF/lib/jamm-0.2.5.jar [new file with mode: 0644]
webservices/compbio/nosql/WebContent/WEB-INF/lib/jstl-1.2.jar [new file with mode: 0644]
webservices/compbio/nosql/WebContent/WEB-INF/lib/libthrift-0.6.0.jar [new file with mode: 0644]
webservices/compbio/nosql/WebContent/WEB-INF/lib/log4j-1.2.16.jar [new file with mode: 0644]
webservices/compbio/nosql/WebContent/WEB-INF/lib/slf4j-1.7.5.tar.gz [new file with mode: 0644]
webservices/compbio/nosql/WebContent/WEB-INF/lib/slf4j-api-1.7.5.jar [new file with mode: 0644]
webservices/compbio/nosql/WebContent/WEB-INF/lib/slf4j-simple-1.7.5.jar [new file with mode: 0644]
webservices/compbio/nosql/WebContent/WEB-INF/web.xml [new file with mode: 0644]
webservices/compbio/nosql/displaytag-1.2.jar [new file with mode: 0644]
webservices/compbio/nosql/jstl-1.2.jar [new file with mode: 0644]
webservices/compbio/nosql/src/combio/cassandra/CassandraCreate.java [new file with mode: 0644]
webservices/compbio/nosql/src/combio/cassandra/DataBase.java [new file with mode: 0644]
webservices/compbio/nosql/src/combio/cassandra/DataParsing.java [new file with mode: 0644]
webservices/compbio/nosql/src/combio/listeners/ContextListener.java [new file with mode: 0644]
webservices/compbio/nosql/src/combio/listeners/DetailList.java [new file with mode: 0644]
webservices/compbio/nosql/src/combio/listeners/LengthServlet.java [new file with mode: 0644]
webservices/compbio/nosql/src/combio/listeners/ProtServlet.java [new file with mode: 0644]
webservices/compbio/nosql/src/combio/listeners/QueryServlet.java [new file with mode: 0644]
webservices/compbio/nosql/src/combio/statistic/StatisticsProt.java [new file with mode: 0644]

diff --git a/webservices/compbio/nosql/.classpath b/webservices/compbio/nosql/.classpath
new file mode 100644 (file)
index 0000000..12511cb
--- /dev/null
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+       <classpathentry kind="src" path="src"/>
+       <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.jst.j2ee.internal.web.container"/>
+       <classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.module.container"/>
+       <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+       <classpathentry kind="lib" path="/home/natasha/Downloads/jamm-0.2.5.jar"/>
+       <classpathentry kind="lib" path="/home/natasha/workspace/nosql/jstl-1.2.jar"/>
+       <classpathentry kind="lib" path="/home/natasha/workspace/nosql/displaytag-1.2.jar"/>
+       <classpathentry kind="output" path="build/classes"/>
+</classpath>
diff --git a/webservices/compbio/nosql/.gitignore b/webservices/compbio/nosql/.gitignore
new file mode 100644 (file)
index 0000000..796b96d
--- /dev/null
@@ -0,0 +1 @@
+/build
diff --git a/webservices/compbio/nosql/.project b/webservices/compbio/nosql/.project
new file mode 100644 (file)
index 0000000..f2e4f29
--- /dev/null
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+       <name>nosql</name>
+       <comment></comment>
+       <projects>
+       </projects>
+       <buildSpec>
+               <buildCommand>
+                       <name>org.eclipse.wst.jsdt.core.javascriptValidator</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+               <buildCommand>
+                       <name>org.eclipse.jdt.core.javabuilder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+               <buildCommand>
+                       <name>org.eclipse.wst.common.project.facet.core.builder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+               <buildCommand>
+                       <name>org.eclipse.wst.validation.validationbuilder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+       </buildSpec>
+       <natures>
+               <nature>org.eclipse.jem.workbench.JavaEMFNature</nature>
+               <nature>org.eclipse.wst.common.modulecore.ModuleCoreNature</nature>
+               <nature>org.eclipse.wst.common.project.facet.core.nature</nature>
+               <nature>org.eclipse.jdt.core.javanature</nature>
+               <nature>org.eclipse.wst.jsdt.core.jsNature</nature>
+       </natures>
+</projectDescription>
diff --git a/webservices/compbio/nosql/.settings/.jsdtscope b/webservices/compbio/nosql/.settings/.jsdtscope
new file mode 100644 (file)
index 0000000..3a28de0
--- /dev/null
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+       <classpathentry kind="src" path="WebContent"/>
+       <classpathentry kind="con" path="org.eclipse.wst.jsdt.launching.JRE_CONTAINER"/>
+       <classpathentry kind="con" path="org.eclipse.wst.jsdt.launching.WebProject">
+               <attributes>
+                       <attribute name="hide" value="true"/>
+               </attributes>
+       </classpathentry>
+       <classpathentry kind="con" path="org.eclipse.wst.jsdt.launching.baseBrowserLibrary"/>
+       <classpathentry kind="output" path=""/>
+</classpath>
diff --git a/webservices/compbio/nosql/.settings/org.eclipse.jdt.core.prefs b/webservices/compbio/nosql/.settings/org.eclipse.jdt.core.prefs
new file mode 100644 (file)
index 0000000..f42de36
--- /dev/null
@@ -0,0 +1,7 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
+org.eclipse.jdt.core.compiler.compliance=1.7
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.7
diff --git a/webservices/compbio/nosql/.settings/org.eclipse.wst.common.component b/webservices/compbio/nosql/.settings/org.eclipse.wst.common.component
new file mode 100644 (file)
index 0000000..e76377e
--- /dev/null
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId" project-version="1.5.0">
+    <wb-module deploy-name="nosql">
+        <wb-resource deploy-path="/" source-path="/WebContent" tag="defaultRootSource"/>
+        <wb-resource deploy-path="/WEB-INF/classes" source-path="/src"/>
+        <property name="java-output-path" value="/nosql/build/classes"/>
+        <property name="context-root" value="nosql"/>
+    </wb-module>
+</project-modules>
diff --git a/webservices/compbio/nosql/.settings/org.eclipse.wst.common.project.facet.core.xml b/webservices/compbio/nosql/.settings/org.eclipse.wst.common.project.facet.core.xml
new file mode 100644 (file)
index 0000000..b3f07fe
--- /dev/null
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<faceted-project>
+  <runtime name="Apache Tomcat v7.0"/>
+  <fixed facet="java"/>
+  <fixed facet="jst.web"/>
+  <fixed facet="wst.jsdt.web"/>
+  <installed facet="java" version="1.7"/>
+  <installed facet="jst.web" version="3.0"/>
+  <installed facet="wst.jsdt.web" version="1.0"/>
+</faceted-project>
diff --git a/webservices/compbio/nosql/.settings/org.eclipse.wst.jsdt.ui.superType.container b/webservices/compbio/nosql/.settings/org.eclipse.wst.jsdt.ui.superType.container
new file mode 100644 (file)
index 0000000..3bd5d0a
--- /dev/null
@@ -0,0 +1 @@
+org.eclipse.wst.jsdt.launching.baseBrowserLibrary
\ No newline at end of file
diff --git a/webservices/compbio/nosql/.settings/org.eclipse.wst.jsdt.ui.superType.name b/webservices/compbio/nosql/.settings/org.eclipse.wst.jsdt.ui.superType.name
new file mode 100644 (file)
index 0000000..05bd71b
--- /dev/null
@@ -0,0 +1 @@
+Window
\ No newline at end of file
diff --git a/webservices/compbio/nosql/.settings/org.jboss.ide.eclipse.as.core.prefs b/webservices/compbio/nosql/.settings/org.jboss.ide.eclipse.as.core.prefs
new file mode 100644 (file)
index 0000000..cf3aa3a
--- /dev/null
@@ -0,0 +1,2 @@
+eclipse.preferences.version=1
+org.jboss.ide.eclipse.as.core.singledeployable.deployableList=
diff --git a/webservices/compbio/nosql/WebContent/AllReports.jsp b/webservices/compbio/nosql/WebContent/AllReports.jsp
new file mode 100644 (file)
index 0000000..110bc3e
--- /dev/null
@@ -0,0 +1,9 @@
+<%
+       String query = request.getParameter("query");
+       if (query.equals("date"))
+               response.sendRedirect("Sample.jsp");
+       else if (query.equals("length"))
+               response.sendRedirect("JobLength.jsp");
+       else if (query.equals("protein"))
+               response.sendRedirect("Sequence.jsp");
+%>
\ No newline at end of file
diff --git a/webservices/compbio/nosql/WebContent/Index.jsp b/webservices/compbio/nosql/WebContent/Index.jsp
new file mode 100644 (file)
index 0000000..475b4a7
--- /dev/null
@@ -0,0 +1,18 @@
+<%@ 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">
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+<title>Cassandra report</title>
+</head>
+<body>
+       <form method="post" action="AllReports.jsp">
+               <h3>Choose query type</h3>
+               <input type="radio" name="query" value="date"  Checked>Search by date<br/>
+               <input type="radio" name="query" value="length">Search by time interval<br/>
+               <input type="radio" name="query" value="protein">Search by protein sequence<br/>
+               <input type="submit" name="Search" value="Search"/>
+       </form>
+</body>
+</html>
\ No newline at end of file
diff --git a/webservices/compbio/nosql/WebContent/JobLength.jsp b/webservices/compbio/nosql/WebContent/JobLength.jsp
new file mode 100644 (file)
index 0000000..65c7004
--- /dev/null
@@ -0,0 +1,23 @@
+<%@ page language="java" contentType="text/html; charset=UTF-8"
+    pageEncoding="UTF-8"%>
+    <%@page import="java.util.Calendar"%>
+   
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+<title>Date interval</title>
+</head>
+<body>
+       <form method="post" action="LengthServlet">
+               <h3>Enter time period</h3>      
+                <% Calendar cal = Calendar.getInstance();
+                String datecalBegin = cal.get(Calendar.YEAR) + "/" + cal.get(Calendar.MONTH) + "/1";
+                       String datecalEnd = cal.get(Calendar.YEAR) + "/" + cal.get(Calendar.MONTH) + "/" + cal.get(Calendar.DAY_OF_MONTH);
+                %>
+               <p>from  <input type="text" name="data1" value = <%= datecalBegin%> style=" width : 145px;"/>
+               to <input type="text" name="data2" value = <%= datecalEnd%> style=" width : 145px;"/></p>
+               <input type="submit" name="Search" value="Search"/>
+       </form>
+</body>
+</html>
\ No newline at end of file
diff --git a/webservices/compbio/nosql/WebContent/META-INF/MANIFEST.MF b/webservices/compbio/nosql/WebContent/META-INF/MANIFEST.MF
new file mode 100644 (file)
index 0000000..5e94951
--- /dev/null
@@ -0,0 +1,3 @@
+Manifest-Version: 1.0\r
+Class-Path: \r
+\r
diff --git a/webservices/compbio/nosql/WebContent/PrintResult.jsp b/webservices/compbio/nosql/WebContent/PrintResult.jsp
new file mode 100644 (file)
index 0000000..c2f2e81
--- /dev/null
@@ -0,0 +1,21 @@
+<%@ 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">
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+<title>Report</title>
+</head>
+<body>
+<h3>Report Results</h3> 
+<%     String rez = request.getAttribute("result").toString();
+       String[] rezLines = rez.split(";");
+       for (int i = 0; i < rezLines.length; i++) {
+%>
+<%= rezLines[i]+"<br/>" %>
+<%
+}
+%>
+<a href="javascript:history.back()">Click here to go Back</a>
+</body>
+</html>
\ No newline at end of file
diff --git a/webservices/compbio/nosql/WebContent/ReportLength.jsp b/webservices/compbio/nosql/WebContent/ReportLength.jsp
new file mode 100644 (file)
index 0000000..0f20353
--- /dev/null
@@ -0,0 +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" %>
+
+<h3>Time execution for the interval: ${data1}  -  ${data2}</h3> 
+<table border="1" style = "border-collapse: collapse; white-space: nowrap"> 
+<thead>
+<tr>
+<th style="text-align: centre">Date</th>
+<th style="text-align: centre">less then 1s</th>
+<th style="text-align: centre">less then 10s</th>
+<th style="text-align: centre">less then 20s</th>
+<th style="text-align: centre">more then 20s</th>
+</tr>
+</thead>
+<tbody>
+<c:forEach items="${result}" var="res">
+<tr>
+<td>${res.date}</td>
+<c:forEach items="${res.timeRez}" var="time">
+<td>${time}</td>
+</c:forEach>
+</c:forEach>
+</tbody>
+</table>
diff --git a/webservices/compbio/nosql/WebContent/ReportNew.jsp b/webservices/compbio/nosql/WebContent/ReportNew.jsp
new file mode 100644 (file)
index 0000000..c0715bd
--- /dev/null
@@ -0,0 +1,43 @@
+<%@page import="java.util.ArrayList"%>
+<%@ 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" %>
+
+<h3>Jobs statistics for the Period: 
+<c:out value = "${data1}"/> to <c:out value = "${data2}"/> </h3>
+<table class="its" style="width:800px" border="1"> 
+<thead>
+<tr>
+<th rowspan="2"style="text-align: centre">Date</th>
+<th colspan="4" style="text-align: centre">Number of Proteins</th>
+</tr>
+<tr>
+<th style="text-align: centre">Total</th>
+<th style="text-align: centre">Failed</th>
+<th style="text-align: centre">Cancelled</th>
+<th style="text-align: centre">Abandoned</th>
+</tr>
+</thead>
+<tbody>
+<c:set var="sum"  value="0" />
+<c:forEach items="${result}" var="res">
+<tr>
+<td>${res.date}</td>
+<c:set var="tot"  value="${res.total}" />
+<c:set var="sum"  value="${sum + tot}" />
+<td style="text-align: right"><c:out value = "${res.total}" /></td>
+<td style="text-align: right">0</td>
+<td style="text-align: right">0</td>
+<td style="text-align: right">0</td>
+</tr>
+</c:forEach>
+<tr style="font-weight: bolder;">
+<td>Total:</td>
+<td style="text-align: right">${sum}</td>
+<td style="text-align: right">0</td>
+<td style="text-align: right">0</td>
+<td style="text-align: right">0</td>
+</tr>
+</tbody>
+</table>
\ No newline at end of file
diff --git a/webservices/compbio/nosql/WebContent/ReportProt.jsp b/webservices/compbio/nosql/WebContent/ReportProt.jsp
new file mode 100644 (file)
index 0000000..e5bc3fa
--- /dev/null
@@ -0,0 +1,39 @@
+<%@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" %>
+
+<h3>Dundee ProteoCache query result</h3>
+<table border="1" style = "border-collapse: collapse; white-space: nowrap"> 
+<thead>
+<tr>
+<th style="text-align: centre">ID</th>
+<th style="text-align: centre">Prediction</th>
+</tr>
+</thead>
+<tbody>
+<c:forEach items="${result}" var="res">
+<tr>
+<td rowspan="2">${res.id}</td>
+<c:if test ="${flag == 'whole'}">
+<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  style=" text-align: left;  border-buttom:  dotted; font-family: monospace">
+<c:forEach items="${res.subProt}" var="seq">
+<c:choose>
+<c:when test="${fn:contains(seq, prot)}"><span style="color:blue">${seq}</span></c:when>
+<c:otherwise>${seq}</c:otherwise>
+</c:choose>
+</c:forEach>
+</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>
+</tbody>
+</table>
diff --git a/webservices/compbio/nosql/WebContent/Sample.jsp b/webservices/compbio/nosql/WebContent/Sample.jsp
new file mode 100644 (file)
index 0000000..f080c3a
--- /dev/null
@@ -0,0 +1,23 @@
+<%@ page language="java" contentType="text/html; charset=UTF-8"
+    pageEncoding="UTF-8"%>
+    <%@page import="java.util.Calendar"%>
+   
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+<title>Date period</title>
+</head>
+<body>
+       <form method="post" action="QueryServlet">
+               <h3>Enter time period</h3>      
+                <% Calendar cal = Calendar.getInstance();
+                       String datecalBegin = cal.get(Calendar.YEAR) + "/" + cal.get(Calendar.MONTH) + "/1";
+                       String datecalEnd = cal.get(Calendar.YEAR) + "/" + cal.get(Calendar.MONTH) + "/" + cal.get(Calendar.DAY_OF_MONTH);
+                %>
+               <p>from  <input type="text" name="data1" value = <%= datecalBegin%> style=" width : 145px;"/>
+               to <input type="text" name="data2" value = <%= datecalEnd%> style=" width : 145px;"/></p>
+               <input type="submit" name="Full report" value="Full Search"/>
+       </form>
+</body>
+</html>
\ No newline at end of file
diff --git a/webservices/compbio/nosql/WebContent/Sequence.jsp b/webservices/compbio/nosql/WebContent/Sequence.jsp
new file mode 100644 (file)
index 0000000..29a033e
--- /dev/null
@@ -0,0 +1,20 @@
+<%@ 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">
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+<title>Sequence of protein</title>
+</head>
+<body>
+       <br/>
+       <form method="post" action="ProtServlet">
+               <h3>Enter protein sequence</h3> 
+               <p><textarea rows="2" cols="100" name="prot">MPIDYSKWKDIEVSDDEDDTHPNIDTPSLFRWRHQARLERMAEKKMEQEKIDKEKGTTSKKMEELEKKLAAADVTDKSDIQKQIDEVKAQEEAWRKKEAELEEKERLEPWNVDTIGHEAFSTSRINKI</textarea></p>
+               <input type="radio" name="protein" value="whole"  Checked>search by the whole sequence
+               <input type="radio" name="protein" value="part">search by a part of sequence<br/>
+               <input type="submit" name="Search" value="Search"/>
+       </form>
+</body>
+</html>
\ No newline at end of file
diff --git a/webservices/compbio/nosql/WebContent/StatisticsProtein.jsp b/webservices/compbio/nosql/WebContent/StatisticsProtein.jsp
new file mode 100644 (file)
index 0000000..06c7d72
--- /dev/null
@@ -0,0 +1,41 @@
+<%@ 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" %>
+
+<table class="its" style="width:800px" border="1"> 
+<thead>
+<tr>
+<th rowspan="2"style="text-align: centre">Date</th>
+<th colspan="4" style="text-align: centre">Number of Proteins</th>
+</tr>
+<tr>
+<th style="text-align: centre">Total</th>
+<th style="text-align: centre">Failed</th>
+<th style="text-align: centre">Cancelled</th>
+<th style="text-align: centre">Abandoned</th>
+</tr>
+</thead>
+<tbody>
+<c:set var="sum"  value="0" />
+<c:forEach items="${statistics}" var="res">
+<tr>
+<td>${res.date}</td>
+<c:set var="tot"  value="${res.total}" />
+<c:set var="sum"  value="${sum + tot}" />
+<td style="text-align: right"><c:out value = "${res.total}" /></td>
+<td style="text-align: right">0</td>
+<td style="text-align: right">0</td>
+<td style="text-align: right">0</td>
+</tr>
+</c:forEach>
+<tr style="font-weight: bolder;">
+<td>Total:</td>
+<td style="text-align: right">${sum}</td>
+<td style="text-align: right">0</td>
+<td style="text-align: right">0</td>
+<td style="text-align: right">0</td>
+
+</tr>
+</tbody>
+</table>
diff --git a/webservices/compbio/nosql/WebContent/WEB-INF/lib/cassandra-all-1.2.4.jar b/webservices/compbio/nosql/WebContent/WEB-INF/lib/cassandra-all-1.2.4.jar
new file mode 100644 (file)
index 0000000..ab244c5
Binary files /dev/null and b/webservices/compbio/nosql/WebContent/WEB-INF/lib/cassandra-all-1.2.4.jar differ
diff --git a/webservices/compbio/nosql/WebContent/WEB-INF/lib/cassandra-clientutil-1.2.4.jar b/webservices/compbio/nosql/WebContent/WEB-INF/lib/cassandra-clientutil-1.2.4.jar
new file mode 100644 (file)
index 0000000..1ac8df4
Binary files /dev/null and b/webservices/compbio/nosql/WebContent/WEB-INF/lib/cassandra-clientutil-1.2.4.jar differ
diff --git a/webservices/compbio/nosql/WebContent/WEB-INF/lib/cassandra-thrift-1.2.4.jar b/webservices/compbio/nosql/WebContent/WEB-INF/lib/cassandra-thrift-1.2.4.jar
new file mode 100644 (file)
index 0000000..ca72cf0
Binary files /dev/null and b/webservices/compbio/nosql/WebContent/WEB-INF/lib/cassandra-thrift-1.2.4.jar differ
diff --git a/webservices/compbio/nosql/WebContent/WEB-INF/lib/commons-lang-2.4.jar b/webservices/compbio/nosql/WebContent/WEB-INF/lib/commons-lang-2.4.jar
new file mode 100644 (file)
index 0000000..532939e
Binary files /dev/null and b/webservices/compbio/nosql/WebContent/WEB-INF/lib/commons-lang-2.4.jar differ
diff --git a/webservices/compbio/nosql/WebContent/WEB-INF/lib/displaytag-1.2.jar b/webservices/compbio/nosql/WebContent/WEB-INF/lib/displaytag-1.2.jar
new file mode 100644 (file)
index 0000000..4f379bd
Binary files /dev/null and b/webservices/compbio/nosql/WebContent/WEB-INF/lib/displaytag-1.2.jar differ
diff --git a/webservices/compbio/nosql/WebContent/WEB-INF/lib/google-collections-0.8.jar b/webservices/compbio/nosql/WebContent/WEB-INF/lib/google-collections-0.8.jar
new file mode 100644 (file)
index 0000000..01a54ef
Binary files /dev/null and b/webservices/compbio/nosql/WebContent/WEB-INF/lib/google-collections-0.8.jar differ
diff --git a/webservices/compbio/nosql/WebContent/WEB-INF/lib/hector-0.7.0-20-sources.jar b/webservices/compbio/nosql/WebContent/WEB-INF/lib/hector-0.7.0-20-sources.jar
new file mode 100644 (file)
index 0000000..9a2fe11
Binary files /dev/null and b/webservices/compbio/nosql/WebContent/WEB-INF/lib/hector-0.7.0-20-sources.jar differ
diff --git a/webservices/compbio/nosql/WebContent/WEB-INF/lib/hector-core-1.0-5.jar b/webservices/compbio/nosql/WebContent/WEB-INF/lib/hector-core-1.0-5.jar
new file mode 100644 (file)
index 0000000..a325f08
Binary files /dev/null and b/webservices/compbio/nosql/WebContent/WEB-INF/lib/hector-core-1.0-5.jar differ
diff --git a/webservices/compbio/nosql/WebContent/WEB-INF/lib/jamm-0.2.5.jar b/webservices/compbio/nosql/WebContent/WEB-INF/lib/jamm-0.2.5.jar
new file mode 100644 (file)
index 0000000..e9baf75
Binary files /dev/null and b/webservices/compbio/nosql/WebContent/WEB-INF/lib/jamm-0.2.5.jar differ
diff --git a/webservices/compbio/nosql/WebContent/WEB-INF/lib/jstl-1.2.jar b/webservices/compbio/nosql/WebContent/WEB-INF/lib/jstl-1.2.jar
new file mode 100644 (file)
index 0000000..0fd275e
Binary files /dev/null and b/webservices/compbio/nosql/WebContent/WEB-INF/lib/jstl-1.2.jar differ
diff --git a/webservices/compbio/nosql/WebContent/WEB-INF/lib/libthrift-0.6.0.jar b/webservices/compbio/nosql/WebContent/WEB-INF/lib/libthrift-0.6.0.jar
new file mode 100644 (file)
index 0000000..624e3ad
Binary files /dev/null and b/webservices/compbio/nosql/WebContent/WEB-INF/lib/libthrift-0.6.0.jar differ
diff --git a/webservices/compbio/nosql/WebContent/WEB-INF/lib/log4j-1.2.16.jar b/webservices/compbio/nosql/WebContent/WEB-INF/lib/log4j-1.2.16.jar
new file mode 100644 (file)
index 0000000..5429a90
Binary files /dev/null and b/webservices/compbio/nosql/WebContent/WEB-INF/lib/log4j-1.2.16.jar differ
diff --git a/webservices/compbio/nosql/WebContent/WEB-INF/lib/slf4j-1.7.5.tar.gz b/webservices/compbio/nosql/WebContent/WEB-INF/lib/slf4j-1.7.5.tar.gz
new file mode 100644 (file)
index 0000000..3f3d799
Binary files /dev/null and b/webservices/compbio/nosql/WebContent/WEB-INF/lib/slf4j-1.7.5.tar.gz differ
diff --git a/webservices/compbio/nosql/WebContent/WEB-INF/lib/slf4j-api-1.7.5.jar b/webservices/compbio/nosql/WebContent/WEB-INF/lib/slf4j-api-1.7.5.jar
new file mode 100644 (file)
index 0000000..8766455
Binary files /dev/null and b/webservices/compbio/nosql/WebContent/WEB-INF/lib/slf4j-api-1.7.5.jar differ
diff --git a/webservices/compbio/nosql/WebContent/WEB-INF/lib/slf4j-simple-1.7.5.jar b/webservices/compbio/nosql/WebContent/WEB-INF/lib/slf4j-simple-1.7.5.jar
new file mode 100644 (file)
index 0000000..9dece31
Binary files /dev/null and b/webservices/compbio/nosql/WebContent/WEB-INF/lib/slf4j-simple-1.7.5.jar differ
diff --git a/webservices/compbio/nosql/WebContent/WEB-INF/web.xml b/webservices/compbio/nosql/WebContent/WEB-INF/web.xml
new file mode 100644 (file)
index 0000000..672606e
--- /dev/null
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">
+  <display-name>nosql</display-name>
+  <listener>
+    <listener-class>combio.listeners.ContextListener</listener-class>
+  </listener>
+</web-app>
\ No newline at end of file
diff --git a/webservices/compbio/nosql/displaytag-1.2.jar b/webservices/compbio/nosql/displaytag-1.2.jar
new file mode 100644 (file)
index 0000000..4f379bd
Binary files /dev/null and b/webservices/compbio/nosql/displaytag-1.2.jar differ
diff --git a/webservices/compbio/nosql/jstl-1.2.jar b/webservices/compbio/nosql/jstl-1.2.jar
new file mode 100644 (file)
index 0000000..0fd275e
Binary files /dev/null and b/webservices/compbio/nosql/jstl-1.2.jar differ
diff --git a/webservices/compbio/nosql/src/combio/cassandra/CassandraCreate.java b/webservices/compbio/nosql/src/combio/cassandra/CassandraCreate.java
new file mode 100644 (file)
index 0000000..376da4c
--- /dev/null
@@ -0,0 +1,103 @@
+package combio.cassandra;
+
+import java.util.Arrays;
+
+import me.prettyprint.cassandra.serializers.LongSerializer;
+import me.prettyprint.cassandra.serializers.StringSerializer;
+import me.prettyprint.cassandra.service.ThriftKsDef;
+import me.prettyprint.hector.api.Cluster;
+import me.prettyprint.hector.api.Keyspace;
+import me.prettyprint.hector.api.beans.ColumnSlice;
+import me.prettyprint.hector.api.ddl.ColumnFamilyDefinition;
+import me.prettyprint.hector.api.ddl.ComparatorType;
+import me.prettyprint.hector.api.ddl.KeyspaceDefinition;
+import me.prettyprint.hector.api.factory.HFactory;
+import me.prettyprint.hector.api.mutation.Mutator;
+import me.prettyprint.hector.api.query.QueryResult;
+import me.prettyprint.hector.api.query.SliceQuery;
+
+public class CassandraCreate {
+       private static Keyspace ksp;
+       private static Cluster cluster;
+       private static Mutator<Long> mutatorLong;
+       private static Mutator<String> mutatorString;
+       private static Mutator<String> mutatorLog;
+       StringSerializer ss = StringSerializer.get();   
+       LongSerializer ls = LongSerializer.get();       
+       
+       
+       // connect to cluster 
+       public void Connection() {
+               cluster = HFactory.getOrCreateCluster("Protein Cluster", "127.0.0.1:9160");
+               KeyspaceDefinition keyspaceDef = cluster.describeKeyspace("ProteinKeyspace");
+               // If keyspace does not exist, the CFs don't exist either. => create them.
+/*             if (keyspaceDef != null) {
+                       cluster.dropColumnFamily("ProteinKeyspace", "ProteinRow", true);
+                       cluster.dropColumnFamily("ProteinKeyspace", "ProteinData", true);
+                       cluster.dropKeyspace("ProteinKeyspace", true);
+                       System.out.println("ProteinKeyspace has been dropped");
+       } else*/ if (keyspaceDef == null) {     // create column family
+                       System.out.println("ProteinKeyspace has been null");
+                       ColumnFamilyDefinition cfProtein = HFactory.createColumnFamilyDefinition("ProteinKeyspace", "ProteinRow", ComparatorType.ASCIITYPE);
+                       ColumnFamilyDefinition cfLog = HFactory.createColumnFamilyDefinition("ProteinKeyspace", "ProteinLog", ComparatorType.ASCIITYPE);
+                       ColumnFamilyDefinition cfData = HFactory.createColumnFamilyDefinition("ProteinKeyspace", "ProteinData", ComparatorType.ASCIITYPE);
+
+                       KeyspaceDefinition newKeyspace = HFactory.createKeyspaceDefinition("ProteinKeyspace",                 
+                                       ThriftKsDef.DEF_STRATEGY_CLASS, 1, Arrays.asList(cfProtein, cfLog, cfData));
+                       //Add the schema to the cluster.
+                       //"true" as the second param means that Hector will block until all nodes see the change.
+                       cluster.addKeyspace(newKeyspace, true);
+                       cluster.addColumnFamily(cfProtein, true);
+                       cluster.addColumnFamily(cfLog, true);
+                       cluster.addColumnFamily(cfData, true);
+               }
+               ksp = HFactory.createKeyspace("ProteinKeyspace", cluster);
+               System.out.println("Cassantra has been connected");             
+       }
+       
+       // parsing data from http://www.compbio.dundee.ac.uk/www-jpred/results/usage-new/alljobs.dat
+       public void Parsing() {
+               mutatorString = HFactory.createMutator(ksp, ss); // CF ProteinRow store protein and prediction
+               mutatorLog = HFactory.createMutator(ksp, ss); // CF ProteinLog store log informations (ip, id, dates start and dates of end)
+               mutatorLong = HFactory.createMutator(ksp, ls); // CF ProteinData store id and protein per data
+               System.out.println("Parsing......");
+               String in = "http://www.compbio.dundee.ac.uk/www-jpred/results/usage-new/alljobs.dat";
+               DataParsing datParsing = new DataParsing();
+               datParsing.ParsingTest(in);
+               mutatorString.execute();
+               mutatorLong.execute();
+               mutatorLog.execute();
+               System.out.println("Data Inserted");
+       }
+       
+       public void Closing() {
+               cluster.getConnectionManager().shutdown();  
+               System.out.println("Cassantra has been closed");
+       }
+       
+       // check whether this id exists in the cassandra DB
+       public boolean CheckIP(String ip) {
+               SliceQuery<String, String, String> sliceQuery = HFactory.createSliceQuery(ksp, ss, ss, ss);
+               sliceQuery.setColumnFamily("ProteinLog").setKey(ip).setRange("", "", false, 100);
+               QueryResult<ColumnSlice<String, String>> result = sliceQuery.execute();
+               if (result.get().getColumns().size() > 0)
+                       return true;
+               else
+                       return false;
+       }       
+       
+       public void InsertData(long dataWork, String dataBegin, String dataEnd, String ip, String id, String statusEx, String statusFinal, String protein, String jnetpred) {
+               mutatorLog.addInsertion(id, "ProteinLog", HFactory.createColumn("ip", ip, ss, ss))
+               .addInsertion(id, "ProteinLog", HFactory.createColumn("DataBegin", dataBegin, ss, ss))
+               .addInsertion(id, "ProteinLog", HFactory.createColumn("DataEnd", dataEnd, ss, ss))
+               .addInsertion(id, "ProteinLog", HFactory.createColumn("Status ex", statusEx, ss, ss))
+               .addInsertion(id, "ProteinLog", HFactory.createColumn("Status final", statusFinal, ss, ss))
+               .addInsertion(id, "ProteinLog", HFactory.createColumn("Protein", protein, ss, ss));                     
+               mutatorString.addInsertion(protein, "ProteinRow", HFactory.createColumn(id, jnetpred, ss, ss));
+               mutatorLong.addInsertion(dataWork, "ProteinData", HFactory.createColumn(id, protein, ss, ss));          
+         }
+       
+       public Keyspace GetKeyspace() {
+               return ksp;
+       }
+}
diff --git a/webservices/compbio/nosql/src/combio/cassandra/DataBase.java b/webservices/compbio/nosql/src/combio/cassandra/DataBase.java
new file mode 100644 (file)
index 0000000..036a48d
--- /dev/null
@@ -0,0 +1,76 @@
+package combio.cassandra;
+
+import java.util.List;
+
+public class DataBase {
+       String date;
+       int total;
+       String id;
+       String prot;
+       String jpred;
+       List<String> subProt;
+       List<Integer> timeRez;
+       
+       
+       public DataBase() {}
+       
+       public DataBase(String dat, int total) {
+               this.date = dat;
+               this.total = total;
+       }
+       
+       public void  setDate(String dat) {
+               this.date = dat;
+       }
+       
+       public String getDate() {
+               return date;
+       }
+       
+       public void  setTotal(int tot) {
+               this.total = tot;
+       }
+       public int getTotal() {
+               return total;
+       }
+
+       public void  setProt(String prot) {
+               this.prot = prot;
+       }
+       
+       public String getProt() {
+               return prot;
+       }
+       
+       public void  setJpred(String jpred) {
+               this.jpred = jpred;
+       }
+       
+       public String getJpred() {
+               return jpred;
+       }
+       
+       public void  setId(String id) {
+               this.id = id;
+       }
+       
+       public String getId() {
+               return id;
+       }
+       
+       public void  setSubProt(List<String> subProt) {
+               this.subProt = subProt;
+       }
+       
+       public List<String>  getSubProt() {
+               return subProt;
+       }
+       
+       public void  setTimeRez(List<Integer> timeRez) {
+               this.timeRez = timeRez;
+       }
+       
+       public List<Integer>  getTimeRez() {
+               return timeRez;
+       }
+}
diff --git a/webservices/compbio/nosql/src/combio/cassandra/DataParsing.java b/webservices/compbio/nosql/src/combio/cassandra/DataParsing.java
new file mode 100644 (file)
index 0000000..1a03ce4
--- /dev/null
@@ -0,0 +1,98 @@
+package combio.cassandra;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.net.HttpURLConnection;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.net.URLConnection;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Calendar;
+import java.util.Date;
+
+public class DataParsing {
+       private CassandraCreate cc = new CassandraCreate();
+       
+       public void ParsingTest(String input) {
+               System.out.println("Inserting.....");
+               URL url, urltable;
+//             int count = 0;
+//             int countNotM = 0;
+//             int countEr = 0;
+//             int countEmp = 0;
+               Calendar cal = Calendar.getInstance();
+               String date = cal.get(Calendar.YEAR) + "/" + cal.get(Calendar.MONTH) + "/" + cal.get(Calendar.DAY_OF_MONTH);     
+               try {
+                       url = new URL(input);
+                       URLConnection conn = url.openConnection();
+                       BufferedReader br = new BufferedReader(new InputStreamReader(conn.getInputStream()));
+                       String line;    
+                       
+                       while ((line = br.readLine()) != null) {
+                               if (line.matches(date + "(.*)jp_[^\\s]+")) {    
+                                       String[] table;
+                                       table = line.split("\\s+");
+       //                              count++;
+                                               if (!cc.CheckIP(table[table.length - 1])) {             
+       //                                              countNotM++;
+                                                       urltable = new URL("http://www.compbio.dundee.ac.uk/www-jpred/results/" +table[table.length - 1]+"/"+table[table.length - 1]+".concise.fasta");
+                                                       HttpURLConnection httpConnection = (HttpURLConnection) urltable.openConnection();
+                                                       if (httpConnection.getResponseCode() > 200) {
+//                                                             countEr++;
+                                                               continue;                                       
+                                                       }
+                                                       try {
+                                                               BufferedReader br1 = new BufferedReader(new InputStreamReader(httpConnection.getInputStream()));
+                                                               String lineNext;
+                                                               String newProt = "";
+                                                               String jnetpred = "";
+                                                               while ((lineNext = br1.readLine()) != null) {
+                                                                       if (lineNext.equals(">QUERY")) {
+                                                                               while (!(lineNext = br1.readLine()).matches(">[^\\s]+"))
+                                                                                       newProt += lineNext;
+                                                                       } else if (lineNext.equals(">jnetpred")) {
+                                                                               while (!(lineNext = br1.readLine()).matches(">[^\\s]+"))
+                                                                                       jnetpred += lineNext;
+                                                                       }                                                               
+                                                               }
+                                                               br1.close();
+                                                               if (newProt.length() <= 1) {            
+               //                                                      countEmp++;
+                                                                       continue;
+                                                               }
+                                                               
+                                                               SimpleDateFormat formatter = new SimpleDateFormat("yyyy/MM/dd");
+                                               
+                                                               String dateInString1 = table[0].substring(0, table[0].indexOf(":"));
+                                                               
+                                                               long dateWork1 = 0;     
+                                                                       
+                                                               try {
+                                                                       Date dat1 = formatter.parse(dateInString1);
+                                                                       dateWork1 = dat1.getTime();
+                                                                       
+                                                               } catch (ParseException e) {
+                                                                       e.printStackTrace();
+                                                               }
+                                                               cc.InsertData(dateWork1, table[0], table[1], table[2], table[table.length - 1], "OK", "OK", newProt, jnetpred);
+                                                       } catch (IOException e) {
+                                                               //                      e.printStackTrace();
+                                                       }       
+                                       //      }       
+                                       }
+                               } 
+                       }
+                       br.close();     
+//                     System.out.println("Match " + count);
+//                     System.out.println("Not Match " + countNotM);
+//                     System.out.println("Error " + countEr);
+//                     System.out.println("No protein " + countEmp);
+               } catch (MalformedURLException e) {
+                       e.printStackTrace();
+               } catch (IOException e) {
+                       e.printStackTrace();
+               }
+       }
+}
diff --git a/webservices/compbio/nosql/src/combio/listeners/ContextListener.java b/webservices/compbio/nosql/src/combio/listeners/ContextListener.java
new file mode 100644 (file)
index 0000000..1b57283
--- /dev/null
@@ -0,0 +1,48 @@
+package combio.listeners;
+
+import java.util.concurrent.Executors;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.TimeUnit;
+
+import javax.servlet.ServletContextEvent;
+import javax.servlet.ServletContextListener;
+import javax.servlet.annotation.WebListener;
+
+import combio.cassandra.CassandraCreate;
+
+/**
+ * Application Lifecycle Listener implementation class ContextListener
+ *
+ */
+@WebListener
+public class ContextListener implements ServletContextListener {
+       private ScheduledExecutorService scheduler;
+       CassandraCreate cc = new CassandraCreate();
+       /**
+     * @see ServletContextListener#contextInitialized(ServletContextEvent)
+     */
+    public void contextInitialized(ServletContextEvent arg0) {
+       System.out.println("Session start ...........................................");        
+       cc.Connection();
+       
+       
+       scheduler = Executors.newSingleThreadScheduledExecutor();
+       scheduler.scheduleAtFixedRate(new Runnable() {
+            @Override
+            public void run() { cc.Parsing();}}
+                       , 0, 30, TimeUnit.SECONDS);
+    }
+
+       /**
+     * @see ServletContextListener#contextDestroyed(ServletContextEvent)
+     */
+    public void contextDestroyed(ServletContextEvent arg0) {
+       cc.Closing();
+       System.out.println("Shut down");
+       scheduler.shutdownNow();
+    }
+    
+    
+    
+    
+}
diff --git a/webservices/compbio/nosql/src/combio/listeners/DetailList.java b/webservices/compbio/nosql/src/combio/listeners/DetailList.java
new file mode 100644 (file)
index 0000000..7d679f1
--- /dev/null
@@ -0,0 +1,45 @@
+package combio.listeners;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import combio.cassandra.*;
+import combio.statistic.StatisticsProt;
+
+/**
+ * Servlet implementation class DetailList
+ */
+@WebServlet("/DetailList")
+public class DetailList extends HttpServlet {
+       private static final long serialVersionUID = 1L;
+       
+    /**
+     * @see HttpServlet#HttpServlet()
+     */
+
+       /**
+        * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
+        */
+       protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
+               List<DataBase> result;
+               String date1 = request.getParameter("data1");
+               String date2 = request.getParameter("data2");
+               StatisticsProt sp = new StatisticsProt();
+//             result = sp.readDetail(date1, date2);
+       }
+
+       /**
+        * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
+        */
+       protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
+               // TODO Auto-generated method stub
+       }
+
+}
diff --git a/webservices/compbio/nosql/src/combio/listeners/LengthServlet.java b/webservices/compbio/nosql/src/combio/listeners/LengthServlet.java
new file mode 100644 (file)
index 0000000..6e4feee
--- /dev/null
@@ -0,0 +1,44 @@
+package combio.listeners;
+
+import java.io.IOException;
+import java.util.List;
+
+import javax.servlet.RequestDispatcher;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import combio.cassandra.DataBase;
+import combio.statistic.StatisticsProt;
+
+/**
+ * Servlet implementation class LengthServlet
+ */
+@WebServlet("/LengthServlet")
+public class LengthServlet extends HttpServlet {
+       private static final long serialVersionUID = 1L;
+       /**
+        * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
+        */
+       protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
+               List<DataBase> result;          
+               String date1 = request.getParameter("data1");
+               String date2 = request.getParameter("data2");
+               StatisticsProt sp = new StatisticsProt();       
+               result = sp.readLength(date1, date2);
+               request.setAttribute("data1", date1);
+               request.setAttribute("data2", date2);
+        request.setAttribute("result", result);
+        RequestDispatcher rd = request.getRequestDispatcher("/ReportLength.jsp");
+        rd.forward(request, response);
+       }
+
+       /**
+        * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
+        */
+       protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
+               doGet(request, response);
+       }
+}
diff --git a/webservices/compbio/nosql/src/combio/listeners/ProtServlet.java b/webservices/compbio/nosql/src/combio/listeners/ProtServlet.java
new file mode 100644 (file)
index 0000000..7bef70d
--- /dev/null
@@ -0,0 +1,49 @@
+package combio.listeners;
+
+import java.io.IOException;
+import java.util.List;
+
+import javax.servlet.RequestDispatcher;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import combio.cassandra.DataBase;
+import combio.statistic.StatisticsProt;
+
+/**
+ * Servlet implementation class ProtServlet
+ */
+@WebServlet("/ProtServlet")
+public class ProtServlet extends HttpServlet {
+       private static final long serialVersionUID = 1L;
+       /**
+        * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
+        */
+       protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
+               List<DataBase> result;          
+               String flag = request.getParameter("protein");
+               String prot = request.getParameter("prot");
+               StatisticsProt sp = new StatisticsProt();       
+               if (flag.equals("whole")) {
+                       result = sp.readProt(prot);
+               } else {
+                       result = sp.readPart(prot);
+               }
+               request.setAttribute("prot", prot);
+               request.setAttribute("flag", flag);
+        request.setAttribute("result", result);
+        RequestDispatcher rd = request.getRequestDispatcher("/ReportProt.jsp");
+        rd.forward(request, response);
+       }
+
+       /**
+        * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
+        */
+       protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
+               doGet(request, response);
+       }
+
+}
diff --git a/webservices/compbio/nosql/src/combio/listeners/QueryServlet.java b/webservices/compbio/nosql/src/combio/listeners/QueryServlet.java
new file mode 100644 (file)
index 0000000..e9ab299
--- /dev/null
@@ -0,0 +1,41 @@
+package combio.listeners;
+
+import java.io.IOException;
+import java.util.List;
+
+import javax.servlet.RequestDispatcher;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import combio.cassandra.*;
+import combio.statistic.StatisticsProt;
+
+
+@WebServlet("/QueryServlet")
+public class QueryServlet extends HttpServlet {
+       private static final long serialVersionUID = 1L;
+       
+       /**
+        * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
+        */
+       protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
+               List<DataBase> result;          
+               String date1 = request.getParameter("data1");
+               String date2 = request.getParameter("data2");
+               StatisticsProt sp = new StatisticsProt();               
+               result = sp.readDetail(date1, date2);
+               request.setAttribute("data1", date1);
+               request.setAttribute("data2", date2);
+        request.setAttribute("result", result);
+        RequestDispatcher rd = request.getRequestDispatcher("/ReportNew.jsp");
+        rd.forward(request, response);
+       }
+       
+       protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
+               doGet(request, response);
+       }
+
+}
diff --git a/webservices/compbio/nosql/src/combio/statistic/StatisticsProt.java b/webservices/compbio/nosql/src/combio/statistic/StatisticsProt.java
new file mode 100644 (file)
index 0000000..72cad07
--- /dev/null
@@ -0,0 +1,204 @@
+package combio.statistic;
+
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Date;
+import java.util.Iterator;
+import java.util.List;
+
+import me.prettyprint.cassandra.serializers.LongSerializer;
+import me.prettyprint.cassandra.serializers.StringSerializer;
+import me.prettyprint.hector.api.beans.ColumnSlice;
+import me.prettyprint.hector.api.beans.HColumn;
+import me.prettyprint.hector.api.beans.OrderedRows;
+import me.prettyprint.hector.api.beans.Row;
+import me.prettyprint.hector.api.factory.HFactory;
+import me.prettyprint.hector.api.query.QueryResult;
+import me.prettyprint.hector.api.query.RangeSlicesQuery;
+import me.prettyprint.hector.api.query.SliceQuery;
+import combio.cassandra.CassandraCreate;
+import combio.cassandra.DataBase;
+
+public class StatisticsProt {
+       private final static long MILLISECONDS_PER_DAY = 1000L * 60 * 60 * 24;
+       private CassandraCreate cc = new CassandraCreate();
+       private ArrayList<DataBase> query;
+       
+       // query for the period from date1 till date2
+              public List<DataBase> readDetail(String dateInStringSt, String dateInStringEnd) {
+                  long dateWorkSt = DateParsing(dateInStringSt);
+                  long dateWorkEnd = DateParsing(dateInStringEnd);                        
+                  query = new ArrayList<DataBase>();
+                  while (dateWorkSt <= dateWorkEnd) {
+                       SliceQuery<Long, String, String> result = HFactory.createSliceQuery(cc.GetKeyspace(), LongSerializer.get(), StringSerializer.get(), StringSerializer.get());
+                       result.setColumnFamily("ProteinData");
+                       result.setKey(dateWorkSt);
+                       result.setRange(null, null, false, Integer.MAX_VALUE); 
+                       QueryResult <ColumnSlice<String, String>> columnSlice = result.execute();
+                       DataBase db = new DataBase(DateFormat(dateWorkSt), columnSlice.get().getColumns().size());
+                       query.add(db);
+                       dateWorkSt +=  MILLISECONDS_PER_DAY ;
+                   } 
+                  return query;
+       }
+       
+       // query jobs for the period from dateInStringSt till dateInStringEnd
+       public List<DataBase>  readLength(String dateInStringSt, String dateInStringEnd) {              
+               query = new ArrayList<DataBase>();
+       long dateWorkSt = DateParsing(dateInStringSt);
+       long dateWorkEnd = DateParsing(dateInStringEnd);                        
+       while (dateWorkSt <= dateWorkEnd) {
+               List<Integer> timeResult = new ArrayList<Integer>();
+               SliceQuery<Long, String, String> result = HFactory.createSliceQuery(cc.GetKeyspace(), LongSerializer.get(), StringSerializer.get(), StringSerializer.get());
+            result.setColumnFamily("ProteinData");
+            result.setKey(dateWorkSt);
+            result.setRange(null, null, false, Integer.MAX_VALUE); 
+            QueryResult <ColumnSlice<String, String>> columnSlice = result.execute();
+            List<HColumn<String, String>> col = columnSlice.get().getColumns();
+            Iterator<HColumn<String, String>> itCol = col.iterator();    
+            for (int i = 0; i < 4; i++) 
+               timeResult.add(i, 0);
+            while (itCol.hasNext()) {
+               String id = itCol.next().getName();             
+               long lenResult = CountID(id);                   
+               if (lenResult <= 1) 
+                       timeResult.set(0,  timeResult.get(0) + 1);
+               else if (lenResult > 1 && lenResult <= 10) 
+                       timeResult.set(1, timeResult.get(1) + 1);
+               else if (lenResult > 10 && lenResult <= 20) 
+                       timeResult.set(2, timeResult.get(2) + 1);
+                else 
+                       timeResult.set(3, timeResult.get(3) + 1);
+            }  
+            DataBase db = new DataBase();
+            db.setTimeRez(timeResult);
+            db.setDate(DateFormat(dateWorkSt));
+            query.add(db);
+            List<Integer> test = query.get(0).getTimeRez();
+            dateWorkSt +=  MILLISECONDS_PER_DAY ;
+        }         
+       return query;
+    }
+       
+       //query by a protein name
+       public List<DataBase> readProt(String protIn) {     
+       query = new ArrayList<DataBase>();
+       SliceQuery<String, String, String> result = HFactory.createSliceQuery(cc.GetKeyspace(), StringSerializer.get(), StringSerializer.get(), StringSerializer.get());
+        result.setColumnFamily("ProteinRow");
+        result.setKey(protIn);
+        result.setRange(null, null, false, Integer.MAX_VALUE); 
+        QueryResult <ColumnSlice<String, String>> columnSlice = result.execute();             
+        Iterator <HColumn<String, String>> it = columnSlice.get().getColumns().iterator();
+        while (it.hasNext()) {
+               HColumn<String, String> col = it.next();
+               DataBase db = new DataBase();
+               db.setProt(protIn);
+               db.setId(col.getName());
+               db.setJpred(col.getValue());      
+               query.add(db);
+        }    
+       return query;
+    }
+       
+       
+       //query by a sequence (whether exists proteins contains this sequence in the name)
+       public List<DataBase> readPart(String protIn) {     
+               int row_count = 10000;
+       query = new ArrayList<DataBase>();
+       RangeSlicesQuery<String, String, String> result = HFactory.createRangeSlicesQuery(cc.GetKeyspace(), StringSerializer.get(), StringSerializer.get(), StringSerializer.get());
+        result.setColumnFamily("ProteinRow");
+        result.setRange(null, null, false, Integer.MAX_VALUE); 
+        result.setRowCount(row_count);
+        String last_key = null;     
+        while (true) {
+               result.setKeys(last_key, null);
+               QueryResult <OrderedRows<String,String, String>> columnSlice = result.execute(); 
+               OrderedRows<String, String, String> rows = columnSlice.get();
+               Iterator<Row<String, String, String>> rowsIterator = rows.iterator();             
+            while (rowsIterator.hasNext()) {
+               Row<String, String, String> row = rowsIterator.next();
+                last_key = row.getKey(); 
+                if (last_key.matches("(.*)" + protIn + "(.*)")) {
+                       Iterator <HColumn<String, String>> it = row.getColumnSlice().getColumns().iterator();
+                       while (it.hasNext()) {
+                               HColumn<String, String> col = it.next();
+                               List<String> subProt = new ArrayList<String>();
+                               String subStr = last_key;
+                               while (subStr.length() > 0 && subStr.contains(protIn)) {
+                                       String first = subStr.substring(0, subStr.indexOf(protIn));
+                                       if (first.length() > 0)
+                                               subProt.add(first);
+                                       subProt.add(protIn);
+                                       subStr = subStr.substring(subStr.indexOf(protIn) + protIn.length(), subStr.length());
+                               }
+                               if (subStr.length() > 0)
+                                       subProt.add(subStr);
+                               DataBase db = new DataBase();
+                               db.setProt(last_key);
+                               db.setId(col.getName());
+                               db.setJpred(col.getValue());
+                               db.setSubProt(subProt);
+                               query.add(db);
+                       }
+                }
+            }
+            if (rows.getCount() < row_count)
+                break;
+        }
+       return query;
+    }
+       
+       // convert String to Date
+       private static long DateParsing(String datInput) {
+               long dateWorkSt = 0;
+               SimpleDateFormat formatter = new SimpleDateFormat("yyyy/MM/dd"); 
+               try {                           
+                       dateWorkSt = formatter.parse(datInput).getTime();                       
+       } catch (ParseException e) {
+                       e.printStackTrace();
+               }       
+           return dateWorkSt;
+       }
+       
+       // convert String to Date
+               private static long TimeConvert(String datInput) {
+                       long dateWorkSt = 0;
+                       SimpleDateFormat formatter = new SimpleDateFormat("yyyy/MM/dd:hh:mm:ss"); 
+                       try {                           
+                               dateWorkSt = formatter.parse(datInput).getTime();                       
+               } catch (ParseException e) {
+                               e.printStackTrace();
+                       }
+       //              System.out.println("start reverce" + DateFormat1(dateWorkSt));
+                   return dateWorkSt;
+               }
+       
+       //  convert long to date in string format
+       private static String DateFormat(long inDate){
+        SimpleDateFormat datformat = new SimpleDateFormat("dd/MM/yyyy");
+        String dateString = datformat.format(new Date(inDate));
+               return dateString;
+       }
+       
+       private static String DateFormat1(long inDate){
+        SimpleDateFormat datformat = new SimpleDateFormat("dd/MM/yyyy:hh:mm:ss");
+        String dateString = datformat.format(new Date(inDate));
+               return dateString;
+       }
+       
+       public long CountID(String id) {
+               SliceQuery<String, String, String> sliceQuery = HFactory.createSliceQuery(cc.GetKeyspace(), StringSerializer.get(), StringSerializer.get(), StringSerializer.get());
+               sliceQuery.setColumnFamily("ProteinLog").setKey(id).setRange("", "", false, 100);
+               QueryResult<ColumnSlice<String, String>> result = sliceQuery.execute();
+               String datBegin = result.get().getColumnByName("DataBegin").getValue();
+               String datEnd = result.get().getColumnByName("DataEnd").getValue();
+               long datBeginLong = TimeConvert(datBegin);
+               long datEndLong = TimeConvert(datEnd);
+               return datEndLong-datBeginLong;
+                
+       }
+       
+}