Program: 12564
Project: 12564
Buggy source:
private static void read(SBOLDocument doc,BufferedInputStream in) throws IOException, SBOLValidationException {
  so=new SequenceOntology();
  nextLine=null;
  featureMode=false;
  originMode=false;
  doc.addNamespace(URI.create(gbNamespace),gbPrefix);
  BufferedReader br=new BufferedReader(new InputStreamReader(in));
  String strLine;
  String id="String_Node_Str";
  String version="String_Node_Str";
  boolean featureMode=false;
  int featureCnt=0;
  int refCnt=0;
  boolean seqMode=false;
  String elements="String_Node_Str";
  String description="String_Node_Str";
  URI type=ComponentDefinition.DNA;
  ComponentDefinition topCD=null;
  List<Annotation> annotations=new ArrayList<Annotation>();
  List<Annotation> nestedAnnotations=null;
  Annotation annotation=null;
  while ((strLine=readGenBankLine(br)) != null) {
    strLine=strLine.trim();
    if (strLine.startsWith("String_Node_Str")) {
      String[] strSplit=strLine.split("String_Node_Str");
      id=strSplit[1];
      if (strSplit[4].toUpperCase().contains("String_Node_Str")) {
        type=ComponentDefinition.RNA;
      }
      annotation=new Annotation(new QName(gbNamespace,"String_Node_Str",gbPrefix),strSplit[4]);
      annotations.add(annotation);
      for (int i=5; i < strSplit.length; i++) {
        if (strSplit[i].startsWith("String_Node_Str") || strSplit[i].startsWith("String_Node_Str")) {
          annotation=new Annotation(new QName(gbNamespace,"String_Node_Str",gbPrefix),strSplit[i]);
        }
 else         if (strSplit[i].length() == 3) {
          annotation=new Annotation(new QName(gbNamespace,"String_Node_Str",gbPrefix),strSplit[i]);
        }
 else {
          annotation=new Annotation(new QName(gbNamespace,"String_Node_Str",gbPrefix),strSplit[i]);
        }
        annotations.add(annotation);
      }
    }
 else     if (strLine.startsWith("String_Node_Str")) {
      description=strLine.replaceFirst("String_Node_Str","String_Node_Str");
    }
 else     if (strLine.startsWith("String_Node_Str")) {
      String[] strSplit=strLine.split("String_Node_Str");
      String accession=strSplit[1];
      id=accession;
    }
 else     if (strLine.startsWith("String_Node_Str")) {
      String[] strSplit=strLine.split("String_Node_Str");
      version=strSplit[1].split("String_Node_Str")[1];
      if (!id.equals(strSplit[1].split("String_Node_Str")[0])) {
        throw new SBOLValidationException("String_Node_Str");
      }
      if (strSplit.length > 2) {
        annotation=new Annotation(new QName(gbNamespace,"String_Node_Str",gbPrefix),strSplit[2]);
        annotations.add(annotation);
      }
    }
 else     if (strLine.startsWith("String_Node_Str")) {
      String annotationStr=strLine.replace("String_Node_Str","String_Node_Str").trim();
      annotation=new Annotation(new QName(gbNamespace,"String_Node_Str",gbPrefix),annotationStr);
      annotations.add(annotation);
    }
 else     if (strLine.startsWith("String_Node_Str")) {
      String annotationStr=strLine.replace("String_Node_Str","String_Node_Str").trim();
      annotation=new Annotation(new QName(gbNamespace,"String_Node_Str",gbPrefix),annotationStr);
      annotations.add(annotation);
    }
 else     if (strLine.startsWith("String_Node_Str")) {
      String annotationStr=strLine.replace("String_Node_Str","String_Node_Str").trim();
      annotation=new Annotation(new QName(gbNamespace,"String_Node_Str",gbPrefix),annotationStr);
      annotations.add(annotation);
    }
 else     if (strLine.startsWith("String_Node_Str")) {
      String annotationStr=strLine.replace("String_Node_Str","String_Node_Str").trim();
      nestedAnnotations=new ArrayList<Annotation>();
      Annotation labelAnnotation=new Annotation(new QName(gbNamespace,"String_Node_Str",gbPrefix),annotationStr);
      nestedAnnotations.add(labelAnnotation);
      URI nestedURI=URI.create(URIPrefix + "String_Node_Str" + id+ "String_Node_Str"+ refCnt);
      refCnt++;
      annotation=new Annotation(new QName(gbNamespace,"String_Node_Str",gbPrefix),new QName(gbNamespace,"String_Node_Str",gbPrefix),nestedURI,nestedAnnotations);
      annotations.add(annotation);
    }
 else     if (strLine.startsWith("String_Node_Str")) {
      String annotationStr=strLine.replace("String_Node_Str","String_Node_Str").trim();
      Annotation nestedAnnotation=new Annotation(new QName(gbNamespace,"String_Node_Str",gbPrefix),annotationStr);
      nestedAnnotations.add(nestedAnnotation);
      annotation.setNestedAnnotations(nestedAnnotations);
    }
 else     if (strLine.startsWith("String_Node_Str")) {
      String annotationStr=strLine.replace("String_Node_Str","String_Node_Str").trim();
      Annotation nestedAnnotation=new Annotation(new QName(gbNamespace,"String_Node_Str",gbPrefix),annotationStr);
      nestedAnnotations.add(nestedAnnotation);
      annotation.setNestedAnnotations(nestedAnnotations);
    }
 else     if (strLine.startsWith("String_Node_Str")) {
      String annotationStr=strLine.replace("String_Node_Str","String_Node_Str").trim();
      Annotation nestedAnnotation=new Annotation(new QName(gbNamespace,"String_Node_Str",gbPrefix),annotationStr);
      nestedAnnotations.add(nestedAnnotation);
      annotation.setNestedAnnotations(nestedAnnotations);
    }
 else     if (strLine.startsWith("String_Node_Str")) {
      String annotationStr=strLine.replace("String_Node_Str","String_Node_Str").trim();
      Annotation nestedAnnotation=new Annotation(new QName(gbNamespace,"String_Node_Str",gbPrefix),annotationStr);
      nestedAnnotations.add(nestedAnnotation);
      annotation.setNestedAnnotations(nestedAnnotations);
    }
 else     if (strLine.startsWith("String_Node_Str")) {
      String annotationStr=strLine.replace("String_Node_Str","String_Node_Str").trim();
      Annotation nestedAnnotation=new Annotation(new QName(gbNamespace,"String_Node_Str",gbPrefix),annotationStr);
      nestedAnnotations.add(nestedAnnotation);
      annotation.setNestedAnnotations(nestedAnnotations);
    }
 else     if (strLine.startsWith("String_Node_Str")) {
      String annotationStr=strLine.replace("String_Node_Str","String_Node_Str").trim();
      annotation=new Annotation(new QName(gbNamespace,"String_Node_Str",gbPrefix),annotationStr);
      annotations.add(annotation);
    }
 else     if (strLine.startsWith("String_Node_Str")) {
      topCD=doc.createComponentDefinition(id,version,type);
      topCD.addRole(SequenceOntology.ENGINEERED_REGION);
      if (!description.equals("String_Node_Str")) {
        topCD.setDescription(description);
      }
      topCD.setAnnotations(annotations);
      featureMode=true;
    }
 else     if (strLine.startsWith("String_Node_Str")) {
      seqMode=true;
      featureMode=false;
    }
 else {
      if (featureMode) {
        if (strLine.startsWith("String_Node_Str")) {
          String[] splitStr=strLine.split("String_Node_Str");
          String tag=splitStr[0].replace("String_Node_Str","String_Node_Str");
          String value=splitStr[1];
          SequenceAnnotation sa=topCD.getSequenceAnnotation("String_Node_Str" + (featureCnt - 1));
          annotation=new Annotation(new QName(gbNamespace,tag,gbPrefix),value);
          sa.addAnnotation(annotation);
          continue;
        }
        strLine=strLine.replace("String_Node_Str","String_Node_Str");
        String[] strSplit=strLine.split("String_Node_Str");
        URI role=convertGenBanktoSO(strSplit[0]);
        ComponentDefinition feature=doc.createComponentDefinition("String_Node_Str" + featureCnt,version,type);
        feature.addRole(role);
        String range=strSplit[1];
        OrientationType orientation=OrientationType.INLINE;
        if (range.startsWith("String_Node_Str")) {
          orientation=OrientationType.REVERSECOMPLEMENT;
          range=range.replace("String_Node_Str","String_Node_Str").replace("String_Node_Str","String_Node_Str");
        }
        if (range.startsWith("String_Node_Str")) {
          range=range.replace("String_Node_Str","String_Node_Str").replace("String_Node_Str","String_Node_Str");
          String[] ranges=range.split("String_Node_Str");
          int rangeCnt=0;
          SequenceAnnotation sa=null;
          for (          String r : ranges) {
            r=r.replace("String_Node_Str","String_Node_Str").replace("String_Node_Str","String_Node_Str");
            String[] rangeSplit=r.split("String_Node_Str");
            int start=Integer.parseInt(rangeSplit[0]);
            int end=Integer.parseInt(rangeSplit[1]);
            if (rangeCnt == 0) {
              sa=topCD.createSequenceAnnotation("String_Node_Str" + featureCnt,"String_Node_Str" + rangeCnt,start,end,orientation);
              sa.setComponent("String_Node_Str" + featureCnt);
            }
 else             if (sa != null) {
              sa.addRange("String_Node_Str" + rangeCnt,start,end,orientation);
            }
            rangeCnt++;
          }
        }
 else         if (range.contains("String_Node_Str")) {
          String[] rangeSplit=range.split("String_Node_Str");
          int at=Integer.parseInt(rangeSplit[0]);
          SequenceAnnotation sa=topCD.createSequenceAnnotation("String_Node_Str" + featureCnt,"String_Node_Str",at,orientation);
          sa.setComponent("String_Node_Str" + featureCnt);
        }
 else {
          range=range.replace("String_Node_Str","String_Node_Str").replace("String_Node_Str","String_Node_Str");
          String[] rangeSplit=range.split("String_Node_Str");
          int start=Integer.parseInt(rangeSplit[0]);
          int end=Integer.parseInt(rangeSplit[1]);
          if (start > end) {
            int temp=start;
            start=end;
            end=temp;
          }
          SequenceAnnotation sa=topCD.createSequenceAnnotation("String_Node_Str" + featureCnt,"String_Node_Str",start,end,orientation);
          sa.setComponent("String_Node_Str" + featureCnt);
        }
        featureCnt++;
      }
      if (seqMode) {
        String[] strSplit=strLine.split("String_Node_Str");
        for (int i=1; i < strSplit.length; i++) {
          elements+=strSplit[i];
        }
      }
    }
  }
  Sequence sequence=doc.createSequence(id + "String_Node_Str",version,elements,Sequence.IUPAC_DNA);
  topCD.addSequence(sequence);
  createSubComponentDefinitions(doc,topCD,type,elements,version);
  br.close();
}

