nus-yam/ex-repair huggingface dataset:
Program: 16759
Project: 16759
Buggy source:
private void atoms2groups(AtomContactSet atomContacts){
  for (  AtomContact atomContact : atomContacts) {
    Pair<Atom> atomPair=atomContact.getPair();
    Group iResidue=atomPair.getFirst().getGroup();
    Group jResidue=atomPair.getSecond().getGroup();
    if (iResidue.equals(jResidue))     continue;
    Pair<Group> residuePair=new Pair<Group>(iResidue,jResidue);
    Pair<ResidueNumber> pair=new Pair<ResidueNumber>(iResidue.getResidueNumber(),jResidue.getResidueNumber());
    if (!contacts.containsKey(pair)) {
      GroupContact groupContact=new GroupContact();
      groupContact.setPair(residuePair);
      groupContact.addAtomContact(atomContact);
      contacts.put(pair,groupContact);
    }
 else {
      GroupContact groupContact=contacts.get(pair);
      groupContact.addAtomContact(atomContact);
    }
  }
}

Fixed version (ground truth):
private void atoms2groups(AtomContactSet atomContacts){
  for (  AtomContact atomContact : atomContacts) {
    Pair<Atom> atomPair=atomContact.getPair();
    Group iResidue=atomPair.getFirst().getGroup();
    Group jResidue=atomPair.getSecond().getGroup();
    if (iResidue.equals(jResidue))     continue;
    Pair<Group> residuePair=new Pair<Group>(iResidue,jResidue);
    Pair<ResidueIdentifier> pair=new Pair<ResidueIdentifier>(new ResidueIdentifier(iResidue),new ResidueIdentifier(jResidue));
    if (!contacts.containsKey(pair)) {
      GroupContact groupContact=new GroupContact();
      groupContact.setPair(residuePair);
      groupContact.addAtomContact(atomContact);
      contacts.put(pair,groupContact);
    }
 else {
      GroupContact groupContact=contacts.get(pair);
      groupContact.addAtomContact(atomContact);
    }
  }
}
Program: 16760
Project: 16760
Buggy source:
/** 
 * Tell whether the given pair is a contact in this GroupContactSet, in a chain-identifier independent way: contacts happening between different copies of  the same Compound(Entity) will be considered equal as long as they have the same residue numbers.
 * @param resId1
 * @param resId2
 * @return
 */
public boolean hasContact(ResidueIdentifier resId1,ResidueIdentifier resId2){
  if (residueIdContacts == null) {
    initResidueIdContacts();
  }
  return residueIdContacts.contains(new Pair<ResidueIdentifier>(resId1,resId2));
}

Fixed version (ground truth):
/** 
 * Tell whether the given pair is a contact in this GroupContactSet, in a chain-identifier independent way: contacts happening between different copies of  the same Compound(Entity) will be considered equal as long as they have the same residue numbers.
 * @param resId1
 * @param resId2
 * @return
 */
public boolean hasContact(ResidueIdentifier resId1,ResidueIdentifier resId2){
  return contacts.containsKey(new Pair<ResidueIdentifier>(resId1,resId2));
}
Program: 16761
Project: 16761
Buggy source:
public ResidueIdentifier(int seqNum,Character insCode){
  this.seqNum=seqNum;
  this.insCode=insCode;
}

Fixed version (ground truth):
public ResidueIdentifier(Group g){
  Chain c=g.getChain();
  if (c == null) {
    logger.warn("String_Node_Str",g.toString());
    this.seqResIndex=-1;
  }
 else {
    Compound comp=c.getCompound();
    if (comp == null) {
      logger.warn("String_Node_Str",g.toString());
      this.seqResIndex=-1;
    }
 else {
      this.seqResIndex=comp.getAlignedResIndex(g,c);
    }
  }
}
Program: 16762
Project: 16762
Buggy source:
@Override public int hashCode(){
  final int prime=31;
  int result=1;
  result=prime * result + seqNum;
  result=prime * result + (insCode == null ? 0 : insCode);
  return result;
}

Fixed version (ground truth):
@Override public int hashCode(){
  return seqResIndex;
}
Program: 16763
Project: 16763
Buggy source:
@Override public boolean equals(Object obj){
  if (this == obj)   return true;
  if (obj == null)   return false;
  if (getClass() != obj.getClass())   return false;
  ResidueIdentifier other=(ResidueIdentifier)obj;
  if (this.seqNum != other.seqNum)   return false;
  if (this.insCode == null && other.insCode != null)   return false;
  if (this.insCode != null && other.insCode == null)   return false;
  if (this.insCode == null && other.insCode == null)   return true;
  if (this.insCode != other.insCode)   return false;
  return true;
}

Fixed version (ground truth):
@Override public boolean equals(Object obj){
  if (this == obj)   return true;
  if (obj == null)   return false;
  if (getClass() != obj.getClass())   return false;
  ResidueIdentifier other=(ResidueIdentifier)obj;
  return this.seqResIndex == other.seqResIndex;
}
Program: 16764
Project: 16764
Buggy source:
@Override public String toString(){
  return "String_Node_Str" + seqNum + (insCode == null ? "String_Node_Str" : insCode);
}

Fixed version (ground truth):
@Override public String toString(){
  return "String_Node_Str" + seqResIndex;
}
Program: 16767
Project: 16767
Buggy source:
/** 
 * Populates domainMap
 * @throws IOException 
 */
private void indexDomains() throws IOException {
  domainsFileLock.writeLock().lock();
  try {
    if (allDomains == null) {
      ensureDomainsFileInstalled();
    }
    domainMap=new HashMap<String,List<EcodDomain>>((int)(150000 / .85),.85f);
    for (    EcodDomain d : allDomains) {
      String pdbId=d.getPdbId();
      if (pdbId == null) {
        String ecodId=d.getDomainId();
        if (ecodId != null && !ecodId.isEmpty()) {
          Matcher match=ECOD_RE.matcher(ecodId);
          pdbId=match.group(1);
        }
      }
      List<EcodDomain> currDomains;
      if (domainMap.containsKey(pdbId)) {
        currDomains=domainMap.get(pdbId);
      }
 else {
        currDomains=new LinkedList<EcodDomain>();
        domainMap.put(pdbId,currDomains);
      }
      currDomains.add(d);
    }
  }
  finally {
    domainsFileLock.writeLock().unlock();
  }
}

Fixed version (ground truth):
/** 
 * Populates domainMap
 * @throws IOException 
 */
