nus-yam/ex-repair huggingface dataset:
Program: 16375
Project: 16375
Buggy source:
/** 
 * Recursive helper
 * @param symmAxes output list
 * @param prior transformation aligning the first repeat of this axis with the first overall
 * @param level current level
 */
private void getSymmetryAxes(List<Axis> symmAxes,Matrix4d prior,int level,int firstRepeat){
  if (level >= getNumLevels()) {
    return;
  }
  Axis elem=axes.get(level);
  Matrix4d elemOp=elem.getOperator();
  Matrix4d currAxisOp=new Matrix4d(prior);
  currAxisOp.invert();
  currAxisOp.mul(elemOp);
  currAxisOp.mul(prior);
  Axis currAxis=new Axis(currAxisOp,elem.getOrder(),elem.getSymmType());
  currAxis.setLevel(level);
  currAxis.setFirstRepeat(firstRepeat);
  symmAxes.add(currAxis);
  getSymmetryAxes(symmAxes,prior,level + 1,0);
  Matrix4d newPrior=new Matrix4d(elemOp);
  newPrior.mul(prior);
  int childSize=getNumRepeats(level + 1);
  getSymmetryAxes(symmAxes,newPrior,level + 1,childSize);
  for (int d=2; d < elem.getOrder(); d++) {
    newPrior.mul(elemOp,newPrior);
    getSymmetryAxes(symmAxes,newPrior,level + 1,childSize * d);
  }
}

Fixed version (ground truth):
/** 
 * Recursive helper
 * @param symmAxes output list
 * @param prior transformation aligning the first repeat of this axis with the first overall
 * @param level current level
 */
private void getSymmetryAxes(List<Axis> symmAxes,Matrix4d prior,int level,int firstRepeat){
  if (level >= getNumLevels()) {
    return;
  }
  Axis elem=axes.get(level);
  Matrix4d elemOp=elem.getOperator();
  Matrix4d currAxisOp=new Matrix4d(prior);
  currAxisOp.invert();
  currAxisOp.mul(elemOp);
  currAxisOp.mul(prior);
  Axis currAxis=new Axis(currAxisOp,elem.getOrder(),elem.getSymmType(),level,firstRepeat);
  symmAxes.add(currAxis);
  getSymmetryAxes(symmAxes,prior,level + 1,0);
  Matrix4d newPrior=new Matrix4d(elemOp);
  newPrior.mul(prior);
  int childSize=getNumRepeats(level + 1);
  getSymmetryAxes(symmAxes,newPrior,level + 1,childSize);
  for (int d=2; d < elem.getOrder(); d++) {
    newPrior.mul(elemOp,newPrior);
    getSymmetryAxes(symmAxes,newPrior,level + 1,childSize * d);
  }
}
Program: 16376
Project: 16376
Buggy source:
public Axis(Matrix4d operator,int order,SymmetryType type){
  if (order < 2) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  if (type != SymmetryType.OPEN && type != SymmetryType.CLOSED) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  this.operator=operator;
  this.order=order;
  this.symmType=type;
  this.level=-1;
  this.firstRepeat=-1;
  rotAxis=null;
}

Fixed version (ground truth):
public Axis(Matrix4d operator,int order,SymmetryType type,int level,int firstRepeat){
  if (order < 2) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  if (type != SymmetryType.OPEN && type != SymmetryType.CLOSED) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  this.operator=operator;
  this.order=order;
  this.symmType=type;
  setLevel(level);
  setFirstRepeat(firstRepeat);
  rotAxis=null;
}
Program: 16378
Project: 16378
Buggy source:
/** 
 * Method that converts the symmetric units of a structure into different chains, so that internal symmetry can be translated into quaternary. <p> Application: obtain the internal symmetry axis with the quaternary symmetry code in biojava or calculate independent repeat properties.
 * @param symmetry CeSymmResult
 * @return Structure with different chains for every symmetric unit
 */
public static Structure getQuaternaryStructure(CeSymmResult symmetry){
  if (!symmetry.isRefined())   throw new IllegalArgumentException("String_Node_Str" + "String_Node_Str");
  Atom[] atoms=symmetry.getAtoms();
  Structure symm=new StructureImpl();
  symm.setStructureIdentifier(symmetry.getStructureId());
  symm.setChains(new ArrayList<Chain>());
  char chainID='A';
  for (int i=0; i < symmetry.getMultipleAlignment().size(); i++) {
    Chain newCh=new ChainImpl();
    Block align=symmetry.getMultipleAlignment().getBlock(0);
    int res1=align.getStartResidue(i);
    int res2=align.getFinalResidue(i);
    Atom[] repeat=Arrays.copyOfRange(atoms,res1,res2 + 1);
    for (int k=0; k < repeat.length; k++) {
      Group g=(Group)repeat[k].getGroup().clone();
      newCh.addGroup(g);
    }
    newCh.setChainID(chainID + "String_Node_Str");
    chainID++;
    symm.addChain(newCh);
  }
  return symm;
}

Fixed version (ground truth):
/** 
 * Method that converts the symmetric units of a structure into different chains, so that internal symmetry can be translated into quaternary. <p> Application: obtain the internal symmetry axis with the quaternary symmetry code in biojava or calculate independent repeat properties.
 * @param symmetry CeSymmResult
 * @return Structure with different chains for every symmetric unit
 */
public static Structure getQuaternaryStructure(CeSymmResult symmetry){
  if (!symmetry.isRefined())   throw new IllegalArgumentException("String_Node_Str" + "String_Node_Str");
  Atom[] atoms=StructureTools.cloneAtomArray(symmetry.getAtoms());
  Structure symm=new StructureImpl();
  symm.setStructureIdentifier(symmetry.getStructureId());
  symm.setChains(new ArrayList<Chain>());
  char chainID='A';
  for (int i=0; i < symmetry.getMultipleAlignment().size(); i++) {
    Chain newCh=new ChainImpl();
    Block align=symmetry.getMultipleAlignment().getBlock(0);
    int res1=align.getStartResidue(i);
    int res2=align.getFinalResidue(i);
    Atom[] repeat=Arrays.copyOfRange(atoms,res1,res2 + 1);
    for (int k=0; k < repeat.length; k++) {
      Group g=(Group)repeat[k].getGroup().clone();
      newCh.addGroup(g);
    }
    newCh.setChainID(chainID + "String_Node_Str");
    chainID++;
    symm.addChain(newCh);
  }
  return symm;
}
Program: 16380
Project: 16380
Buggy source:
@Test public void test1STP() throws IOException, StructureException {
  testID("String_Node_Str",1,4);
}

