Program: 17096
Project: 17096
Buggy source:
static public LinkedHashMap<String,ChromosomeSequence> loadFastaAddGeneFeaturesFromUpperCaseExonFastaFile(File fastaSequenceFile,File uppercaseFastaFile,boolean throwExceptionGeneNotFound) throws Exception {
  LinkedHashMap<String,ChromosomeSequence> chromosomeSequenceList=new LinkedHashMap<String,ChromosomeSequence>();
  LinkedHashMap<String,DNASequence> dnaSequenceList=FastaReaderHelper.readFastaDNASequence(fastaSequenceFile);
  for (  String accession : dnaSequenceList.keySet()) {
    DNASequence contigSequence=dnaSequenceList.get(accession);
    ChromosomeSequence chromsomeSequence=new ChromosomeSequence(contigSequence.getSequenceAsString());
    chromsomeSequence.setAccession(contigSequence.getAccession());
    chromosomeSequenceList.put(accession,chromsomeSequence);
  }
  LinkedHashMap<String,DNASequence> geneSequenceList=FastaReaderHelper.readFastaDNASequence(uppercaseFastaFile);
  for (  DNASequence dnaSequence : geneSequenceList.values()) {
    String geneSequence=dnaSequence.getSequenceAsString();
    String lcGeneSequence=geneSequence.toLowerCase();
    String reverseGeneSequence=dnaSequence.getReverse().getSequenceAsString();
    String lcReverseGeneSequence=reverseGeneSequence.toLowerCase();
    Integer bioStart=null;
    Integer bioEnd=null;
    Strand strand=Strand.POSITIVE;
    boolean geneFound=false;
    String accession="String_Node_Str";
    for (    String id : dnaSequenceList.keySet()) {
      accession=id;
      DNASequence contigDNASequence=dnaSequenceList.get(id);
      String contigSequence=contigDNASequence.getSequenceAsString().toLowerCase();
      bioStart=contigSequence.indexOf(lcGeneSequence);
      if (bioStart != -1) {
        bioStart=bioStart + 1;
        bioEnd=bioStart + geneSequence.length();
        geneFound=true;
        break;
      }
 else {
        bioStart=contigSequence.indexOf(lcReverseGeneSequence);
        if (bioStart != -1) {
          bioStart=bioStart + 1;
          bioEnd=bioStart - geneSequence.length();
          strand=Strand.NEGATIVE;
          geneFound=true;
          break;
        }
      }
    }
    if (geneFound) {
      System.out.println("String_Node_Str" + bioStart + "String_Node_Str"+ bioEnd);
      ChromosomeSequence chromosomeSequence=chromosomeSequenceList.get(accession);
      GeneSequence geneSeq=chromosomeSequence.addGene(dnaSequence.getAccession(),bioStart,bioEnd,strand);
      geneSeq.setSource(uppercaseFastaFile.getName());
      String transcriptName=dnaSequence.getAccession().getID() + "String_Node_Str";
      TranscriptSequence transcriptSequence=geneSeq.addTranscript(new AccessionID(transcriptName),bioStart,bioEnd);
      ArrayList<Integer> exonBoundries=new ArrayList<Integer>();
      for (int i=0; i < geneSequence.length(); i++) {
        if (i == 0 && Character.isUpperCase(geneSequence.charAt(i))) {
          exonBoundries.add(i);
        }
 else         if (i == geneSequence.length() - 1) {
          exonBoundries.add(i);
        }
 else         if (Character.isUpperCase(geneSequence.charAt(i)) && Character.isLowerCase(geneSequence.charAt(i - 1))) {
          exonBoundries.add(i);
        }
 else         if (Character.isUpperCase(geneSequence.charAt(i)) && Character.isLowerCase(geneSequence.charAt(i + 1))) {
          exonBoundries.add(i);
        }
      }
      if (strand == Strand.NEGATIVE) {
        Collections.reverse(exonBoundries);
      }
      int runningFrameLength=0;
      for (int i=0; i < exonBoundries.size(); i=i + 2) {
        int cdsBioStart=exonBoundries.get(i) + bioStart;
        int cdsBioEnd=exonBoundries.get(i + 1) + bioStart;
        runningFrameLength=runningFrameLength + Math.abs(cdsBioEnd - cdsBioStart) + 1;
        String cdsName=transcriptName + "String_Node_Str" + cdsBioStart+ "String_Node_Str"+ cdsBioEnd;
        AccessionID cdsAccessionID=new AccessionID(cdsName);
        ExonSequence exonSequence=geneSeq.addExon(cdsAccessionID,cdsBioStart,cdsBioEnd);
        int remainder=runningFrameLength % 3;
        int frame=0;
        if (remainder == 1) {
          frame=2;
        }
 else         if (remainder == 2) {
          frame=1;
        }
        CDSSequence cdsSequence=transcriptSequence.addCDS(cdsAccessionID,cdsBioStart,cdsBioEnd,frame);
      }
    }
 else {
      if (throwExceptionGeneNotFound) {
        throw new Exception(dnaSequence.getAccession().toString() + "String_Node_Str");
      }
    }
  }
  return chromosomeSequenceList;
}