private void indexDomains() throws IOException {
  domainsFileLock.writeLock().lock();
  logger.trace("String_Node_Str");
  try {
    if (allDomains == null) {
      ensureDomainsFileInstalled();
    }
    domainMap=new HashMap<String,List<EcodDomain>>((int)(150000 / .85),.85f);
    for (    EcodDomain d : allDomains) {
      String pdbId=d.getPdbId();
      if (pdbId == null) {
        String ecodId=d.getDomainId();
        if (ecodId != null && !ecodId.isEmpty()) {
          Matcher match=ECOD_RE.matcher(ecodId);
          pdbId=match.group(1);
        }
      }
      List<EcodDomain> currDomains;
      if (domainMap.containsKey(pdbId)) {
        currDomains=domainMap.get(pdbId);
      }
 else {
        currDomains=new LinkedList<EcodDomain>();
        domainMap.put(pdbId,currDomains);
      }
      currDomains.add(d);
    }
  }
  finally {
    logger.trace("String_Node_Str");
    domainsFileLock.writeLock().unlock();
  }
}
Program: 16768
Project: 16768
Buggy source:
public void setVersion(String version){
  domainsFileLock.readLock().lock();
  try {
    if (version.equals(this.version)) {
      return;
    }
  }
  finally {
    domainsFileLock.readLock().unlock();
  }
  domainsFileLock.writeLock().lock();
  try {
    this.version=version;
    this.clear();
  }
  finally {
    domainsFileLock.writeLock().unlock();
  }
}

Fixed version (ground truth):
public void setVersion(String version){
  domainsFileLock.readLock().lock();
  logger.trace("String_Node_Str");
  try {
    if (version.equals(this.version)) {
      return;
    }
  }
  finally {
    logger.trace("String_Node_Str");
    domainsFileLock.readLock().unlock();
  }
  domainsFileLock.writeLock().lock();
  logger.trace("String_Node_Str");
  try {
    this.version=version;
    this.clear();
  }
  finally {
    logger.trace("String_Node_Str");
    domainsFileLock.writeLock().unlock();
  }
}
Program: 16769
Project: 16769
Buggy source:
/** 
 * Blocks until ECOD domains file has been downloaded and parsed. This may be useful in multithreaded environments
 * @throws IOException
 */
public void ensureDomainsFileInstalled() throws IOException {
  domainsFileLock.readLock().lock();
  try {
    if (allDomains != null) {
      return;
    }
  }
  finally {
    domainsFileLock.readLock().unlock();
  }
  domainsFileLock.writeLock().lock();
  try {
    if (!domainsAvailable()) {
      downloadDomains();
    }
    parseDomains();
  }
  finally {
    domainsFileLock.writeLock().unlock();
  }
}

Fixed version (ground truth):
/** 
 * Blocks until ECOD domains file has been downloaded and parsed. This may be useful in multithreaded environments
 * @throws IOException
 */
public void ensureDomainsFileInstalled() throws IOException {
  domainsFileLock.readLock().lock();
  logger.trace("String_Node_Str");
  try {
    if (allDomains != null) {
      return;
    }
  }
  finally {
    logger.trace("String_Node_Str");
    domainsFileLock.readLock().unlock();
  }
  domainsFileLock.writeLock().lock();
  logger.trace("String_Node_Str");
  try {
    if (!domainsAvailable()) {
      downloadDomains();
    }
    parseDomains();
  }
  finally {
    logger.trace("String_Node_Str");
    domainsFileLock.writeLock().unlock();
  }
}
Program: 16770
Project: 16770
Buggy source:
/** 
 * Clears all domains, requiring the file to be reparsed for subsequent accesses
 */
public void clear(){
  domainsFileLock.writeLock().lock();
  ;
  allDomains=null;
  domainMap=null;
  domainsFileLock.writeLock().unlock();
}

Fixed version (ground truth):
/** 
 * Clears all domains, requiring the file to be reparsed for subsequent accesses
 */
public void clear(){
  domainsFileLock.writeLock().lock();
  logger.trace("String_Node_Str");
  allDomains=null;
  domainMap=null;
  logger.trace("String_Node_Str");
  domainsFileLock.writeLock().unlock();
}
Program: 16771
Project: 16771
Buggy source:
/** 
 * Get a list of all ECOD domains for a particular PDB ID
 * @param pdbId
 * @return the list of domains, or null if no matching domains were found
 * @throws IOException
 */
public List<EcodDomain> getDomainsForPDB(String pdbId) throws IOException {
  domainsFileLock.readLock().lock();
  try {
    while (domainMap == null) {
      domainsFileLock.readLock().unlock();
      indexDomains();
      domainsFileLock.readLock().lock();
    }
    if (pdbId != null)     pdbId=pdbId.toLowerCase();
    List<EcodDomain> doms=domainMap.get(pdbId);
    if (doms == null) {
      return null;
    }
    List<EcodDomain> clonedDoms=new ArrayList<EcodDomain>(doms.size());
    for (    EcodDomain d : doms) {
      clonedDoms.add(new EcodDomain(d));
    }
    return clonedDoms;
  }
  finally {
    domainsFileLock.readLock().unlock();
  }
}

Fixed version (ground truth):
/** 
 * Get a list of all ECOD domains for a particular PDB ID
 * @param pdbId
 * @return the list of domains, or null if no matching domains were found
 * @throws IOException
 */
public List<EcodDomain> getDomainsForPDB(String pdbId) throws IOException {
  domainsFileLock.readLock().lock();
  try {
    logger.trace("String_Node_Str");
    while (domainMap == null) {
      logger.trace("String_Node_Str");
      domainsFileLock.readLock().unlock();
      indexDomains();
      domainsFileLock.readLock().lock();
      logger.trace("String_Node_Str");
    }
    if (pdbId != null)     pdbId=pdbId.toLowerCase();
    List<EcodDomain> doms=domainMap.get(pdbId);
    if (doms == null) {
      return null;
    }
    List<EcodDomain> clonedDoms=new ArrayList<EcodDomain>(doms.size());
    for (    EcodDomain d : doms) {
      clonedDoms.add(new EcodDomain(d));
    }
    return clonedDoms;
  }
  finally {
    logger.trace("String_Node_Str");
    domainsFileLock.readLock().unlock();
  }
}
Program: 16772
Project: 16772
Buggy source:
/** 
 * Downloads the domains file, overwriting any existing file
 * @throws IOException
 */
