ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/owl/trunk/testDeltaDistanceMap.java
Revision: 517
Committed: Tue Jan 15 13:19:36 2008 UTC (16 years, 8 months ago) by duarte
File size: 2437 byte(s)
Log Message:
Changed Alignment class so that both alignment and sequence indexing are starting at 1 (before alignment indices were starting at 0). Also mapping is now done through arrays not maps.
Changed all other classes using Alignment to accommodate this. 
NOTE: graph averaging hasn't been tested after the change
Line File contents
1 import proteinstructure.*;
2 import java.util.*;
3
4 import edu.uci.ics.jung.graph.util.Pair;
5
6 /**
7 * Calculate a matrix containing the element-wise differences between the distance maps of two proteins
8 * @author stehr
9 *
10 */
11 public class testDeltaDistanceMap {
12
13 /**
14 * Run tests
15 */
16 public static void main(String[] args) {
17 try {
18 String pdbCode1 = "12as";
19 String chainCode1 = "A";
20 String pdbCode2 = "12as";
21 String chainCode2 = "B";
22
23 System.out.println("Loading pdb objects...");
24 Pdb pdb1 = new PdbasePdb("12as");
25 pdb1.load("B");
26 assert(pdb1 != null);
27 Pdb pdb2 = new PdbasePdb("12as");
28 pdb2.load("A");
29 assert(pdb2 != null);
30
31 System.out.println("Calculating distance maps...");
32 HashMap<Pair<Integer>,Double> distMap1 = pdb1.calculate_dist_matrix("Ca");
33 assert(distMap1 != null);
34 HashMap<Pair<Integer>,Double> distMap2 = pdb2.calculate_dist_matrix("Ca");
35 assert(distMap2 != null);
36
37 // create an alignment
38 String name1 = pdbCode1+chainCode1;
39 String name2 = pdbCode2+chainCode2;
40 String[] tags = {name1, name2};
41 String[] seqs = {pdb1.getSequence(), pdb2.getSequence()};
42 Alignment ali = new Alignment(tags, seqs);
43
44 System.out.println("Calculating difference distance map...");
45 HashMap<Pair<Integer>,Double> diffDistMap = pdb1.getDiffDistMap("Ca", pdb2, "Ca", ali, name1, name2);
46 assert(diffDistMap != null);
47 assert(diffDistMap.size() == distMap1.size());
48 assert(diffDistMap.size() == distMap2.size());
49
50 System.out.print("Missing matrix values (dim=" + pdb1.getFullLength() + "): ");
51 int mis = 0;
52 for(int i=1; i<=pdb1.getFullLength();i++) {
53 for(int j=1; j<i;j++) {
54 if(!diffDistMap.containsKey(new Pair<Integer>(j,i))) {
55 //System.out.print("(" + i + "," + j + ") ");
56 mis++;
57 }
58 }
59 }
60 System.out.println(mis);
61
62 Pair<Integer> e = new Pair<Integer>(27,30);
63
64 double dist1 = distMap1.get(e);
65 double dist2 = distMap2.get(e);
66 double diffDist = diffDistMap.get(e);
67 assert(diffDist == Math.abs(dist1 - dist2));
68 double min = Collections.min(diffDistMap.values());
69 double max = Collections.max(diffDistMap.values());
70
71 System.out.println("Checking difference distance map for " + pdbCode1 + chainCode1 + " and " + pdbCode2 + chainCode2);
72 System.out.println("size=" + diffDistMap.size() + " min=" + min + " max= " + max);
73 }
74 catch(Exception e) {
75 e.printStackTrace();
76
77 }
78
79 }
80
81 }