Fixed version (ground truth):
@Test public void test1STP() throws IOException, StructureException {
  comparePdbVsMmcif("String_Node_Str",1,4);
}
Program: 16381
Project: 16381
Buggy source:
@Test public void test3NTU() throws IOException, StructureException {
  testID("String_Node_Str",1,6);
}

Fixed version (ground truth):
@Test public void test3NTU() throws IOException, StructureException {
  comparePdbVsMmcif("String_Node_Str",1,6);
}
Program: 16382
Project: 16382
Buggy source:
@Test public void test5LDH() throws IOException, StructureException {
  testID("String_Node_Str",1,4);
  boolean gotException=false;
  try {
    AtomCache cache=new AtomCache();
    cache.setUseMmCif(true);
    StructureIO.setAtomCache(cache);
    StructureIO.getBiologicalAssembly("String_Node_Str",3);
  }
 catch (  StructureException e) {
    gotException=true;
  }
  assertTrue("String_Node_Str",gotException);
  gotException=false;
  try {
    AtomCache cache=new AtomCache();
    cache.setUseMmCif(true);
    StructureIO.setAtomCache(cache);
    StructureIO.getBiologicalAssembly("String_Node_Str",2);
  }
 catch (  StructureException e) {
    gotException=true;
  }
  assertTrue("String_Node_Str",!gotException);
}

Fixed version (ground truth):
@Test public void test5LDH() throws IOException, StructureException {
  comparePdbVsMmcif("String_Node_Str",1,4);
  boolean gotException=false;
  try {
    AtomCache cache=new AtomCache();
    cache.setUseMmCif(true);
    StructureIO.setAtomCache(cache);
    StructureIO.getBiologicalAssembly("String_Node_Str",3);
  }
 catch (  StructureException e) {
    gotException=true;
  }
  assertTrue("String_Node_Str",gotException);
  gotException=false;
  try {
    AtomCache cache=new AtomCache();
    cache.setUseMmCif(true);
    StructureIO.setAtomCache(cache);
    StructureIO.getBiologicalAssembly("String_Node_Str",2);
  }
 catch (  StructureException e) {
    gotException=true;
  }
  assertTrue("String_Node_Str",!gotException);
}
Program: 16383
Project: 16383
Buggy source:
@Test public void test3FAD() throws IOException, StructureException {
  testID("String_Node_Str",1,1);
  testID("String_Node_Str",2,2);
}

Fixed version (ground truth):
@Test public void test3FAD() throws IOException, StructureException {
  comparePdbVsMmcif("String_Node_Str",1,1);
  comparePdbVsMmcif("String_Node_Str",2,2);
}
Program: 16384
Project: 16384
Buggy source:
@Test public void test1A29() throws IOException, StructureException {
  testID("String_Node_Str",1,1);
}

Fixed version (ground truth):
@Test public void test1A29() throws IOException, StructureException {
  comparePdbVsMmcif("String_Node_Str",1,1);
}
Program: 16385
Project: 16385
Buggy source:
@Override public void run(){
  CESymmParameters params=parent.getParameters();
  try {
    Atom[] atoms=StructureTools.getRepresentativeAtomArray(structure);
    CeSymmResult result=CeSymm.analyze(atoms,params);
    SymmetryDisplay.display(result);
  }
 catch (  StructureException e) {
    logger.warn(e.getMessage());
  }
  parent.notifyCalcFinished();
}

Fixed version (ground truth):
@Override public void run(){
  CESymmParameters params=parent.getParameters();
  try {
    Atom[] atoms=SymmetryTools.getRepresentativeAtoms(structure);
    CeSymmResult result=CeSymm.analyze(atoms,params);
    SymmetryDisplay.display(result);
  }
 catch (  StructureException e) {
    logger.warn(e.getMessage());
  }
  parent.notifyCalcFinished();
}
Program: 16386
Project: 16386
Buggy source:
/** 
 * Displays a single structure in a cartoon representation with each symmetric repeat colored differently.
 * @param msa the symmetry multiple alignment obtained from CeSymm
 * @throws StructureException
 */
public static AbstractAlignmentJmol display(CeSymmResult symmResult) throws StructureException {
  if (symmResult.isSignificant() && symmResult.isRefined()) {
    MultipleAlignment msa=symmResult.getMultipleAlignment();
    List<Atom[]> atoms=msa.getAtomArrays();
    MultipleAlignmentJmol jmol=new MultipleAlignmentJmol(msa,atoms);
    jmol.setTitle(jmol.getStructure().getPDBHeader().getTitle());
    addSymmetryMenu(jmol,symmResult);
    jmol.evalString(printSymmetryGroup(symmResult));
    jmol.evalString(printSymmetryAxes(symmResult));
    jmol.setTitle(getSymmTitle(symmResult));
    return jmol;
  }
 else {
    logger.info("String_Node_Str");
    Atom[] cloned=StructureTools.cloneAtomArray(symmResult.getAtoms());
    AbstractAlignmentJmol jmol=StructureAlignmentDisplay.display(symmResult.getSelfAlignment(),symmResult.getAtoms(),cloned);
    RotationAxis axis=new RotationAxis(symmResult.getSelfAlignment());
    jmol.evalString(axis.getJmolScript(symmResult.getAtoms()));
    return jmol;
  }
}

Fixed version (ground truth):
/** 
 * Displays a single structure in a cartoon representation with each symmetric repeat colored differently.
 * @param msa the symmetry multiple alignment obtained from CeSymm
 * @throws StructureException
 */
