nus-yam/ex-repair huggingface dataset:
Program: 16294
Project: 16294
Buggy source:
private boolean evaluatePermutation(List<Integer> permutation){
  for (int j=0, n=subunits.getSubunitCount(); j < n; j++) {
    transformedCoords[j].set(originalCoords[permutation.get(j)]);
  }
  int fold=PermutationGroup.getOrder(permutation);
  Matrix4d transformation=SuperPositions.superposeAndTransformAtOrigin(originalCoords,transformedCoords);
  AxisAngle4d axisAngle=new AxisAngle4d();
  axisAngle.set(transformation);
  Vector3d axis=new Vector3d(axisAngle.x,axisAngle.y,axisAngle.z);
  if (axis.lengthSquared() < 1.0E-6) {
    axisAngle.x=0;
    axisAngle.y=0;
    axisAngle.z=1;
    axisAngle.angle=0;
  }
 else {
    axis.normalize();
    axisAngle.x=axis.x;
    axisAngle.y=axis.y;
    axisAngle.z=axis.z;
  }
  double subunitRmsd=CalcPoint.rmsd(transformedCoords,originalCoords);
  if (subunitRmsd < parameters.getRmsdThreshold()) {
    combineWithTranslation(transformation);
    QuatSymmetryScores scores=QuatSuperpositionScorer.calcScores(subunits,transformation,permutation);
    if (scores.getRmsd() < 0.0 || scores.getRmsd() > parameters.getRmsdThreshold()) {
      return false;
    }
    scores.setRmsdCenters(subunitRmsd);
    Rotation symmetryOperation=createSymmetryOperation(permutation,transformation,axisAngle,fold,scores);
    rotations.addRotation(symmetryOperation);
    return true;
  }
  return false;
}

Fixed version (ground truth):
private boolean evaluatePermutation(List<Integer> permutation){
  for (int j=0, n=subunits.getSubunitCount(); j < n; j++) {
    transformedCoords[j].set(originalCoords[permutation.get(j)]);
  }
  int fold=PermutationGroup.getOrder(permutation);
  Quat4d quat=UnitQuaternions.relativeOrientation(originalCoords,transformedCoords);
  AxisAngle4d axisAngle=new AxisAngle4d();
  Matrix4d transformation=new Matrix4d();
  transformation.set(quat);
  axisAngle.set(quat);
  Vector3d axis=new Vector3d(axisAngle.x,axisAngle.y,axisAngle.z);
  if (axis.lengthSquared() < 1.0E-6) {
    axisAngle.x=0;
    axisAngle.y=0;
    axisAngle.z=1;
    axisAngle.angle=0;
  }
 else {
    axis.normalize();
    axisAngle.x=axis.x;
    axisAngle.y=axis.y;
    axisAngle.z=axis.z;
  }
  CalcPoint.transform(transformation,transformedCoords);
  double subunitRmsd=CalcPoint.rmsd(transformedCoords,originalCoords);
  if (subunitRmsd < parameters.getRmsdThreshold()) {
    combineWithTranslation(transformation);
    QuatSymmetryScores scores=QuatSuperpositionScorer.calcScores(subunits,transformation,permutation);
    if (scores.getRmsd() < 0.0 || scores.getRmsd() > parameters.getRmsdThreshold()) {
      return false;
    }
    scores.setRmsdCenters(subunitRmsd);
    Rotation symmetryOperation=createSymmetryOperation(permutation,transformation,axisAngle,fold,scores);
    rotations.addRotation(symmetryOperation);
    return true;
  }
  return false;
}
Program: 16295
Project: 16295
Buggy source:
/** 
 * Adds translational component to rotation matrix
 * @param rotTrans
 * @param rotation
 * @return
 */
private void combineWithTranslation(Matrix4d rotation){
  rotation.setTranslation(centroid);
  rotation.mul(rotation,centroidInverse);
}

Fixed version (ground truth):
/** 
 * Adds translational component to rotation matrix
 * @param rotation
 * @return
 */
private void combineWithTranslation(Matrix4d rotation){
  rotation.setTranslation(centroid);
  rotation.mul(rotation,centroidInverse);
}
Program: 16296
Project: 16296
Buggy source:
private boolean evaluatePermutation(List<Integer> permutation){
  for (int j=0, n=subunits.getSubunitCount(); j < n; j++) {
    transformedCoords[j].set(originalCoords[permutation.get(j)]);
  }
  int fold=PermutationGroup.getOrder(permutation);
  Matrix4d transformation=SuperPositions.superposeAndTransformAtOrigin(originalCoords,transformedCoords);
  AxisAngle4d axisAngle=new AxisAngle4d();
  axisAngle.set(transformation);
  Vector3d axis=new Vector3d(axisAngle.x,axisAngle.y,axisAngle.z);
  if (axis.lengthSquared() < 1.0E-6) {
    axisAngle.x=0;
    axisAngle.y=0;
    axisAngle.z=1;
    axisAngle.angle=0;
  }
 else {
    axis.normalize();
    axisAngle.x=axis.x;
    axisAngle.y=axis.y;
    axisAngle.z=axis.z;
  }
  double subunitRmsd=CalcPoint.rmsd(transformedCoords,originalCoords);
  if (subunitRmsd < parameters.getRmsdThreshold()) {
    combineWithTranslation(transformation);
    QuatSymmetryScores scores=QuatSuperpositionScorer.calcScores(subunits,transformation,permutation);
    if (scores.getRmsd() < 0.0 || scores.getRmsd() > parameters.getRmsdThreshold()) {
      return false;
    }
    scores.setRmsdCenters(subunitRmsd);
    Rotation symmetryOperation=createSymmetryOperation(permutation,transformation,axisAngle,fold,scores);
    rotations.addRotation(symmetryOperation);
    return true;
  }
  return false;
}

