Search in sources :

Example 26 with com.google.api.services.cloudresourcemanager.v3.model

use of com.google.api.services.cloudresourcemanager.v3.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));
}
Also used : SBOLDocument(org.sbolstandard.core2.SBOLDocument) Model(org.sbolstandard.core2.Model)

Example 27 with com.google.api.services.cloudresourcemanager.v3.model

use of com.google.api.services.cloudresourcemanager.v3.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));
}
Also used : ModuleDefinition(org.sbolstandard.core2.ModuleDefinition) SBOLDocument(org.sbolstandard.core2.SBOLDocument) Model(org.sbolstandard.core2.Model) FunctionalComponent(org.sbolstandard.core2.FunctionalComponent) Module(org.sbolstandard.core2.Module) ComponentDefinition(org.sbolstandard.core2.ComponentDefinition)

Example 28 with com.google.api.services.cloudresourcemanager.v3.model

use of com.google.api.services.cloudresourcemanager.v3.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()));
}
Also used : Model(org.sbolstandard.core2.Model) Test(org.junit.Test)

Example 29 with com.google.api.services.cloudresourcemanager.v3.model

use of com.google.api.services.cloudresourcemanager.v3.model in project VERDICT by ge-high-assurance.

the class VerdictSynthesis method performSynthesisMaxSmt.

/**
 * Perform synthesis using Z3 MaxSMT.
 *
 * @param tree
 * @param targetDal
 * @param factory
 * @return
 * @deprecated use the multi-requirement approach instead
 */
@Deprecated
public static Optional<Pair<Set<ComponentDefense>, Double>> performSynthesisMaxSmt(DTree tree, int targetDal, DLeaf.Factory factory) {
    Context context = new Context();
    Optimize optimizer = context.mkOptimize();
    Collection<ComponentDefense> pairs = factory.allComponentDefensePairs();
    int costLcd = normalizeCosts(pairs);
    for (ComponentDefense pair : pairs) {
        if (pair.dalToNormCost(targetDal) > 0) {
            // this id ("cover") doesn't matter but we have to specify something
            optimizer.AssertSoft(context.mkNot(pair.toZ3(context)), pair.dalToNormCost(targetDal), "cover");
        }
    }
    optimizer.Assert(tree.toZ3(context));
    if (optimizer.Check().equals(Status.SATISFIABLE)) {
        Set<ComponentDefense> output = new LinkedHashSet<>();
        int totalNormalizedCost = 0;
        Model model = optimizer.getModel();
        for (ComponentDefense pair : pairs) {
            Expr expr = model.eval(pair.toZ3(context), true);
            switch(expr.getBoolValue()) {
                case Z3_L_TRUE:
                    output.add(pair);
                    totalNormalizedCost += pair.dalToNormCost(targetDal);
                    break;
                case Z3_L_FALSE:
                    break;
                case Z3_L_UNDEF:
                default:
                    throw new RuntimeException("Synthesis: Undefined variable in output model: " + pair.toString());
            }
        }
        return Optional.of(new Pair<>(output, ((double) totalNormalizedCost) / costLcd));
    } else {
        System.err.println("Synthesis: SMT not satisfiable, perhaps there are unmitigatable attacks");
        return Optional.empty();
    }
}
Also used : Context(com.microsoft.z3.Context) LinkedHashSet(java.util.LinkedHashSet) BoolExpr(com.microsoft.z3.BoolExpr) ArithExpr(com.microsoft.z3.ArithExpr) Expr(com.microsoft.z3.Expr) ComponentDefense(com.ge.verdict.synthesis.dtree.DLeaf.ComponentDefense) Model(com.microsoft.z3.Model) Optimize(com.microsoft.z3.Optimize)

Example 30 with com.google.api.services.cloudresourcemanager.v3.model

use of com.google.api.services.cloudresourcemanager.v3.model in project VERDICT by ge-high-assurance.

the class VerdictSynthesis method addExtraImplDefenses.

/**
 * Returns a new results instance with any extraneous defenses from the provided list added to
 * the results items liset as removals.
 *
 * @param results the input results to use as a baseline
 * @param implCompDefPairs the set of all implemented component-defense pairs
 * @param costModel the cost model
 * @return a new results instance with the extraneous defenses included
 */
