Package LONI.tree.module.format

Examples of LONI.tree.module.format.Format


   
    //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("");
View Full Code Here


    String sinkProcessor = "";
    Link source;
    Link sink;
    Parameter parameter = null;
    Output output = null;
    Format format;
    FileTypes fileTypes;
   

    for(DataLink d : datalinks){
      source = d.getSource();
      sourceLinkType = source.getLinkType();
      sourcePort = source.getPort();
      sourceProcessor = source.getProcessor();
     
      sink = d.getSink();
      sinkLinkType = sink.getLinkType();
      sinkPort = sink.getPort();
      sinkProcessor = sink.getProcessor();
     
     
      // Even if the Taverna port is a SOURCE, that will correspond to Output.class in LONI. It's weird, but you have to be careful. In side the Input of LONI, the dataModule actually contains <output>, not <input>!
      if(sinkPort == inputPortName){
        parameter = new Parameter();
        parameter.setId(dataModule.getId() +".Input");
        parameter.setName(inputPortName);
        parameter.setDescription("Input description");
        parameter.setRequired(true);
        parameter.setEnabled(true);
        parameter.setOrder(tavernaContext.getNextOrder());
        parameter.setLink("");
        parameter.setValues(new Values());
        // Create a new Format for parameter
        format = new Format();
        format.setType("File");
        format.setCardinality(1);
        format.setCardinalityBase("");
          format.setTransformationBase("");
         
        // Create and fill in file types for format
        fileTypes = new FileTypes();
        fileTypes.addFileType(new FileType(TavernaType, "", ""));
        format.setFileTypes(fileTypes);
       
        // Give parameter the newly created Format object
        parameter.setFileFormat(format);
       
        dataModule.addInput(parameter);
        break;
      }
      else if(sourcePort == inputPortName){
        output = new Output();
        output.setId(dataModule.getId() +".Output");
        output.setName(inputPortName);
        output.setDescription("Output description");
        output.setRequired(true);
        output.setEnabled(true);
        output.setOrder(tavernaContext.getNextOrder());
        output.setLink("");
        output.setValues(new Values());
        // Create a new Format for output
        output.setFormat(new Format());
        output.getFormat().setType("File");
        output.getFormat().setCardinality(1);
        output.getFormat().setCardinalityBase("");
        output.getFormat().setTransformationBase("");
       
View Full Code Here

    p.setName( input.getName());
    p.setPrefix(input.getName()+"=");
    p.setEnabled(true);
    p.setOrder(1);
    p.setPrefixSpaced(false);
    p.setFileFormat(new Format());
    p.getFormat().setCardinality(1);
    p.getFormat().setType("File");
    if(input.getTranslatedElementType() != null){
      String elem_class = input.getTranslatedElementType();
      if(elem_class.equals("java.lang.String")){
View Full Code Here

    out.setName( output.getName());
    out.setPrefix("*"+output.getName()+"=");
    out.setEnabled(true);
    out.setOrder(1);
    out.setPrefixSpaced(false);
    out.setFormat(new Format());
    out.getFormat().setType("File");
    out.getFormat().setCardinality(1);
    FileType ft =new FileType();
    ft.setDescription("");
    ft.setExtension("");
View Full Code Here

   
    Parameter scriptParam = new Parameter();
    scriptParam.setName("Beanshell wrapper script");
    scriptParam.setEnabled(true);
    scriptParam.setOrder(0);
    scriptParam.setFileFormat(new Format());
    scriptParam.getFileFormat().setType("String");
    scriptParam.getFileFormat().setCardinality(1);
    Value val = new Value();
    val.setValue(wrapper);
    scriptParam.getValues().addValue(val);
    args.add(scriptParam);       
   
    if(c.getlWACB() != null){
      Parameter scriptBody = new Parameter();
      scriptBody.setName("Beanshell script body");
      scriptBody.setEnabled(true);
      scriptBody.setOrder(1);
      scriptBody.setPrefix("@");
      scriptBody.setPrefixSpaced(false);
      scriptBody.setFileFormat(new Format());
      scriptBody.getFileFormat().setType("String");
      scriptBody.getFileFormat().setCardinality(1);
      Value myval = new Value();
      myval.setValue(cleanStringValue(c.getlWACB().getScript()));
      scriptBody.getValues().addValue(myval);
View Full Code Here

TOP

Related Classes of LONI.tree.module.format.Format

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.