ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/owl/trunk/proteinstructure/CatalSiteSet.java
Revision: 514
Committed: Fri Jan 11 14:59:43 2008 UTC (16 years, 9 months ago) by filippis
File size: 4928 byte(s)
Log Message:
Latest scop and csa versions updated.
Line User Rev File contents
1 filippis 382 package proteinstructure;
2    
3     import java.util.HashMap;
4     import java.util.HashSet;
5     import java.util.Iterator;
6     import java.util.Set;
7     import java.util.Vector;
8    
9     /** This class encapsulates the catalytic site annotation of a single protein chain. */
10     public class CatalSiteSet {
11    
12     /*------------------------------ constants ------------------------------*/
13    
14 filippis 514 private static final String LATEST_VERSION = "2.2.7"; // default version
15 filippis 382
16     /*--------------------------- member variables --------------------------*/
17    
18     private HashMap<Integer,HashSet<CatalyticSite>> resser2catalsite; // residue serials to set of catalytic sites
19     private Vector<CatalyticSite> catalyticSites; // the actual collection of catalytic sites
20     private String version; // an optional comment describing the version of the catalytic site annotation
21    
22     /*----------------------------- constructors ----------------------------*/
23    
24     /** Create an empty catalytic site object */
25     public CatalSiteSet() {
26     this.catalyticSites = new Vector<CatalyticSite>();
27     this.resser2catalsite = new HashMap<Integer,HashSet<CatalyticSite>>();
28     this.version = LATEST_VERSION;
29     }
30    
31     /*---------------------------- public methods ---------------------------*/
32    
33     /**
34     * Add the given catalytic site to this set of catalytic sites object.
35     */
36     public void add(CatalyticSite e) {
37     this.catalyticSites.add(e);
38     Set<Integer> ressers = e.getRes();
39 stehr 502 Iterator<Integer> iter = ressers.iterator();
40 filippis 382 while (iter.hasNext()) {
41     int resser = (Integer)iter.next();
42     HashSet<CatalyticSite> values = resser2catalsite.get(resser);
43     if (values == null) {
44     values = new HashSet<CatalyticSite>();
45     resser2catalsite.put(resser,values);
46     }
47     values.add(e);
48     }
49     }
50    
51     /**
52     * Returns true iff this catalytic sites set object contains no catalytic sites.
53     */
54     public boolean isEmpty() {
55     return this.catalyticSites.isEmpty();
56     }
57    
58     /**
59     * Returns an iterator over all assigned catalytic sites in this object.
60     */
61     public Iterator<CatalyticSite> getIterator() {
62     return catalyticSites.iterator();
63     }
64    
65     /**
66     * For a given residue returns the catalytic sites this residue participates in,
67     * or null if the residue is not in an assigned catalytic site.
68     */
69     public HashSet<CatalyticSite> getCatalSite(int resser){
70     if(resser2catalsite.containsKey(resser)) {
71     return this.resser2catalsite.get(resser);
72     } else {
73     return null;
74     }
75     }
76    
77     public String getCatalSiteNum(int resser) {
78     String csNums = null;
79     if (resser2catalsite.containsKey(resser)) {
80     csNums = "";
81     HashSet<CatalyticSite> css = getCatalSite(resser);
82 stehr 502 Iterator<CatalyticSite> it = css.iterator();
83 filippis 382 while (it.hasNext()) {
84     CatalyticSite cs = (CatalyticSite)it.next();
85     csNums += cs.getSerial();
86     if (it.hasNext()) {
87     csNums += ",";
88     }
89     }
90     }
91     return csNums;
92     }
93    
94     public String getCatalSiteChemFunc(int resser) {
95     String csChemFuncs = null;
96     if (resser2catalsite.containsKey(resser)) {
97     csChemFuncs = "";
98     HashSet<CatalyticSite> css = getCatalSite(resser);
99 stehr 502 Iterator<CatalyticSite> it = css.iterator();
100 filippis 382 while (it.hasNext()) {
101     CatalyticSite cs = (CatalyticSite)it.next();
102     csChemFuncs += cs.getChemFuncFromResSerial(resser);
103     if (it.hasNext()) {
104     csChemFuncs += ",";
105     }
106     }
107     }
108     return csChemFuncs;
109     }
110    
111     public String getCatalSiteEvid(int resser) {
112     String csEvids = null;
113     if (resser2catalsite.containsKey(resser)) {
114     csEvids = "";
115     HashSet<CatalyticSite> css = getCatalSite(resser);
116 stehr 502 Iterator<CatalyticSite> it = css.iterator();
117 filippis 382 while (it.hasNext()) {
118     CatalyticSite cs = (CatalyticSite)it.next();
119     csEvids += cs.getEvidence();
120     if (it.hasNext()) {
121     csEvids += ",";
122     }
123     }
124     }
125     return csEvids;
126     }
127    
128 filippis 503 public void removeCatalSiteRes(int resser) {
129     if (resser2catalsite.containsKey(resser)) {
130     HashSet<CatalyticSite> css = getCatalSite(resser);
131 stehr 504 Iterator<CatalyticSite> it = css.iterator();
132 filippis 503 while (it.hasNext()) {
133     CatalyticSite cs = (CatalyticSite)it.next();
134     cs.remRes(resser);
135     if (cs.getRes().size() == 0) {
136     catalyticSites.remove(cs);
137     }
138     }
139     resser2catalsite.remove(resser);
140     }
141     }
142    
143 filippis 382 /** Return a deep copy of this catalytic site set object */
144     public CatalSiteSet copy() {
145     CatalSiteSet newS = new CatalSiteSet();
146     for(CatalyticSite e:catalyticSites) {
147     newS.add(e.copy());
148     }
149     return newS;
150     }
151    
152     /** Sets the version to c */
153     public void setVersion(String c) {
154     this.version = c;
155     }
156    
157     /** Returns the version */
158     public String getVersion() {
159     return this.version;
160     }
161    
162     /** Returns the number of catalytic sites in this catalytic sites set object */
163     public int getNumCatalSites() {
164     return this.catalyticSites.size();
165     }
166    
167     public void print() {
168 stehr 502 Iterator<CatalyticSite> iterator = catalyticSites.iterator ();
169 filippis 382 while (iterator.hasNext ()) {
170     CatalyticSite cs = (CatalyticSite)iterator.next();
171     cs.print();
172     }
173     }
174     }