nus-yam/ex-repair huggingface dataset:
Program: 16425
Project: 16425
Buggy source:
private void printStructure(Structure struc){
  System.out.println(struc);
  String pdbid=struc.getPDBCode();
  for (int i=0; i < struc.nrModels(); i++) {
    for (    Chain ch : struc.getModel(i)) {
      if (!ch.getChainID().equals("String_Node_Str"))       continue;
      System.out.println(pdbid + "String_Node_Str" + ch.getChainID()+ "String_Node_Str"+ ch.getAtomSequence());
      System.out.println(pdbid + "String_Node_Str" + ch.getChainID()+ "String_Node_Str"+ ch.getSeqResSequence());
      List<Group> group=ch.getSeqResGroups();
      int seqPos=0;
      for (      Group gp : group) {
        System.out.println(ch.getChainID() + "String_Node_Str" + seqPos+ "String_Node_Str"+ gp.getResidueNumber()+ "String_Node_Str"+ gp.getPDBName()+ "String_Node_Str"+ gp.getType());
        seqPos++;
      }
    }
  }
}

Fixed version (ground truth):
private void printStructure(Structure struc){
  System.out.println(struc);
  String pdbid=struc.getPDBCode();
  for (int i=0; i < struc.nrModels(); i++) {
    for (    Chain ch : struc.getModel(i)) {
      if (!ch.getName().equals("String_Node_Str"))       continue;
      System.out.println(pdbid + "String_Node_Str" + ch.getName()+ "String_Node_Str"+ ch.getAtomSequence());
      System.out.println(pdbid + "String_Node_Str" + ch.getName()+ "String_Node_Str"+ ch.getSeqResSequence());
      List<Group> group=ch.getSeqResGroups();
      int seqPos=0;
      for (      Group gp : group) {
        System.out.println(ch.getName() + "String_Node_Str" + seqPos+ "String_Node_Str"+ gp.getResidueNumber()+ "String_Node_Str"+ gp.getPDBName()+ "String_Node_Str"+ gp.getType());
        seqPos++;
      }
    }
  }
}
Program: 16427
Project: 16427
Buggy source:
public static void main(String[] args) throws IOException, StructureException {
  String pdbID="String_Node_Str";
  FileParsingParameters params=new FileParsingParameters();
  params.setParseSecStruc(true);
  AtomCache cache=new AtomCache();
  cache.setFileParsingParams(params);
  cache.setUseMmCif(false);
  Structure s=cache.getStructure(pdbID);
  System.out.println("String_Node_Str");
  List<SecStrucInfo> ssi=SecStrucTools.getSecStrucInfo(s);
  for (  SecStrucInfo ss : ssi) {
    System.out.println(ss.getGroup().getChain().getChainID() + "String_Node_Str" + ss.getGroup().getResidueNumber()+ "String_Node_Str"+ ss.getGroup().getPDBName()+ "String_Node_Str"+ ss.toString());
  }
  DSSPParser.fetch(pdbID,s,true);
  System.out.println("String_Node_Str");
  ssi=SecStrucTools.getSecStrucInfo(s);
  for (  SecStrucInfo ss : ssi) {
    System.out.println(ss.getGroup().getChain().getChainID() + "String_Node_Str" + ss.getGroup().getResidueNumber()+ "String_Node_Str"+ ss.getGroup().getPDBName()+ "String_Node_Str"+ ss.toString());
  }
}

Fixed version (ground truth):
public static void main(String[] args) throws IOException, StructureException {
  String pdbID="String_Node_Str";
  FileParsingParameters params=new FileParsingParameters();
  params.setParseSecStruc(true);
  AtomCache cache=new AtomCache();
  cache.setFileParsingParams(params);
  cache.setUseMmCif(false);
  Structure s=cache.getStructure(pdbID);
  System.out.println("String_Node_Str");
  List<SecStrucInfo> ssi=SecStrucTools.getSecStrucInfo(s);
  for (  SecStrucInfo ss : ssi) {
    System.out.println(ss.getGroup().getChain().getName() + "String_Node_Str" + ss.getGroup().getResidueNumber()+ "String_Node_Str"+ ss.getGroup().getPDBName()+ "String_Node_Str"+ ss.toString());
  }
  DSSPParser.fetch(pdbID,s,true);
  System.out.println("String_Node_Str");
  ssi=SecStrucTools.getSecStrucInfo(s);
  for (  SecStrucInfo ss : ssi) {
    System.out.println(ss.getGroup().getChain().getName() + "String_Node_Str" + ss.getGroup().getResidueNumber()+ "String_Node_Str"+ ss.getGroup().getPDBName()+ "String_Node_Str"+ ss.toString());
  }
}
Program: 16428
Project: 16428
Buggy source:
public void basicLoad(){
  try {
    PDBFileReader reader=new PDBFileReader();
    reader.setPath("String_Node_Str");
    FileParsingParameters params=new FileParsingParameters();
    params.setAlignSeqRes(true);
    params.setParseSecStruc(false);
    reader.setFileParsingParameters(params);
    Structure structure=reader.getStructureById("String_Node_Str");
    System.out.println(structure);
    Chain c=structure.getChainByPDB("String_Node_Str");
    System.out.print(c);
    System.out.println(c.getEntityInfo());
  }
 catch (  Exception e) {
    e.printStackTrace();
  }
}

Fixed version (ground truth):
public void basicLoad(){
  try {
    PDBFileReader reader=new PDBFileReader();
    reader.setPath("String_Node_Str");
    FileParsingParameters params=new FileParsingParameters();
    params.setAlignSeqRes(true);
    params.setParseSecStruc(false);
    reader.setFileParsingParameters(params);
    Structure structure=reader.getStructureById("String_Node_Str");
    System.out.println(structure);
    Chain c=structure.getPolyChainByPDB("String_Node_Str");
    System.out.print(c);
    System.out.println(c.getEntityInfo());
  }
 catch (  Exception e) {
    e.printStackTrace();
  }
}
Program: 16429
Project: 16429
Buggy source:
public void loadStructureIO(){
  try {
    Structure s1=StructureIO.getStructure("String_Node_Str");
    System.out.println(s1.getPDBCode() + "String_Node_Str");
    System.out.println(StructureTools.getNrAtoms(s1));
    Chain chain1=s1.getChain(0);
    System.out.println("String_Node_Str" + chain1);
    System.out.println("String_Node_Str" + chain1.getChainID() + "String_Node_Str");
    for (    SeqMisMatch mm : chain1.getSeqMisMatches()) {
      System.out.println(mm);
    }
    Structure s2=StructureIO.getBiologicalAssembly("String_Node_Str");
    System.out.println(s2.getPDBCode() + "String_Node_Str");
    System.out.println(StructureTools.getNrAtoms(s2));
  }
 catch (  Exception e) {
    e.printStackTrace();
  }
}

