Program: 16688
Project: 16688
Buggy source:
/** 
 * Generate a Jmol command String that colors the aligned residues of every structure.
 * @param multAln
 * @param atomArrays
 * @throws StructureAlignmentException 
 */
private static String getJmolString(MultipleAlignment multAln,List<Atom[]> atomArrays,Color[] colors) throws StructureAlignmentException {
  if (multAln.getBlockSets().size() > 1)   return getMultiBlockJmolString(multAln,atomArrays,colors);
 else   if (multAln.getBlockSets().get(0).getBlocks().size() > 1)   return getMultiBlockJmolString(multAln,atomArrays,colors);
  StringBuffer j=new StringBuffer();
  j.append(DEFAULT_SCRIPT);
  StringBuffer sel=new StringBuffer();
  sel.append("String_Node_Str");
  List<List<String>> allPDB=new ArrayList<List<String>>();
  for (int i=0; i < multAln.size(); i++) {
    List<String> pdb=DisplayAFP.getPDBresnum(i,multAln,atomArrays.get(i));
    allPDB.add(pdb);
    sel.append("String_Node_Str");
    int pos=0;
    for (    String res : pdb) {
      if (pos > 0)       sel.append("String_Node_Str");
      pos++;
      sel.append(res);
      sel.append("String_Node_Str" + (i + 1));
    }
    if (pos == 0)     sel.append("String_Node_Str");
    sel.append("String_Node_Str" + colors[i].getRed() + "String_Node_Str"+ colors[i].getGreen()+ "String_Node_Str"+ colors[i].getBlue()+ "String_Node_Str");
  }
  j.append(sel);
  j.append("String_Node_Str");
  j.append(LIGAND_DISPLAY_SCRIPT);
  StringBuffer buf=new StringBuffer("String_Node_Str");
  for (int i=0; i < multAln.size(); i++) {
    int count=0;
    for (    String res : allPDB.get(i)) {
      if (count > 0)       buf.append("String_Node_Str");
      buf.append(res);
      buf.append("String_Node_Str" + (i + 1));
      count++;
    }
    if (i != multAln.size() - 1)     buf.append("String_Node_Str");
  }
  j.append(buf);
  return j.toString();
}

Fixed version (ground truth):
/** 
 * Generate a Jmol command String that colors the aligned residues of every structure.
 * @param multAln
 * @param atomArrays
 * @throws StructureAlignmentException 
 */
private static String getJmolString(MultipleAlignment multAln,List<Atom[]> atomArrays,Color[] colors) throws StructureAlignmentException {
  if (multAln.getBlockSets().size() > 1)   return getMultiBlockJmolString(multAln,atomArrays,colors);
 else   if (multAln.getBlockSets().get(0).getBlocks().size() > 1)   return getMultiBlockJmolString(multAln,atomArrays,colors);
  StringBuffer j=new StringBuffer();
  j.append(DEFAULT_SCRIPT);
  StringBuffer sel=new StringBuffer();
  sel.append("String_Node_Str");
  List<List<String>> allPDB=new ArrayList<List<String>>();
  for (int i=0; i < multAln.size(); i++) {
    List<String> pdb=MultipleAlignmentDisplay.getPDBresnum(i,multAln,atomArrays.get(i));
    allPDB.add(pdb);
    sel.append("String_Node_Str");
    int pos=0;
    for (    String res : pdb) {
      if (pos > 0)       sel.append("String_Node_Str");
      pos++;
      sel.append(res);
      sel.append("String_Node_Str" + (i + 1));
    }
    if (pos == 0)     sel.append("String_Node_Str");
    sel.append("String_Node_Str" + colors[i].getRed() + "String_Node_Str"+ colors[i].getGreen()+ "String_Node_Str"+ colors[i].getBlue()+ "String_Node_Str");
  }
  j.append(sel);
  j.append("String_Node_Str");
  j.append(LIGAND_DISPLAY_SCRIPT);
  StringBuffer buf=new StringBuffer("String_Node_Str");
  for (int i=0; i < multAln.size(); i++) {
    int count=0;
    for (    String res : allPDB.get(i)) {
      if (count > 0)       buf.append("String_Node_Str");
      buf.append(res);
      buf.append("String_Node_Str" + (i + 1));
      count++;
    }
    if (i != multAln.size() - 1)     buf.append("String_Node_Str");
  }
  j.append(buf);
  return j.toString();
}