private void downloadDomains() throws IOException {
  domainsFileLock.writeLock().lock();
  try {
    URL domainsURL=new URL(url + DOMAINS_PATH + getDomainFilename());
    File localFile=getDomainFile();
    logger.info("String_Node_Str",domainsURL,localFile);
    FileDownloadUtils.downloadFile(domainsURL,localFile);
  }
 catch (  MalformedURLException e) {
    logger.error("String_Node_Str" + url + DOMAINS_PATH+ getDomainFilename(),e);
  }
 finally {
    domainsFileLock.writeLock().unlock();
  }
}

Fixed version (ground truth):
/** 
 * Downloads the domains file, overwriting any existing file
 * @throws IOException
 */
private void downloadDomains() throws IOException {
  domainsFileLock.writeLock().lock();
  logger.trace("String_Node_Str");
  try {
    URL domainsURL=new URL(url + DOMAINS_PATH + getDomainFilename());
    File localFile=getDomainFile();
    logger.info("String_Node_Str",domainsURL,localFile);
    FileDownloadUtils.downloadFile(domainsURL,localFile);
  }
 catch (  MalformedURLException e) {
    logger.error("String_Node_Str" + url + DOMAINS_PATH+ getDomainFilename(),e);
  }
 finally {
    logger.trace("String_Node_Str");
    domainsFileLock.writeLock().unlock();
  }
}
Program: 16773
Project: 16773
Buggy source:
/** 
 * Parses the domains from the local file
 * @throws IOException
 */
private void parseDomains() throws IOException {
  domainsFileLock.writeLock().lock();
  try {
    EcodParser parser=new EcodParser(getDomainFile());
    allDomains=parser.getDomains();
  }
  finally {
    domainsFileLock.writeLock().unlock();
  }
}

Fixed version (ground truth):
/** 
 * Parses the domains from the local file
 * @throws IOException
 */
private void parseDomains() throws IOException {
  domainsFileLock.writeLock().lock();
  logger.trace("String_Node_Str");
  try {
    EcodParser parser=new EcodParser(getDomainFile());
    allDomains=parser.getDomains();
  }
  finally {
    logger.trace("String_Node_Str");
    domainsFileLock.writeLock().unlock();
  }
}
Program: 16774
Project: 16774
Buggy source:
public List<EcodDomain> getAllDomains() throws IOException {
  domainsFileLock.readLock().lock();
  try {
    while (allDomains == null) {
      domainsFileLock.readLock().unlock();
      ensureDomainsFileInstalled();
      domainsFileLock.readLock().lock();
    }
    return allDomains;
  }
  finally {
    domainsFileLock.readLock().lock();
  }
}

Fixed version (ground truth):
public List<EcodDomain> getAllDomains() throws IOException {
  domainsFileLock.readLock().lock();
  logger.trace("String_Node_Str");
  try {
    while (allDomains == null) {
      logger.trace("String_Node_Str");
      domainsFileLock.readLock().unlock();
      ensureDomainsFileInstalled();
      domainsFileLock.readLock().lock();
      logger.trace("String_Node_Str");
    }
    return allDomains;
  }
  finally {
    logger.trace("String_Node_Str");
    domainsFileLock.readLock().unlock();
  }
}
Program: 16775
Project: 16775
Buggy source:
/** 
 * Set an alternate download location for files
 * @param cacheLocation
 */
public void setCacheLocation(String cacheLocation){
  if (cacheLocation.equals(this.cacheLocation)) {
    return;
  }
  domainsFileLock.writeLock().lock();
  this.cacheLocation=cacheLocation;
  domainsFileLock.writeLock().unlock();
}

Fixed version (ground truth):
/** 
 * Set an alternate download location for files
 * @param cacheLocation
 */
public void setCacheLocation(String cacheLocation){
  if (cacheLocation.equals(this.cacheLocation)) {
    return;
  }
  domainsFileLock.writeLock().lock();
  logger.trace("String_Node_Str");
  this.cacheLocation=cacheLocation;
  logger.trace("String_Node_Str");
  domainsFileLock.writeLock().unlock();
}
Program: 16776
Project: 16776
Buggy source:
public EcodDomain getDomainsById(String ecodId) throws IOException {
  if (ecodId == null || ecodId.isEmpty()) {
    return null;
  }
  Matcher match=ECOD_RE.matcher(ecodId);
  String pdbId=null;
  if (match.matches())   pdbId=match.group(1);
  List<EcodDomain> doms=getDomainsForPDB(pdbId);
  for (  EcodDomain d : doms) {
    if (ecodId.equals(d.getDomainId())) {
      return d;
    }
  }
  return null;
}

Fixed version (ground truth):
public EcodDomain getDomainsById(String ecodId) throws IOException {
  if (ecodId == null || ecodId.isEmpty()) {
    return null;
  }
  Matcher match=ECOD_RE.matcher(ecodId);
  String pdbId=null;
  if (match.matches())   pdbId=match.group(1);
  List<EcodDomain> doms=getDomainsForPDB(pdbId);
  if (doms == null) {
    logger.debug("String_Node_Str",pdbId,ecodId);
    return null;
  }
  logger.debug("String_Node_Str",doms.size(),pdbId);
  for (  EcodDomain d : doms) {
    if (ecodId.equals(d.getDomainId())) {
      return d;
    }
  }
  return null;
}
Program: 16777
Project: 16777
Buggy source:
/** 
 * Checks that the domains file has been downloaded
 * @return
 */
private boolean domainsAvailable(){
  domainsFileLock.readLock().lock();
  try {
    File f=getDomainFile();
    return f.exists() && f.length() > 0;
  }
  finally {
    domainsFileLock.readLock().unlock();
  }
}

Fixed version (ground truth):
/** 
 * Checks that the domains file has been downloaded
 * @return
 */
private boolean domainsAvailable(){
  domainsFileLock.readLock().lock();
  logger.trace("String_Node_Str");
  try {
    File f=getDomainFile();
    return f.exists() && f.length() > 0;
  }
  finally {
    logger.trace("String_Node_Str");
    domainsFileLock.readLock().unlock();
  }
}
Program: 16778
Project: 16778
Buggy source:
@Test public void testDownloads() throws IOException {
  File domainsFile=new File(ecod.getCacheLocation(),"String_Node_Str" + VERSION + "String_Node_Str");
  if (domainsFile.exists()) {
    domainsFile.delete();
  }
  ecod.ensureDomainsFileInstalled();
  assertTrue("String_Node_Str" + domainsFile.toString(),domainsFile.exists());
}