public static AbstractAlignmentJmol display(CeSymmResult symmResult) throws StructureException {
  if (symmResult.isSignificant() && symmResult.isRefined()) {
    MultipleAlignment msa=symmResult.getMultipleAlignment();
    List<Atom[]> atoms=msa.getAtomArrays();
    Atom[] allAtoms=atoms.get(0);
    List<Group> hetatms=StructureTools.getUnalignedGroups(allAtoms);
    allAtoms=Arrays.copyOf(allAtoms,allAtoms.length + hetatms.size());
    for (int h=0; h < hetatms.size(); h++) {
      int index=(allAtoms.length - hetatms.size()) + h;
      allAtoms[index]=hetatms.get(h).getAtom(0);
    }
    for (int s=0; s < msa.size(); s++)     atoms.set(s,allAtoms);
    MultipleAlignmentJmol jmol=new MultipleAlignmentJmol(msa,atoms);
    jmol.setTitle(jmol.getStructure().getPDBHeader().getTitle());
    addSymmetryMenu(jmol,symmResult);
    jmol.evalString(printSymmetryGroup(symmResult));
    jmol.evalString(printSymmetryAxes(symmResult));
    jmol.setTitle(getSymmTitle(symmResult));
    return jmol;
  }
 else {
    logger.info("String_Node_Str");
    Atom[] cloned=StructureTools.cloneAtomArray(symmResult.getAtoms());
    AbstractAlignmentJmol jmol=StructureAlignmentDisplay.display(symmResult.getSelfAlignment(),symmResult.getAtoms(),cloned);
    RotationAxis axis=new RotationAxis(symmResult.getSelfAlignment());
    jmol.evalString(axis.getJmolScript(symmResult.getAtoms()));
    return jmol;
  }
}
Program: 16387
Project: 16387
Buggy source:
/** 
 * Generates a String that displays the symmetry axes of a structure.
 * @param symm CeSymmResult
 * @return
 * @throws StructureException 
 */
public static String printSymmetryAxes(CeSymmResult symm) throws StructureException {
  int id=0;
  String script="String_Node_Str";
  SymmetryAxes axes=symm.getAxes();
  List<Atom[]> repeats=SymmetryTools.toRepeatsAlignment(symm).getAtomArrays();
  List<Matrix4d> symmAxes=axes.getElementaryAxes();
  for (int a=0; a < symmAxes.size(); a++) {
    RotationAxis rot=new RotationAxis(symmAxes.get(a));
    Set<Integer> repIndex=new TreeSet<Integer>(axes.getRepeatRelation(a).get(0));
    repIndex.addAll(axes.getRepeatRelation(a).get(1));
    List<Atom> repAtoms=new ArrayList<Atom>();
    for (    Integer r : repIndex)     repAtoms.addAll(Arrays.asList(repeats.get(r)));
    script+=rot.getJmolScript(repAtoms.toArray(new Atom[repAtoms.size()]),id);
    id++;
  }
  return script;
}

Fixed version (ground truth):
/** 
 * Generates a String that displays the symmetry axes of a structure.
 * @param symm CeSymmResult
 * @return
 * @throws StructureException
 */
public static String printSymmetryAxes(CeSymmResult symm) throws StructureException {
  int id=0;
  String script="String_Node_Str";
  SymmetryAxes axes=symm.getAxes();
  List<Atom[]> repeats=SymmetryTools.toRepeatsAlignment(symm).getAtomArrays();
  List<Matrix4d> symmAxes=axes.getElementaryAxes();
  for (int a=0; a < symmAxes.size(); a++) {
    RotationAxis rot=new RotationAxis(symmAxes.get(a));
    Set<Integer> repIndex=new TreeSet<Integer>(axes.getRepeatRelation(a).get(0));
    repIndex.addAll(axes.getRepeatRelation(a).get(1));
    List<Atom> repAtoms=new ArrayList<Atom>();
    for (    Integer r : repIndex)     repAtoms.addAll(Arrays.asList(repeats.get(r)));
    script+=rot.getJmolScript(repAtoms.toArray(new Atom[repAtoms.size()]),id);
    id++;
  }
  return script;
}
Program: 16388
Project: 16388
Buggy source:
/** 
 * New structures are downloaded if they were not cached in the alignment and they are entirely transformed here with the superposition information in the Multiple Alignment.
 * @param multAln
 * @return list of transformed AtomArrays
 * @throws StructureException
 */
public static List<Atom[]> getRotatedAtoms(MultipleAlignment multAln) throws StructureException {
  int size=multAln.size();
  List<Atom[]> atomArrays=multAln.getAtomArrays();
  for (int i=0; i < size; i++) {
    if (atomArrays.get(i).length < 1)     throw new StructureException("String_Node_Str" + atomArrays.get(i).length);
  }
  List<Atom[]> rotatedAtoms=new ArrayList<Atom[]>();
  List<Matrix4d> transf=multAln.getBlockSet(0).getTransformations();
  if (transf == null) {
    logger.error("String_Node_Str" + "String_Node_Str");
    multAln=multAln.clone();
    MultipleSuperimposer imposer=new ReferenceSuperimposer();
    imposer.superimpose(multAln);
    transf=multAln.getBlockSet(0).getTransformations();
    assert(transf != null);
  }
  for (int i=0; i < size; i++) {
    Structure displayS=atomArrays.get(i)[0].getGroup().getChain().getStructure().clone();
    Atom[] rotCA=StructureTools.getRepresentativeAtomArray(displayS);
    List<Group> hetatms=StructureTools.getUnalignedGroups(rotCA);
    for (    Group g : hetatms) {
      rotCA=Arrays.copyOf(rotCA,rotCA.length + 1);
      rotCA[rotCA.length - 1]=g.getAtom(0);
    }
    Calc.transform(displayS,transf.get(i));
    rotatedAtoms.add(rotCA);
  }
  return rotatedAtoms;
}

Fixed version (ground truth):
/** 
 * New structures are downloaded if they were not cached in the alignment and they are entirely transformed here with the superposition information in the Multiple Alignment.
 * @param multAln
 * @return list of transformed AtomArrays
 * @throws StructureException
 */
public static List<Atom[]> getRotatedAtoms(MultipleAlignment multAln) throws StructureException {
  int size=multAln.size();
  List<Atom[]> atomArrays=multAln.getAtomArrays();
  for (int i=0; i < size; i++) {
    if (atomArrays.get(i).length < 1)     throw new StructureException("String_Node_Str" + atomArrays.get(i).length);
  }
  List<Atom[]> rotatedAtoms=new ArrayList<Atom[]>();
  List<Matrix4d> transf=multAln.getBlockSet(0).getTransformations();
  if (transf == null) {
    logger.error("String_Node_Str" + "String_Node_Str");
    multAln=multAln.clone();
    MultipleSuperimposer imposer=new ReferenceSuperimposer();
    imposer.superimpose(multAln);
    transf=multAln.getBlockSet(0).getTransformations();
    assert(transf != null);
  }
  for (int i=0; i < size; i++) {
    Structure displayS=atomArrays.get(i)[0].getGroup().getChain().getStructure().clone();
    Atom[] rotCA=StructureTools.getRepresentativeAtomArray(displayS);
    List<Group> hetatms=StructureTools.getUnalignedGroups(rotCA);
    int index=rotCA.length;
    rotCA=Arrays.copyOf(rotCA,rotCA.length + hetatms.size());
    for (    Group g : hetatms) {
      rotCA[index]=g.getAtom(0);
      index++;
    }
    Calc.transform(displayS,transf.get(i));
    rotatedAtoms.add(rotCA);
  }
  return rotatedAtoms;
}
Program: 16389
Project: 16389
Buggy source:
public static void main(String[] args){
  try {
    BioUnitDataProviderFactory.setBioUnitDataProvider(BioUnitDataProviderFactory.pdbProviderClassName);
    Structure bioAssembly=StructureIO.getBiologicalAssembly("String_Node_Str",1);
    StructureAlignmentJmol jmolPanel=new StructureAlignmentJmol();
    jmolPanel.setStructure(bioAssembly);
    jmolPanel.evalString("String_Node_Str");
    System.out.println("String_Node_Str");
  }
 catch (  Exception e) {
    e.printStackTrace();
  }
}