Fixed version (ground truth):
private boolean evaluatePermutation(List<Integer> permutation){
  for (int j=0, n=subunits.getSubunitCount(); j < n; j++) {
    transformedCoords[j].set(originalCoords[permutation.get(j)]);
  }
  int fold=PermutationGroup.getOrder(permutation);
  Quat4d quat=UnitQuaternions.relativeOrientation(originalCoords,transformedCoords);
  AxisAngle4d axisAngle=new AxisAngle4d();
  Matrix4d transformation=new Matrix4d();
  transformation.set(quat);
  axisAngle.set(quat);
  Vector3d axis=new Vector3d(axisAngle.x,axisAngle.y,axisAngle.z);
  if (axis.lengthSquared() < 1.0E-6) {
    axisAngle.x=0;
    axisAngle.y=0;
    axisAngle.z=1;
    axisAngle.angle=0;
  }
 else {
    axis.normalize();
    axisAngle.x=axis.x;
    axisAngle.y=axis.y;
    axisAngle.z=axis.z;
  }
  CalcPoint.transform(transformation,transformedCoords);
  double subunitRmsd=CalcPoint.rmsd(transformedCoords,originalCoords);
  if (subunitRmsd < parameters.getRmsdThreshold()) {
    combineWithTranslation(transformation);
    QuatSymmetryScores scores=QuatSuperpositionScorer.calcScores(subunits,transformation,permutation);
    if (scores.getRmsd() < 0.0 || scores.getRmsd() > parameters.getRmsdThreshold()) {
      return false;
    }
    scores.setRmsdCenters(subunitRmsd);
    Rotation symmetryOperation=createSymmetryOperation(permutation,transformation,axisAngle,fold,scores);
    rotations.addRotation(symmetryOperation);
    return true;
  }
  return false;
}
Program: 16297
Project: 16297
Buggy source:
@Test public void testMutation() throws Exception {
  Group g1=(Group)structure.getChainByIndex(0).getAtomGroup(21).clone();
  assertTrue(g1 != null);
  Group g2=(Group)structure.getChainByIndex(0).getAtomGroup(53).clone();
  assertTrue(g2 != null);
  assertEquals("String_Node_Str","String_Node_Str",g1.getPDBName());
  assertEquals("String_Node_Str","String_Node_Str",g1.getResidueNumber().toString());
  assertEquals("String_Node_Str","String_Node_Str",g2.getPDBName());
  assertEquals("String_Node_Str","String_Node_Str",g2.getResidueNumber().toString());
  Atom[] atoms1=new Atom[3];
  Atom[] atoms2=new Atom[3];
  atoms1[0]=g1.getAtom("String_Node_Str");
  atoms1[1]=g1.getAtom("String_Node_Str");
  atoms1[2]=g1.getAtom("String_Node_Str");
  atoms2[0]=g2.getAtom("String_Node_Str");
  atoms2[1]=g2.getAtom("String_Node_Str");
  atoms2[2]=g2.getAtom("String_Node_Str");
  SuperPositionSVD svds=new SuperPositionSVD(atoms1,atoms2);
  Matrix rotMatrix=svds.getRotation();
  Atom tran=svds.getTranslation();
  Group newGroup=(Group)g2.clone();
  Calc.rotate(newGroup,rotMatrix);
  Calc.shift(newGroup,tran);
  Atom ca1=g1.getAtom("String_Node_Str");
  Atom oldca2=g2.getAtom("String_Node_Str");
  Atom newca2=newGroup.getAtom("String_Node_Str");
  Element e1=ca1.getElement();
  assertEquals(Element.C,e1);
  double olddistance=Calc.getDistance(ca1,oldca2);
  assertTrue(olddistance > 10);
  double newdistance=Calc.getDistance(ca1,newca2);
  assertTrue(newdistance < 0.1);
}

Fixed version (ground truth):
@Test public void testMutation() throws Exception {
  Group g1=(Group)structure.getChainByIndex(0).getAtomGroup(21).clone();
  assertTrue(g1 != null);
  Group g2=(Group)structure.getChainByIndex(0).getAtomGroup(53).clone();
  assertTrue(g2 != null);
  assertEquals("String_Node_Str","String_Node_Str",g1.getPDBName());
  assertEquals("String_Node_Str","String_Node_Str",g1.getResidueNumber().toString());
  assertEquals("String_Node_Str","String_Node_Str",g2.getPDBName());
  assertEquals("String_Node_Str","String_Node_Str",g2.getResidueNumber().toString());
  Atom[] atoms1=new Atom[3];
  Atom[] atoms2=new Atom[3];
  atoms1[0]=g1.getAtom("String_Node_Str");
  atoms1[1]=g1.getAtom("String_Node_Str");
  atoms1[2]=g1.getAtom("String_Node_Str");
  atoms2[0]=g2.getAtom("String_Node_Str");
  atoms2[1]=g2.getAtom("String_Node_Str");
  atoms2[2]=g2.getAtom("String_Node_Str");
  Matrix4d transform=SuperPositions.superpose(Calc.atomsToPoints(atoms1),Calc.atomsToPoints(atoms2));
  Group newGroup=(Group)g2.clone();
  Calc.transform(newGroup,transform);
  Atom ca1=g1.getAtom("String_Node_Str");
  Atom oldca2=g2.getAtom("String_Node_Str");
  Atom newca2=newGroup.getAtom("String_Node_Str");
  Element e1=ca1.getElement();
  assertEquals(Element.C,e1);
  double olddistance=Calc.getDistance(ca1,oldca2);
  assertTrue(olddistance > 10);
  double newdistance=Calc.getDistance(ca1,newca2);
  assertTrue(newdistance < 0.1);
}
Program: 16298
Project: 16298
Buggy source:
/** 
 * get the RMSD between the aligned positions
 * @param afpChain
 * @param ca1
 * @param ca2
 * @return
 */
private double getRMSD(AFPChain afpChain,Atom[] ca1,Atom[] ca2) throws StructureException {
  Atom[] ca2clone=StructureTools.cloneAtomArray(ca2);
  rotateAtoms2(afpChain,ca2clone);
  Atom[] catmp1=AFPAlignmentDisplay.getAlignedAtoms1(afpChain,ca1);
  Atom[] catmp2=AFPAlignmentDisplay.getAlignedAtoms2(afpChain,ca2clone);
  assertTrue(catmp1.length == catmp2.length);
  assertTrue(catmp1.length == afpChain.getNrEQR());
  return SuperPositionSVD.getRMS(catmp1,catmp2);
}

Fixed version (ground truth):
/** 
 * get the RMSD between the aligned positions
 * @param afpChain
 * @param ca1
 * @param ca2
 * @return
 */
private double getRMSD(AFPChain afpChain,Atom[] ca1,Atom[] ca2) throws StructureException {
  Atom[] ca2clone=StructureTools.cloneAtomArray(ca2);
  rotateAtoms2(afpChain,ca2clone);
  Atom[] catmp1=AFPAlignmentDisplay.getAlignedAtoms1(afpChain,ca1);
  Atom[] catmp2=AFPAlignmentDisplay.getAlignedAtoms2(afpChain,ca2clone);
  assertTrue(catmp1.length == catmp2.length);
  assertTrue(catmp1.length == afpChain.getNrEQR());
  return Calc.rmsd(catmp1,catmp2);
}
Program: 16299
Project: 16299
Buggy source:
/** 
 * get the RMSD between the aligned positions
 * @param afpChain
 * @param ca1
 * @param ca2
 * @return
 */
private double getRMSD(AFPChain afpChain,Atom[] ca1,Atom[] ca2) throws StructureException {
  Atom[] ca2clone=StructureTools.cloneAtomArray(ca2);
  rotateAtoms2(afpChain,ca2clone);
  Atom[] catmp1=AFPAlignmentDisplay.getAlignedAtoms1(afpChain,ca1);
  Atom[] catmp2=AFPAlignmentDisplay.getAlignedAtoms2(afpChain,ca2clone);
  assertTrue(catmp1.length == catmp2.length);
  assertTrue(catmp1.length == afpChain.getNrEQR());
  return SuperPositionSVD.getRMS(catmp1,catmp2);
}

Fixed version (ground truth):
/** 
 * get the RMSD between the aligned positions
 * @param afpChain
 * @param ca1
 * @param ca2
 * @return
 */