Fixed version (ground truth):
@Test public void testDownloads() throws IOException {
  EcodInstallation ecod2=new EcodInstallation(tmpFolder.getRoot().getAbsolutePath());
  ecod2.setVersion(VERSION);
  File domainsFile=new File(ecod2.getCacheLocation(),"String_Node_Str" + VERSION + "String_Node_Str");
  if (domainsFile.exists()) {
    domainsFile.delete();
  }
  ecod2.ensureDomainsFileInstalled();
  assertTrue("String_Node_Str" + domainsFile.toString(),domainsFile.exists());
}
Program: 16779
Project: 16779
Buggy source:
@Override public AFPChain align(Atom[] ca1,Atom[] ca2,Object parameters) throws StructureException {
  if (parameters == null) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  if (!(parameters instanceof SmithWaterman3DParameters))   throw new IllegalArgumentException("String_Node_Str" + parameters.getClass().getName());
  params=(SmithWaterman3DParameters)parameters;
  AFPChain afpChain=new AFPChain();
  try {
    String seq1=StructureTools.convertAtomsToSeq(ca1);
    String seq2=StructureTools.convertAtomsToSeq(ca2);
    ProteinSequence s1=new ProteinSequence(seq1);
    ProteinSequence s2=new ProteinSequence(seq2);
    SubstitutionMatrix<AminoAcidCompound> matrix=SubstitutionMatrixHelper.getBlosum65();
    GapPenalty penalty=new SimpleGapPenalty();
    penalty.setOpenPenalty(params.getGapOpen());
    penalty.setExtensionPenalty(params.getGapExtend());
    PairwiseSequenceAligner<ProteinSequence,AminoAcidCompound> smithWaterman=Alignments.getPairwiseAligner(s1,s2,PairwiseSequenceAlignerType.LOCAL,penalty,matrix);
    SequencePair<ProteinSequence,AminoAcidCompound> pair=smithWaterman.getPair();
    logger.debug("String_Node_Str" + pair.toString(100));
    afpChain=convert(ca1,ca2,pair,smithWaterman);
  }
 catch (  CompoundNotFoundException e) {
    throw new StructureException(e.getMessage(),e);
  }
  return afpChain;
}

Fixed version (ground truth):
@Override public AFPChain align(Atom[] ca1,Atom[] ca2,Object parameters) throws StructureException {
  if (parameters == null) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  if (!(parameters instanceof SmithWaterman3DParameters))   throw new IllegalArgumentException("String_Node_Str" + parameters.getClass().getName());
  params=(SmithWaterman3DParameters)parameters;
  AFPChain afpChain=new AFPChain();
  String seq1=StructureTools.convertAtomsToSeq(ca1);
  String seq2=StructureTools.convertAtomsToSeq(ca2);
  ProteinSequence s1=null;
  ProteinSequence s2=null;
  try {
    s1=new ProteinSequence(seq1);
    s2=new ProteinSequence(seq2);
  }
 catch (  CompoundNotFoundException e) {
    throw new StructureException(e.getMessage(),e);
  }
  SubstitutionMatrix<AminoAcidCompound> matrix=SubstitutionMatrixHelper.getBlosum65();
  GapPenalty penalty=new SimpleGapPenalty();
  penalty.setOpenPenalty(params.getGapOpen());
  penalty.setExtensionPenalty(params.getGapExtend());
  PairwiseSequenceAligner<ProteinSequence,AminoAcidCompound> smithWaterman=Alignments.getPairwiseAligner(s1,s2,PairwiseSequenceAlignerType.LOCAL,penalty,matrix);
  SequencePair<ProteinSequence,AminoAcidCompound> pair=smithWaterman.getPair();
  if (pair.getTarget().toString().isEmpty() || pair.getQuery().toString().isEmpty()) {
    throw new StructureException("String_Node_Str" + s1 + "String_Node_Str"+ s2);
  }
  logger.debug("String_Node_Str" + pair.toString(100));
  afpChain=convert(ca1,ca2,pair,smithWaterman);
  return afpChain;
}
Program: 16780
Project: 16780
Buggy source:
public boolean identityMatch(Atom[] cAlphaAtoms,String chainId,int modelNumber,int structureId,String sequence){
  UniqueSequenceList u=uniqueSequenceList.get(0);
  String refSequence=u.getSeqResSequence();
  boolean seqMatch=refSequence.equals(sequence);
  if (seqMatch) {
    List<Integer> alig1=new ArrayList<Integer>();
    List<Integer> alig2=new ArrayList<Integer>();
    Atom[] referenceAtoms=u.getCalphaAtoms();
    int inCommon=alignIdenticalSequence(referenceAtoms,cAlphaAtoms,alig1,alig2);
    if (inCommon > 0) {
      UniqueSequenceList seqList=new UniqueSequenceList(cAlphaAtoms,chainId,modelNumber,structureId,sequence);
      seqList.setAlignment1(alig1);
      seqList.setAlignment2(alig2);
      addUniqueSequenceList(seqList);
      return true;
    }
  }
  return false;
}

Fixed version (ground truth):
public boolean identityMatch(Atom[] cAlphaAtoms,String chainId,int modelNumber,int structureId,String sequence){
  UniqueSequenceList u=uniqueSequenceList.get(0);
  String refSequence=u.getSeqResSequence();
  boolean seqMatch=refSequence.equals(sequence);
  if (seqMatch) {
    List<Integer> alig1=new ArrayList<Integer>();
    List<Integer> alig2=new ArrayList<Integer>();
    Atom[] referenceAtoms=u.getCalphaAtoms();
    int inCommon=0;
    try {
      inCommon=alignIdenticalSequence(referenceAtoms,cAlphaAtoms,alig1,alig2);
    }
 catch (    StructureException e) {
      logger.warn("String_Node_Str",u.getChainId(),refSequence,chainId,sequence);
    }
    if (inCommon > 0) {
      UniqueSequenceList seqList=new UniqueSequenceList(cAlphaAtoms,chainId,modelNumber,structureId,sequence);
      seqList.setAlignment1(alig1);
      seqList.setAlignment2(alig2);
      addUniqueSequenceList(seqList);
      return true;
    }
  }
  return false;
}
Program: 16781
Project: 16781
Buggy source:
private AFPChain alignPairBySequence(Atom[] ca1Seq,Atom[] ca2Seq){
  SmithWaterman3Daligner aligner=new SmithWaterman3Daligner();
  AFPChain afp=null;
  try {
    afp=aligner.align(ca1Seq,ca2Seq);
  }
 catch (  StructureException e) {
    logger.error("String_Node_Str" + ca1Seq.length + "String_Node_Str"+ ca2Seq.length,e);
  }
  return afp;
}

