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 File contents
1 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 private TreeMap<Integer,Point3d> i_pointsInBox;
12 private TreeMap<Integer,Point3d> j_pointsInBox;
13
14 public Box(Point3i floor){
15 this.floor=floor;
16 i_pointsInBox = new TreeMap<Integer, Point3d>();
17 j_pointsInBox = new TreeMap<Integer, Point3d>();
18 }
19
20 public void put_i_Point(int serial, Point3d point){
21 i_pointsInBox.put(serial, point);
22 }
23
24 public void put_j_Point(int serial, Point3d point){
25 j_pointsInBox.put(serial, point);
26 }
27
28 public void getDistancesWithinBox(float[][] distMatrix, boolean crossed){ //we pass a reference to the distMatrix that we alter within this method
29 for (int i_serial:i_pointsInBox.keySet()) {
30 for (int j_serial:j_pointsInBox.keySet()) {
31 if (!crossed) {
32 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 distMatrix[i_serial][j_serial] = (float)i_pointsInBox.get(i_serial).distance(j_pointsInBox.get(j_serial));
35 }
36 } else {
37 // 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 distMatrix[i_serial][j_serial] = (float)i_pointsInBox.get(i_serial).distance(j_pointsInBox.get(j_serial));
42 }
43 }
44 }
45 }
46
47 }
48
49 public void getDistancesToNeighborBox(Box nbBox ,float[][] distMatrix, boolean crossed){
50 for (int i_serial:i_pointsInBox.keySet()){
51 for (int j_serial:nbBox.j_pointsInBox.keySet()){
52 if (!crossed) {
53 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 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 }
58 }
59 } else {
60 distMatrix[i_serial][j_serial] = (float)i_pointsInBox.get(i_serial).distance(nbBox.j_pointsInBox.get(j_serial));
61 }
62 }
63 }
64 }
65
66 // Beware, this returns only the size for i
67 public int size() {
68 return i_pointsInBox.size();
69 }
70
71 }