Program: 16812
Project: 16812
Buggy source:
@Override public void documentEnd(){
  if (current_chain != null) {
    current_chain.addGroup(current_group);
    if (isKnownChain(current_chain.getChainID(),current_model) == null) {
      current_model.add(current_chain);
    }
  }
 else {
    logger.warn("String_Node_Str");
  }
  structure.addModel(current_model);
  for (  StructAsym asym : structAsyms) {
    logger.debug("String_Node_Str",asym.getEntity_id(),asym.getId());
    asymId2entityId.put(asym.getId(),asym.getEntity_id());
    Chain s=getEntityChain(asym.getEntity_id());
    Chain seqres=(Chain)s.clone();
    seqres=removeSeqResHeterogeneity(seqres);
    seqres.setChainID(asym.getId());
    seqResChains.add(seqres);
    logger.debug("String_Node_Str" + asym.getId() + "String_Node_Str"+ seqres+ "String_Node_Str");
    int eId=0;
    try {
      eId=Integer.parseInt(asym.getEntity_id());
    }
 catch (    NumberFormatException e) {
      logger.warn("String_Node_Str",asym.getEntity_id());
    }
    Entity e=getEntity(eId);
    for (    EntitySrcGen esg : entitySrcGens) {
      if (!esg.getEntity_id().equals(asym.getEntity_id()))       continue;
      Compound c=structure.getCompoundById(eId);
      if (c == null) {
        if (e != null && e.getType().equals("String_Node_Str")) {
          c=createNewCompoundFromESG(esg,eId);
          c.setMolName(e.getPdbx_description());
          structure.addCompound(c);
          logger.debug("String_Node_Str",eId,c.getMolName());
        }
      }
    }
    for (    EntitySrcNat esn : entitySrcNats) {
      if (!esn.getEntity_id().equals(asym.getEntity_id()))       continue;
      Compound c=structure.getCompoundById(eId);
      if (c == null) {
        if (e != null && e.getType().equals("String_Node_Str")) {
          c=createNewCompoundFromESN(esn,eId);
          c.setMolName(e.getPdbx_description());
          structure.addCompound(c);
          logger.debug("String_Node_Str",eId,c.getMolName());
        }
      }
    }
    for (    EntitySrcSyn ess : entitySrcSyns) {
      if (!ess.getEntity_id().equals(asym.getEntity_id()))       continue;
      Compound c=structure.getCompoundById(eId);
      if (c == null) {
        if (e != null && e.getType().equals("String_Node_Str")) {
          c=createNewCompoundFromESS(ess,eId);
          c.setMolName(e.getPdbx_description());
          structure.addCompound(c);
          logger.debug("String_Node_Str",eId,c.getMolName());
        }
      }
    }
    Compound c=structure.getCompoundById(eId);
    if (c == null) {
      c=new Compound();
      c.setMolId(eId);
      if (e != null && e.getType().equals("String_Node_Str")) {
        c.setMolName(e.getPdbx_description());
        structure.addCompound(c);
        logger.debug("String_Node_Str",eId,c.getMolName());
      }
    }
  }
  if (params.isAlignSeqRes()) {
    List<Chain> atomList=structure.getModel(0);
    for (    Chain seqResChain : seqResChains) {
      Chain atomChain=SeqRes2AtomAligner.getMatchingAtomRes(seqResChain,atomList);
      List<Group> seqResGroups=seqResChain.getAtomGroups();
      for (int seqResPos=0; seqResPos < seqResGroups.size(); seqResPos++) {
        Group seqresG=seqResGroups.get(seqResPos);
        boolean found=false;
        for (        Group atomG : atomChain.getAtomGroups()) {
          int internalNr=getInternalNr(atomG);
          if (seqresG.getResidueNumber().getSeqNum() == internalNr) {
            seqResGroups.set(seqResPos,atomG);
            found=true;
            break;
          }
        }
        if (!found)         seqresG.setResidueNumber(null);
      }
      atomChain.setSeqResGroups(seqResGroups);
    }
  }
  if (params.shouldCreateAtomBonds())   addBonds();
  Set<String> asymIds=asymStrandId.keySet();
  for (int i=0; i < structure.nrModels(); i++) {
    List<Chain> model=structure.getModel(i);
    List<Chain> pdbChains=new ArrayList<Chain>();
    for (    Chain chain : model) {
      for (      String asym : asymIds) {
        if (chain.getChainID().equals(asym)) {
          String newChainId=asymStrandId.get(asym);
          logger.debug("String_Node_Str",asym,chain.getAtomGroups().size(),newChainId);
          chain.setChainID(newChainId);
          chain.setInternalChainID(asym);
          for (          Group g : chain.getAtomGroups()) {
            ResidueNumber resNum=g.getResidueNumber();
            if (resNum != null)             resNum.setChainId(newChainId);
          }
          for (          Group g : chain.getSeqResGroups()) {
            ResidueNumber resNum=g.getResidueNumber();
            if (resNum != null)             resNum.setChainId(newChainId);
          }
          Chain known=isKnownChain(chain.getChainID(),pdbChains);
          if (known == null) {
            pdbChains.add(chain);
          }
 else {
            for (            Group g : chain.getAtomGroups()) {
              known.addGroup(g);
            }
          }
          break;
        }
      }
    }
    Iterator<Chain> it=pdbChains.iterator();
    while (it.hasNext()) {
      Chain c=it.next();
      if (StructureTools.isChainWaterOnly(c)) {
        logger.warn("String_Node_Str",c.getChainID(),c.getInternalChainID(),c.getAtomGroups().size());
        it.remove();
      }
    }
    structure.setModel(i,pdbChains);
    for (    Chain chain : pdbChains) {
      String entityId=asymId2entityId.get(chain.getInternalChainID());
      int eId=Integer.parseInt(entityId);
      Compound compound=structure.getCompoundById(eId);
      if (compound == null) {
        logger.warn("String_Node_Str",eId,chain.getChainID(),chain.getInternalChainID());
      }
 else {
        logger.debug("String_Node_Str",chain.getChainID(),chain.getInternalChainID(),eId);
        compound.addChain(chain);
        chain.setCompound(compound);
      }
    }
  }
  List<Compound> compounds=structure.getCompounds();
  for (  Compound compound : compounds) {
    if (compound.getChains().isEmpty()) {
      logger.info("String_Node_Str",compound.getId() == null ? "String_Node_Str" : compound.getId(),compound.getMolName());
    }
  }
  if (params.isParseBioAssembly()) {
    Map<Integer,BioAssemblyInfo> bioAssemblies=new HashMap<Integer,BioAssemblyInfo>();
    for (    PdbxStructAssembly psa : strucAssemblies) {
      List<PdbxStructAssemblyGen> psags=new ArrayList<PdbxStructAssemblyGen>(1);
      for (      PdbxStructAssemblyGen psag : strucAssemblyGens) {
        if (psag.getAssembly_id().equals(psa.getId())) {
          psags.add(psag);
        }
      }
      BiologicalAssemblyBuilder builder=new BiologicalAssemblyBuilder();
      List<BiologicalAssemblyTransformation> transformations=builder.getBioUnitTransformationList(psa,psags,structOpers);
      int mmSize=0;
      int bioAssemblyId=-1;
      try {
        bioAssemblyId=Integer.parseInt(psa.getId());
      }
 catch (      NumberFormatException e) {
        logger.info("String_Node_Str",psa.getId());
      }
      try {
        mmSize=Integer.parseInt(psa.getOligomeric_count());
      }
 catch (      NumberFormatException e) {
        if (bioAssemblyId != -1)         logger.warn("String_Node_Str",psa.getOligomeric_count(),psa.getId());
 else         logger.info("String_Node_Str",psa.getOligomeric_count(),psa.getId());
      }
      if (bioAssemblyId != -1) {
        BioAssemblyInfo bioAssembly=new BioAssemblyInfo();
        bioAssembly.setId(bioAssemblyId);
        bioAssembly.setMacromolecularSize(mmSize);
        bioAssembly.setTransforms(transformations);
        bioAssemblies.put(bioAssemblyId,bioAssembly);
      }
    }
    structure.getPDBHeader().setBioAssemblies(bioAssemblies);
  }
  ArrayList<Matrix4d> ncsOperators=new ArrayList<Matrix4d>();
  for (  StructNcsOper sNcsOper : structNcsOper) {
    if (sNcsOper.getCode().equals("String_Node_Str")) {
      ncsOperators.add(sNcsOper.getOperator());
    }
  }
  if (ncsOperators.size() > 0) {
    structure.getCrystallographicInfo().setNcsOperators(ncsOperators.toArray(new Matrix4d[ncsOperators.size()]));
  }
}