public static ResultsInstance addExtraImplDefenses(ResultsInstance results, Map<com.ge.verdict.attackdefensecollector.Pair<String, String>, Integer> implCompDefPairs, CostModel costModel) {
    List<ResultsInstance.Item> items = new ArrayList<>(results.items);
    Fraction inputCost = results.inputCost;
    Fraction outputCost = results.outputCost;
    // find all of the pairs already in the defense tree
    Set<com.ge.verdict.attackdefensecollector.Pair<String, String>> accountedCompDefPairs = results.items.stream().map(item -> new com.ge.verdict.attackdefensecollector.Pair<>(item.component, item.defenseProperty)).collect(Collectors.toSet());
    for (Map.Entry<com.ge.verdict.attackdefensecollector.Pair<String, String>, Integer> entry : implCompDefPairs.entrySet()) {
        // only add if not already accounted for
        if (!accountedCompDefPairs.contains(entry.getKey())) {
            String comp = entry.getKey().left;
            String defProp = entry.getKey().right;
            int implDal = entry.getValue();
            // compute cost of the implemented pair
            Fraction pairInputCost = costModel.cost(defProp, comp, implDal);
            Fraction pairOutputCost = costModel.cost(defProp, comp, 0);
            // the item will be a removal, so from implDal -> 0 DAL
            items.add(new ResultsInstance.Item(comp, defProp, implDal, 0, pairInputCost, pairOutputCost));
            inputCost = inputCost.add(pairInputCost);
            // this may seem silly, but in theory we can have a non-zero cost for DAL 0
            outputCost = outputCost.add(pairOutputCost);
        }
    }
    return new ResultsInstance(results.partialSolution, results.meritAssignment, results.inputSat, inputCost, outputCost, items);
}
Also used : IntStream(java.util.stream.IntStream) Optimize(com.microsoft.z3.Optimize) Context(com.microsoft.z3.Context) Formula(org.logicng.formulas.Formula) Assignment(org.logicng.datastructures.Assignment) MaxSATSolver(org.logicng.solvers.MaxSATSolver) RatNum(com.microsoft.z3.RatNum) ArrayList(java.util.ArrayList) Map(java.util.Map) FormulaFactory(org.logicng.formulas.FormulaFactory) BoolExpr(com.microsoft.z3.BoolExpr) Status(com.microsoft.z3.Status) DTree(com.ge.verdict.synthesis.dtree.DTree) ArithExpr(com.microsoft.z3.ArithExpr) LinkedHashSet(java.util.LinkedHashSet) DLeaf(com.ge.verdict.synthesis.dtree.DLeaf) PrintWriter(java.io.PrintWriter) Collection(java.util.Collection) Set(java.util.Set) Collectors(java.util.stream.Collectors) FileNotFoundException(java.io.FileNotFoundException) ComponentDefense(com.ge.verdict.synthesis.dtree.DLeaf.ComponentDefense) Model(com.microsoft.z3.Model) List(java.util.List) Fraction(org.apache.commons.math3.fraction.Fraction) ArithmeticUtils(org.apache.commons.math3.util.ArithmeticUtils) Pair(com.ge.verdict.synthesis.util.Pair) ResultsInstance(com.ge.verdict.vdm.synthesis.ResultsInstance) Expr(com.microsoft.z3.Expr) Optional(java.util.Optional) UnsupportedEncodingException(java.io.UnsupportedEncodingException) ArrayList(java.util.ArrayList) Fraction(org.apache.commons.math3.fraction.Fraction) ResultsInstance(com.ge.verdict.vdm.synthesis.ResultsInstance) Map(java.util.Map) Pair(com.ge.verdict.synthesis.util.Pair)

Aggregations

Test (org.junit.Test)48 Model (org.eclipse.xtext.valueconverter.bug250313.Model)30 Model (com.google.cloud.aiplatform.v1.Model)16 AutoMlClient (com.google.cloud.automl.v1.AutoMlClient)16 Model (com.google.cloud.automl.v1.Model)16 ICompositeNode (org.eclipse.xtext.nodemodel.ICompositeNode)16 LocationName (com.google.cloud.aiplatform.v1.LocationName)14 PipelineServiceClient (com.google.cloud.aiplatform.v1.PipelineServiceClient)14 PipelineServiceSettings (com.google.cloud.aiplatform.v1.PipelineServiceSettings)14 TrainingPipeline (com.google.cloud.aiplatform.v1.TrainingPipeline)14 InputDataConfig (com.google.cloud.aiplatform.v1.InputDataConfig)13 ModelContainerSpec (com.google.cloud.aiplatform.v1.ModelContainerSpec)13 FilterSplit (com.google.cloud.aiplatform.v1.FilterSplit)11 FractionSplit (com.google.cloud.aiplatform.v1.FractionSplit)11 PredefinedSplit (com.google.cloud.aiplatform.v1.PredefinedSplit)11 TimestampSplit (com.google.cloud.aiplatform.v1.TimestampSplit)11 Status (com.google.rpc.Status)11 Model (com.microsoft.z3.Model)11 DeployedModelRef (com.google.cloud.aiplatform.v1.DeployedModelRef)10 EnvVar (com.google.cloud.aiplatform.v1.EnvVar)10