Here's the method - but one thing I find strange is that on from the first to the second profile i reorganized some of the methods - but then the large time consumption just moved in the call hierachy.
And also - I wonder what the time that is not marked as "self" in a method is spent on (except other methods). The numbers dont add up. "self" + "other methods" < total time.
-Anders /** * Calculate the entire energy for this protein. This is done by an all vs * all check. However the energy is symmetric, so if A <-> B is done, then * avoid B <-> A. * * @return whether a hard-core overlap was detected */ public boolean calcEnergy() { // update the Energy
totalEnergy = 0;
boolean overlap = false; for (int i = 0; i < ncalf; i++) { Monomer monI = monomers[i];
for (int j = i; j < ncalf; j++) { Monomer monJ = monomers[j]; int indexDist = Math.abs(j - i);
> Actually it's EnergyMatrix.calcEnergy where all the time is going, right?
Well, it depends - in profile1 it looks that way. But after a bit of code - reorg - in profile2 it is Protein.calcEnergy that takes all the time. And the really strange part is that the "EnergyMatrix.calcEnergy" that takes all the time in profile1 is the two-parameter one of the two methods below. This is why I question if I understand the profiles correctly?
Anders
/** * Calculate the contact energy between the two monomers * * @param m1 * @param m2 * @return the contact energy value */ public static double calcEnergy(Monomer m1, Monomer m2){ return calcEnergy(m1, m2, m2.pos); }
/** * Calculate the contact energy between the two monomers * * @param m1 * @param m2 * @param m2Pos the position to be used for m2 in stead of * m2.pos * @return the contact energy value */ public static double calcEnergy(Monomer m1, Monomer m2, Point m2Pos){ final float energy = matrix[m1.aa.ordinal()][m2.aa.ordinal()]; double dist = m1.pos.distanceTo(m2Pos); double ddist = dist - m1.aa.size - m2.aa.size; //TODO clean up return energy*distanceFactor(ddist); } [ November 07, 2005: Message edited by: Anders Norgaard ]