Example #1
0
  public ActionForward setup(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {
    GpIntegrationForm gpForm = (GpIntegrationForm) form;
    /*setup the defined Disease query names and the list of samples selected from a Resultset*/
    ClinicalGroupRetriever clinicalGroupRetriever =
        new ClinicalGroupRetriever(request.getSession());
    gpForm.setExistingGroupsList(clinicalGroupRetriever.getClinicalGroupsCollection());

    UserListBeanHelper listHelper = new UserListBeanHelper(request.getSession());
    // fetch the users gene groups populate the dropdown
    List<String> names = (List<String>) listHelper.getGenericListNames(ListType.Gene);
    List<LabelValueBean> gsNameList = new ArrayList<LabelValueBean>();
    for (String listName : names) {
      gsNameList.add(new LabelValueBean(listName, listName));
    }
    gpForm.setGeneSetNameList(gsNameList);
    return mapping.findForward("success");
  }
Example #2
0
  private ISPYGPIntegrationQueryDTO createGPIntegrationQueryDTO(
      GpIntegrationForm gpQueryForm, HttpSession session) {

    ISPYGPIntegrationQueryDTO gpQueryDTO =
        (ISPYGPIntegrationQueryDTO)
            ApplicationFactory.newQueryDTO(QueryType.PROBESET_CLONEID_QUERY_FOR_HOA);
    gpQueryDTO.setQueryName(gpQueryForm.getAnalysisResultName());

    HashMap<String, UserList> patientLists = new HashMap<String, UserList>();
    HashMap<String, Set<TimepointType>> timepointLists = new HashMap<String, Set<TimepointType>>();
    UserListBeanHelper listHelper = new UserListBeanHelper(session);
    String groupTimepoint = null;
    String groupName = null;
    String timePointName = null;
    if (gpQueryForm.getSelectedGroups() != null && gpQueryForm.getSelectedGroups().length > 0) {
      for (int i = 0; i < gpQueryForm.getSelectedGroups().length; i++) {
        groupTimepoint = gpQueryForm.getSelectedGroups()[i];
        int index = groupTimepoint.lastIndexOf("---");
        groupName = groupTimepoint.substring(0, index);
        timePointName = groupTimepoint.substring(index + 3);
        UserList userList = listHelper.getUserList(groupName);
        patientLists.put(groupTimepoint, userList);
        String[] times = timePointName.split("-");
        String fixedTimepointString = null;
        Set<TimepointType> set = new HashSet<TimepointType>();
        for (String time : times) {
          TimepointType fixedTimepointBase; // timepoint for both queryDTOs
          fixedTimepointString = EnumHelper.getEnumTypeName(time, TimepointType.values());
          if (fixedTimepointString != null) {
            fixedTimepointBase = TimepointType.valueOf(fixedTimepointString);
            set.add(fixedTimepointBase);
          }
        }
        timepointLists.put(groupTimepoint, set);
      }
    }
    gpQueryDTO.setPatientLists(patientLists);
    gpQueryDTO.setTimepointLists(timepointLists);

    // UserListBeanHelper listHelper = new UserListBeanHelper(session);
    if (gpQueryForm.getGeneSetName() != null
        && (!gpQueryForm.getGeneSetName().equals("")
            && !gpQueryForm.getGeneSetName().equals("none"))) {
      geneIdentifierDECollection = listHelper.getGeneDEforList(gpQueryForm.getGeneSetName());
      if (geneIdentifierDECollection != null && !geneIdentifierDECollection.isEmpty()) {
        logger.debug("geneIdentifierDECollection was found");
        gpQueryDTO.setGeneIdentifierDEs(geneIdentifierDECollection);
        gpQueryDTO.setReportersName(gpQueryForm.getGeneSetName());
      } else {
        logger.debug("geneIdentifierDECollection could not be found");
      }
    }
    // Create arrayPlatfrom DEs
    if (gpQueryForm.getArrayPlatform() != "" || gpQueryForm.getArrayPlatform().length() != 0) {
      ArrayPlatformDE arrayPlatformDE = new ArrayPlatformDE(gpQueryForm.getArrayPlatform());
      gpQueryDTO.setArrayPlatformDE(arrayPlatformDE);
    }

    return gpQueryDTO;
  }
Example #3
0
  /**
   * Method submittal
   *
   * @param ActionMapping mapping
   * @param ActionForm form
   * @param HttpServletRequest request
   * @param HttpServletResponse response
   * @return ActionForward
   * @throws Exception
   */
  public ActionForward submit(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {

    GpIntegrationForm gpForm = (GpIntegrationForm) form;
    String sessionId = request.getSession().getId();
    HttpSession session = request.getSession();
    ISPYGPIntegrationQueryDTO ispyGPIntegrationQueryDTO =
        createGPIntegrationQueryDTO(gpForm, session);

    // to filter id with time points
    ISPYFindingsFactory findingFactory = new ISPYFindingsFactory();
    try {
      findingFactory.createGPIntegrationSampleIds(ispyGPIntegrationQueryDTO, sessionId);
    } catch (FrameworkException fwe) {
      logger.error(fwe.getMessage());
      fwe.printStackTrace();
    }
    SampleGroup[] sampleGroups = ispyGPIntegrationQueryDTO.getSampleGroups();
    // Now let's check id overlapping problem.
    if (isIdOverlap(sampleGroups)) {
      ActionErrors errors = new ActionErrors();
      errors.add(
          "selectedGroups1",
          new ActionMessage("gov.nih.nci.nautilus.ui.struts.form.groups.intersect.error"));
      this.saveErrors(request, errors);
      return setup(mapping, form, request, response);
    }

    List<List<String>> allStringList = new ArrayList<List<String>>();
    List<String> fileNameList = new ArrayList<String>();
    List<String> idStringList = new ArrayList<String>();
    List<String> reportIdStringList = new ArrayList<String>();

    String gpModule = System.getProperty("gov.nih.nci.caintegrator.gp.modulename");
    String analysisResultName =
        (gpForm.getAnalysisResultName() != null && !gpForm.getAnalysisResultName().equals(""))
            ? (String) gpForm.getAnalysisResultName()
            : "unnamed_task";

    // for sample Id file
    for (SampleGroup sampleGroup : sampleGroups) {
      idStringList.add(getIdsAsDelimitedString(sampleGroup, "\t"));
    }
    allStringList.add(idStringList);
    fileNameList.add("labIdsFile");

    // for reporter id file
    ReporterGroup reporterGroup = ispyGPIntegrationQueryDTO.getReporterGroup();
    if (reporterGroup != null && reporterGroup.size() > 0) {
      reportIdStringList.add(getIdsAsDelimitedString(reporterGroup, "\t"));
      allStringList.add(reportIdStringList);
      fileNameList.add("reproterIdsFile");
    } else {
      reportIdStringList.add("reporter=NONE");
      allStringList.add(reportIdStringList);
      fileNameList.add("reproterIdsFile");
    }
    // For class file
    // makeClassFile(classStringList, sampleGroups);
    // allStringList.add(classStringList);
    // fileNameList.add("ispyClassFile");

    // Now let's write them to files
    List<String> filePathList = new ArrayList<String>();
    writeGPFile(filePathList, allStringList, fileNameList);

    // Now get the R-binary file name:
    String r_fileName = null;
    String a_fileName = null;
    if (ispyGPIntegrationQueryDTO.getArrayPlatformDE().getValueObjectAsArrayPlatformType()
        == ArrayPlatformType.AGILENT) {
      r_fileName = System.getProperty("gov.nih.nci.ispyportal.agilent_data_matrix");
      a_fileName = System.getProperty("gov.nih.nci.ispyportal.agilent_data_annotation");
    } else {
      r_fileName = System.getProperty("gov.nih.nci.ispyportal.cdna_data_matrix");
      a_fileName = System.getProperty("gov.nih.nci.ispyportal.cdna_data_annotation");
    }

    // *** RUN TASK ON THE GP SERVER
    String tid = "209";

    String gpserverURL =
        System.getProperty("gov.nih.nci.caintegrator.gp.server") != null
            ? (String) System.getProperty("gov.nih.nci.caintegrator.gp.server")
            : "localhost:8080"; // default to localhost
    try {
      String ispyUser = (String) session.getAttribute("name");
      String publicUser = System.getProperty("gov.nih.nci.caintegrator.gp.publicuser.name");
      String password = System.getProperty("gov.nih.nci.caintegrator.gp.publicuser.password");

      // Check to see the user is already created otherwise create one.

      GPServer gpServer = null;
      if (ispyUser.equals(publicUser)) {
        String gpUser = (String) session.getAttribute(GenePatternPublicUserPool.PUBLIC_USER_NAME);
        if (gpUser == null) {
          PublicUserPool pool = GenePatternPublicUserPool.getInstance();
          gpUser = pool.borrowPublicUser();
          session.setAttribute(GenePatternPublicUserPool.PUBLIC_USER_NAME, gpUser);
          session.setAttribute(GenePatternPublicUserPool.PUBLIC_USER_POOL, pool);
        }
        ispyUser = gpUser;
      }
      String encryptKey = System.getProperty("gov.nih.nci.caintegrator.gp.desencrypter.key");
      String urlString = EncryptionUtil.encrypt(ispyUser + gpPoolString, encryptKey);
      urlString = URLEncoder.encode(urlString, "UTF-8");
      String ticketString = gpserverURL + "gp?ticket=" + urlString;

      logger.debug(ticketString);
      URL url;
      try {
        url = new java.net.URL(ticketString);
        URLConnection conn = url.openConnection();
        final int size = conn.getContentLength();
        logger.debug(Integer.toString(size));

      } catch (Exception e) {
        logger.error(e.getMessage());
      }
      gpServer = new GPServer(gpserverURL, ispyUser, password);

      // GPServer gpServer = new GPServer(gpserverURL, gpuname, password);
      Parameter[] par = new Parameter[filePathList.size() + 3 + 3];
      int currpos = 1;
      for (int i = 0; i < filePathList.size(); i++) {
        par[i] = new Parameter("input.filename" + currpos++, filePathList.get(i));
      }
      par[--currpos] = new Parameter("project.name", "ispy");

      // r_fileName = "'/usr/local/genepattern/resources/DataMatrix_ISPY_306cDNA_17May07.Rda'";
      par[++currpos] = new Parameter("array.filename", r_fileName);
      par[++currpos] = new Parameter("annotation.filename", a_fileName);

      par[++currpos] = new Parameter("analysis.name", analysisResultName);

      // always just 2
      par[++currpos] = new Parameter("output.cls.file", analysisResultName + ".cls");
      par[++currpos] = new Parameter("output.gct.file", analysisResultName + ".gct");

      // JobResult preprocess = gpServer.runAnalysis(gpModule, par);
      int nowait = gpServer.runAnalysisNoWait(gpModule, par);

      tid = String.valueOf(nowait);
      request.setAttribute("jobId", tid);
      request.setAttribute("gpStatus", "running");
      session.setAttribute("genePatternServer", gpServer);
      request.setAttribute("genePatternURL", ticketString);
      request.getSession().setAttribute("gptid", tid);
      request.getSession().setAttribute("gpUserId", ispyUser);
      request.getSession().setAttribute("ticketString", ticketString);
      GPTask gpTask = new GPTask(tid, analysisResultName, FindingStatus.Running);
      PresentationTierCache _cacheManager = ApplicationFactory.getPresentationTierCache();
      _cacheManager.addNonPersistableToSessionCache(
          request.getSession().getId(), "latestGpTask", (Serializable) gpTask);

    } catch (Exception e) {
      StringWriter sw = new StringWriter();
      PrintWriter pw = new PrintWriter(sw);
      e.printStackTrace(pw);
      logger.error(sw.toString());
      logger.error(gpModule + " failed...." + e.getMessage());
      throw new Exception(e.getMessage());
    }
    return mapping.findForward("viewJob");
  }