use of org.sbolstandard.core2.SBOLDocument in project libSBOLj by SynBioDex.
the class GenericTopLevelOutput method main.
public static void main(String[] args) throws Exception {
String myAppURI = "http://www.myapp.org/";
String myAppPrefix = "myapp";
String prURI = "http://www.partsregistry.org/";
SBOLDocument document = new SBOLDocument();
document.addNamespace(URI.create(myAppURI + "/"), myAppPrefix);
document.setDefaultURIprefix(prURI);
document.setTypesInURIs(true);
GenericTopLevel topLevel = document.createGenericTopLevel("datasheet1", "", new QName("http://www.myapp.org", "Datasheet", myAppPrefix));
topLevel.setName("Datasheet 1");
topLevel.createAnnotation(new QName(myAppURI, "characterizationData", myAppPrefix), URI.create(myAppURI + "/measurement/1"));
topLevel.createAnnotation(new QName(myAppURI, "transcriptionRate", myAppPrefix), "1");
ComponentDefinition promoter = document.createComponentDefinition("BBa_J23119", "", new HashSet<URI>(Arrays.asList(ComponentDefinition.DNA)));
promoter.addRole(SequenceOntology.PROMOTER);
promoter.setName("J23119");
promoter.setDescription("Constitutive promoter");
promoter.createAnnotation(new QName(myAppURI, "datasheet", myAppPrefix), topLevel.getIdentity());
promoter.addWasDerivedFrom(URI.create("http://www.partsregistry.org/Part:BBa_J23119"));
SBOLWriter.write(document, (System.out));
}
use of org.sbolstandard.core2.SBOLDocument 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.SBOLDocument in project libSBOLj by SynBioDex.
the class ModuleTest method setUp.
@Before
public void setUp() throws Exception {
doc = new SBOLDocument();
doc.setDefaultURIprefix("http://sbols.org/CRISPR_Example/");
doc.setComplete(true);
doc.setCreateDefaults(true);
doc.setComplete(true);
geneticToggleSwitch = doc.createModuleDefinition("toggle_switch");
LacIInverter_MD = doc.createModuleDefinition("LacIInverter_MD");
TetRInverter_MD = doc.createModuleDefinition("TetRInverter_MD");
TetR = doc.createComponentDefinition("TetR", ComponentDefinition.PROTEIN);
LacI = doc.createComponentDefinition("LacI", ComponentDefinition.PROTEIN);
TF_TetR = doc.createComponentDefinition("TF_TetR", ComponentDefinition.PROTEIN);
TF_LacI = doc.createComponentDefinition("TF_LacI", ComponentDefinition.PROTEIN);
TetRInverter_fc = geneticToggleSwitch.createFunctionalComponent("TetRInverter_fc", AccessType.PUBLIC, TetR.getIdentity(), DirectionType.INOUT);
LacIInverter_fc = geneticToggleSwitch.createFunctionalComponent("LacIInverter_fc", AccessType.PUBLIC, LacI.getIdentity(), DirectionType.INOUT);
TF_TetR_fc = TetRInverter_MD.createFunctionalComponent("TF_TetR_fc", AccessType.PUBLIC, TF_TetR.getIdentity(), DirectionType.NONE);
TF_LacI_fc = LacIInverter_MD.createFunctionalComponent("TF_LacI_fc", AccessType.PUBLIC, TF_LacI.getIdentity(), DirectionType.NONE);
TetRInverter = geneticToggleSwitch.createModule("TetRInverter", TetRInverter_MD.getIdentity());
LacIInverter = geneticToggleSwitch.createModule("LacIInverter", LacIInverter_MD.getIdentity());
}
use of org.sbolstandard.core2.SBOLDocument 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;
}
use of org.sbolstandard.core2.SBOLDocument 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