private double getRMSD(AFPChain afpChain,Atom[] ca1,Atom[] ca2) throws StructureException {
  Atom[] ca2clone=StructureTools.cloneAtomArray(ca2);
  rotateAtoms2(afpChain,ca2clone);
  Atom[] catmp1=AFPAlignmentDisplay.getAlignedAtoms1(afpChain,ca1);
  Atom[] catmp2=AFPAlignmentDisplay.getAlignedAtoms2(afpChain,ca2clone);
  assertTrue(catmp1.length == catmp2.length);
  assertTrue(catmp1.length == afpChain.getNrEQR());
  return Calc.rmsd(catmp1,catmp2);
}
Program: 16301
Project: 16301
Buggy source:
/** 
 * Creates a new AtomCache object based on the provided UserConfiguration.
 * @param config the UserConfiguration to use for this cache.
 */
public AtomCache(UserConfiguration config){
  this(config.getPdbFilePath(),config.getCacheFilePath());
  fetchBehavior=config.getFetchBehavior();
  obsoleteBehavior=config.getObsoleteBehavior();
  useMmCif=config.getFileFormat().equals(UserConfiguration.MMCIF_FORMAT);
}

Fixed version (ground truth):
/** 
 * Creates a new AtomCache object based on the provided UserConfiguration.
 * @param config the UserConfiguration to use for this cache.
 */
public AtomCache(UserConfiguration config){
  this(config.getPdbFilePath(),config.getCacheFilePath());
  fetchBehavior=config.getFetchBehavior();
  obsoleteBehavior=config.getObsoleteBehavior();
  useMmCif=config.getFileFormat().equals(UserConfiguration.MMCIF_FORMAT);
  if (useMmCif)   useMmtf=false;
}
Program: 16302
Project: 16302
Buggy source:
/** 
 * Loads a structure directly by PDB ID
 * @param pdbId
 * @return
 * @throws IOException
 * @throws StructureException
 */
public Structure getStructureForPdbId(String pdbId) throws IOException, StructureException {
  if (pdbId == null)   return null;
  if (pdbId.length() != 4) {
    throw new StructureException("String_Node_Str" + pdbId);
  }
  while (checkLoading(pdbId)) {
    try {
      Thread.sleep(100);
    }
 catch (    InterruptedException e) {
      logger.error(e.getMessage());
    }
  }
  Structure s;
  if (useMmtf) {
    s=loadStructureFromMmtfByPdbId(pdbId);
  }
 else   if (useMmCif) {
    s=loadStructureFromCifByPdbId(pdbId);
  }
 else {
    s=loadStructureFromPdbByPdbId(pdbId);
  }
  return s;
}

Fixed version (ground truth):
/** 
 * Loads a structure directly by PDB ID
 * @param pdbId
 * @return
 * @throws IOException
 * @throws StructureException
 */
public Structure getStructureForPdbId(String pdbId) throws IOException, StructureException {
  if (pdbId == null)   return null;
  if (pdbId.length() != 4) {
    throw new StructureException("String_Node_Str" + pdbId);
  }
  while (checkLoading(pdbId)) {
    try {
      Thread.sleep(100);
    }
 catch (    InterruptedException e) {
      logger.error(e.getMessage());
    }
  }
  Structure s;
  if (useMmtf) {
    logger.debug("String_Node_Str");
    s=loadStructureFromMmtfByPdbId(pdbId);
  }
 else   if (useMmCif) {
    logger.debug("String_Node_Str");
    s=loadStructureFromCifByPdbId(pdbId);
  }
 else {
    logger.debug("String_Node_Str");
    s=loadStructureFromPdbByPdbId(pdbId);
  }
  return s;
}
Program: 16303
Project: 16303
Buggy source:
/** 
 * Default UserConfiguration: <ul> <li>split directory</li> <li>autofetch files</li> <li>default download location. This is the first specified of: <ol><li>  {@value #PDB_DIR} system property (for instance, -D{@value #PDB_DIR}=/tmp)</li> <li>  {@value #PDB_DIR} environment variable</li><li>System temp directory (java.io.tmpdir property)</li> </ol> if the provided path is not a directory then the system's temp directory is used. A non-writable path is allowed, only a warning will be logged. </li> <li>default cache location. This is the first specified of: <ol><li> {@value #PDB_CACHE_DIR} system property (for instance, -D{@value #PDB_CACHE_DIR}=/tmp)</li> <li>  {@value #PDB_CACHE_DIR} environment variable</li><li>the value set for  {@value #PDB_DIR}</li> </ol> if the provided path is not a directory or is not writable then the system's temp directory is used. </li> </ul>
 */
public UserConfiguration(){
  fetchBehavior=FetchBehavior.DEFAULT;
  obsoleteBehavior=ObsoleteBehavior.DEFAULT;
  pdbFilePath=initPdbFilePath();
  cacheFilePath=initCacheFilePath();
  fileFormat=MMCIF_FORMAT;
}

Fixed version (ground truth):
/** 
 * Default UserConfiguration: <ul> <li>split directory</li> <li>autofetch files</li> <li>default download location. This is the first specified of: <ol><li>  {@value #PDB_DIR} system property (for instance, -D{@value #PDB_DIR}=/tmp)</li> <li>  {@value #PDB_DIR} environment variable</li><li>System temp directory (java.io.tmpdir property)</li> </ol> if the provided path is not a directory then the system's temp directory is used. A non-writable path is allowed, only a warning will be logged. </li> <li>default cache location. This is the first specified of: <ol><li> {@value #PDB_CACHE_DIR} system property (for instance, -D{@value #PDB_CACHE_DIR}=/tmp)</li> <li>  {@value #PDB_CACHE_DIR} environment variable</li><li>the value set for  {@value #PDB_DIR}</li> </ol> if the provided path is not a directory or is not writable then the system's temp directory is used. </li> </ul>
 */
public UserConfiguration(){
  fetchBehavior=FetchBehavior.DEFAULT;
  obsoleteBehavior=ObsoleteBehavior.DEFAULT;
  pdbFilePath=initPdbFilePath();
  cacheFilePath=initCacheFilePath();
  fileFormat=MMTF_FORMAT;
}
Program: 16304
Project: 16304
Buggy source:
/** 
 * Create and set a new structure from a given atom array.
 * @param atoms
 */
public void setAtoms(Atom[] atoms){
  Structure s=new StructureImpl();
  Chain c=new ChainImpl();
  c.setId("String_Node_Str");
  for (  Atom a : atoms) {
    c.addGroup(a.getGroup());
  }
  s.addChain(c);
  setStructure(s);
}

Fixed version (ground truth):
/** 
 * Create and set a new structure from a given atom array.
 * @param atoms
 */
public void setAtoms(Atom[] atoms){
  Structure s=new StructureImpl();
  Chain c=new ChainImpl();
  c.setChainID("String_Node_Str");
  for (  Atom a : atoms) {
    c.addGroup(a.getGroup());
  }
  s.addChain(c);
  setStructure(s);
}
Program: 16305
Project: 16305
Buggy source:
/** 
 * Creates bond objects from a LinkRecord as parsed from a PDB file
 * @param linkRecord
 */
