Search in sources :

Example 1 with TaskContext

use of org.vcell.workflow.TaskContext in project vcell by virtualcell.

the class WorkflowTest method getVFrapSimpleExample.

public static Workflow getVFrapSimpleExample(File workingDirectory, File vfrapFile) {
    // 
    // construct the dataflow graph
    // 
    LocalWorkspace localWorkspace = new LocalWorkspace(workingDirectory);
    Workflow workflow = new Workflow("main");
    Repository repository = new MemoryRepository();
    TaskContext context = new TaskContext(workflow, repository, localWorkspace);
    // 
    // workflow parameters
    // 
    WorkflowParameter<File> vfrapFileParam = workflow.addParameter(File.class, "vfrapFile");
    context.setParameterValue(vfrapFileParam, vfrapFile);
    WorkflowParameter<Double> bleachThreshold = workflow.addParameter(Double.class, "bleachThreshold");
    context.setParameterValue(bleachThreshold, 0.80);
    WorkflowParameter<Double> cellThreshold = workflow.addParameter(Double.class, "cellThreshold");
    context.setParameterValue(cellThreshold, 0.5);
    WorkflowParameter<String> displayROITitle = workflow.addParameter(String.class, "displayROITitle");
    context.setParameterValue(displayROITitle, "rois");
    WorkflowParameter<String> displayProfileOneTitle = workflow.addParameter(String.class, "displayProfileOneTitle");
    context.setParameterValue(displayProfileOneTitle, "1 Diffusing");
    WorkflowParameter<String> displayProfileTwoWithoutPenaltyTitle = workflow.addParameter(String.class, "displayProfileTwoTitle");
    context.setParameterValue(displayProfileTwoWithoutPenaltyTitle, "2 Diffusing - no penalty");
    WorkflowParameter<String> displayProfileTwoWithPenaltyTitle = workflow.addParameter(String.class, "displayProfileTwoTitle");
    context.setParameterValue(displayProfileTwoWithPenaltyTitle, "2 Diffusing - with penalty");
    WorkflowParameter<String> displayRawImagesTitle = workflow.addParameter(String.class, "displayRawImagesTitle");
    context.setParameterValue(displayRawImagesTitle, "raw Images from " + ImportRawTimeSeriesFromVFrap.class.getName());
    ImportRawTimeSeriesFromVFrap importFromVFrap = new ImportRawTimeSeriesFromVFrap("importFromVFrap");
    workflow.connectParameter(vfrapFileParam, importFromVFrap.vfrapFile);
    workflow.addTask(importFromVFrap);
    DisplayTimeSeries displayRawImages = new DisplayTimeSeries("displayRawImages");
    workflow.connect2(importFromVFrap.rawTimeSeriesImages, displayRawImages.imageTimeSeries);
    workflow.connectParameter(displayRawImagesTitle, displayRawImages.title);
    workflow.addTask(displayRawImages);
    VFrapProcess vfrapProcess = new VFrapProcess("vfrapProcess");
    workflow.connectParameter(bleachThreshold, vfrapProcess.bleachThreshold);
    workflow.connectParameter(cellThreshold, vfrapProcess.cellThreshold);
    workflow.connect2(importFromVFrap.rawTimeSeriesImages, vfrapProcess.rawTimeSeriesImages);
    workflow.addTask(vfrapProcess);
    DisplayDependentROIs displayROIs = new DisplayDependentROIs("displayROis");
    workflow.connect2(vfrapProcess.cellROI_2D, displayROIs.cellROI);
    workflow.connect2(vfrapProcess.imageDataROIs, displayROIs.imageROIs);
    workflow.connectParameter(displayROITitle, displayROIs.title);
    workflow.addTask(displayROIs);
    DisplayProfileLikelihoodPlots displayProfilesOne = new DisplayProfileLikelihoodPlots("displayProfilesOne");
    workflow.connect2(vfrapProcess.profileDataOne, displayProfilesOne.profileData);
    workflow.connectParameter(displayProfileOneTitle, displayProfilesOne.title);
    workflow.addTask(displayProfilesOne);
    DisplayProfileLikelihoodPlots displayProfilesTwoWithPenalty = new DisplayProfileLikelihoodPlots("displayProfilesTwoWithPenalty");
    workflow.connect2(vfrapProcess.profileDataTwoWithPenalty, displayProfilesTwoWithPenalty.profileData);
    workflow.connectParameter(displayProfileTwoWithPenaltyTitle, displayProfilesTwoWithPenalty.title);
    workflow.addTask(displayProfilesTwoWithPenalty);
    return workflow;
}
Also used : LocalWorkspace(org.vcell.vmicro.workflow.data.LocalWorkspace) TaskContext(org.vcell.workflow.TaskContext) DisplayTimeSeries(org.vcell.vmicro.workflow.task.DisplayTimeSeries) Workflow(org.vcell.workflow.Workflow) DisplayProfileLikelihoodPlots(org.vcell.vmicro.workflow.task.DisplayProfileLikelihoodPlots) MemoryRepository(org.vcell.workflow.MemoryRepository) Repository(org.vcell.workflow.Repository) DisplayDependentROIs(org.vcell.vmicro.workflow.task.DisplayDependentROIs) ImportRawTimeSeriesFromVFrap(org.vcell.vmicro.workflow.task.ImportRawTimeSeriesFromVFrap) MemoryRepository(org.vcell.workflow.MemoryRepository) VFrapProcess(org.vcell.vmicro.workflow.task.VFrapProcess) File(java.io.File)

