ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/owl/trunk/testDeltaDistanceMap.java
Revision: 419
Committed: Thu Nov 22 14:09:18 2007 UTC (16 years, 11 months ago) by duarte
Original Path: branches/aglappe-jung/testDeltaDistanceMap.java
File size: 2044 byte(s)
Log Message:
Re-branching for JUNG2 development
Line File contents
1 import proteinstructure.*;
2 import java.util.*;
3
4 /**
5 * Calculate a matrix containing the element-wise differences between the distance maps of two proteins
6 * @author stehr
7 *
8 */
9 public class testDeltaDistanceMap {
10
11 /**
12 * Run tests
13 */
14 public static void main(String[] args) {
15 try {
16 String pdbCode1 = "12as";
17 String chainCode1 = "A";
18 String pdbCode2 = "12as";
19 String chainCode2 = "B";
20
21 System.out.println("Loading pdb objects...");
22 Pdb pdb1 = new PdbasePdb("12as", "B");
23 assert(pdb1 != null);
24 Pdb pdb2 = new PdbasePdb("12as", "A");
25 assert(pdb2 != null);
26
27 System.out.println("Calculating distance maps...");
28 HashMap<Edge,Double> distMap1 = pdb1.calculate_dist_matrix("Ca");
29 assert(distMap1 != null);
30 HashMap<Edge,Double> distMap2 = pdb2.calculate_dist_matrix("Ca");
31 assert(distMap2 != null);
32
33 System.out.println("Calculating difference distance map...");
34 HashMap<Edge,Double> diffDistMap = pdb1.getDiffDistMap("Ca", pdb2, "Ca");
35 assert(diffDistMap != null);
36 assert(diffDistMap.size() == distMap1.size());
37 assert(diffDistMap.size() == distMap2.size());
38
39 System.out.print("Missing matrix values (dim=" + pdb1.getFullLength() + "): ");
40 int mis = 0;
41 for(int i=1; i<=pdb1.getFullLength();i++) {
42 for(int j=1; j<i;j++) {
43 if(!diffDistMap.containsKey(new Edge(j,i))) {
44 //System.out.print("(" + i + "," + j + ") ");
45 mis++;
46 }
47 }
48 }
49 System.out.println(mis);
50
51 Edge e = new Edge(27,30);
52
53 double dist1 = distMap1.get(e);
54 double dist2 = distMap2.get(e);
55 double diffDist = diffDistMap.get(e);
56 assert(diffDist == Math.abs(dist1 - dist2));
57 double min = Collections.min(diffDistMap.values());
58 double max = Collections.max(diffDistMap.values());
59
60 System.out.println("Checking difference distance map for " + pdbCode1 + chainCode1 + " and " + pdbCode2 + chainCode2);
61 System.out.println("size=" + diffDistMap.size() + " min=" + min + " max= " + max);
62 }
63 catch(Exception e) {
64 e.printStackTrace();
65
66 }
67
68 }
69
70 }