Search in sources :

Example 6 with Module

use of org.sbolstandard.core2.Module 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 a compliant URI for the mapsTo to be created. It starts with this module's persistent
 * identity, followed by the mapsTo's display ID, and ends with this module's version.
 *
 * @param displayId the display ID of the mapsTo to be created
 * @param refinement the relationship between the local and remote components
 * @param local the identity URI of the local functional component
 * @param remote the identity URI of the remote functional component
 * @return the created mapsTo
 * @throws SBOLValidationException if any of the following SBOL validation rules was violated:
 * 10201, 10202, 10204, 10206, 10802, 10803, 10804, 10805, 10807, 10808, 10809, 10811, 11609.
 */
public MapsTo createMapsTo(String displayId, RefinementType refinement, URI local, URI remote) throws SBOLValidationException {
    String parentPersistentIdStr = this.getPersistentIdentity().toString();
    String version = this.getVersion();
    URI newMapsToURI = createCompliantURI(parentPersistentIdStr, displayId, version);
    MapsTo m = createMapsTo(newMapsToURI, refinement, local, remote);
    m.setPersistentIdentity(createCompliantURI(parentPersistentIdStr, displayId, ""));
    m.setDisplayId(displayId);
    m.setVersion(version);
    return m;
}
Also used : URI(java.net.URI) URIcompliance.createCompliantURI(org.sbolstandard.core2.URIcompliance.createCompliantURI)

Example 7 with Module

use of org.sbolstandard.core2.Module in project libSBOLj by SynBioDex.

the class ModuleDefinition method createFunctionalComponent.

/**
 * Creates a child functional component for this module definition with the given arguments, and then adds to this
 * module definition's list of functional components.
 * <p>
 * This method creates a compliant URI for the functional component to be created. It starts with
 * this component defintion's persistent identity, followed by the given functional component's display ID,
 * and ends with this module definition's version.
 *
 * @param displayId the display ID of the functional component to be created
 * @param access the access property of the functional component to be created
 * @param definitionURI the identity URI of the component definition referenced by the functional component to be created
 * @param direction the direction property of the functional component to be created
 * @return the created functional component
 * @throws SBOLValidationException if any of the following SBOL validation rules was violated:
 * 10201, 10202, 10204, 10206, 10602, 10604, 10607, 11802, 10804.
 */
public FunctionalComponent createFunctionalComponent(String displayId, AccessType access, URI definitionURI, DirectionType direction) throws SBOLValidationException {
    if (this.getSBOLDocument() != null && this.getSBOLDocument().isComplete()) {
        if (this.getSBOLDocument().getComponentDefinition(definitionURI) == null) {
            throw new SBOLValidationException("sbol-10604", this);
        }
    }
    String URIprefix = this.getPersistentIdentity().toString();
    String version = this.getVersion();
    URI functionalComponentURI = createCompliantURI(URIprefix, displayId, version);
    FunctionalComponent fc = createFunctionalComponent(functionalComponentURI, access, definitionURI, direction);
    fc.setPersistentIdentity(createCompliantURI(URIprefix, displayId, ""));
    fc.setDisplayId(displayId);
    fc.setVersion(version);
    return fc;
}
Also used : URI(java.net.URI) URIcompliance.createCompliantURI(org.sbolstandard.core2.URIcompliance.createCompliantURI)

Example 8 with Module

use of org.sbolstandard.core2.Module in project libSBOLj by SynBioDex.

the class ModuleDefinition method flattenRecurse.

/**
 * @return flattened ModuleDefinition
 * @throws SBOLValidationException if either of the following condition is satisfied:
 * <ul>
 * <li>The following SBOL validation rule was violated: 10811; or</li>
 *
 * <li>if an SBOL validation rule violation occurred in any of the following methods:</li>
 *	 <ul>
 *     	<li>{@link #deepCopy()},</li>
 * 		<li>{@link #flattenRecurse()},</li>
 * 		<li>{@link FunctionalComponent#setDefinition(URI)},</li>
 * 		<li>{@link FunctionalComponent#deepCopy()},</li>
 * 		<li>{@link FunctionalComponent#updateCompliantURI(String, String, String)},</li>
 * 		<li>{@link #addFunctionalComponent(FunctionalComponent)},</li>
 * 		<li>{@link Participation#setParticipant(URI)},</li>
 * 		<li>{@link #addInteraction(Interaction)}, or</li>
 * 		<li>{@link Interaction#deepCopy()}.</li>
 * 	</ul>
 * </ul>
 */