Fixed version (ground truth):
public static void main(String[] args){
  try {
    Structure bioAssembly=StructureIO.getBiologicalAssembly("String_Node_Str",1);
    StructureAlignmentJmol jmolPanel=new StructureAlignmentJmol();
    jmolPanel.setStructure(bioAssembly);
    jmolPanel.evalString("String_Node_Str");
    System.out.println("String_Node_Str");
  }
 catch (  Exception e) {
    e.printStackTrace();
  }
}
Program: 16390
Project: 16390
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);
    List<Chain> hs=s.getNonPolyChainsByPDB("String_Node_Str");
    Chain h=hs.get(0);
    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();
  }
}

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);
    List<Chain> hs=s.getNonPolyChainsByPDB("String_Node_Str");
    Chain h=hs.get(0);
    List<Group> ligands=h.getAtomGroups();
    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: 16391
Project: 16391
Buggy source:
/** 
 * Returns the macromolecular size of this biological assembly, i.e. the number of polymeric chains (protein or nucleotide chains) in the biological  assembly.
 * @return
 */
public int getMacromolecularSize(){
  for (  BiologicalAssemblyTransformation bat : getTransforms()) {
  }
  return macromolecularSize;
}

Fixed version (ground truth):
/** 
 * Returns the macromolecular size of this biological assembly, i.e. the number of polymeric chains (protein or nucleotide chains) in the biological  assembly.
 * @return
 */
public int getMacromolecularSize(){
  return macromolecularSize;
}
Program: 16393
Project: 16393
Buggy source:
/** 
 * @return
 */
private Group getGroupWithSameResNumButDiffPDBName(){
  for (  Group g : chain.getAtomGroups()) {
    if (g.getResidueNumber().getSeqNum() == group.getResidueNumber().getSeqNum()) {
      if (!g.getPDBName().equals(group.getPDBName())) {
        return g;
      }
    }
  }
  return null;
}

Fixed version (ground truth):
/** 
 * @return
 */
private Group getGroupWithSameResNumButDiffPDBName(){
  for (  Group g : chain.getAtomGroups()) {
    if (g.getResidueNumber().equals(group.getResidueNumber())) {
      if (!g.getPDBName().equals(group.getPDBName())) {
        return g;
      }
    }
  }
  return null;
}
Program: 16394
Project: 16394
Buggy source:
@Override public void setHeaderInfo(float rFree,float rWork,float resolution,String title,String depositionDate,String releaseDate,String[] experimnetalMethods){
  SimpleDateFormat formatter=new SimpleDateFormat("String_Node_Str");
  PDBHeader pdbHeader=structure.getPDBHeader();
  pdbHeader.setTitle(title);
  pdbHeader.setResolution(resolution);
  pdbHeader.setRfree(rFree);
  pdbHeader.setRwork(rWork);
  for (  String techniqueStr : experimnetalMethods) {
    pdbHeader.setExperimentalTechnique(techniqueStr);
  }
  try {
    Date depDate=formatter.parse(depositionDate);
    pdbHeader.setDepDate(depDate);
  }
 catch (  ParseException e) {
    logger.warn("String_Node_Str",depositionDate);
  }
  try {
    Date relDate=formatter.parse(releaseDate);
    pdbHeader.setModDate(relDate);
  }
 catch (  ParseException e) {
    logger.warn("String_Node_Str",releaseDate);
  }
}

Fixed version (ground truth):
@Override public void setHeaderInfo(float rFree,float rWork,float resolution,String title,String depositionDate,String releaseDate,String[] experimnetalMethods){
  SimpleDateFormat formatter=new SimpleDateFormat("String_Node_Str");
  PDBHeader pdbHeader=structure.getPDBHeader();
  pdbHeader.setTitle(title);
  pdbHeader.setResolution(resolution);
  pdbHeader.setRfree(rFree);
  pdbHeader.setRwork(rWork);
  for (  String techniqueStr : experimnetalMethods) {
    pdbHeader.setExperimentalTechnique(techniqueStr);
  }
  if (depositionDate != null) {
    try {
      Date depDate=formatter.parse(depositionDate);
      pdbHeader.setDepDate(depDate);
    }
 catch (    ParseException e) {
      logger.warn("String_Node_Str",depositionDate);
    }
  }
 else {
    pdbHeader.setDepDate(new Date(0));
  }
  if (releaseDate != null) {
    try {
      Date relDate=formatter.parse(releaseDate);
      pdbHeader.setModDate(relDate);
    }
 catch (    ParseException e) {
      logger.warn("String_Node_Str",releaseDate);
    }
  }
 else {
    pdbHeader.setModDate(new Date(0));
  }
}
Program: 16396
Project: 16396
Buggy source:
@Test public void testZipChemCompProvider() throws IOException {
  InputStream testPDB=new ByteArrayInputStream(DNAexample.getBytes());
  UserConfiguration config=new UserConfiguration();
  String cachePath=config.getCacheFilePath();
  Path pdbdir=Paths.get(cachePath);
  Path chemComp=pdbdir.resolve("String_Node_Str");
  System.out.println("String_Node_Str" + pdbdir.toString() + "String_Node_Str");
  ZipChemCompProvider zp=new ZipChemCompProvider(chemComp.toString(),pdbdir.toString());
  zp.setRemoveCif(false);
  ChemCompGroupFactory.setChemCompProvider(zp);
  FileParsingParameters params=new FileParsingParameters();
  PDBFileReader pdbreader=new PDBFileReader();
  pdbreader.setFileParsingParameters(params);
  Structure s=pdbreader.getStructure(testPDB);
  assertEquals(5,s.getChain(0).getAtomGroups().size());
}

