code: public static double getRefRMSD(List<Atom[]> transformed, int reference) {
  
  		double sumSqDist = 0;
  		int totalLength = 0;
  		for (int c = 0; c < transformed.get(reference).length; c++) {
  			Atom refAtom = transformed.get(reference)[c];
  			if (refAtom == null)
  				continue;
  
  			double nonNullSqDist = 0;
  			int nonNullLength = 0;
  			for (int r = 0; r < transformed.size(); r++) {
  				if (r == reference)
  					continue;
  				Atom atom = transformed.get(r)[c];
  				if (atom != null) {
  					nonNullSqDist += Calc.getDistanceFast(refAtom, atom);
  					nonNullLength++;
  				}
  			}
  
  			if (nonNullLength > 0) {
  				totalLength++;
  				sumSqDist += nonNullSqDist / nonNullLength;
  			}
  		}
  		return Math.sqrt(sumSqDist / totalLength);
  	}
docs: Calculates the average RMSD from all structures to a reference s
  tructure, given a set of superimposed atoms.
  <p>
  Complexity: T(n,l) = O(l*n), if n=number of structures and l=alignment
  length.
  <p>
  For ungapped alignments, this is just the sqroot of the average distance
  from an atom to the aligned atom from the reference. Thus, for R
  structures aligned over C columns (with structure 0 as the reference), we
  have:
  
  <pre>
  RefRMSD = \sqrt{ 1/(C*(R-1)) * \sum_{r=1}^{R-1} \sum_{j=0}^{C-1}
  (atom[1][c]-atom[r][c])^2 }
  </pre>
  <p>
  For gapped alignments, null atoms are omitted from consideration, so that
  the RMSD is the average over all columns with non-null reference of the
  average RMSD within the non-null elements of the column.
  
  @param transformed
  @param reference
  @return