File: Category.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 (122 lines) | stat: -rw-r--r-- 3,586 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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
/**
 * Class that splits {@link Services} to categories. Services themselves have no
 * knowledge which category they belongs to.
 * 
 * This class is responsible for initialization of all the categories (done
 * statically) and holds the category names as constrains.
 * 
 * Two categories considered equals if their names are equals.
 * 
 * @author pvtroshin
 * @version 1.0 September 2011
 */

package compbio.data.msa;

import java.util.HashSet;
import java.util.Set;
import java.util.TreeSet;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;

import compbio.ws.client.Services;

@XmlAccessorType(XmlAccessType.FIELD)
public class Category {
	/*
	 * TODO refactor initialization and constrains into separate classes if
	 * further complexity is expected.
	 */

	/**
	 * All of the Category names
	 */
	public static final String CATEGORY_ALIGNMENT = "Alignment";
	public static final String CATEGORY_DISORDER = "Protein Disorder";
	public static final String CATEGORY_CONSERVATION = "Conservation";
	public static final String CATEGORY_PREDICTION = "Prediction";

	public String name;
	Set<Services> services;

	private Category(String name, Set<Services> services) {
		this.name = name;
		this.services = services;
	}

	private Category() {
		// Default constructor for JAXB
	}

	public Set<Services> getServices() {
		return new TreeSet<Services>(services);
	}

	public static Set<Category> getCategories() {
		return init();
	}

	private static Set<Category> init() {
		Set<Services> align_services = new HashSet<Services>();
		align_services.add(Services.ClustalOWS);
		align_services.add(Services.ClustalWS);
		align_services.add(Services.MafftWS);
		align_services.add(Services.MuscleWS);
		align_services.add(Services.ProbconsWS);
		align_services.add(Services.MSAprobsWS);
		align_services.add(Services.GLprobsWS);
		align_services.add(Services.TcoffeeWS);
		Category alignment = new Category(CATEGORY_ALIGNMENT, align_services);

		Set<Services> disorder_services = new HashSet<Services>();
		disorder_services.add(Services.DisemblWS);
		disorder_services.add(Services.GlobPlotWS);
		disorder_services.add(Services.IUPredWS);
		disorder_services.add(Services.JronnWS);
		Category disorder = new Category(CATEGORY_DISORDER, disorder_services);

		Set<Services> conservation_services = new HashSet<Services>();
		conservation_services.add(Services.AAConWS);
		Category conservation = new Category(CATEGORY_CONSERVATION, conservation_services);

		Set<Services> prediction_services = new HashSet<Services>();
//		prediction_services.add(Services.JpredWS);
		prediction_services.add(Services.RNAalifoldWS);
		Category prediction = new Category(CATEGORY_PREDICTION, prediction_services);

		Set<Category> categories = new HashSet<Category>();
		categories.add(alignment);
		categories.add(disorder);
		categories.add(conservation);
		categories.add(prediction);

		return categories;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((name == null) ? 0 : name.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Category other = (Category) obj;
		if (name == null) {
			if (other.name != null)
				return false;
		} else if (!name.equals(other.name))
			return false;
		return true;
	}

}