this.predictions = new LinkedHashMap<String, String>();
this.jobid = new ArrayList<String>();
setPredictions(pred);
+ setJnetpred(pred);
}
public void setSequence(String seq) {
import compbio.beans.ProteinBean;
+/**
+ * Reader class for making requests on protein sequences to cassandra.
+ *
+ * @author Alexander Sherstnev
+ * @author Natasha Sherstneva
+ *
+ * @since 0.5
+ * @version 1.0
+ * @since December 2013
+ */
public class SequenceReader extends CassandraReader {
public SequenceReader() {
/**
* query: protein sequence
*
- * @param protIn
+ * @param sequence
* protein sequence or partial of protein sequence
* @param searchtype
* "whole" or "partial" of protein sequence
* @return List<ProteinBean> to the controller SequenceController
*
**/
- public List<ProteinBean> readProteins(String protIn, String searchtype) {
+ public List<ProteinBean> readProteins(String sequence, String searchtype) {
List<ProteinBean> query = new ArrayList<ProteinBean>();
if (searchtype.equals("whole")) {
- ResultSet results = CassandraQuery("SELECT JobID, Predictions FROM ProteinRow WHERE Protein = '" + protIn + "';");
+ ResultSet results = CassandraQuery("SELECT JobID, Predictions FROM ProteinRow WHERE Protein = '" + sequence + "';");
if (results.isExhausted())
return null;
List<Row> rows = results.all();
- ProteinBean structure = new ProteinBean(protIn, rows.get(0).getMap("Predictions", String.class, String.class));
+ ProteinBean structure = new ProteinBean(sequence, rows.get(0).getMap("Predictions", String.class, String.class));
for (Row r : rows) {
structure.setJobid(r.getString("JobID"));
}
query.add(structure);
} else {
- ResultSet results = CassandraQuery("SELECT * FROM ProteinRow;");
+ ResultSet results = CassandraQuery("SELECT * FROM ProteinRow;");
if (results.isExhausted())
return null;
List<Row> rows = results.all();
for (Row r : rows) {
- String prot = r.getString("Protein");
- if (prot.matches("(.*)" + protIn + "(.*)")) {
- ProteinBean structure = new ProteinBean(prot, r.getMap("Predictions", String.class, String.class));
- structure.setJobid(r.getString("JobID"));
- query.add(structure);
+ String protein = r.getString("Protein");
+ if (protein.matches("(.*)" + sequence + "(.*)")) {
+ ProteinBean foundsequence = new ProteinBean(protein, r.getMap("Predictions", String.class, String.class));
+ query.add(foundsequence);
}
}
}
if (searchtype.equals("partial")) {
for (ProteinBean entry : query) {
- entry.setSubProt(CreateSubprotein(entry.getSequence(), protIn));
+ entry.setSubProt(CreateSubprotein(entry.getSequence(), sequence));
}
}
return query;
import compbio.engine.archive.ArchivedJob;
/**
+ * Spring controller for supporting job queries. This version works in the
+ * servlet style.
+ *
* @author Alexander Sherstnev
* @author Natasha Sherstneva
- * @version 1.0 Dec 2013
+ * @version 1.0
+ * @since Dec 2013
*/
@Controller
public class JobController extends BasicController {
/**
* form a report page for a job execution time statistics.
*
+ * @param date1
+ * initial date for requested statistics
+ * @param date2
+ * final date for requested statistics
+ * @param alldates
+ * All available jobs are analyzed if alldates="AllDates,off"
* @param model
* MVC model
* @return link to the JSP query page
*/
@RequestMapping(value = "/stat/exectime/results", method = RequestMethod.GET)
public String findExecTimeData(@RequestParam("date1") String date1, @RequestParam("date2") String date2,
- @RequestParam(value = "option", required = false) String option, Map<String, Object> model) {
+ @RequestParam(value = "option", required = false) String alldates, Map<String, Object> model) {
model.put("username", getPrincipalName());
final long startTime = System.currentTimeMillis();
Calendar loccal = Calendar.getInstance();
ExecutionTimeReader reader = new ExecutionTimeReader();
- if (option.equals("AllDates,off")) {
+ if (alldates.equals("AllDates,off")) {
date1 = theEaerlistDate;
date2 = theCurrentDate;
}
-
+
// dates in string format
String trimmeddate1 = date1.replaceAll("\\s", "");
String trimmeddate2 = date2.replaceAll("\\s", "");
model.put("date2", date2);
return "query/JobTimeExecution";
}
-
+
if (longDate1 < CassandraReader.earliestDate())
longDate1 = CassandraReader.earliestDate();
if (longDate2 > loccal.getTimeInMillis())
date2 = DateFormatter.DateLongToString(longDate2, formaterYYMMDD);
model.put("date1", date1);
model.put("date2", date2);
- model.put("option", option);
- ExecutionTimeBean res = reader.query(longDate1, longDate2);;
+ model.put("option", alldates);
+ ExecutionTimeBean res = reader.query(longDate1, longDate2);
+ ;
model.put("result", res);
Map<String, TotalExecutionTime> results = res.getDateTotal();
- String csvline = "";
+ StringBuilder csvline = new StringBuilder("");
if (0 < res.getDateTotal().size()) {
- csvline = "\'Date\',\'Total\',\'0-30 sec\',\'30-60 sec\',\'1-2 min\',\'2-10 min\',\'more 10 min\'%0A";
+ csvline.append("\'Date\',\'Total\',\'0-30 sec\',\'30-60 sec\',\'1-2 min\',\'2-10 min\',\'more 10 min\'%0A");
for (Map.Entry<String, TotalExecutionTime> entry : results.entrySet()) {
- csvline += "\'" + entry.getKey() + "\',\'" + entry.getValue().getTotal() + "\',\'" + entry.getValue().getTotal0_30s() + "\',\'"
- + entry.getValue().getTotal30_60s() + "\',\'" + entry.getValue().getTotal1_2m() + "\',\'"
- + entry.getValue().getTotal2_10m() + "\',\'" + entry.getValue().getTotal10m() + "\'%0A";
+ csvline.append("\'" + entry.getKey() + "\',\'" + entry.getValue().getTotal() + "\',\'" + entry.getValue().getTotal0_30s()
+ + "\',\'" + entry.getValue().getTotal30_60s() + "\',\'" + entry.getValue().getTotal1_2m() + "\',\'"
+ + entry.getValue().getTotal2_10m() + "\',\'" + entry.getValue().getTotal10m() + "\'%0A");
}
}
- model.put("csvfile", csvline);
+ model.put("csvfile", csvline.toString());
model.put("ndays", res.getDateTotal().size() - 1);
final long endTime = System.currentTimeMillis();
model.put("timeExecution", (endTime - startTime));
}
/**
- * form a query page for a job. The servlet should no be visible to users at
- * all.
+ * form result page for one job with a given job ID.
*
+ * @param jobid
+ * job ID
* @param model
* MVC model
+ *
* @return link to the JSP query page
* @throws IOException
*/
model.put("timeExecution", (endTime - startTime));
model.put("IdJob", jobid);
+ // prepare archive file for the job for downloading
ArchivedJob aj = new ArchivedJob(jobid);
try {
model.put("jobarchive", aj.prepareJobArchiveToWeb());
import compbio.statistic.CassandraRequester;
/**
- * Spring controller for sequence queries. This version works in the servlet
- * style.
+ * Spring controller for protein secondary structure features. This version
+ * works in the servlet style.
*
* @author Alexander Sherstnev
* @author Natasha Sherstneva
@RequestMapping("/features")
public class SSFeaturesController extends BasicController {
+ /**
+ * form a query page for protein secondary structure feaatures: Proteins
+ * with given fraction of H/E (helix/beta sheets)
+ *
+ * @param model
+ * MVC model object
+ *
+ * @return link to the report JSP page
+ */
@RequestMapping(value = "query", method = RequestMethod.GET)
public String formCounterQuery(Map<String, Object> model) {
model.put("username", getPrincipalName());
return "query/SSFeatures";
}
+ /**
+ * form a results page for protein secondary structure features: Proteins
+ * with given fraction of H/E (helix/beta sheets) All proteins with E/H
+ * higher than a given percent of the length are returned
+ *
+ * @param model
+ * MVC model object
+ * @param typeFeature
+ * type of SS: H/E (helix/beta sheets)
+ * @param percent
+ * fraction of the protein length predicted as H/E (helix/beta
+ * sheets)
+ *
+ * @return link to the report JSP page
+ */
@RequestMapping(value = "results", method = RequestMethod.GET)
public String countSequences(@RequestParam("TypeFeatures") String typeFeature, @RequestParam("Percent") String percent,
Map<String, Object> model) {
Map<String, String> r = cr.readProteinsPrediction(typeFeature, realpercent);
model.put("results", r);
model.put("njobs", 0);
- String csvline = "";
+ StringBuilder csvline = new StringBuilder("");
if (null != r) {
model.put("njobs", r.size());
- csvline = "\'Prediction%20number\',\'Protein%20Sequence\', \'Secondary%20Structure%20Prediction\'%0A";
- }
+ csvline.append("\'Prediction%20number\',\'Protein%20Sequence\', \'Secondary%20Structure%20Prediction\'%0A");
- // form line for CSV file
- int counter = 1;
- for (Map.Entry<String, String> entry : r.entrySet()) {
- csvline += "\'" + counter + "\',\'" + entry.getKey() + "\',\'" + entry.getValue() + "\'%0A";
- ++counter;
+ // form line for CSV file
+ int counter = 1;
+ for (Map.Entry<String, String> entry : r.entrySet()) {
+ csvline.append("\'" + counter + "\',\'" + entry.getKey() + "\',\'" + entry.getValue() + "\'%0A");
+ ++counter;
+ }
}
- model.put("csvfile", csvline);
+ model.put("csvfile", csvline.toString());
final long endTime = System.currentTimeMillis();
model.put("timeExecution", (endTime - startTime));
import compbio.cassandra.readers.SequenceReader;
/**
- * Spring controller for sequence queries. This version works in the servlet
- * style.
+ * Spring controller for supporting sequence queries. This version works in the
+ * servlet style.
*
* @author Alexander Sherstnev
* @author Natasha Sherstneva
model.put("njobs", 0);
model.put("prot", trimmedsequence);
model.put("searchtype", searchtype);
- String csvline = "";
+ StringBuilder csvline = new StringBuilder("");
if (0 < trimmedsequence.length()) {
SequenceReader reader = new SequenceReader();
List<ProteinBean> result = reader.readProteins(trimmedsequence, searchtype);
model.put("results", result);
if (null != result) {
- if (searchtype.equals("whole"))
+ if (searchtype.equals("whole")) {
model.put("njobs", result.get(0).getJobid().size());
- else
+ } else {
model.put("njobs", result.size());
- csvline = "\'Job\',\'Annotation\',\'Sequence\'%0A";
- // form CSV file string
+ }
+ csvline.append("\'Job\',\'Annotation\',\'Sequence\'%0A");
for (ProteinBean entry : result) {
List<String> jobs = entry.getJobid();
String protein = entry.getSequence();
LinkedHashMap<String, String> predictions = entry.getPredictions();
+ StringBuilder jobline = new StringBuilder();
+ for (Map.Entry<String, String> pr : predictions.entrySet()) {
+ jobline.append("\'\',\'" + pr.getKey() + "\',\'" + pr.getValue() + "\'%0A");
+ }
for (String job : jobs) {
- csvline += "\'" + job + "\',\'Sequence\',\'" + protein + "\',\'%0A";
- for (Map.Entry<String, String> pr : predictions.entrySet()) {
- csvline += "\'\',\'" + pr.getKey() + "\',\'" + pr.getValue() + "\'%0A";
- }
+ csvline.append("\'" + job + "\',\'Sequence\',\'" + protein + "\',\'%0A" + jobline.toString());
}
}
}
}
- model.put("csvfile", csvline);
+ model.put("csvfile", csvline.toString());
final long endTime = System.currentTimeMillis();
model.put("timeExecution", (endTime - startTime));
List<TotalByCounterBean> r = reader.readProteinByCounter(realcounter);
model.put("results", r);
model.put("njobs", 0);
- String csvline = "";
+ StringBuilder csvline = new StringBuilder("");
if (null != r) {
model.put("njobs", r.size());
- csvline = "\'Job%20 count\', \'Protein%20Sequence\'%0A";
- }
- // form line for CSV file
-
- for (TotalByCounterBean b : r) {
- if (b.getName().equals("")) {
- csvline += "\'" + b.getTotaljobs() + "\',\'Alignment%20job\'%0A";
- // fix problem with records without protein sequence (alignment
- // jobs)
- b.setName("Alignment job");
- } else {
- csvline += "\'" + b.getTotaljobs() + "\',\'" + b.getName() + "\'%0A";
+ // form line for CSV file
+ csvline.append("\'Job%20 count\', \'Protein%20Sequence\'%0A");
+ for (TotalByCounterBean b : r) {
+ if (b.getName().equals("")) {
+ // fix problem with records without protein sequence
+ // (alignment jobs)
+ csvline.append("\'" + b.getTotaljobs() + "\',\'Alignment%20job\'%0A");
+ b.setName("Alignment job");
+ } else {
+ csvline.append("\'" + b.getTotaljobs() + "\',\'" + b.getName() + "\'%0A");
+ }
}
}
- model.put("csvfile", csvline);
+ model.put("csvfile", csvline.toString());
model.put("results", r);
final long endTime = System.currentTimeMillis();
<%@ 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"%>
-<%@page import="java.util.ArrayList"%>
+<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags"%>
<html>
<jsp:include page="../fragments/header.jsp" />
</div>
<div class="panel-body">
+<sec:authorize access="hasRole('ROLE_ADMIN')">
+ <p>Servlet execution time: ${timeExecution} milliseconds</p>
+</sec:authorize>
<c:choose>
<c:when test="${njobs == 0}">
<p>No proteins with feature ${feature} more then ${percent}% of the protein sequence found</p>
<%@ 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"%>
-<%@page import="java.util.ArrayList"%>
+<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags"%>
<html>
<jsp:include page="../fragments/header.jsp" />
</div>
<div class="panel-body">
+<sec:authorize access="hasRole('ROLE_ADMIN')">
+ <p>Servlet execution time: ${timeExecution} milliseconds</p>
+</sec:authorize>
<c:choose>
<c:when test="${njobs == 0}">
<p>No jobs found</p>
<c:forEach items="${results}" var="res" varStatus="status">
<c:forEach items="${res.jobid}" var="id" varStatus="status">
<tr>
- <th rowspan="${res.size + 2}"><a
+ <th rowspan="3"><a
title="Click to view the job log"
href="${job_query}?IdJob=${id}">${id}</a></th>
</tr>
<tr>
<td style="text-align: center; font-weight: bold; font-family: monospace">Sequence</td>
<c:if test="${searchtype == 'whole'}">
- <td
- style="text-align: left; border-buttom: dotted; font-family: monospace"><c:out
- value="${res.sequence}" /></td>
+ <td style="text-align: left; font-family: monospace">
+ ${res.sequence}</td>
</c:if>
<c:if test="${searchtype == 'partial'}">
- <td
- style="text-align: left; border-buttom: dotted; font-family: monospace">
+ <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="background-color: blue">${seq}</span></c:when>
- <c:otherwise>${seq}</c:otherwise>
+ <c:when test="${fn:contains(seq, prot)}">
+ <span style="background-color: blue">${seq}</span></c:when>
+ <c:otherwise>${seq}</c:otherwise>
</c:choose>
</c:forEach>
</td>
</c:if>
</tr>
- <c:forEach items="${res.predictions}" var="seq"
- varStatus="status">
- <tr>
- <td
- style="text-align: center; font-weight: bold; font-family: monospace"><c:out
- value="${seq.key}" /></td>
- <td
- style="text-align: left; border-buttom: dotted; font-family: monospace"><c:out
- value="${seq.value}" /></td>
- </tr>
- </c:forEach>
+ <tr>
+ <td style="text-align: center; font-weight: bold; font-family: monospace">
+ Jnetpred
+ </td>
+ <td style="text-align: left; border-buttom: dotted; font-family: monospace">
+ ${res.jnetpred}
+ </td>
+ </tr>
</c:forEach>
</c:forEach>
</tbody>
<%@ 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 prefix="sec" uri="http://www.springframework.org/security/tags"%>
<html>
<jsp:include page="../fragments/header.jsp" />
</div>
<div class="panel-body">
+<sec:authorize access="hasRole('ROLE_ADMIN')">
+ <p>Servlet execution time: ${timeExecution} milliseconds</p>
+</sec:authorize>
<c:choose>
<c:when test="${njobs == 0}">
<p>No proteins with at least ${counter} jobs found</p>