#################################################################################
# Jpred sources
# real Jpred web-server
-cassandra.jpred.web.update=false
+cassandra.jpred.web.update=true
cassandra.jpred.web.inidelay=0
cassandra.jpred.web.updaterate=30
-package compbio.cassandra;
+package compbio.beans;
import java.util.HashMap;
import java.util.LinkedHashMap;
-package compbio.cassandra;
+package compbio.beans;
import java.util.LinkedHashMap;
import java.util.Map;
+import compbio.cassandra.PredictionIndex;
+
public class JobBean implements PredictionIndex {
private String jobid;
private String dateStart;
-package compbio.cassandra;
+package compbio.beans;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
+import compbio.cassandra.PredictionIndex;
+
public class ProteinBean implements PredictionIndex{
private String sequence;
private String jnetpred;
-package compbio.cassandra;
+package compbio.beans;
+/**
+ * bean is stored Total for a TotalJobsStatisticBean.
+ *
+ * @param total
+ * total number of jobs for a day
+ * @param totalOK
+ * number of jobs with execution status OK for a date
+ * @param totalStopped
+ * number of jobs with execution status STOPPED for a date
+ * @param totalError
+ * number of jobs with execution status Jpred ERROR for a date
+ * @param totalTimeOut
+ * number of jobs with execution status TIMEDOUT for a date
+ */
public class Total {
- private long total; // total number of jobs
- private long totalOK; // number of jobs with execution status OK
- private long totalStopped; // number of jobs with execution status STOPPED
- private long totalError; // number of jobs with execution status Jpred ERROR
- private long totalTimeOut; // number of jobs with execution status TIMEOUT
-
- public Total() {}
-
+ private long total;
+ private long totalOK;
+ private long totalStopped;
+ private long totalError;
+ private long totalTimeOut;
+
public Total(long total, long totalOK, long totalStopped, long totalError, long totalTimeOut) {
this.total = total;
this.totalOK = totalOK;
-package compbio.cassandra;
+package compbio.beans;
public class TotalByCounterBean {
private int totaljobs; // total jobs for current condition
-package compbio.cassandra;
+package compbio.beans;
import java.util.LinkedHashMap;
-import java.util.List;
import java.util.Map;
-public class TotalJobsStatisticBean extends Total {
+/**
+ * bean for a report of daily statistics.
+ *
+ * @param dateTotal
+ * Map<String, Total> where String - a date, Total - total info for jobs with different status
+ * @param wholeTotal
+ * total sum for each parameter from dateTotal
+ */
+public class TotalJobsStatisticBean {
private Map<String, Total> dateTotal;
private Total wholeTotal;
public TotalJobsStatisticBean() {
- super();
this.dateTotal = new LinkedHashMap<String, Total>();
}
-package compbio.cassandra;
+package compbio.beans;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
+++ /dev/null
-package compbio.cassandra;
-
-import org.apache.log4j.Logger;
-
-import com.datastax.driver.core.ResultSet;
-import com.datastax.driver.core.Session;
-
-public class CassandraReader {
- private static long earlestDate = 0;
- private Session session;
- private static Logger log = Logger.getLogger(CassandraNativeConnector.class);
-
- public CassandraReader() {
- Session inis = CassandraNativeConnector.getSession();
- setSession(inis);
- }
-
- public void setSession(Session s) {
- assert s != null;
- session = s;
- }
-
- public ResultSet CassandraQuery(String column, String table, String condition) {
- String com = "SELECT " + column + " FROM " + table + ";";
- System.out.println("Command: " + com);
- ResultSet results = session.execute(com);
- return results;
- }
-
- /*
- * find the earliest date in the database
- */
- public static long earliestDate() {
- earlestDate = CassandraNativeConnector.getEarliestDateInDB();
- return earlestDate;
- }
-
-
-}
import com.datastax.driver.core.Session;
import com.datastax.driver.core.ResultSet;
+import compbio.beans.DateBean;
+import compbio.beans.JobBean;
+import compbio.beans.ProteinBean;
+import compbio.beans.Total;
import compbio.engine.JobStatus;
public class CassandraReaderOld {
import java.util.ArrayList;
import java.util.Collections;
+import compbio.beans.JobBean;
+import compbio.beans.ProteinBean;
+
public class DataBase {
private String date;
private int total; // total number of jobs
--- /dev/null
+package compbio.cassandra.readers;
+
+import org.apache.log4j.Logger;
+
+import com.datastax.driver.core.ResultSet;
+import com.datastax.driver.core.Session;
+import com.datastax.driver.core.exceptions.QueryExecutionException;
+import com.datastax.driver.core.exceptions.QueryValidationException;
+import compbio.cassandra.CassandraNativeConnector;
+
+public class CassandraReader {
+ private static long earlestDate = 0;
+ private Session session;
+ protected static Logger log = Logger.getLogger(CassandraNativeConnector.class);
+
+ public CassandraReader() {
+ Session inis = CassandraNativeConnector.getSession();
+ setSession(inis);
+ }
+
+ public void setSession(Session s) {
+ assert s != null;
+ session = s;
+ }
+
+ protected ResultSet CassandraQuery(String command) {
+ try {
+ ResultSet results = session.execute(command);
+ return results;
+ } catch (QueryExecutionException e) {
+ String mess = "CassandraUserManagerImpl.findAllUsers: query execution exception...";
+ System.out.println(mess);
+ log.error(mess);
+ log.error(e.getLocalizedMessage(), e.getCause());
+ return null;
+ } catch (QueryValidationException e) {
+ String mess = "CassandraUserManagerImpl.findAllUsers: query validation exception... Command: " + command;
+ System.out.println(mess);
+ log.error(mess);
+ log.error(e.getLocalizedMessage(), e.getCause());
+ return null;
+ }
+
+ }
+
+ /*
+ * find the earliest date in the database
+ */
+ public static long earliestDate() {
+ earlestDate = CassandraNativeConnector.getEarliestDateInDB();
+ return earlestDate;
+ }
+
+
+}
--- /dev/null
+package compbio.cassandra.readers;
+
+import java.util.Calendar;
+import java.util.Date;
+import java.util.List;
+
+import com.datastax.driver.core.ResultSet;
+import com.datastax.driver.core.Row;
+
+import compbio.beans.DateBean;
+import compbio.beans.Total;
+import compbio.beans.TotalJobsStatisticBean;
+import compbio.cassandra.DateFormatter;
+import compbio.engine.JobStatus;
+
+public class DailyStatisticsReader extends CassandraReader {
+
+ public DailyStatisticsReader() {
+ super();
+ }
+
+ /**
+ * query: total number of jobs for the period from date1 till date2
+ *
+ * @param dateStart
+ * the first date in the period
+ * @param dateEnd
+ * the last date in the period
+ *
+ * @return TotalJobsStatisticBean to the controller DailyStatisticsController
+ **/
+ public TotalJobsStatisticBean query(long dateStart, long dateEnd) {
+ Calendar start = Calendar.getInstance();
+ start.setTime(new Date(dateStart));
+ Calendar end = Calendar.getInstance();
+ end.setTime(new Date(dateEnd));
+ TotalJobsStatisticBean query = new TotalJobsStatisticBean();
+ Total wholeTotal = new Total(0, 0, 0, 0, 0);
+ for (Date date = start.getTime(); !start.after(end); start.add(Calendar.DATE, 1), date = start.getTime()) {
+ ResultSet results = CassandraQuery("SELECT * FROM JobDateInfo WHERE jobday = " + date.getTime() + ";");
+ if (results == null)
+ return null;
+ if (results.isExhausted())
+ continue;
+ Row therow = results.one();
+ Total res = new Total(therow.getLong("Total"), therow.getLong("TotalOK"), therow.getLong("TotalStopped"),
+ therow.getLong("TotalError"), therow.getLong("TotalTimeOut"));
+ if (!results.isExhausted()) {
+ Date dat = new Date(date.getTime());
+ log.warn("CassandraReader.ReadDateTable: date row for " + dat.toString() + " (" + date.getTime() + ") duplicated ");
+ }
+ query.setDateTotal(DateFormatter.DateLongToString(date.getTime(), DateFormatter.getFormatDDMMYY()), res);
+ wholeTotal.setTotal(res.getTotal() + wholeTotal.getTotal());
+ wholeTotal.setTotalOK(res.getTotalOK() + wholeTotal.getTotalOK());
+ wholeTotal.setTotalStopped(res.getTotalStopped() + wholeTotal.getTotalStopped());
+ wholeTotal.setTotalError(res.getTotalError() + wholeTotal.getTotalError());
+ wholeTotal.setTotalTimeOut(res.getTotalTimeOut() + wholeTotal.getTotalTimeOut());
+ }
+ query.setWholeTotal(wholeTotal);
+ return query;
+ }
+
+ /**
+ * query: jobs and sequence at a date
+ *
+ * @param day
+ * the date in long format
+ * @param date
+ * the date in String format
+ *
+ * @param status
+ * final job status
+ * @return DateBean to the controller DailyStatisticsController
+ **/
+ public DateBean readJobByDay(long day, String date, JobStatus status) {
+ DateBean res = new DateBean(date);
+ if (status == JobStatus.OK) {
+ ResultSet results = CassandraQuery("SELECT JobID, Protein FROM ProteinData WHERE jobtime = " + day + ";");
+ if (results == null || results.isExhausted())
+ return null;
+ List<Row> rows = results.all();
+ for (Row r : rows) {
+ res.setJobidAndSeq(r.getString("JobID"), r.getString("Protein"));
+ }
+ }
+ else {
+ ResultSet results = CassandraQuery("SELECT JobID FROM FailLog WHERE jobtime = " + day + " and FinalStatus = '" + status.name() + "';");
+ if (results == null || results.isExhausted())
+ return null;
+ List<Row> rows = results.all();
+ for (Row r : rows) {
+ String jobid = r.getString("JobID");
+ ResultSet results2 = CassandraQuery("SELECT Protein FROM ProteinLog WHERE JobID = '" + jobid + "';");
+ if (results2 == null || results2.isExhausted())
+ return null;
+ List<Row> jrows = results2.all();
+ if (1 == jrows.size()) {
+ String protein = jrows.get(0).getString("Protein");
+ res.setJobidAndSeq(jobid, protein);
+ }
+ }
+ }
+ return res;
+ }
+
+}
--- /dev/null
+package compbio.cassandra.readers;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import com.datastax.driver.core.ResultSet;
+import com.datastax.driver.core.Row;
+
+import compbio.beans.UserBean;
+
+public class IpReader extends CassandraReader {
+
+ public IpReader() {
+ super();
+ }
+
+ /**
+ * query jobs by ip
+ *
+ * @param ip
+ *
+ * @return UserBean to the controller IPDataController
+ **/
+ public UserBean readIp(String ip) {
+ ResultSet results = CassandraQuery("SELECT JobID, Protein, FinalStatus, DataBegin FROM ProteinLog WHERE ip = '" + ip + "';");
+ if (results.isExhausted())
+ return null;
+ List<Row> rows = results.all();
+ Map<String, String[]> res = new HashMap<String, String[]>();
+ for (Row r : rows) {
+ if (r.getString("FinalStatus").equals("OK")) {
+ String date = r.getString("DataBegin");
+ res.put(r.getString("JobID"), new String[] { date.substring(0, date.indexOf(":")), r.getString("Protein") });
+ }
+ }
+ UserBean query = new UserBean(ip);
+ query.setMainInfo(res);
+ return query;
+ }
+
+}
--- /dev/null
+package compbio.cassandra.readers;
+
+import com.datastax.driver.core.ResultSet;
+import com.datastax.driver.core.Row;
+
+import compbio.beans.JobBean;
+
+public class JobReader extends CassandraReader {
+
+ public JobReader() {
+ super();
+ }
+
+ /**
+ * query jobs log info
+ *
+ * @param jobid
+ *
+ * @return JobBean to the controller JobController
+ *
+ **/
+ public JobBean readJobLog(String jobid) {
+ ResultSet results = CassandraQuery("SELECT * FROM ProteinLog WHERE JobID = '" + jobid + "';");
+ if (results.isExhausted())
+ return null;
+ Row row = results.one();
+ ResultSet results1 = CassandraQuery("SELECT * FROM ProteinRow WHERE JobID = '" + jobid + "' ALLOW FILTERING;");
+ if (results1.isExhausted())
+ return null;
+ Row row1 = results1.one();
+ JobBean res = new JobBean(row.getString("Protein"), row.getString("JobID"), row.getString("DataBegin"), row.getString("DataEnd"),
+ row.getString("ip"), row1.getMap("Predictions", String.class, String.class));
+ return res;
+ }
+}
--- /dev/null
+package compbio.cassandra.readers;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import com.datastax.driver.core.ResultSet;
+import com.datastax.driver.core.Row;
+
+public class PredictionReader extends CassandraReader {
+
+ public PredictionReader() {
+ super();
+ }
+
+ /**
+ * query: protein feature
+ *
+ * @param feature
+ * a feature of secondary structure: Helix or Beta Sheet
+ *
+ * @param percent
+ * fraction the feature in the protein
+ *
+ * @return Map<String, String> to the controller SSFeaturesController
+ *
+ **/
+ public Map<String, String> readProteinsPrediction(String feature, int percent) {
+ ResultSet results = CassandraQuery("SELECT * FROM ProteinRow;");
+ if (results.isExhausted())
+ return null;
+ List<Row> rows = results.all();
+ Map<String, String> query = new HashMap<String, String>();
+ for (Row r : rows) {
+ String prot = r.getString("Protein");
+ String prediction = findJnetpred(r.getMap("Predictions", String.class, String.class));
+ if (prot != null || prediction != null) {
+ if (prediction.replaceAll("[^"+feature+"]", "").length() > prediction.length() * percent / 100) {
+ query.put(prot, prediction);
+ }
+ }
+ }
+ return query;
+ }
+
+ private String findJnetpred (Map<String,String> pred) {
+ if (pred != null) {
+ if (pred.containsKey("jnetpred"))
+ return pred.get("jnetpred");
+ }
+ return null;
+ }
+}
--- /dev/null
+package compbio.cassandra.readers;
+
+
+public interface ProteoDAO<E> {
+
+ E query(long dateStart, long dateEnd);
+
+
+
+}
--- /dev/null
+package compbio.cassandra.readers;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import com.datastax.driver.core.ResultSet;
+import com.datastax.driver.core.Row;
+
+import compbio.beans.TotalByCounterBean;
+
+public class ReaderByCounter extends CassandraReader{
+
+ public ReaderByCounter() {
+ super();
+ }
+
+
+
+ /**
+ * query protein sequences with number of jobs
+ *
+ * @param minimalcounter
+ *
+ * @return List<TotalByCounterBean> to the controller SequenceController
+ *
+ **/
+ public List<TotalByCounterBean> readProteinByCounter(int minimalcounter) {
+ ResultSet results = CassandraQuery("SELECT Protein, JobID FROM ProteinRow;");
+ return QueryByCounter(results, "Protein", minimalcounter);
+ }
+
+ /**
+ * query ip with number of jobs
+ *
+ * @param minimalcounter
+ *
+ * @return List<TotalByCounterBean> to the controller IPDataController
+ *
+ **/
+ public List<TotalByCounterBean> readIpByCounter(Integer minimalcounter) {
+ ResultSet results = CassandraQuery("SELECT JobID, ip FROM ProteinLog;");
+ return QueryByCounter(results, "ip", minimalcounter);
+ }
+
+
+ /**
+ * query number of jobs by counter and parameter: ip or protein
+ *
+ * @param results
+ * cassandra query result
+ * @param counterParameter
+ * parameter for a query: ip or proteint
+ * @param minimalcounter
+ *
+ * @return List<TotalByCounterBean>
+ *
+ **/
+ public List<TotalByCounterBean> QueryByCounter(ResultSet results, String counterParameter, int minimalcounter) {
+ List<TotalByCounterBean> query = new ArrayList<TotalByCounterBean>();
+ if (results.isExhausted())
+ return null;
+ List<Row> rows = results.all();
+ Map<String, Integer> res = new HashMap<String, Integer>();
+ for (Row r : rows) {
+ String parameter = r.getString(counterParameter);
+ if (res.containsKey(parameter))
+ res.put(parameter, res.get(parameter) + 1);
+ else
+ res.put(parameter, 1);
+ }
+ for (Map.Entry<String, Integer> entry : res.entrySet()) {
+ if (entry.getValue() > minimalcounter) {
+ TotalByCounterBean bean = new TotalByCounterBean();
+ bean.setTotaljobs(entry.getValue());
+ bean.setName(entry.getKey());
+ query.add(bean);
+ }
+ }
+ return query;
+ }
+
+}
--- /dev/null
+package compbio.cassandra.readers;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import com.datastax.driver.core.ResultSet;
+import com.datastax.driver.core.Row;
+
+import compbio.beans.ProteinBean;
+
+public class SequenceReader extends CassandraReader {
+
+ public SequenceReader() {
+ super();
+ }
+
+ /**
+ * query: protein sequence
+ *
+ * @param protIn
+ * 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) {
+ List<ProteinBean> query = new ArrayList<ProteinBean>();
+ if (searchtype.equals("whole")) {
+ ResultSet results = CassandraQuery("SELECT JobID, Predictions FROM ProteinRow WHERE Protein = '" + protIn + "';");
+ if (results.isExhausted())
+ return null;
+ List<Row> rows = results.all();
+ ProteinBean structure = new ProteinBean(protIn, 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;");
+ 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);
+ }
+ }
+ }
+ if (searchtype.equals("partial")) {
+ for (ProteinBean entry : query) {
+ entry.setSubProt(CreateSubprotein(entry.getSequence(), protIn));
+ }
+ }
+ return query;
+ }
+
+ /**
+ * create a list of parts of protein sequence for highlighting current value in report;
+ *
+ * @param protein
+ * protein sequence
+ * @param subprot
+ * partial of protein sequence
+ *
+ * @return List<String>
+ *
+ **/
+ private static List<String> CreateSubprotein(String protein, String subprot) {
+ List<String> sub = new ArrayList<String>();
+ String subStr = protein;
+ while (subStr.length() > 0 && subStr.contains(subprot)) {
+ String first = subStr.substring(0, subStr.indexOf(subprot));
+ if (first.length() > 0)
+ sub.add(first);
+ sub.add(subprot);
+ subStr = subStr.substring(subStr.indexOf(subprot) + subprot.length(), subStr.length());
+ }
+ if (subStr.length() > 0)
+ sub.add(subStr);
+ return sub;
+ }
+}
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.security.core.userdetails.UserDetails;
-import compbio.cassandra.CassandraReader;
import compbio.cassandra.DateFormatter;
+import compbio.cassandra.readers.CassandraReader;
public class BasicController {
final protected SimpleDateFormat formaterDDMMYY = DateFormatter.getFormatDDMMYY();
import org.springframework.web.bind.annotation.RequestParam;
import compbio.engine.JobStatus;
-import compbio.cassandra.CassandraReader;
-import compbio.cassandra.DateBean;
+import compbio.beans.DateBean;
+import compbio.beans.TotalJobsStatisticBean;
import compbio.cassandra.DateFormatter;
-import compbio.cassandra.TotalJobsStatisticBean;
-import compbio.statistic.CassandraRequester;
+import compbio.cassandra.readers.CassandraReader;
+import compbio.cassandra.readers.DailyStatisticsReader;
+import compbio.cassandra.readers.ProteoDAO;
/**
* @author Alexander Sherstnev
model.put("username", getPrincipalName());
Calendar loccal = Calendar.getInstance();
final long startTime = System.currentTimeMillis();
- CassandraRequester cr = new CassandraRequester();
+ DailyStatisticsReader reader = new DailyStatisticsReader();
if (option.equals("AllDates,off")) {
date1 = theEaerlistDate;
date2 = theCurrentDate;
date2 = DateFormatter.DateLongToString(longDate2, formaterYYMMDD);
model.put("date1", date1);
model.put("date2", date2);
- TotalJobsStatisticBean res = cr.countJobs(date1, date2);
+ TotalJobsStatisticBean res = reader.query(longDate1, longDate2);
model.put("result", res);
model.put("ndays", res.getDateTotal().size());
final long endTime = System.currentTimeMillis();
final long startTime = System.currentTimeMillis();
String realdate;
+ long thetime = 0;
try {
- long thetime = formaterYYMMDD.parse(date).getTime();
+ thetime = formaterYYMMDD.parse(date).getTime();
if (thetime < 0) {
realdate = date;
} else {
}
} catch (ParseException e) {
realdate = date;
+ thetime = formaterDDMMYY.parse(realdate).getTime();
}
-
+
if (null == JobStatus.getJobStatus(status)) {
return "support/Notimplemented";
}
- CassandraRequester cr = new CassandraRequester();
+ DailyStatisticsReader reader = new DailyStatisticsReader();
// IMPORTANT: input should be suppied in the format: DD/MM/YYYY
- DateBean r = cr.readJobByDay(realdate, JobStatus.getJobStatus(status));
+ DateBean r = reader.readJobByDay(thetime, realdate, JobStatus.getJobStatus(status));
model.put("results", r);
if (r != null)
model.put("njobs", r.getJobidAndSeq().size());
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
-import compbio.cassandra.TotalByCounterBean;
-import compbio.cassandra.UserBean;
+import compbio.beans.TotalByCounterBean;
+import compbio.beans.UserBean;
+import compbio.cassandra.readers.IpReader;
+import compbio.cassandra.readers.ReaderByCounter;
import compbio.statistic.CassandraRequester;
/**
}
final long startTime = System.currentTimeMillis();
- CassandraRequester cr = new CassandraRequester();
- List<TotalByCounterBean> r = cr.readIpByCounter(realcounter);
+ ReaderByCounter reader = new ReaderByCounter();
+ List<TotalByCounterBean> r = reader.readIpByCounter(realcounter);
model.put("results", r);
model.put("njobs", 0);
if (null != r) {
public String findIP(@RequestParam("ip") String ip, Map<String, Object> model) {
model.put("username", getPrincipalName());
final long startTime = System.currentTimeMillis();
- CassandraRequester cr = new CassandraRequester();
- UserBean r = cr.readIp(ip);
+ IpReader reader = new IpReader();
+ UserBean r = reader.readIp(ip);
model.put("results", r);
model.put("njobs", 0);
if (null != r) {
import compbio.statistic.CassandraRequester;
import compbio.cassandra.DataBase;
+import compbio.cassandra.readers.JobReader;
import compbio.engine.archive.ArchivedJob;
/**
public String findJob(@RequestParam("IdJob") String jobid, Map<String, Object> model) {
model.put("username", getPrincipalName());
final long startTime = System.currentTimeMillis();
- CassandraRequester cr = new CassandraRequester();
- model.put("result", cr.readJobLog(jobid));
+ JobReader reader = new JobReader();
+ model.put("result", reader.readJobLog(jobid));
final long endTime = System.currentTimeMillis();
model.put("timeExecution", (endTime - startTime));
model.put("IdJob", jobid);
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
-import compbio.cassandra.ProteinBean;
-import compbio.cassandra.TotalByCounterBean;
+import compbio.beans.ProteinBean;
+import compbio.beans.TotalByCounterBean;
+import compbio.cassandra.readers.ReaderByCounter;
+import compbio.cassandra.readers.SequenceReader;
import compbio.statistic.CassandraRequester;
/**
*/
private final Pattern NONPROTEIN = Pattern.compile("[^ARNDCQEGHILKMFPSTWYV]+", Pattern.CASE_INSENSITIVE);
+ /**
+ * form a query page for search protein sequence. The servlet should be
+ * available for users and admins only.
+ *
+ * @param model
+ * MVC model
+ * @return link to the JSP query page
+ */
@RequestMapping(value = "query", method = RequestMethod.GET)
public String formSequenceQuery(Map<String, Object> model) {
model.put("username", getPrincipalName());
return "query/Sequence";
}
+ /**
+ * form a query page for statistics: Protein by job count. The servlet should be
+ * available for users and admins only.
+ *
+ * @param model
+ * MVC model
+ * @return link to the JSP query page
+ */
@RequestMapping(value = "counts/query", method = RequestMethod.GET)
public String formCounterQuery(Map<String, Object> model) {
model.put("username", getPrincipalName());
return "query/SequenceCounts";
}
+ /**
+ * form a report page for search protein sequence.
+ *
+ * @param model
+ * MVC model object
+ * @param sequence
+ * protein sequence or part of sequence
+ * @param searchtype
+ * defined whether the whole sequence or part of sequence would be searched
+ * @return link to the report JSP page
+ */
@RequestMapping(value = "sequence/results", method = RequestMethod.GET)
public String findSequence(@RequestParam("sequence") String sequence, @RequestParam("searchtype") String searchtype,
Map<String, Object> model) {
model.put("searchtype", searchtype);
if (0 < trimmedsequence.length()) {
- CassandraRequester cr = new CassandraRequester();
- List<ProteinBean> r = cr.readProteins(trimmedsequence, searchtype);
- model.put("results", r);
- if (null != r) {
+ SequenceReader reader = new SequenceReader();
+ List<ProteinBean> result = reader.readProteins(trimmedsequence, searchtype);
+ model.put("results", result);
+ if (null != result) {
if (searchtype.equals("whole"))
- model.put("njobs", r.get(0).getJobid().size());
+ model.put("njobs", result.get(0).getJobid().size());
else
- model.put("njobs", r.size());
+ model.put("njobs", result.size());
}
}
final long endTime = System.currentTimeMillis();
return "reportProteinSequences";
}
+ /**
+ * form a report page for statistics: Protein by job count.
+ *
+ * @param model
+ * MVC model object
+ * @param counter
+ *
+ * @return link to the report JSP page
+ */
@RequestMapping(value = "counts/results", method = RequestMethod.GET)
public String countSequences(@RequestParam("counterJob") String counter, Map<String, Object> model) {
model.put("username", getPrincipalName());
return "query/SequenceCounts";
}
- CassandraRequester cr = new CassandraRequester();
- List<TotalByCounterBean> r = cr.readProteinByCounter(realcounter);
+ ReaderByCounter reader = new ReaderByCounter();
+
+ List<TotalByCounterBean> r = reader.readProteinByCounter(realcounter);
model.put("results", r);
model.put("njobs", 0);
if (null != r) {
import java.util.List;
import java.util.Map;
-import compbio.cassandra.DateBean;
-import compbio.cassandra.ProteinBean;
+import compbio.beans.DateBean;
+import compbio.beans.JobBean;
+import compbio.beans.ProteinBean;
+import compbio.beans.Total;
+import compbio.beans.TotalByCounterBean;
+import compbio.beans.TotalJobsStatisticBean;
+import compbio.beans.UserBean;
import compbio.cassandra.CassandraNativeConnector;
import compbio.cassandra.CassandraReaderOld;
import compbio.cassandra.DataBase;
import compbio.cassandra.Pair;
-import compbio.cassandra.JobBean;
-import compbio.cassandra.Total;
-import compbio.cassandra.TotalByCounterBean;
-import compbio.cassandra.TotalJobsStatisticBean;
-import compbio.cassandra.UserBean;
import compbio.engine.JobStatus;
public class CassandraRequester {
/*
* query: total number of jobs for the period from date1 till date2
- */
+ */
public TotalJobsStatisticBean countJobs(String date1, String date2) {
/* if (null == date1) {
date1 = "1970/1/1";