Search in sources :

Example 21 with Activity

use of spold2.Activity in project libSBOLj by SynBioDex.

the class Provenance_SpecifyBuildOperations method specifyAmplifyOperation.

/**
 * specifies the amplify operation, which amplifies a linear DNA construct using
 * 5' and 3' primers
 *
 * @throws Exception
 */
public static void specifyAmplifyOperation() throws Exception {
    // instantiate a document
    SBOLDocument document = new SBOLDocument();
    document.setDefaultURIprefix(BUILD_PREFIX);
    // the linear DNA construct
    ComponentDefinition dnaConstruct = document.createComponentDefinition("dna_construct", LINEAR_SINGLE_STRANDED_DNA);
    dnaConstruct.setName("dna_construct");
    // the 5' primer for amplification
    ComponentDefinition fivePrimer = document.createComponentDefinition("five_primer", FORWARD_PRIMER);
    fivePrimer.setName("five_primer");
    // the 3' primer for amplification
    ComponentDefinition threePrimer = document.createComponentDefinition("three_primer", REVERSE_PRIMER);
    threePrimer.setName("three_primer");
    // Create the generic top level entity for the amplify operation
    Activity amplifyOperation = document.createActivity("amplify_" + dnaConstruct.getName() + "_with_" + fivePrimer.getName() + "_and_" + threePrimer.getName());
    amplifyOperation.setName("amplify(" + dnaConstruct.getName() + ", " + fivePrimer.getName() + ", " + threePrimer.getName() + ")");
    // create the qualifiedUsage annotation to describe the inputs of the amplification operation
    // -- the amplicon
    Usage usageDNAConstruct = amplifyOperation.createUsage("dna_construct", dnaConstruct.getIdentity());
    usageDNAConstruct.addRole(URI.create("http://sbols.org/v2#source"));
    usageDNAConstruct.addRole(PCR_PRODUCT);
    // -- the forward primer
    Usage usageFwdPrimer = amplifyOperation.createUsage("forward_primer", fivePrimer.getIdentity());
    usageFwdPrimer.addRole(FORWARD_PRIMER);
    usageFwdPrimer.addRole(FORWARD_PRIMER);
    // -- the reverse primer
    Usage usageRevPrimer = amplifyOperation.createUsage("reverse_primer", threePrimer.getIdentity());
    usageRevPrimer.addRole(REVERSE_PRIMER);
    usageRevPrimer.addRole(REVERSE_PRIMER);
    // the result of the amplification operation
    ComponentDefinition amplified_construct = document.createComponentDefinition("my_amplified_dna", AMPLIFIED_CONSTRUCT);
    amplified_construct.setName("my_amplified_dna");
    amplified_construct.addWasGeneratedBy(amplifyOperation.getIdentity());
    // serialize the document to a file
    SBOLWriter.write(document, System.out);
}
Also used : Usage(org.sbolstandard.core2.Usage) SBOLDocument(org.sbolstandard.core2.SBOLDocument) Activity(org.sbolstandard.core2.Activity) ComponentDefinition(org.sbolstandard.core2.ComponentDefinition)

Example 22 with Activity

use of spold2.Activity 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 23 with Activity

use of spold2.Activity in project libSBOLj by SynBioDex.

the class Provenance_StrainDerivation 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 b168 = getCds(document, "bsubtilis168", "Bacillus subtilis 168");
    ComponentDefinition b3610 = getCds(document, "bsubtilisncimb3610", "Bacillus subtilis NCIMB 3610");
    b168.addWasDerivedFrom(b3610.getIdentity());
    // Create the agent definition to represent X-ray
    Agent agent = document.createAgent("x_ray");
    agent.setName("X-ray");
    // Create the generic top level entity for the X-ray mutagenesis activity
    Activity activity = document.createActivity("xraymutagenesis");
    activity.setName("X-ray mutagenesis");
    // Create the qualifiedUsage annotation to describe the use of the parent strain
    activity.createUsage("usage", b3610.getIdentity()).addRole(URI.create("http://sbols.org/v2#source"));
    // Create the qualifiedAssociation annotation to describe the use of the agent used in the activity
    activity.createAssociation("association", agent.getIdentity()).addRole(myAppNs.namespacedUri("mutagen"));
    b168.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 24 with Activity

use of spold2.Activity in project libSBOLj by SynBioDex.

the class SBOLWorkshop2018 method main.

