-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMonteCarloResult.java
51 lines (45 loc) · 1.5 KB
/
MonteCarloResult.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import java.util.*;
import com.google.common.collect.*;
public class MonteCarloResult implements Result, Immutable
{
/** the best results from the minimization */
public final ImmutableList<Peptide> bestPeptides;
public MonteCarloResult(List<Peptide> bestPeptides)
{
// check that each peptide has an EnergyBreakdown
for (Peptide p : bestPeptides)
if ( p.energyBreakdown == null || p.energyBreakdown == EnergyBreakdown.BLANK )
throw new IllegalArgumentException("missing energy breakdown for peptide " + p.name);
this.bestPeptides = ImmutableList.copyOf(bestPeptides);
}
@Override
public int hashCode()
{
return Objects.hash(bestPeptides);
}
@Override
public boolean equals(Object obj)
{
if ( obj == null )
return false;
if ( obj == this )
return true;
if ( !(obj instanceof MonteCarloResult) )
return false;
MonteCarloResult r = (MonteCarloResult)obj;
if ( this.bestPeptides.equals(r.bestPeptides) )
return true;
return false;
}
@Override
public String toString()
{
String returnString = "[";
for (Peptide p : bestPeptides)
returnString += String.format("%.1f, ", p.energyBreakdown.totalEnergy);
if ( returnString.length() > 1 )
returnString = returnString.substring(0,returnString.length()-2);
returnString += "]";
return returnString;
}
}