Program: 12657
Project: 12657
Buggy source:
private static Sequence parseDnaSequenceV1(SBOLDocument SBOLDoc,IdentifiableDocument<QName> topLevel){
  String elements=null;
  String displayId=null;
  String name=null;
  String description=null;
  URI identity=topLevel.getIdentity();
  URI persistentIdentity=null;
  URI encoding=Sbol2Terms.SequenceURI.DnaSequenceV1;
  List<Annotation> annotations=new ArrayList<>();
  if (URIPrefix != null) {
    if (topLevel.getIdentity().toString().lastIndexOf('/') != -1) {
      displayId=topLevel.getIdentity().toString().substring(topLevel.getIdentity().toString().lastIndexOf('/') + 1);
      displayId=fixDisplayId(displayId);
      identity=createCompliantURI(URIPrefix,TopLevel.SEQUENCE,displayId,version,typesInURI);
      persistentIdentity=createCompliantURI(URIPrefix,TopLevel.SEQUENCE,displayId,"String_Node_Str",typesInURI);
    }
  }
  for (  NamedProperty<QName> namedProperty : topLevel.getProperties()) {
    if (namedProperty.getName().equals(Sbol1Terms.DNASequence.nucleotides)) {
      elements=((Literal<QName>)namedProperty.getValue()).getValue().toString();
    }
 else     if (namedProperty.getName().equals(Sbol2Terms.Documented.displayId)) {
      displayId=((Literal<QName>)namedProperty.getValue()).getValue().toString();
      if (URIPrefix != null) {
        identity=createCompliantURI(URIPrefix,TopLevel.SEQUENCE,displayId,version,typesInURI);
      }
    }
 else     if (namedProperty.getName().equals(Sbol2Terms.Documented.title)) {
      name=((Literal<QName>)namedProperty.getValue()).getValue().toString();
    }
 else     if (namedProperty.getName().equals(Sbol2Terms.Documented.description)) {
      description=((Literal<QName>)namedProperty.getValue()).getValue().toString();
    }
 else {
      annotations.add(new Annotation(namedProperty));
    }
  }
  Sequence sequence=SBOLDoc.getSequence(identity);
  if (sequence == null) {
    sequence=SBOLDoc.createSequence(identity,elements,encoding);
    if (persistentIdentity != null) {
      sequence.setPersistentIdentity(persistentIdentity);
      sequence.setVersion(version);
    }
    if (identity != topLevel.getIdentity())     sequence.setWasDerivedFrom(topLevel.getIdentity());
    if (displayId != null)     sequence.setDisplayId(displayId);
    if (name != null)     sequence.setName(name);
    if (description != null)     sequence.setDescription(description);
    if (!annotations.isEmpty())     sequence.setAnnotations(annotations);
  }
  return sequence;
}

Fixed version (ground truth):
private static Sequence parseDnaSequenceV1(SBOLDocument SBOLDoc,IdentifiableDocument<QName> topLevel){
  String elements=null;
  String displayId=null;
  String name=null;
  String description=null;
  URI identity=topLevel.getIdentity();
  URI persistentIdentity=null;
  URI encoding=Sbol2Terms.SequenceURI.DnaSequenceV1;
  List<Annotation> annotations=new ArrayList<>();
  if (URIPrefix != null) {
    int slash=topLevel.getIdentity().toString().lastIndexOf('/');
    int pound=topLevel.getIdentity().toString().lastIndexOf('#');
    int colon=topLevel.getIdentity().toString().lastIndexOf(':');
    if (slash != -1 && slash > pound && slash > colon) {
      displayId=topLevel.getIdentity().toString().substring(slash + 1);
    }
 else     if (pound != -1 && pound > colon) {
      displayId=topLevel.getIdentity().toString().substring(pound + 1);
    }
 else     if (colon != -1) {
      displayId=topLevel.getIdentity().toString().substring(colon + 1);
    }
 else {
      displayId=topLevel.getIdentity().toString();
    }
    displayId=fixDisplayId(displayId);
    identity=createCompliantURI(URIPrefix,TopLevel.SEQUENCE,displayId,version,typesInURI);
    persistentIdentity=createCompliantURI(URIPrefix,TopLevel.SEQUENCE,displayId,"String_Node_Str",typesInURI);
  }
  for (  NamedProperty<QName> namedProperty : topLevel.getProperties()) {
    if (namedProperty.getName().equals(Sbol1Terms.DNASequence.nucleotides)) {
      elements=((Literal<QName>)namedProperty.getValue()).getValue().toString();
    }
 else     if (namedProperty.getName().equals(Sbol2Terms.Documented.displayId)) {
      displayId=((Literal<QName>)namedProperty.getValue()).getValue().toString();
      if (URIPrefix != null) {
        identity=createCompliantURI(URIPrefix,TopLevel.SEQUENCE,displayId,version,typesInURI);
      }
    }
 else     if (namedProperty.getName().equals(Sbol2Terms.Documented.title)) {
      name=((Literal<QName>)namedProperty.getValue()).getValue().toString();
    }
 else     if (namedProperty.getName().equals(Sbol2Terms.Documented.description)) {
      description=((Literal<QName>)namedProperty.getValue()).getValue().toString();
    }
 else {
      annotations.add(new Annotation(namedProperty));
    }
  }
  Sequence sequence=SBOLDoc.getSequence(identity);
  if (sequence == null) {
    sequence=SBOLDoc.createSequence(identity,elements,encoding);
    if (persistentIdentity != null) {
      sequence.setPersistentIdentity(persistentIdentity);
      sequence.setVersion(version);
    }
    if (identity != topLevel.getIdentity())     sequence.setWasDerivedFrom(topLevel.getIdentity());
    if (displayId != null)     sequence.setDisplayId(displayId);
    if (name != null)     sequence.setName(name);
    if (description != null)     sequence.setDescription(description);
    if (!annotations.isEmpty())     sequence.setAnnotations(annotations);
  }
  return sequence;
}