public static void main(String[] args) throws SBOLValidationException, IOException, SBOLConversionException, SynBioHubException {
    /* Getting a Device from an SBOL Compliant XML */
    // Start a new SBOL Document to hold the device
    SBOLDocument doc = new SBOLDocument();
    doc.setCreateDefaults(true);
    // Set your Homespace. All new SBOL objects will be created in this namespace
    String my_namespace = "http://my_namespace.org/";
    doc.setDefaultURIprefix(my_namespace);
    // Create a new device
    ComponentDefinition my_device = doc.createComponentDefinition("my_device", version, ComponentDefinition.DNA_REGION);
    System.out.println(my_device.getIdentity());
    System.out.println("");
    // Load some genetic parts taken from the Cello paper
    // TODO: need to fill in path
    SBOLDocument cello_parts = SBOLReader.read("/Users/myers/Downloads/parts.xml");
    System.out.println(len(cello_parts));
    printCounts(cello_parts);
    System.out.println("");
    // componentDefinitions and sequences
    for (TopLevel topLevel : cello_parts.getTopLevels()) {
        System.out.println(topLevel.getIdentity());
    }
    System.out.println("");
    // Import these objects into your Document
    doc.createCopy(cello_parts);
    for (TopLevel topLevel : doc.getTopLevels()) {
        System.out.println(topLevel.getIdentity());
    }
    System.out.println("");
    // Retrieve an object from the Document using its uniform resource identifier (URI)
    Collection promoter_collection = doc.getCollection(URI.create("http://examples.org/Collection/promoters/1"));
    // A Collection contains a list of URI references to objects, not the object themselves
    for (TopLevel topLevel : promoter_collection.getMembers()) {
        System.out.println(topLevel.getIdentity());
    }
    System.out.println("");
    // Retrieve a component, using its full URI
    ComponentDefinition promoter = doc.getComponentDefinition(URI.create("http://examples.org/ComponentDefinition/pPhlF/1"));
    // Review the BioPAX and Sequence Ontology terms that describe this component
    System.out.println(promoter.getTypes());
    System.out.println(promoter.getRoles());
    System.out.println("");
    /* Getting a Device from Synbiohub */
    // Start an interface to the part shop
    SynBioHubFrontend part_shop = new SynBioHubFrontend("https://synbiohub.org");
    // Search for records from the interlab study
    ArrayList<IdentifiedMetadata> records = part_shop.getMatchingComponentDefinitionMetadata("interlab", null, null, null, 0, 50);
    for (IdentifiedMetadata record : records) {
        System.out.println(record.getDisplayId() + ": " + record.getUri());
    }
    System.out.println("");
    // Import the medium device into the user's Document
    doc.createCopy(part_shop.getSBOL(URI.create("https://synbiohub.org/public/iGEM_2016_interlab/Medium_2016Interlab/1")));
    // Explore the new parts
    for (TopLevel topLevel : doc.getTopLevels()) {
        System.out.println(topLevel.getClass().getSimpleName() + ": " + topLevel.getIdentity());
    }
    System.out.println("");
    /* Extracting a ComponentDefinition from a Pre-existing Device */
    // Extract the medium strength promoter
    ComponentDefinition medium_strength_promoter = doc.getComponentDefinition(URI.create("https://synbiohub.org/public/igem/BBa_J23106/1"));
    // Get parts for a new circuit
    ComponentDefinition rbs = doc.getComponentDefinition(URI.create("http://examples.org/ComponentDefinition/Q2/1"));
    ComponentDefinition cds = doc.getComponentDefinition(URI.create("http://examples.org/ComponentDefinition/LuxR/1"));
    ComponentDefinition terminator = doc.getComponentDefinition(URI.create("http://examples.org/ComponentDefinition/ECK120010818/1"));
    // Assemble a new gene
    my_device.createSequenceConstraint("constraint1", RestrictionType.PRECEDES, medium_strength_promoter.getIdentity(), rbs.getIdentity());
    my_device.createSequenceConstraint("constraint2", RestrictionType.PRECEDES, rbs.getIdentity(), cds.getIdentity());
    my_device.createSequenceConstraint("constraint3", RestrictionType.PRECEDES, cds.getIdentity(), terminator.getIdentity());
    // Annotate the target construct with a Sequence Ontology term
    my_device.addRole(SequenceOntology.ENGINEERED_REGION);
    // Explore the newly assembled gene
    for (Component component : my_device.getComponents()) {
        System.out.println(component.getDisplayId());
    }
    System.out.println("");
    compile(doc, my_device);
    Sequence seq = my_device.getSequenceByEncoding(Sequence.IUPAC_DNA);
    System.out.println(seq.getElements());
    System.out.println("");
    /* Managing a Design-Build-Test-Learn workflow */
    Activity workflow_step_1 = doc.createActivity("build_1", version);
    Activity workflow_step_2 = doc.createActivity("build_2", version);
    Activity workflow_step_3 = doc.createActivity("test_1", version);
    Activity workflow_step_4 = doc.createActivity("analysis_1", version);
    Plan workflow_step_1_plan = doc.createPlan("gibson_assembly", version);
    Plan workflow_step_2_plan = doc.createPlan("transformation", version);
    Plan workflow_step_3_plan = doc.createPlan("promoter_characterization", version);
    Plan workflow_step_4_plan = doc.createPlan("parameter_optimization", version);
    workflow_step_1.createAssociation("association", URI.create("mailto:jdoe@my_namespace.org")).setPlan(workflow_step_1_plan.getIdentity());
    workflow_step_2.createAssociation("association", URI.create("mailto:jdoe@my_namespace.org")).setPlan(workflow_step_2_plan.getIdentity());
    workflow_step_3.createAssociation("association", URI.create("http://sys-bio.org/plate_reader_1")).setPlan(workflow_step_3_plan.getIdentity());
    workflow_step_4.createAssociation("association", URI.create("http://tellurium.analogmachine.org")).setPlan(workflow_step_4_plan.getIdentity());
    Implementation gibson_mix = doc.createImplementation("gibson_mix", version);
    gibson_mix.setBuilt(my_device);
    gibson_mix.addWasGeneratedBy(workflow_step_1.getIdentity());
    workflow_step_1.createUsage("usage", my_device.getIdentity());
    Collection clones = doc.createCollection("clones", version);
    Implementation clone1 = doc.createImplementation("clone1", version);
    clone1.setBuilt(my_device);
    clones.addMember(clone1.getIdentity());
    Implementation clone2 = doc.createImplementation("clone2", version);
    clone2.setBuilt(my_device);
    clones.addMember(clone2.getIdentity());
    Implementation clone3 = doc.createImplementation("clone3", version);
    clone3.setBuilt(my_device);
    clones.addMember(clone3.getIdentity());
    clones.addWasGeneratedBy(workflow_step_2.getIdentity());
    workflow_step_2.createUsage("usage", gibson_mix.getIdentity());
    Collection experiment1 = doc.createCollection("experiment1", version);
    experiment1.addWasGeneratedBy(workflow_step_3.getIdentity());
    workflow_step_3.createUsage("usage", clones.getIdentity());
    Collection analysis1 = doc.createCollection("analysis1", version);
    analysis1.addWasGeneratedBy(workflow_step_4.getIdentity());
    workflow_step_4.createUsage("usage", experiment1.getIdentity());
    // Validate the Document
    SBOLValidate.validateSBOL(doc, false, false, false);
    for (String error : SBOLValidate.getErrors()) {
        System.out.println(error);
    }
    System.out.println(analysis1.getIdentity());
    System.out.println("");
    /* Uploading the Device back to SynBioHub */
    // TODO: Need to provide your credentials
    String user_name = "myers";
    String password = "MaWen69!";
    part_shop.login(user_name, password);
    // Upon submission, the Document will be converted to a Collection with the following properties
    // The new Collection will have a URI that conforms to the following pattern:
    // https://synbiohub.org/user/<USERNAME>/<DOC.DISPLAYID>/<DOC.DISPLAYID>_collection
    String displayId = "my_device";
    String name = "my device";
    String description = "a description of the cassette";
    part_shop.createCollection(displayId, version, name, description, "", true, doc);
    // TODO: need to fill in your path
    String attachment_path = "/Users/myers/Downloads/results.txt";
    // Attach raw experimental data to the Test object here. Note the pattern
    URI test_uri = URI.create("https://synbiohub.org/user/" + user_name + "/" + displayId + "/experiment1/1");
    part_shop.attachFile(test_uri, attachment_path);
    // Attach processed experimental data here
    // TODO: need to fill in your path
    String other_attachement_path = "/Users/myers/Downloads/results.txt";
    URI analysis_uri = URI.create("https://synbiohub.org/user/" + user_name + "/" + displayId + "/analysis1/1");
    part_shop.attachFile(analysis_uri, other_attachement_path);
    System.out.println("Successfully uploaded");
}
Also used : SBOLDocument(org.sbolstandard.core2.SBOLDocument) Activity(org.sbolstandard.core2.Activity) Sequence(org.sbolstandard.core2.Sequence) Plan(org.sbolstandard.core2.Plan) URI(java.net.URI) Implementation(org.sbolstandard.core2.Implementation) Collection(org.sbolstandard.core2.Collection) TopLevel(org.sbolstandard.core2.TopLevel) SynBioHubFrontend(org.synbiohub.frontend.SynBioHubFrontend) Component(org.sbolstandard.core2.Component) IdentifiedMetadata(org.synbiohub.frontend.IdentifiedMetadata) ComponentDefinition(org.sbolstandard.core2.ComponentDefinition)