Fixed version (ground truth):
@Override public void documentEnd(){
  if (current_chain != null) {
    current_chain.addGroup(current_group);
    if (isKnownChain(current_chain.getChainID(),current_model) == null) {
      current_model.add(current_chain);
    }
  }
 else {
    logger.warn("String_Node_Str");
  }
  structure.addModel(current_model);
  for (  StructAsym asym : structAsyms) {
    logger.debug("String_Node_Str",asym.getEntity_id(),asym.getId());
    asymId2entityId.put(asym.getId(),asym.getEntity_id());
    Chain s=getEntityChain(asym.getEntity_id());
    Chain seqres=(Chain)s.clone();
    seqres=removeSeqResHeterogeneity(seqres);
    seqres.setChainID(asym.getId());
    seqResChains.add(seqres);
    logger.debug("String_Node_Str" + asym.getId() + "String_Node_Str"+ seqres+ "String_Node_Str");
    int eId=0;
    try {
      eId=Integer.parseInt(asym.getEntity_id());
    }
 catch (    NumberFormatException e) {
      logger.warn("String_Node_Str",asym.getEntity_id());
    }
    Entity e=getEntity(eId);
    for (    EntitySrcGen esg : entitySrcGens) {
      if (!esg.getEntity_id().equals(asym.getEntity_id()))       continue;
      Compound c=structure.getCompoundById(eId);
      if (c == null) {
        if (e != null && e.getType().equals("String_Node_Str")) {
          c=createNewCompoundFromESG(esg,eId);
          c.setMolName(e.getPdbx_description());
          structure.addCompound(c);
          logger.debug("String_Node_Str",eId,c.getMolName());
        }
      }
    }
    for (    EntitySrcNat esn : entitySrcNats) {
      if (!esn.getEntity_id().equals(asym.getEntity_id()))       continue;
      Compound c=structure.getCompoundById(eId);
      if (c == null) {
        if (e != null && e.getType().equals("String_Node_Str")) {
          c=createNewCompoundFromESN(esn,eId);
          c.setMolName(e.getPdbx_description());
          structure.addCompound(c);
          logger.debug("String_Node_Str",eId,c.getMolName());
        }
      }
    }
    for (    EntitySrcSyn ess : entitySrcSyns) {
      if (!ess.getEntity_id().equals(asym.getEntity_id()))       continue;
      Compound c=structure.getCompoundById(eId);
      if (c == null) {
        if (e != null && e.getType().equals("String_Node_Str")) {
          c=createNewCompoundFromESS(ess,eId);
          c.setMolName(e.getPdbx_description());
          structure.addCompound(c);
          logger.debug("String_Node_Str",eId,c.getMolName());
        }
      }
    }
    Compound c=structure.getCompoundById(eId);
    if (c == null) {
      c=new Compound();
      c.setMolId(eId);
      if (e != null && e.getType().equals("String_Node_Str")) {
        c.setMolName(e.getPdbx_description());
        structure.addCompound(c);
        logger.debug("String_Node_Str",eId,c.getMolName());
      }
    }
  }
  if (params.isAlignSeqRes()) {
    List<Chain> atomList=structure.getModel(0);
    for (    Chain seqResChain : seqResChains) {
      Chain atomChain=SeqRes2AtomAligner.getMatchingAtomRes(seqResChain,atomList);
      if (atomChain == null) {
        logger.warn("String_Node_Str",seqResChain.getChainID());
        continue;
      }
      List<Group> seqResGroups=seqResChain.getAtomGroups();
      for (int seqResPos=0; seqResPos < seqResGroups.size(); seqResPos++) {
        Group seqresG=seqResGroups.get(seqResPos);
        boolean found=false;
        for (        Group atomG : atomChain.getAtomGroups()) {
          int internalNr=getInternalNr(atomG);
          if (seqresG.getResidueNumber().getSeqNum() == internalNr) {
            seqResGroups.set(seqResPos,atomG);
            found=true;
            break;
          }
        }
        if (!found)         seqresG.setResidueNumber(null);
      }
      atomChain.setSeqResGroups(seqResGroups);
    }
  }
  if (params.shouldCreateAtomBonds())   addBonds();
  Set<String> asymIds=asymStrandId.keySet();
  for (int i=0; i < structure.nrModels(); i++) {
    List<Chain> model=structure.getModel(i);
    List<Chain> pdbChains=new ArrayList<Chain>();
    for (    Chain chain : model) {
      for (      String asym : asymIds) {
        if (chain.getChainID().equals(asym)) {
          String newChainId=asymStrandId.get(asym);
          logger.debug("String_Node_Str",asym,chain.getAtomGroups().size(),newChainId);
          chain.setChainID(newChainId);
          chain.setInternalChainID(asym);
          for (          Group g : chain.getAtomGroups()) {
            ResidueNumber resNum=g.getResidueNumber();
            if (resNum != null)             resNum.setChainId(newChainId);
          }
          for (          Group g : chain.getSeqResGroups()) {
            ResidueNumber resNum=g.getResidueNumber();
            if (resNum != null)             resNum.setChainId(newChainId);
          }
          Chain known=isKnownChain(chain.getChainID(),pdbChains);
          if (known == null) {
            pdbChains.add(chain);
          }
 else {
            for (            Group g : chain.getAtomGroups()) {
              known.addGroup(g);
            }
          }
          break;
        }
      }
    }
    Iterator<Chain> it=pdbChains.iterator();
    while (it.hasNext()) {
      Chain c=it.next();
      if (StructureTools.isChainWaterOnly(c)) {
        logger.warn("String_Node_Str",c.getChainID(),c.getInternalChainID(),c.getAtomGroups().size());
        it.remove();
      }
    }
    structure.setModel(i,pdbChains);
    for (    Chain chain : pdbChains) {
      String entityId=asymId2entityId.get(chain.getInternalChainID());
      int eId=Integer.parseInt(entityId);
      Compound compound=structure.getCompoundById(eId);
      if (compound == null) {
        logger.warn("String_Node_Str",eId,chain.getChainID(),chain.getInternalChainID());
      }
 else {
        logger.debug("String_Node_Str",chain.getChainID(),chain.getInternalChainID(),eId);
        compound.addChain(chain);
        chain.setCompound(compound);
      }
    }
  }
  List<Compound> compounds=structure.getCompounds();
  for (  Compound compound : compounds) {
    if (compound.getChains().isEmpty()) {
      logger.info("String_Node_Str",compound.getId() == null ? "String_Node_Str" : compound.getId(),compound.getMolName());
    }
  }
  if (params.isParseBioAssembly()) {
    Map<Integer,BioAssemblyInfo> bioAssemblies=new HashMap<Integer,BioAssemblyInfo>();
    for (    PdbxStructAssembly psa : strucAssemblies) {
      List<PdbxStructAssemblyGen> psags=new ArrayList<PdbxStructAssemblyGen>(1);
      for (      PdbxStructAssemblyGen psag : strucAssemblyGens) {
        if (psag.getAssembly_id().equals(psa.getId())) {
          psags.add(psag);
        }
      }
      BiologicalAssemblyBuilder builder=new BiologicalAssemblyBuilder();
      List<BiologicalAssemblyTransformation> transformations=builder.getBioUnitTransformationList(psa,psags,structOpers);
      int mmSize=0;
      int bioAssemblyId=-1;
      try {
        bioAssemblyId=Integer.parseInt(psa.getId());
      }
 catch (      NumberFormatException e) {
        logger.info("String_Node_Str",psa.getId());
      }
      try {
        mmSize=Integer.parseInt(psa.getOligomeric_count());
      }
 catch (      NumberFormatException e) {
        if (bioAssemblyId != -1)         logger.warn("String_Node_Str",psa.getOligomeric_count(),psa.getId());
 else         logger.info("String_Node_Str",psa.getOligomeric_count(),psa.getId());
      }
      if (bioAssemblyId != -1) {
        BioAssemblyInfo bioAssembly=new BioAssemblyInfo();
        bioAssembly.setId(bioAssemblyId);
        bioAssembly.setMacromolecularSize(mmSize);
        bioAssembly.setTransforms(transformations);
        bioAssemblies.put(bioAssemblyId,bioAssembly);
      }
    }
    structure.getPDBHeader().setBioAssemblies(bioAssemblies);
  }
  ArrayList<Matrix4d> ncsOperators=new ArrayList<Matrix4d>();
  for (  StructNcsOper sNcsOper : structNcsOper) {
    if (sNcsOper.getCode().equals("String_Node_Str")) {
      ncsOperators.add(sNcsOper.getOperator());
    }
  }
  if (ncsOperators.size() > 0) {
    structure.getCrystallographicInfo().setNcsOperators(ncsOperators.toArray(new Matrix4d[ncsOperators.size()]));
  }
}