Program: 17090
Project: 17090
Buggy source:
/** 
 * aligns two chains of groups, where the first parent is representing the list of amino acids as obtained from the SEQRES records, and the second parent represents the groups obtained from the ATOM records (and containing the actual ATOM information). This does the actual alignment and if a group can be mapped to a position in the SEQRES then the corresponding position is repplaced with the group that contains the atoms.
 * @param seqRes
 * @param atomRes
 * @return true if no match has bee found
 * @throws StructureException
 */
public boolean align(List<Group> seqRes,List<Group> atomRes) throws StructureException {
  String seq1=getFullAtomSequence(seqRes);
  String seq2=getFullAtomSequence(atomRes);
  if (DEBUG) {
    System.out.println("String_Node_Str" + seq1);
    System.out.println("String_Node_Str" + seq2);
  }
  ProteinSequence s1=new ProteinSequence(seq1);
  ProteinSequence s2=new ProteinSequence(seq2);
  SubstitutionMatrix<AminoAcidCompound> matrix=SubstitutionMatrixHelper.getBlosum65();
  GapPenalty penalty=new SimpleGapPenalty();
  short gop=8;
  short extend=1;
  penalty.setOpenPenalty(gop);
  penalty.setExtensionPenalty(extend);
  PairwiseSequenceAligner<ProteinSequence,AminoAcidCompound> smithWaterman=Alignments.getPairwiseAligner(s1,s2,PairwiseSequenceAlignerType.LOCAL,penalty,matrix);
  SequencePair<ProteinSequence,AminoAcidCompound> pair=smithWaterman.getPair();
  if (pair == null)   throw new StructureException("String_Node_Str");
  if (DEBUG) {
    System.out.println(pair.toString(60));
  }
  boolean noMatchFound=mapChains(seqRes,atomRes,pair);
  return noMatchFound;
}

Fixed version (ground truth):
/** 
 * aligns two chains of groups, where the first parent is representing the list of amino acids as obtained from the SEQRES records, and the second parent represents the groups obtained from the ATOM records (and containing the actual ATOM information). This does the actual alignment and if a group can be mapped to a position in the SEQRES then the corresponding position is repplaced with the group that contains the atoms.
 * @param seqRes
 * @param atomRes
 * @return true if no match has bee found
 * @throws StructureException
 */
public boolean align(List<Group> seqRes,List<Group> atomRes) throws StructureException {
  Map<Integer,Integer> seqresIndexPosition=new HashMap<Integer,Integer>();
  Map<Integer,Integer> atomIndexPosition=new HashMap<Integer,Integer>();
  String seq1=getFullAtomSequence(seqRes,seqresIndexPosition);
  String seq2=getFullAtomSequence(atomRes,atomIndexPosition);
  if (DEBUG) {
    System.out.println("String_Node_Str" + seq1.length() + "String_Node_Str"+ seq1);
    System.out.println("String_Node_Str" + seq2.length() + "String_Node_Str"+ seq2);
  }
  ProteinSequence s1=new ProteinSequence(seq1);
  ProteinSequence s2=new ProteinSequence(seq2);
  SubstitutionMatrix<AminoAcidCompound> matrix=SubstitutionMatrixHelper.getBlosum65();
  GapPenalty penalty=new SimpleGapPenalty();
  short gop=8;
  short extend=1;
  penalty.setOpenPenalty(gop);
  penalty.setExtensionPenalty(extend);
  PairwiseSequenceAligner<ProteinSequence,AminoAcidCompound> smithWaterman=Alignments.getPairwiseAligner(s1,s2,PairwiseSequenceAlignerType.LOCAL,penalty,matrix);
  SequencePair<ProteinSequence,AminoAcidCompound> pair=smithWaterman.getPair();
  if (pair == null)   throw new StructureException("String_Node_Str");
  if (DEBUG) {
    System.out.println(pair.toString(60));
  }
  boolean noMatchFound=mapChains(seqRes,atomRes,pair,seqresIndexPosition,atomIndexPosition);
  return noMatchFound;
}