public void formLinkRecordBond(LinkRecord linkRecord){
  if (linkRecord.getAltLoc1().equals("String_Node_Str") || linkRecord.getAltLoc2().equals("String_Node_Str"))   return;
  try {
    Atom a=getAtomFromRecord(linkRecord.getName1(),linkRecord.getAltLoc1(),linkRecord.getResName1(),linkRecord.getChainID1(),linkRecord.getResSeq1(),linkRecord.getiCode1());
    Atom b=getAtomFromRecord(linkRecord.getName2(),linkRecord.getAltLoc2(),linkRecord.getResName2(),linkRecord.getChainID2(),linkRecord.getResSeq2(),linkRecord.getiCode2());
    new BondImpl(a,b,1);
  }
 catch (  StructureException e) {
    if (!params.isParseCAOnly()) {
      logger.warn("String_Node_Str",linkRecord.toString());
    }
 else {
      logger.debug("String_Node_Str");
    }
  }
}

Fixed version (ground truth):
/** 
 * Creates bond objects from a LinkRecord as parsed from a PDB file
 * @param linkRecord
 */
public void formLinkRecordBond(LinkRecord linkRecord){
  if (linkRecord.getAltLoc1().equals("String_Node_Str") || linkRecord.getAltLoc2().equals("String_Node_Str"))   return;
  try {
    Map<Integer,Atom> a=getAtomFromRecord(linkRecord.getName1(),linkRecord.getAltLoc1(),linkRecord.getResName1(),linkRecord.getChainID1(),linkRecord.getResSeq1(),linkRecord.getiCode1());
    Map<Integer,Atom> b=getAtomFromRecord(linkRecord.getName2(),linkRecord.getAltLoc2(),linkRecord.getResName2(),linkRecord.getChainID2(),linkRecord.getResSeq2(),linkRecord.getiCode2());
    for (int i=0; i < structure.nrModels(); i++) {
      if (a.containsKey(i) && b.containsKey(i)) {
        new BondImpl(a.get(i),b.get(i),1);
      }
    }
  }
 catch (  StructureException e) {
    if (!params.isParseCAOnly()) {
      logger.warn("String_Node_Str",linkRecord.toString());
    }
 else {
      logger.debug("String_Node_Str");
    }
  }
}
Program: 16307
Project: 16307
Buggy source:
/** 
 * Creates disulfide bond objects and references in the corresponding Atoms objects, given a list of   {@link SSBondImpl}s parsed from a PDB/mmCIF file.
 * @param disulfideBonds
 */
public void formDisulfideBonds(List<SSBondImpl> disulfideBonds){
  List<Bond> bonds=new ArrayList<>();
  for (  SSBondImpl disulfideBond : disulfideBonds) {
    Bond bond=formDisulfideBond(disulfideBond);
    if (bond != null)     bonds.add(bond);
  }
  structure.setSSBonds(bonds);
}

Fixed version (ground truth):
/** 
 * Creates disulfide bond objects and references in the corresponding Atoms objects, given a list of   {@link SSBondImpl}s parsed from a PDB/mmCIF file.
 * @param disulfideBonds
 */
public void formDisulfideBonds(List<SSBondImpl> disulfideBonds){
  for (  SSBondImpl disulfideBond : disulfideBonds) {
    formDisulfideBond(disulfideBond);
  }
}
Program: 16308
Project: 16308
Buggy source:
private Atom getAtomFromRecord(String name,String altLoc,String resName,String chainID,String resSeq,String iCode) throws StructureException {
  if (iCode == null || iCode.isEmpty()) {
    iCode="String_Node_Str";
  }
  Chain chain=structure.getChain(chainID);
  ResidueNumber resNum=new ResidueNumber(chainID,Integer.parseInt(resSeq),iCode.charAt(0));
  Group group=chain.getGroupByPDB(resNum);
  Group g=group;
  if (!altLoc.isEmpty()) {
    g=group.getAltLocGroup(altLoc.charAt(0));
    if (g == null)     throw new StructureException("String_Node_Str" + altLoc + "String_Node_Str"+ resSeq+ iCode+ "String_Node_Str"+ chainID);
  }
  return g.getAtom(name);
}

Fixed version (ground truth):
private Map<Integer,Atom> getAtomFromRecord(String name,String altLoc,String resName,String chainID,String resSeq,String iCode) throws StructureException {
  if (iCode == null || iCode.isEmpty()) {
    iCode="String_Node_Str";
  }
  Map<Integer,Atom> outMap=new HashMap<>();
  ResidueNumber resNum=new ResidueNumber(chainID,Integer.parseInt(resSeq),iCode.charAt(0));
  for (int i=0; i < structure.nrModels(); i++) {
    Chain chain=structure.getChain(chainID,i);
    Group group=chain.getGroupByPDB(resNum);
    Group g=group;
    if (!altLoc.isEmpty()) {
      g=group.getAltLocGroup(altLoc.charAt(0));
      if (g == null)       throw new StructureException("String_Node_Str" + altLoc + "String_Node_Str"+ resSeq+ iCode+ "String_Node_Str"+ chainID);
    }
    outMap.put(i,g.getAtom(name));
  }
  return outMap;
}
Program: 16309
Project: 16309
Buggy source:
private Bond formDisulfideBond(SSBondImpl disulfideBond){
  try {
    Atom a=getAtomFromRecord("String_Node_Str","String_Node_Str","String_Node_Str",disulfideBond.getChainID1(),disulfideBond.getResnum1(),disulfideBond.getInsCode1());
    Atom b=getAtomFromRecord("String_Node_Str","String_Node_Str","String_Node_Str",disulfideBond.getChainID2(),disulfideBond.getResnum2(),disulfideBond.getInsCode2());
    Bond ssbond=new BondImpl(a,b,1);
    structure.addSSBond(ssbond);
    return ssbond;
  }
 catch (  StructureException e) {
    if (!params.isParseCAOnly()) {
      logger.warn("String_Node_Str",disulfideBond.toString());
    }
 else {
      logger.debug("String_Node_Str");
    }
    return null;
  }
}

Fixed version (ground truth):
private void formDisulfideBond(SSBondImpl disulfideBond){
  try {
    Map<Integer,Atom> a=getAtomFromRecord("String_Node_Str","String_Node_Str","String_Node_Str",disulfideBond.getChainID1(),disulfideBond.getResnum1(),disulfideBond.getInsCode1());
    Map<Integer,Atom> b=getAtomFromRecord("String_Node_Str","String_Node_Str","String_Node_Str",disulfideBond.getChainID2(),disulfideBond.getResnum2(),disulfideBond.getInsCode2());
    for (int i=0; i < structure.nrModels(); i++) {
      if (a.containsKey(i) && b.containsKey(i)) {
        Bond ssbond=new BondImpl(a.get(i),b.get(i),1);
        structure.addSSBond(ssbond);
      }
    }
  }
 catch (  StructureException e) {
    if (!params.isParseCAOnly()) {
      logger.warn("String_Node_Str",disulfideBond.toString());
    }
 else {
      logger.debug("String_Node_Str");
    }
  }
}
Program: 16313
Project: 16313
Buggy source:
/** 
 * Use DownloadChemCompProvider to grab a gzipped cif record from the PDB. Zip all downloaded cif.gz files into the dictionary.
 * @param recordName is the three-letter chemical component code (i.e. residue name).
 * @return ChemComp matching recordName
 */
