Search in sources :

Example 6 with URIcompliance.createCompliantURI

use of org.sbolstandard.core2.URIcompliance.createCompliantURI in project libSBOLj by SynBioDex.

the class ComponentDefinition method createSequenceConstraint.

/**
 * Creates a child sequence constraint for this component definition with the given arguments,
 * and then adds to this component definition's list of sequence constraints.
 * <p>
 * Creation of a sequence constraint requires URIs of a subject component and an object component.
 * This method creates compliant URIs for them respectively. The subject component compliant URI is created with this
 * component defintion's persistent identity URI, followed by the given subject component's display ID,
 * followed by this component's version. The object component compliant URI is created similarly.
 * This method then calls {@link #createSequenceConstraint(String, RestrictionType, URI, URI)} to create
 * the sequence constraint.
 * <p>
 * This method automatically creates a subject component if all of the following conditions are satisfied:
 * <ul>
 * <li>the associated SBOLDocument, i.e., the SBOLDocument instance hosting this component definition, is not {@code null};</li>
 * <li>if default components should be automatically created when not present for the associated SBOLDocument instance,
 * i.e., {@link SBOLDocument#isCreateDefaults} returns {@code true}; and</li>
 * <li>if this component definition does not already have a component with the created compliant subject component URI.</li>
 * </ul>
 * An object component is automatically created if the similar set of conditions hold.
 *
 * @param displayId the display ID of the sequence constraint to be created
 * @param restriction the structural restriction of the subject and object components
 * @param subjectId the display ID of the subject component
 * @param objectId the display ID of the object component
 * @return the created sequence constraint
 * @throws SBOLValidationException if any of the following condition is satisfied:
 * <ul>
 * <li>if any of the following SBOL validation rules was violated:
 * 10201, 10202, 10204, 10206, 10602, 10604, 10605, 10607, 10803; or</li>
 * <li>an SBOL validation rule violation occurred in {@link #createSequenceConstraint(String, RestrictionType, URI, URI)}.</li>
 * </ul>
 */
public SequenceConstraint createSequenceConstraint(String displayId, RestrictionType restriction, String subjectId, String objectId) throws SBOLValidationException {
    URI subjectURI = URIcompliance.createCompliantURI(this.getPersistentIdentity().toString(), subjectId, this.getVersion());
    if (this.getSBOLDocument() != null && this.getSBOLDocument().isCreateDefaults() && this.getComponent(subjectURI) == null) {
        this.createComponent(subjectId, AccessType.PUBLIC, subjectId, "");
    }
    URI objectURI = URIcompliance.createCompliantURI(this.getPersistentIdentity().toString(), objectId, this.getVersion());
    if (this.getSBOLDocument() != null && this.getSBOLDocument().isCreateDefaults() && this.getComponent(objectURI) == null) {
        this.createComponent(objectId, AccessType.PUBLIC, objectId, "");
    }
    return createSequenceConstraint(displayId, restriction, subjectURI, objectURI);
}
Also used : URI(java.net.URI) URIcompliance.createCompliantURI(org.sbolstandard.core2.URIcompliance.createCompliantURI)

Example 7 with URIcompliance.createCompliantURI

use of org.sbolstandard.core2.URIcompliance.createCompliantURI in project libSBOLj by SynBioDex.

the class Module method createMapsTo.

