コード例 #1
0
  @Before
  public void setUp() throws DaoException {
    DaoCancerStudy.reCacheAll();
    DaoGeneOptimized.getInstance().reCache();
    ProgressMonitor.resetWarnings();

    studyId = DaoCancerStudy.getCancerStudyByStableId("study_tcga_pub").getInternalId();

    GeneticProfile newGeneticProfile = new GeneticProfile();
    newGeneticProfile.setCancerStudyId(studyId);
    newGeneticProfile.setGeneticAlterationType(GeneticAlterationType.COPY_NUMBER_ALTERATION);
    newGeneticProfile.setStableId("study_tcga_pub_test");
    newGeneticProfile.setProfileName("Barry CNA Results");
    newGeneticProfile.setDatatype("test");
    DaoGeneticProfile.addGeneticProfile(newGeneticProfile);

    geneticProfileId =
        DaoGeneticProfile.getGeneticProfileByStableId("study_tcga_pub_test").getGeneticProfileId();

    sample1 =
        DaoSample.getSampleByCancerStudyAndSampleId(studyId, "TCGA-A1-A0SB-01").getInternalId();
    sample2 =
        DaoSample.getSampleByCancerStudyAndSampleId(studyId, "TCGA-A1-A0SD-01").getInternalId();
    sample3 =
        DaoSample.getSampleByCancerStudyAndSampleId(studyId, "TCGA-A1-A0SE-01").getInternalId();
    sample4 =
        DaoSample.getSampleByCancerStudyAndSampleId(studyId, "TCGA-A1-A0SF-01").getInternalId();
    sample5 =
        DaoSample.getSampleByCancerStudyAndSampleId(studyId, "TCGA-A1-A0SG-01").getInternalId();
  }
コード例 #2
0
  /**
   * Given an HttpServletRequest, determine all cancer_study_ids associated with it. cancer study
   * identifiers can be inferred from profile_ids, case_list_ids, or case_ids. this returns the set
   * of ALL POSSIBLE cancer study identifiers
   *
   * @param request
   * @return the cancer_study_ids associated with the request, which will be empty if none can be
   *     determined; or empty set if a problem arises.
   * @throws DaoException
   * @throws ProtocolException
   */
  public static HashSet<String> getCancerStudyIDs(HttpServletRequest request)
      throws DaoException, ProtocolException {

    HashSet<String> cancerStudies = new HashSet<String>();

    // a CANCER_STUDY_ID is explicitly provided, as in getGeneticProfiles, getCaseLists, etc.
    // make sure the cancer_study_id provided in the request points to a real study
    String studyIDstring = getCancerStudyId(request);
    if (studyIDstring != null) {
      if (DaoCancerStudy.doesCancerStudyExistByStableId(studyIDstring)) {
        cancerStudies.add(studyIDstring);
      }

      return cancerStudies;
    }

    // a genetic_profile_id is explicitly provided, as in getProfileData
    if (null != request.getParameter(WebService.GENETIC_PROFILE_ID)) {
      ArrayList<String> geneticProfileIds = getGeneticProfileId(request);
      for (String geneticProfileId : geneticProfileIds) {

        // that's the point of this code??
        //                if (geneticProfileId == null) {
        //                    return cancerStudies;
        //                }

        GeneticProfile aGeneticProfile =
            DaoGeneticProfile.getGeneticProfileByStableId(geneticProfileId);
        if (aGeneticProfile != null
            && DaoCancerStudy.doesCancerStudyExistByInternalId(
                aGeneticProfile.getCancerStudyId())) {
          cancerStudies.add(
              DaoCancerStudy.getCancerStudyByInternalId(aGeneticProfile.getCancerStudyId())
                  .getCancerStudyStableId());
        }
      }

      return cancerStudies;
    }

    // a patient_set_id is explicitly provided, as in getProfileData, getMutationData,
    // getClinicalData, etc.
    String sampleSetId = request.getParameter(WebService.CASE_SET_ID);
    if (sampleSetId != null) {
      DaoSampleList aDaoSampleList = new DaoSampleList();
      SampleList aSampleList = aDaoSampleList.getSampleListByStableId(sampleSetId);

      if (aSampleList != null
          && DaoCancerStudy.doesCancerStudyExistByInternalId(aSampleList.getCancerStudyId())) {
        cancerStudies.add(
            DaoCancerStudy.getCancerStudyByInternalId(aSampleList.getCancerStudyId())
                .getCancerStudyStableId());
      }

      return cancerStudies;
    }

    return cancerStudies;
  }
