1 |
package graphAveraging; |
2 |
|
3 |
/** |
4 |
* |
5 |
* A square in phi/psi angle space. Think of a square region in a Ramachandran plot. |
6 |
* We use 1st, 2nd dimension to refer to phi and psi dimensions |
7 |
* |
8 |
*/ |
9 |
public class ConsensusSquare { |
10 |
|
11 |
private ConsensusInterval consInterval1stDim; // the interval containing the phi angles |
12 |
private ConsensusInterval consInterval2ndDim; // the interval containing the psi angles |
13 |
|
14 |
public ConsensusSquare (ConsensusInterval consInterval1stDim, ConsensusInterval consInterval2ndDim) { |
15 |
this.consInterval1stDim = consInterval1stDim; |
16 |
this.consInterval2ndDim = consInterval2ndDim; |
17 |
checkInput(); |
18 |
} |
19 |
|
20 |
private void checkInput() { |
21 |
if (consInterval1stDim.getVoteCount()!=consInterval2ndDim.getVoteCount()) { |
22 |
throw new IllegalArgumentException("Different voter count for the 2 ConsensusInterval passed to constructor of this ConsensusSquare"); |
23 |
} |
24 |
for (String voter:consInterval1stDim.getVoters()) { |
25 |
if (!consInterval2ndDim.contains(voter)) { |
26 |
throw new IllegalArgumentException("Different voters found in the 2 ConsensusInterval passed to constructor of this ConsensusSquare"); |
27 |
} |
28 |
} |
29 |
} |
30 |
|
31 |
public boolean equals(Object o) { |
32 |
if (! (o instanceof ConsensusSquare)) { |
33 |
return false; |
34 |
} |
35 |
ConsensusSquare other = (ConsensusSquare) o; |
36 |
if (! other.getConsInterval1stDim().equals(this.consInterval1stDim)) { |
37 |
return false; |
38 |
} |
39 |
if (! other.getConsInterval2ndDim().equals(this.consInterval2ndDim)) { |
40 |
return false; |
41 |
} |
42 |
return true; |
43 |
} |
44 |
|
45 |
public int getVoteCount() { |
46 |
// we've already checked with checkInput than the 2 dimensions have the same vote count, so we can safely return the count from the first |
47 |
return this.consInterval1stDim.getVoteCount(); |
48 |
} |
49 |
|
50 |
public ConsensusInterval getConsInterval1stDim () { |
51 |
return consInterval1stDim; |
52 |
} |
53 |
|
54 |
public ConsensusInterval getConsInterval2ndDim () { |
55 |
return consInterval2ndDim; |
56 |
} |
57 |
|
58 |
} |