Example 25 with Activity

use of spold2.Activity in project olca-modules by GreenDelta.

the class ProcessImport method getProcessName.

/**
 * The name of the process has the following pattern:
 * <p>
 * <process name> | <product name> | <system model>, <process type>
 * <p>
 * Where <system model> is a mnemonic like "APOS" or "Cutoff" and the process
 * type is "U" when it is a unit process or "S" when it is a LCI result
 */
private String getProcessName(DataSet ds) {
    // the process and ref. product name
    Activity a = Spold2.getActivity(ds);
    String name = a != null ? a.name : "?";
    IntermediateExchange qRef = Spold2.getReferenceProduct(ds);
    if (qRef != null && qRef.name != null) {
        name += " | " + qRef.name;
    }
    // we try to infer a short name for the system model here
    // because the short name is part of the master data which
    // is not always available (or can be found) when importing
    // a data set
    String model = null;
    Representativeness repri = Spold2.getRepresentativeness(ds);
    if (repri.systemModelName != null) {
        String sys = repri.systemModelName.toLowerCase();
        if (sys.contains("consequential")) {
            model = "Consequential";
        } else if (sys.contains("apos") || sys.contains("allocation at the point of substitution")) {
            model = "APOS";
        } else if (sys.contains("cut-off") || sys.contains("cutoff")) {
            model = "Cutoff";
        } else if (sys.contains("legacy")) {
            model = "Legacy";
        } else {
            model = repri.systemModelName;
        }
    }
    if (model != null) {
        name += " | " + model;
    }
    // the process type
    String type = a != null && a.type == 2 ? "S" : "U";
    name += ", " + type;
    return name;
}
Also used : Representativeness(spold2.Representativeness) IntermediateExchange(spold2.IntermediateExchange) Activity(spold2.Activity)

