Search in sources :

Example 11 with ComponentDefinition

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

the class ComponentDefinitionOutput method createComponentDefinitionOutput.

public static SBOLDocument createComponentDefinitionOutput() throws SBOLValidationException {
    String prURI = "http://partsregistry.org/";
    String prPrefix = "pr";
    SBOLDocument document = new SBOLDocument();
    document.setTypesInURIs(true);
    document.addNamespace(URI.create(prURI), prPrefix);
    document.setDefaultURIprefix(prURI);
    Sequence seqpTetR = document.createSequence("BBa_R0040", "", "tccctatcagtgatagagattgacatccctatcagtgatagagatactgagcac", URI.create("http://www.chem.qmul.ac.uk/iubmb/misc/naseq.html"));
    Sequence seqRbs = document.createSequence("BBa_B0034", "", "aaagaggagaaa", URI.create("http://www.chem.qmul.ac.uk/iubmb/misc/naseq.html"));
    Sequence seqCds = document.createSequence("BBa_C0062", "", "atgcttatctgatatgactaaaatggtacattgtgaatattatttactcgcgatcatttatcctcattctatggttaaatctgatatttcaatcctagataattaccctaaaaaatggaggcaatattatgatgacgctaatttaataaaatatgatcctatagtagattattctaactccaatcattcaccaattaattggaatatatttgaaaacaatgctgtaaataaaaaatctccaaatgtaattaaagaagcgaaaacatcaggtcttatcactgggtttagtttccctattcatacggctaacaatggcttcggaatgcttagttttgcacattcagaaaaagacaactatatagatagtttatttttacatgcgtgtatgaacataccattaattgttccttctctagttgataattatcgaaaaataaatatagcaaataataaatcaaacaacgatttaaccaaaagagaaaaagaatgtttagcgtgggcatgcgaaggaaaaagctcttgggatatttcaaaaatattaggttgcagtgagcgtactgtcactttccatttaaccaatgcgcaaatgaaactcaatacaacaaaccgctgccaaagtatttctaaagcaattttaacaggagcaattgattgcccatactttaaaaattaataacactgatagtgctagtgtagatcac", URI.create("http://www.chem.qmul.ac.uk/iubmb/misc/naseq.html"));
    Sequence seqTer = document.createSequence("BBa_B0015", "", "ccaggcatcaaataaaacgaaaggctcagtcgaaagactgggcctttcgttttatctgttgtttgtcggtgaacgctctctactagagtcacactggctcaccttcgggtgggcctttctgcgtttata", URI.create("http://www.chem.qmul.ac.uk/iubmb/misc/naseq.html"));
    Sequence seqPluxR = document.createSequence("BBa_R0062", "", "acctgtaggatcgtacaggtttacgcaagaaaatggtttgttatagtcgaataaa", URI.create("http://www.chem.qmul.ac.uk/iubmb/misc/naseq.html"));
    ComponentDefinition pTetR = document.createComponentDefinition("BBa_R0040", "", new HashSet<URI>(Arrays.asList(ComponentDefinition.DNA)));
    pTetR.addRole(SequenceOntology.PROMOTER);
    pTetR.setName("pTetR");
    pTetR.setDescription("TetR repressible promoter");
    pTetR.addSequence(seqpTetR.getIdentity());
    ComponentDefinition rbs = document.createComponentDefinition("BBa_B0034", "", new HashSet<URI>(Arrays.asList(ComponentDefinition.DNA)));
    rbs.addRole(SequenceOntology.RIBOSOME_ENTRY_SITE);
    rbs.setName("BBa_B0034");
    rbs.setDescription("RBS based on Elowitz repressilator");
    rbs.addSequence(seqRbs.getIdentity());
    ComponentDefinition cds = document.createComponentDefinition("BBa_C0062", "", new HashSet<URI>(Arrays.asList(ComponentDefinition.DNA)));
    cds.addRole(SequenceOntology.CDS);
    cds.setName("luxR");
    cds.setDescription("luxR coding sequence");
    cds.addSequence(seqCds.getIdentity());
    ComponentDefinition ter = document.createComponentDefinition("BBa_B0015", "", new HashSet<URI>(Arrays.asList(ComponentDefinition.DNA)));
    ter.addRole(URI.create("http://identifiers.org/so/SO:0000141"));
    ter.setName("BBa_B0015");
    ter.setDescription("Double terminator");
    ter.addSequence(seqTer.getIdentity());
    ComponentDefinition pluxR = document.createComponentDefinition("BBa_R0062", "", new HashSet<URI>(Arrays.asList(ComponentDefinition.DNA)));
    // 
    pluxR.addRole(SequenceOntology.PROMOTER);
    pluxR.setName("pLuxR");
    pluxR.setDescription("LuxR inducible promoter");
    pluxR.addSequence(seqPluxR.getIdentity());
    ComponentDefinition device = document.createComponentDefinition("BBa_F2620", "", new HashSet<URI>(Arrays.asList(ComponentDefinition.DNA)));
    // biological region
    device.addRole(URI.create("http://identifiers.org/so/SO:00001411"));
    device.setName("BBa_F2620");
    device.setDescription("3OC6HSL -> PoPS Receiver");
    Component comPtetR = device.createComponent("pTetR", AccessType.PUBLIC, pTetR.getIdentity());
    Component comRbs = device.createComponent("rbs", AccessType.PUBLIC, rbs.getIdentity());
    Component comCds = device.createComponent("luxR", AccessType.PUBLIC, cds.getIdentity());
    Component comTer = device.createComponent("ter", AccessType.PUBLIC, ter.getIdentity());
    Component comPluxR = device.createComponent("pLuxR", AccessType.PUBLIC, pluxR.getIdentity());
    int start = 1;
    int end = seqPluxR.getElements().length();
    SequenceAnnotation anno = device.createSequenceAnnotation("anno1", "location1", start, end, OrientationType.INLINE);
    anno.setComponent(comPtetR.getIdentity());
    start = end + 1;
    end = seqRbs.getElements().length() + end + 1;
    SequenceAnnotation anno2 = device.createSequenceAnnotation("anno2", "location2", start, end, OrientationType.INLINE);
    anno2.setComponent(comRbs.getIdentity());
    start = end + 1;
    end = seqCds.getElements().length() + end + 1;
    SequenceAnnotation anno3 = device.createSequenceAnnotation("anno3", "location3", start, end, OrientationType.INLINE);
    anno3.setComponent(comCds.getIdentity());
    start = end + 1;
    end = seqTer.getElements().length() + end + 1;
    SequenceAnnotation anno4 = device.createSequenceAnnotation("anno4", "location4", start, end, OrientationType.INLINE);
    anno4.setComponent(comTer.getIdentity());
    start = end + 1;
    end = seqPluxR.getElements().length() + end + 1;
    SequenceAnnotation anno5 = device.createSequenceAnnotation("anno5", "location5", start, end, OrientationType.INLINE);
    anno5.setComponent(comPluxR.getIdentity());
    return document;
}
Also used : SBOLDocument(org.sbolstandard.core2.SBOLDocument) SequenceAnnotation(org.sbolstandard.core2.SequenceAnnotation) Sequence(org.sbolstandard.core2.Sequence) Component(org.sbolstandard.core2.Component) URI(java.net.URI) ComponentDefinition(org.sbolstandard.core2.ComponentDefinition)

