use of org.sbolstandard.core2.SBOLValidationException in project libSBOLj by SynBioDex.
the class SequenceAnnotation method addCut.
/**
* Creates a cut with the given arguments and then adds it to this sequence annotation's
* list of locations.
* <p>
* This method first creates a compliant URI for the cut to be created.
* It starts with this sequence annotation's persistent identity URI,
* followed by the given display ID, and ends an empty string for version.
*
* @param displayId the display ID for the cut to be created
* @param at the at property for the cut to be created
* @param orientation the orientation type
* @return the created cut
* @throws SBOLValidationException if any of the following SBOL validation rules was violated:
* 10201, 10202, 10204, 10206, 11202.
*/
public Cut addCut(String displayId, int at, OrientationType orientation) throws SBOLValidationException {
URI identity = createCompliantURI(this.getPersistentIdentity().toString(), displayId, this.getVersion());
Cut cut = new Cut(identity, at);
cut.setPersistentIdentity(createCompliantURI(this.getPersistentIdentity().toString(), displayId, ""));
cut.setDisplayId(displayId);
cut.setVersion(this.getVersion());
cut.setOrientation(orientation);
addLocation(cut);
return cut;
}
use of org.sbolstandard.core2.SBOLValidationException in project libSBOLj by SynBioDex.
the class SequenceAnnotation method copy.
void copy(SequenceAnnotation sequenceAnnotation) throws SBOLValidationException {
((Identified) this).copy((Identified) sequenceAnnotation);
for (Location location : sequenceAnnotation.getLocations()) {
String displayId = URIcompliance.findDisplayId(location);
if (location instanceof Range) {
Range range = (Range) location;
Range newRange;
if (range.isSetOrientation()) {
newRange = this.addRange(displayId, range.getStart(), range.getEnd(), range.getOrientation());
} else {
newRange = this.addRange(displayId, range.getStart(), range.getEnd());
}
newRange.copy(range);
} else if (location instanceof Cut) {
Cut cut = (Cut) location;
Cut newCut;
if (cut.isSetOrientation()) {
newCut = this.addCut(displayId, cut.getAt(), cut.getOrientation());
} else {
newCut = this.addCut(displayId, cut.getAt());
}
newCut.copy(cut);
} else if (location instanceof GenericLocation) {
GenericLocation genericLocation = (GenericLocation) location;
GenericLocation newGenericLocation;
if (genericLocation.isSetOrientation()) {
newGenericLocation = this.addGenericLocation(displayId, genericLocation.getOrientation());
} else {
newGenericLocation = this.addGenericLocation(displayId);
}
newGenericLocation.copy(genericLocation);
}
}
Location location = this.getLocation("DUMMY__LOCATION");
if (location != null) {
this.removeLocation(location);
}
if (sequenceAnnotation.isSetComponent()) {
String componentDisplayId = URIcompliance.findDisplayId(sequenceAnnotation.getComponent());
this.setComponent(componentDisplayId);
}
this.roles = new HashSet<>();
for (URI role : sequenceAnnotation.getRoles()) {
this.addRole(URI.create(role.toString()));
}
}
use of org.sbolstandard.core2.SBOLValidationException in project libSBOLj by SynBioDex.
the class SequenceAnnotation method addCut.
/**
* Creates a cut with the given arguments and then adds it to this sequence annotation's
* list of locations.
* <p>
* This method first creates a compliant URI for the cut to be created.
* It starts with this sequence annotation's persistent identity URI,
* followed by the given display ID, and ends an empty string for version.
*
* @param displayId the display ID for the cut to be created
* @param at the at property for the cut to be created
* @return the created cut
* @throws SBOLValidationException if any of the following SBOL validation rules was violated:
* 10201, 10202, 10204, 10206, 11202.
*/
public Cut addCut(String displayId, int at) throws SBOLValidationException {
URI identity = createCompliantURI(this.getPersistentIdentity().toString(), displayId, this.getVersion());
Cut cut = new Cut(identity, at);
cut.setPersistentIdentity(createCompliantURI(this.getPersistentIdentity().toString(), displayId, ""));
cut.setDisplayId(displayId);
cut.setVersion(this.getVersion());
addLocation(cut);
return cut;
}
use of org.sbolstandard.core2.SBOLValidationException in project libSBOLj by SynBioDex.
the class SequenceAnnotation method addGenericLocation.
/**
* Creates a generic location with the given arguments and then adds it to this sequence annotation's
* list of locations.
* <p>
* This method first creates a compliant URI for the generic location to be created.
* It starts with this sequence annotation's persistent identity URI,
* followed by the given display ID, and ends an empty string for version.
*
* @param displayId the display ID for the generic location to be created
* @return the created generic location instance
* @throws SBOLValidationException if any of the following SBOL validation rules was violated:
* 10201, 10202, 10204, 10206.
*/
public GenericLocation addGenericLocation(String displayId) throws SBOLValidationException {
URI identity = createCompliantURI(this.getPersistentIdentity().toString(), displayId, this.getVersion());
GenericLocation genericLocation = new GenericLocation(identity);
genericLocation.setPersistentIdentity(createCompliantURI(this.getPersistentIdentity().toString(), displayId, ""));
genericLocation.setDisplayId(displayId);
genericLocation.setVersion(this.getVersion());
addLocation(genericLocation);
return genericLocation;
}
use of org.sbolstandard.core2.SBOLValidationException in project libSBOLj by SynBioDex.
the class Model method copy.
/* (non-Javadoc)
* @see org.sbolstandard.core2.abstract_classes.TopLevel#copy(java.lang.String, java.lang.String, java.lang.String)
*/
/**
* @throws SBOLValidationException if an SBOL validation rule violation occurred in any of the following methods:
* <ul>
* <li>{@link #deepCopy()},</li>
* <li>{@link URIcompliance#createCompliantURI(String, String, String)},</li>
* <li>{@link #setDisplayId(String)},</li>
* <li>{@link #setVersion(String)},</li>
* <li>{@link #setWasDerivedFrom(URI)}, or</li>
* <li>{@link #setIdentity(URI)}.</li>
* </ul>
*/
@Override
Model copy(String URIprefix, String displayId, String version) throws SBOLValidationException {
Model cloned = this.deepCopy();
cloned.setPersistentIdentity(createCompliantURI(URIprefix, displayId, ""));
cloned.setDisplayId(displayId);
cloned.setVersion(version);
URI newIdentity = createCompliantURI(URIprefix, displayId, version);
if (!this.getIdentity().equals(newIdentity)) {
cloned.addWasDerivedFrom(this.getIdentity());
} else {
cloned.setWasDerivedFroms(this.getWasDerivedFroms());
}
cloned.setIdentity(newIdentity);
return cloned;
}
Aggregations