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));
}
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));
}
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!");
}
}
}
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;
}
}
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;
}
Aggregations