public class DateBean {
private String date;
- private Map<String, String> jobidAndSeq; // Map for jobid and sequence
-
+ private Map<String, String> jobidAndSeq; // Map for jobid and sequence
+
public DateBean() {
this.jobidAndSeq = new HashMap<String, String>();
}
-
+
public DateBean(String date) {
this.date = date;
this.jobidAndSeq = new HashMap<String, String>();
}
-
+
public void setJobidAndSeq(String jobid, String seq) {
if (jobidAndSeq == null)
jobidAndSeq = new HashMap<String, String>();
jobidAndSeq.put(jobid, seq);
}
-
public Map<String, String> getJobidAndSeq() {
return jobidAndSeq;
}
-
+
public void setDate(String date) {
this.date = date;
}
private String dateStart;
private String dateEnd;
private String sequence;
- private String ip;
- private LinkedHashMap<String,String> predictions;
-
- public JobBean (String seq, String id, String dateStart, String dateEnd, String ip, Map<String,String> pred) {
+ private String ip;
+ private LinkedHashMap<String, String> predictions;
+
+ public JobBean(String seq, String id, String dateStart, String dateEnd, String ip, Map<String, String> pred) {
this.sequence = seq;
this.jobid = id;
this.dateStart = dateStart;
this.dateEnd = dateEnd;
this.ip = ip;
- this.predictions = new LinkedHashMap<String,String>();
+ this.predictions = new LinkedHashMap<String, String>();
setPredictions(pred);
}
-
- public void setPredictions(Map<String,String> pred) {
+
+ public void setPredictions(Map<String, String> pred) {
if (predictions == null)
- predictions = new LinkedHashMap<String,String>();
+ predictions = new LinkedHashMap<String, String>();
for (String index : predIndex) {
this.predictions.put(index, pred.get(index));
- }
+ }
}
- public String getSequence () {
+
+ public String getSequence() {
return sequence;
}
-
- public String getJobid () {
+
+ public String getJobid() {
return jobid;
}
-
- public String getDateStart () {
+
+ public String getDateStart() {
return dateStart;
}
-
- public String getDateEnd () {
+
+ public String getDateEnd() {
return dateEnd;
}
-
- public String getIp () {
+
+ public String getIp() {
return ip;
}
-
- public Map<String,String> getPrediction () {
+
+ public Map<String, String> getPrediction() {
return predictions;
}
}
import compbio.cassandra.PredictionIndex;
-public class ProteinBean implements PredictionIndex{
+public class ProteinBean implements PredictionIndex {
private String sequence;
private String jnetpred;
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 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) {
+
+ public ProteinBean(String seq, Map<String, String> pred) {
this.sequence = seq;
- this.predictions = new LinkedHashMap<String,String>();
+ this.predictions = new LinkedHashMap<String, String>();
this.jobid = new ArrayList<String>();
setPredictions(pred);
}
-
- public void setSequence (String seq) {
+
+ public void setSequence(String seq) {
this.sequence = seq;
}
-
- public void setPredictions(Map<String,String> pred) {
+
+ public void setPredictions(Map<String, String> pred) {
if (predictions == null)
- predictions = new LinkedHashMap<String,String>();
+ predictions = new LinkedHashMap<String, String>();
for (String index : predIndex) {
this.predictions.put(index, pred.get(index));
- }
+ }
this.size = predictions.size();
}
-
- public String getSequence () {
+
+ public String getSequence() {
return sequence;
}
-
- public String getJnetpred () {
+
+ public String getJnetpred() {
return jnetpred;
}
-
- public void setJnetpred (Map<String,String> pred) {
+
+ public void setJnetpred(Map<String, String> pred) {
if (pred != null) {
- if (pred.containsKey("jnetpred"))
+ if (pred.containsKey("jnetpred"))
jnetpred = pred.get("jnetpred");
}
}
-
- public List<String> getJobid () {
+
+ public List<String> getJobid() {
return jobid;
}
-
- public void setJobid (String id) {
+
+ public void setJobid(String id) {
this.jobid.add(id);
}
- public int getSize () {
+ public int getSize() {
return size;
}
-
- public LinkedHashMap<String,String> getPredictions () {
+
+ public LinkedHashMap<String, String> getPredictions() {
return predictions;
}
-
+
public void setSubProt(List<String> subProt) {
this.subProt = subProt;
}
* @param total
* total number of jobs for a day
* @param totalOK
- * number of jobs with execution status OK for a date
+ * number of jobs with execution status OK for a date
* @param totalStopped
- * number of jobs with execution status STOPPED for a date
+ * number of jobs with execution status STOPPED for a date
* @param totalError
- * number of jobs with execution status Jpred ERROR for a date
+ * number of jobs with execution status Jpred ERROR for a date
* @param totalTimeOut
- * number of jobs with execution status TIMEDOUT for a date
+ * number of jobs with execution status TIMEDOUT for a date
*/
public class Total {
- private long total;
- private long totalOK;
- private long totalStopped;
- private long totalError;
- private long totalTimeOut;
-
+ 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;
this.totalError = totalError;
this.totalTimeOut = totalTimeOut;
}
-
+
public void setTotal(long tot) {
this.total = tot;
}
package compbio.beans;
public class TotalByCounterBean {
- private int totaljobs; // total jobs for current condition
- private String name; // name for counter condition (ip or sequence)
-
+ private int totaljobs; // total jobs for current condition
+ private String name; // name for counter condition (ip or sequence)
+
public void setTotaljobs(int tot) {
this.totaljobs = tot;
}
public int getTotaljobs() {
return totaljobs;
}
-
+
public void setName(String name) {
this.name = name;
}
* bean for a report of daily statistics.
*
* @param dateTotal
- * Map<String, Total> where String - a date, Total - total info for jobs with different status
+ * Map<String, Total> where String - a date, Total - total info for
+ * jobs with different status
* @param wholeTotal
- * total sum for each parameter from dateTotal
+ * total sum for each parameter from dateTotal
*/
public class TotalJobsStatisticBean {
private Map<String, Total> dateTotal;
private Total wholeTotal;
-
+
public TotalJobsStatisticBean() {
this.dateTotal = new LinkedHashMap<String, Total>();
}
-
+
public void setDateTotal(String dat, Total tot) {
if (this.dateTotal == null)
dateTotal = new LinkedHashMap<String, Total>();
public Map<String, Total> getDateTotal() {
return dateTotal;
}
-
+
public void setWholeTotal(Total tot) {
this.wholeTotal = tot;
}
-
+
public Total getWholeTotal() {
return wholeTotal;
}
package compbio.beans;
-import java.util.ArrayList;
-import java.util.Arrays;
+
import java.util.HashMap;
-import java.util.List;
import java.util.Map;
-
public class UserBean {
private String ip;
- private Map<String,String[]> mainInfo; // store jobid, date start and sequence
-
+ private Map<String, String[]> mainInfo; // store jobid, date start and
+ // sequence
+
public UserBean(String ip) {
this.ip = ip;
- mainInfo = new HashMap<String,String[]>();
+ mainInfo = new HashMap<String, String[]>();
}
public String getIp() {
return ip;
}
-
+
public void setMainInfo(String jobid, String date, String sequence) {
if (mainInfo == null)
- mainInfo = new HashMap<String,String[]>();
- mainInfo.put(jobid, new String[] {date, sequence});
+ mainInfo = new HashMap<String, String[]>();
+ mainInfo.put(jobid, new String[] { date, sequence });
}
-
- public void setMainInfo( Map<String,String[]> info) {
+
+ public void setMainInfo(Map<String, String[]> info) {
if (mainInfo == null)
- mainInfo = new HashMap<String,String[]>();
+ mainInfo = new HashMap<String, String[]>();
mainInfo = info;
}
-
- public Map<String,String[]> getMainInfo() {
+
+ public Map<String, String[]> getMainInfo() {
return mainInfo;
}
public static String CASSANDRA_HOSTNAME = "localhost";
- public static Session getSession () {
+ public static Session getSession() {
return session;
}
Cluster.Builder builder = Cluster.builder();
builder.addContactPoint(CASSANDRA_HOSTNAME);
- //PrintClusterConfiguration( builder.getConfiguration());
+ // PrintClusterConfiguration( builder.getConfiguration());
cluster = builder.build();
Metadata metadata = cluster.getMetadata();
session.execute("CREATE KEYSPACE IF NOT EXISTS ProteinKeyspace WITH replication = {'class':'SimpleStrategy', 'replication_factor':3};");
session.execute("USE ProteinKeyspace");
- session.execute("CREATE TABLE IF NOT EXISTS MainParameters "
- + "(Name ascii, Value ascii, PRIMARY KEY(Name));");
-
+ session.execute("CREATE TABLE IF NOT EXISTS MainParameters " + "(Name ascii, Value ascii, PRIMARY KEY(Name));");
+
session.execute("CREATE TABLE IF NOT EXISTS ProteinRow "
+ "(Protein ascii, JobID ascii, Predictions map<ascii,ascii>, PRIMARY KEY(JobID));");
session.execute("CREATE TABLE IF NOT EXISTS FailLog "
+ "(jobtime bigint, JobID ascii, ExecTime int, ip ascii, FinalStatus ascii, PRIMARY KEY(jobtime, JobID));");
-
+
session.execute("CREATE TABLE IF NOT EXISTS JpredArchive "
+ "(JobID ascii, Protein varchar, IP ascii, StartTime bigint, ExecTime int, FinalStatus ascii, ExecutionStatus ascii, alignment map<ascii,ascii>, "
+ "predictions map<ascii,ascii>, ArchiveLink varchar, LOG varchar, PRIMARY KEY(JobID));");
String com = "CREATE TABLE IF NOT EXISTS Users "
+ "(name varchar, id bigint, email varchar, password varchar, organisation varchar, position varchar, signedtolist boolean, registrationdate bigint, PRIMARY KEY(id));";
-
-
+
try {
session.execute(com);
} catch (QueryExecutionException e) {
session.execute("CREATE INDEX IF NOT EXISTS ON ProteinLog (ExecutionStatus);");
session.execute("CREATE INDEX IF NOT EXISTS ON FailLog (FinalStatus);");
session.execute("CREATE INDEX IF NOT EXISTS ON Users (email);");
- // session.execute("CREATE INDEX IF NOT EXISTS JobDateStamp ON ProteinData (jobtime);");
- }
+ // session.execute("CREATE INDEX IF NOT EXISTS JobDateStamp ON ProteinData (jobtime);");
+ }
public void Closing() {
session.shutdown();
Calendar cal = Calendar.getInstance();
return cal.getTimeInMillis();
}
-
+
private void PrintClusterConfiguration(Configuration cc) {
Policies policies = cc.getPolicies();
SocketOptions sopt = cc.getSocketOptions();
ProtocolOptions propt = cc.getProtocolOptions();
PoolingOptions plopt = cc.getPoolingOptions();
MetricsOptions mopt = cc.getMetricsOptions();
- QueryOptions qopt = cc.getQueryOptions();
+ QueryOptions qopt = cc.getQueryOptions();
System.out.println("Cluster configuration:");
System.out.println(" Policies = " + policies.toString());
System.out.println(" Socket Options = " + sopt.toString());
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 (prot != null || prediction != null)
res.put(prot, prediction);
}
final long endTime = System.currentTimeMillis();
return res;
}
- private String findJnetpred (Map<String,String> pred) {
+ private String findJnetpred(Map<String, String> pred) {
if (pred != null) {
- if (pred.containsKey("jnetpred"))
+ if (pred.containsKey("jnetpred"))
return pred.get("jnetpred");
}
return null;
}
+
/*
* getting protein sequences by counter
*/
public class CassandraRemover {
private Session session;
- static SimpleDateFormat dateformatter = new SimpleDateFormat("yyyy/MM/dd");
+ static SimpleDateFormat dateformatter = new SimpleDateFormat("yyyy/MM/dd");
private static Logger log = Logger.getLogger(CassandraNativeConnector.class);
public CassandraRemover() {
Session inis = CassandraNativeConnector.getSession();
- setSession (inis);
+ setSession(inis);
}
public void setSession(Session s) {
assert s != null;
session = s;
}
-
+
/*
* delete a record from CF for current jobId
*/
System.out.println("Command: " + com);
ResultSet results = session.execute(com);
Row row = results.one();
- long njobs = row.getLong("Total") -1 ;
+ long njobs = row.getLong("Total") - 1;
if (status.equals("OK")) {
long njobsOK = row.getLong("TotalOK") - 1;
String com1 = "DELETE FROM ProteinRow WHERE JobID = '" + jobid + "';";
}
System.out.println("Remove jobs: " + jobid);
}
-
+
private void UpdateJobDateInfo(long date, String ColumnName, long totalcol, long total) {
String com4 = "UPDATE JobDateInfo SET " + ColumnName + " = " + totalcol + ", Total = " + total + " WHERE jobday = " + date + ";";
System.out.println("Command: " + com4);
session.execute(com4);
}
-
- public int RemoveJobById (String jobid) {
- if (jobid == null)
+
+ public int RemoveJobById(String jobid) {
+ if (jobid == null)
return 0;
Long date = FindDate(jobid);
RemoveJob(jobid, date);
return 1;
}
-
- public int RemoveJobByDate (String date1, String date2) {
+
+ public int RemoveJobByDate(String date1, String date2) {
int numremover = 0;
- if (date1 == null || date2 == null)
+ if (date1 == null || date2 == null)
return 0;
Long dateBegin = convertDate(date1);
Long dateEnd = convertDate(date2);
}
return numremover;
}
-
-
- public int RemoveJobByIp (String ip) {
+
+ public int RemoveJobByIp(String ip) {
int numremover = 0;
- if (ip == null)
+ if (ip == null)
return 0;
String com = "SELECT databegin, JobID FROM ProteinLog WHERE ip = '" + ip + "';";
ResultSet results = session.execute(com);
}
return numremover;
}
-
- public int RemoveJobBySequence (String seq) {
+
+ public int RemoveJobBySequence(String seq) {
int numremover = 0;
- if (seq == null)
+ if (seq == null)
return 0;
String com = "SELECT JobID FROM ProteinRow WHERE Protein = '" + seq + "';";
ResultSet results = session.execute(com);
}
return numremover;
}
-
+
private Long FindDate(String jobid) {
String com = "SELECT databegin FROM ProteinLog WHERE JobID = '" + jobid + "';";
ResultSet results = session.execute(com);
Long date = convertDate(results.one().getString("databegin"));
return date;
}
-
+
private String FindStatus(String jobid) {
String com = "SELECT FinalStatus FROM ProteinLog WHERE JobID = '" + jobid + "';";
System.out.println("Command: " + com);
System.out.println("*****status: " + status);
return status;
}
-
- protected long convertDate (String d) {
+
+ protected long convertDate(String d) {
try {
if (null != d) {
Date startdate = dateformatter.parse(d);
if (0 < users.all().size()) {
throw new DataIntegrityViolationException("A user with email " + user.getEmail() + " exists");
}
-
+
} catch (QueryExecutionException e) {
String mess = "CassandraUserManagerImpl.addUser: query execution exception...";
System.out.println(mess);
String test = list.get(0).getString("Value");
id = Long.parseLong(test, 10);
} else {
- // if the MaxUserId parameter does not exist it is inserted with id = 1
+ // if the MaxUserId parameter does not exist it is inserted
+ // with id = 1
id = 0;
}
id++;
}
String incom = "INSERT INTO Users (name, id, email, password, organisation, position, signedtolist, registrationdate) VALUES ('"
- + user.getFullName() + "'," + id + ",'" + user.getEmail() + "','" + user.getPassword() + "','"
- + user.getOrganisation() + "','" + user.getPosition() + "'," + user.isUpdateByEmail() + ","
- + user.getRegistrationDate().getTime() + ");";
+ + user.getFullName() + "'," + id + ",'" + user.getEmail() + "','" + user.getPassword() + "','" + user.getOrganisation()
+ + "','" + user.getPosition() + "'," + user.isUpdateByEmail() + "," + user.getRegistrationDate().getTime() + ");";
try {
session.execute(incom);
} catch (QueryExecutionException e) {
import java.util.List;
import org.apache.log4j.Logger;
-import org.springframework.dao.DataIntegrityViolationException;
import com.datastax.driver.core.Row;
import com.datastax.driver.core.Session;
public class DataBase {
private String date;
- private int total; // total number of jobs
- private int totalOK; // number of jobs with execution status OK
- private int totalStopped; // number of jobs with execution status STOPPED
- private int totalError; // number of jobs with execution status Jpred ERROR
- private int totalTimeOut; // number of jobs with execution status TIMEOUT
+ private int total; // total number of jobs
+ private int totalOK; // number of jobs with execution status OK
+ private int totalStopped; // number of jobs with execution status STOPPED
+ private int totalError; // number of jobs with execution status Jpred ERROR
+ private int totalTimeOut; // number of jobs with execution status TIMEOUT
private int totalJobs;
- private int totalId; // total jobs for current protein sequence
+ private int totalId; // total jobs for current protein sequence
private String id;
private String ip;
- private String prot; // protein sequence
+ private String prot; // protein sequence
private String jpred;
private List<Integer> timeRez;
private List<Integer> timeTotalExec;
public int getTotalTimeOut() {
return totalTimeOut;
}
-
+
public void setTotalJobs(int totalJobs) {
this.totalJobs = totalJobs;
}
public String getId() {
return id;
}
-
+
public void setIp(String ip) {
this.ip = ip;
}
public List<Integer> getTimeRez() {
return timeRez;
}
-
+
public void setTimeTotalExec(List<Integer> timeTotalExec) {
this.timeTotalExec = timeTotalExec;
}
public List<Integer> getTimeTotalExec() {
return timeTotalExec;
}
-
- public void setLogInfo(JobBean logInfo){
+
+ public void setLogInfo(JobBean logInfo) {
this.logInfo = logInfo;
}
-
+
public JobBean getLogInfo() {
return logInfo;
}
-
- public void setPredictions(ProteinBean predictions){
+
+ public void setPredictions(ProteinBean predictions) {
this.predictions = predictions;
}
-
+
public ProteinBean getPredictions() {
return predictions;
}
public class DateFormatter {
private final static SimpleDateFormat formatYYMMDD = new SimpleDateFormat("yyyy/MM/dd");
private final static SimpleDateFormat formatDDMMYY = new SimpleDateFormat("dd/MM/yyyy");
-
+
/*
* convert String date into long date (miliseconds since the epoch start)
*/
}
return dateWorkSt;
}
-
+
/*
- * date validator
- * true - if valid date, false - if invalid
+ * date validator true - if valid date, false - if invalid
*/
public static boolean isThisDateValid(String dateToValidate, SimpleDateFormat sdf) {
if (dateToValidate == null || dateToValidate.equals("")) {
}
return true;
}
-
+
/*
* convert date from long to String
*/
String dateString = formatter.format(new Date(indate));
return dateString;
}
-
+
public static SimpleDateFormat getFormatYYMMDD() {
return formatYYMMDD;
}
-
+
public static SimpleDateFormat getFormatDDMMYY() {
return formatDDMMYY;
}
/*
* Defines a source file with metainformation of Jpred Jobs
- **/
- void setSource (String newsourceprefix);
-
+ */
+ void setSource(String newsourceprefix);
+
/*
* Makes real parsing of the source file
- **/
+ */
void Parsing(String source, int nDays) throws IOException;
}
}
return protein;
}
+
private String parseSeqFile(final InputStream stream, String jobid) throws FileNotFoundException {
final FastaReader fr = new FastaReader(stream);
String protein = "";
} catch (ParseException e) {
e.printStackTrace();
}
- //countinsertions += cw.FormQueryTables(insertdate, starttime, finishtime, ip, id, "OK", "OK", newprotein, seqs);
+ // countinsertions += cw.FormQueryTables(insertdate,
+ // starttime, finishtime, ip, id, "OK", "OK",
+ // newprotein, seqs);
}
fr.close();
} catch (IOException e) {
/**
* Ordering indexes for predictions
*/
- public final String[] predIndex = {"jnetpred", "JNETCONF", "JNETHMM", "JNETPSSM", "JNETSOL0", "JNETSOL5",
- "JNETSOL25", "Lupas_14", "Lupas_21", "Lupas_28"};
+ public final String[] predIndex = { "jnetpred", "JNETCONF", "JNETHMM", "JNETPSSM", "JNETSOL0", "JNETSOL5", "JNETSOL25", "Lupas_14",
+ "Lupas_21", "Lupas_28" };
}
assert s != null;
session = s;
}
-
+
protected ResultSet CassandraQuery(String command) {
try {
ResultSet results = session.execute(command);
log.error(e.getLocalizedMessage(), e.getCause());
return null;
}
-
+
}
-
+
/*
* find the earliest date in the database
*/
return earlestDate;
}
-
}
package compbio.cassandra.readers;
-
import java.util.Calendar;
import java.util.List;
import java.util.ArrayList;
-import org.apache.log4j.Logger;
-
import com.datastax.driver.core.Row;
import com.datastax.driver.core.Session;
import com.datastax.driver.core.ResultSet;
-import com.datastax.driver.core.PreparedStatement;
-import com.datastax.driver.core.BoundStatement;
-import compbio.cassandra.CassandraReaderOld;
import compbio.cassandra.Pair;
-import compbio.engine.ProteoCachePropertyHelperManager;
-import compbio.util.PropertyHelper;
public class CassandraReaderExecutionTime {
private Session session;
public DailyStatisticsReader() {
super();
}
-
+
/**
* query: total number of jobs for the period from date1 till date2
*
* @param dateStart
- * the first date in the period
+ * the first date in the period
* @param dateEnd
- * the last date in the period
+ * the last date in the period
*
- * @return TotalJobsStatisticBean to the controller DailyStatisticsController
+ * @return TotalJobsStatisticBean to the controller
+ * DailyStatisticsController
**/
public TotalJobsStatisticBean query(long dateStart, long dateEnd) {
Calendar start = Calendar.getInstance();
query.setWholeTotal(wholeTotal);
return query;
}
-
+
/**
* query: jobs and sequence at a date
*
* @param day
- * the date in long format
+ * the date in long format
* @param date
- * the date in String format
+ * the date in String format
*
* @param status
- * final job status
+ * final job status
* @return DateBean to the controller DailyStatisticsController
**/
- public DateBean readJobByDay(long day, String date, JobStatus status) {
+ 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 + ";");
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() + "';");
+ } 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();
import compbio.beans.UserBean;
public class IpReader extends CassandraReader {
-
+
public IpReader() {
super();
}
-
+
/**
* query jobs by ip
*
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") });
+ res.put(r.getString("JobID"), new String[] { date.substring(0, date.indexOf(":")), r.getString("Protein") });
}
}
UserBean query = new UserBean(ip);
import compbio.beans.JobBean;
public class JobReader extends CassandraReader {
-
+
public JobReader() {
super();
}
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
+ * @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
*
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) {
+ 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) {
+ private String findJnetpred(Map<String, String> pred) {
if (pred != null) {
- if (pred.containsKey("jnetpred"))
+ if (pred.containsKey("jnetpred"))
return pred.get("jnetpred");
}
return null;
package compbio.cassandra.readers;
-
public interface ProteoDAO<E> {
-
+
E query(long dateStart, long dateEnd);
-
-
}
import compbio.beans.TotalByCounterBean;
-public class ReaderByCounter extends CassandraReader{
-
+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) {
+ 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
*
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
+ * cassandra query result
* @param counterParameter
- * parameter for a query: ip or proteint
+ * parameter for a query: ip or proteint
* @param minimalcounter
- *
- * @return List<TotalByCounterBean>
+ *
+ * @return List<TotalByCounterBean>
*
**/
public List<TotalByCounterBean> QueryByCounter(ResultSet results, String counterParameter, int minimalcounter) {
}
}
return query;
- }
-
+ }
+
}
public SequenceReader() {
super();
}
-
+
/**
* query: protein sequence
- *
+ *
* @param protIn
- * protein sequence or partial of protein sequence
+ * protein sequence or partial of protein sequence
* @param searchtype
- * "whole" or "partial" of protein sequence
+ * "whole" or "partial" of protein sequence
*
* @return List<ProteinBean> to the controller SequenceController
*
}
return query;
}
-
+
/**
- * create a list of parts of protein sequence for highlighting current value in report;
- *
+ * create a list of parts of protein sequence for highlighting current value
+ * in report;
+ *
* @param protein
- * protein sequence
+ * protein sequence
* @param subprot
- * partial of protein sequence
+ * partial of protein sequence
*
- * @return List<String>
+ * @return List<String>
*
**/
private static List<String> CreateSubprotein(String protein, String subprot) {
private long StartingTime;
private long ExecutionTime;
- static SimpleDateFormat dateformatter = new SimpleDateFormat("yyyy/MM/dd");;
+ static SimpleDateFormat dateformatter = new SimpleDateFormat("yyyy/MM/dd");;
static SimpleDateFormat timeformatter = new SimpleDateFormat("yyyy/MM/dd:H:m:s");
public Job() {
ExecutionStatus = "OK";
FinalStatus = "OK";
jobid = "";
-
+
StartingDateStr = "1970/1/1";
StartingTimeStr = "1970/1/1:0:0:0";
EndTimeStr = "1970/1/1:0:0:0";
setDates(date1, date2);
}
- protected void setDates (String d1, String d2) {
+ protected void setDates(String d1, String d2) {
StartingTimeStr = d1;
StartingDateStr = d1.substring(0, d1.indexOf(":"));
StartingTime = convertTime(StartingTimeStr);
EndTime = convertTime(d2);
ExecutionTime = EndTime - StartingTime;
}
-
-
- protected long convertDate (String d) {
+
+ protected long convertDate(String d) {
try {
if (null != d) {
Date startdate = dateformatter.parse(d);
}
return 0L;
}
-
- protected long convertTime (String d) {
+
+ protected long convertTime(String d) {
try {
if (null != d) {
Date startdate = timeformatter.parse(d);
}
return 0L;
}
-
-
+
public void setStartingDate(String date) {
this.StartingDateStr = date;
StartingDate = convertDate(date);
public String getStartingDateStr() {
return StartingDateStr;
}
+
public String getStartingTimeStr() {
return StartingTimeStr;
}
+
public long getStartingDate() {
return StartingDate;
}
+
public long getStartingTime() {
return StartingTime;
}
public String getEndTimeStr() {
return EndTimeStr;
}
+
public long getEndTime() {
return EndTime;
}
public void setFinalStatus(String status) {
FinalStatus = status;
}
-
+
public String getExecutionStatus() {
return ExecutionStatus;
}
public long getExecutionTime() {
return ExecutionTime;
}
-
+
public void setIP(String IP) {
this.IP = IP;
}
return IP;
return "127.0.0.1";
}
-
+
public void setEmail(String email) {
this.Email = email;
}
super(jobid, date1, date2);
this.protein = protein;
predictions = new ArrayList<FastaSequence>();
- alignment = new ArrayList<FastaSequence>();
+ alignment = new ArrayList<FastaSequence>();
log = "";
}
super(jobid, date1, date2);
this.protein = protein;
this.alignment = alignment;
- this.predictions = predictions;
+ this.predictions = predictions;
}
public void setProtein(String protein) {
private static PropertyHelper ph = null;\r
\r
/**\r
- * Ways to fix path problem: \r
- * 1) find a path to WEB-INF directory based on the path to a known class. \r
- * Then prepend this absolute path to the rest of paths \r
- * pros: no input from user \r
- * cons: relocation of the source may cause problems \r
+ * Ways to fix path problem: 1) find a path to WEB-INF directory based on\r
+ * the path to a known class. Then prepend this absolute path to the rest of\r
+ * paths pros: no input from user cons: relocation of the source may cause\r
+ * problems\r
* \r
- * 2) Require users to add configuration directories to the class\r
- * path and then load entries from it. \r
- * pros: \r
- * cons: Many paths needs to be added. Put significant burden on the user. \r
- * Hard to tell web appl server to add these entries to its class path. \r
+ * 2) Require users to add configuration directories to the class path and\r
+ * then load entries from it. pros: cons: Many paths needs to be added. Put\r
+ * significant burden on the user. Hard to tell web appl server to add these\r
+ * entries to its class path.\r
* \r
- * 3) Ask for project source directory explicitly in the configuration. \r
- * pros:\r
- * cons: similar to 1, but this initial configuration file must reside in \r
- * well known location! Why ask users what can be found automatically?\r
+ * 3) Ask for project source directory explicitly in the configuration.\r
+ * pros: cons: similar to 1, but this initial configuration file must reside\r
+ * in well known location! Why ask users what can be found automatically?\r
* \r
- * 4) Have everything in the location already in class path for tomcat. \r
- * pros:\r
- * cons: only classes and lib/*.jar are added, Eclipse will remove non \r
+ * 4) Have everything in the location already in class path for tomcat.\r
+ * pros: cons: only classes and lib/*.jar are added, Eclipse will remove non\r
* classses from classes dir.\r
* \r
* Try 1 - succeed.\r
\r
/**\r
* Method return the absolute path to the project root directory. It assumes\r
- * the following structure of the project:\r
- * project-root: \r
- * conf/settings\r
- * binaries \r
- * WEB-INF/classes/compbio/engine/conf/PropertyHelperManager.class\r
+ * the following structure of the project: project-root: conf/settings\r
+ * binaries WEB-INF/classes/compbio/engine/conf/PropertyHelperManager.class\r
* If the structure changes it must be reflected in this method\r
* \r
* @return the local path\r
} catch (IllegalArgumentException e) {\r
// Classes are in the jar file, using different method to determine\r
// the path new File(INCORRECT URL) throws it\r
- String mes = "It looks like classes are in the jar file. " \r
- + "Attempting a different method to determinine the path to the resources";\r
+ String mes = "It looks like classes are in the jar file. "\r
+ + "Attempting a different method to determinine the path to the resources";\r
log.debug(mes + e.getLocalizedMessage(), e.getCause());\r
try {\r
f = new File(ProteoCachePropertyHelperManager.class.getProtectionDomain().getCodeSource().getLocation().toURI().getPath());\r
return Boolean.parseBoolean(propValue);\r
}\r
return false;\r
- }}\r
+ }\r
+}\r
String path = ph.getProperty("archive.path");
assert (null != path);
- if (isAbsolutePath (path)) {
+ if (isAbsolutePath(path)) {
archivepath = path;
} else {
String abspath = ProteoCachePropertyHelperManager.getLocalPath();
}
}
- private boolean isAbsolutePath (String path) {
- return (new File(path).isAbsolute());
+ private boolean isAbsolutePath(String path) {
+ return (new File(path).isAbsolute());
}
-
- private boolean isDirExists (String path) throws IOException {
+
+ private boolean isDirExists(String path) throws IOException {
archive = new File(path);
return archive.getCanonicalFile().isDirectory();
}
-
- public boolean addArchivedJob (ArchivedJob job) {
+ public boolean addArchivedJob(ArchivedJob job) {
return true;
}
-
+
public String createJob(String jobid) {
return archivepath + "/" + jobid + ".tar.gz";
}
package compbio.engine.archive;
-import java.io.File;
import java.io.FileNotFoundException;
-import java.io.InputStream;
+
import java.util.Iterator;
-import java.util.Scanner;
//import compbio.util.Util;
*/
public class ArchiveManager implements Iterator<ArchivedJob> {
Archive archive;
- //private final Scanner input;
+
+ // private final Scanner input;
/**
* Delimiter for the scanner
*/
- //private final String DELIM = ">";
+ // private final String DELIM = ">";
/**
* Header data can contain non-ASCII symbols and read in UTF8
*/
public ArchiveManager(final String mainPath) throws FileNotFoundException {
/*
- input = new Scanner(new File(mainPath), "UTF8");
- input.useDelimiter(DELIM);
- Runtime.getRuntime().addShutdownHook(new Thread() {
-
- @Override
- public void run() {
- if (input != null) {
- input.close();
- }
- }
- });
- */
+ * input = new Scanner(new File(mainPath), "UTF8");
+ * input.useDelimiter(DELIM); Runtime.getRuntime().addShutdownHook(new
+ * Thread() {
+ *
+ * @Override public void run() { if (input != null) { input.close(); } }
+ * });
+ */
}
-
+
public ArchiveManager(Archive ar) {
archive = ar;
}
-
/**
* {@inheritDoc}
*
*/
@Override
public boolean hasNext() {
- //return input.hasNext();
+ // return input.hasNext();
return true;
}
public ArchivedJob next() {
String path = "bla-bla-bla";
/*
- String path = input.next();
- while (fastaHeader.indexOf("\n") < 0 && input.hasNext()) {
- path = fastaHeader.concat(">");
- path = fastaHeader.concat(input.next());
- }
- */
+ * String path = input.next(); while (fastaHeader.indexOf("\n") < 0 &&
+ * input.hasNext()) { path = fastaHeader.concat(">"); path =
+ * fastaHeader.concat(input.next()); }
+ */
return new ArchivedJob(path);
}
* instance of the FastaReader will be possible after calling this method.
*/
public void close() {
- //input.close();
+ // input.close();
}
private static ArchivedJob toFastaSequence(final String singleFastaEntry) {
int nlineidx = singleFastaEntry.indexOf("\n");
if (nlineidx < 0) {
- throw new AssertionError(
- "The FASTA sequence must contain the header information"
- + " separated by the new line from the sequence. Given sequence does not appear to "
- + "contain the header! Given data:\n "
- + singleFastaEntry);
+ throw new AssertionError("The FASTA sequence must contain the header information"
+ + " separated by the new line from the sequence. Given sequence does not appear to "
+ + "contain the header! Given data:\n " + singleFastaEntry);
}
String header = singleFastaEntry.substring(0, nlineidx);
}
if (Files.isReadable(Paths.get(thefile))) {
Files.copy(Paths.get(thefile), Paths.get(finalpath));
- return resultpath + '/' + jobfilename;
+ return resultpath + '/' + jobfilename;
}
return null;
}