From: Natasha Sherstneva Date: Tue, 3 Dec 2013 11:39:07 +0000 (+0000) Subject: create ProteinBean X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=7f749bf97bd6232116c2fed86fb3aa5767f8e1ba;p=proteocache.git create ProteinBean --- diff --git a/datadb/compbio/cassandra/AnnotatedProteinSequenceBean.java b/datadb/compbio/cassandra/AnnotatedProteinSequenceBean.java deleted file mode 100644 index 9289407..0000000 --- a/datadb/compbio/cassandra/AnnotatedProteinSequenceBean.java +++ /dev/null @@ -1,39 +0,0 @@ -package compbio.cassandra; - -import java.util.Map; - -public class AnnotatedProteinSequenceBean { - private String sequence; - private String jobid; - private Map predictions; - private int size; - - public AnnotatedProteinSequenceBean (String seq, String id, Map 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 getPredictions () { - return predictions; - } - - public void setPredictions (Map predictions) { - this.predictions = predictions; - this.size = predictions.size(); - } - -} diff --git a/datadb/compbio/cassandra/CassandraReader.java b/datadb/compbio/cassandra/CassandraReader.java index e75f148..9ac0a3b 100644 --- a/datadb/compbio/cassandra/CassandraReader.java +++ b/datadb/compbio/cassandra/CassandraReader.java @@ -98,7 +98,7 @@ public class CassandraReader { /* * getting whole protein sequence from the db ProteinRow */ - public List ReadWholeSequence(String queryProtein) { + public List 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 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 res = new ArrayList(); + List res = new ArrayList(); + 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 ReadPartOfSequence(String queryProtein) { + public List 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 rows = results.all(); System.out.println("Query time is " + (queryTime - startTime) + " msec"); System.out.println(" rows analysed, " + rows.size()); - List res = new ArrayList(); + List res = new ArrayList(); 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; } diff --git a/datadb/compbio/cassandra/DataBase.java b/datadb/compbio/cassandra/DataBase.java index 2f10eef..ab21e43 100644 --- a/datadb/compbio/cassandra/DataBase.java +++ b/datadb/compbio/cassandra/DataBase.java @@ -17,11 +17,10 @@ public class DataBase { private String ip; private String prot; // protein sequence private String jpred; - private List subProt; // protein sequence divided by several parts for highlighting the particular part private List timeRez; private List 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 subProt) { - this.subProt = subProt; - } - - public List getSubProt() { - return subProt; - } - public void setTimeRez(List 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 index 0000000..d184650 --- /dev/null +++ b/datadb/compbio/cassandra/PredictionIndex.java @@ -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 index 0000000..d2b7cb7 --- /dev/null +++ b/datadb/compbio/cassandra/ProteinBean.java @@ -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 jobid; + private LinkedHashMap predictions; + private List subProt; // protein sequence divided by several parts for highlighting the particular part + private int size; + + public ProteinBean (String seq, Map pred) { + this.sequence = seq; + this.predictions = new LinkedHashMap(); + this.jobid = new ArrayList(); + setPredictions(pred); + } + + public void setPredictions(Map pred) { + for (String index : predIndex) { + this.predictions.put(index, pred.get(index)); + } + this.size = predictions.size(); + } + + public String getSequence () { + return sequence; + } + + public List getJobid () { + return jobid; + } + + public void setJobid (String id) { + this.jobid.add(id); + } + + public int getSize () { + return size; + } + + public LinkedHashMap getPredictions () { + return predictions; + } + + public void setSubProt(List subProt) { + this.subProt = subProt; + } + + public List getSubProt() { + return subProt; + } + +} diff --git a/server/compbio/controllers/SequenceController.java b/server/compbio/controllers/SequenceController.java index d4afbdc..b73a172 100644 --- a/server/compbio/controllers/SequenceController.java +++ b/server/compbio/controllers/SequenceController.java @@ -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 r = cr.readProteins(trimmedsequence, flag); + List 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(); diff --git a/server/compbio/listeners/ServletSequenceProtein.java b/server/compbio/listeners/ServletSequenceProtein.java index 84af1b8..5515566 100644 --- a/server/compbio/listeners/ServletSequenceProtein.java +++ b/server/compbio/listeners/ServletSequenceProtein.java @@ -37,8 +37,8 @@ public class ServletSequenceProtein extends HttpServlet { request.setAttribute("results", r); // System.out.println ("Search counter: " + r.size() + " proteins found"); } else { - List r = cr.readProteins(prot, flag); - request.setAttribute("results", r); + // List r = cr.readProteins(prot, flag); + // request.setAttribute("results", r); // System.out.println ("Search sequence: " + r.size() + " proteins found"); } final long endTime = System.currentTimeMillis(); diff --git a/server/compbio/statistic/CassandraRequester.java b/server/compbio/statistic/CassandraRequester.java index f4c4c18..c92b9bf 100755 --- a/server/compbio/statistic/CassandraRequester.java +++ b/server/compbio/statistic/CassandraRequester.java @@ -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 readProteins(String protIn, String flag) { - query = new ArrayList(); - List res; + public List readProteins(String protIn, String flag) { + List 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; } diff --git a/webapp/view/reportProteinSequences.jsp b/webapp/view/reportProteinSequences.jsp index 8bc1213..db6837b 100644 --- a/webapp/view/reportProteinSequences.jsp +++ b/webapp/view/reportProteinSequences.jsp @@ -49,11 +49,11 @@ - + - ${res.id} + href="${jobquery}?IdJob=${id}">${id} + value="${res.sequence}" /> - +