code: public static double getRefTMScore(List<Atom[]> transformed,
  			List<Integer> lengths, int reference) throws StructureException {
  
  		if (transformed.size() != lengths.size())
  			throw new IllegalArgumentException("Input sizes differ");
  
  		double sumTM = 0;
  		int comparisons = 0;
  
  		int len = transformed.get(reference).length;
  		for (int r = 0; r < transformed.size(); r++) {
  			if (r == reference)
  				continue;
  			// 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(reference)[c] != null
  						&& transformed.get(r)[c] != null) {
  					ref[nonNullLen] = transformed.get(reference)[c];
  					aln[nonNullLen] = transformed.get(r)[c];
  					nonNullLen++;
  				}
  			}
  			// truncate nulls
  			if (nonNullLen < len) {
  				ref = Arrays.copyOf(ref, nonNullLen);
  				aln = Arrays.copyOf(aln, nonNullLen);
  			}
  			sumTM += Calc.getTMScore(ref, aln,
  					lengths.get(reference), lengths.get(r));
  			comparisons++;
  		}
  		return sumTM / comparisons;
  	}
docs: Calculates the average TMScore from all structures to a reference
  structure, given a set of superimposed atoms.
  <p>
  Complexity: T(n,l) = O(l*n^2), if n=number of structures and l=alignment
  length.
  
  @param transformed
  Arrays of aligned atoms, after superposition
  @param lengths
  lengths of the full input structures
  @param reference
  Index of the reference structure
  @return
  @throws StructureException