Aggregations

Activity (org.eclipse.bpmn2.Activity)21 FlowElement (org.eclipse.bpmn2.FlowElement)12 ArrayList (java.util.ArrayList)9 CallActivity (org.eclipse.bpmn2.CallActivity)9 CompensateEventDefinition (org.eclipse.bpmn2.CompensateEventDefinition)9 SubProcess (org.eclipse.bpmn2.SubProcess)9 ErrorEventDefinition (org.eclipse.bpmn2.ErrorEventDefinition)8 EventDefinition (org.eclipse.bpmn2.EventDefinition)8 MessageEventDefinition (org.eclipse.bpmn2.MessageEventDefinition)8 RootElement (org.eclipse.bpmn2.RootElement)8 SignalEventDefinition (org.eclipse.bpmn2.SignalEventDefinition)8 FeatureMap (org.eclipse.emf.ecore.util.FeatureMap)8 Entry (java.util.Map.Entry)7 ConditionalEventDefinition (org.eclipse.bpmn2.ConditionalEventDefinition)7 EscalationEventDefinition (org.eclipse.bpmn2.EscalationEventDefinition)7 FlowElementsContainer (org.eclipse.bpmn2.FlowElementsContainer)7 TimerEventDefinition (org.eclipse.bpmn2.TimerEventDefinition)7 SimpleFeatureMapEntry (org.eclipse.emf.ecore.impl.EStructuralFeatureImpl.SimpleFeatureMapEntry)7 AdHocSubProcess (org.eclipse.bpmn2.AdHocSubProcess)6 Escalation (org.eclipse.bpmn2.Escalation)6