Fixed version (ground truth):
@Test public void testZipChemCompProvider() throws IOException {
  InputStream testPDB=new ByteArrayInputStream(DNAexample.getBytes());
  UserConfiguration config=new UserConfiguration();
  String cachePath=config.getCacheFilePath();
  Path pdbdir=Paths.get(cachePath);
  Path chemComp=pdbdir.resolve("String_Node_Str");
  System.out.println("String_Node_Str" + pdbdir.toString() + "String_Node_Str");
  ZipChemCompProvider zp=new ZipChemCompProvider(chemComp.toString(),pdbdir.toString());
  zp.setRemoveCif(false);
  ChemCompGroupFactory.setChemCompProvider(zp);
  FileParsingParameters params=new FileParsingParameters();
  PDBFileReader pdbreader=new PDBFileReader();
  pdbreader.setFileParsingParameters(params);
  Structure s=pdbreader.getStructure(testPDB);
  assertEquals(3,s.getChain(0).getAtomGroups().size());
}
Program: 16397
Project: 16397
Buggy source:
@Test public void testSeqResParsing(){
  List<Chain> chains=structure.getChains(0);
  assertEquals("String_Node_Str",2,chains.size());
  Chain c=chains.get(0);
  List<Group> seqResGroups=c.getSeqResGroups();
  assertEquals("String_Node_Str",58,seqResGroups.size());
  List<Group> atomGroups=c.getAtomGroups();
  Group g3=seqResGroups.get(2);
  int indexAtom=atomGroups.indexOf(g3);
  assertEquals("String_Node_Str",2,indexAtom);
  Group g5=atomGroups.get(5);
  assertEquals("String_Node_Str",5,seqResGroups.indexOf(g5));
  Chain c2=chains.get(1);
  List<Group> atomGroups2=c2.getAtomGroups();
  Group g58=atomGroups2.get(0);
  assertEquals("String_Node_Str","String_Node_Str",g58.getPDBName());
  assertEquals("String_Node_Str",-1,seqResGroups.indexOf(g58));
}

Fixed version (ground truth):
@Test public void testSeqResParsing(){
  List<Chain> chains=structure.getChains(0);
  assertEquals("String_Node_Str",4,chains.size());
  Chain c=chains.get(0);
  List<Group> seqResGroups=c.getSeqResGroups();
  assertEquals("String_Node_Str",58,seqResGroups.size());
  List<Group> atomGroups=c.getAtomGroups();
  Group g3=seqResGroups.get(2);
  int indexAtom=atomGroups.indexOf(g3);
  assertEquals("String_Node_Str",2,indexAtom);
  Group g5=atomGroups.get(5);
  assertEquals("String_Node_Str",5,seqResGroups.indexOf(g5));
  Chain c2=chains.get(1);
  List<Group> atomGroups2=c2.getAtomGroups();
  Group g58=atomGroups2.get(0);
  assertEquals("String_Node_Str","String_Node_Str",g58.getPDBName());
  assertEquals("String_Node_Str",-1,seqResGroups.indexOf(g58));
}
Program: 16398
Project: 16398
Buggy source:
/** 
 * Tests if a PDB file can be parsed
 * @throws Exception
 */
@Test public void testReadPDBFile() throws Exception {
  assertEquals("String_Node_Str","String_Node_Str",structure.getPDBCode());
  Chain c=structure.getChain(0);
  assertEquals("String_Node_Str",58,c.getAtomGroups(GroupType.AMINOACID).size());
  assertEquals(0,c.getAtomGroups(GroupType.HETATM).size());
  Chain c2=structure.getChain(1);
  assertEquals(64,c2.getAtomGroups(GroupType.HETATM).size());
  assertEquals(0,c2.getAtomGroups(GroupType.NUCLEOTIDE).size());
  List<EntityInfo> compounds=structure.getEntityInfos();
  EntityInfo mol=compounds.get(0);
  assertTrue(mol.getDescription().startsWith("String_Node_Str"));
}

Fixed version (ground truth):
/** 
 * Tests if a PDB file can be parsed
 * @throws Exception
 */
@Test public void testReadPDBFile() throws Exception {
  assertEquals("String_Node_Str","String_Node_Str",structure.getPDBCode());
  Chain c=structure.getChain(0);
  assertEquals("String_Node_Str",58,c.getAtomGroups(GroupType.AMINOACID).size());
  assertEquals(0,c.getAtomGroups(GroupType.HETATM).size());
  Chain c4=structure.getChain(3);
  assertEquals(63,c4.getAtomGroups(GroupType.HETATM).size());
  assertEquals(0,c4.getAtomGroups(GroupType.NUCLEOTIDE).size());
  List<EntityInfo> compounds=structure.getEntityInfos();
  assertEquals(4,compounds.size());
  EntityInfo mol=compounds.get(0);
  assertTrue(mol.getDescription().startsWith("String_Node_Str"));
}
Program: 16399
Project: 16399
Buggy source:
@BeforeClass public static void setUp() throws IOException {
  InputStream inStream=StructureTest.class.getResourceAsStream("String_Node_Str");
  assertNotNull(inStream);
  PDBFileParser pdbpars=new PDBFileParser();
  FileParsingParameters params=new FileParsingParameters();
  params.setAlignSeqRes(true);
  params.setCreateAtomBonds(true);
  pdbpars.setFileParsingParameters(params);
  structure=pdbpars.parsePDBFile(inStream);
  assertNotNull(structure);
  assertEquals("String_Node_Str",2,structure.size());
}

Fixed version (ground truth):
@BeforeClass public static void setUp() throws IOException {
  InputStream inStream=StructureTest.class.getResourceAsStream("String_Node_Str");
  assertNotNull(inStream);
  PDBFileParser pdbpars=new PDBFileParser();
  FileParsingParameters params=new FileParsingParameters();
  params.setAlignSeqRes(true);
  params.setCreateAtomBonds(true);
  pdbpars.setFileParsingParameters(params);
  structure=pdbpars.parsePDBFile(inStream);
  assertNotNull(structure);
  assertEquals("String_Node_Str",1,structure.size());
}
Program: 16400
Project: 16400
Buggy source:
/** 
 * Returns true if the given chain is composed of non-polymeric groups only
 * @param c
 * @return
 */