Example 12 with ComponentDefinition

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

the class Provenance_CodonOptimization method main.

public static void main(String[] args) throws Exception {
    NamespaceBinding myAppNs = NamespaceBinding("http://myapp.com/", "myapp");
    SBOLDocument document = new SBOLDocument();
    document.addNamespace(URI.create(myAppNs.getNamespaceURI()), myAppNs.getPrefix());
    document.setDefaultURIprefix(myAppNs.getNamespaceURI());
    ComponentDefinition optimizedCds = getCds(document, "codon_optimized", "Codon optimised CDS");
    ComponentDefinition sourceCds = getCds(document, "non_codon_optimized", "Non Codon optimised CDS");
    optimizedCds.addWasDerivedFrom(sourceCds.getIdentity());
    // Create the agent definition for the codon optimization software
    Agent agent = document.createAgent("codon_optimization_software");
    agent.setName("Codon Optimization Software");
    // Create the generic top level entity for the codon optimization activity
    Activity activity = document.createActivity("codon_optimization_activity");
    activity.setName("Codon Optimization Activity");
    // Create the qualifiedUsage annotation to describe the use of the non codon optimized CDS component
    activity.createUsage("usage", sourceCds.getIdentity()).addRole(URI.create("http://sbols.org/v2#source"));
    // Create the qualifiedAssociation annotation to describe the use of the software agent used in the activity
    activity.createAssociation("association", agent.getIdentity()).addRole(myAppNs.namespacedUri("codonoptimiser"));
    optimizedCds.addWasGeneratedBy(activity.getIdentity());
    SBOLWriter.write(document, System.out);
}
Also used : Agent(org.sbolstandard.core2.Agent) SBOLDocument(org.sbolstandard.core2.SBOLDocument) Activity(org.sbolstandard.core2.Activity) NamespaceBinding(org.sbolstandard.core.datatree.Datatree.NamespaceBinding) NamespaceBinding(org.sbolstandard.core.datatree.NamespaceBinding) ComponentDefinition(org.sbolstandard.core2.ComponentDefinition)