Fixed version (ground truth):
public void loadStructureIO(){
  try {
    Structure s1=StructureIO.getStructure("String_Node_Str");
    System.out.println(s1.getPDBCode() + "String_Node_Str");
    System.out.println(StructureTools.getNrAtoms(s1));
    Chain chain1=s1.getChain(0);
    System.out.println("String_Node_Str" + chain1);
    System.out.println("String_Node_Str" + chain1.getName() + "String_Node_Str");
    for (    SeqMisMatch mm : chain1.getSeqMisMatches()) {
      System.out.println(mm);
    }
    Structure s2=StructureIO.getBiologicalAssembly("String_Node_Str");
    System.out.println(s2.getPDBCode() + "String_Node_Str");
    System.out.println(StructureTools.getNrAtoms(s2));
  }
 catch (  Exception e) {
    e.printStackTrace();
  }
}
Program: 16430
Project: 16430
Buggy source:
/** 
 * An example demonstrating how to directly use the mmCif file parsing classes. This could potentially be used to use the parser to populate a data-structure that is different from the biojava-structure data model.
 */
public void loadFromDirectAccess(){
  String pdbId="String_Node_Str";
  StructureProvider pdbreader=new MMCIFFileReader();
  try {
    Structure s=pdbreader.getStructureById(pdbId);
    Chain h=s.getChainByPDB("String_Node_Str");
    List<Group> ligands=h.getAtomLigands();
    System.out.println("String_Node_Str" + h.getChainID());
    for (    Group l : ligands) {
      System.out.println(l);
    }
    System.out.println("String_Node_Str");
    Group qwe=h.getGroupByPDB(new ResidueNumber("String_Node_Str",373,null));
    System.out.println(qwe.getChemComp());
    System.out.println(h.getSeqResSequence());
    System.out.println(h.getAtomSequence());
    System.out.println(h.getAtomGroups(GroupType.HETATM));
    System.out.println("String_Node_Str" + s.getEntityInfos());
  }
 catch (  Exception e) {
    e.printStackTrace();
  }
}

Fixed version (ground truth):
/** 
 * An example demonstrating how to directly use the mmCif file parsing classes. This could potentially be used to use the parser to populate a data-structure that is different from the biojava-structure data model.
 */
public void loadFromDirectAccess(){
  String pdbId="String_Node_Str";
  StructureProvider pdbreader=new MMCIFFileReader();
  try {
    Structure s=pdbreader.getStructureById(pdbId);
    Chain h=s.getNonPolyChainByPDB("String_Node_Str");
    List<Group> ligands=h.getAtomLigands();
    System.out.println("String_Node_Str" + h.getName());
    for (    Group l : ligands) {
      System.out.println(l);
    }
    System.out.println("String_Node_Str");
    Group qwe=h.getGroupByPDB(new ResidueNumber("String_Node_Str",373,null));
    System.out.println(qwe.getChemComp());
    System.out.println(h.getSeqResSequence());
    System.out.println(h.getAtomSequence());
    System.out.println(h.getAtomGroups(GroupType.HETATM));
    System.out.println("String_Node_Str" + s.getEntityInfos());
  }
 catch (  Exception e) {
    e.printStackTrace();
  }
}
Program: 16431
Project: 16431
Buggy source:
/** 
 * Retrieve a non-polymeric Chain based on the 'public' chain name (authId) for the given model index
 * @param authId the author id (chainName, public chain id)
 * @param modelIdx the index of the required model (0-based)
 * @return a non-polymeric Chain or null if it can't be found
 */
Chain getNonPolyChainByPDB(String authId,int modelIdx);

Fixed version (ground truth):
/** 
 * Retrieve the first non-polymeric Chain corresponding to the 'public' chain name (authId) and the given model index. <p> Note that other non-polymeric chains might still exist with the same authId, due to the one-to-many relationship between public chain ids (authIds) and the stored non-polymeric  chains that follow the mmCIF data model.  If the user is interested in non-polymeric chains different from first one, he/she would need to go through   {@link #getNonPolyChains(int)} to find them all.
 * @param authId the author id (chainName, public chain id)
 * @param modelIdx the index of the required model (0-based)
 * @return a non-polymeric Chain or null if it can't be found
 */
Chain getNonPolyChainByPDB(String authId,int modelIdx);
Program: 16432
Project: 16432
Buggy source:
/** 
 * Request a particular chain from a particular model
 * @param modelnr the number of the model to use
 * @param authId the name of a chain that should be returned
 * @return Chain the requested chain
 * @throws StructureException
 * @Deprecated use {@link #getChainByPDB(String,int)} instead
 */
@Deprecated Chain findChain(String authId,int modelnr) throws StructureException ;

Fixed version (ground truth):
/** 
 * Request a particular chain from a particular model
 * @param authId the name of a chain that should be returned
 * @param modelnr the number of the model to use
 * @return Chain the requested chain
 * @throws StructureException
 * @Deprecated use {@link #getPolyChainByPDB(String,int)} or {@link #getNonPolyChainByPDB(String,int)} instead
 */
@Deprecated Chain findChain(String authId,int modelnr) throws StructureException ;
Program: 16433
Project: 16433
Buggy source:
/** 
 * Prints the connections in PDB style Rewritten since 5.0 to use   {@link Bond}s Will produce strictly one CONECT record per bond (won't group several bonds in one line)
 */
private String printPDBConnections(){
  StringBuilder str=new StringBuilder();
  for (  Chain c : structure.getChains()) {
    for (    Group g : c.getAtomGroups()) {
      for (      Atom a : g.getAtoms()) {
        for (        Bond b : a.getBonds()) {
          str.append(String.format("String_Node_Str" + newline,b.getAtomA().getPDBserial(),b.getAtomB().getPDBserial()));
        }
      }
    }
  }
  return str.toString();
}

Fixed version (ground truth):
/** 
 * Prints the connections in PDB style Rewritten since 5.0 to use   {@link Bond}s Will produce strictly one CONECT record per bond (won't group several bonds in one line)
 */
private String printPDBConnections(){
  StringBuilder str=new StringBuilder();
  for (  Chain c : structure.getChains()) {
    for (    Group g : c.getAtomGroups()) {
      for (      Atom a : g.getAtoms()) {
        if (a.getBonds() != null) {
          for (          Bond b : a.getBonds()) {
            str.append(String.format("String_Node_Str" + newline,b.getAtomA().getPDBserial(),b.getAtomB().getPDBserial()));
          }
        }
      }
    }
  }
  return str.toString();
}
Program: 16434
Project: 16434
Buggy source:
public static void toPDB(Atom a,StringBuffer str){
  toPDB(a,str,a.getGroup().getChainId());
}