public static boolean isChainPureNonPolymer(Chain c){
  for (  Group g : c.getAtomGroups()) {
    if (g.getType() == GroupType.AMINOACID || g.getType() == GroupType.NUCLEOTIDE)     return false;
  }
  return true;
}

Fixed version (ground truth):
/** 
 * Returns true if the given chain is composed of non-polymeric (including water) groups only.  To be used at parsing time only.
 * @param c
 * @return
 */
public static boolean isChainPureNonPolymer(Chain c){
  for (  Group g : c.getAtomGroups()) {
    ChemComp cc=g.getChemComp();
    ResidueType resType=cc.getResidueType();
    PolymerType polType=cc.getPolymerType();
    if ((resType == ResidueType.lPeptideLinking || PolymerType.PROTEIN_ONLY.contains(polType) || PolymerType.POLYNUCLEOTIDE_ONLY.contains(polType)) && !g.isHetAtomInFile()) {
      return false;
    }
  }
  return true;
}
Program: 16402
Project: 16402
Buggy source:
/** 
 * Returns the RNASequence or null if one can't be created
 * @param str
 * @return
 */
private RNASequence getRNASequence(String str){
  try {
    RNASequence s=new RNASequence(str);
    return s;
  }
 catch (  CompoundNotFoundException e) {
    logger.error("String_Node_Str",e);
  }
  return null;
}

Fixed version (ground truth):
/** 
 * Returns the RNASequence or null if one can't be created
 * @param str
 * @return
 */
private static RNASequence getRNASequence(String str){
  try {
    RNASequence s=new RNASequence(str);
    return s;
  }
 catch (  CompoundNotFoundException e) {
    logger.error("String_Node_Str",e);
  }
  return null;
}
Program: 16403
Project: 16403
Buggy source:
private boolean isRNASequence(String str){
  try {
    new RNASequence(str);
  }
 catch (  CompoundNotFoundException e) {
    return false;
  }
  return true;
}

Fixed version (ground truth):
private static boolean isRNASequence(String str){
  try {
    new RNASequence(str);
  }
 catch (  CompoundNotFoundException e) {
    return false;
  }
  return true;
}
Program: 16404
Project: 16404
Buggy source:
private SequencePair<DNASequence,NucleotideCompound> alignDNA(DNASequence s1,DNASequence s2){
  SubstitutionMatrix<NucleotideCompound> matrix=SubstitutionMatrixHelper.getNuc4_4();
  GapPenalty penalty=new SimpleGapPenalty(8,1);
  PairwiseSequenceAligner<DNASequence,NucleotideCompound> nw=Alignments.getPairwiseAligner(s1,s2,PairwiseSequenceAlignerType.GLOBAL,penalty,matrix);
  return nw.getPair();
}

Fixed version (ground truth):
private static SequencePair<DNASequence,NucleotideCompound> alignDNA(DNASequence s1,DNASequence s2){
  SubstitutionMatrix<NucleotideCompound> matrix=SubstitutionMatrixHelper.getNuc4_4();
  GapPenalty penalty=new SimpleGapPenalty(8,1);
  PairwiseSequenceAligner<DNASequence,NucleotideCompound> nw=Alignments.getPairwiseAligner(s1,s2,PairwiseSequenceAlignerType.GLOBAL,penalty,matrix);
  return nw.getPair();
}
Program: 16405
Project: 16405
Buggy source:
/** 
 * Utility method that employs some heuristics to find the   {@link EntityInfo}s for the polymeric chains given in constructor.  To be used in case the information is missing in PDB/mmCIF file 
 * @return
 */
public List<EntityInfo> findPolyEntities(){
  TreeMap<String,EntityInfo> chainIds2entities=findEntitiesFromAlignment();
  List<EntityInfo> entities=findUniqueEntities(chainIds2entities);
  return entities;
}

Fixed version (ground truth):
/** 
 * Utility method that employs some heuristics to find the   {@link EntityInfo}s for the polymeric chains given in constructor.  To be used in case the information is missing in PDB/mmCIF file 
 * @return
 */
public static List<EntityInfo> findPolyEntities(List<List<Chain>> polyModels){
  TreeMap<String,EntityInfo> chainIds2entities=findEntitiesFromAlignment(polyModels);
  List<EntityInfo> entities=findUniqueEntities(chainIds2entities);
  return entities;
}
Program: 16406
Project: 16406
Buggy source:
/** 
 * Returns the ProteinSequence or null if one can't be created
 * @param str
 * @return
 */
private ProteinSequence getProteinSequence(String str){
  try {
    ProteinSequence s=new ProteinSequence(str);
    return s;
  }
 catch (  CompoundNotFoundException e) {
    logger.error("String_Node_Str",e);
  }
  return null;
}

Fixed version (ground truth):
/** 
 * Returns the ProteinSequence or null if one can't be created
 * @param str
 * @return
 */
private static ProteinSequence getProteinSequence(String str){
  try {
    ProteinSequence s=new ProteinSequence(str);
    return s;
  }
 catch (  CompoundNotFoundException e) {
    logger.error("String_Node_Str",e);
  }
  return null;
}
Program: 16408
Project: 16408
Buggy source:
/** 
 * Returns the DNASequence or null if one can't be created
 * @param str
 * @return
 */
private DNASequence getDNASequence(String str){
  try {
    DNASequence s=new DNASequence(str);
    return s;
  }
 catch (  CompoundNotFoundException e) {
    logger.error("String_Node_Str",e);
  }
  return null;
}

Fixed version (ground truth):
/** 
 * Returns the DNASequence or null if one can't be created
 * @param str
 * @return
 */
private static DNASequence getDNASequence(String str){
  try {
    DNASequence s=new DNASequence(str);
    return s;
  }
 catch (  CompoundNotFoundException e) {
    logger.error("String_Node_Str",e);
  }
  return null;
}
Program: 16409
Project: 16409
Buggy source:
private boolean isProteinSequence(String str){
  try {
    new ProteinSequence(str);
  }
 catch (  CompoundNotFoundException e) {
    return false;
  }
  return true;
}

Fixed version (ground truth):
private static boolean isProteinSequence(String str){
  try {
    new ProteinSequence(str);
  }
 catch (  CompoundNotFoundException e) {
    return false;
  }
  return true;
}
Program: 16410
Project: 16410
Buggy source:
private boolean isDNASequence(String str){
  try {
    new DNASequence(str);
  }
 catch (  CompoundNotFoundException e) {
    return false;
  }
  return true;
}

