BitSet bsNearbyResidues = new BitSet(); // [ipt]
// check for a strut. We are going to set struts within 3 residues
// of the ends of biopolymers, so we track those positions as well.
Atom a1 = (Atom) vCA.get(0);
Atom a2;
int nBiopolymers = modelSet.getBioPolymerCountInModel(a1.modelIndex);
int[][] biopolymerStartsEnds = new int[nBiopolymers][nEndMin * 2];
for (int i = 0; i < n; i++) {
a1 = (Atom) vCA.get(i);
int polymerIndex = a1.getPolymerIndexInModel();
int monomerIndex = a1.getMonomerIndex();
int bpt = monomerIndex;
if (bpt < nEndMin)
biopolymerStartsEnds[polymerIndex][bpt] = i + 1;
bpt = ((Monomer) a1.getGroup()).getBioPolymerLength() - monomerIndex - 1;
if (bpt < nEndMin)
biopolymerStartsEnds[polymerIndex][nEndMin + bpt] = i + 1;
}
// Get all distances.
// For n CA positions, there will be n(n-1)/2 distances needed.
// There is no need for a full matrix X[i][j]. Instead, we just count
// carefully using the variable ipt:
//
// ipt = i * (2 * n - i - 1) / 2 + j - i - 1
float[] d2 = new float[n * (n - 1) / 2];
for (int i = 0; i < n; i++) {
a1 = (Atom) vCA.get(i);
for (int j = i + 1; j < n; j++) {
int ipt = strutPoint(i, j, n);
a2 = (Atom) vCA.get(j);
int resno1 = a1.getResno();
int polymerIndex1 = a1.getPolymerIndexInModel();
int resno2 = a2.getResno();
int polymerIndex2 = a2.getPolymerIndexInModel();
if (polymerIndex1 == polymerIndex2 && Math.abs(resno2 - resno1) < delta)
bsNearbyResidues.set(ipt);
float d = d2[ipt] = a1.distanceSquared(a2);
if (d >= thresh2)
bsNotAvailable.set(ipt);