private ModuleDefinition flattenRecurse() throws SBOLValidationException {
    ModuleDefinition flatModuleDefinition = this.deepCopy();
    for (Module module : this.getModules()) {
        ModuleDefinition flatModule = module.getDefinition().flattenRecurse();
        for (FunctionalComponent fc : flatModule.getFunctionalComponents()) {
            boolean foundIt = false;
            URI oldURI = fc.getIdentity();
            URI newURI = null;
            for (MapsTo mapsTo : module.getMapsTos()) {
                if (mapsTo.getRemoteURI().equals(fc.getIdentity())) {
                    newURI = mapsTo.getLocalURI();
                    FunctionalComponent topFc = flatModuleDefinition.getFunctionalComponent(newURI);
                    if (mapsTo.getRefinement() == RefinementType.USEREMOTE) {
                        topFc.setDefinition(fc.getDefinitionURI());
                    } else if (mapsTo.getRefinement() == RefinementType.VERIFYIDENTICAL) {
                        if (!topFc.getDefinitionURI().equals(fc.getDefinitionURI())) {
                            // + "' are not identical.");
                            throw new SBOLValidationException("sbol-10811", mapsTo);
                        }
                    } else if (mapsTo.getRefinement() == RefinementType.MERGE) {
                    // TODO: merge?
                    }
                    foundIt = true;
                    break;
                }
            }
            if (!foundIt) {
                FunctionalComponent newFC = fc.deepCopy();
                newFC.updateCompliantURI(this.getPersistentIdentity().toString(), module.getDisplayId() + "__" + fc.getDisplayId(), this.getVersion());
                newURI = newFC.getIdentity();
                flatModuleDefinition.addFunctionalComponent(newFC);
            }
            for (Interaction i : flatModule.getInteractions()) {
                for (Participation p : i.getParticipations()) {
                    if (p.getParticipantURI().equals(oldURI)) {
                        p.setParticipant(newURI);
                    }
                }
            }
        }
        for (Interaction i : flatModule.getInteractions()) {
            flatModuleDefinition.addInteraction(i.deepCopy());
        }
    }
    flatModuleDefinition.clearModules();
    return flatModuleDefinition;
}
Also used : URI(java.net.URI) URIcompliance.createCompliantURI(org.sbolstandard.core2.URIcompliance.createCompliantURI)

Example 9 with Module

use of org.sbolstandard.core2.Module in project libSBOLj by SynBioDex.

the class ModuleDefinition method getModelIdentities.

/**
 * Returns the set of models identities referenced by this module definition.
 *
 * @return the set of models identities referenced by this module definition
 */
public Set<URI> getModelIdentities() {
    Set<URI> result = new HashSet<>();
    for (URI modelURI : models) {
        Model model = this.getSBOLDocument().getModel(modelURI);
        result.add(model.getIdentity());
    }
    return result;
}
Also used : URI(java.net.URI) URIcompliance.createCompliantURI(org.sbolstandard.core2.URIcompliance.createCompliantURI) HashSet(java.util.HashSet)

Example 10 with Module

use of org.sbolstandard.core2.Module in project libSBOLj by SynBioDex.

the class ModuleDefinition method createModule.

/**
 * Creates a child module for this module definition with the
 * given arguments, and then adds to this module definition's list of modules.
 * <p>
 * This method creates a compliant Module URI with the default URI prefix
 * for this SBOLDocument instance, the given display ID of the module to be created, and this
 * module definition's version.
 *
 * @param displayId the display ID for the module to be created
 * @param moduleDefinitionURI the identity URI of the module definition referenced by the module to be created
 * @return the created module
 * @throws SBOLValidationException if any of the following SBOL validation rules was violated:
 * 10201, 10202, 10204, 10206, 10804, 11702, 11703, 11704, 11705.
 */
public Module createModule(String displayId, URI moduleDefinitionURI) throws SBOLValidationException {
    if (this.getSBOLDocument() != null && this.getSBOLDocument().isComplete()) {
        if (this.getSBOLDocument().getModuleDefinition(moduleDefinitionURI) == null) {
            throw new SBOLValidationException("sbol-11703", this);
        }
    }
    String URIprefix = this.getPersistentIdentity().toString();
    String version = this.getVersion();
    URI newModuleURI = createCompliantURI(URIprefix, displayId, version);
    Module m = createModule(newModuleURI, moduleDefinitionURI);
    m.setPersistentIdentity(createCompliantURI(URIprefix, displayId, ""));
    m.setDisplayId(displayId);
    m.setVersion(version);
    return m;
}
Also used : URI(java.net.URI) URIcompliance.createCompliantURI(org.sbolstandard.core2.URIcompliance.createCompliantURI)

Aggregations

URI (java.net.URI)19 URIcompliance.createCompliantURI (org.sbolstandard.core2.URIcompliance.createCompliantURI)16 HashSet (java.util.HashSet)5 ModuleDefinition (org.sbolstandard.core2.ModuleDefinition)5 QName (javax.xml.namespace.QName)3 ComponentDefinition (org.sbolstandard.core2.ComponentDefinition)3 Interaction (org.sbolstandard.core2.Interaction)3 Module (org.sbolstandard.core2.Module)3 SBOLDocument (org.sbolstandard.core2.SBOLDocument)3 ArrayList (java.util.ArrayList)2 IdentifiableDocument (org.sbolstandard.core.datatree.IdentifiableDocument)2 Literal (org.sbolstandard.core.datatree.Literal)2 NestedDocument (org.sbolstandard.core.datatree.NestedDocument)2 StringifyQName (org.sbolstandard.core.io.json.StringifyQName)2 FunctionalComponent (org.sbolstandard.core2.FunctionalComponent)2 SequenceOntology (org.sbolstandard.core2.SequenceOntology)2 DefaultInitializeArgs (iaik.pkcs.pkcs11.DefaultInitializeArgs)1 Module (iaik.pkcs.pkcs11.Module)1 TokenException (iaik.pkcs.pkcs11.TokenException)1 PKCS11Exception (iaik.pkcs.pkcs11.wrapper.PKCS11Exception)1