use of org.sbolstandard.core2.Sequence in project libSBOLj by SynBioDex.
the class ComponentDefinition method createSequenceAnnotation.
/**
* Creates a child sequence annotation for this component definition with the given arguments,
* and then adds to this component definition's list of sequence annotations.
*
* @param displayId the display ID of the sequence annotation to be created
* @param location the location of the sequence annotation to be created
* @return the created sequence annotation
* @throws SBOLValidationException if any of the following condition is satisfied:
* <ul>
* <li>an SBOL validation rule violation occurred in {@link URIcompliance#createCompliantURI(String, String, String)};</li>
* <li>an SBOL validation rule violation occurred in {@link #createSequenceAnnotation(URI, Set)};</li>
* <li>an SBOL validation rule violation occurred in {@link SequenceAnnotation#setDisplayId(String)}; or</li>
* <li>an SBOL validation rule violation occurred in {@link SequenceAnnotation#setVersion(String)}.</li>
* </ul>
*/
private SequenceAnnotation createSequenceAnnotation(String displayId, Location location) throws SBOLValidationException {
String URIprefix = this.getPersistentIdentity().toString();
String version = this.getVersion();
URI newSequenceAnnotationURI = createCompliantURI(URIprefix, displayId, version);
Set<Location> locations = new HashSet<>();
locations.add(location);
SequenceAnnotation sa = createSequenceAnnotation(newSequenceAnnotationURI, locations);
sa.setPersistentIdentity(createCompliantURI(URIprefix, displayId, ""));
sa.setDisplayId(displayId);
sa.setVersion(version);
return sa;
}
use of org.sbolstandard.core2.Sequence in project libSBOLj by SynBioDex.
the class SBOLDocument method updateReferences.
// TODO: need to update persistentIdentities too
private void updateReferences(HashMap<URI, URI> uriMap) throws SBOLValidationException {
for (TopLevel topLevel : getTopLevels()) {
for (URI wasDerivedFrom : topLevel.getWasDerivedFroms()) {
if (uriMap.get(wasDerivedFrom) != null) {
topLevel.removeWasDerivedFrom(wasDerivedFrom);
topLevel.addWasDerivedFrom(uriMap.get(wasDerivedFrom));
}
}
for (URI wasGeneratedBy : topLevel.getWasGeneratedBys()) {
if (uriMap.get(wasGeneratedBy) != null) {
topLevel.removeWasGeneratedBy(wasGeneratedBy);
topLevel.addWasGeneratedBy(uriMap.get(wasGeneratedBy));
}
}
for (URI attachmentURI : topLevel.getAttachmentURIs()) {
if (uriMap.get(attachmentURI) != null) {
topLevel.removeAttachment(attachmentURI);
topLevel.addAttachment(uriMap.get(attachmentURI));
}
}
}
for (Collection collection : getCollections()) {
for (URI memberURI : collection.getMemberURIs()) {
if (uriMap.get(memberURI) != null) {
collection.removeMember(memberURI);
collection.addMember(uriMap.get(memberURI));
}
}
updateReferences(collection, uriMap);
}
for (ComponentDefinition componentDefinition : getComponentDefinitions()) {
updateReferences(componentDefinition, uriMap);
for (Component component : componentDefinition.getComponents()) {
if (uriMap.get(component.getDefinitionURI()) != null) {
component.setDefinition(uriMap.get(component.getDefinitionURI()));
for (MapsTo mapsTo : component.getMapsTos()) {
ComponentDefinition cd = getComponentDefinition(component.getDefinitionURI());
if (cd != null) {
String displayId = URIcompliance.extractDisplayId(mapsTo.getRemoteURI());
URI newURI = URIcompliance.createCompliantURI(cd.getPersistentIdentity().toString(), displayId, cd.getVersion());
mapsTo.setRemote(newURI);
}
}
}
updateReferences(component, uriMap);
for (MapsTo mapsTo : component.getMapsTos()) {
updateReferences(mapsTo, uriMap);
}
}
for (SequenceAnnotation sa : componentDefinition.getSequenceAnnotations()) {
for (Location loc : sa.getLocations()) {
updateReferences(loc, uriMap);
}
updateReferences(sa, uriMap);
}
for (SequenceConstraint sc : componentDefinition.getSequenceConstraints()) {
updateReferences(sc, uriMap);
}
for (URI sequenceURI : componentDefinition.getSequenceURIs()) {
if (uriMap.get(sequenceURI) != null) {
componentDefinition.removeSequence(sequenceURI);
componentDefinition.addSequence(uriMap.get(sequenceURI));
}
}
}
for (ModuleDefinition moduleDefinition : getModuleDefinitions()) {
updateReferences(moduleDefinition, uriMap);
for (FunctionalComponent functionalComponent : moduleDefinition.getFunctionalComponents()) {
if (uriMap.get(functionalComponent.getDefinitionURI()) != null) {
functionalComponent.setDefinition(uriMap.get(functionalComponent.getDefinitionURI()));
for (MapsTo mapsTo : functionalComponent.getMapsTos()) {
ComponentDefinition cd = getComponentDefinition(functionalComponent.getDefinitionURI());
if (cd != null) {
String displayId = URIcompliance.extractDisplayId(mapsTo.getRemoteURI());
URI newURI = URIcompliance.createCompliantURI(cd.getPersistentIdentity().toString(), displayId, cd.getVersion());
mapsTo.setRemote(newURI);
}
}
}
updateReferences(functionalComponent, uriMap);
for (MapsTo mapsTo : functionalComponent.getMapsTos()) {
updateReferences(mapsTo, uriMap);
}
}
for (Module module : moduleDefinition.getModules()) {
if (uriMap.get(module.getDefinitionURI()) != null) {
module.setDefinition(uriMap.get(module.getDefinitionURI()));
for (MapsTo mapsTo : module.getMapsTos()) {
ModuleDefinition md = getModuleDefinition(module.getDefinitionURI());
if (md != null) {
String displayId = URIcompliance.extractDisplayId(mapsTo.getRemoteURI());
URI newURI = URIcompliance.createCompliantURI(md.getPersistentIdentity().toString(), displayId, md.getVersion());
mapsTo.setRemote(newURI);
}
}
}
updateReferences(module, uriMap);
for (MapsTo mapsTo : module.getMapsTos()) {
updateReferences(mapsTo, uriMap);
}
}
for (Interaction interaction : moduleDefinition.getInteractions()) {
updateReferences(interaction, uriMap);
for (Participation participation : interaction.getParticipations()) {
updateReferences(participation, uriMap);
}
}
for (URI modelURI : moduleDefinition.getModelURIs()) {
if (uriMap.get(modelURI) != null) {
moduleDefinition.removeModel(modelURI);
moduleDefinition.addModel(uriMap.get(modelURI));
}
}
}
for (Model model : getModels()) {
updateReferences(model, uriMap);
}
for (Sequence sequence : getSequences()) {
updateReferences(sequence, uriMap);
}
for (Attachment attachment : getAttachments()) {
updateReferences(attachment, uriMap);
}
for (Implementation implementation : getImplementations()) {
if (implementation.isSetBuilt()) {
URI built = implementation.getBuiltURI();
if (uriMap.get(built) != null) {
implementation.setBuilt(uriMap.get(built));
}
}
updateReferences(implementation, uriMap);
}
for (GenericTopLevel genericTopLevel : getGenericTopLevels()) {
updateReferences(genericTopLevel, uriMap);
}
for (CombinatorialDerivation combinatorialDerivation : getCombinatorialDerivations()) {
updateReferences(combinatorialDerivation, uriMap);
if (uriMap.get(combinatorialDerivation.getTemplateURI()) != null) {
combinatorialDerivation.setTemplate(uriMap.get(combinatorialDerivation.getTemplateURI()));
ComponentDefinition cd = getComponentDefinition(combinatorialDerivation.getTemplateURI());
if (cd != null) {
for (VariableComponent variableComponent : combinatorialDerivation.getVariableComponents()) {
String displayId = URIcompliance.extractDisplayId(variableComponent.getVariableURI());
URI newURI = URIcompliance.createCompliantURI(cd.getPersistentIdentity().toString(), displayId, cd.getVersion());
variableComponent.setVariable(newURI);
}
}
}
for (VariableComponent variableComponent : combinatorialDerivation.getVariableComponents()) {
updateReferences(variableComponent, uriMap);
}
}
for (Activity activity : getActivities()) {
updateReferences(activity, uriMap);
for (Association association : activity.getAssociations()) {
if (uriMap.get(association.getAgentURI()) != null) {
association.setAgent(uriMap.get(association.getAgentURI()));
}
if (uriMap.get(association.getPlanURI()) != null) {
association.setPlan(uriMap.get(association.getPlanURI()));
}
updateReferences(association, uriMap);
}
for (Usage usage : activity.getUsages()) {
if (uriMap.get(usage.getEntityURI()) != null) {
usage.setEntity(uriMap.get(usage.getEntityURI()));
}
updateReferences(usage, uriMap);
}
}
for (Agent agent : getAgents()) {
updateReferences(agent, uriMap);
}
for (Plan plan : getPlans()) {
updateReferences(plan, uriMap);
}
}
use of org.sbolstandard.core2.Sequence 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.Sequence 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.Sequence 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;
}
Aggregations