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 |
System.out.println("Calculating difference distance map..."); |
38 |
HashMap<Pair<Integer>,Double> diffDistMap = pdb1.getDiffDistMap("Ca", pdb2, "Ca"); |
39 |
assert(diffDistMap != null); |
40 |
assert(diffDistMap.size() == distMap1.size()); |
41 |
assert(diffDistMap.size() == distMap2.size()); |
42 |
|
43 |
System.out.print("Missing matrix values (dim=" + pdb1.getFullLength() + "): "); |
44 |
int mis = 0; |
45 |
for(int i=1; i<=pdb1.getFullLength();i++) { |
46 |
for(int j=1; j<i;j++) { |
47 |
if(!diffDistMap.containsKey(new Pair<Integer>(j,i))) { |
48 |
//System.out.print("(" + i + "," + j + ") "); |
49 |
mis++; |
50 |
} |
51 |
} |
52 |
} |
53 |
System.out.println(mis); |
54 |
|
55 |
Pair<Integer> e = new Pair<Integer>(27,30); |
56 |
|
57 |
double dist1 = distMap1.get(e); |
58 |
double dist2 = distMap2.get(e); |
59 |
double diffDist = diffDistMap.get(e); |
60 |
assert(diffDist == Math.abs(dist1 - dist2)); |
61 |
double min = Collections.min(diffDistMap.values()); |
62 |
double max = Collections.max(diffDistMap.values()); |
63 |
|
64 |
System.out.println("Checking difference distance map for " + pdbCode1 + chainCode1 + " and " + pdbCode2 + chainCode2); |
65 |
System.out.println("size=" + diffDistMap.size() + " min=" + min + " max= " + max); |
66 |
} |
67 |
catch(Exception e) { |
68 |
e.printStackTrace(); |
69 |
|
70 |
} |
71 |
|
72 |
} |
73 |
|
74 |
} |