Fixed version (ground truth):
private AFPChain alignPairBySequence(Atom[] ca1Seq,Atom[] ca2Seq) throws StructureException {
  SmithWaterman3Daligner aligner=new SmithWaterman3Daligner();
  return aligner.align(ca1Seq,ca2Seq);
}
Program: 16782
Project: 16782
Buggy source:
private int alignIdenticalSequence(Atom[] ca1Seq,Atom[] ca2Seq,List<Integer> align1,List<Integer> align2){
  AFPChain afp=alignPairBySequence(ca1Seq,ca2Seq);
  int[][][] align=afp.getOptAln();
  if (align == null) {
    return 0;
  }
  int len=afp.getOptLength();
  List<Integer> delta=new ArrayList<Integer>();
  Set<Integer> unique=new HashSet<Integer>();
  for (int i=0; i < len; i++) {
    Atom a1=ca1Seq[align[0][0][i]];
    String residueName1=a1.getGroup().getPDBName();
    Atom a2=ca2Seq[align[0][1][i]];
    String residueName2=a2.getGroup().getPDBName();
    if (residueName1.equals(residueName2)) {
      int n1=a1.getGroup().getResidueNumber().getSeqNum();
      int n2=a2.getGroup().getResidueNumber().getSeqNum();
      delta.add(n2 - n1);
      unique.add(n2 - n1);
    }
  }
  int offset=0;
  int frequency=0;
  for (  Integer i : unique) {
    int freq=Collections.frequency(delta,i);
    if (freq > frequency) {
      offset=i;
      frequency=freq;
    }
  }
  for (int i=0; i < len; i++) {
    Atom a1=ca1Seq[align[0][0][i]];
    int n1=a1.getGroup().getResidueNumber().getSeqNum();
    Atom a2=ca2Seq[align[0][1][i]];
    int n2=a2.getGroup().getResidueNumber().getSeqNum();
    if (n2 - offset == n1) {
      align1.add(align[0][0][i]);
      align2.add(align[0][1][i]);
    }
  }
  return align1.size();
}

Fixed version (ground truth):
private int alignIdenticalSequence(Atom[] ca1Seq,Atom[] ca2Seq,List<Integer> align1,List<Integer> align2) throws StructureException {
  AFPChain afp=alignPairBySequence(ca1Seq,ca2Seq);
  int[][][] align=afp.getOptAln();
  if (align == null) {
    return 0;
  }
  int len=afp.getOptLength();
  List<Integer> delta=new ArrayList<Integer>();
  Set<Integer> unique=new HashSet<Integer>();
  for (int i=0; i < len; i++) {
    Atom a1=ca1Seq[align[0][0][i]];
    String residueName1=a1.getGroup().getPDBName();
    Atom a2=ca2Seq[align[0][1][i]];
    String residueName2=a2.getGroup().getPDBName();
    if (residueName1.equals(residueName2)) {
      int n1=a1.getGroup().getResidueNumber().getSeqNum();
      int n2=a2.getGroup().getResidueNumber().getSeqNum();
      delta.add(n2 - n1);
      unique.add(n2 - n1);
    }
  }
  int offset=0;
  int frequency=0;
  for (  Integer i : unique) {
    int freq=Collections.frequency(delta,i);
    if (freq > frequency) {
      offset=i;
      frequency=freq;
    }
  }
  for (int i=0; i < len; i++) {
    Atom a1=ca1Seq[align[0][0][i]];
    int n1=a1.getGroup().getResidueNumber().getSeqNum();
    Atom a2=ca2Seq[align[0][1][i]];
    int n2=a2.getGroup().getResidueNumber().getSeqNum();
    if (n2 - offset == n1) {
      align1.add(align[0][0][i]);
      align2.add(align[0][1][i]);
    }
  }
  return align1.size();
}
Program: 16783
Project: 16783
Buggy source:
public Structure rebuildQuaternaryStructure(Structure asymUnit,List<BiologicalAssemblyTransformation> transformations){
  orderTransformationsByChainId(asymUnit,transformations);
  Structure s=asymUnit.clone();
  s.setChains(new ArrayList<Chain>());
  for (  BiologicalAssemblyTransformation transformation : transformations) {
    for (    Chain c : asymUnit.getChains()) {
      String intChainID=c.getInternalChainID();
      if (intChainID == null) {
        logger.info("String_Node_Str" + c.getChainID());
        intChainID=c.getChainID();
      }
      if (transformation.getChainId().equals(intChainID)) {
        Chain chain=(Chain)c.clone();
        for (        Group g : chain.getAtomGroups()) {
          for (          Atom a : g.getAtoms()) {
            transformation.transformPoint(a.getCoords());
          }
        }
        String transformId=transformation.getId();
        addChainAndModel(s,chain,transformId);
      }
    }
  }
  s.setBiologicalAssembly(true);
  return s;
}

Fixed version (ground truth):
public Structure rebuildQuaternaryStructure(Structure asymUnit,List<BiologicalAssemblyTransformation> transformations){
  orderTransformationsByChainId(asymUnit,transformations);
  Structure s=asymUnit.clone();
  s.resetModels();
  for (  BiologicalAssemblyTransformation transformation : transformations) {
    for (    Chain c : asymUnit.getChains()) {
      String intChainID=c.getInternalChainID();
      if (intChainID == null) {
        logger.info("String_Node_Str" + c.getChainID());
        intChainID=c.getChainID();
      }
      if (transformation.getChainId().equals(intChainID)) {
        Chain chain=(Chain)c.clone();
        for (        Group g : chain.getAtomGroups()) {
          for (          Atom a : g.getAtoms()) {
            transformation.transformPoint(a.getCoords());
          }
        }
        String transformId=transformation.getId();
        addChainAndModel(s,chain,transformId);
      }
    }
  }
  s.setBiologicalAssembly(true);
  return s;
}
Program: 16786
Project: 16786
Buggy source:
private boolean isAminoAcid(Group group){
  ChemComp cc=group.getChemComp();
  if (cc.getResidueType() == null) {
    System.err.println("String_Node_Str" + group.getPDBName());
    return false;
  }
  return (cc.getResidueType().equals(ResidueType.lPeptideLinking) || cc.getResidueType().equals(ResidueType.glycine));
}