Fixed version (ground truth):
private static boolean isDNASequence(String str){
  try {
    new DNASequence(str);
  }
 catch (  CompoundNotFoundException e) {
    return false;
  }
  return true;
}
Program: 16411
Project: 16411
Buggy source:
private SequencePair<RNASequence,NucleotideCompound> alignRNA(RNASequence s1,RNASequence s2){
  SubstitutionMatrix<NucleotideCompound> matrix=SubstitutionMatrixHelper.getNuc4_4();
  GapPenalty penalty=new SimpleGapPenalty(8,1);
  PairwiseSequenceAligner<RNASequence,NucleotideCompound> nw=Alignments.getPairwiseAligner(s1,s2,PairwiseSequenceAlignerType.GLOBAL,penalty,matrix);
  return nw.getPair();
}

Fixed version (ground truth):
private static SequencePair<RNASequence,NucleotideCompound> alignRNA(RNASequence s1,RNASequence s2){
  SubstitutionMatrix<NucleotideCompound> matrix=SubstitutionMatrixHelper.getNuc4_4();
  GapPenalty penalty=new SimpleGapPenalty(8,1);
  PairwiseSequenceAligner<RNASequence,NucleotideCompound> nw=Alignments.getPairwiseAligner(s1,s2,PairwiseSequenceAlignerType.GLOBAL,penalty,matrix);
  return nw.getPair();
}
Program: 16412
Project: 16412
Buggy source:
private SequencePair<ProteinSequence,AminoAcidCompound> alignProtein(ProteinSequence s1,ProteinSequence s2){
  SubstitutionMatrix<AminoAcidCompound> matrix=SubstitutionMatrixHelper.getIdentity();
  GapPenalty penalty=new SimpleGapPenalty(8,1);
  PairwiseSequenceAligner<ProteinSequence,AminoAcidCompound> nw=Alignments.getPairwiseAligner(s1,s2,PairwiseSequenceAlignerType.GLOBAL,penalty,matrix);
  return nw.getPair();
}

Fixed version (ground truth):
private static SequencePair<ProteinSequence,AminoAcidCompound> alignProtein(ProteinSequence s1,ProteinSequence s2){
  SubstitutionMatrix<AminoAcidCompound> matrix=SubstitutionMatrixHelper.getIdentity();
  GapPenalty penalty=new SimpleGapPenalty(8,1);
  PairwiseSequenceAligner<ProteinSequence,AminoAcidCompound> nw=Alignments.getPairwiseAligner(s1,s2,PairwiseSequenceAlignerType.GLOBAL,penalty,matrix);
  return nw.getPair();
}
Program: 16414
Project: 16414
Buggy source:
/** 
 * Start the parsing
 */
@Override public void documentStart(){
  structure=new StructureImpl();
  currentChain=null;
  currentGroup=null;
  currentNmrModelNumber=null;
  allModels=new ArrayList<List<Chain>>();
  currentModel=new ArrayList<Chain>();
  entities=new ArrayList<Entity>();
  strucRefs=new ArrayList<StructRef>();
  seqResChains=new ArrayList<Chain>();
  entityChains=new ArrayList<Chain>();
  structAsyms=new ArrayList<StructAsym>();
  asymId2entityId=new HashMap<String,String>();
  structOpers=new ArrayList<PdbxStructOperList>();
  strucAssemblies=new ArrayList<PdbxStructAssembly>();
  strucAssemblyGens=new ArrayList<PdbxStructAssemblyGen>();
  entitySrcGens=new ArrayList<EntitySrcGen>();
  entitySrcNats=new ArrayList<EntitySrcNat>();
  entitySrcSyns=new ArrayList<EntitySrcSyn>();
  structConn=new ArrayList<StructConn>();
  structNcsOper=new ArrayList<StructNcsOper>();
  sequenceDifs=new ArrayList<StructRefSeqDif>();
  structSiteGens=new ArrayList<StructSiteGen>();
}

Fixed version (ground truth):
/** 
 * Start the parsing
 */
@Override public void documentStart(){
  structure=new StructureImpl();
  currentChain=null;
  currentGroup=null;
  currentNmrModelNumber=null;
  allModels=new ArrayList<List<Chain>>();
  currentModel=new ArrayList<Chain>();
  entities=new ArrayList<Entity>();
  entityPolys=new ArrayList<>();
  strucRefs=new ArrayList<StructRef>();
  seqResChains=new ArrayList<Chain>();
  entityChains=new ArrayList<Chain>();
  structAsyms=new ArrayList<StructAsym>();
  asymId2entityId=new HashMap<String,String>();
  asymId2authorId=new HashMap<>();
  structOpers=new ArrayList<PdbxStructOperList>();
  strucAssemblies=new ArrayList<PdbxStructAssembly>();
  strucAssemblyGens=new ArrayList<PdbxStructAssemblyGen>();
  entitySrcGens=new ArrayList<EntitySrcGen>();
  entitySrcNats=new ArrayList<EntitySrcNat>();
  entitySrcSyns=new ArrayList<EntitySrcSyn>();
  structConn=new ArrayList<StructConn>();
  structNcsOper=new ArrayList<StructNcsOper>();
  sequenceDifs=new ArrayList<StructRefSeqDif>();
  structSiteGens=new ArrayList<StructSiteGen>();
}
Program: 16417
Project: 16417
Buggy source:
@After public void printInfo(){
  if (pdbId != null)   System.out.println("String_Node_Str" + pdbId);
}

Fixed version (ground truth):
@After public void printInfo(){
  if (pdbId != null)   System.out.println("String_Node_Str" + pdbId + "String_Node_Str"+ countTested+ "String_Node_Str");
}
Program: 16418
Project: 16418
Buggy source:
private void testChains(Structure sPdb,Structure sCif) throws StructureException {
  assertNotNull(sPdb.getChains());
  assertNotNull(sCif.getChains());
  assertEquals(sPdb.getPolyChains().size(),sCif.getPolyChains().size());
  assertEquals(sPdb.getNonPolyChains().size(),sCif.getNonPolyChains().size());
  assertEquals(sPdb.getWaterChains().size(),sCif.getWaterChains().size());
  assertEquals(sPdb.getChains().size(),sCif.getChains().size());
  List<String> chainIds=new ArrayList<String>();
  for (  Chain chain : sPdb.getChains()) {
    chainIds.add(chain.getName());
  }
  for (  String chainId : chainIds) {
    testSingleChain(sPdb.getPolyChainByPDB(chainId),sCif.getPolyChainByPDB(chainId));
  }
}

