ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/owl/trunk/proteinstructure/Box.java
Revision: 433
Committed: Tue Nov 27 17:58:26 2007 UTC (16 years, 10 months ago) by duarte
Original Path: branches/aglappe-jung/proteinstructure/Box.java
File size: 2476 byte(s)
Log Message:
Added more comments

Line User Rev File contents
1 duarte 226 package proteinstructure;
2    
3     import java.util.TreeMap;
4     import javax.vecmath.Point3d;
5     import javax.vecmath.Point3i;
6    
7     public class Box {
8    
9     Point3i floor;
10    
11 duarte 228 private TreeMap<Integer,Point3d> i_pointsInBox;
12     private TreeMap<Integer,Point3d> j_pointsInBox;
13 duarte 226
14     public Box(Point3i floor){
15     this.floor=floor;
16 duarte 228 i_pointsInBox = new TreeMap<Integer, Point3d>();
17     j_pointsInBox = new TreeMap<Integer, Point3d>();
18 duarte 226 }
19    
20 duarte 228 public void put_i_Point(int serial, Point3d point){
21     i_pointsInBox.put(serial, point);
22 duarte 226 }
23    
24 duarte 228 public void put_j_Point(int serial, Point3d point){
25     j_pointsInBox.put(serial, point);
26     }
27    
28 duarte 421 public void getDistancesWithinBox(float[][] distMatrix, boolean crossed){ //we pass a reference to the distMatrix that we alter within this method
29 duarte 228 for (int i_serial:i_pointsInBox.keySet()) {
30     for (int j_serial:j_pointsInBox.keySet()) {
31 duarte 421 if (!crossed) {
32 duarte 228 if (j_serial>i_serial) {
33     // this only works if previously we have made sure that atom serials are sequential from 0 to MAXATOMSERIAL
34 duarte 282 distMatrix[i_serial][j_serial] = (float)i_pointsInBox.get(i_serial).distance(j_pointsInBox.get(j_serial));
35 duarte 228 }
36     } else {
37 duarte 433 // We need to check this because it can happen when the 2 contact types (i/j) have overlapping atoms, e.g. ALL/BB
38     // It is not strictly necessary, because distance in case i=j would be 0 (atom to itself). It's just to make sure that
39     // there wouldn't be rounding problems in comparing to 0.0 in get_graph in Pdb
40     if (j_serial!=i_serial) {
41 duarte 421 distMatrix[i_serial][j_serial] = (float)i_pointsInBox.get(i_serial).distance(j_pointsInBox.get(j_serial));
42     }
43 duarte 226 }
44     }
45     }
46    
47     }
48    
49 duarte 421 public void getDistancesToNeighborBox(Box nbBox ,float[][] distMatrix, boolean crossed){
50 duarte 228 for (int i_serial:i_pointsInBox.keySet()){
51     for (int j_serial:nbBox.j_pointsInBox.keySet()){
52 duarte 421 if (!crossed) {
53 duarte 228 if (j_serial>i_serial) {
54     // this only works if previously we have made sure that atom serials are sequential from 0 to MAXATOMSERIAL
55 duarte 282 if (distMatrix[i_serial][j_serial]==0.0f){ // i.e. if we haven't passed through this cell yet
56     distMatrix[i_serial][j_serial] = (float)i_pointsInBox.get(i_serial).distance(nbBox.j_pointsInBox.get(j_serial));
57 duarte 228 }
58 duarte 226 }
59 duarte 228 } else {
60 duarte 282 distMatrix[i_serial][j_serial] = (float)i_pointsInBox.get(i_serial).distance(nbBox.j_pointsInBox.get(j_serial));
61 duarte 226 }
62     }
63     }
64     }
65    
66 stehr 250 // Beware, this returns only the size for i
67     public int size() {
68     return i_pointsInBox.size();
69     }
70    
71 duarte 226 }