Program: 12616
Project: 12616
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=topLevel.getIdentity();
  URI encoding=Sbol2Terms.SequenceURI.DnaSequenceV1;
  List<Annotation> annotations=new ArrayList<>();
  if (URIPrefix != null) {
    displayId=findDisplayId(topLevel.getIdentity().toString());
    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.Identified.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.Identified.title)) {
      name=((Literal<QName>)namedProperty.getValue()).getValue().toString();
    }
 else     if (namedProperty.getName().equals(Sbol2Terms.Identified.description)) {
      description=((Literal<QName>)namedProperty.getValue()).getValue().toString();
    }
 else {
      annotations.add(new Annotation(namedProperty));
    }
  }
  Sequence sequence=new Sequence(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);
  Sequence oldS=SBOLDoc.getSequence(identity);
  if (oldS == null) {
    SBOLDoc.addSequence(sequence);
  }
 else   if (sequence.isSetWasDerivedFrom() && oldS.isSetWasDerivedFrom() && !sequence.getWasDerivedFrom().equals(oldS.getWasDerivedFrom())) {
    Set<TopLevel> topLevels=SBOLDoc.getByWasDerivedFrom(sequence.getWasDerivedFrom());
    for (    TopLevel top : topLevels) {
      if (top instanceof Sequence) {
        return (Sequence)top;
      }
    }
    do {
      displayId=displayId + "String_Node_Str";
      identity=createCompliantURI(URIPrefix,TopLevel.SEQUENCE,displayId,version,typesInURI);
      persistentIdentity=createCompliantURI(URIPrefix,TopLevel.SEQUENCE,displayId,"String_Node_Str",typesInURI);
    }
 while (SBOLDoc.getSequence(identity) != null);
    sequence.setIdentity(identity);
    sequence.setDisplayId(displayId);
    sequence.setPersistentIdentity(persistentIdentity);
    SBOLDoc.addSequence(sequence);
  }
 else   if (dropObjectsWithDuplicateURIs) {
    return oldS;
  }
 else {
    if (!sequence.equals(oldS)) {
      throw new SBOLValidationException("String_Node_Str" + identity);
    }
  }
  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=topLevel.getIdentity();
  URI encoding=Sequence.IUPAC_DNA;
  List<Annotation> annotations=new ArrayList<>();
  if (URIPrefix != null) {
    displayId=findDisplayId(topLevel.getIdentity().toString());
    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.Identified.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.Identified.title)) {
      name=((Literal<QName>)namedProperty.getValue()).getValue().toString();
    }
 else     if (namedProperty.getName().equals(Sbol2Terms.Identified.description)) {
      description=((Literal<QName>)namedProperty.getValue()).getValue().toString();
    }
 else {
      annotations.add(new Annotation(namedProperty));
    }
  }
  Sequence sequence=new Sequence(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);
  Sequence oldS=SBOLDoc.getSequence(identity);
  if (oldS == null) {
    SBOLDoc.addSequence(sequence);
  }
 else   if (sequence.isSetWasDerivedFrom() && oldS.isSetWasDerivedFrom() && !sequence.getWasDerivedFrom().equals(oldS.getWasDerivedFrom())) {
    Set<TopLevel> topLevels=SBOLDoc.getByWasDerivedFrom(sequence.getWasDerivedFrom());
    for (    TopLevel top : topLevels) {
      if (top instanceof Sequence) {
        return (Sequence)top;
      }
    }
    do {
      displayId=displayId + "String_Node_Str";
      identity=createCompliantURI(URIPrefix,TopLevel.SEQUENCE,displayId,version,typesInURI);
      persistentIdentity=createCompliantURI(URIPrefix,TopLevel.SEQUENCE,displayId,"String_Node_Str",typesInURI);
    }
 while (SBOLDoc.getSequence(identity) != null);
    sequence.setIdentity(identity);
    sequence.setDisplayId(displayId);
    sequence.setPersistentIdentity(persistentIdentity);
    SBOLDoc.addSequence(sequence);
  }
 else   if (dropObjectsWithDuplicateURIs) {
    return oldS;
  }
 else {
    if (!sequence.equals(oldS)) {
      throw new SBOLValidationException("String_Node_Str" + identity);
    }
  }
  return sequence;
}