Search in sources :

Example 16 with Component

use of org.sbolstandard.core2.Component 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;
}
Also used : URI(java.net.URI) URIcompliance.createCompliantURI(org.sbolstandard.core2.URIcompliance.createCompliantURI) HashSet(java.util.HashSet)

Example 17 with Component

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

the class ComponentDefinition 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 constructors or 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)},</li>
 * <li>{@link #setIdentity(URI)}</li>
 * <li>{@link Component#setDisplayId(String)}</li>
 * <li>{@link Component#updateCompliantURI(String, String, String)},</li>
 * <li>{@link #addComponent(Component)},</li>
 * <li>{@link SequenceConstraint#setDisplayId(String)}</li>
 * <li>{@link SequenceConstraint#updateCompliantURI(String, String, String)},</li>
 * <li>{@link #addSequenceConstraint(SequenceConstraint)},</li>
 * <li>{@link SequenceAnnotation#setDisplayId(String)}</li>
 * <li>{@link SequenceAnnotation#updateCompliantURI(String, String, String)}, or</li>
 * <li>{@link #addSequenceAnnotation(SequenceAnnotation)},</li>
 * </ul>
 */
@Override
ComponentDefinition copy(String URIprefix, String displayId, String version) throws SBOLValidationException {
    ComponentDefinition 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);
    int count = 0;
    for (Component component : cloned.getComponents()) {
        if (!component.isSetDisplayId())
            component.setDisplayId("component" + ++count);
        component.updateCompliantURI(cloned.getPersistentIdentity().toString(), component.getDisplayId(), version);
        cloned.removeChildSafely(component, cloned.components);
        cloned.addComponent(component);
    }
    count = 0;
    for (SequenceConstraint sequenceConstraint : cloned.getSequenceConstraints()) {
        if (!sequenceConstraint.isSetDisplayId())
            sequenceConstraint.setDisplayId("sequenceConstraint" + ++count);
        sequenceConstraint.updateCompliantURI(cloned.getPersistentIdentity().toString(), sequenceConstraint.getDisplayId(), version);
        cloned.removeChildSafely(sequenceConstraint, cloned.sequenceConstraints);
        cloned.addSequenceConstraint(sequenceConstraint);
    }
    count = 0;
    for (SequenceAnnotation sequenceAnnotation : cloned.getSequenceAnnotations()) {
        if (!sequenceAnnotation.isSetDisplayId())
            sequenceAnnotation.setDisplayId("sequenceAnnotation" + ++count);
        sequenceAnnotation.updateCompliantURI(cloned.getPersistentIdentity().toString(), sequenceAnnotation.getDisplayId(), version);
        cloned.removeChildSafely(sequenceAnnotation, cloned.sequenceAnnotations);
        cloned.addSequenceAnnotation(sequenceAnnotation);
    }
    return cloned;
}
Also used : URI(java.net.URI) URIcompliance.createCompliantURI(org.sbolstandard.core2.URIcompliance.createCompliantURI)

Example 18 with Component

use of org.sbolstandard.core2.Component 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);
    }
}
Also used : URIcompliance.createCompliantURI(org.sbolstandard.core2.URIcompliance.createCompliantURI) URI(java.net.URI)

Example 19 with Component

use of org.sbolstandard.core2.Component 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 20 with Component

use of org.sbolstandard.core2.Component 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)

Aggregations

URI (java.net.URI)25 URIcompliance.createCompliantURI (org.sbolstandard.core2.URIcompliance.createCompliantURI)22 HashSet (java.util.HashSet)7 ComponentDefinition (org.sbolstandard.core2.ComponentDefinition)7 ArrayList (java.util.ArrayList)6 QName (javax.xml.namespace.QName)6 Point (java.awt.Point)5 Component (org.powerbot.script.rt6.Component)5 SBOLDocument (org.sbolstandard.core2.SBOLDocument)5 Condition (org.powerbot.script.Condition)4 Literal (org.sbolstandard.core.datatree.Literal)4 NestedDocument (org.sbolstandard.core.datatree.NestedDocument)4 StringifyQName (org.sbolstandard.core.io.json.StringifyQName)4 Component (org.sbolstandard.core2.Component)4 IdentifiableDocument (org.sbolstandard.core.datatree.IdentifiableDocument)3 FunctionalComponent (org.sbolstandard.core2.FunctionalComponent)3 Sequence (org.sbolstandard.core2.Sequence)3 SequenceAnnotation (org.sbolstandard.core2.SequenceAnnotation)3 Font (java.awt.Font)2 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)2