import java.util.List;
import java.util.Map;
+import compbio.cassandra.AnnotatedProteinSequenceBean;
import compbio.cassandra.CassandraNativeConnector;
import compbio.cassandra.CassandraReader;
import compbio.cassandra.DataBase;
import compbio.cassandra.Pair;
import compbio.cassandra.StructureJobLog;
-import compbio.cassandra.StructureProteinPrediction;
public class CassandraRequester {
private CassandraReader db = new CassandraReader();
date1 = "2100/1/1";
}
if (!isThisDateValid(date1,formatYYMMDD) || !isThisDateValid(date2,formatYYMMDD)) {
- System.out.println("Wrong date: point 3");
+ System.out.println("CassandraRequester.extractExecutionTime: wrong format for date1 " + date1 + "or date2 " + date2);
return null;
}
SetDateRange();
DataBase db = new DataBase();
db.setTimeTotalExec(totalTime);
query.add(db);
- System.out.println("StatisticsProt.readLength: total number of dates = " + query.size());
return query;
}
date1 = "2100/1/1";
}
if (!isThisDateValid(date1, formatYYMMDD) || !isThisDateValid(date2, formatYYMMDD)) {
- System.out.println("Wrong date: point 3");
+ System.out.println("CassandraRequester.countJobs: wrong format for date1 " + date1 + "or date2 " + date2);
return null;
}
SetDateRange();
bean.setDate(DateFormat(date.getTime()));
query.add(bean);
}
- System.out.println("StatisticsProt.readLength: total number of dates = " + query.size());
return query;
}
-
+
/*
* query: jobs and sequence at date
*/
public List<DataBase> readJobByDay (String date) {
- System.out.println(date);
if (null == date) {
return null;
}
if (!isThisDateValid(date, formatDDMMYY)) {
- System.out.println("Wrong date: point 3");
+ System.out.println("CassandraRequester.readJobByDay: Wrong date format for " + date);
return null;
}
SetDateRange();
long day = DateParsing(date, formatDDMMYY);
- System.out.println(day);
if (day < earlestDate || day > currentDate)
return null;
List<Pair<String, String>> res = db.ReadProteinData(day);
bean.setProt(entry.getElement1());
query.add(bean);
}
- System.out.println("StatisticsProt.readLength: total number of dates = " + query.size());
return query;
}
+
+
/*
* query: protein sequence
* */
public List<DataBase> readProteins(String protIn, String flag) {
- if (protIn == null)
- return null;
- System.out.println(protIn.length());
query = new ArrayList<DataBase>();
- List<StructureProteinPrediction> res;
+ List<AnnotatedProteinSequenceBean> res;
if (flag.equals("whole"))
res = db.ReadWholeSequence(protIn);
else
- res = (protIn.length() > 0) ? db.ReadPartOfSequence(protIn) : null;
+ res = db.ReadPartOfSequence(protIn);
if (res == null)
return null;
- for (StructureProteinPrediction entry : res) {
- DataBase bean = new DataBase();
- bean.setProt(entry.getSequence());
- bean.setId(entry.getJobid());
- bean.setJpred(entry.getJnetpred());
- if (flag.equals("part"))
- bean.setSubProt(CreateSubprot (entry.getSequence(), protIn));
- query.add(bean);
-
+ 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));
+ }
+ query.add(db);
}
return query;
}
+
/*
* query protein sequences with number of jobs
*/
return query;
}
+ /*
+ * query ip with number of jobs
+ */
+ public List<DataBase> readIpByCounter(Integer minimalcounter) {
+ query = new ArrayList<DataBase>();
+ Map<String, Integer> map = db.ReadIpByCounter();
+ if (minimalcounter == null)
+ minimalcounter = 0;
+ if (map == null)
+ return null;
+ for (Map.Entry<String, Integer> entry : map.entrySet()) {
+ if (entry.getValue() > minimalcounter) {
+ DataBase bean = new DataBase();
+ bean.setTotalId(entry.getValue());
+ bean.setIp(entry.getKey());
+ query.add(bean);
+ }
+ }
+ return query;
+ }
/*
* query jobs log info
*/
return query;
}
+
+ /*
+ * query jobs by ipStructureJobLog
+ */
+ public List<DataBase> readIp(String ip) {
+ if (ip == null)
+ return null;
+ List<Pair<String, String>> res = db.ReadIpWithJobs(ip);
+ if (res == null)
+ return null;
+ query = new ArrayList<DataBase>();
+ for (Pair<String, String> entry : res) {
+ DataBase bean = new DataBase();
+ bean.setIp(ip);
+ bean.setId(entry.getElement0());
+ bean.setProt(entry.getElement1());
+ query.add(bean);
+ }
+ return query;
+ }
+
/*
* create list of parts of protein sequence;
*/
if (0 == earlestDate) {
CassandraRequester cr = new CassandraRequester();
earlestDate = cr.earliestDate();
- System.out.println("Set earlest Date = " + earlestDate);
}
}
public boolean isThisDateValid(String dateToValidate, SimpleDateFormat sdf) {
if (dateToValidate == null || dateToValidate.equals("")) {
- System.out.println("Undefined date");
return false;
}
try {