Fixed version (ground truth):
public static void toPDB(Atom a,StringBuffer str){
  toPDB(a,str,a.getGroup().getChain().getName());
}
Program: 16436
Project: 16436
Buggy source:
/** 
 * Returns the list of unique interfaces that the given Structure has upon generation of all crystal symmetry mates. An interface is defined as any pair of chains that contact, i.e. for which there is at least a pair of atoms (one from each chain) within the given cutoff distance.
 * @param cutoff the distance cutoff for 2 chains to be considered in contact
 * @return
 */
public StructureInterfaceList getUniqueInterfaces(double cutoff){
  StructureInterfaceList set=new StructureInterfaceList();
  if (structure.getChains().size() == 0) {
    logger.warn("String_Node_Str");
    return set;
  }
  initialiseVisited();
  calcInterfacesCrystal(set,cutoff);
  return set;
}

Fixed version (ground truth):
/** 
 * Returns the list of unique interfaces that the given Structure has upon generation of all crystal symmetry mates. An interface is defined as any pair of chains that contact, i.e. for which there is at least a pair of atoms (one from each chain) within the given cutoff distance.
 * @param cutoff the distance cutoff for 2 chains to be considered in contact
 * @return
 */
public StructureInterfaceList getUniqueInterfaces(double cutoff){
  StructureInterfaceList set=new StructureInterfaceList();
  if (numPolyChainsAu == 0) {
    logger.warn("String_Node_Str");
    return set;
  }
  initialiseVisited();
  calcInterfacesCrystal(set,cutoff);
  return set;
}
Program: 16437
Project: 16437
Buggy source:
public CrystalBuilder(Structure structure){
  this.structure=structure;
  this.crystallographicInfo=structure.getCrystallographicInfo();
  this.numChainsAu=structure.getChains().size();
  this.numOperatorsSg=1;
  if (structure.isCrystallographic()) {
    this.isCrystallographic=true;
    if (this.crystallographicInfo.getSpaceGroup() == null) {
      logger.warn("String_Node_Str");
      this.isCrystallographic=false;
    }
 else {
      this.numOperatorsSg=this.crystallographicInfo.getSpaceGroup().getMultiplicity();
    }
    if (this.crystallographicInfo.getCrystalCell() == null) {
      logger.warn("String_Node_Str");
      this.isCrystallographic=false;
    }
  }
 else {
    this.isCrystallographic=false;
  }
  this.numCells=DEF_NUM_CELLS;
}

Fixed version (ground truth):
public CrystalBuilder(Structure structure){
  this.structure=structure;
  this.crystallographicInfo=structure.getCrystallographicInfo();
  this.numPolyChainsAu=structure.getPolyChains().size();
  this.numOperatorsSg=1;
  if (structure.isCrystallographic()) {
    this.isCrystallographic=true;
    if (this.crystallographicInfo.getSpaceGroup() == null) {
      logger.warn("String_Node_Str");
      this.isCrystallographic=false;
    }
 else {
      this.numOperatorsSg=this.crystallographicInfo.getSpaceGroup().getMultiplicity();
    }
    if (this.crystallographicInfo.getCrystalCell() == null) {
      logger.warn("String_Node_Str");
      this.isCrystallographic=false;
    }
  }
 else {
    this.isCrystallographic=false;
  }
  this.numCells=DEF_NUM_CELLS;
}
Program: 16438
Project: 16438
Buggy source:
private StructureInterface calcContacts(Chain chaini,Chain chainj,double cutoff,CrystalTransform tt,StringBuilder builder){
  AtomContactSet graph=StructureTools.getAtomsInContact(chaini,chainj,cutoff,INCLUDE_HETATOMS);
  if (graph.size() > 0) {
    if (builder != null)     builder.append("String_Node_Str");
    CrystalTransform transf=new CrystalTransform(this.crystallographicInfo.getSpaceGroup());
    StructureInterface interf=new StructureInterface(StructureTools.getAllAtomArray(chaini),StructureTools.getAllAtomArray(chainj),chaini.getChainID(),chainj.getChainID(),graph,transf,tt);
    return interf;
  }
 else {
    if (builder != null)     builder.append("String_Node_Str");
    return null;
  }
}

Fixed version (ground truth):
private StructureInterface calcContacts(Chain chaini,Chain chainj,double cutoff,CrystalTransform tt,StringBuilder builder){
  AtomContactSet graph=StructureTools.getAtomsInContact(chaini,chainj,cutoff,INCLUDE_HETATOMS);
  if (graph.size() > 0) {
    if (builder != null)     builder.append("String_Node_Str");
    CrystalTransform transf=new CrystalTransform(this.crystallographicInfo.getSpaceGroup());
    StructureInterface interf=new StructureInterface(StructureTools.getAllAtomArray(chaini),StructureTools.getAllAtomArray(chainj),chaini.getName(),chainj.getName(),graph,transf,tt);
    return interf;
  }
 else {
    if (builder != null)     builder.append("String_Node_Str");
    return null;
  }
}
Program: 16439
Project: 16439
Buggy source:
private void setBb(Structure s,boolean includeHetAtoms,int i){
  chainBbs[i]=new BoundingBox[numChainsAu];
  for (int j=0; j < numChainsAu; j++) {
    System.out.println(s.getChain(j));
    chainBbs[i][j]=new BoundingBox(StructureTools.getAllNonHAtomArray(s.getChain(j),includeHetAtoms));
  }
  auBbs[i]=new BoundingBox(chainBbs[i]);
}

Fixed version (ground truth):
private void setBb(Structure s,boolean includeHetAtoms,int i){
  chainBbs[i]=new BoundingBox[numPolyChainsAu];
  List<Chain> polyChains=s.getPolyChains();
  int j=0;
  for (  Chain polyChain : polyChains) {
    chainBbs[i][j]=new BoundingBox(StructureTools.getAllNonHAtomArray(polyChain,includeHetAtoms));
    j++;
  }
  auBbs[i]=new BoundingBox(chainBbs[i]);
}
Program: 16440
Project: 16440
Buggy source:
public UnitCellBoundingBox(int numOperatorsSg,int numChainsAu){
  this.numOperatorsSg=numOperatorsSg;
  this.numChainsAu=numChainsAu;
  this.chainBbs=new BoundingBox[numOperatorsSg][numChainsAu];
  this.auBbs=new BoundingBox[numOperatorsSg];
}