Fixed version (ground truth):
private boolean isAminoAcid(Group group){
  ChemComp cc=group.getChemComp();
  if (cc.getResidueType() == null) {
    logger.warn("String_Node_Str" + group.getPDBName());
    return false;
  }
  return (cc.getResidueType().equals(ResidueType.lPeptideLinking) || cc.getResidueType().equals(ResidueType.glycine));
}
Program: 16787
Project: 16787
Buggy source:
/** 
 * Get the list of chains that are part of this Compound
 * @return a List of Chain objects
 */
public List<Chain> getChains(){
  return this.chains;
}

Fixed version (ground truth):
/** 
 * Get the list of chains that are part of this Compound. Note that for multi-model  structures chains from all models are returned.
 * @return a List of Chain objects
 */
public List<Chain> getChains(){
  return this.chains;
}
Program: 16788
Project: 16788
Buggy source:
/** 
 * Return the list of member chain IDs that are described by this Compound 
 * @return the list of ChainIDs that are described by this Compound
 * @see #setChains(List)
 * @see #getChains()
 */
public List<String> getChainIds(){
  List<String> chainIds=new ArrayList<String>();
  for (  Chain chain : chains) {
    chainIds.add(chain.getChainID());
  }
  return chainIds;
}

Fixed version (ground truth):
/** 
 * Return the list of member chain IDs that are described by this Compound,  only unique chain IDs are contained in the list.  Note that in the case of multimodel structures this will return just the unique chain identifiers whilst   {@link #getChains()} will return a corresponding chain per model. 
 * @return the list of unique ChainIDs that are described by this Compound
 * @see #setChains(List)
 * @see #getChains()
 */
public List<String> getChainIds(){
  Set<String> uniqChainIds=new TreeSet<String>();
  for (int i=0; i < getChains().size(); i++) {
    uniqChainIds.add(getChains().get(i).getChainID());
  }
  return new ArrayList<String>(uniqChainIds);
}
Program: 16789
Project: 16789
Buggy source:
/** 
 * returns an identical copy of this structure .
 * @return an identical Structure object
 */
@Override public Structure clone(){
  Structure n=new StructureImpl();
  n.setPDBCode(getPDBCode());
  n.setName(getName());
  n.setPDBHeader(pdbHeader);
  n.setDBRefs(this.getDBRefs());
  n.setConnections(getConnections());
  n.setSites(getSites());
  for (int i=0; i < nrModels(); i++) {
    List<Chain> cloned_model=new ArrayList<Chain>();
    for (int j=0; j < size(i); j++) {
      Chain cloned_chain=(Chain)getChain(i,j).clone();
      cloned_chain.setParent(n);
      cloned_model.add(cloned_chain);
    }
    n.addModel(cloned_model);
  }
  List<Compound> newCompoundList=new ArrayList<Compound>();
  for (  Compound compound : this.compounds) {
    Compound newCompound=new Compound(compound);
    for (    String chainId : compound.getChainIds()) {
      try {
        for (int modelNr=0; modelNr < n.nrModels(); modelNr++) {
          Chain newChain=n.getChainByPDB(chainId,modelNr);
          newChain.setCompound(newCompound);
          newCompound.addChain(newChain);
        }
      }
 catch (      StructureException e) {
        logger.error("String_Node_Str",e);
      }
    }
    newCompoundList.add(newCompound);
  }
  n.setCompounds(newCompoundList);
  for (  SSBond ssbond : ssbonds) {
    n.addSSBond(ssbond.clone());
  }
  return n;
}

Fixed version (ground truth):
/** 
 * returns an identical copy of this structure .
 * @return an identical Structure object
 */
@Override public Structure clone(){
  Structure n=new StructureImpl();
  n.setPDBCode(getPDBCode());
  n.setName(getName());
  n.setPDBHeader(pdbHeader);
  n.setDBRefs(this.getDBRefs());
  n.setConnections(getConnections());
  n.setSites(getSites());
  for (int i=0; i < nrModels(); i++) {
    List<Chain> cloned_model=new ArrayList<Chain>();
    for (int j=0; j < size(i); j++) {
      Chain cloned_chain=(Chain)getChain(i,j).clone();
      cloned_chain.setParent(n);
      cloned_model.add(cloned_chain);
    }
    n.addModel(cloned_model);
  }
  List<Compound> newCompoundList=new ArrayList<Compound>();
  for (  Compound compound : this.compounds) {
    Compound newCompound=new Compound(compound);
    for (    String chainId : compound.getChainIds()) {
      for (int modelNr=0; modelNr < n.nrModels(); modelNr++) {
        try {
          Chain newChain=n.getChainByPDB(chainId,modelNr);
          newChain.setCompound(newCompound);
          newCompound.addChain(newChain);
        }
 catch (        StructureException e) {
          logger.warn("String_Node_Str" + chainId + "String_Node_Str"+ modelNr+ "String_Node_Str"+ compound.getMolId()+ "String_Node_Str");
        }
      }
    }
    newCompoundList.add(newCompound);
  }
  n.setCompounds(newCompoundList);
  for (  SSBond ssbond : ssbonds) {
    n.addSSBond(ssbond.clone());
  }
  return n;
}
Program: 16792
Project: 16792
Buggy source:
/** 
 * returns an identical copy of this structure .
 * @return an identical Structure object
 */
@Override public Structure clone(){
  Structure n=new StructureImpl();
  n.setPDBCode(getPDBCode());
  n.setName(getName());
  n.setPDBHeader(pdbHeader);
  n.setDBRefs(this.getDBRefs());
  n.setConnections(getConnections());
  n.setSites(getSites());
  for (int i=0; i < nrModels(); i++) {
    List<Chain> cloned_model=new ArrayList<Chain>();
    for (int j=0; j < size(i); j++) {
      Chain cloned_chain=(Chain)getChain(i,j).clone();
      cloned_chain.setParent(n);
      cloned_model.add(cloned_chain);
    }
    n.addModel(cloned_model);
  }
  List<Compound> newCompoundList=new ArrayList<Compound>();
  for (  Compound compound : this.compounds) {
    Compound newCompound=new Compound(compound);
    for (    String chainId : compound.getChainIds()) {
      try {
        Chain newChain=n.getChainByPDB(chainId);
        newChain.setCompound(newCompound);
        newCompound.addChain(newChain);
      }
 catch (      StructureException e) {
        logger.error("String_Node_Str",e);
      }
    }
    newCompoundList.add(newCompound);
  }
  n.setCompounds(newCompoundList);
  for (  SSBond ssbond : ssbonds) {
    n.addSSBond(ssbond.clone());
  }
  return n;
}