Fixed version (ground truth):
private static void read(SBOLDocument doc,BufferedInputStream in) throws IOException, SBOLValidationException {
  so=new SequenceOntology();
  nextLine=null;
  featureMode=false;
  originMode=false;
  lineCounter=0;
  doc.addNamespace(URI.create(gbNamespace),gbPrefix);
  BufferedReader br=new BufferedReader(new InputStreamReader(in));
  String strLine;
  String id="String_Node_Str";
  String version="String_Node_Str";
  int featureCnt=0;
  int refCnt=0;
  StringBuilder sbSequence=new StringBuilder();
  String elements=null;
  String description="String_Node_Str";
  URI type=ComponentDefinition.DNA;
  ComponentDefinition topCD=null;
  List<Annotation> annotations=new ArrayList<Annotation>();
  List<Annotation> nestedAnnotations=null;
  Annotation annotation=null;
  while ((strLine=readGenBankLine(br)) != null) {
    strLine=strLine.trim();
    if (strLine.startsWith("String_Node_Str")) {
      String[] strSplit=strLine.split("String_Node_Str");
      id=strSplit[1];
      if (strSplit[4].toUpperCase().contains("String_Node_Str")) {
        type=ComponentDefinition.RNA;
      }
      annotation=new Annotation(new QName(gbNamespace,"String_Node_Str",gbPrefix),strSplit[4]);
      annotations.add(annotation);
      for (int i=5; i < strSplit.length; i++) {
        if (strSplit[i].startsWith("String_Node_Str") || strSplit[i].startsWith("String_Node_Str")) {
          annotation=new Annotation(new QName(gbNamespace,"String_Node_Str",gbPrefix),strSplit[i]);
        }
 else         if (strSplit[i].length() == 3) {
          annotation=new Annotation(new QName(gbNamespace,"String_Node_Str",gbPrefix),strSplit[i]);
        }
 else {
          annotation=new Annotation(new QName(gbNamespace,"String_Node_Str",gbPrefix),strSplit[i]);
        }
        annotations.add(annotation);
      }
    }
 else     if (strLine.startsWith("String_Node_Str")) {
      description=strLine.replaceFirst("String_Node_Str","String_Node_Str");
    }
 else     if (strLine.startsWith("String_Node_Str")) {
      String[] strSplit=strLine.split("String_Node_Str");
      String accession=strSplit[1];
      id=accession;
    }
 else     if (strLine.startsWith("String_Node_Str")) {
      String[] strSplit=strLine.split("String_Node_Str");
      version=strSplit[1].split("String_Node_Str")[1];
      if (!id.equals(strSplit[1].split("String_Node_Str")[0])) {
        throw new SBOLValidationException("String_Node_Str");
      }
      if (strSplit.length > 2) {
        annotation=new Annotation(new QName(gbNamespace,"String_Node_Str",gbPrefix),strSplit[2]);
        annotations.add(annotation);
      }
    }
 else     if (strLine.startsWith("String_Node_Str")) {
      String annotationStr=strLine.replace("String_Node_Str","String_Node_Str").trim();
      annotation=new Annotation(new QName(gbNamespace,"String_Node_Str",gbPrefix),annotationStr);
      annotations.add(annotation);
    }
 else     if (strLine.startsWith("String_Node_Str")) {
      String annotationStr=strLine.replace("String_Node_Str","String_Node_Str").trim();
      annotation=new Annotation(new QName(gbNamespace,"String_Node_Str",gbPrefix),annotationStr);
      annotations.add(annotation);
    }
 else     if (strLine.startsWith("String_Node_Str")) {
      String annotationStr=strLine.replace("String_Node_Str","String_Node_Str").trim();
      annotation=new Annotation(new QName(gbNamespace,"String_Node_Str",gbPrefix),annotationStr);
      annotations.add(annotation);
    }
 else     if (strLine.startsWith("String_Node_Str")) {
      String annotationStr=strLine.replace("String_Node_Str","String_Node_Str").trim();
      nestedAnnotations=new ArrayList<Annotation>();
      Annotation labelAnnotation=new Annotation(new QName(gbNamespace,"String_Node_Str",gbPrefix),annotationStr);
      nestedAnnotations.add(labelAnnotation);
      URI nestedURI=URI.create(URIPrefix + "String_Node_Str" + id+ "String_Node_Str"+ refCnt);
      refCnt++;
      annotation=new Annotation(new QName(gbNamespace,"String_Node_Str",gbPrefix),new QName(gbNamespace,"String_Node_Str",gbPrefix),nestedURI,nestedAnnotations);
      annotations.add(annotation);
    }
 else     if (strLine.startsWith("String_Node_Str")) {
      String annotationStr=strLine.replace("String_Node_Str","String_Node_Str").trim();
      Annotation nestedAnnotation=new Annotation(new QName(gbNamespace,"String_Node_Str",gbPrefix),annotationStr);
      nestedAnnotations.add(nestedAnnotation);
      annotation.setNestedAnnotations(nestedAnnotations);
    }
 else     if (strLine.startsWith("String_Node_Str")) {
      String annotationStr=strLine.replace("String_Node_Str","String_Node_Str").trim();
      Annotation nestedAnnotation=new Annotation(new QName(gbNamespace,"String_Node_Str",gbPrefix),annotationStr);
      nestedAnnotations.add(nestedAnnotation);
      annotation.setNestedAnnotations(nestedAnnotations);
    }
 else     if (strLine.startsWith("String_Node_Str")) {
      String annotationStr=strLine.replace("String_Node_Str","String_Node_Str").trim();
      Annotation nestedAnnotation=new Annotation(new QName(gbNamespace,"String_Node_Str",gbPrefix),annotationStr);
      nestedAnnotations.add(nestedAnnotation);
      annotation.setNestedAnnotations(nestedAnnotations);
    }
 else     if (strLine.startsWith("String_Node_Str")) {
      String annotationStr=strLine.replace("String_Node_Str","String_Node_Str").trim();
      Annotation nestedAnnotation=new Annotation(new QName(gbNamespace,"String_Node_Str",gbPrefix),annotationStr);
      nestedAnnotations.add(nestedAnnotation);
      annotation.setNestedAnnotations(nestedAnnotations);
    }
 else     if (strLine.startsWith("String_Node_Str")) {
      String annotationStr=strLine.replace("String_Node_Str","String_Node_Str").trim();
      Annotation nestedAnnotation=new Annotation(new QName(gbNamespace,"String_Node_Str",gbPrefix),annotationStr);
      nestedAnnotations.add(nestedAnnotation);
      annotation.setNestedAnnotations(nestedAnnotations);
    }
 else     if (strLine.startsWith("String_Node_Str")) {
      String annotationStr=strLine.replace("String_Node_Str","String_Node_Str").trim();
      annotation=new Annotation(new QName(gbNamespace,"String_Node_Str",gbPrefix),annotationStr);
      annotations.add(annotation);
    }
 else     if (strLine.startsWith("String_Node_Str")) {
      String annotationStr=strLine.replace("String_Node_Str","String_Node_Str").trim();
      annotation=new Annotation(new QName(gbNamespace,"String_Node_Str",gbPrefix),annotationStr);
      annotations.add(annotation);
    }
 else     if (strLine.startsWith("String_Node_Str")) {
      topCD=doc.createComponentDefinition(id,version,type);
      topCD.addRole(SequenceOntology.ENGINEERED_REGION);
      if (!"String_Node_Str".equals(description)) {
        topCD.setDescription(description);
      }
      topCD.setAnnotations(annotations);
      featureMode=true;
    }
 else     if (strLine.startsWith("String_Node_Str")) {
      originMode=true;
      featureMode=false;
    }
 else {
      if (featureMode) {
        if (strLine.startsWith("String_Node_Str")) {
          String tag=strLine.replace("String_Node_Str","String_Node_Str").trim();
          String value="String_Node_Str";
          if ((-1) != strLine.indexOf('=')) {
            String[] splitStr=strLine.split("String_Node_Str");
            tag=splitStr[0].replace("String_Node_Str","String_Node_Str");
            value=splitStr[1];
          }
          StringBuilder sbValue=new StringBuilder();
          sbValue.append(value);
          if (value.startsWith("String_Node_Str") && !value.endsWith("String_Node_Str")) {
            while (true) {
              strLine=readGenBankLine(br).trim();
              sbValue.append(strLine);
              if (strLine.endsWith("String_Node_Str")) {
                break;
              }
            }
          }
          SequenceAnnotation sa=topCD.getSequenceAnnotation("String_Node_Str" + (featureCnt - 1));
          if (null != sa) {
            annotation=new Annotation(new QName(gbNamespace,tag,gbPrefix),value);
            sa.addAnnotation(annotation);
          }
        }
 else {
          strLine=strLine.replace("String_Node_Str","String_Node_Str");
          String[] strSplit=strLine.split("String_Node_Str");
          URI role=convertGenBanktoSO(strSplit[0]);
          ComponentDefinition feature=doc.createComponentDefinition("String_Node_Str" + featureCnt,version,type);
          feature.addRole(role);
          String range=strSplit[1];
          OrientationType orientation=OrientationType.INLINE;
          if (range.startsWith("String_Node_Str")) {
            orientation=OrientationType.REVERSECOMPLEMENT;
            range=range.replace("String_Node_Str","String_Node_Str").replace("String_Node_Str","String_Node_Str");
          }
          if (range.startsWith("String_Node_Str")) {
            range=range.replace("String_Node_Str","String_Node_Str").replace("String_Node_Str","String_Node_Str");
            String[] ranges=range.split("String_Node_Str");
            int rangeCnt=0;
            SequenceAnnotation sa=null;
            for (            String r : ranges) {
              r=r.replace("String_Node_Str","String_Node_Str").replace("String_Node_Str","String_Node_Str");
              String[] rangeSplit=r.split("String_Node_Str");
              int start=Integer.parseInt(rangeSplit[0]);
              int end=Integer.parseInt(rangeSplit[1]);
              if (rangeCnt == 0) {
                sa=topCD.createSequenceAnnotation("String_Node_Str" + featureCnt,"String_Node_Str" + rangeCnt,start,end,orientation);
                sa.setComponent("String_Node_Str" + featureCnt);
              }
 else               if (sa != null) {
                sa.addRange("String_Node_Str" + rangeCnt,start,end,orientation);
              }
              rangeCnt++;
            }
          }
 else           if (range.contains("String_Node_Str")) {
            String[] rangeSplit=range.split("String_Node_Str");
            int at=Integer.parseInt(rangeSplit[0]);
            SequenceAnnotation sa=topCD.createSequenceAnnotation("String_Node_Str" + featureCnt,"String_Node_Str",at,orientation);
            sa.setComponent("String_Node_Str" + featureCnt);
          }
 else {
            range=range.replace("String_Node_Str","String_Node_Str").replace("String_Node_Str","String_Node_Str");
            String[] rangeSplit=range.split("String_Node_Str");
            try {
              int start=Integer.parseInt(rangeSplit[0]);
              int end=Integer.parseInt(rangeSplit[1]);
              if (start > end) {
                int temp=start;
                start=end;
                end=temp;
              }
              SequenceAnnotation sa=topCD.createSequenceAnnotation("String_Node_Str" + featureCnt,"String_Node_Str",start,end,orientation);
              sa.setComponent("String_Node_Str" + featureCnt);
            }
 catch (            Exception e) {
              System.out.println(lineCounter + "String_Node_Str" + strLine);
            }
          }
          featureCnt++;
        }
      }
 else       if (originMode) {
        if (elements == null) {
          elements=new String("String_Node_Str");
        }
        String[] strSplit=strLine.split("String_Node_Str");
        for (int i=1; i < strSplit.length; i++) {
          sbSequence.append(strSplit[i]);
        }
      }
    }
  }
  Sequence sequence=doc.createSequence(id + "String_Node_Str",version,sbSequence.toString(),Sequence.IUPAC_DNA);
  topCD.addSequence(sequence);
  createSubComponentDefinitions(doc,topCD,type,sbSequence.toString(),version);
  br.close();
}