Program: 17095
Project: 17095
Buggy source:
static public void addGmodGFF3GeneFeatures(LinkedHashMap<String,ChromosomeSequence> chromosomeSequenceList,FeatureList listGenes) throws Exception {
  FeatureList mRNAFeatures=listGenes.selectByType("String_Node_Str");
  for (  FeatureI f : mRNAFeatures) {
    Feature mRNAFeature=(Feature)f;
    String geneid=mRNAFeature.getAttribute("String_Node_Str");
    String source=mRNAFeature.source();
    FeatureList gene=listGenes.selectByAttribute("String_Node_Str",geneid);
    FeatureI geneFeature=gene.get(0);
    ChromosomeSequence seq=chromosomeSequenceList.get(geneFeature.seqname());
    AccessionID geneAccessionID=new AccessionID(geneid);
    GeneSequence geneSequence=null;
    FeatureList cdsFeatures=gene.selectByType("String_Node_Str");
    FeatureI feature=cdsFeatures.get(0);
    Strand strand=Strand.POSITIVE;
    if (feature.location().isNegative()) {
      strand=strand.NEGATIVE;
    }
    cdsFeatures=cdsFeatures.sortByStart();
    String seqName=feature.seqname();
    FeatureI startCodon=null;
    FeatureI stopCodon=null;
    Integer startCodonBegin=null;
    Integer stopCodonEnd=null;
    String startCodonName="String_Node_Str";
    String stopCodonName="String_Node_Str";
    FeatureList startCodonList=gene.selectByAttribute("String_Node_Str","String_Node_Str");
    if (startCodonList != null && startCodonList.size() > 0) {
      startCodon=startCodonList.get(0);
      if (strand == Strand.NEGATIVE) {
        startCodonBegin=startCodon.location().bioEnd();
      }
 else {
        startCodonBegin=startCodon.location().bioStart();
      }
      startCodonName=startCodon.getAttribute("String_Node_Str");
    }
    FeatureList stopCodonList=gene.selectByAttribute("String_Node_Str","String_Node_Str");
    if (stopCodonList != null && stopCodonList.size() > 0) {
      stopCodon=stopCodonList.get(0);
      if (strand == Strand.NEGATIVE) {
        stopCodonEnd=stopCodon.location().bioStart();
      }
 else {
        stopCodonEnd=stopCodon.location().bioEnd();
      }
      stopCodonName=stopCodon.getAttribute("String_Node_Str");
    }
    if (startCodonBegin == null) {
      if (strand == Strand.NEGATIVE) {
        FeatureI firstFeature=cdsFeatures.get(0);
        startCodonBegin=firstFeature.location().bioEnd();
      }
 else {
        FeatureI firstFeature=cdsFeatures.get(0);
        startCodonBegin=firstFeature.location().bioStart();
      }
    }
    if (stopCodonEnd == null) {
      if (strand == Strand.NEGATIVE) {
        FeatureI lastFeature=cdsFeatures.get(cdsFeatures.size() - 1);
        stopCodonEnd=lastFeature.location().bioStart();
      }
 else {
        FeatureI lastFeature=cdsFeatures.get(cdsFeatures.size() - 1);
        stopCodonEnd=lastFeature.location().bioEnd();
      }
    }
    if (startCodonBegin > stopCodonEnd) {
      int temp=startCodonBegin;
      startCodonBegin=stopCodonEnd;
      stopCodonEnd=temp;
    }
    AccessionID transcriptAccessionID=new AccessionID(geneid);
    if (geneSequence == null) {
      geneSequence=seq.addGene(geneAccessionID,startCodonBegin,stopCodonEnd,strand);
      geneSequence.setSource(source);
    }
 else {
      if (startCodonBegin < geneSequence.getBioBegin()) {
        geneSequence.setBioBegin(startCodonBegin);
      }
      if (stopCodonEnd > geneSequence.getBioBegin()) {
        geneSequence.setBioEnd(stopCodonEnd);
      }
    }
    TranscriptSequence transcriptSequence=geneSequence.addTranscript(transcriptAccessionID,startCodonBegin,stopCodonEnd);
    if (startCodon != null) {
      if (startCodonName == null || startCodonName.length() == 0) {
        startCodonName=geneid + "String_Node_Str" + startCodon.location().bioStart()+ "String_Node_Str"+ startCodon.location().bioEnd();
      }
      transcriptSequence.addStartCodonSequence(new AccessionID(startCodonName),startCodon.location().bioStart(),startCodon.location().bioEnd());
    }
    if (stopCodon != null) {
      if (stopCodonName == null || stopCodonName.length() == 0) {
        stopCodonName=geneid + "String_Node_Str" + stopCodon.location().bioStart()+ "String_Node_Str"+ stopCodon.location().bioEnd();
      }
      transcriptSequence.addStopCodonSequence(new AccessionID(stopCodonName),stopCodon.location().bioStart(),stopCodon.location().bioEnd());
    }
    for (    FeatureI cdsFeature : cdsFeatures) {
      Feature cds=(Feature)cdsFeature;
      String cdsName=cds.getAttribute("String_Node_Str");
      if (cdsName == null || cdsName.length() == 0) {
        cdsName=geneid + "String_Node_Str" + cds.location().bioStart()+ "String_Node_Str"+ cds.location().bioEnd();
      }
      AccessionID cdsAccessionID=new AccessionID(cdsName);
      ExonSequence exonSequence=geneSequence.addExon(cdsAccessionID,cdsFeature.location().bioStart(),cdsFeature.location().bioEnd());
      transcriptSequence.addCDS(cdsAccessionID,cdsFeature.location().bioStart(),cdsFeature.location().bioEnd(),cds.frame());
    }
  }
}