Fixed version (ground truth):
/** 
 * returns an identical copy of this structure .
 * @return an identical Structure object
 */
@Override public Structure clone(){
  Structure n=new StructureImpl();
  n.setPDBCode(getPDBCode());
  n.setName(getName());
  n.setPDBHeader(pdbHeader);
  n.setDBRefs(this.getDBRefs());
  n.setConnections(getConnections());
  n.setSites(getSites());
  for (int i=0; i < nrModels(); i++) {
    List<Chain> cloned_model=new ArrayList<Chain>();
    for (int j=0; j < size(i); j++) {
      Chain cloned_chain=(Chain)getChain(i,j).clone();
      cloned_chain.setParent(n);
      cloned_model.add(cloned_chain);
    }
    n.addModel(cloned_model);
  }
  List<Compound> newCompoundList=new ArrayList<Compound>();
  for (  Compound compound : this.compounds) {
    Compound newCompound=new Compound(compound);
    for (    String chainId : compound.getChainIds()) {
      try {
        for (int modelNr=0; modelNr < n.nrModels(); modelNr++) {
          Chain newChain=n.getChainByPDB(chainId,modelNr);
          newChain.setCompound(newCompound);
          newCompound.addChain(newChain);
        }
      }
 catch (      StructureException e) {
        logger.error("String_Node_Str",e);
      }
    }
    newCompoundList.add(newCompound);
  }
  n.setCompounds(newCompoundList);
  for (  SSBond ssbond : ssbonds) {
    n.addSSBond(ssbond.clone());
  }
  return n;
}
Program: 16793
Project: 16793
Buggy source:
private void testChainRefs(Chain c){
  assertNotNull(c.getCompound());
  for (  Group g : c.getAtomGroups()) {
    assertSame("String_Node_Str" + g.toString(),c,g.getChain());
    for (    Atom a : g.getAtoms()) {
      assertSame(g,a.getGroup());
      assertSame(c,a.getGroup().getChain());
    }
    if (c.getSeqResGroups().size() > 0) {
      assertTrue("String_Node_Str" + g.toString(),containsReference(g,c.getSeqResGroups()));
    }
  }
  for (  Group g : c.getSeqResGroups()) {
    assertSame("String_Node_Str" + g.toString(),c,g.getChain());
    for (    Atom a : g.getAtoms()) {
      assertSame(g,a.getGroup());
      assertSame(c,a.getGroup().getChain());
    }
  }
}

Fixed version (ground truth):
private void testChainRefs(Chain c){
  assertNotNull(c.getCompound());
  for (  Group g : c.getAtomGroups()) {
    assertSame("String_Node_Str" + g.toString(),c,g.getChain());
    for (    Atom a : g.getAtoms()) {
      assertSame(g,a.getGroup());
      assertSame(c,a.getGroup().getChain());
    }
    if (c.getSeqResGroups().size() > 0) {
      if (g.getType() == GroupType.HETATM)       continue;
      assertTrue("String_Node_Str" + g.toString(),containsReference(g,c.getSeqResGroups()));
    }
  }
  for (  Group g : c.getSeqResGroups()) {
    assertSame("String_Node_Str" + g.toString(),c,g.getChain());
    for (    Atom a : g.getAtoms()) {
      assertSame(g,a.getGroup());
      assertSame(c,a.getGroup().getChain());
    }
  }
}
Program: 16794
Project: 16794
Buggy source:
@Test public void testCrossReferencesMmCif() throws IOException, StructureException {
  AtomCache cache=new AtomCache();
  cache.setUseMmCif(true);
  FileParsingParameters params=new FileParsingParameters();
  params.setAlignSeqRes(false);
  cache.setFileParsingParams(params);
  StructureIO.setAtomCache(cache);
  Structure structure=StructureIO.getStructure("String_Node_Str");
  System.out.println("String_Node_Str");
  doFullTest(structure);
}

Fixed version (ground truth):
@Test public void testCrossReferencesMmCif() throws IOException, StructureException {
  AtomCache cache=new AtomCache();
  cache.setUseMmCif(true);
  FileParsingParameters params=new FileParsingParameters();
  params.setAlignSeqRes(false);
  cache.setFileParsingParams(params);
  StructureIO.setAtomCache(cache);
  Structure structure=StructureIO.getStructure(PDBCODE1);
  System.out.println("String_Node_Str");
  doFullTest(structure);
  structure=StructureIO.getStructure(PDBCODE2);
  doFullTest(structure);
}
Program: 16795
Project: 16795
Buggy source:
@Test public void testCrossReferencesPdbAlignSeqRes() throws IOException, StructureException {
  AtomCache cache=new AtomCache();
  cache.setUseMmCif(false);
  FileParsingParameters params=new FileParsingParameters();
  params.setAlignSeqRes(true);
  cache.setFileParsingParams(params);
  StructureIO.setAtomCache(cache);
  System.out.println("String_Node_Str");
  Structure structure=StructureIO.getStructure("String_Node_Str");
  doFullTest(structure);
}

Fixed version (ground truth):
@Test public void testCrossReferencesPdbAlignSeqRes() throws IOException, StructureException {
  AtomCache cache=new AtomCache();
  cache.setUseMmCif(false);
  FileParsingParameters params=new FileParsingParameters();
  params.setAlignSeqRes(true);
  cache.setFileParsingParams(params);
  StructureIO.setAtomCache(cache);
  System.out.println("String_Node_Str");
  Structure structure=StructureIO.getStructure(PDBCODE1);
  doFullTest(structure);
  structure=StructureIO.getStructure(PDBCODE2);
  doFullTest(structure);
}
Program: 16796
Project: 16796
Buggy source:
@Test public void testCrossReferencesMmCifAlignSeqRes() throws IOException, StructureException {
  AtomCache cache=new AtomCache();
  cache.setUseMmCif(true);
  FileParsingParameters params=new FileParsingParameters();
  params.setAlignSeqRes(true);
  cache.setFileParsingParams(params);
  StructureIO.setAtomCache(cache);
  Structure structure=StructureIO.getStructure("String_Node_Str");
  System.out.println("String_Node_Str");
  doFullTest(structure);
}

