1 package compbio.ws.jpred;
3 import java.io.IOException;
4 import java.util.ArrayList;
7 import javax.jws.WebService;
9 import org.apache.log4j.Logger;
11 import compbio.beans.ProteinBean;
12 import compbio.cassandra.CassandraNativeConnector;
13 import compbio.cassandra.readers.JobReader;
14 import compbio.cassandra.readers.SequenceReader;
15 import compbio.engine.archive.ArchivedJob;
18 * Implementation of the Jpred web service in ProteoCache
20 * @author Alexander Sherstnev
21 * @author Natasha Sherstneva
26 @WebService(endpointInterface = "compbio.ws.jpred.Jpred", targetNamespace = "http://server.proteocache.ws", serviceName = "ProteoCacheWS", portName = "ProteoCacheWSPort")
27 public class JpredWS implements Jpred {
28 private static Logger log = Logger.getLogger(CassandraNativeConnector.class);
31 private List<String> findJobs(String sequence, String program, String version) {
32 CassandraNativeConnector dbconnector = new CassandraNativeConnector();
33 SequenceReader reader = new SequenceReader();
34 reader.setSession(dbconnector.getSession());
35 log.debug("ProteoCacheWS is connected:\n search for sequence: " + sequence + "\ncalculated with " + program + " (version: "
37 List<String> jobs = new ArrayList<String>();
38 List<ProteinBean> result = reader.readProteins(sequence, "whole");
40 for (ProteinBean protein : result) {
41 List<String> thejobs = protein.getJobid();
42 jobid = thejobs.get(0);
43 for (String job : thejobs) {
52 public int findSequence(String sequence, String program, String version) {
53 List<String> jobs = findJobs(sequence, program, version);
61 public String findJobForSequence(String sequence, String program, String version) {
62 List<String> jobs = findJobs(sequence, program, version);
64 for (String job : jobs) {
66 ArchivedJob aj = new ArchivedJob(job);
68 link = aj.prepareJobArchiveToWeb();
69 } catch (IOException e) {
70 log.error("JpredWS.findSequence: IO exception with job archive file");
71 log.error(e.getLocalizedMessage(), e.getCause());
83 public String getArchive(String jobid) {
85 ArchivedJob aj = new ArchivedJob(jobid);
87 link = aj.prepareJobArchiveToWeb();
88 } catch (IOException e) {
89 log.error("JpredWS.findSequence: IO exception with job archive file");
90 log.error(e.getLocalizedMessage(), e.getCause());
92 // if the archive file is not available null is returned
97 public int jobExists(String jobid) {
98 CassandraNativeConnector dbconnector = new CassandraNativeConnector();
99 JobReader reader = new JobReader();
100 reader.setSession(dbconnector.getSession());
101 if (null != reader.readJobLog(jobid)) {