/**
 * Creates a child mapsTo for this module with the given arguments, and then adds it to its list of mapsTos.
 * <p>
 * This method creates compliant local and remote URIs first.
 * The compliant local URI is created with this module's persistent identity URI, followed by
 * the given local module's display ID, followed by this module's version.
 * The compliant remote URI is created following the same pattern.
 * It then calls {@link #createMapsTo(String, RefinementType, URI, URI)} with the given mapsTo's display ID, its refinement type,
 * and the created compliant local and remote functional components' URIs.
 * <p>
 * This method calls {@link ModuleDefinition#createFunctionalComponent(String, AccessType, String, String, DirectionType)}
 * to automatically create a local functional component with the given display ID of referenced local component definition,
 * {@link AccessType#PUBLIC}, an empty version string, and {@link DirectionType#INOUT}, if all of the following conditions are satisfied:
 * <ul>
 * <li>the associated SBOLDocument instance for this module is not {@code null};</li>
 * <li>if default functional components should be automatically created when not present in the associated SBOLDocument instance,
 * i.e., {@link SBOLDocument#isCreateDefaults} returns {@code true};</li>
 * <li>if this module's parent ModuleDefinition instance exists; and</li>
 * <li>if this module's parent ModuleDefinition instance does not already have a functional component
 * with the created compliant local URI.</li>
 * </ul>
 * This automatically created created functional component has the same display ID as its referenced component definition.
 *
 * @param displayId the display ID of the mapsTo to be created
 * @param refinement the relationship between the local and remote components
 * @param localId the display ID of the local functional component
 * @param remoteId the display ID of the remote functional component
 * @return the created mapsTo
 * @throws SBOLValidationException if any of the following condition is satisfied:
 * <ul>
 * <li>if either of the following SBOL validation rules was violated: 10204, 10206;</li>
 * <li>an SBOL validation exception occurred in {@link ModuleDefinition#createFunctionalComponent(String, AccessType, String, String, DirectionType)}; or</li>
 * <li>an SBOL validation exception occurred in {@link #createMapsTo(String, RefinementType, URI, URI)}.</li>
 * </ul>
 */
public MapsTo createMapsTo(String displayId, RefinementType refinement, String localId, String remoteId) throws SBOLValidationException {
    URI localURI = URIcompliance.createCompliantURI(moduleDefinition.getPersistentIdentity().toString(), localId, moduleDefinition.getVersion());
    if (this.getSBOLDocument() != null && this.getSBOLDocument().isCreateDefaults() && moduleDefinition != null && moduleDefinition.getFunctionalComponent(localURI) == null) {
        moduleDefinition.createFunctionalComponent(localId, AccessType.PUBLIC, localId, "", DirectionType.INOUT);
    }
    URI remoteURI = URIcompliance.createCompliantURI(getDefinition().getPersistentIdentity().toString(), remoteId, getDefinition().getVersion());
    return createMapsTo(displayId, refinement, localURI, remoteURI);
}
Also used : URI(java.net.URI) URIcompliance.createCompliantURI(org.sbolstandard.core2.URIcompliance.createCompliantURI)

Example 8 with URIcompliance.createCompliantURI

use of org.sbolstandard.core2.URIcompliance.createCompliantURI in project libSBOLj by SynBioDex.

the class FunctionalComponent method createMapsTo.

/**
 * Creates a child MapsTo instance for this module with the given arguments, and then adds to this module's list of mapsTos.
 * <p>
 * This method creates compliant local and remote URIs first.
 * The compliant local URI is created with this module's persistent identity URI, followed by
 * the given local component's display ID, followed by this module's version.
 * The compliant remote URI is created following the same pattern.
 * It then calls {@link #createMapsTo(String, RefinementType, URI, URI)} to create
 * a MapsTo instance.
 * <p>
 * This method automatically creates a local functional component if all of the following conditions are satisfied:
 * <ul>
 * <li>the associated SBOLDocument instance for this module is not {@code null};</li>
 * <li>if default functional components should be automatically created when not present for the associated SBOLDocument instance,
 * i.e., {@link SBOLDocument#isCreateDefaults} returns {@code true};</li>
 * <li>if this module's parent module definition exists; and</li>
 * <li>if this module's parent module definition does not already have a functional component
 * with the created compliant local functional component URI.</li>
 * </ul>
 * @param displayId the display ID of the mapsTo to be created
 * @param refinement the relationship between the local and remote functional components
 * @param localId the display ID of the local functional component
 * @param remoteId the display ID of the remote functional component
 * @return the created mapsTo
 * @throws SBOLValidationException if any of the following conditions is satisfied:
 * <ul>
 * <li>if either of the following SBOL validation rules was violated: 10204, 10206;</li>
 * <li>an SBOL validation rule violation occurred in {@link ModuleDefinition#createFunctionalComponent(String, AccessType, String, String, DirectionType)}; or</li>
 * <li>an SBOL validation rule violation occurred in {@link #createMapsTo(String, RefinementType, URI, URI)}.</li>
 * </ul>
 */