Fixed version (ground truth):
public UnitCellBoundingBox(int numOperatorsSg,int numPolyChainsAu){
  this.numOperatorsSg=numOperatorsSg;
  this.numPolyChainsAu=numPolyChainsAu;
  this.chainBbs=new BoundingBox[numOperatorsSg][numPolyChainsAu];
  this.auBbs=new BoundingBox[numOperatorsSg];
}
Program: 16441
Project: 16441
Buggy source:
/** 
 * Returns a new BoundingBoxes object containing the same bounds as this BoundingBoxes object translated by the given translation
 * @param translation
 * @return
 */
public UnitCellBoundingBox getTranslatedBbs(Vector3d translation){
  UnitCellBoundingBox translatedBbs=new UnitCellBoundingBox(numOperatorsSg,numChainsAu);
  for (int i=0; i < numOperatorsSg; i++) {
    for (int j=0; j < numChainsAu; j++) {
      translatedBbs.chainBbs[i][j]=new BoundingBox(this.chainBbs[i][j]);
      translatedBbs.chainBbs[i][j].translate(translation);
    }
    translatedBbs.auBbs[i]=new BoundingBox(translatedBbs.chainBbs[i]);
  }
  return translatedBbs;
}

Fixed version (ground truth):
/** 
 * Returns a new BoundingBoxes object containing the same bounds as this BoundingBoxes object translated by the given translation
 * @param translation
 * @return
 */
public UnitCellBoundingBox getTranslatedBbs(Vector3d translation){
  UnitCellBoundingBox translatedBbs=new UnitCellBoundingBox(numOperatorsSg,numPolyChainsAu);
  for (int i=0; i < numOperatorsSg; i++) {
    for (int j=0; j < numPolyChainsAu; j++) {
      translatedBbs.chainBbs[i][j]=new BoundingBox(this.chainBbs[i][j]);
      translatedBbs.chainBbs[i][j].translate(translation);
    }
    translatedBbs.auBbs[i]=new BoundingBox(translatedBbs.chainBbs[i]);
  }
  return translatedBbs;
}
Program: 16442
Project: 16442
Buggy source:
/** 
 * {@inheritDoc} 
 */
@Override public List<Chain> getChains(){
  return getChains(0);
}

Fixed version (ground truth):
/** 
 * {@inheritDoc} 
 */
@Override public List<Chain> getChains(){
  if (models.size() == 0) {
    return new ArrayList<>(0);
  }
  return getChains(0);
}
Program: 16446
Project: 16446
Buggy source:
private List<Chain> getFirstModelChains(){
  List<Chain> firstModel=new ArrayList<>();
  for (  String id : getChainIds()) {
    for (    Chain chain : chains) {
      if (chain.getId().equals(id)) {
        firstModel.add(chain);
        break;
      }
    }
  }
  return firstModel;
}

Fixed version (ground truth):
private List<Chain> getFirstModelChains(){
  List<Chain> firstModel=new ArrayList<>();
  outer:   for (  String id : getChainIds()) {
    for (    Chain chain : chains) {
      if (chain.getId().equals(id)) {
        firstModel.add(chain);
        break outer;
      }
    }
  }
  return firstModel;
}
Program: 16447
Project: 16447
Buggy source:
public void align(Structure s,List<Chain> seqResList){
  List<Chain> atomList=s.getModel(0);
  for (  Chain seqRes : seqResList) {
    Chain atomRes=getMatchingAtomRes(seqRes,atomList);
    if (atomRes == null)     continue;
    mapSeqresRecords(atomRes,seqRes);
  }
}

Fixed version (ground truth):
public void align(Structure s,List<Chain> seqResList){
  List<Chain> atomList=s.getModel(0);
  for (  Chain seqRes : seqResList) {
    Chain atomRes=getMatchingAtomRes(seqRes,atomList,false);
    if (atomRes == null)     continue;
    mapSeqresRecords(atomRes,seqRes);
  }
}
Program: 16448
Project: 16448
Buggy source:
/** 
 * Storing unaligned SEQRES groups in a Structure.
 * @param structure
 * @param seqResChains
 */
public static void storeUnAlignedSeqRes(Structure structure,List<Chain> seqResChains,boolean headerOnly){
  for (int i=0; i < structure.nrModels(); i++) {
    List<Chain> atomChains=structure.getModel(i);
    for (    Chain seqRes : seqResChains) {
      Chain atomRes;
      if (headerOnly) {
        seqRes.setSeqResGroups(seqRes.getAtomGroups());
        seqRes.setAtomGroups(new ArrayList<Group>());
        atomChains.add(seqRes);
      }
 else {
        atomRes=SeqRes2AtomAligner.getMatchingAtomRes(seqRes,atomChains);
        if (atomRes != null)         atomRes.setSeqResGroups(seqRes.getAtomGroups());
 else         logger.warn("String_Node_Str" + seqRes.getId());
      }
    }
    if (headerOnly) {
      structure.setChains(i,atomChains);
    }
  }
}

Fixed version (ground truth):
/** 
 * Storing unaligned SEQRES groups in a Structure.
 * @param structure
 * @param seqResChains
 */
public static void storeUnAlignedSeqRes(Structure structure,List<Chain> seqResChains,boolean headerOnly){
  for (int i=0; i < structure.nrModels(); i++) {
    List<Chain> atomChains=structure.getModel(i);
    for (    Chain seqRes : seqResChains) {
      Chain atomRes;
      if (headerOnly) {
        seqRes.setSeqResGroups(seqRes.getAtomGroups());
        seqRes.setAtomGroups(new ArrayList<Group>());
        atomChains.add(seqRes);
      }
 else {
        atomRes=SeqRes2AtomAligner.getMatchingAtomRes(seqRes,atomChains,true);
        if (atomRes != null)         atomRes.setSeqResGroups(seqRes.getAtomGroups());
 else         logger.warn("String_Node_Str" + seqRes.getId());
      }
    }
    if (headerOnly) {
      structure.setChains(i,atomChains);
    }
  }
}
Program: 16449
Project: 16449
Buggy source:
public static Chain getMatchingAtomRes(Chain seqRes,List<Chain> atomList){
  Iterator<Chain> iter=atomList.iterator();
  while (iter.hasNext()) {
    Chain atomChain=iter.next();
    if (atomChain.getName().equals(seqRes.getName())) {
      return atomChain;
    }
  }
  logger.info("String_Node_Str" + seqRes.getId() + "String_Node_Str"+ seqRes.getName()+ "String_Node_Str"+ atomList.size());
  return null;
}

Fixed version (ground truth):
/** 
 * @param seqRes
 * @param atomList
 * @param useChainId if true chainId (Chain.getId) is used for matching, if false chainName (Chain.getName) is used 
 * @return
 */