private ChemComp downloadAndAdd(String recordName){
  final ChemComp cc=m_dlProvider.getChemComp(recordName);
  final File[] files=new File[1];
  Path cif=m_tempDir.resolve("String_Node_Str").resolve(recordName + "String_Node_Str");
  files[0]=cif.toFile();
  if (files != null) {
    addToZipFileSystem(m_zipFile,files,m_zipRootDir);
    if (m_removeCif)     for (    File f : files)     f.delete();
  }
  return cc;
}

Fixed version (ground truth):
/** 
 * Use DownloadChemCompProvider to grab a gzipped cif record from the PDB. Zip all downloaded cif.gz files into the dictionary.
 * @param recordName is the three-letter chemical component code (i.e. residue name).
 * @return ChemComp matching recordName
 */
private ChemComp downloadAndAdd(String recordName){
  final ChemComp cc=m_dlProvider.getChemComp(recordName);
  final File[] files=new File[1];
  Path cif=m_tempDir.resolve("String_Node_Str").resolve(recordName + "String_Node_Str");
  files[0]=cif.toFile();
  if (files[0] != null) {
    addToZipFileSystem(m_zipFile,files,m_zipRootDir);
    if (m_removeCif)     for (    File f : files)     f.delete();
  }
  return cc;
}
Program: 16314
Project: 16314
Buggy source:
/** 
 * Creates bond objects from a LinkRecord as parsed from a PDB file
 * @param linkRecord
 */
public void formLinkRecordBond(LinkRecord linkRecord){
  if (linkRecord.getAltLoc1().equals("String_Node_Str") || linkRecord.getAltLoc2().equals("String_Node_Str"))   return;
  try {
    Map<Integer,Atom> a=getAtomFromRecord(linkRecord.getName1(),linkRecord.getAltLoc1(),linkRecord.getResName1(),linkRecord.getChainID1(),linkRecord.getResSeq1(),linkRecord.getiCode1());
    Map<Integer,Atom> b=getAtomFromRecord(linkRecord.getName2(),linkRecord.getAltLoc2(),linkRecord.getResName2(),linkRecord.getChainID2(),linkRecord.getResSeq2(),linkRecord.getiCode2());
    for (int i=0; i < structure.nrModels(); i++) {
      if (a.containsKey(i) && b.containsKey(i)) {
        new BondImpl(a.get(i),b.get(i),1);
      }
    }
  }
 catch (  StructureException e) {
    if (!params.isParseCAOnly()) {
      logger.warn("String_Node_Str",linkRecord.toString());
    }
 else {
      logger.debug("String_Node_Str");
    }
  }
}

Fixed version (ground truth):
/** 
 * Creates bond objects from a LinkRecord as parsed from a PDB file
 * @param linkRecord
 */
public void formLinkRecordBond(LinkRecord linkRecord){
  if (linkRecord.getAltLoc1().equals("String_Node_Str") || linkRecord.getAltLoc2().equals("String_Node_Str"))   return;
  try {
    Map<Integer,Atom> a=getAtomFromRecord(linkRecord.getName1(),linkRecord.getAltLoc1(),linkRecord.getResName1(),linkRecord.getChainID1(),linkRecord.getResSeq1(),linkRecord.getiCode1());
    Map<Integer,Atom> b=getAtomFromRecord(linkRecord.getName2(),linkRecord.getAltLoc2(),linkRecord.getResName2(),linkRecord.getChainID2(),linkRecord.getResSeq2(),linkRecord.getiCode2());
    for (int i=0; i < structure.nrModels(); i++) {
      if (a.containsKey(i) && b.containsKey(i)) {
        if (!a.get(i).equals(b.get(i))) {
          new BondImpl(a.get(i),b.get(i),1);
        }
      }
    }
  }
 catch (  StructureException e) {
    if (!params.isParseCAOnly()) {
      logger.warn("String_Node_Str",linkRecord.toString());
    }
 else {
      logger.debug("String_Node_Str");
    }
  }
}
Program: 16316
Project: 16316
Buggy source:
private void formDisulfideBond(SSBondImpl disulfideBond){
  try {
    Map<Integer,Atom> a=getAtomFromRecord("String_Node_Str","String_Node_Str","String_Node_Str",disulfideBond.getChainID1(),disulfideBond.getResnum1(),disulfideBond.getInsCode1());
    Map<Integer,Atom> b=getAtomFromRecord("String_Node_Str","String_Node_Str","String_Node_Str",disulfideBond.getChainID2(),disulfideBond.getResnum2(),disulfideBond.getInsCode2());
    for (int i=0; i < structure.nrModels(); i++) {
      if (a.containsKey(i) && b.containsKey(i)) {
        Bond ssbond=new BondImpl(a.get(i),b.get(i),1);
        structure.addSSBond(ssbond);
      }
    }
  }
 catch (  StructureException e) {
    if (!params.isParseCAOnly()) {
      logger.warn("String_Node_Str",disulfideBond.toString());
    }
 else {
      logger.debug("String_Node_Str");
    }
  }
}

Fixed version (ground truth):
private void formDisulfideBond(SSBondImpl disulfideBond){
  try {
    Map<Integer,Atom> a=getAtomFromRecord("String_Node_Str","String_Node_Str","String_Node_Str",disulfideBond.getChainID1(),disulfideBond.getResnum1(),disulfideBond.getInsCode1());
    Map<Integer,Atom> b=getAtomFromRecord("String_Node_Str","String_Node_Str","String_Node_Str",disulfideBond.getChainID2(),disulfideBond.getResnum2(),disulfideBond.getInsCode2());
    for (int i=0; i < structure.nrModels(); i++) {
      if (a.containsKey(i) && b.containsKey(i)) {
        if (!a.get(i).equals(b.get(i))) {
          Bond ssbond=new BondImpl(a.get(i),b.get(i),1);
          structure.addSSBond(ssbond);
        }
      }
    }
  }
 catch (  StructureException e) {
    if (!params.isParseCAOnly()) {
      logger.warn("String_Node_Str",disulfideBond.toString());
    }
 else {
      logger.debug("String_Node_Str");
    }
  }
}
Program: 16317
Project: 16317
Buggy source:
@Override public void setAtomInfo(String atomName,int serialNumber,char alternativeLocationId,float x,float y,float z,float occupancy,float temperatureFactor,String element,int charge){
  Atom atom=new AtomImpl();
  Group altGroup=null;
  atom.setPDBserial(serialNumber);
  atom.setName(atomName.trim());
  atom.setElement(Element.valueOfIgnoreCase(element));
  if (alternativeLocationId == MmtfStructure.UNAVAILABLE_CHAR_VALUE) {
    alternativeLocationId=' ';
  }
  if (alternativeLocationId != ' ') {
    altGroup=getCorrectAltLocGroup(alternativeLocationId);
    atom.setAltLoc(alternativeLocationId);
  }
 else {
    atom.setAltLoc(Character.valueOf(' '));
  }
  atom.setX(x);
  atom.setY(y);
  atom.setZ(z);
  atom.setOccupancy(occupancy);
  atom.setTempFactor(temperatureFactor);
  atom.setCharge((short)charge);
  if (altGroup == null) {
    group.addAtom(atom);
  }
 else {
    altGroup.setChain(chain);
    altGroup.addAtom(atom);
  }
  if (!group.hasAtom(atom.getName())) {
    if (group.getPDBName().equals(atom.getGroup().getPDBName())) {
      group.addAtom(atom);
    }
  }
  atomsInGroup.add(atom);
  allAtoms[atomCounter]=atom;
  atomCounter++;
}

