Search in sources :

Example 16 with ModuleDefinition

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

the class ModuleDefinitionTest method test_moduleDefinitionDeepCopy.

@Test
public void test_moduleDefinitionDeepCopy() throws SBOLValidationException {
    SBOLDocument doc_copy = new SBOLDocument();
    doc_copy.setDefaultURIprefix("http://sbols.org/CRISPR_Example/");
    doc_copy.setComplete(false);
    doc_copy.setCreateDefaults(true);
    doc_copy.createCopy(geneticToggleSwitch);
    ModuleDefinition TetRInverter_copy = doc_copy.getModuleDefinition("geneticToggleSwitch", "");
    assertTrue(TetRInverter_copy.getModule("TetRInverter").equals(TetRInverter));
    assertTrue(doc_copy.createRecursiveCopy(geneticToggleSwitch).equals(doc));
}
Also used : ModuleDefinition(org.sbolstandard.core2.ModuleDefinition) SBOLDocument(org.sbolstandard.core2.SBOLDocument) Test(org.junit.Test)

Example 17 with ModuleDefinition

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

the class SimpleModuleDefinition method main.

public static void main(String[] args) throws Exception {
    SBOLDocument document = new SBOLDocument();
    setDefaultNameSpace(document, example.getNamespaceURI());
    document.setTypesInURIs(true);
    ModuleDefinition module = document.createModuleDefinition("GFP_expression");
    FunctionalComponent cds = module.createFunctionalComponent("Constitutive_GFP", AccessType.PUBLIC, URI.create("http://sbolstandard.org/example/GFP_generator"), DirectionType.IN);
    FunctionalComponent protein = module.createFunctionalComponent("GFP_protein", AccessType.PUBLIC, URI.create("http://sbolstandard.org/example/GFP"), DirectionType.OUT);
    Interaction interaction = module.createInteraction("express_GFP", new HashSet<URI>(Arrays.asList(URI.create("Transcription"))));
    interaction.createParticipation("CDS", cds.getIdentity(), SystemsBiologyOntology.PROMOTER);
    interaction.createParticipation("Protein", protein.getIdentity(), SystemsBiologyOntology.PRODUCT);
    SBOLWriter.write(document, (System.out));
}
Also used : ModuleDefinition(org.sbolstandard.core2.ModuleDefinition) Interaction(org.sbolstandard.core2.Interaction) SBOLDocument(org.sbolstandard.core2.SBOLDocument) FunctionalComponent(org.sbolstandard.core2.FunctionalComponent) URI(java.net.URI)

Example 18 with ModuleDefinition

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

the class TestCircularModules method main.

// Check if an SBOLValidationException is thrown in every run, and check if it throws the right exception.
/**
 * Tests circular reference between ModuleDefinition and Module (validation rules 11704 and 11705).
 * @param args
 * @throws Exception
 */
public static void main(String[] args) throws Exception {
    ModuleDefModuleTree tree = new ModuleDefModuleTree(maxDepth, numOfModules);
    tree.setRandomSeed(12);
    for (int i = 0; i < numOfRuns; i++) {
        boolean exceptionCaught = false;
        // String expectedError = null;
        try {
            tree.generateModel();
        } catch (SBOLValidationException e) {
            exceptionCaught = true;
            if (!e.getMessage().contains(tree.getExpectedError())) {
                throw new Exception("Unexpected exception!");
            }
        }
        if (!exceptionCaught) {
            throw new Exception("Exception NOT caught!");
        }
    }
}
Also used : SBOLValidationException(org.sbolstandard.core2.SBOLValidationException) SBOLValidationException(org.sbolstandard.core2.SBOLValidationException)

Example 19 with ModuleDefinition

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

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

the class ModuleDefModuleTree method generateModel.

public String generateModel() throws SBOLValidationException, IOException, SBOLConversionException {
    SBOLDocument doc = new SBOLDocument();
    String version = "1.0";
    doc.setDefaultURIprefix("http://sbols.org/CRISPR_Example/");
    doc.setComplete(true);
    doc.setCreateDefaults(true);
    ModuleDefinition md1 = doc.createModuleDefinition("md_top", version);
    ArrayList<String> mdNames = new ArrayList<String>();
    mdNames.add("md_top");
    int depth = maxDepth;
    ArrayList<Integer> address = new ArrayList<Integer>();
    int selectedDepth = randInt(1, maxDepth);
    for (int i = 0; i < selectedDepth; i++) {
        addrCirfRef.add(randInt(1, numOfModules));
    }
    System.out.println("depth = " + depth);
    System.out.println("mdNames = " + mdNames);
    System.out.println("address = " + address);
    System.out.println("addrSelfRef = " + addrCirfRef);
    createModuleMDGraph(doc, depth, mdNames, address, md1);
    SBOLWriter.write(doc, "TestCircularModules.rdf");
    System.out.println("Finished writing.");
    // SBOLReader.read("/Users/zhangz/libSBOLproject/libSBOLj/examples/TestCircularModules.rdf");
    // SBOLReader.read("/Users/zhangz/libSBOLproject/libSBOLj/core2/src/test/resources/test/data/Validation/sbol-11705.rdf");
    SBOLValidate.validateSBOL(doc, true, true, true);
    if (SBOLValidate.getNumErrors() > 0) {
        for (String error : SBOLValidate.getErrors()) {
            System.out.println("TEST: error = " + error);
        }
    }
    return expectedError;
}
Also used : ModuleDefinition(org.sbolstandard.core2.ModuleDefinition) SBOLDocument(org.sbolstandard.core2.SBOLDocument) ArrayList(java.util.ArrayList)

Aggregations

URI (java.net.URI)15 URIcompliance.createCompliantURI (org.sbolstandard.core2.URIcompliance.createCompliantURI)10 ModuleDefinition (org.sbolstandard.core2.ModuleDefinition)8 SBOLDocument (org.sbolstandard.core2.SBOLDocument)7 ArrayList (java.util.ArrayList)4 QName (javax.xml.namespace.QName)4 ComponentDefinition (org.sbolstandard.core2.ComponentDefinition)4 FunctionalComponent (org.sbolstandard.core2.FunctionalComponent)4 Interaction (org.sbolstandard.core2.Interaction)4 HashSet (java.util.HashSet)3 IdentifiableDocument (org.sbolstandard.core.datatree.IdentifiableDocument)3 Literal (org.sbolstandard.core.datatree.Literal)3 StringifyQName (org.sbolstandard.core.io.json.StringifyQName)3 Module (org.sbolstandard.core2.Module)3 Before (org.junit.Before)2 NestedDocument (org.sbolstandard.core.datatree.NestedDocument)2 SequenceOntology (org.sbolstandard.core2.SequenceOntology)2 Test (org.junit.Test)1 CombinatorialDerivation (org.sbolstandard.core2.CombinatorialDerivation)1 GenericTopLevel (org.sbolstandard.core2.GenericTopLevel)1