public MapsTo createMapsTo(String displayId, RefinementType refinement, String localId, String remoteId) throws SBOLValidationException {
    URI localURI = URIcompliance.createCompliantURI(moduleDefinition.getPersistentIdentity().toString(), localId, moduleDefinition.getVersion());
    if (this.getSBOLDocument() != null && this.getSBOLDocument().isCreateDefaults() && moduleDefinition != null && moduleDefinition.getFunctionalComponent(localURI) == null) {
        moduleDefinition.createFunctionalComponent(localId, AccessType.PUBLIC, localId, "", DirectionType.INOUT);
    }
    URI remoteURI = URIcompliance.createCompliantURI(getDefinition().getPersistentIdentity().toString(), remoteId, getDefinition().getVersion());
    return createMapsTo(displayId, refinement, localURI, remoteURI);
}
Also used : URI(java.net.URI) URIcompliance.createCompliantURI(org.sbolstandard.core2.URIcompliance.createCompliantURI)

Example 9 with URIcompliance.createCompliantURI

use of org.sbolstandard.core2.URIcompliance.createCompliantURI in project libSBOLj by SynBioDex.

the class VariableComponent method addVariantDerivation.

/**
 * Adds the given variant derivation to the list of variant derivations.
 *
 * @param uriPrefix
 * 			URI prefix for variant derivation
 * @param displayId
 *          display id for variant derivation
 * @param version
 *          version for variant derivation
 * @throws SBOLValidationException if the following SBOL validation rule was violated:
 */
public void addVariantDerivation(String uriPrefix, String displayId, String version) throws SBOLValidationException {
    URI uri = URIcompliance.createCompliantURI(uriPrefix, displayId, version);
    CombinatorialDerivation combinatorialDerivation = this.getSBOLDocument().getCombinatorialDerivation(uri);
    addVariantDerivation(combinatorialDerivation.getIdentity());
}
Also used : URI(java.net.URI) URIcompliance.createCompliantURI(org.sbolstandard.core2.URIcompliance.createCompliantURI)

Example 10 with URIcompliance.createCompliantURI

use of org.sbolstandard.core2.URIcompliance.createCompliantURI in project libSBOLj by SynBioDex.

the class SequenceAnnotation method setComponent.

/**
 * Sets this sequence annotation's reference component (its identity URI) to the one matching
 * the given display ID.
 * <p>
 * This method first creates a compliant URI for the reference component. It starts with this sequence
 * annotation's parent component defintion's persistent identity URI, followed by the given display ID,
 * and ends with this sequence annotation's parent component defintion's version.
 *
 * @param displayId the given display ID for the reference component
 * @throws SBOLValidationException if either of the following conditions is satisfied:
 * <ul>
 * <li>either of the following SBOL validation rules was violated: 10204, 10206; or</li>
 * <li>if an SBOL validation rule violation occurred in any of the following constructors or methods:
 * 	<ul>
 * 		<li>{@link ComponentDefinition#createComponent(String, AccessType, String, String)}, or</li>
 * 		<li>{@link #setComponent(URI)}.</li>
 * 	</ul>
 * </li>
 * </ul>
 */
public void setComponent(String displayId) throws SBOLValidationException {
    URI componentURI = URIcompliance.createCompliantURI(componentDefinition.getPersistentIdentity().toString(), displayId, componentDefinition.getVersion());
    if (this.getSBOLDocument() != null && this.getSBOLDocument().isCreateDefaults() && componentDefinition != null && componentDefinition.getComponent(componentURI) == null) {
        componentDefinition.createComponent(displayId, AccessType.PUBLIC, displayId, "");
    }
    setComponent(componentURI);
}
Also used : URI(java.net.URI) URIcompliance.createCompliantURI(org.sbolstandard.core2.URIcompliance.createCompliantURI)

Aggregations

URI (java.net.URI)10 URIcompliance.createCompliantURI (org.sbolstandard.core2.URIcompliance.createCompliantURI)10