ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/owl/trunk/proteinstructure/EC.java
Revision: 502
Committed: Tue Jan 8 11:00:15 2008 UTC (16 years, 9 months ago) by stehr
File size: 2497 byte(s)
Log Message:
EC, CatalSiteSet: added typing to some iterators to avoid eclipse warning
Interval: added typing to Comparator to avoid eclipse warning
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.Vector;
7    
8     /** This class encapsulates the EC annotation of a single protein chain. */
9     public class EC {
10    
11     /*--------------------------- member variables --------------------------*/
12    
13     private HashMap<Integer,HashSet<ECRegion>> resser2ecregion; // residue serials to set of ec regions
14     private Vector<ECRegion> ecRegions; // the actual collection of ec regions
15    
16     /*----------------------------- constructors ----------------------------*/
17    
18     /** Create an empty ec object */
19     public EC() {
20     this.ecRegions = new Vector<ECRegion>();
21     this.resser2ecregion = new HashMap<Integer,HashSet<ECRegion>>();
22     }
23    
24     /*---------------------------- public methods ---------------------------*/
25    
26     /**
27     * Add the given ec region to this ec object.
28     */
29     public void add(ECRegion e) {
30     this.ecRegions.add(e);
31     Interval intv = e.getInterval();
32     for(int i = intv.beg; i <= intv.end; i++) {
33     HashSet<ECRegion> values = resser2ecregion.get(i);
34     if (values == null) {
35     values = new HashSet<ECRegion>();
36     resser2ecregion.put(i,values);
37     }
38     values.add(e);
39     }
40     }
41    
42     /**
43     * Returns true iff this ec object contains no scop regions.
44     */
45     public boolean isEmpty() {
46     return this.ecRegions.isEmpty();
47     }
48    
49     /**
50     * Returns an iterator over all assigned ec regions in this object.
51     */
52     public Iterator<ECRegion> getIterator() {
53     return ecRegions.iterator();
54     }
55    
56     /**
57     * For a given residue returns the ec regions this residue participates in,
58     * or null if the residue is not in an assigned ec region.
59     */
60     public HashSet<ECRegion> getECRegion(int resser){
61     if(resser2ecregion.containsKey(resser)) {
62     return this.resser2ecregion.get(resser);
63     } else {
64     return null;
65     }
66     }
67    
68     public String getECNum(int resser) {
69     String ecNums = null;
70     if (resser2ecregion.containsKey(resser)) {
71     ecNums = "";
72     HashSet<ECRegion> ecs = getECRegion(resser);
73 stehr 502 Iterator<ECRegion> it = ecs.iterator();
74 filippis 382 while (it.hasNext()) {
75     ECRegion er = (ECRegion)it.next();
76     ecNums += er.getECNum();
77     if (it.hasNext()) {
78     ecNums += ",";
79     }
80     }
81     }
82     return ecNums;
83     }
84    
85     /** Return a deep copy of this ec object */
86     public EC copy() {
87     EC newS = new EC();
88     for(ECRegion e:ecRegions) {
89     newS.add(e.copy());
90     }
91     return newS;
92     }
93    
94     /** Returns the number of ec regions in this ec object */
95     public int getNumRegions() {
96     return this.ecRegions.size();
97     }
98     }