Search in sources :

Example 96 with SBOLValidationException

use of org.sbolstandard.core2.SBOLValidationException 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 97 with SBOLValidationException

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

the class ModuleTest method test_MapsTo.

@Test
public void test_MapsTo() throws SBOLValidationException {
    MapsTo TetRInverterMap = TetRInverter.createMapsTo("TetRInverterMap", RefinementType.USEREMOTE, TetRInverter_fc.getDisplayId(), TF_TetR_fc.getDisplayId());
    MapsTo LacIInverterMap = LacIInverter.createMapsTo("LacIInverterMap", RefinementType.USEREMOTE, LacIInverter_fc.getDisplayId(), TF_LacI_fc.getDisplayId());
    assertTrue(TetRInverter.getMapsTo("TetRInverterMap").equals(TetRInverterMap));
    assertTrue(TetRInverter.getMapsTo(TetRInverterMap.getIdentity()).equals(TetRInverterMap));
    assertTrue(LacIInverter.getMapsTo("LacIInverterMap").equals(LacIInverterMap));
    assertTrue(LacIInverter.getMapsTo(LacIInverterMap.getIdentity()).equals(LacIInverterMap));
    TetRInverter.removeMapsTo(TetRInverterMap);
    assertTrue(TetRInverter.getMapsTos().size() == 0);
}
Also used : MapsTo(org.sbolstandard.core2.MapsTo) Test(org.junit.Test)

Example 98 with SBOLValidationException

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

Example 99 with SBOLValidationException

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

the class ModuleDefModuleTree method createModuleMDGraph.

public void createModuleMDGraph(SBOLDocument doc, int depth, ArrayList<String> mdNames, ArrayList<Integer> address, ModuleDefinition parentMd) throws SBOLValidationException {
    // System.out.println("depth = " + depth);
    if (depth > 0) {
        for (int i = 1; i <= numOfModules; i++) {
            address.add(i);
            System.out.println("address = " + intArrayListToString(address));
            System.out.println("addrSelfRef = " + intArrayListToString(addrCirfRef));
            String mdId = "md_" + intArrayListToString(address);
            String mId = "m_" + intArrayListToString(address);
            System.out.println("mdId = " + mdId);
            // System.out.println("mId = " + mId);
            if (intArrayListToString(address).equals(intArrayListToString(addrCirfRef))) {
                int circularRefIndex = randInt(0, mdNames.size() - 1);
                // int circleRefIndex = mdNames.size()-1; // Force 10704 to occur.
                System.out.println("circleRefIndex = " + circularRefIndex);
                System.out.println("address = " + intArrayListToString(address));
                System.out.println("addrCirRef = " + intArrayListToString(addrCirfRef));
                System.out.println("mdNames = " + mdNames);
                if (circularRefIndex == mdNames.size() - 1) {
                    System.out.println("Expect 11704");
                    expectedError = "11704";
                } else {
                    System.out.println("Expect 11705");
                    expectedError = "11705";
                }
                System.out.println("Last module displayId (mId) = " + mId);
                System.out.println("parentMd displayId = " + parentMd.getDisplayId());
                System.out.println("mdName = " + mdNames.get(circularRefIndex));
                // create the circular reference from module with mId to module definition selected by mdNames.get(circularRefIndex).
                parentMd.createModule(mId, mdNames.get(circularRefIndex));
            } else {
                ModuleDefinition childMd = doc.createModuleDefinition(mdId);
                parentMd.createModule(mId, mdId);
                mdNames.add(mdId);
                // System.out.println(mdId);
                // System.out.println("Interm. Module displayId = " + m.getDisplayId());
                System.out.println("mdNames = " + mdNames);
                createModuleMDGraph(doc, depth - 1, mdNames, address, childMd);
                mdNames.remove(mdId);
            }
            address.remove(address.size() - 1);
        }
    }
}
Also used : ModuleDefinition(org.sbolstandard.core2.ModuleDefinition)

Example 100 with SBOLValidationException

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

the class Provenance_StrainDerivation 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)

Aggregations

URI (java.net.URI)81 URIcompliance.createCompliantURI (org.sbolstandard.core2.URIcompliance.createCompliantURI)75 QName (javax.xml.namespace.QName)36 HashSet (java.util.HashSet)35 ArrayList (java.util.ArrayList)31 Literal (org.sbolstandard.core.datatree.Literal)30 StringifyQName (org.sbolstandard.core.io.json.StringifyQName)30 IdentifiableDocument (org.sbolstandard.core.datatree.IdentifiableDocument)17 Test (org.junit.Test)16 NestedDocument (org.sbolstandard.core.datatree.NestedDocument)13 ComponentDefinition (org.sbolstandard.core2.ComponentDefinition)9 SBOLDocument (org.sbolstandard.core2.SBOLDocument)9 ModuleDefinition (org.sbolstandard.core2.ModuleDefinition)6 Sequence (org.sbolstandard.core2.Sequence)5 Interaction (org.sbolstandard.core2.Interaction)4 GenericTopLevel (org.sbolstandard.core2.GenericTopLevel)3 MapsTo (org.sbolstandard.core2.MapsTo)3 Set (java.util.Set)2 Annotation (org.sbolstandard.core2.Annotation)2 GenericLocation (org.sbolstandard.core2.GenericLocation)2