use of org.sbolstandard.core2.Module 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.Module 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.Module 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);
}
}
}
Aggregations