Search in sources :

Example 31 with Component

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

the class ModuleDefinitionOutput method addSubComponents.

private static void addSubComponents(SBOLDocument document, ComponentDefinition componentDef, List<ComponentDefinition> subComponents) throws Exception {
    int i = 1;
    int start = 0;
    int end = 0;
    for (ComponentDefinition subComponent : subComponents) {
        Component component = componentDef.createComponent(subComponent.getDisplayId(), AccessType.PUBLIC, subComponent.getIdentity());
        start = end + 1;
        end = start + getSequenceLength(document, subComponent);
        SequenceAnnotation annotation = componentDef.createSequenceAnnotation("anno" + i, "location" + i, start, end, OrientationType.INLINE);
        annotation.setComponent(component.getIdentity());
        i++;
    }
}
Also used : SequenceAnnotation(org.sbolstandard.core2.SequenceAnnotation) Component(org.sbolstandard.core2.Component) FunctionalComponent(org.sbolstandard.core2.FunctionalComponent) ComponentDefinition(org.sbolstandard.core2.ComponentDefinition)

Example 32 with Component

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

the class ModuleDefinitionOutput method getSequenceLength.

private static int getSequenceLength(SBOLDocument document, ComponentDefinition componentDef) throws Exception {
    if (componentDef.getSequences() != null && componentDef.getSequences().size() > 0) {
        Sequence sequence = componentDef.getSequences().iterator().next();
        return sequence.getElements().length();
    } else {
        int total = 0;
        for (SequenceAnnotation annotation : componentDef.getSequenceAnnotations()) {
            if (annotation.getComponent() != null) {
                Component component = annotation.getComponent();
                ComponentDefinition subComponentDef = component.getDefinition();
                total = total + getSequenceLength(document, subComponentDef);
            } else {
                throw new Exception("Can't get sequence length for an incomplete design");
            }
        }
        return total;
    }
}
Also used : SequenceAnnotation(org.sbolstandard.core2.SequenceAnnotation) Sequence(org.sbolstandard.core2.Sequence) Component(org.sbolstandard.core2.Component) FunctionalComponent(org.sbolstandard.core2.FunctionalComponent) SBOLValidationException(org.sbolstandard.core2.SBOLValidationException) ComponentDefinition(org.sbolstandard.core2.ComponentDefinition)

Example 33 with Component

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

the class SequenceConstraintOutput method main.

public static void main(String[] args) throws Exception {
    String prURI = "http://partsregistry.org/";
    SBOLDocument document = new SBOLDocument();
    document.setDefaultURIprefix(prURI);
    document.setTypesInURIs(true);
    ComponentDefinition promoter = document.createComponentDefinition("BBa_K174004", "", new HashSet<URI>(Arrays.asList(ComponentDefinition.DNA)));
    promoter.addRole(SequenceOntology.PROMOTER);
    promoter.setName("pspac promoter");
    promoter.setDescription("LacI repressible promoter");
    ComponentDefinition constPromoter = document.createComponentDefinition("pspac", "", new HashSet<URI>(Arrays.asList(ComponentDefinition.DNA)));
    constPromoter.addRole(SequenceOntology.PROMOTER);
    constPromoter.setName("constitutive promoter");
    constPromoter.setDescription("pspac core promoter region");
    ComponentDefinition operator = document.createComponentDefinition("LacI_operator", "", new HashSet<URI>(Arrays.asList(ComponentDefinition.DNA)));
    operator.addRole(SequenceOntology.OPERATOR);
    operator.setName("LacI operator");
    operator.setDescription("LacI binding site");
    Component promoterComponent = promoter.createComponent("promoter", AccessType.PUBLIC, constPromoter.getIdentity());
    Component operatorComponent = promoter.createComponent("operator", AccessType.PUBLIC, operator.getIdentity());
    promoter.createSequenceConstraint("r1", RestrictionType.PRECEDES, promoterComponent.getIdentity(), operatorComponent.getIdentity());
    SBOLWriter.write(document, (System.out));
}
Also used : SBOLDocument(org.sbolstandard.core2.SBOLDocument) Component(org.sbolstandard.core2.Component) URI(java.net.URI) ComponentDefinition(org.sbolstandard.core2.ComponentDefinition)

Example 34 with Component

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

the class MapsToExample method main.

public static void main(String[] args) throws URISyntaxException, SBOLValidationException {
    SBOLDocument doc = new SBOLDocument();
    doc.setDefaultURIprefix("http://sbols.org/MapsToExample/");
    doc.setComplete(true);
    doc.setCreateDefaults(true);
    String version = "";
    ModuleDefinition md1 = doc.createModuleDefinition("md1", version);
    ComponentDefinition fc1_def = doc.createComponentDefinition("fc1_def", version, ComponentDefinition.DNA);
    ComponentDefinition fc2_def = doc.createComponentDefinition("fc2_def", version, ComponentDefinition.DNA);
    FunctionalComponent fc1 = md1.createFunctionalComponent("fc1", AccessType.PUBLIC, "fc1_def", version, DirectionType.NONE);
    FunctionalComponent fc2 = md1.createFunctionalComponent("fc2", AccessType.PUBLIC, "fc2_def", version, DirectionType.NONE);
    ComponentDefinition cd = doc.createComponentDefinition("cd", version, ComponentDefinition.DNA);
    fc1_def.createComponent("component", AccessType.PUBLIC, "cd");
    fc1.createMapsTo("mapsTo", RefinementType.USELOCAL, "fc2", "component");
    SBOLValidate.validateSBOL(doc, true, true, true);
    if (SBOLValidate.getNumErrors() > 0) {
        for (String error : SBOLValidate.getErrors()) {
            System.out.println(error);
        }
        return;
    }
}
Also used : ModuleDefinition(org.sbolstandard.core2.ModuleDefinition) SBOLDocument(org.sbolstandard.core2.SBOLDocument) FunctionalComponent(org.sbolstandard.core2.FunctionalComponent) ComponentDefinition(org.sbolstandard.core2.ComponentDefinition)

Example 35 with Component

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