From c15dbff6d660ba14d41407bebeceda4414f45068 Mon Sep 17 00:00:00 2001 From: Natasha Sherstneva Date: Mon, 16 Dec 2013 09:37:19 +0000 Subject: [PATCH] created features report --- conf/Proteocache.properties | 2 +- datadb/compbio/cassandra/CassandraReader.java | 35 ++++++++ datadb/compbio/cassandra/ProteinBean.java | 16 ++++ .../compbio/controllers/SSFeaturesController.java | 86 ++++++++++++++++++++ server/compbio/statistic/CassandraRequester.java | 19 +++++ webapp/view/fragments/mainmenu.jsp | 1 + webapp/view/query/SSFeatures.jsp | 56 +++++++++++++ webapp/view/reportSSFeatures.jsp | 62 ++++++++++++++ 8 files changed, 276 insertions(+), 1 deletion(-) create mode 100644 server/compbio/controllers/SSFeaturesController.java create mode 100644 webapp/view/query/SSFeatures.jsp create mode 100644 webapp/view/reportSSFeatures.jsp diff --git a/conf/Proteocache.properties b/conf/Proteocache.properties index b1730f4..8851680 100644 --- a/conf/Proteocache.properties +++ b/conf/Proteocache.properties @@ -9,7 +9,7 @@ cassandra.newtables.update=false ################################################################################# # Jpred sources # real Jpred web-server -cassandra.jpred.web.update=true +cassandra.jpred.web.update=false cassandra.jpred.web.inidelay=0 cassandra.jpred.web.updaterate=30 diff --git a/datadb/compbio/cassandra/CassandraReader.java b/datadb/compbio/cassandra/CassandraReader.java index 00a9f27..1720c48 100644 --- a/datadb/compbio/cassandra/CassandraReader.java +++ b/datadb/compbio/cassandra/CassandraReader.java @@ -11,6 +11,7 @@ import org.apache.log4j.Logger; import com.datastax.driver.core.Row; import com.datastax.driver.core.Session; import com.datastax.driver.core.ResultSet; + import compbio.engine.JobStatus; public class CassandraReader { @@ -198,6 +199,40 @@ public class CassandraReader { } /* + * getting protein sequence from the db ProteinRow + */ + public Map ReadProtein() { + final long startTime = System.currentTimeMillis(); + String com = "SELECT * FROM ProteinRow;"; + System.out.println("Command: " + com); + ResultSet results = session.execute(com); + if (results.isExhausted()) + return null; + final long queryTime = System.currentTimeMillis(); + List rows = results.all(); + System.out.println("Query time is " + (queryTime - startTime) + " msec"); + System.out.println(" rows analysed, " + rows.size()); + Map res = new HashMap(); + int c = 0; + for (Row r : rows) { + String prot = r.getString("Protein"); + String prediction = findJnetpred(r.getMap("Predictions", String.class, String.class)); + if (prot != null || prediction != null) + res.put(prot, prediction); + } + final long endTime = System.currentTimeMillis(); + System.out.println(c + " rows analysed, execution time is " + (endTime - startTime) + " msec"); + return res; + } + + private String findJnetpred (Map pred) { + if (pred != null) { + if (pred.containsKey("jnetpred")) + return pred.get("jnetpred"); + } + return null; + } + /* * getting protein sequences by counter */ public Map ReadProteinSequenceByCounter() { diff --git a/datadb/compbio/cassandra/ProteinBean.java b/datadb/compbio/cassandra/ProteinBean.java index 80f111b..d5e700b 100644 --- a/datadb/compbio/cassandra/ProteinBean.java +++ b/datadb/compbio/cassandra/ProteinBean.java @@ -7,6 +7,7 @@ import java.util.Map; public class ProteinBean implements PredictionIndex{ private String sequence; + private String jnetpred; private List jobid; private LinkedHashMap predictions; private List subProt; // protein sequence divided by several parts for highlighting the particular part @@ -19,6 +20,10 @@ public class ProteinBean implements PredictionIndex{ setPredictions(pred); } + public void setSequence (String seq) { + this.sequence = seq; + } + public void setPredictions(Map pred) { if (predictions == null) predictions = new LinkedHashMap(); @@ -32,6 +37,17 @@ public class ProteinBean implements PredictionIndex{ return sequence; } + public String getJnetpred () { + return jnetpred; + } + + public void setJnetpred (Map pred) { + if (pred != null) { + if (pred.containsKey("jnetpred")) + jnetpred = pred.get("jnetpred"); + } + } + public List getJobid () { return jobid; } diff --git a/server/compbio/controllers/SSFeaturesController.java b/server/compbio/controllers/SSFeaturesController.java new file mode 100644 index 0000000..27015bb --- /dev/null +++ b/server/compbio/controllers/SSFeaturesController.java @@ -0,0 +1,86 @@ +package compbio.controllers; + +import java.util.List; +import java.util.Map; + +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RequestParam; + +import compbio.cassandra.ProteinBean; +import compbio.cassandra.TotalByCounterBean; +import compbio.statistic.CassandraRequester; + +/** + * Spring controller for sequence queries. This version works in the servlet + * style. + * + * @author Alexander Sherstnev + * @author Natasha Sherstneva + * + * @since 0.5 + * @version 1.0 December 2013 + */ +@Controller +@RequestMapping("/features") +public class SSFeaturesController extends BasicController { + + @RequestMapping(value = "query", method = RequestMethod.GET) + public String formCounterQuery(Map model) { + model.put("username", getPrincipalName()); + model.put("type", 'E'); + model.put("value", 80); + return "query/SSFeatures"; + } + + @RequestMapping(value = "features/results", method = RequestMethod.GET) + public String countSequences(@RequestParam("TypeFeatures") String typeFeature, @RequestParam("Percent") String percent,Map model) { + model.put("username", getPrincipalName()); + final long startTime = System.currentTimeMillis(); + + if (percent.equals("")) { + model.put("error", "The value must not be empty"); + model.put("type", typeFeature); + model.put("value", percent); + return "query/SSFeatures"; + } + + int realpercent; + try { + realpercent = Integer.parseInt(percent.trim()); + } catch (NumberFormatException e) { + model.put("error", "The value must be an integer number"); + model.put("value", percent); + return "query/SSFeatures"; + } + + if (realpercent < 1) { + model.put("error", "The value must be greater than 0"); + model.put("value", percent); + return "query/SSFeatures"; + } + + if (realpercent > 100) { + model.put("error", "The value must be less than 100"); + model.put("value", percent); + return "query/SSFeatures"; + } + + CassandraRequester cr = new CassandraRequester(); + Map r = cr.readProteinsPrediction(typeFeature, realpercent); + model.put("results", r); + model.put("njobs", 0); + if (null != r) { + model.put("njobs", r.size()); + } + final long endTime = System.currentTimeMillis(); + model.put("timeExecution", (endTime - startTime)); + model.put("feature", typeFeature); + model.put("percent", realpercent); + return "reportSSFeatures"; + } + + + +} diff --git a/server/compbio/statistic/CassandraRequester.java b/server/compbio/statistic/CassandraRequester.java index 1bb0050..f2336e7 100755 --- a/server/compbio/statistic/CassandraRequester.java +++ b/server/compbio/statistic/CassandraRequester.java @@ -5,6 +5,7 @@ import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Calendar; import java.util.Date; +import java.util.HashMap; import java.util.List; import java.util.Map; @@ -200,6 +201,24 @@ public class CassandraRequester { } return result; } + + /* + * query: protein feature + */ + public Map readProteinsPrediction(String feature, int percent) { + Map result = db.ReadProtein();; + if (result == null) + return null; + Map query = new HashMap(); + for (Map.Entry entry : result.entrySet()) { + String pred = entry.getValue(); + if (pred.replaceAll("[^"+feature+"]", "").length() > pred.length() * percent / 100 && (!entry.getKey().equals(""))) { + // if (!entry.getKey().equals("")) + query.put(entry.getKey(), pred); + } + } + return query; + } /* * query protein sequences with number of jobs diff --git a/webapp/view/fragments/mainmenu.jsp b/webapp/view/fragments/mainmenu.jsp index f310fbf..8f8e403 100644 --- a/webapp/view/fragments/mainmenu.jsp +++ b/webapp/view/fragments/mainmenu.jsp @@ -24,6 +24,7 @@
  • ">Job Time Execution
  • ">IPs by Job count
  • ">Proteins by Job count
  • +
  • ">Proteins by SS Features
  • diff --git a/webapp/view/query/SSFeatures.jsp b/webapp/view/query/SSFeatures.jsp new file mode 100644 index 0000000..59cdc1c --- /dev/null +++ b/webapp/view/query/SSFeatures.jsp @@ -0,0 +1,56 @@ + + +<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%> +<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> +<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%> +<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %> +<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %> + + + + +
    + + + +
    +
    +
    Proteins with features
    +
    +
    +
    +
    + + +
    + + + + +
    +
    + +
    + + + + +

    ${error}

    +
    +
    +
    + +
    +
    +
    +
    + +
    + + diff --git a/webapp/view/reportSSFeatures.jsp b/webapp/view/reportSSFeatures.jsp new file mode 100644 index 0000000..2d885f7 --- /dev/null +++ b/webapp/view/reportSSFeatures.jsp @@ -0,0 +1,62 @@ +<%@ page language="java" contentType="text/html; charset=UTF-8" + pageEncoding="UTF-8"%> + + +<%@ taglib uri="http://www.springframework.org/tags" prefix="spring"%> +<%@ 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"%> + + + + +
    + + + +
    +
    +
    Jobs Statistics
    +
    +
    + + + +

    No proteins with features ${feature} more then ${percent} % found

    +
    + +

    ${njobs} proteins with features ${feature} more then ${percent} % found

    +
    + + + + + + + + + + + + + + + + + + + +
    NProtein/Prediction
    ${count} + + ${res.key}
    ${res.value}
    +
    +
    +
    +
    +
    + + +
    + + \ No newline at end of file -- 1.7.10.2