create ProteinBean
authorNatasha Sherstneva <n.shertneva@gmail.com>
Tue, 3 Dec 2013 11:39:07 +0000 (11:39 +0000)
committerNatasha Sherstneva <n.shertneva@gmail.com>
Tue, 3 Dec 2013 11:39:07 +0000 (11:39 +0000)
datadb/compbio/cassandra/AnnotatedProteinSequenceBean.java [deleted file]
datadb/compbio/cassandra/CassandraReader.java
datadb/compbio/cassandra/DataBase.java
datadb/compbio/cassandra/PredictionIndex.java [new file with mode: 0644]
datadb/compbio/cassandra/ProteinBean.java [new file with mode: 0644]
server/compbio/controllers/SequenceController.java
server/compbio/listeners/ServletSequenceProtein.java
server/compbio/statistic/CassandraRequester.java
webapp/view/reportProteinSequences.jsp

diff --git a/datadb/compbio/cassandra/AnnotatedProteinSequenceBean.java b/datadb/compbio/cassandra/AnnotatedProteinSequenceBean.java
deleted file mode 100644 (file)
index 9289407..0000000
+++ /dev/null
@@ -1,39 +0,0 @@
-package compbio.cassandra;
-
-import java.util.Map;
-
-public class AnnotatedProteinSequenceBean {
-       private String sequence;
-       private String jobid;
-       private Map<String,String> predictions;
-       private int size;
-       
-       public AnnotatedProteinSequenceBean (String seq, String id, Map<String,String> pred) {
-               this.sequence = seq;
-               this.jobid = id;
-               this.predictions = pred;
-               this.size = pred.size();
-       }
-       
-       public String getSequence () {
-               return sequence;
-       }
-       
-       public String getJobid () {
-               return jobid;
-       }
-
-       public int getmapsize () {
-               return size;
-       }
-       
-       public Map<String,String> getPredictions () {
-               return predictions;
-       }
-
-       public void setPredictions (Map<String,String> predictions) {
-               this.predictions = predictions;
-               this.size = predictions.size();
-       }
-
-}
index e75f148..9ac0a3b 100644 (file)
@@ -98,7 +98,7 @@ public class CassandraReader {
        /*
         * getting whole protein sequence from the db ProteinRow
         */
-       public List<AnnotatedProteinSequenceBean> ReadWholeSequence(String queryProtein) {
+       public List<ProteinBean> ReadWholeSequence(String queryProtein) {
                final long startTime = System.currentTimeMillis();
                String com = "SELECT JobID, Predictions FROM ProteinRow WHERE Protein = '" + queryProtein + "';";
                System.out.println("Command: " + com);
@@ -107,16 +107,19 @@ public class CassandraReader {
                        return null;
                final long queryTime = System.currentTimeMillis();
                List<Row> rows = results.all();
+               System.out.println("first size : " + rows.size());
                System.out.println("Query time is " + (queryTime - startTime) + " msec");
                System.out.println(" rows analysed,  " + rows.size());
-               List<AnnotatedProteinSequenceBean> res = new ArrayList<AnnotatedProteinSequenceBean>();
+               List<ProteinBean> res = new ArrayList<ProteinBean>();
+               ProteinBean structure = new ProteinBean(queryProtein, rows.get(0).getMap(
+                               "Predictions", String.class, String.class));
+               System.out.println("second size : " + rows.size());
                int c = 0;
                for (Row r : rows) {
-                       AnnotatedProteinSequenceBean structure = new AnnotatedProteinSequenceBean(queryProtein, r.getString("JobID"), r.getMap(
-                                       "Predictions", String.class, String.class));
-                       res.add(structure);
+                       structure.setJobid(r.getString("JobID"));                       
                        ++c;
                }
+               res.add(structure);
                final long endTime = System.currentTimeMillis();
                System.out.println(c + " rows analysed, execution time is " + (endTime - startTime) + " msec");
                return res;
@@ -156,7 +159,7 @@ public class CassandraReader {
        /*
         * getting part of protein sequence from the db ProteinRow
         */
-       public List<AnnotatedProteinSequenceBean> ReadPartOfSequence(String queryProtein) {
+       public List<ProteinBean> ReadPartOfSequence(String queryProtein) {
                final long startTime = System.currentTimeMillis();
                String com = "SELECT * FROM ProteinRow;";
                System.out.println("Command: " + com);
@@ -167,13 +170,13 @@ public class CassandraReader {
                List<Row> rows = results.all();
                System.out.println("Query time is " + (queryTime - startTime) + " msec");
                System.out.println(" rows analysed,  " + rows.size());
-               List<AnnotatedProteinSequenceBean> res = new ArrayList<AnnotatedProteinSequenceBean>();
+               List<ProteinBean> res = new ArrayList<ProteinBean>();
                int c = 0;
                for (Row r : rows) {
                        String prot = r.getString("Protein");
                        if (prot.matches("(.*)" + queryProtein + "(.*)")) {
-                               AnnotatedProteinSequenceBean structure = new AnnotatedProteinSequenceBean(prot, r.getString("JobID"), r.getMap("Predictions",
-                                               String.class, String.class));
+                               ProteinBean structure = new ProteinBean(prot,  r.getMap("Predictions", String.class, String.class));
+                               structure.setJobid(r.getString("JobID"));
                                res.add(structure);
                                ++c;
                        }
index 2f10eef..ab21e43 100644 (file)
@@ -17,11 +17,10 @@ public class DataBase {
        private String ip;
        private String prot;                            // protein sequence
        private String jpred;
-       private List<String> subProt;           // protein sequence divided by several parts for highlighting the particular part
        private List<Integer> timeRez;
        private List<Integer> timeTotalExec;
        private StructureJobLog logInfo;
-       private AnnotatedProteinSequenceBean predictions;
+       private ProteinBean predictions;
 
        public DataBase() {
        }
@@ -129,14 +128,6 @@ public class DataBase {
                return ip;
        }
 
-       public void setSubProt(List<String> subProt) {
-               this.subProt = subProt;
-       }
-
-       public List<String> getSubProt() {
-               return subProt;
-       }
-
        public void setTimeRez(List<Integer> timeRez) {
                this.timeRez = timeRez;
        }
@@ -161,11 +152,11 @@ public class DataBase {
                return logInfo;
        }
        
-       public void setPredictions(AnnotatedProteinSequenceBean predictions){
+       public void setPredictions(ProteinBean predictions){
                this.predictions = predictions;
        }
        
-       public AnnotatedProteinSequenceBean getPredictions() {
+       public ProteinBean getPredictions() {
                return predictions;
        }
 
diff --git a/datadb/compbio/cassandra/PredictionIndex.java b/datadb/compbio/cassandra/PredictionIndex.java
new file mode 100644 (file)
index 0000000..d184650
--- /dev/null
@@ -0,0 +1,10 @@
+package compbio.cassandra;
+
+public interface PredictionIndex {
+
+       /**
+        * Ordering indexes for predictions
+        */
+       public final String[] predIndex =  {"jnetpred", "JNETCONF", "JNETHMM", "JNETPSSM", "JNETSOL0", "JNETSOL5",
+                       "JNETSOL25", "Lupas_14", "Lupas_21", "Lupas_28"};
+}
diff --git a/datadb/compbio/cassandra/ProteinBean.java b/datadb/compbio/cassandra/ProteinBean.java
new file mode 100644 (file)
index 0000000..d2b7cb7
--- /dev/null
@@ -0,0 +1,57 @@
+package compbio.cassandra;
+
+import java.util.ArrayList;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+
+public class ProteinBean implements PredictionIndex{
+       private String sequence;
+       private List<String> jobid;
+       private LinkedHashMap<String,String> predictions;
+       private List<String> subProt;           // protein sequence divided by several parts for highlighting the particular part
+       private int size;
+       
+       public ProteinBean (String seq, Map<String,String> pred) {
+               this.sequence = seq;
+               this.predictions = new LinkedHashMap<String,String>();  
+               this.jobid = new ArrayList<String>();
+               setPredictions(pred);
+       }
+       
+       public void setPredictions(Map<String,String> pred) {
+               for (String index : predIndex) {
+                       this.predictions.put(index, pred.get(index));
+               }       
+               this.size = predictions.size();
+       }
+       
+       public String getSequence () {
+               return sequence;
+       }
+       
+       public List<String> getJobid () {
+               return jobid;
+       }
+       
+       public void setJobid (String id) {
+               this.jobid.add(id);
+       }
+
+       public int getSize () {
+               return size;
+       }
+       
+       public LinkedHashMap<String,String> getPredictions () {
+               return predictions;
+       }
+       
+       public void setSubProt(List<String> subProt) {
+               this.subProt = subProt;
+       }
+
+       public List<String> getSubProt() {
+               return subProt;
+       }
+
+}
index d4afbdc..b73a172 100644 (file)
@@ -8,8 +8,8 @@ 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.DataBase;
-
 import compbio.statistic.CassandraRequester;
 
 /**
@@ -42,11 +42,13 @@ public class SequenceController {
 
                if (0 < trimmedsequence.length()) {
                        CassandraRequester cr = new CassandraRequester();
-                       List<DataBase> r = cr.readProteins(trimmedsequence, flag);
+                       List<ProteinBean> r = cr.readProteins(trimmedsequence, flag);
                        model.put("results", r);
                        if (null != r) {
-                               System.out.println("result size = " + r.size());
-                               model.put("njobs", r.size());
+                               if (flag.equals("whole"))
+                                       model.put("njobs",r.get(0).getJobid().size());
+                               else
+                                       model.put("njobs", r.size());
                        }
                }
                final long endTime = System.currentTimeMillis();
index 84af1b8..5515566 100644 (file)
@@ -37,8 +37,8 @@ public class ServletSequenceProtein extends HttpServlet {
                        request.setAttribute("results", r);
        //              System.out.println ("Search counter: " + r.size() + " proteins found");
                } else {
-                       List<DataBase> r = cr.readProteins(prot, flag);
-                       request.setAttribute("results", r);
+               //      List<DataBase> r = cr.readProteins(prot, flag);
+               //      request.setAttribute("results", r);
                //      System.out.println ("Search sequence: " + r.size() + " proteins found");
                }
                final long endTime = System.currentTimeMillis();
index f4c4c18..c92b9bf 100755 (executable)
@@ -9,7 +9,7 @@ import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 
-import compbio.cassandra.AnnotatedProteinSequenceBean;
+import compbio.cassandra.ProteinBean;
 import compbio.cassandra.CassandraNativeConnector;
 import compbio.cassandra.CassandraReader;
 import compbio.cassandra.DataBase;
@@ -195,26 +195,21 @@ public class CassandraRequester {
        /* 
         * query: protein sequence
         * */
-       public List<DataBase> readProteins(String protIn, String flag) {
-               query = new ArrayList<DataBase>();
-               List<AnnotatedProteinSequenceBean> res;
+       public List<ProteinBean> readProteins(String protIn, String flag) {
+               List<ProteinBean> result;
                if (flag.equals("whole")) 
-                       res = db.ReadWholeSequence(protIn);
+                       result = db.ReadWholeSequence(protIn);
                 else 
-                       res = db.ReadPartOfSequence(protIn);
-               if (res == null)
+                        result = db.ReadPartOfSequence(protIn);
+               if (result == null)
                        return null;
-               for (AnnotatedProteinSequenceBean entry : res) {
-                       DataBase db = new DataBase();
-                       db.setProt(entry.getSequence());
-                       db.setPredictions(entry);
-                       db.setId(entry.getJobid());
-                       if (flag.equals("part")) {
-                               db.setSubProt(CreateSubprot (entry.getSequence(), protIn));
+               
+               if (flag.equals("part")) {
+                       for (ProteinBean entry : result) {
+                               entry.setSubProt(CreateSubprot(entry.getSequence(), protIn));
                        }
-                       query.add(db);
-               }
-               return query;
+               }                                       
+               return result;
        }
        
 
index 8bc1213..db6837b 100644 (file)
                                                </thead>
                                                <tbody>
                                                        <c:forEach items="${results}" var="res" varStatus="status">
-                                                               <c:set var="ann" value="${res.predictions}" />
+                                                               <c:forEach items="${res.jobid}" var="id" varStatus="status">
                                                                <tr>
-                                                                       <th rowspan="${ann.mapsize + 2}"><a
+                                                                       <th rowspan="${res.size + 2}"><a
                                                                                title="Click to view the job log"
-                                                                               href="${jobquery}?IdJob=${res.id}">${res.id}</a></th>
+                                                                               href="${jobquery}?IdJob=${id}">${id}</a></th>
                                                                </tr>
                                                                <tr>
                                                                        <td
@@ -62,7 +62,7 @@
                                                                        <c:if test="${flag == 'whole'}">
                                                                                <td
                                                                                        style="text-align: left; border-buttom: dotted; font-family: monospace"><c:out
-                                                                                               value="${res.prot}" /></td>
+                                                                                               value="${res.sequence}" /></td>
                                                                        </c:if>
                                                                        <c:if test="${flag == 'part'}">
                                                                                <td
@@ -77,7 +77,7 @@
                                                                                </td>
                                                                        </c:if>
                                                                </tr>
-                                                               <c:forEach items="${ann.predictions}" var="seq"
+                                                               <c:forEach items="${res.predictions}" var="seq"
                                                                        varStatus="status">
                                                                        <tr>
                                                                                <td
@@ -89,6 +89,7 @@
                                                                        </tr>
                                                                </c:forEach>
                                                        </c:forEach>
+                                                       </c:forEach>
                                                </tbody>
                                        </table>
                                </div>