Fixed version (ground truth):
static public void addGmodGFF3GeneFeatures(LinkedHashMap<String,ChromosomeSequence> chromosomeSequenceList,FeatureList listGenes) throws Exception {
  FeatureList mRNAFeatures=listGenes.selectByType("String_Node_Str");
  for (  FeatureI f : mRNAFeatures) {
    Feature mRNAFeature=(Feature)f;
    String geneid=mRNAFeature.getAttribute("String_Node_Str");
    String source=mRNAFeature.source();
    FeatureList gene=listGenes.selectByAttribute("String_Node_Str",geneid);
    FeatureI geneFeature=gene.get(0);
    ChromosomeSequence seq=chromosomeSequenceList.get(geneFeature.seqname());
    AccessionID geneAccessionID=new AccessionID(geneid);
    GeneSequence geneSequence=null;
    FeatureList cdsFeatures=gene.selectByType("String_Node_Str");
    FeatureI feature=cdsFeatures.get(0);
    Strand strand=Strand.POSITIVE;
    if (feature.location().isNegative()) {
      strand=strand.NEGATIVE;
    }
    cdsFeatures=cdsFeatures.sortByStart();
    String seqName=feature.seqname();
    FeatureI startCodon=null;
    FeatureI stopCodon=null;
    Integer startCodonBegin=null;
    Integer stopCodonEnd=null;
    String startCodonName="String_Node_Str";
    String stopCodonName="String_Node_Str";
    FeatureList startCodonList=gene.selectByType("String_Node_Str");
    if (startCodonList != null && startCodonList.size() > 0) {
      startCodon=startCodonList.get(0);
      if (strand == Strand.NEGATIVE) {
        startCodonBegin=startCodon.location().bioEnd();
      }
 else {
        startCodonBegin=startCodon.location().bioStart();
      }
      startCodonName=startCodon.getAttribute("String_Node_Str");
    }
    FeatureList stopCodonList=gene.selectByType("String_Node_Str");
    if (stopCodonList != null && stopCodonList.size() > 0) {
      stopCodon=stopCodonList.get(0);
      if (strand == Strand.NEGATIVE) {
        stopCodonEnd=stopCodon.location().bioStart();
      }
 else {
        stopCodonEnd=stopCodon.location().bioEnd();
      }
      stopCodonName=stopCodon.getAttribute("String_Node_Str");
    }
    if (startCodonBegin == null) {
      if (strand == Strand.NEGATIVE) {
        FeatureI firstFeature=cdsFeatures.get(0);
        startCodonBegin=firstFeature.location().bioEnd();
      }
 else {
        FeatureI firstFeature=cdsFeatures.get(0);
        startCodonBegin=firstFeature.location().bioStart();
      }
    }
    if (stopCodonEnd == null) {
      if (strand == Strand.NEGATIVE) {
        FeatureI lastFeature=cdsFeatures.get(cdsFeatures.size() - 1);
        stopCodonEnd=lastFeature.location().bioStart();
      }
 else {
        FeatureI lastFeature=cdsFeatures.get(cdsFeatures.size() - 1);
        stopCodonEnd=lastFeature.location().bioEnd();
      }
    }
    if (startCodonBegin > stopCodonEnd) {
      int temp=startCodonBegin;
      startCodonBegin=stopCodonEnd;
      stopCodonEnd=temp;
    }
    AccessionID transcriptAccessionID=new AccessionID(geneid);
    if (geneSequence == null) {
      geneSequence=seq.addGene(geneAccessionID,startCodonBegin,stopCodonEnd,strand);
      geneSequence.setSource(source);
    }
 else {
      if (startCodonBegin < geneSequence.getBioBegin()) {
        geneSequence.setBioBegin(startCodonBegin);
      }
      if (stopCodonEnd > geneSequence.getBioBegin()) {
        geneSequence.setBioEnd(stopCodonEnd);
      }
    }
    TranscriptSequence transcriptSequence=geneSequence.addTranscript(transcriptAccessionID,startCodonBegin,stopCodonEnd);
    if (startCodon != null) {
      if (startCodonName == null || startCodonName.length() == 0) {
        startCodonName=geneid + "String_Node_Str" + startCodon.location().bioStart()+ "String_Node_Str"+ startCodon.location().bioEnd();
      }
      transcriptSequence.addStartCodonSequence(new AccessionID(startCodonName),startCodon.location().bioStart(),startCodon.location().bioEnd());
    }
    if (stopCodon != null) {
      if (stopCodonName == null || stopCodonName.length() == 0) {
        stopCodonName=geneid + "String_Node_Str" + stopCodon.location().bioStart()+ "String_Node_Str"+ stopCodon.location().bioEnd();
      }
      transcriptSequence.addStopCodonSequence(new AccessionID(stopCodonName),stopCodon.location().bioStart(),stopCodon.location().bioEnd());
    }
    for (    FeatureI cdsFeature : cdsFeatures) {
      Feature cds=(Feature)cdsFeature;
      String cdsName=cds.getAttribute("String_Node_Str");
      if (cdsName == null || cdsName.length() == 0) {
        cdsName=geneid + "String_Node_Str" + cds.location().bioStart()+ "String_Node_Str"+ cds.location().bioEnd();
      }
      AccessionID cdsAccessionID=new AccessionID(cdsName);
      ExonSequence exonSequence=geneSequence.addExon(cdsAccessionID,cdsFeature.location().bioStart(),cdsFeature.location().bioEnd());
      transcriptSequence.addCDS(cdsAccessionID,cdsFeature.location().bioStart(),cdsFeature.location().bioEnd(),cds.frame());
    }
  }
}