Example 13 with ComponentDefinition

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

the class Provenance_CodonOptimization method getCds.

private static ComponentDefinition getCds(SBOLDocument document, String id, String name) throws SBOLValidationException {
    ComponentDefinition cds = document.createComponentDefinition(id, ComponentDefinition.DNA);
    cds.addRole(SequenceOntology.CDS);
    cds.setName(name);
    return cds;
}
Also used : ComponentDefinition(org.sbolstandard.core2.ComponentDefinition)

Example 14 with ComponentDefinition

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

the class CombinatorialDerivation method addVariableComponentNoCheck.

/**
 * Adds the given variable component to the list of variable components.
 *
 * @param variableComponent
 */
private void addVariableComponentNoCheck(VariableComponent variableComponent) throws SBOLValidationException {
    variableComponent.setSBOLDocument(this.getSBOLDocument());
    variableComponent.setCombinatorialDerivation(this);
    ComponentDefinition template = this.getTemplate();
    if (template != null) {
        if (template.getComponent(variableComponent.getVariableURI()) == null) {
            throw new SBOLValidationException("sbol-13005", this);
        }
    }
    for (URI cdURI : variableComponent.getVariantDerivationURIs()) {
        if (this.getSBOLDocument() != null && this.getSBOLDocument().isComplete()) {
            CombinatorialDerivation cd = this.getSBOLDocument().getCombinatorialDerivation(cdURI);
            if (cd != null && this.getIdentity().equals(cd.getIdentity())) {
                throw new SBOLValidationException("sbol-13015", variableComponent);
            }
        }
    }
    addChildSafely(variableComponent, variableComponents, "variableComponent");
}
Also used : URI(java.net.URI) URIcompliance.createCompliantURI(org.sbolstandard.core2.URIcompliance.createCompliantURI)

Example 15 with ComponentDefinition

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

the class SBOLReader method parseCombinatorialDerivation.

/**
 * @param SBOLDoc
 * @param topLevel
 * @param nested
 * @return
 */