コード例 #3
0
  private boolean validate(HttpServletRequest request) throws DaoException {
    String cancerStudyID = request.getParameter(ID);
    if (cancerStudyID == null) {
      cancerStudyID = request.getParameter(QueryBuilder.CANCER_STUDY_ID);
    }

    CancerStudy cancerStudy = DaoCancerStudy.getCancerStudyByStableId(cancerStudyID);
    if (cancerStudy == null) {
      try {
        cancerStudy = DaoCancerStudy.getCancerStudyByInternalId(Integer.parseInt(cancerStudyID));
      } catch (NumberFormatException ex) {
      }
    }
    if (cancerStudy == null) {
      request.setAttribute(ERROR, "No such cancer study");
      return false;
    }
    String cancerStudyIdentifier = cancerStudy.getCancerStudyStableId();

    if (accessControl.isAccessibleCancerStudy(cancerStudyIdentifier).size() != 1) {
      request.setAttribute(
          ERROR,
          "You are not authorized to view the cancer study with id: '"
              + cancerStudyIdentifier
              + "'. ");
      return false;
    } else {
      UserDetails ud = accessControl.getUserDetails();
      if (ud != null) {
        logger.info("CancerStudyView.validate: Query initiated by user: "******"_all";
      request.setAttribute(QueryBuilder.CASE_SET_ID, sampleListId);
    }

    SampleList sampleList = daoSampleList.getSampleListByStableId(sampleListId);
    if (sampleList == null) {
      request.setAttribute(ERROR, "Could not find sample list of '" + sampleListId + "'. ");
      return false;
    }

    request.setAttribute(QueryBuilder.CASE_IDS, sampleList.getSampleList());

    request.setAttribute(CANCER_STUDY, cancerStudy);
    request.setAttribute(QueryBuilder.HTML_TITLE, cancerStudy.getName());
    return true;
  }
コード例 #4
0
 @Before
 public void setUp() throws DaoException {
   study = DaoCancerStudy.getCancerStudyByStableId("study_tcga_pub");
   DaoGeneticProfile.reCache();
   DaoPatient.reCache();
   DaoSample.reCache();
 }
コード例 #5
0
  private void processRequestStatistics(
      HttpServletRequest request, HttpServletResponse response, String type)
      throws ServletException, IOException {
    String cancerStudyIds = request.getParameter(QueryBuilder.CANCER_STUDY_ID);

    try {
      boolean includeMut = "mut".equalsIgnoreCase(type);
      boolean includeCna = "cna".equalsIgnoreCase(type);

      Map<String, Map<String, Object>> data = new HashMap<String, Map<String, Object>>();
      // get list of cancer studies
      AccessControl accessControl = getaccessControl();
      List<CancerStudy> cancerStudies;
      if (cancerStudyIds == null || cancerStudyIds.isEmpty()) {
        cancerStudies = accessControl.getCancerStudies();
      } else {
        cancerStudies = new ArrayList<CancerStudy>();
        for (String studyId : cancerStudyIds.split("[ ,]+")) {
          CancerStudy study = DaoCancerStudy.getCancerStudyByStableId(studyId);
          if (study != null && !accessControl.isAccessibleCancerStudy(studyId).isEmpty()) {
            cancerStudies.add(study);
          }
        }
      }
      for (CancerStudy cancerStudy : cancerStudies) {
        if (cancerStudy.getCancerStudyStableId().equalsIgnoreCase("all")) {
          continue;
        }
        Map<String, Object> row = new HashMap<String, Object>();
        data.put(cancerStudy.getCancerStudyStableId(), row);

        if (!includeMut && !includeMut) {
          row.put("name", cancerStudy.getName());
          String pmid = cancerStudy.getPmid();
          if (pmid != null) {
            row.put("pmid", pmid);
          }
          String citation = cancerStudy.getCitation();
          if (citation != null) {
            row.put("citation", citation);
          }
          row.put(
              "cases", DaoPatient.getPatientsByCancerStudyId(cancerStudy.getInternalId()).size());
        }

        if (includeMut) {
          GeneticProfile mutProfile = cancerStudy.getMutationProfile();
          if (mutProfile == null) {
            row.put("mut", 0);
          } else {
            int mutEvents = DaoMutation.countMutationEvents(mutProfile.getGeneticProfileId());
            int samplesWithMut =
                DaoSampleProfile.countSamplesInProfile(mutProfile.getGeneticProfileId());
            row.put("mut", 1.0 * mutEvents / samplesWithMut);
          }
        }

        if (includeCna) {
          GeneticProfile cnaProfile = cancerStudy.getCopyNumberAlterationProfile(false);
          if (cnaProfile == null) {
            row.put("cna", 0);
          } else {
            List<Integer> samples =
                DaoSampleProfile.getAllSampleIdsInProfile(cnaProfile.getGeneticProfileId());
            Map<Integer, Double> fracs =
                DaoCopyNumberSegment.getCopyNumberActeredFraction(
                    samples,
                    cnaProfile.getCancerStudyId(),
                    GlobalProperties.getPatientViewGenomicOverviewCnaCutoff()[0]);
            double aveFrac = 0;
            for (double frac : fracs.values()) {
              aveFrac += frac;
            }
            aveFrac /= samples.size();
            row.put("cna", aveFrac);
          }
        }
      }

      response.setContentType("application/json");

      PrintWriter out = response.getWriter();
      try {
        JSONValue.writeJSONString(data, out);
      } finally {
        out.close();
      }
    } catch (DaoException ex) {
      throw new ServletException(ex);
    } catch (ProtocolException ex) {
      throw new ServletException(ex);
    }
  }