Fixed version (ground truth):
private void testChains(Structure sPdb,Structure sCif) throws StructureException {
  assertNotNull(sPdb.getChains());
  assertNotNull(sCif.getChains());
  if (!containsSugar(sCif)) {
    assertEquals(sPdb.getPolyChains().size(),sCif.getPolyChains().size());
    if (!containsUNL(sCif)) {
      assertEquals(sPdb.getNonPolyChains().size(),sCif.getNonPolyChains().size());
    }
    assertEquals(sPdb.getWaterChains().size(),sCif.getWaterChains().size());
    if (!containsUNL(sCif)) {
      assertEquals(sPdb.getChains().size(),sCif.getChains().size());
    }
  }
  Set<String> chainIds=new TreeSet<String>();
  for (  Chain chain : sPdb.getPolyChains()) {
    chainIds.add(chain.getName());
  }
  for (  String chainId : chainIds) {
    testSingleChain(sPdb.getPolyChainByPDB(chainId),sCif.getPolyChainByPDB(chainId));
  }
}
Program: 16419
Project: 16419
Buggy source:
private void testAll(List<String> pdbIds) throws IOException, StructureException {
  pdbIdsWithMismatchingMolIds=new HashSet<String>();
  long start=System.currentTimeMillis();
  System.out.println("String_Node_Str" + pdbIds.size() + "String_Node_Str");
  for (int i=0; i < pdbIds.size(); i++) {
    pdbId=pdbIds.get(i);
    System.out.print("String_Node_Str");
    testSingleEntry(pdbId);
    if (((i + 1) % DOTS_PER_LINE) == 0)     System.out.println();
  }
  pdbId=null;
  long end=System.currentTimeMillis();
  checkWarnings();
  System.out.printf("String_Node_Str",(end - start) / 60000.0);
}

Fixed version (ground truth):
private void testAll(List<String> pdbIds) throws IOException, StructureException {
  pdbIdsWithMismatchingMolIds=new HashSet<String>();
  long start=System.currentTimeMillis();
  System.out.println("String_Node_Str" + pdbIds.size() + "String_Node_Str");
  for (int i=0; i < pdbIds.size(); i++) {
    pdbId=pdbIds.get(i);
    countTested=i + 1;
    System.out.print("String_Node_Str");
    testSingleEntry(pdbId);
    if (((i + 1) % DOTS_PER_LINE) == 0)     System.out.println();
  }
  pdbId=null;
  long end=System.currentTimeMillis();
  checkWarnings();
  System.out.printf("String_Node_Str",(end - start) / 60000.0);
}
Program: 16420
Project: 16420
Buggy source:
/** 
 * Returns true if the given chain is composed of water molecules only
 * @param c
 * @return
 */
public static boolean isChainWaterOnly(Chain c){
  boolean waterOnly=true;
  for (  Group g : c.getAtomGroups()) {
    if (!g.isWater())     waterOnly=false;
    break;
  }
  return waterOnly;
}

Fixed version (ground truth):
/** 
 * Returns true if the given chain is composed of water molecules only
 * @param c
 * @return
 */
public static boolean isChainWaterOnly(Chain c){
  for (  Group g : c.getAtomGroups()) {
    if (!g.isWater())     return false;
  }
  return true;
}
Program: 16421
Project: 16421
Buggy source:
/** 
 * Split the given chain (containing non-polymer groups and water groups only)  into individual chains per non-polymer group and individual chains per contiguous sets of water groups. 
 * @param chain
 * @return a list of lists of size 2: first list is the split non-poly chains, second list is the split water chains 
 */
private static List<List<Chain>> splitNonPolyChain(Chain chain){
  List<Chain> splitNonPolys=new ArrayList<>();
  List<Chain> waterChains=new ArrayList<>();
  Chain split=null;
  boolean previousGroupIsWater=false;
  for (  Group g : chain.getAtomGroups()) {
    if (!previousGroupIsWater) {
      if (split != null) {
        splitNonPolys.add(split);
      }
      split=new ChainImpl();
      split.setName(chain.getName());
    }
 else     if (!g.isWater()) {
      waterChains.add(split);
    }
    if (g.isWater()) {
      previousGroupIsWater=true;
    }
 else {
      previousGroupIsWater=false;
    }
    split.addGroup(g);
  }
  if (split != null) {
    if (previousGroupIsWater)     waterChains.add(split);
 else     splitNonPolys.add(split);
  }
  List<List<Chain>> all=new ArrayList<>(2);
  all.add(splitNonPolys);
  all.add(waterChains);
  return all;
}

Fixed version (ground truth):
/** 
 * Split the given chain (containing non-polymer groups and water groups only)  into individual chains per non-polymer group and individual chains per contiguous sets of water groups. 
 * @param chain
 * @return a list of lists of size 2: first list is the split non-poly chains, second list is the split water chains 
 */
private static List<List<Chain>> splitNonPolyChain(Chain chain){
  List<Chain> splitNonPolys=new ArrayList<>();
  List<Chain> waterChains=new ArrayList<>();
  Chain split=null;
  boolean previousGroupIsWater=false;
  for (  Group g : chain.getAtomGroups()) {
    if (!previousGroupIsWater) {
      if (split != null) {
        splitNonPolys.add(split);
      }
      split=new ChainImpl();
      split.setName(chain.getName());
    }
 else     if (!g.isWater()) {
      waterChains.add(split);
      split=new ChainImpl();
      split.setName(chain.getName());
    }
    if (g.isWater()) {
      previousGroupIsWater=true;
    }
 else {
      previousGroupIsWater=false;
    }
    split.addGroup(g);
  }
  if (split != null) {
    if (previousGroupIsWater)     waterChains.add(split);
 else     splitNonPolys.add(split);
  }
  List<List<Chain>> all=new ArrayList<>(2);
  all.add(splitNonPolys);
  all.add(waterChains);
  return all;
}
Program: 16424
Project: 16424
Buggy source:
@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);
}

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.getPolyChainByPDB("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(1,count);
  c=s.getNonPolyChainByPDB("String_Node_Str");
  g=c.getGroupByPDB(rn);
  assertNotNull(g);
  assertEquals("String_Node_Str",g.getPDBName());
}