Fixed version (ground truth):
@Test public void testCrossReferencesMmCifAlignSeqRes() throws IOException, StructureException {
  AtomCache cache=new AtomCache();
  cache.setUseMmCif(true);
  FileParsingParameters params=new FileParsingParameters();
  params.setAlignSeqRes(true);
  cache.setFileParsingParams(params);
  StructureIO.setAtomCache(cache);
  Structure structure=StructureIO.getStructure(PDBCODE1);
  System.out.println("String_Node_Str");
  doFullTest(structure);
  structure=StructureIO.getStructure(PDBCODE2);
  doFullTest(structure);
}
Program: 16797
Project: 16797
Buggy source:
@Test public void testCrossReferencesPdb() throws IOException, StructureException {
  AtomCache cache=new AtomCache();
  cache.setUseMmCif(false);
  FileParsingParameters params=new FileParsingParameters();
  params.setAlignSeqRes(false);
  cache.setFileParsingParams(params);
  StructureIO.setAtomCache(cache);
  Structure structure=StructureIO.getStructure("String_Node_Str");
  System.out.println("String_Node_Str");
  doFullTest(structure);
}

Fixed version (ground truth):
@Test public void testCrossReferencesPdb() throws IOException, StructureException {
  AtomCache cache=new AtomCache();
  cache.setUseMmCif(false);
  FileParsingParameters params=new FileParsingParameters();
  params.setAlignSeqRes(false);
  cache.setFileParsingParams(params);
  StructureIO.setAtomCache(cache);
  Structure structure=StructureIO.getStructure(PDBCODE1);
  System.out.println("String_Node_Str");
  doFullTest(structure);
  structure=StructureIO.getStructure(PDBCODE2);
  doFullTest(structure);
}
Program: 16798
Project: 16798
Buggy source:
private void testStructureRefs(Structure s) throws StructureException {
  for (  Chain c : s.getChains()) {
    logger.debug("String_Node_Str",System.identityHashCode(s));
    logger.debug("String_Node_Str",System.identityHashCode(c.getParent()));
    assertSame(s,c.getParent());
    testChainRefs(c);
  }
  for (  Compound compound : s.getCompounds()) {
    for (    Chain c : compound.getChains()) {
      assertSame(compound,c.getCompound());
      Chain cFromStruc=s.getChainByPDB(c.getChainID());
      assertSame(cFromStruc,c);
    }
  }
}

Fixed version (ground truth):
private void testStructureRefs(Structure s) throws StructureException {
  for (  Chain c : s.getChains()) {
    logger.debug("String_Node_Str",System.identityHashCode(s));
    logger.debug("String_Node_Str",System.identityHashCode(c.getParent()));
    assertSame(s,c.getParent());
    testChainRefs(c);
  }
  for (  Compound compound : s.getCompounds()) {
    for (    Chain c : compound.getChains()) {
      assertSame(compound,c.getCompound());
      int count=0;
      for (int modelNr=0; modelNr < s.nrModels(); modelNr++) {
        Chain cFromStruc=s.getChainByPDB(c.getChainID(),modelNr);
        if (cFromStruc == c)         count++;
      }
      assertEquals("String_Node_Str",1,count);
    }
  }
}
Program: 16799
Project: 16799
Buggy source:
/** 
 * Searches for previously downloaded files
 * @param pdbId
 * @return A file pointing to the existing file, or null if not found
 */
public File getLocalFile(String pdbId){
  LinkedList<File> searchdirs=new LinkedList<File>();
  String middle=pdbId.substring(1,3).toLowerCase();
  File splitdir=new File(splitDirPath,middle);
  searchdirs.add(splitdir);
  if (getObsoleteBehavior() == ObsoleteBehavior.FETCH_OBSOLETE) {
    File obsdir=new File(obsoleteDirPath,middle);
    searchdirs.add(obsdir);
  }
  String[] prefixes=new String[]{"String_Node_Str","String_Node_Str"};
  for (  File searchdir : searchdirs) {
    for (    String prefix : prefixes) {
      for (      String ex : getExtensions()) {
        File f=new File(searchdir,prefix + pdbId + ex);
        if (f.exists()) {
          return f;
        }
      }
    }
  }
  return null;
}

Fixed version (ground truth):
/** 
 * Searches for previously downloaded files
 * @param pdbId
 * @return A file pointing to the existing file, or null if not found
 */
public File getLocalFile(String pdbId){
  LinkedList<File> searchdirs=new LinkedList<File>();
  String middle=pdbId.substring(1,3).toLowerCase();
  File splitdir=new File(splitDirPath,middle);
  searchdirs.add(splitdir);
  if (getObsoleteBehavior() == ObsoleteBehavior.FETCH_OBSOLETE) {
    File obsdir=new File(obsoleteDirPath,middle);
    searchdirs.add(obsdir);
  }
  String[] prefixes=new String[]{"String_Node_Str","String_Node_Str"};
  for (  File searchdir : searchdirs) {
    for (    String prefix : prefixes) {
      for (      String ex : getExtensions()) {
        File f=new File(searchdir,prefix + pdbId.toLowerCase() + ex);
        if (f.exists()) {
          return f;
        }
      }
    }
  }
  return null;
}
Program: 16801
Project: 16801
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,isCrystallographic);
  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 (structure.getChains().size() == 0) {
    logger.warn("String_Node_Str");
    return set;
  }
  initialiseVisited();
  calcInterfacesCrystal(set,cutoff);
  return set;
}
Program: 16802
Project: 16802
Buggy source:
public CrystalBuilder(Structure structure){
  this.structure=structure;
  this.crystallographicInfo=structure.getCrystallographicInfo();
  this.numChainsAu=structure.getChains().size();
  this.numOperatorsSg=1;
  this.isCrystallographic=false;
  if (structure.isCrystallographic() && this.crystallographicInfo.getSpaceGroup() == null) {
    logger.warn("String_Node_Str");
  }
  if (structure.isCrystallographic() && this.crystallographicInfo.getSpaceGroup() != null) {
    this.numOperatorsSg=this.crystallographicInfo.getSpaceGroup().getMultiplicity();
    this.isCrystallographic=true;
  }
  this.numCells=DEF_NUM_CELLS;
}

Fixed version (ground truth):
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;
}