public static Chain getMatchingAtomRes(Chain seqRes,List<Chain> atomList,boolean useChainId){
  Iterator<Chain> iter=atomList.iterator();
  while (iter.hasNext()) {
    Chain atomChain=iter.next();
    String atomChainId=null;
    String seqResChainId=null;
    if (useChainId) {
      atomChainId=atomChain.getId();
      seqResChainId=seqRes.getId();
    }
 else {
      atomChainId=atomChain.getName();
      seqResChainId=seqRes.getName();
    }
    if (atomChainId.equals(seqResChainId)) {
      return atomChain;
    }
  }
  logger.info("String_Node_Str" + seqRes.getId() + "String_Node_Str"+ seqRes.getName()+ "String_Node_Str"+ atomList.size());
  return null;
}
Program: 16450
Project: 16450
Buggy source:
private void alignSeqRes(){
  logger.debug("String_Node_Str");
  for (int model=0; model < structure.nrModels(); model++) {
    List<Chain> atomList=structure.getModel(model);
    for (    Chain seqResChain : seqResChains) {
      Chain atomChain=SeqRes2AtomAligner.getMatchingAtomRes(seqResChain,atomList);
      if (atomChain == null) {
        logger.warn("String_Node_Str",seqResChain.getId());
        continue;
      }
      List<Group> seqResGroups=new ArrayList<Group>();
      for (int i=0; i < seqResChain.getAtomGroups().size(); i++) {
        seqResGroups.add((Group)seqResChain.getAtomGroups().get(i).clone());
      }
      for (int seqResPos=0; seqResPos < seqResGroups.size(); seqResPos++) {
        Group seqresG=seqResGroups.get(seqResPos);
        boolean found=false;
        for (        Group atomG : atomChain.getAtomGroups()) {
          int internalNr=getInternalNr(atomG);
          if (seqresG.getResidueNumber().getSeqNum() == internalNr) {
            seqResGroups.set(seqResPos,atomG);
            found=true;
            break;
          }
        }
        if (!found)         seqresG.setResidueNumber(null);
      }
      atomChain.setSeqResGroups(seqResGroups);
    }
  }
}

Fixed version (ground truth):
private void alignSeqRes(){
  logger.debug("String_Node_Str");
  for (int model=0; model < structure.nrModels(); model++) {
    List<Chain> atomList=structure.getModel(model);
    for (    Chain seqResChain : seqResChains) {
      Chain atomChain=SeqRes2AtomAligner.getMatchingAtomRes(seqResChain,atomList,true);
      if (atomChain == null) {
        logger.warn("String_Node_Str",seqResChain.getId());
        continue;
      }
      List<Group> seqResGroups=new ArrayList<Group>();
      for (int i=0; i < seqResChain.getAtomGroups().size(); i++) {
        seqResGroups.add((Group)seqResChain.getAtomGroups().get(i).clone());
      }
      for (int seqResPos=0; seqResPos < seqResGroups.size(); seqResPos++) {
        Group seqresG=seqResGroups.get(seqResPos);
        boolean found=false;
        for (        Group atomG : atomChain.getAtomGroups()) {
          int internalNr=getInternalNr(atomG);
          if (seqresG.getResidueNumber().getSeqNum() == internalNr) {
            seqResGroups.set(seqResPos,atomG);
            found=true;
            break;
          }
        }
        if (!found)         seqresG.setResidueNumber(null);
      }
      atomChain.setSeqResGroups(seqResGroups);
    }
  }
}
Program: 16451
Project: 16451
Buggy source:
private ResidueNumber findResNumInOtherChains(int i,Chain chain){
  for (  Chain c : getChains()) {
    if (c == chain)     continue;
    Group seqResGroup=c.getSeqResGroup(i);
    if (seqResGroup == null) {
      logger.warn("String_Node_Str",i,c.getId(),chain.getId());
      continue;
    }
    if (seqResGroup.getResidueNumber() != null)     return seqResGroup.getResidueNumber();
  }
  return null;
}

Fixed version (ground truth):
private ResidueNumber findResNumInOtherChains(int i,Chain chain){
  for (  Chain c : getFirstModelChains()) {
    if (c == chain)     continue;
    Group seqResGroup=c.getSeqResGroup(i);
    if (seqResGroup == null) {
      logger.warn("String_Node_Str",i,c.getId(),chain.getId());
      continue;
    }
    if (seqResGroup.getResidueNumber() != null)     return seqResGroup.getResidueNumber();
  }
  return null;
}
Program: 16452
Project: 16452
Buggy source:
public static Chain getMatchingAtomRes(Chain seqRes,List<Chain> atomList){
  Iterator<Chain> iter=atomList.iterator();
  while (iter.hasNext()) {
    Chain atomChain=iter.next();
    if (atomChain.getId().equals(seqRes.getId())) {
      return atomChain;
    }
  }
  logger.info("String_Node_Str" + seqRes.getId() + "String_Node_Str"+ seqRes.getName()+ "String_Node_Str"+ atomList.size());
  return null;
}

Fixed version (ground truth):
public static Chain getMatchingAtomRes(Chain seqRes,List<Chain> atomList){
  Iterator<Chain> iter=atomList.iterator();
  while (iter.hasNext()) {
    Chain atomChain=iter.next();
    if (atomChain.getName().equals(seqRes.getName())) {
      return atomChain;
    }
  }
  logger.info("String_Node_Str" + seqRes.getId() + "String_Node_Str"+ seqRes.getName()+ "String_Node_Str"+ atomList.size());
  return null;
}
Program: 16453
Project: 16453
Buggy source:
@Test public void test3C5FWithSeqresPdb() throws IOException, StructureException {
  InputStream inStream=new GZIPInputStream(this.getClass().getResourceAsStream("String_Node_Str"));
  assertNotNull(inStream);
  PDBFileParser pdbpars=new PDBFileParser();
  FileParsingParameters params=new FileParsingParameters();
  params.setAlignSeqRes(true);
  pdbpars.setFileParsingParameters(params);
  Structure s=pdbpars.parsePDBFile(inStream);
  assertNotNull(s);
  assertEquals(8,s.getChains().size());
  assertEquals(4,s.getEntityInfos().size());
  CrystalBuilder cb=new CrystalBuilder(s);
  StructureInterfaceList interfaces=cb.getUniqueInterfaces(5.5);
  interfaces.calcAsas(100,1,0);
  interfaces.removeInterfacesBelowArea();
  List<StructureInterfaceCluster> clusters=interfaces.getClusters();
  assertEquals(23,interfaces.size());
  assertTrue("String_Node_Str",clusters.size() < 23);
  assertEquals("String_Node_Str",2,clusters.get(2).getMembers().size());
  assertTrue("String_Node_Str",interfaces.get(3).isIsologous());
}