Fixed version (ground truth):
@Override public void setAtomInfo(String atomName,int serialNumber,char alternativeLocationId,float x,float y,float z,float occupancy,float temperatureFactor,String element,int charge){
  Atom atom=new AtomImpl();
  Group altGroup=null;
  atom.setPDBserial(serialNumber);
  atom.setName(atomName.trim());
  atom.setElement(Element.valueOfIgnoreCase(element));
  if (alternativeLocationId == MmtfStructure.UNAVAILABLE_CHAR_VALUE) {
    alternativeLocationId=' ';
  }
  if (alternativeLocationId != ' ') {
    altGroup=getCorrectAltLocGroup(alternativeLocationId);
    atom.setAltLoc(alternativeLocationId);
  }
 else {
    atom.setAltLoc(Character.valueOf(' '));
  }
  atom.setX(x);
  atom.setY(y);
  atom.setZ(z);
  atom.setOccupancy(occupancy);
  atom.setTempFactor(temperatureFactor);
  atom.setCharge((short)charge);
  if (altGroup == null) {
    group.addAtom(atom);
  }
 else {
    altGroup.setChain(chain);
    altGroup.addAtom(atom);
  }
  if (!group.hasAtom(atom.getName())) {
    if (group.getPDBName().equals(atom.getGroup().getPDBName())) {
      if (StructureTools.hasNonDeuteratedEquiv(atom,group)) {
      }
 else {
        group.addAtom(atom);
      }
    }
  }
  atomsInGroup.add(atom);
  allAtoms[atomCounter]=atom;
  atomCounter++;
}
Program: 16320
Project: 16320
Buggy source:
@Before public void setUp() throws StructureException {
  int size=50;
  Random rnd=new Random();
  cloud1=new Atom[size];
  cloud2=new Atom[size];
  cloud2noise=new Atom[size];
  axis=new AxisAngle4d(0.440,0.302,0.845,1.570);
  translation=new Vector3d(0.345,2.453,5.324);
  transform=new Matrix4d();
  transform.set(axis);
  transform.setTranslation(translation);
  for (int p=0; p < size; p++) {
    Atom a=new AtomImpl();
    a.setCoords(new double[]{rnd.nextInt(100),rnd.nextInt(50),rnd.nextInt(150)});
    cloud1[p]=a;
    cloud2[p]=(Atom)a.clone();
    Atom b=new AtomImpl();
    b.setCoords(new double[]{a.getX() + rnd.nextDouble(),a.getY() + rnd.nextDouble(),a.getZ() + rnd.nextDouble()});
    cloud2noise[p]=b;
  }
  cloud1=Calc.centerAtoms(cloud1);
  cloud2=Calc.centerAtoms(cloud2);
  cloud2noise=Calc.centerAtoms(cloud2noise);
  Calc.transform(cloud2,transform);
  Calc.transform(cloud2noise,transform);
}

Fixed version (ground truth):
@Before public void setUp() throws StructureException {
  int size=500;
  Random rnd=new Random();
  cloud1=new Atom[size];
  cloud2=new Atom[size];
  cloud2noise=new Atom[size];
  axis=new AxisAngle4d(0.440,0.302,0.845,1.570);
  translation=new Vector3d(0.345,2.453,5.324);
  transform=new Matrix4d();
  transform.set(axis);
  transform.setTranslation(translation);
  for (int p=0; p < size; p++) {
    Atom a=new AtomImpl();
    a.setCoords(new double[]{rnd.nextInt(100),rnd.nextInt(50),rnd.nextInt(150)});
    cloud1[p]=a;
    cloud2[p]=(Atom)a.clone();
    Atom b=new AtomImpl();
    b.setCoords(new double[]{a.getX() + rnd.nextDouble(),a.getY() + rnd.nextDouble(),a.getZ() + rnd.nextDouble()});
    cloud2noise[p]=b;
  }
  cloud1=Calc.centerAtoms(cloud1);
  cloud2=Calc.centerAtoms(cloud2);
  cloud2noise=Calc.centerAtoms(cloud2noise);
  Calc.transform(cloud2,transform);
  Calc.transform(cloud2noise,transform);
}
Program: 16321
Project: 16321
Buggy source:
/** 
 * returns and identical copy of this Group object .
 * @return  and identical copy of this Group object
 */
@Override public Object clone(){
  AminoAcidImpl n=new AminoAcidImpl();
  n.setPDBFlag(has3D());
  n.setResidueNumber(getResidueNumber());
  n.setPDBName(getPDBName());
  n.setAminoType(getAminoType());
  n.setRecordType(recordType);
  for (  Atom atom1 : atoms) {
    Atom atom=(Atom)atom1.clone();
    n.addAtom(atom);
    atom.setGroup(n);
  }
  if (getAltLocs() != null && !getAltLocs().isEmpty()) {
    for (    Group altLocGroup : this.getAltLocs()) {
      Group nAltLocGroup=(Group)altLocGroup.clone();
      n.addAltLoc(nAltLocGroup);
    }
  }
  return n;
}

Fixed version (ground truth):
/** 
 * returns and identical copy of this Group object .
 * @return  and identical copy of this Group object
 */
@Override public Object clone(){
  AminoAcidImpl n=new AminoAcidImpl();
  n.setPDBFlag(has3D());
  n.setResidueNumber(getResidueNumber());
  n.setPDBName(getPDBName());
  n.setAminoType(getAminoType());
  n.setRecordType(recordType);
  for (  Atom atom1 : atoms) {
    Atom atom=(Atom)atom1.clone();
    n.addAtom(atom);
    atom.setGroup(n);
  }
  if (getAltLocs() != null && !getAltLocs().isEmpty()) {
    for (    Group altLocGroup : this.getAltLocs()) {
      Group nAltLocGroup=(Group)altLocGroup.clone();
      n.addAltLoc(nAltLocGroup);
    }
  }
  if (chemComp != null)   n.setChemComp(chemComp);
  return n;
}
Program: 16322
Project: 16322
Buggy source:
/** 
 * returns and identical copy of this Group object .
 * @return  and identical copy of this Group object
 */
@Override public Object clone(){
  HetatomImpl n=new HetatomImpl();
  n.setPDBFlag(has3D());
  n.setResidueNumber(residueNumber);
  n.setPDBName(getPDBName());
  for (  Atom atom1 : atoms) {
    Atom atom=(Atom)atom1.clone();
    n.addAtom(atom);
    atom.setGroup(n);
  }
  if (altLocs != null) {
    for (    Group altLocGroup : this.altLocs) {
      Group nAltLocGroup=(Group)altLocGroup.clone();
      n.addAltLoc(nAltLocGroup);
    }
  }
  return n;
}