@SuppressWarnings("unchecked")
private static CombinatorialDerivation parseCombinatorialDerivation(SBOLDocument SBOLDoc, IdentifiableDocument<QName> topLevel, Map<URI, NestedDocument<QName>> nested) throws SBOLValidationException {
    // URIcompliance.extractDisplayId(topLevel.getIdentity());
    String displayId = null;
    String name = null;
    String description = null;
    // URI.create(URIcompliance.extractPersistentId(topLevel.getIdentity()));
    URI persistentIdentity = null;
    URI template = null;
    StrategyType strategy = null;
    String version = null;
    Set<URI> wasDerivedFroms = new HashSet<>();
    Set<URI> wasGeneratedBys = new HashSet<>();
    Set<URI> attachments = new HashSet<>();
    Set<VariableComponent> variableComponents = new HashSet<>();
    List<Annotation> annotations = new ArrayList<>();
    for (NamedProperty<QName> namedProperty : topLevel.getProperties()) {
        if (namedProperty.getName().equals(Sbol2Terms.Identified.version)) {
            if (!(namedProperty.getValue() instanceof Literal) || version != null || (!(((Literal<QName>) namedProperty.getValue()).getValue() instanceof String))) {
                throw new SBOLValidationException("sbol-10206", topLevel.getIdentity());
            }
            version = ((Literal<QName>) namedProperty.getValue()).getValue().toString();
        } else if (namedProperty.getName().equals(Sbol2Terms.Identified.persistentIdentity)) {
            if (!(namedProperty.getValue() instanceof Literal) || persistentIdentity != null || (!(((Literal<QName>) namedProperty.getValue()).getValue() instanceof URI))) {
                throw new SBOLValidationException("sbol-10203", topLevel.getIdentity());
            }
            persistentIdentity = URI.create(((Literal<QName>) namedProperty.getValue()).getValue().toString());
        } else if (namedProperty.getName().equals(Sbol2Terms.CombinatorialDerivation.template)) {
            if (namedProperty.getValue() instanceof Literal) {
                if (!(((Literal<QName>) namedProperty.getValue()).getValue() instanceof URI)) {
                    throw new SBOLValidationException("sbol-12904", topLevel.getIdentity());
                }
                template = URI.create(((Literal<QName>) namedProperty.getValue()).getValue().toString());
            } else if (namedProperty.getValue() instanceof IdentifiableDocument) {
                if (((IdentifiableDocument<QName>) namedProperty).getType().equals(Sbol2Terms.ComponentDefinition.ComponentDefinition)) {
                    ComponentDefinition cd = parseComponentDefinition(SBOLDoc, (IdentifiableDocument<QName>) namedProperty.getValue(), nested);
                    template = cd.getIdentity();
                } else {
                    throw new SBOLValidationException("sbol-12904", topLevel.getIdentity());
                }
            } else {
                throw new SBOLValidationException("sbol-12904", topLevel.getIdentity());
            }
        } else if (namedProperty.getName().equals(Sbol2Terms.CombinatorialDerivation.strategy)) {
            if (!(namedProperty.getValue() instanceof Literal) || strategy != null || (!(((Literal<QName>) namedProperty.getValue()).getValue() instanceof URI))) {
                throw new SBOLValidationException("sbol-12902", topLevel.getIdentity());
            }
            String strategyTypeStr = ((Literal<QName>) namedProperty.getValue()).getValue().toString();
            try {
                strategy = StrategyType.convertToStrategyType(URI.create(strategyTypeStr));
            } catch (SBOLValidationException e) {
                throw new SBOLValidationException("sbol-12902", topLevel.getIdentity());
            }
        } else if (namedProperty.getName().equals(Sbol2Terms.Identified.displayId)) {
            if (!(namedProperty.getValue() instanceof Literal) || displayId != null || (!(((Literal<QName>) namedProperty.getValue()).getValue() instanceof String))) {
                throw new SBOLValidationException("sbol-10204", topLevel.getIdentity());
            }
            displayId = ((Literal<QName>) namedProperty.getValue()).getValue().toString();
        } else if (namedProperty.getName().equals(Sbol2Terms.CombinatorialDerivation.hasVariableComponent)) {
            if (namedProperty.getValue() instanceof NestedDocument) {
                NestedDocument<QName> nestedDocument = ((NestedDocument<QName>) namedProperty.getValue());
                if (nestedDocument.getType() == null || !nestedDocument.getType().equals(Sbol2Terms.VariableComponent.VariableComponent)) {
                    throw new SBOLValidationException("sbol-12906", topLevel.getIdentity());
                }
                variableComponents.add(parseVariableComponent(SBOLDoc, ((NestedDocument<QName>) namedProperty.getValue()), nested));
            } else {
                URI uri = (URI) ((Literal<QName>) namedProperty.getValue()).getValue();
                NestedDocument<QName> nestedDocument = nested.get(uri);
                if (nestedDocument == null || nestedDocument.getType() == null || !nestedDocument.getType().equals(Sbol2Terms.VariableComponent.VariableComponent)) {
                    throw new SBOLValidationException("sbol-12906", topLevel.getIdentity());
                }
                variableComponents.add(parseVariableComponent(SBOLDoc, nested.get(uri), nested));
            }
        } else if (namedProperty.getName().equals(Sbol2Terms.Identified.title)) {
            if (!(namedProperty.getValue() instanceof Literal) || name != null || (!(((Literal<QName>) namedProperty.getValue()).getValue() instanceof String))) {
                throw new SBOLValidationException("sbol-10212", topLevel.getIdentity());
            }
            name = ((Literal<QName>) namedProperty.getValue()).getValue().toString();
        } else if (namedProperty.getName().equals(Sbol2Terms.Identified.description)) {
            if (!(namedProperty.getValue() instanceof Literal) || description != null || (!(((Literal<QName>) namedProperty.getValue()).getValue() instanceof String))) {
                throw new SBOLValidationException("sbol-10213", topLevel.getIdentity());
            }
            description = ((Literal<QName>) namedProperty.getValue()).getValue().toString();
        } else if (namedProperty.getName().equals(Sbol2Terms.Identified.wasDerivedFrom)) {
            if (!(namedProperty.getValue() instanceof Literal) || (!(((Literal<QName>) namedProperty.getValue()).getValue() instanceof URI))) {
                throw new SBOLValidationException("sbol-10208", topLevel.getIdentity());
            }
            wasDerivedFroms.add(URI.create(((Literal<QName>) namedProperty.getValue()).getValue().toString()));
        } else if (namedProperty.getName().equals(Sbol2Terms.Identified.wasGeneratedBy)) {
            if (!(namedProperty.getValue() instanceof Literal) || (!(((Literal<QName>) namedProperty.getValue()).getValue() instanceof URI))) {
                throw new SBOLValidationException("sbol-10221", topLevel.getIdentity());
            }
            wasGeneratedBys.add(URI.create(((Literal<QName>) namedProperty.getValue()).getValue().toString()));
        } else if (namedProperty.getName().equals(Sbol2Terms.TopLevel.hasAttachment)) {
            if (namedProperty.getValue() instanceof Literal) {
                if (!(((Literal<QName>) namedProperty.getValue()).getValue() instanceof URI)) {
                    throw new SBOLValidationException("sbol-XXXXX", topLevel.getIdentity());
                }
                attachments.add(URI.create(((Literal<QName>) namedProperty.getValue()).getValue().toString()));
            } else if (namedProperty.getValue() instanceof IdentifiableDocument) {
                if (((IdentifiableDocument<QName>) namedProperty).getType().equals(Sbol2Terms.Attachment.Attachment)) {
                    Attachment attachment = parseAttachment(SBOLDoc, (IdentifiableDocument<QName>) namedProperty.getValue());
                    attachments.add(attachment.getIdentity());
                } else {
                    throw new SBOLValidationException("sbol-XXXXX", topLevel.getIdentity());
                }
            } else {
                throw new SBOLValidationException("sbol-XXXXX", topLevel.getIdentity());
            }
        } else {
            annotations.add(new Annotation(namedProperty));
        }
    }
    CombinatorialDerivation c = new CombinatorialDerivation(topLevel.getIdentity(), template);
    if (strategy != null)
        c.setStrategy(strategy);
    if (displayId != null)
        c.setDisplayId(displayId);
    if (persistentIdentity != null)
        c.setPersistentIdentity(persistentIdentity);
    if (name != null)
        c.setName(name);
    if (!variableComponents.isEmpty())
        c.setVariableComponents(variableComponents);
    if (description != null)
        c.setDescription(description);
    if (!annotations.isEmpty())
        c.setAnnotations(annotations);
    if (version != null)
        c.setVersion(version);
    c.setWasDerivedFroms(wasDerivedFroms);
    c.setWasGeneratedBys(wasGeneratedBys);
    c.setAttachments(attachments);
    CombinatorialDerivation oldC = SBOLDoc.getCombinatorialDerivation(topLevel.getIdentity());
    if (oldC == null) {
        SBOLDoc.addCombinatorialDerivation(c);
    } else {
        if (!c.equals(oldC)) {
            throw new SBOLValidationException("sbol-10202", c);
        }
    }
    return c;
}
Also used : StringifyQName(org.sbolstandard.core.io.json.StringifyQName) QName(javax.xml.namespace.QName) ArrayList(java.util.ArrayList) URIcompliance.createCompliantURI(org.sbolstandard.core2.URIcompliance.createCompliantURI) URI(java.net.URI) NestedDocument(org.sbolstandard.core.datatree.NestedDocument) IdentifiableDocument(org.sbolstandard.core.datatree.IdentifiableDocument) Literal(org.sbolstandard.core.datatree.Literal) HashSet(java.util.HashSet)