Fixed version (ground truth):
@Test public void test3C5FWithSeqresPdb() throws IOException, StructureException {
  InputStream inStream=new GZIPInputStream(this.getClass().getResourceAsStream("String_Node_Str"));
  assertNotNull(inStream);
  PDBFileParser pdbpars=new PDBFileParser();
  FileParsingParameters params=new FileParsingParameters();
  params.setAlignSeqRes(true);
  pdbpars.setFileParsingParameters(params);
  Structure s=pdbpars.parsePDBFile(inStream);
  assertNotNull(s);
  assertEquals(8,s.getPolyChains().size());
  assertEquals(6,s.getEntityInfos().size());
  CrystalBuilder cb=new CrystalBuilder(s);
  StructureInterfaceList interfaces=cb.getUniqueInterfaces(5.5);
  interfaces.calcAsas(100,1,0);
  interfaces.removeInterfacesBelowArea();
  List<StructureInterfaceCluster> clusters=interfaces.getClusters();
  assertEquals(23,interfaces.size());
  assertTrue("String_Node_Str",clusters.size() < 23);
  assertEquals("String_Node_Str",2,clusters.get(2).getMembers().size());
  assertTrue("String_Node_Str",interfaces.get(3).isIsologous());
}
Program: 16454
Project: 16454
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.getChainByPDB(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 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);
}
Program: 16455
Project: 16455
Buggy source:
/** 
 * Test that the bonds we are finding is consistenty.
 * @throws IOException
 * @throws StructureException
 */
@Test public void testInterGroupBonds() throws IOException, StructureException {
  assertEquals(getInterBonds("String_Node_Str"),2236);
  assertEquals(getInterBonds("String_Node_Str"),956);
  assertEquals(getInterBonds("String_Node_Str"),2290);
  assertEquals(getInterBonds("String_Node_Str"),22);
}

Fixed version (ground truth):
/** 
 * Test that the bonds we are finding is consistenty.
 * @throws IOException
 * @throws StructureException
 */
@Test public void testInterGroupBonds() throws IOException, StructureException {
  assertEquals(2236,getInterBonds("String_Node_Str"));
  assertEquals(956,getInterBonds("String_Node_Str"));
  assertEquals(2294,getInterBonds("String_Node_Str"));
  assertEquals(22,getInterBonds("String_Node_Str"));
}
Program: 16456
Project: 16456
Buggy source:
/** 
 * Find all of the inter group bonds in a structure
 * @param pdbId the pdb id of the structure to determine
 * @return the number of inter group bonds (dobule counted) in a structure
 * @throws IOException
 * @throws StructureException
 */
public int getInterBonds(String pdbId) throws IOException, StructureException {
  AtomCache cache=new AtomCache();
  cache.setUseMmCif(true);
  cache.setFetchBehavior(FetchBehavior.FETCH_FILES);
  FileParsingParameters params=cache.getFileParsingParams();
  params.setCreateAtomBonds(true);
  params.setAlignSeqRes(true);
  params.setParseBioAssembly(true);
  DownloadChemCompProvider dcc=new DownloadChemCompProvider();
  ChemCompGroupFactory.setChemCompProvider(dcc);
  dcc.checkDoFirstInstall();
  cache.setFileParsingParams(params);
  StructureIO.setAtomCache(cache);
  int counter=0;
  Structure newStruc=StructureIO.getStructure(pdbId);
  for (  Chain c : newStruc.getChains()) {
    for (    Group g : c.getAtomGroups()) {
      List<Atom> theseAtoms=g.getAtoms();
      for (      Atom a : theseAtoms) {
        List<Bond> theseBonds=a.getBonds();
        if (theseBonds != null) {
          for (          Bond b : a.getBonds()) {
            Atom other=b.getOther(a);
            int indexOther=theseAtoms.indexOf(other);
            if (indexOther < 0 || indexOther >= theseAtoms.size()) {
              counter++;
            }
          }
        }
      }
    }
  }
  return counter;
}

Fixed version (ground truth):
/** 
 * Find all of the inter group bonds in a structure
 * @param pdbId the pdb id of the structure to determine
 * @return the number of inter group bonds (double counted) in a structure
 * @throws IOException
 * @throws StructureException
 */