Fixed version (ground truth):
/** 
 * returns and identical copy of this Group object .
 * @return  and identical copy of this Group object
 */
@Override public Object clone(){
  HetatomImpl n=new HetatomImpl();
  n.setPDBFlag(has3D());
  n.setResidueNumber(residueNumber);
  n.setPDBName(getPDBName());
  for (  Atom atom1 : atoms) {
    Atom atom=(Atom)atom1.clone();
    n.addAtom(atom);
    atom.setGroup(n);
  }
  if (altLocs != null) {
    for (    Group altLocGroup : this.altLocs) {
      Group nAltLocGroup=(Group)altLocGroup.clone();
      n.addAltLoc(nAltLocGroup);
    }
  }
  if (chemComp != null)   n.setChemComp(chemComp);
  return n;
}
Program: 16324
Project: 16324
Buggy source:
private static void showResults(Structure s,String name,QuatSymmetryResults results){
  String title=name + "String_Node_Str" + results.getSubunits().getStoichiometry()+ "String_Node_Str"+ results.getSymmetry();
  if (results.getSubunits().isPseudoSymmetric())   title+="String_Node_Str";
  if (results.isLocal())   title+="String_Node_Str";
  String script="String_Node_Str" + "String_Node_Str" + "String_Node_Str";
  AxisAligner aligner=AxisAligner.getInstance(results);
  JmolSymmetryScriptGenerator scriptGenerator=JmolSymmetryScriptGeneratorPointGroup.getInstance(aligner,"String_Node_Str");
  script+=scriptGenerator.getOrientationWithZoom(0);
  script+=scriptGenerator.drawPolyhedron();
  script+=scriptGenerator.drawAxes();
  script+=scriptGenerator.colorBySymmetry();
  title+="String_Node_Str" + results.getMethod();
  script+="String_Node_Str";
  BiojavaJmol jmol=new BiojavaJmol();
  jmol.setStructure(s);
  jmol.setTitle(title);
  jmol.evalString(script);
}

Fixed version (ground truth):
private static void showResults(Structure s,String name,QuatSymmetryResults results){
  String title=name + "String_Node_Str" + results.getStoichiometry()+ "String_Node_Str"+ results.getSymmetry();
  if (results.isPseudosymmetric())   title+="String_Node_Str";
  if (results.isLocal())   title+="String_Node_Str";
  String script="String_Node_Str" + "String_Node_Str" + "String_Node_Str";
  AxisAligner aligner=AxisAligner.getInstance(results);
  JmolSymmetryScriptGenerator scriptGenerator=JmolSymmetryScriptGeneratorPointGroup.getInstance(aligner,"String_Node_Str");
  script+=scriptGenerator.getOrientationWithZoom(0);
  script+=scriptGenerator.drawPolyhedron();
  script+=scriptGenerator.drawAxes();
  script+=scriptGenerator.colorBySymmetry();
  title+="String_Node_Str" + results.getMethod();
  script+="String_Node_Str";
  BiojavaJmol jmol=new BiojavaJmol();
  jmol.setStructure(s);
  jmol.setTitle(title);
  jmol.evalString(script);
}
Program: 16326
Project: 16326
Buggy source:
/** 
 * Returns a Jmol script that colors the subunits of a structure by different colors
 * @return
 */
@Override public String colorBySubunit(){
  Subunits subunits=helixAxisAligner.getSubunits();
  List<Integer> modelNumbers=subunits.getModelNumbers();
  List<String> chainIds=subunits.getChainIds();
  List<List<Integer>> orbits=helixAxisAligner.getOrbits();
  Color[] col=ColorBrewer.Spectral.getColorPalette(orbits.size());
  Color4f[] colors=ColorConverter.convertColor4f(col);
  int half=colors.length / 2;
  for (int i=0; i < half; i++) {
    if (i % 2 != 0) {
      Color4f temp=colors[i];
      colors[i]=colors[half + i];
      colors[half + i]=temp;
    }
  }
  Map<Color4f,List<String>> colorMap=new HashMap<Color4f,List<String>>();
  for (int i=0; i < orbits.size(); i++) {
    for (    Integer j : orbits.get(i)) {
      Color4f c=colors[i];
      List<String> ids=colorMap.get(c);
      if (ids == null) {
        ids=new ArrayList<String>();
        colorMap.put(c,ids);
      }
      String id=getChainSpecification(modelNumbers,chainIds,j);
      ids.add(id);
    }
  }
  String coloring=defaultColoring + getJmolColorScript(colorMap);
  return coloring;
}

Fixed version (ground truth):
/** 
 * Returns a Jmol script that colors the subunits of a structure by different colors
 * @return
 */
@Override public String colorBySubunit(){
  QuatSymmetrySubunits subunits=helixAxisAligner.getSubunits();
  List<Integer> modelNumbers=subunits.getModelNumbers();
  List<String> chainIds=subunits.getChainIds();
  List<List<Integer>> orbits=helixAxisAligner.getOrbits();
  Color[] col=ColorBrewer.Spectral.getColorPalette(orbits.size());
  Color4f[] colors=ColorConverter.convertColor4f(col);
  int half=colors.length / 2;
  for (int i=0; i < half; i++) {
    if (i % 2 != 0) {
      Color4f temp=colors[i];
      colors[i]=colors[half + i];
      colors[half + i]=temp;
    }
  }
  Map<Color4f,List<String>> colorMap=new HashMap<Color4f,List<String>>();
  for (int i=0; i < orbits.size(); i++) {
    for (    Integer j : orbits.get(i)) {
      Color4f c=colors[i];
      List<String> ids=colorMap.get(c);
      if (ids == null) {
        ids=new ArrayList<String>();
        colorMap.put(c,ids);
      }
      String id=getChainSpecification(modelNumbers,chainIds,j);
      ids.add(id);
    }
  }
  String coloring=defaultColoring + getJmolColorScript(colorMap);
  return coloring;
}
Program: 16327
Project: 16327
Buggy source:
/** 
 * Returns a Jmol script that colors subunits by their sequence cluster ids.
 * @return Jmol script
 */
@Override public String colorBySequenceCluster(){
  Subunits subunits=helixAxisAligner.getSubunits();
  int n=subunits.getSubunitCount();
  List<Integer> modelNumbers=subunits.getModelNumbers();
  List<String> chainIds=subunits.getChainIds();
  List<Integer> seqClusterIds=subunits.getSequenceClusterIds();
  int clusters=Collections.max(seqClusterIds) + 1;
  Color[] col=ColorBrewer.BrBG.getColorPalette(clusters);
  Color4f[] colors=ColorConverter.convertColor4f(col);
  Map<Color4f,List<String>> colorMap=new HashMap<Color4f,List<String>>();
  for (int i=0; i < n; i++) {
    Color4f c=colors[seqClusterIds.get(i)];
    List<String> ids=colorMap.get(c);
    if (ids == null) {
      ids=new ArrayList<String>();
      colorMap.put(c,ids);
    }
    String id=getChainSpecification(modelNumbers,chainIds,i);
    ids.add(id);
  }
  String coloring=defaultColoring + getJmolColorScript(colorMap);
  return coloring;
}