Example 2 with TaskContext

use of org.vcell.workflow.TaskContext in project vcell by virtualcell.

the class WorkflowTest method main.

public static void main(String[] args) {
    if (args.length != 2) {
        System.out.println("expecting 2 arguments");
        System.out.println("usage: java " + Workflow.class.getSimpleName() + " workingdir workflowInputFile");
        System.out.println("workingdir example: " + "D:\\developer\\eclipse\\workspace\\VCell_5.4_vmicro\\datadir");
        System.out.println("workflowInputFile example: " + "D:\\developer\\eclipse\\workspace\\VCell_5.4_vmicro\\workflow1.txt");
        System.exit(1);
    }
    try {
        // PropertyLoader.loadProperties();
        // workflowInputFile "C:\\developer\\eclipse\\workspace\\VCell_5.3_vmicro\\workflow1.txt"
        File workingDirectory = new File(args[0]);
        LocalWorkspace localWorkspace = new LocalWorkspace(workingDirectory);
        Repository repository = new MemoryRepository();
        String workflowLanguageText = BeanUtils.readBytesFromFile(new File(args[1]), null);
        Workflow workflow = Workflow.parse(repository, localWorkspace, workflowLanguageText);
        System.err.println(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> using hard-coded example instead <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<");
        // File vfrapFile = new File("D:\\Developer\\eclipse\\workspace_refactor\\VCell_5.4_vmicro\\3D_FRAP_2_ZProjection_Simulation1.vfrap");
        // Workflow workflow = getVFrapSimpleExample(workingDirectory, vfrapFile);
        TaskContext taskContext = new TaskContext(workflow, repository, localWorkspace);
        ArrayList<Issue> issues = new ArrayList<Issue>();
        IssueContext issueContext = new IssueContext();
        workflow.gatherIssues(issueContext, issues);
        // WorkflowJGraphProxy workflowJGraphProxy = new WorkflowJGraphProxy(workflow);
        // displayWorkflowGraphJGraphX(workflowJGraphProxy);
        WorkflowUtilities.displayWorkflowGraph(workflow);
        WorkflowUtilities.displayWorkflowTable(taskContext);
        workflow.reportIssues(issues, Issue.SEVERITY_INFO, true);
        // 
        // execute the workflow
        // 
        workflow.compute(taskContext, new WorkflowUtilities.Progress());
    } catch (Exception e) {
        e.printStackTrace(System.out);
    }
}
Also used : LocalWorkspace(org.vcell.vmicro.workflow.data.LocalWorkspace) TaskContext(org.vcell.workflow.TaskContext) Issue(org.vcell.util.Issue) ArrayList(java.util.ArrayList) Workflow(org.vcell.workflow.Workflow) MemoryRepository(org.vcell.workflow.MemoryRepository) Repository(org.vcell.workflow.Repository) MemoryRepository(org.vcell.workflow.MemoryRepository) IssueContext(org.vcell.util.IssueContext) File(java.io.File)

Example 3 with TaskContext

use of org.vcell.workflow.TaskContext in project vcell by virtualcell.

the class WorkflowFileTest method main.

public static void main(String[] args) {
    if (args.length != 2) {
        System.out.println("expecting 2 arguments");
        System.out.println("usage: java " + Workflow.class.getSimpleName() + " workingdir workflowInputFile");
        System.out.println("workingdir example: " + "D:\\developer\\eclipse\\workspace\\VCell_5.4_vmicro\\datadir");
        System.out.println("workflowInputFile example: " + "D:\\developer\\eclipse\\workspace\\VCell_5.4_vmicro\\workflow1.txt");
        System.exit(1);
    }
    try {
        File workingDirectory = new File(args[0]);
        LocalWorkspace localWorkspace = new LocalWorkspace(workingDirectory);
        String workflowLanguageText = BeanUtils.readBytesFromFile(new File(args[1]), null);
        Repository repository = new MemoryRepository();
        Workflow workflow = Workflow.parse(repository, localWorkspace, workflowLanguageText);
        TaskContext taskContext = new TaskContext(workflow, repository, localWorkspace);
        WorkflowUtilities.displayWorkflowGraph(taskContext.getWorkflow());
        WorkflowUtilities.displayWorkflowTable(taskContext);
        WorkflowUtilities.displayWorkflowGraphJGraphX(new WorkflowJGraphProxy(taskContext));
        ArrayList<Issue> issues = new ArrayList<Issue>();
        taskContext.getWorkflow().reportIssues(issues, Issue.SEVERITY_INFO, true);
        // 
        // execute the workflow
        // 
        taskContext.getWorkflow().compute(taskContext, new WorkflowUtilities.Progress());
    } catch (Exception e) {
        e.printStackTrace(System.out);
    }
}
Also used : LocalWorkspace(org.vcell.vmicro.workflow.data.LocalWorkspace) TaskContext(org.vcell.workflow.TaskContext) Issue(org.vcell.util.Issue) ArrayList(java.util.ArrayList) Workflow(org.vcell.workflow.Workflow) WorkflowJGraphProxy(org.vcell.vmicro.workflow.jgraphx.WorkflowJGraphProxy) Repository(org.vcell.workflow.Repository) MemoryRepository(org.vcell.workflow.MemoryRepository) MemoryRepository(org.vcell.workflow.MemoryRepository) File(java.io.File)

Example 4 with TaskContext

use of org.vcell.workflow.TaskContext in project vcell by virtualcell.

the class Generate2DExpModel_UniformBleach method compute0.

@Override
protected void compute0(final TaskContext context, final ClientTaskStatusSupport clientTaskStatusSupport) throws Exception {
    // get input
    double deltaX = context.getData(this.deltaX);
    double bleachRadius = context.getData(this.bleachRadius);
    double cellRadius = context.getData(this.cellRadius);
    double bleachDuration = context.getData(this.bleachDuration);
    double bleachRate = context.getData(this.bleachRate);
    double postbleachDelay = context.getData(this.postbleachDelay);
    double postbleachDuration = context.getData(this.postbleachDuration);
    double psfSigma = context.getData(this.psfSigma);
    double outputTimeStep = context.getData(this.outputTimeStep);
    double primaryDiffusionRate = context.getData(this.primaryDiffusionRate);
    double primaryFraction = context.getData(this.primaryFraction);
    double bleachMonitorRate = context.getData(this.bleachMonitorRate);
    double secondaryDiffusionRate = context.getData(this.secondaryDiffusionRate);
    double secondaryFraction = context.getData(this.secondaryFraction);
    String extracellularName = context.getData(this.extracellularName);
    String cytosolName = context.getData(this.cytosolName);
    // isolate from Workflow
    Context modelGenerationContext = new Context() {

        @Override
        public User getDefaultOwner() {
            return context.getDefaultOwner();
        }

        @Override
        public KeyValue createNewKeyValue() {
            return context.createNewKeyValue();
        }
    };
    // do op
    Generate2DExpModel_UniformBleachOp op = new Generate2DExpModel_UniformBleachOp();
    GeneratedModelResults results = op.generateModel(deltaX, bleachRadius, cellRadius, bleachDuration, bleachRate, postbleachDelay, postbleachDuration, psfSigma, outputTimeStep, primaryDiffusionRate, primaryFraction, bleachMonitorRate, secondaryDiffusionRate, secondaryFraction, extracellularName, cytosolName, modelGenerationContext);
    // set output
    context.setData(this.bioModel_2D, results.bioModel_2D);
    context.setData(this.simulation_2D, results.simulation_2D);
    context.setData(this.bleachBlackoutBeginTime, results.bleachBlackoutBeginTime);
    context.setData(this.bleachBlackoutEndTime, results.bleachBlackoutEndTime);
}
Also used : Context(org.vcell.vmicro.op.Generate2DExpModelOpAbstract.Context) TaskContext(org.vcell.workflow.TaskContext) GeneratedModelResults(org.vcell.vmicro.op.Generate2DExpModelOpAbstract.GeneratedModelResults) Generate2DExpModel_UniformBleachOp(org.vcell.vmicro.op.Generate2DExpModel_UniformBleachOp)

Example 5 with TaskContext

use of org.vcell.workflow.TaskContext in project vcell by virtualcell.

the class Generate2DExpModel_GaussianBleach method compute0.

@Override
protected void compute0(final TaskContext context, final ClientTaskStatusSupport clientTaskStatusSupport) throws Exception {
    // get input
    double deltaX = context.getData(this.deltaX);
    double bleachRadius = context.getData(this.bleachRadius);
    double cellRadius = context.getData(this.cellRadius);
    double bleachDuration = context.getData(this.bleachDuration);
    double bleachRate = context.getData(this.bleachRate);
    double postbleachDelay = context.getData(this.postbleachDelay);
    double postbleachDuration = context.getData(this.postbleachDuration);
    double psfSigma = context.getData(this.psfSigma);
    double outputTimeStep = context.getData(this.outputTimeStep);
    double primaryDiffusionRate = context.getData(this.primaryDiffusionRate);
    double primaryFraction = context.getData(this.primaryFraction);
    double bleachMonitorRate = context.getData(this.bleachMonitorRate);
    double secondaryDiffusionRate = context.getData(this.secondaryDiffusionRate);
    double secondaryFraction = context.getData(this.secondaryFraction);
    String extracellularName = context.getData(this.extracellularName);
    String cytosolName = context.getData(this.cytosolName);
    // isolate from Workflow
    Context modelGenerationContext = new Context() {

        @Override
        public User getDefaultOwner() {
            return context.getDefaultOwner();
        }

        @Override
        public KeyValue createNewKeyValue() {
            return context.createNewKeyValue();
        }
    };
    // do op
    Generate2DExpModel_GaussianBleachOp op = new Generate2DExpModel_GaussianBleachOp();
    GeneratedModelResults results = op.generateModel(deltaX, bleachRadius, cellRadius, bleachDuration, bleachRate, postbleachDelay, postbleachDuration, psfSigma, outputTimeStep, primaryDiffusionRate, primaryFraction, bleachMonitorRate, secondaryDiffusionRate, secondaryFraction, extracellularName, cytosolName, modelGenerationContext);
    // set output
    context.setData(this.bioModel_2D, results.bioModel_2D);
    context.setData(this.simulation_2D, results.simulation_2D);
    context.setData(this.bleachBlackoutBeginTime, results.bleachBlackoutBeginTime);
    context.setData(this.bleachBlackoutEndTime, results.bleachBlackoutEndTime);
}
Also used : Context(org.vcell.vmicro.op.Generate2DExpModelOpAbstract.Context) TaskContext(org.vcell.workflow.TaskContext) GeneratedModelResults(org.vcell.vmicro.op.Generate2DExpModelOpAbstract.GeneratedModelResults) Generate2DExpModel_GaussianBleachOp(org.vcell.vmicro.op.Generate2DExpModel_GaussianBleachOp)

Aggregations

TaskContext (org.vcell.workflow.TaskContext)9 Workflow (org.vcell.workflow.Workflow)7 File (java.io.File)6 LocalWorkspace (org.vcell.vmicro.workflow.data.LocalWorkspace)6 MemoryRepository (org.vcell.workflow.MemoryRepository)5 Repository (org.vcell.workflow.Repository)5 ArrayList (java.util.ArrayList)3 Issue (org.vcell.util.Issue)3 IssueContext (org.vcell.util.IssueContext)2 Context (org.vcell.vmicro.op.Generate2DExpModelOpAbstract.Context)2 GeneratedModelResults (org.vcell.vmicro.op.Generate2DExpModelOpAbstract.GeneratedModelResults)2 DisplayDependentROIs (org.vcell.vmicro.workflow.task.DisplayDependentROIs)2 DisplayProfileLikelihoodPlots (org.vcell.vmicro.workflow.task.DisplayProfileLikelihoodPlots)2 ImportRawTimeSeriesFromVFrap (org.vcell.vmicro.workflow.task.ImportRawTimeSeriesFromVFrap)2 RunProfileLikelihoodGeneral (org.vcell.vmicro.workflow.task.RunProfileLikelihoodGeneral)2 AsynchClientTask (cbit.vcell.client.task.AsynchClientTask)1 Hashtable (java.util.Hashtable)1 JFrame (javax.swing.JFrame)1 ClientTaskStatusSupport (org.vcell.util.ClientTaskStatusSupport)1 Generate2DExpModel_GaussianBleachOp (org.vcell.vmicro.op.Generate2DExpModel_GaussianBleachOp)1