Fixed version (ground truth):
static public LinkedHashMap<String,ChromosomeSequence> loadFastaAddGeneFeaturesFromUpperCaseExonFastaFile(File fastaSequenceFile,File uppercaseFastaFile,boolean throwExceptionGeneNotFound) throws Exception {
  LinkedHashMap<String,ChromosomeSequence> chromosomeSequenceList=new LinkedHashMap<String,ChromosomeSequence>();
  LinkedHashMap<String,DNASequence> dnaSequenceList=FastaReaderHelper.readFastaDNASequence(fastaSequenceFile);
  for (  String accession : dnaSequenceList.keySet()) {
    DNASequence contigSequence=dnaSequenceList.get(accession);
    ChromosomeSequence chromsomeSequence=new ChromosomeSequence(contigSequence.getSequenceAsString());
    chromsomeSequence.setAccession(contigSequence.getAccession());
    chromosomeSequenceList.put(accession,chromsomeSequence);
  }
  LinkedHashMap<String,DNASequence> geneSequenceList=FastaReaderHelper.readFastaDNASequence(uppercaseFastaFile);
  for (  DNASequence dnaSequence : geneSequenceList.values()) {
    String geneSequence=dnaSequence.getSequenceAsString();
    String lcGeneSequence=geneSequence.toLowerCase();
    String reverseGeneSequence=dnaSequence.getReverse().getSequenceAsString();
    String lcReverseGeneSequence=reverseGeneSequence.toLowerCase();
    Integer bioStart=null;
    Integer bioEnd=null;
    Strand strand=Strand.POSITIVE;
    boolean geneFound=false;
    String accession="String_Node_Str";
    for (    String id : dnaSequenceList.keySet()) {
      accession=id;
      DNASequence contigDNASequence=dnaSequenceList.get(id);
      String contigSequence=contigDNASequence.getSequenceAsString().toLowerCase();
      bioStart=contigSequence.indexOf(lcGeneSequence);
      if (bioStart != -1) {
        bioStart=bioStart + 1;
        bioEnd=bioStart + geneSequence.length() - 1;
        geneFound=true;
        break;
      }
 else {
        bioStart=contigSequence.indexOf(lcReverseGeneSequence);
        if (bioStart != -1) {
          bioStart=bioStart + 1;
          bioEnd=bioStart - geneSequence.length() - 1;
          strand=Strand.NEGATIVE;
          geneFound=true;
          break;
        }
      }
    }
    if (geneFound) {
      System.out.println("String_Node_Str" + bioStart + "String_Node_Str"+ bioEnd);
      ChromosomeSequence chromosomeSequence=chromosomeSequenceList.get(accession);
      ArrayList<Integer> exonBoundries=new ArrayList<Integer>();
      for (int i=0; i < geneSequence.length(); i++) {
        if (i == 0 && Character.isUpperCase(geneSequence.charAt(i))) {
          exonBoundries.add(i);
        }
 else         if (i == geneSequence.length() - 1) {
          exonBoundries.add(i);
        }
 else         if (Character.isUpperCase(geneSequence.charAt(i)) && Character.isLowerCase(geneSequence.charAt(i - 1))) {
          exonBoundries.add(i);
        }
 else         if (Character.isUpperCase(geneSequence.charAt(i)) && Character.isLowerCase(geneSequence.charAt(i + 1))) {
          exonBoundries.add(i);
        }
      }
      if (strand == Strand.NEGATIVE) {
        Collections.reverse(exonBoundries);
      }
      GeneSequence geneSeq=chromosomeSequence.addGene(dnaSequence.getAccession(),bioStart,bioEnd,strand);
      geneSeq.setSource(uppercaseFastaFile.getName());
      String transcriptName=dnaSequence.getAccession().getID() + "String_Node_Str";
      TranscriptSequence transcriptSequence=geneSeq.addTranscript(new AccessionID(transcriptName),bioStart,bioEnd);
      int runningFrameLength=0;
      for (int i=0; i < exonBoundries.size() - 1; i=i + 2) {
        int cdsBioStart=exonBoundries.get(i) + bioStart;
        int cdsBioEnd=exonBoundries.get(i + 1) + bioStart;
        runningFrameLength=runningFrameLength + Math.abs(cdsBioEnd - cdsBioStart) + 1;
        String cdsName=transcriptName + "String_Node_Str" + cdsBioStart+ "String_Node_Str"+ cdsBioEnd;
        AccessionID cdsAccessionID=new AccessionID(cdsName);
        ExonSequence exonSequence=geneSeq.addExon(cdsAccessionID,cdsBioStart,cdsBioEnd);
        int remainder=runningFrameLength % 3;
        int frame=0;
        if (remainder == 1) {
          frame=2;
        }
 else         if (remainder == 2) {
          frame=1;
        }
        CDSSequence cdsSequence=transcriptSequence.addCDS(cdsAccessionID,cdsBioStart,cdsBioEnd,frame);
      }
    }
 else {
      if (throwExceptionGeneNotFound) {
        throw new Exception(dnaSequence.getAccession().toString() + "String_Node_Str");
      }
    }
  }
  return chromosomeSequenceList;
}