use of org.hl7.fhir.dstu3.model in project libSBOLj by SynBioDex.
the class ModelOutput method main.
public static void main(String[] args) throws Exception {
SBOLDocument document = new SBOLDocument();
document.setTypesInURIs(false);
document.setDefaultURIprefix("http://www.sbolstandard.org/examples/");
Model model = document.createModel("pIKE_Toggle_1", "", URI.create("http://virtualparts.org/part/pIKE_Toggle_1"), URI.create("http://identifiers.org/edam/format_2585"), SystemsBiologyOntology.CONTINUOUS_FRAMEWORK);
model.setName("pIKE_Toggle_1 toggle switch");
SBOLWriter.write(document, (System.out));
}
use of org.hl7.fhir.dstu3.model in project libSBOLj by SynBioDex.
the class ModuleDefinitionOutput method main.
public static void main(String[] args) throws Exception {
SBOLDocument document = new SBOLDocument();
setDefaultNameSpace(document, pr.getNamespaceURI());
ComponentDefinition gfp = createComponenDefinition(document, pr.withLocalPart("BBa_E0040"), "gfp", Terms.biopaxTerms.DnaRegion, Terms.soTerms.CDS, "gfp coding sequence");
ComponentDefinition tetR = createComponenDefinition(document, pr.withLocalPart("BBa_C0040"), "tetR", Terms.biopaxTerms.DnaRegion, Terms.soTerms.CDS, "tetR coding sequence");
ComponentDefinition lacI = createComponenDefinition(document, pr.withLocalPart("BBa_C0012"), "lacI", Terms.biopaxTerms.DnaRegion, Terms.soTerms.CDS, "lacI coding sequence");
ComponentDefinition placI = createComponenDefinition(document, pr.withLocalPart("BBa_R0010"), "pLacI", Terms.biopaxTerms.DnaRegion, Terms.soTerms.promoter, "pLacI promoter");
ComponentDefinition ptetR = createComponenDefinition(document, pr.withLocalPart("BBa_R0040"), "pTetR", Terms.biopaxTerms.DnaRegion, Terms.soTerms.promoter, "pTet promoter");
ComponentDefinition rbslacI = createComponenDefinition(document, pr.withLocalPart("BBa_J61101"), "BBa_J61101 RBS", Terms.biopaxTerms.DnaRegion, Terms.soTerms.RBS, "RBS1");
ComponentDefinition rbstetR = createComponenDefinition(document, pr.withLocalPart("BBa_J61120"), "BBa_J61101 RBS", Terms.biopaxTerms.DnaRegion, Terms.soTerms.RBS, "RBS2");
ComponentDefinition rbsgfp = createComponenDefinition(document, pr.withLocalPart("BBa_J61130"), "BBa_J61101 RBS", Terms.biopaxTerms.DnaRegion, Terms.soTerms.RBS, "RBS2");
setDefaultNameSpace(document, uniprot.getNamespaceURI());
ComponentDefinition GFP = createComponenDefinition(document, uniprot.withLocalPart("P42212"), "GFP", Terms.biopaxTerms.Protein, Terms.sboTerms.product, "GFP protein");
ComponentDefinition TetR = createComponenDefinition(document, uniprot.withLocalPart("Q6QR72"), "TetR", Terms.biopaxTerms.Protein, Terms.sboTerms.inhibitor, "TetR protein");
ComponentDefinition LacI = createComponenDefinition(document, uniprot.withLocalPart("P03023"), "LacI", Terms.biopaxTerms.Protein, Terms.sboTerms.inhibitor, "LacI protein");
setDefaultNameSpace(document, pr.getNamespaceURI());
ComponentDefinition lacITerminator = createComponenDefinition(document, pr.withLocalPart("ECK120029600"), "ECK120029600", Terms.biopaxTerms.DnaRegion, Terms.soTerms.terminator, "Terminator1");
ComponentDefinition tetRTerminator = createComponenDefinition(document, pr.withLocalPart("ECK120033736"), "ECK120033736", Terms.biopaxTerms.DnaRegion, Terms.soTerms.terminator, "Terminator2");
setDefaultNameSpace(document, vpr.getNamespaceURI());
ComponentDefinition tetRInverter = createComponenDefinition(document, vpr.withLocalPart("pIKELeftCassette_1"), "TetR Inverter", Terms.biopaxTerms.DnaRegion, Terms.soTerms.engineeredGene, "TetR Inverter");
ComponentDefinition lacIInverter = createComponenDefinition(document, vpr.withLocalPart("pIKERightCassette_1"), "LacI Inverter", Terms.biopaxTerms.DnaRegion, Terms.soTerms.engineeredGene, "LacI Inverter");
ComponentDefinition toggleSwitch = createComponenDefinition(document, vpr.withLocalPart("pIKE_Toggle_1"), "LacI/TetR Toggle Switch", Terms.biopaxTerms.DnaRegion, Terms.soTerms.engineeredGene, "LacI/TetR Toggle Switch");
// tetR inverter sequences
addPRSequence(document, ptetR, "tccctatcagtgatagagattgacatccctatcagtgatagagatactgagcac");
addPRSequence(document, rbslacI, "aaagacaggacc");
addPRSequence(document, lacI, "atggtgaatgtgaaaccagtaacgttatacgatgtcgcagagtatgccggtgtctcttatcagaccgtttcccgcgtggtgaaccaggccagccacgtttctgcgaaaacgcgggaaaaagtggaagcggcgatggcggagctgaattacattcccaaccgcgtggcacaacaactggcgggcaaacagtcgttgctgattggcgttgccacctccagtctggccctgcacgcgccgtcgcaaattgtcgcggcgattaaatctcgcgccgatcaactgggtgccagcgtggtggtgtcgatggtagaacgaagcggcgtcgaagcctgtaaagcggcggtgcacaatcttctcgcgcaacgcgtcagtgggctgatcattaactatccgctggatgaccaggatgccattgctgtggaagctgcctgcactaatgttccggcgttatttcttgatgtctctgaccagacacccatcaacagtattattttctcccatgaagacggtacgcgactgggcgtggagcatctggtcgcattgggtcaccagcaaatcgcgctgttagcgggcccattaagttctgtctcggcgcgtctgcgtctggctggctggcataaatatctcactcgcaatcaaattcagccgatagcggaacgggaaggcgactggagtgccatgtccggttttcaacaaaccatgcaaatgctgaatgagggcatcgttcccactgcgatgctggttgccaacgatcagatggcgctgggcgcaatgcgcgccattaccgagtccgggctgcgcgttggtgcggatatctcggtagtgggatacgacgataccgaagacagctcatgttatatcccgccgttaaccaccatcaaacaggattttcgcctgctggggcaaaccagcgtggaccgcttgctgcaactctctcagggccaggcggtgaagggcaatcagctgttgcccgtctcactggtgaaaagaaaaaccaccctggcgcccaatacgcaaaccgcctctccccgcgcgttggccgattcattaatgcagctggcacgacaggtttcccgactggaaagcgggcaggctgcaaacgacgaaaactacgctttagtagcttaataa");
addPRSequence(document, lacITerminator, "ttcagccaaaaaacttaagaccgccggtcttgtccactaccttgcagtaatgcggtggacaggatcggcggttttcttttctcttctcaa");
// lacI inverter sequences
addPRSequence(document, placI, "tccctatcagtgatagagattgacatccctatcagtgatagagatactgagcac");
addPRSequence(document, rbstetR, "aaagacaggacc");
addPRSequence(document, tetR, "atgtccagattagataaaagtaaagtgattaacagcgcattagagctgcttaatgaggtcggaatcgaaggtttaacaacccgtaaactcgcccagaagctaggtgtagagcagcctacattgtattggcatgtaaaaaataagcgggctttgctcgacgccttagccattgagatgttagataggcaccatactcacttttgccctttagaaggggaaagctggcaagattttttacgtaataacgctaaaagttttagatgtgctttactaagtcatcgcgatggagcaaaagtacatttaggtacacggcctacagaaaaacagtatgaaactctcgaaaatcaattagcctttttatgccaacaaggtttttcactagagaatgcattatatgcactcagcgctgtggggcattttactttaggttgcgtattggaagatcaagagcatcaagtcgctaaagaagaaagggaaacacctactactgatagtatgccgccattattacgacaagctatcgaattatttgatcaccaaggtgcagagccagccttcttattcggccttgaattgatcatatgcggattagaaaaacaacttaaatgtgaaagtgggtccgctgcaaacgacgaaaactacgctttagtagcttaataa");
addPRSequence(document, rbsgfp, "aaagaaacgaca");
addPRSequence(document, gfp, "atgcgtaaaggagaagaacttttcactggagttgtcccaattcttgttgaattagatggtgatgttaatgggcacaaattttctgtcagtggagagggtgaaggtgatgcaacatacggaaaacttacccttaaatttatttgcactactggaaaactacctgttccatggccaacacttgtcactactttcggttatggtgttcaatgctttgcgagatacccagatcatatgaaacagcatgactttttcaagagtgccatgcccgaaggttatgtacaggaaagaactatatttttcaaagatgacgggaactacaagacacgtgctgaagtcaagtttgaaggtgatacccttgttaatagaatcgagttaaaaggtattgattttaaagaagatggaaacattcttggacacaaattggaatacaactataactcacacaatgtatacatcatggcagacaaacaaaagaatggaatcaaagttaacttcaaaattagacacaacattgaagatggaagcgttcaactagcagaccattatcaacaaaatactccaattggcgatggccctgtccttttaccagacaaccattacctgtccacacaatctgccctttcgaaagatcccaacgaaaagagagaccacatggtccttcttgagtttgtaacagctgctgggattacacatggcatggatgaactatacaaataataa");
addPRSequence(document, tetRTerminator, "ttcagccaaaaaacttaagaccgccggtcttgtccactaccttgcagtaatgcggtggacaggatcggcggttttcttttctcttctcaa");
addSubComponents(document, tetRInverter, ptetR, rbslacI, lacI, lacITerminator);
addSubComponents(document, lacIInverter, placI, rbstetR, tetR, rbsgfp, gfp, tetRTerminator);
addSubComponents(document, toggleSwitch, tetRInverter, lacIInverter);
setDefaultNameSpace(document, example.getNamespaceURI());
ModuleDefinition laciInverterModuleDef = document.createModuleDefinition("laci_inverter");
laciInverterModuleDef.addRole(Terms.moduleRoles.inverter);
ModuleDefinition tetRInverterModuleDef = document.createModuleDefinition("tetr_inverter");
tetRInverterModuleDef.addRole(Terms.moduleRoles.inverter);
createInverter(document, laciInverterModuleDef, placI, LacI);
createInverter(document, tetRInverterModuleDef, ptetR, TetR);
ModuleDefinition toggleSwitchModuleDef = document.createModuleDefinition("toggle_switch");
toggleSwitchModuleDef.addRole(toURI(example.withLocalPart("module_role/toggle_switch")));
FunctionalComponent toggleSwitchModuleDef_TetR = toggleSwitchModuleDef.createFunctionalComponent("TetR", AccessType.PUBLIC, TetR.getIdentity(), DirectionType.INOUT);
FunctionalComponent toggleSwitchModuleDef_LacI = toggleSwitchModuleDef.createFunctionalComponent("LacI", AccessType.PUBLIC, LacI.getIdentity(), DirectionType.INOUT);
Module lacInverterSubModule = toggleSwitchModuleDef.createModule("laci_inverter", laciInverterModuleDef.getIdentity());
lacInverterSubModule.createMapsTo("LacI_mapping", RefinementType.USEREMOTE, toggleSwitchModuleDef_LacI.getIdentity(), laciInverterModuleDef.getFunctionalComponent("TF").getIdentity());
Module tetRInverterSubModule = toggleSwitchModuleDef.createModule("tetr_inverter", tetRInverterModuleDef.getIdentity());
tetRInverterSubModule.createMapsTo("TetR_mapping", RefinementType.USEREMOTE, toggleSwitchModuleDef_TetR.getIdentity(), tetRInverterModuleDef.getFunctionalComponent("TF").getIdentity());
Model model = document.createModel("toogleswitch", URI.create("http://virtualparts.org/part/pIKE_Toggle_1"), EDAMOntology.SBML, SystemsBiologyOntology.CONTINUOUS_FRAMEWORK);
toggleSwitchModuleDef.addModel(model.getIdentity());
SBOLWriter.write(document, (System.out));
}
use of org.hl7.fhir.dstu3.model in project libSBOLj by SynBioDex.
the class ModuleDefinitionTest method test_modelMethods.
@Test
public void test_modelMethods() throws SBOLValidationException {
Model model = doc.createModel("pIKE_Toggle_1", "1.0", URI.create("http://virtualparts.org/part/pIKE_Toggle_1"), URI.create("http://identifiers.org/edam/format_2585"), SystemsBiologyOntology.CONTINUOUS_FRAMEWORK);
assertTrue(geneticToggleSwitch.addModel("pIKE_Toggle_1"));
assertTrue(doc.getModuleDefinition("geneticToggleSwitch", "").getModels().contains(model));
assertTrue(geneticToggleSwitch.removeModel(model.getPersistentIdentity()));
assertTrue(geneticToggleSwitch.addModel("pIKE_Toggle_1", "1.0"));
assertTrue(doc.getModuleDefinition("geneticToggleSwitch", "").getModels().contains(model));
assertTrue(geneticToggleSwitch.containsModel(model.getIdentity()));
}
use of org.hl7.fhir.dstu3.model in project bmoth by hhu-stups.
the class Issue73Test method testSatPredicateWithoutModel.
@Test
public void testSatPredicateWithoutModel() throws IOException {
String formula = "1 < 2";
BoolExpr constraint = translatePredicate(formula, z3Context);
SolutionFinder finder = new SolutionFinder(z3Solver, z3Context);
Set<Model> solutions = finder.findSolutions(constraint, 20);
assertEquals(0, solutions.size());
}
use of org.hl7.fhir.dstu3.model in project Dat3M by hernanponcedeleon.
the class Porthos method main.
public static void main(String[] args) throws Z3Exception, IOException {
List<String> MCMs = Arrays.asList("sc", "tso", "pso", "rmo", "alpha", "power", "arm");
Options options = new Options();
Option sourceOpt = new Option("s", "source", true, "source MCM");
sourceOpt.setRequired(true);
options.addOption(sourceOpt);
Option targetOpt = new Option("t", "target", true, "target MCM");
targetOpt.setRequired(true);
options.addOption(targetOpt);
Option inputOpt = new Option("i", "input", true, "input file path");
inputOpt.setRequired(true);
options.addOption(inputOpt);
options.addOption("state", false, "PORTHOS performs state portability");
options.addOption(Option.builder("draw").hasArg().desc("If a buf is found, it outputs a graph \\path_to_file.dot").build());
options.addOption(Option.builder("rels").hasArgs().desc("Relations to be drawn in the graph").build());
options.addOption(Option.builder("unroll").hasArg().desc("Unrolling steps").build());
CommandLineParser parserCmd = new DefaultParser();
HelpFormatter formatter = new HelpFormatter();
CommandLine cmd;
try {
cmd = parserCmd.parse(options, args);
} catch (ParseException e) {
System.out.println(e.getMessage());
formatter.printHelp("PORTHOS", options);
System.exit(1);
return;
}
String source = cmd.getOptionValue("source");
if (!MCMs.stream().anyMatch(mcms -> mcms.trim().equals(source))) {
System.out.println("Unrecognized source");
System.exit(0);
return;
}
String target = cmd.getOptionValue("target");
if (!MCMs.stream().anyMatch(mcms -> mcms.trim().equals(target))) {
System.out.println("Unrecognized target");
System.exit(0);
return;
}
String inputFilePath = cmd.getOptionValue("input");
if (!inputFilePath.endsWith("pts") && !inputFilePath.endsWith("litmus")) {
System.out.println("Unrecognized program format");
System.exit(0);
return;
}
File file = new File(inputFilePath);
boolean statePortability = cmd.hasOption("state");
String[] rels = new String[100];
if (cmd.hasOption("rels")) {
rels = cmd.getOptionValues("rels");
}
String program = FileUtils.readFileToString(file, "UTF-8");
ANTLRInputStream input = new ANTLRInputStream(program);
Program p = new Program(inputFilePath);
if (inputFilePath.endsWith("litmus")) {
LitmusLexer lexer = new LitmusLexer(input);
CommonTokenStream tokens = new CommonTokenStream(lexer);
LitmusParser parser = new LitmusParser(tokens);
p = parser.program(inputFilePath).p;
}
if (inputFilePath.endsWith("pts")) {
PorthosLexer lexer = new PorthosLexer(input);
CommonTokenStream tokens = new CommonTokenStream(lexer);
PorthosParser parser = new PorthosParser(tokens);
p = parser.program(inputFilePath).p;
}
int steps = 1;
if (cmd.hasOption("unroll")) {
steps = Integer.parseInt(cmd.getOptionValue("unroll"));
}
p.initialize(steps);
Program pSource = p.clone();
Program pTarget = p.clone();
pSource.compile(source, false, true);
Integer startEId = Collections.max(pSource.getEvents().stream().filter(e -> e instanceof Init).map(e -> e.getEId()).collect(Collectors.toSet())) + 1;
pTarget.compile(target, false, true, startEId);
Context ctx = new Context();
ctx.setPrintMode(Z3_ast_print_mode.Z3_PRINT_SMTLIB_FULL);
Solver s = ctx.mkSolver();
Solver s2 = ctx.mkSolver();
BoolExpr sourceDF = pSource.encodeDF(ctx);
BoolExpr sourceCF = pSource.encodeCF(ctx);
BoolExpr sourceDF_RF = pSource.encodeDF_RF(ctx);
BoolExpr sourceDomain = Domain.encode(pSource, ctx);
BoolExpr sourceMM = pSource.encodeMM(ctx, source);
s.add(pTarget.encodeDF(ctx));
s.add(pTarget.encodeCF(ctx));
s.add(pTarget.encodeDF_RF(ctx));
s.add(Domain.encode(pTarget, ctx));
s.add(pTarget.encodeMM(ctx, target));
s.add(pTarget.encodeConsistent(ctx, target));
s.add(sourceDF);
s.add(sourceCF);
s.add(sourceDF_RF);
s.add(sourceDomain);
s.add(sourceMM);
s.add(pSource.encodeInconsistent(ctx, source));
s.add(encodeCommonExecutions(pTarget, pSource, ctx));
s2.add(sourceDF);
s2.add(sourceCF);
s2.add(sourceDF_RF);
s2.add(sourceDomain);
s2.add(sourceMM);
s2.add(pSource.encodeConsistent(ctx, source));
if (!statePortability) {
if (s.check() == Status.SATISFIABLE) {
System.out.println("The program is not portable");
// System.out.println(" 0");
if (cmd.hasOption("draw")) {
String outputPath = cmd.getOptionValue("draw");
Utils.drawGraph(p, pSource, pTarget, ctx, s.getModel(), outputPath, rels);
}
return;
} else {
System.out.println("The program is portable");
// System.out.println(" 1");
return;
}
}
int iterations = 0;
Status lastCheck = Status.SATISFIABLE;
Set<Expr> visited = new HashSet<Expr>();
while (lastCheck == Status.SATISFIABLE) {
lastCheck = s.check();
if (lastCheck == Status.SATISFIABLE) {
iterations = iterations + 1;
Model model = s.getModel();
s2.push();
BoolExpr reachedState = encodeReachedState(pTarget, model, ctx);
visited.add(reachedState);
assert (iterations == visited.size());
s2.add(reachedState);
if (s2.check() == Status.UNSATISFIABLE) {
System.out.println("The program is not state-portable");
System.out.println("Iterations: " + iterations);
// System.out.println(" 0");
return;
} else {
s2.pop();
s.add(ctx.mkNot(reachedState));
}
} else {
System.out.println("The program is state-portable");
System.out.println("Iterations: " + iterations);
// System.out.println(" 1");
return;
}
}
}
Aggregations