Package LONI.tree.workflow

Examples of LONI.tree.workflow.Pipeline


      case GALAXY:
        outputString = GalaxySpecification.getJSONGenerator().generate(
            g);
        break;
      case LONI:
        Pipeline p;

        // don't import; use fully-qualified name to avoid collision
        // with local converter
        Galaxy.Visitor.Webservice.GalaxyToLoniWorkflowConverter foo = new Galaxy.Visitor.Webservice.GalaxyToLoniWorkflowConverter();
        Printer.log("Using Webservice Galaxy Converter");
        p = (Pipeline) foo.visit(g);

        outputString = LoniSpecification.getXMLGenerator().generate(p);
        break;
      default:
        cantConvert();
      }
      break;
    }
    case TAVERNA: {
      Taverna.Tree.Workflow t = null;
      try {
        t = TavernaSpecification.getXMLParser().parse(
            new File(ConverterConfig.INPUT_PATH));
      } catch (FileNotFoundException e) {
        Printer.log("What, FileNotFoundException not caught by configureInput?");
      }

      switch (ConverterConfig.OUTPUT_FORMAT) {
      case TAVERNA:
        outputString = TavernaSpecification.getXMLGenerator().generate(
            t);
        break;
      case LONI:
        TavernaToLoniConverter foo = new TavernaToLoniConverter();
        Pipeline p = (Pipeline) foo.visit(t);
        outputString = LoniSpecification.getXMLGenerator().generate(p);
        break;
      default:
        cantConvert();
      }
      break;
    }
    case LONI: {
      Pipeline p = null;
      try {
        p = LoniSpecification.getXMLParser().parse(
            new File(ConverterConfig.INPUT_PATH));
      } catch (FileNotFoundException e) {
        Printer.log("What, FileNotFoundException not caught by configureInput?");
View Full Code Here


  }


  public Object visit(Workflow workflow)
  {
    Pipeline pipeline;
    ModuleGroup mgroup;
    LoniEnvironment stepEnv;
    LoniContext context = new LoniContext();
   
    String annotation = workflow.getAnnotation();
    String version = workflow.getFormatVersion();
    String name = workflow.getName();
    mgroup = new ModuleGroup();
    mgroup.setName(name);
    mgroup.setVersion("version");
    mgroup.setDescription(annotation);
    mgroup.setPosX(0);
    mgroup.setPosY(0);
    /* Add the Galaxy directory global to the loni file*/
    String varName="GALAXY_DIR";
    String varDescription="directory of galaxy installation. Used to find galaxy scripts.";
    boolean secret = false;
    int order = 0;
    boolean required=true;
    mgroup.getVariables().addVariable(new Variable(varName, varDescription, required,
        secret, order, ConverterConfig.GALAXY_INPUT_DIR) );
   
    varName="OUTPUT_FILE_DIR";
    varDescription="directory of galaxy installation. Used to find galaxy scripts.";
    mgroup.getVariables().addVariable(new Variable(varName, varDescription, required,
        secret, order, ConverterConfig.GALAXY_OUTPUT_DIR) );
   
    /* Record environmental variable in context for future use*/
    /*TODO: Migrate these globals to some sort of configuration file*/
   
    Connections connections = new Connections();
   
    for(Step s : workflow.getSteps()){
      Pair<GraphObject, LoniEnvironment> dat;
      dat = (Pair<GraphObject, LoniEnvironment>) stepVisitor.visit(s, context);
      connections.addConnections(dat.getElem2().getConnections());
      mgroup.getModules().addAll(dat.getElem2().getModules());
      if(dat.getElem1() != null)
        mgroup.getModules().add(dat.getElem1());
     
    }
   
    pipeline = new Pipeline(version, mgroup, connections);
   
    return pipeline;
  }
View Full Code Here

 
  /* (non-Javadoc)
   * @see Taverna.Visitor.DFSVisitor#visit(Taverna.Tree.Workflow)
   */
  public Object visit(Workflow workflow){
    Pipeline pipeline;
    String version  = workflow.getVersion();
   
    ModuleGroup moduleGroup;
    Connections connections = getConnections(workflow.getDataflow());
    moduleGroup = (ModuleGroup) visit(workflow.getDataflow());


    pipeline = new Pipeline(version, moduleGroup, connections);
    return pipeline;
  }
View Full Code Here

  /**
   * Converts a workflow into a loni pipeline.
   * @param workflow The workflow to be converted.
   */
  public Object visit(Workflow workflow) {
    Pipeline pipeline = new Pipeline();
    ModuleGroup moduleGroup = new ModuleGroup();
    LoniEnvironment le = new LoniEnvironment();
    /*
     * Create a modulegroup
     */
    moduleGroup.setDescription(workflow.getAnnotation());
    moduleGroup.setPosX(0);
    moduleGroup.setPosY(0);
    moduleGroup.setName(workflow.getName());
    moduleGroup.setRotation(0);
    //set module group as root module group in pipeline.
    pipeline.setPipelineModuleGroup(moduleGroup);
    /*
     * INITIALIZE THE SETUP, RUN MODULES
     *
     */
    /*
     * Create the setupModule.
     *
     */
    setupModule = new Module();
    setupContext = new LoniContext();
    setupModule.setId("Setup");
    setupModule.setRotation(4);
    setupModule.setName("Setup");
    setupModule.setLocation(ConverterConstants.LOCALHOST_PATH + ConverterConfig.PYTHON_BIN);
   
    //create the String parameter containing the script name for the
    //setup module.
    LONI.tree.module.Parameter setupScript = new LONI.tree.module.Parameter();
    setupScript.setEnabled(true);
    setupScript.setFileFormat(new Format());
    setupScript.getFileFormat().setCardinality(1);
    setupScript.getFileFormat().setType("String");
    setupScript.setOrder(0);
    setupScript.setName("setupScript");
    Value scriptValue = new Value();
    scriptValue.setValue("{"+SCRIPT_DIR+"}setup_workflow.py");
    setupScript.getValues().addValue(scriptValue);
    setupModule.getInputs().add(setupScript);
   
    //Create the String Parameter that contains the Galaxy API Key
    //for the setupScript Module.
    LONI.tree.module.Parameter setupAPI = new LONI.tree.module.Parameter();
    setupAPI.setEnabled(true);
    setupAPI.setFileFormat(new Format());
    setupAPI.getFileFormat().setCardinality(1);
    setupAPI.getFileFormat().setType("String");
    setupAPI.setOrder(1);
    setupAPI.setName("Galaxy API Key");
    setupAPI.setPrefix("-api-key");
    setupAPI.setPrefixSpaced(true);
    Value apiValue = new Value();
    apiValue.setValue("{"+API_KEY+"}");
    setupAPI.getValues().addValue(apiValue);
    setupModule.getInputs().add(setupAPI);
   
    /*
     * Initialize and add the String parameter that contains the Galaxy Root Directory
     * to the setup Module. This directory is used to call python scripts inside Galaxy.
     */
    LONI.tree.module.Parameter setupGalRootDir = new LONI.tree.module.Parameter();
    setupGalRootDir.setEnabled(true);
    setupGalRootDir.setFileFormat(new Format());
    setupGalRootDir.getFileFormat().setCardinality(1);
    setupGalRootDir.getFileFormat().setType("String");
    setupGalRootDir.setOrder(1);
    setupGalRootDir.setName("Galaxy Root Dir");
    setupGalRootDir.setPrefix("-galaxy-root-dir");
    setupGalRootDir.setPrefixSpaced(true);
    Value setupGalRootDirValue = new Value();
    setupGalRootDirValue.setValue("{"+GALAXY_DIR+"}");
    setupGalRootDir.getValues().addValue(setupGalRootDirValue);
    setupModule.getInputs().add(setupGalRootDir);
   
    /*
     * Initialize and add String parameter containing Galaxy server url to setup module.
     */
    LONI.tree.module.Parameter setupGalURLDir = new LONI.tree.module.Parameter();
    setupGalURLDir.setEnabled(true);
    setupGalURLDir.setFileFormat(new Format());
    setupGalURLDir.getFileFormat().setCardinality(1);
    setupGalURLDir.getFileFormat().setType("String");
    setupGalURLDir.setOrder(2);
    setupGalURLDir.setPrefixSpaced(true);
    setupGalURLDir.setName("Galaxy URL");
    setupGalURLDir.setPrefix("-galaxy-url");
    Value setupGalaxyURLValue = new Value();
    setupGalaxyURLValue.setValue("{"+GALAXY_URL+"}");
    setupGalURLDir.getValues().addValue(setupGalaxyURLValue);
    setupModule.getInputs().add(setupGalURLDir);
   
    /*
     * Initialize and add String cookie parameter containing cookie for website
     * to setup module.
     */
    LONI.tree.module.Parameter setupCookie = new LONI.tree.module.Parameter();
    setupCookie.setEnabled(true);
    setupCookie.setFileFormat(new Format());
    setupCookie.getFileFormat().setCardinality(1);
    setupCookie.getFileFormat().setType("String");
    setupCookie.setOrder(2);
    setupCookie.setName("Cookie for galaxy site");
    setupCookie.setPrefix("-cookie");
    setupCookie.setPrefixSpaced(true);
    Value setupCookieValue = new Value();
    setupCookieValue.setValue("{"+COOKIE+"}");
    setupCookie.getValues().addValue(setupCookieValue);
    setupModule.getInputs().add(setupCookie);
   
    /*
     * Initialize and fill in the run module.
     *
     */
    runModule = new Module();
    runModule.setRotation(4);
    runContext = new LoniContext();
    runModule.setId("Run");
    runModule.setLocation(ConverterConstants.LOCALHOST_PATH + ConverterConfig.PYTHON_BIN);
   
    //Add the String script parameter containing the name of the script to run.
    LONI.tree.module.Parameter runScript = new LONI.tree.module.Parameter();
    runScript.setEnabled(true);
    runScript.setFileFormat(new Format());
    runScript.getFileFormat().setCardinality(1);
    runScript.getFileFormat().setType("String");
    runScript.setOrder(0);
    runScript.setName("runScript");
    scriptValue = new Value();
    scriptValue.setValue("{"+SCRIPT_DIR+"}run_workflow.py");
    runScript.getValues().addValue(scriptValue);
    runModule.getInputs().add(runScript);
   
    //Create the workflow output to the run module. This output contains
    //a functional galaxy workflow that was generated from the loni pipeline
    //modules.
    LONI.tree.module.Output runWorkflow = new LONI.tree.module.Output();
    runWorkflow.setEnabled(true);
    runWorkflow.setFormat(new Format());
    runWorkflow.getFormat().setCardinality(1);
    runWorkflow.getFormat().setType("File");
    FileType runFileType = new FileType();
    runFileType.setName(GENERIC_DICT_TYPE);
    runFileType.setDescription("");
    runFileType.setExtension("");
    runWorkflow.getFormat().getFileTypes().addFileType(runFileType);
    runWorkflow.setOrder(0);
    runWorkflow.setPrefix("-workflow");
    runWorkflow.setPrefixSpaced(true);
    runWorkflow.setName("Workflow Data");
    runModule.getOutputs().add(runWorkflow);
   
    //Add the setup and run modules to the setup and run contexts respectively.
    setupContext.getPathContext().addContext("Setup");
    runContext.getPathContext().addContext("Run");
   
    /*
     *VISIT THE STEPS IN THE WORKFLOW
     */
     //used to place run, setup modules
    int totalY=0; // running sum of y values.
    int leftX = -1; //furthest left x position
    int rightX = 0; //furthest right y position
    int spacing = 200; //spacing between modules.
   
    // TODO Auto-generated method stub
    for(Step s : workflow.getSteps()){
      //visit each step in the workflow
      Pair<GraphObject,LoniEnvironment> step = stepVisitor.visit(s, new LoniContext());
      //add the returned environment to the pipeline environment.
      le.addEnvironment(step.getElem2());
      //add the returned graphobject to the pipeline modulegroup
      moduleGroup.getModules().add(step.getElem1());
      //add the step's y value to the running sum of y values.
      totalY += s.getPosition().getFromTop();
      //update furthest left position
      if(leftX < 0 || leftX > s.getPosition().getFromLeft())
        leftX =s.getPosition().getFromLeft();
      //update furthest right position
      if(rightX < s.getPosition().getFromLeft())
        rightX=s.getPosition().getFromLeft();
    }
    //calculate the average y value from the total.
    int avgY = totalY;
    if(workflow.getSteps().size() > 0)
      avgY = totalY / workflow.getSteps().size();
   
    //place the setup module futhest to the left, at the
    //average y value.
    setupModule.setPosX(leftX);
    setupModule.setPosY(avgY + spacing);
    //Place the run module furthest to the right, at the
    //average y value.
    runModule.setPosX(rightX+ spacing);
    runModule.setPosY(avgY);
   
    //add the run, setupmodule
    moduleGroup.getModules().add(setupModule);
    moduleGroup.getModules().add(runModule);
   
    /*
     * Connect module outputs that are not connected to anything to the
     * run module.
     */
    int conncount=1;
   
    /*
     * For each module output
     */
    for(String id : le.getOutputAliases().keySet()){
      boolean isConnected = false;
      //check if any connections link the output of that module
      //to the input of some other module.
      for(Connection c : le.getConnections()){
        if(c.getSource().equals(id))
          isConnected = true;
      }
      //If the output is not connected to any other modules.
      if(isConnected == false){
        Connection runConn; //connection to the run module
       
        //Create a new parameter for the runmodule that is connected
        //to the connectionless output.
        LONI.tree.module.Parameter runInput = new LONI.tree.module.Parameter();
        runInput.setId(runContext.getPathContext().getAbsoluteContext("conn"+conncount));
        runInput.setFileFormat(new Format());
        runInput.getFormat().setCardinality(1);
        runInput.getFormat().setType("File");
        runFileType = new FileType();
        runFileType.setName(GENERIC_DICT_TYPE);
        runFileType.setDescription("");
        runFileType.setExtension("");
        runInput.getFormat().getFileTypes().addFileType(runFileType);
        runInput.setOrder(conncount);
        runInput.setPrefix("-input");
        runInput.setPrefixSpaced(true);
        runInput.setEnabled(true);
        runInput.setName("input"+ conncount);
        //add the created input to the runmodule.
        runModule.addInput(runInput);
        //create a new connection from the connectionless output to the new run module input.
        runConn = new Connection(id, runInput.getId());
        le.addConnection(runConn);
        conncount++;
      }
    }
    //add all the connections in the environment being maintained to
    //the pipeline
    pipeline.getConnections().addConnections(le.getConnections());
    //set the moduleGroup to the pipeline moduelGroup.
    pipeline.setPipelineModuleGroup(moduleGroup);
   
    /**
     * Create Pipeline Variables
     */
   
 
View Full Code Here

    System.out.println("==="+path+"===");
    Workflow G;
    try {
      G = GalaxySpecification.getJSONParser().parse(new File(path));
      GalaxyToLoniWorkflowConverter glc = new GalaxyToLoniWorkflowConverter();
      Pipeline pipeline = (Pipeline) glc.visit(G);
     
      try {
        LoniSpecification.getXMLGenerator().generate(pipeline, output);
      } catch (IOException e) {
        // TODO Auto-generated catch block
View Full Code Here

   
  }
 
  public static void testLoniXML(String path, String output){
    System.out.println("==="+path+"===");
    Pipeline G;
    try {
      G = LoniSpecification.getXMLParser().parse(new File(path));
      try {
        LoniSpecification.getXMLGenerator().generate(G, output);
      } catch (IOException e) {
View Full Code Here

    Workflow G;
    try {
      G = GalaxySpecification.getJSONParser().parse(new File(path));
      Galaxy.Visitor.Webservice.GalaxyToLoniWorkflowConverter glc;
      glc = new Galaxy.Visitor.Webservice.GalaxyToLoniWorkflowConverter();
      Pipeline pipeline = (Pipeline) glc.visit(G);
     
      try {
        LoniSpecification.getXMLGenerator().generate(pipeline, output);
      } catch (IOException e) {
        // TODO Auto-generated catch block
View Full Code Here

 
  }
  private static void testPipelineConverter(String path, String output) {
    // TODO Auto-generated method stub
    System.out.println("==="+path+"===");
    Pipeline p;
    try {
      p = LoniSpecification.getXMLParser().parse(new File(path));
      LoniToGalaxyConverter lgc = new LoniToGalaxyConverter();
      Workflow workflow = (Workflow) lgc.visit(p);
     
View Full Code Here

    try {
      Galaxy.Visitor.Local.GalaxyToLoniWorkflowConverter glc;
      glc = new Galaxy.Visitor.Local.GalaxyToLoniWorkflowConverter();
     
      G = GalaxySpecification.getJSONParser().parse(new File(path));
      Pipeline pipeline = (Pipeline) glc.visit(G);
     
      try {
        LoniSpecification.getXMLGenerator().generate(pipeline, output);
      } catch (IOException e) {
        // TODO Auto-generated catch block
View Full Code Here

    try {
      Galaxy.Visitor.Webservice.GalaxyToLoniWorkflowConverter glc;
      glc = new Galaxy.Visitor.Webservice.GalaxyToLoniWorkflowConverter();
     
      G = GalaxySpecification.getJSONParser().parse(new File(path));
      Pipeline pipeline = (Pipeline) glc.visit(G);
     
      try {
        LoniSpecification.getXMLGenerator().generate(pipeline, output);
      } catch (IOException e) {
        // TODO Auto-generated catch block
View Full Code Here

TOP

Related Classes of LONI.tree.workflow.Pipeline

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.