Aggregations

URI (java.net.URI)30 ComponentDefinition (org.sbolstandard.core2.ComponentDefinition)23 URIcompliance.createCompliantURI (org.sbolstandard.core2.URIcompliance.createCompliantURI)18 SBOLDocument (org.sbolstandard.core2.SBOLDocument)15 QName (javax.xml.namespace.QName)12 HashSet (java.util.HashSet)9 ArrayList (java.util.ArrayList)7 IdentifiableDocument (org.sbolstandard.core.datatree.IdentifiableDocument)7 Literal (org.sbolstandard.core.datatree.Literal)7 StringifyQName (org.sbolstandard.core.io.json.StringifyQName)7 Sequence (org.sbolstandard.core2.Sequence)7 NestedDocument (org.sbolstandard.core.datatree.NestedDocument)5 Activity (org.sbolstandard.core2.Activity)5 FunctionalComponent (org.sbolstandard.core2.FunctionalComponent)5 Component (org.sbolstandard.core2.Component)4 ModuleDefinition (org.sbolstandard.core2.ModuleDefinition)4 GenericTopLevel (org.sbolstandard.core2.GenericTopLevel)3 Interaction (org.sbolstandard.core2.Interaction)3 Module (org.sbolstandard.core2.Module)3 SequenceAnnotation (org.sbolstandard.core2.SequenceAnnotation)3