code: public static double getAvgTMScore(List<Atom[]> transformed,
  			List<Integer> lengths) throws StructureException {
  
  		if (transformed.size() != lengths.size())
  			throw new IllegalArgumentException("Input sizes differ.");
  
  		double sumTM = 0;
  		int comparisons = 0;
  
  		for (int r1 = 0; r1 < transformed.size(); r1++) {
  			for (int r2 = r1 + 1; r2 < transformed.size(); r2++) {
  				int len = transformed.get(r1).length;
  				// Remove nulls from both arrays
  				Atom[] ref = new Atom[len];
  				Atom[] aln = new Atom[len];
  				int nonNullLen = 0;
  				for (int c = 0; c < len; c++) {
  					if (transformed.get(r1)[c] != null
  							&& transformed.get(r2)[c] != null) {
  						ref[nonNullLen] = transformed.get(r1)[c];
  						aln[nonNullLen] = transformed.get(r2)[c];
  						nonNullLen++;
  					}
  				}
  				// Truncate nulls
  				if (nonNullLen < len) {
  					ref = Arrays.copyOf(ref, nonNullLen);
  					aln = Arrays.copyOf(aln, nonNullLen);
  				}
  				sumTM += Calc.getTMScore(ref, aln, lengths.get(r1),
  						lengths.get(r2));
  				comparisons++;
  			}
  		}
  		return sumTM / comparisons;
  	}
docs: Calculates the average TMScore all the possible pairwise structure
  comparisons of the given a set of superimposed Atoms and the original
  structure lengths.
  <p>
  Complexity: T(n,l) = O(l*n^2), if n=number of structures and l=alignment
  length.
  
  @param transformed
  aligned Atoms transformed
  @param lengths
  lengths of the structures in residue number
  @return double Average TMscore
  @throws StructureException