Fixed version (ground truth):
/** 
 * Returns a Jmol script that colors subunits by their sequence cluster ids.
 * @return Jmol script
 */
@Override public String colorBySequenceCluster(){
  QuatSymmetrySubunits subunits=helixAxisAligner.getSubunits();
  int n=subunits.getSubunitCount();
  List<Integer> modelNumbers=subunits.getModelNumbers();
  List<String> chainIds=subunits.getChainIds();
  List<Integer> seqClusterIds=subunits.getSequenceClusterIds();
  int clusters=Collections.max(seqClusterIds) + 1;
  Color[] col=ColorBrewer.BrBG.getColorPalette(clusters);
  Color4f[] colors=ColorConverter.convertColor4f(col);
  Map<Color4f,List<String>> colorMap=new HashMap<Color4f,List<String>>();
  for (int i=0; i < n; i++) {
    Color4f c=colors[seqClusterIds.get(i)];
    List<String> ids=colorMap.get(c);
    if (ids == null) {
      ids=new ArrayList<String>();
      colorMap.put(c,ids);
    }
    String id=getChainSpecification(modelNumbers,chainIds,i);
    ids.add(id);
  }
  String coloring=defaultColoring + getJmolColorScript(colorMap);
  return coloring;
}
Program: 16329
Project: 16329
Buggy source:
private Map<Color4f,List<String>> getCnColorMap(){
  Subunits subunits=rotationAxisAligner.getSubunits();
  List<Integer> modelNumbers=subunits.getModelNumbers();
  List<String> chainIds=subunits.getChainIds();
  List<List<Integer>> orbits=rotationAxisAligner.getOrbits();
  int fold=rotationGroup.getRotation(0).getFold();
  Map<Color4f,List<String>> colorMap=new HashMap<Color4f,List<String>>();
  Color4f[] colors=getSymmetryColors(fold);
  for (  List<Integer> orbit : orbits) {
    for (int i=0; i < fold; i++) {
      int subunit=orbit.get(i);
      String id=null;
      id=getChainSpecification(modelNumbers,chainIds,subunit);
      Color4f c=colors[i];
      List<String> ids=colorMap.get(c);
      if (ids == null) {
        ids=new ArrayList<String>();
        colorMap.put(c,ids);
      }
      ids.add(id);
    }
  }
  return colorMap;
}

Fixed version (ground truth):
private Map<Color4f,List<String>> getCnColorMap(){
  QuatSymmetrySubunits subunits=rotationAxisAligner.getSubunits();
  List<Integer> modelNumbers=subunits.getModelNumbers();
  List<String> chainIds=subunits.getChainIds();
  List<List<Integer>> orbits=rotationAxisAligner.getOrbits();
  int fold=rotationGroup.getRotation(0).getFold();
  Map<Color4f,List<String>> colorMap=new HashMap<Color4f,List<String>>();
  Color4f[] colors=getSymmetryColors(fold);
  for (  List<Integer> orbit : orbits) {
    for (int i=0; i < fold; i++) {
      int subunit=orbit.get(i);
      String id=null;
      id=getChainSpecification(modelNumbers,chainIds,subunit);
      Color4f c=colors[i];
      List<String> ids=colorMap.get(c);
      if (ids == null) {
        ids=new ArrayList<String>();
        colorMap.put(c,ids);
      }
      ids.add(id);
    }
  }
  return colorMap;
}
Program: 16330
Project: 16330
Buggy source:
@Override public String colorBySubunit(){
  Subunits subunits=rotationAxisAligner.getSubunits();
  List<Integer> modelNumbers=subunits.getModelNumbers();
  List<String> chainIds=subunits.getChainIds();
  List<List<Integer>> orbits=rotationAxisAligner.getOrbits();
  int fold=rotationGroup.getRotation(0).getFold();
  Color[] col=null;
  Color4f[] colors=null;
  if (fold > 1) {
    col=ColorBrewer.Spectral.getColorPalette(2 * fold);
    colors=ColorConverter.convertColor4f(col);
  }
 else {
    col=ColorBrewer.Spectral.getColorPalette(orbits.size());
    colors=ColorConverter.convertColor4f(col);
  }
  int half=colors.length / 2;
  for (int i=0; i < half; i++) {
    if (i % 2 != 0) {
      Color4f temp=colors[i];
      colors[i]=colors[half + i];
      colors[half + i]=temp;
    }
  }
  Map<Color4f,List<String>> colorMap=new HashMap<Color4f,List<String>>();
  for (int i=0; i < orbits.size(); i++) {
    for (int j=0; j < fold; j++) {
      int colorIndex=i;
      if (fold > 1) {
        if (i % 2 == 0) {
          colorIndex=j;
        }
 else {
          colorIndex=fold + j;
        }
      }
      int subunit=orbits.get(i).get(j);
      Color4f c=colors[colorIndex];
      List<String> ids=colorMap.get(c);
      if (ids == null) {
        ids=new ArrayList<String>();
        colorMap.put(c,ids);
      }
      String id=getChainSpecification(modelNumbers,chainIds,subunit);
      ids.add(id);
    }
  }
  return defaultColoring + getJmolColorScript(colorMap) + getJmolLigandScript();
}

Fixed version (ground truth):
@Override public String colorBySubunit(){
  QuatSymmetrySubunits subunits=rotationAxisAligner.getSubunits();
  List<Integer> modelNumbers=subunits.getModelNumbers();
  List<String> chainIds=subunits.getChainIds();
  List<List<Integer>> orbits=rotationAxisAligner.getOrbits();
  int fold=rotationGroup.getRotation(0).getFold();
  Color[] col=null;
  Color4f[] colors=null;
  if (fold > 1) {
    col=ColorBrewer.Spectral.getColorPalette(2 * fold);
    colors=ColorConverter.convertColor4f(col);
  }
 else {
    col=ColorBrewer.Spectral.getColorPalette(orbits.size());
    colors=ColorConverter.convertColor4f(col);
  }
  int half=colors.length / 2;
  for (int i=0; i < half; i++) {
    if (i % 2 != 0) {
      Color4f temp=colors[i];
      colors[i]=colors[half + i];
      colors[half + i]=temp;
    }
  }
  Map<Color4f,List<String>> colorMap=new HashMap<Color4f,List<String>>();
  for (int i=0; i < orbits.size(); i++) {
    for (int j=0; j < fold; j++) {
      int colorIndex=i;
      if (fold > 1) {
        if (i % 2 == 0) {
          colorIndex=j;
        }
 else {
          colorIndex=fold + j;
        }
      }
      int subunit=orbits.get(i).get(j);
      Color4f c=colors[colorIndex];
      List<String> ids=colorMap.get(c);
      if (ids == null) {
        ids=new ArrayList<String>();
        colorMap.put(c,ids);
      }
      String id=getChainSpecification(modelNumbers,chainIds,subunit);
      ids.add(id);
    }
  }
  return defaultColoring + getJmolColorScript(colorMap) + getJmolLigandScript();
}