File: ServicesUtil.java

package info (click to toggle)
libjaba-client-java 2.2.0-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 2,052 kB
  • sloc: java: 17,308; makefile: 12
file content (103 lines) | stat: -rw-r--r-- 3,014 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
package compbio.ws.client;

import java.io.File;

import compbio.engine.client.ConfExecutable;
import compbio.engine.client.Executable;
import compbio.runner.conservation.AACon;
//import compbio.runner.predictors.Jpred;
import compbio.runner.disorder.Disembl;
import compbio.runner.disorder.GlobPlot;
import compbio.runner.disorder.IUPred;
import compbio.runner.disorder.Jronn;
import compbio.runner.msa.ClustalO;
import compbio.runner.msa.ClustalW;
import compbio.runner.msa.Mafft;
import compbio.runner.msa.Muscle;
import compbio.runner.msa.Probcons;
import compbio.runner.msa.MSAprobs;
import compbio.runner.msa.GLprobs;
import compbio.runner.msa.Tcoffee;
import compbio.runner.structure.RNAalifold;

public class ServicesUtil {

	public static Services getServiceByRunner(Class<? extends Executable> class1) {
		assert class1 != null;
		String sname = class1.getSimpleName().toLowerCase();
		for (Services service : Services.values()) {
			if (service.toString().toLowerCase().contains(sname)) {
				return service;
			}
		}
		return null;
	}

	private static Class<? extends Executable<?>> getServiceImpl(Services service) {
		switch (service) {
			case AAConWS :
				return AACon.class;
//			case JpredWS :
//				return Jpred.class;
			case ClustalOWS :
				return ClustalO.class;
			case ClustalWS :
				return ClustalW.class;
			case MafftWS :
				return Mafft.class;
			case MuscleWS :
				return Muscle.class;
			case TcoffeeWS :
				return Tcoffee.class;
			case ProbconsWS :
				return Probcons.class;
			case MSAprobsWS :
				return MSAprobs.class;
			case GLprobsWS :
				return GLprobs.class;
			case DisemblWS :
				return Disembl.class;
			case GlobPlotWS :
				return GlobPlot.class;
			case JronnWS :
				return Jronn.class;
			case IUPredWS :
				return IUPred.class;
			case RNAalifoldWS :
				return RNAalifold.class;
			default :
				throw new RuntimeException("Unknown web service implementation class for service: " + service);
		}
	}

	public static Class<? extends Executable<?>> getRunnerByJobDirectory(File jobdir) {
		Services service = getServiceByRunnerName(getRunnerNameByJobDirectory(jobdir));
		return getServiceImpl(service);
	}

	private static String getRunnerNameByJobDirectory(File jobdir) {
		String name = jobdir.getName().split("#")[0];

		if (name.startsWith(ConfExecutable.CLUSTER_TASK_ID_PREFIX)) {
			assert ConfExecutable.CLUSTER_TASK_ID_PREFIX.length() == 1;
			name = name.substring(1);
		}
		return name;
	}

	public static Services getServiceByJobDirectory(File jobdir) {
		return getServiceByRunnerName(getRunnerNameByJobDirectory(jobdir));
	}

	private static Services getServiceByRunnerName(String name) {
		for (Services service : Services.values()) {
			String runnerName = getServiceImpl(service).getSimpleName().toLowerCase();
			name = name.trim().toLowerCase();
			if (name.startsWith(runnerName)) {
				return service;
			}
		}
		return null;
	}

}