public int getInterBonds(String pdbId) throws IOException, StructureException {
  AtomCache cache=new AtomCache();
  cache.setUseMmCif(true);
  cache.setFetchBehavior(FetchBehavior.FETCH_FILES);
  FileParsingParameters params=cache.getFileParsingParams();
  params.setCreateAtomBonds(true);
  params.setAlignSeqRes(true);
  params.setParseBioAssembly(true);
  DownloadChemCompProvider dcc=new DownloadChemCompProvider();
  ChemCompGroupFactory.setChemCompProvider(dcc);
  dcc.checkDoFirstInstall();
  cache.setFileParsingParams(params);
  StructureIO.setAtomCache(cache);
  int counter=0;
  Structure newStruc=StructureIO.getStructure(pdbId);
  for (  Chain c : newStruc.getChains()) {
    for (    Group g : c.getAtomGroups()) {
      List<Atom> theseAtoms=g.getAtoms();
      for (      Atom a : theseAtoms) {
        List<Bond> theseBonds=a.getBonds();
        if (theseBonds != null) {
          for (          Bond b : a.getBonds()) {
            Atom other=b.getOther(a);
            int indexOther=theseAtoms.indexOf(other);
            if (indexOther < 0 || indexOther >= theseAtoms.size()) {
              counter++;
            }
          }
        }
      }
    }
  }
  return counter;
}
Program: 16457
Project: 16457
Buggy source:
public void addCharges(){
  for (  Chain c : structure.getChains()) {
    for (    Group g : c.getAtomGroups()) {
      ChemComp thisChemComp=ChemCompGroupFactory.getChemComp(g.getPDBName());
      List<ChemCompAtom> chemAtoms=thisChemComp.getAtoms();
      List<Atom> protAtoms=g.getAtoms();
      if (protAtoms.size() != chemAtoms.size()) {
        continue;
      }
      for (int i=0; i < protAtoms.size(); i++) {
        ChemCompAtom cca=chemAtoms.get(i);
        Atom a=protAtoms.get(i);
        try {
          short charge=Short.parseShort(cca.getCharge());
          a.setCharge(charge);
        }
 catch (        NumberFormatException e) {
          logger.info("String_Node_Str",a.getName(),g.getPDBName());
          a.setCharge((short)0);
        }
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * Function to add the charges to a given structure.
 */
public static void addCharges(Structure structure){
  for (int i=0; i < structure.nrModels(); i++) {
    for (    Chain c : structure.getChains(i)) {
      for (      Group g : c.getAtomGroups()) {
        ChemComp thisChemComp=ChemCompGroupFactory.getChemComp(g.getPDBName());
        List<ChemCompAtom> chemAtoms=thisChemComp.getAtoms();
        for (        ChemCompAtom chemCompAtom : chemAtoms) {
          Atom atom=g.getAtom(chemCompAtom.getAtom_id());
          String stringCharge=chemCompAtom.getCharge();
          short shortCharge=0;
          if (stringCharge != null) {
            shortCharge=Short.parseShort(stringCharge);
          }
 else {
            logger.warn("String_Node_Str" + chemCompAtom.getAtom_id() + "String_Node_Str"+ thisChemComp.getId());
          }
          if (atom != null) {
            atom.setCharge(shortCharge);
          }
          for (          Group altLoc : g.getAltLocs()) {
            Atom altAtom=altLoc.getAtom(chemCompAtom.getAtom_id());
            if (altAtom != null) {
              altAtom.setCharge(shortCharge);
            }
          }
        }
      }
    }
  }
}
Program: 16458
Project: 16458
Buggy source:
private void addCharges(){
  ChargeAdder adder=new ChargeAdder(structure);
  adder.addCharges();
}

Fixed version (ground truth):
private void addCharges(){
  ChargeAdder.addCharges(structure);
}
Program: 16459
Project: 16459
Buggy source:
private void addCharges(){
  ChargeAdder adder=new ChargeAdder(structure);
  adder.addCharges();
}

Fixed version (ground truth):
private void addCharges(){
  ChargeAdder.addCharges(structure);
}
Program: 16460
Project: 16460
Buggy source:
public void addCharges(){
  for (  Chain c : structure.getChains()) {
    for (    Group g : c.getAtomGroups()) {
      ChemComp thisChemComp=ChemCompGroupFactory.getChemComp(g.getPDBName());
      List<ChemCompAtom> chemAtoms=thisChemComp.getAtoms();
      List<Atom> protAtoms=g.getAtoms();
      if (protAtoms.size() != chemAtoms.size()) {
        continue;
      }
      for (int i=0; i < protAtoms.size(); i++) {
        ChemCompAtom cca=chemAtoms.get(i);
        Atom a=protAtoms.get(i);
        try {
          short charge=Short.parseShort(cca.getCharge());
          a.setCharge(charge);
        }
 catch (        NumberFormatException e) {
          logger.info("String_Node_Str",a.getName(),g.getPDBName());
          a.setCharge((short)0);
        }
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * Function to add the charges to a given structure.
 */
public static void addCharges(Structure structure){
  for (int i=0; i < structure.nrModels(); i++) {
    for (    Chain c : structure.getChains(i)) {
      for (      Group g : c.getAtomGroups()) {
        ChemComp thisChemComp=ChemCompGroupFactory.getChemComp(g.getPDBName());
        List<ChemCompAtom> chemAtoms=thisChemComp.getAtoms();
        for (        ChemCompAtom chemCompAtom : chemAtoms) {
          Atom atom=g.getAtom(chemCompAtom.getAtom_id());
          String stringCharge=chemCompAtom.getCharge();
          short shortCharge=0;
          if (stringCharge != null) {
            shortCharge=Short.parseShort(stringCharge);
          }
 else {
            logger.warn("String_Node_Str" + chemCompAtom.getAtom_id() + "String_Node_Str"+ thisChemComp.getId());
          }
          if (atom != null) {
            atom.setCharge(shortCharge);
          }
          for (          Group altLoc : g.getAltLocs()) {
            Atom altAtom=altLoc.getAtom(chemCompAtom.getAtom_id());
            if (altAtom != null) {
              altAtom.setCharge(shortCharge);
            }
          }
        }
      }
    }
  }
}
Program: 16461
Project: 16461
Buggy source:
/** 
 * Add the charges to the Structure
 */
private void addCharges(){
  ChargeAdder adder=new ChargeAdder(structure);
  adder.addCharges();
}

Fixed version (ground truth):
/** 
 * Add the charges to the Structure
 */
private void addCharges(){
  ChargeAdder.addCharges(structure);
}
Program: 16462
Project: 16462
Buggy source:
private void addCharges(){
  ChargeAdder adder=new ChargeAdder(structure);
  adder.addCharges();
}

Fixed version (ground truth):
private void addCharges(){
  ChargeAdder.addCharges(structure);
}
Program: 16463
Project: 16463
Buggy source:
@Override protected void setUp() throws Exception {
  super.setUp();
  AtomCache cache=new AtomCache();
  cache.setUseMmCif(true);
  cache.setFetchBehavior(FetchBehavior.FETCH_FILES);
  FileParsingParameters params=cache.getFileParsingParams();
  params.setUseInternalChainId(true);
  cache.setFileParsingParams(params);
  StructureIO.setAtomCache(cache);
  String pdbId="String_Node_Str";
  structure=StructureIO.getStructure(pdbId);
}

Fixed version (ground truth):
@Override protected void setUp() throws Exception {
  super.setUp();
  AtomCache cache=new AtomCache();
  cache.setUseMmCif(true);
  cache.setFetchBehavior(FetchBehavior.FETCH_FILES);
  StructureIO.setAtomCache(cache);
  String pdbId="String_Node_Str";
  structure=StructureIO.getStructure(pdbId);
}
Program: 16465
Project: 16465
Buggy source:
@Test public void test3th3() throws StructureException, IOException {
  AtomCache cache=new AtomCache();
  FileParsingParameters params=cache.getFileParsingParams();
  params.setUseInternalChainId(false);
  params.setCreateAtomBonds(true);
  StructureIO.setAtomCache(cache);
  Structure s=StructureIO.getStructure("String_Node_Str");
  Chain c=s.getChainByPDB("String_Node_Str");
  ResidueNumber rn=ResidueNumber.fromString("String_Node_Str");
  rn.setChainId("String_Node_Str");
  Group g=c.getGroupByPDB(rn);
  assertEquals("String_Node_Str",g.getPDBName());
  int count=0;
  for (  Group gr : c.getAtomGroups()) {
    if (gr.getResidueNumber().equals(rn))     count++;
  }
  assertEquals(2,count);
}

Fixed version (ground truth):
@Test public void test3th3() throws StructureException, IOException {
  AtomCache cache=new AtomCache();
  StructureIO.setAtomCache(cache);
  Structure s=StructureIO.getStructure("String_Node_Str");
  Chain c=s.getChainByPDB("String_Node_Str");
  ResidueNumber rn=ResidueNumber.fromString("String_Node_Str");
  rn.setChainName("String_Node_Str");
  Group g=c.getGroupByPDB(rn);
  assertEquals("String_Node_Str",g.getPDBName());
  int count=0;
  for (  Group gr : c.getAtomGroups()) {
    if (gr.getResidueNumber().equals(rn))     count++;
  }
  assertEquals(2,count);
}
Program: 16466
Project: 16466
Buggy source:
@Test @Ignore public void test4v5a() throws StructureException, IOException {
  AtomCache cache=new AtomCache();
  FileParsingParameters params=cache.getFileParsingParams();
  params.setUseInternalChainId(false);
  params.setCreateAtomBonds(true);
  StructureIO.setAtomCache(cache);
  StructureIO.getStructure("String_Node_Str");
}

Fixed version (ground truth):
@Test @Ignore public void test4v5a() throws StructureException, IOException {
  AtomCache cache=new AtomCache();
  FileParsingParameters params=cache.getFileParsingParams();
  params.setCreateAtomBonds(true);
  StructureIO.setAtomCache(cache);
  StructureIO.getStructure("String_Node_Str");
}
Program: 16467
Project: 16467
Buggy source:
@Test @Ignore public void test4v5aInternalChainIds() throws StructureException, IOException {
  AtomCache cache=new AtomCache();
  FileParsingParameters params=cache.getFileParsingParams();
  params.setUseInternalChainId(true);
  params.setCreateAtomBonds(true);
  StructureIO.setAtomCache(cache);
  StructureIO.getStructure("String_Node_Str");
}

Fixed version (ground truth):
@Test @Ignore public void test4v5aInternalChainIds() throws StructureException, IOException {
  AtomCache cache=new AtomCache();
  FileParsingParameters params=cache.getFileParsingParams();
  params.setCreateAtomBonds(true);
  StructureIO.setAtomCache(cache);
  StructureIO.getStructure("String_Node_Str");
}
Program: 16468
Project: 16468
Buggy source:
public static StructureGroup fromXML(Node n){
  String chainID=getAttribute(n,"String_Node_Str");
  String pdbName=getAttribute(n,"String_Node_Str");
  String insCode=getAttribute(n,"String_Node_Str");
  String resN=getAttribute(n,"String_Node_Str");
  String isAminoAcid=getAttribute(n,"String_Node_Str");
  ResidueNumber resNum=new ResidueNumber();
  resNum.setChainId(chainID);
  if ((insCode != null) && (!insCode.equals("String_Node_Str")) && insCode.length() == 1)   resNum.setInsCode(insCode.charAt(0));
  resNum.setSeqNum(Integer.parseInt(resN));
  StructureGroup g=new StructureGroup(resNum,pdbName,Boolean.valueOf(isAminoAcid));
  return g;
}

Fixed version (ground truth):
public static StructureGroup fromXML(Node n){
  String chainID=getAttribute(n,"String_Node_Str");
  String pdbName=getAttribute(n,"String_Node_Str");
  String insCode=getAttribute(n,"String_Node_Str");
  String resN=getAttribute(n,"String_Node_Str");
  String isAminoAcid=getAttribute(n,"String_Node_Str");
  ResidueNumber resNum=new ResidueNumber();
  resNum.setChainName(chainID);
  if ((insCode != null) && (!insCode.equals("String_Node_Str")) && insCode.length() == 1)   resNum.setInsCode(insCode.charAt(0));
  resNum.setSeqNum(Integer.parseInt(resN));
  StructureGroup g=new StructureGroup(resNum,pdbName,Boolean.valueOf(isAminoAcid));
  return g;
}
Program: 16470
Project: 16470
Buggy source:
public String getChainId(){
  return resNum.getChainId();
}

Fixed version (ground truth):
public String getChainId(){
  return resNum.getChainName();
}
Program: 16471
Project: 16471
Buggy source:
@Override public String toString(){
  StringBuilder sb=new StringBuilder();
  sb.append(pdbName);
  sb.append('\t');
  sb.append(resNum.getChainId());
  sb.append('\t');
  sb.append(resNum.getSeqNum());
  if (resNum.getInsCode() != null)   sb.append(resNum.getInsCode());
  sb.append('\t');
  return sb.toString();
}

Fixed version (ground truth):
@Override public String toString(){
  StringBuilder sb=new StringBuilder();
  sb.append(pdbName);
  sb.append('\t');
  sb.append(resNum.getChainName());
  sb.append('\t');
  sb.append(resNum.getSeqNum());
  if (resNum.getInsCode() != null)   sb.append(resNum.getInsCode());
  sb.append('\t');
  return sb.toString();
}
Program: 16472
Project: 16472
Buggy source:
public void setChainId(String chainId){
  if (resNum == null)   resNum=new ResidueNumber();
  resNum.setChainId(chainId);
}

Fixed version (ground truth):
public void setChainId(String chainId){
  if (resNum == null)   resNum=new ResidueNumber();
  resNum.setChainName(chainId);
}
Program: 16473
Project: 16473
Buggy source:
/** 
 * Converts an array of ResidueNumbers into a jMol selection. <p>For example, "select 11^ :A.CA or 12^ :A.CA;" would select the CA atoms of residues 11-12 on chain A.
 * @param residues Residues to include in the selection. Nulls are ignored.
 * @return
 */
private static String buildJmolSelection(ResidueNumber[] residues){
  StringBuilder cmd=new StringBuilder("String_Node_Str");
  for (  ResidueNumber res : residues) {
    if (res != null) {
      cmd.append(String.format("String_Node_Str",res.getSeqNum(),res.getInsCode() == null ? "String_Node_Str" : res.getInsCode(),res.getChainId()));
    }
  }
  cmd.append("String_Node_Str");
  return cmd.toString();
}

Fixed version (ground truth):
/** 
 * Converts an array of ResidueNumbers into a jMol selection. <p>For example, "select 11^ :A.CA or 12^ :A.CA;" would select the CA atoms of residues 11-12 on chain A.
 * @param residues Residues to include in the selection. Nulls are ignored.
 * @return
 */
private static String buildJmolSelection(ResidueNumber[] residues){
  StringBuilder cmd=new StringBuilder("String_Node_Str");
  for (  ResidueNumber res : residues) {
    if (res != null) {
      cmd.append(String.format("String_Node_Str",res.getSeqNum(),res.getInsCode() == null ? "String_Node_Str" : res.getInsCode(),res.getChainName()));
    }
  }
  cmd.append("String_Node_Str");
  return cmd.toString();
}