/**
   * Grabs the appropriate stuff from a request and returns a list of case_ids
   *
   * @param request
   * @return
   * @throws ProtocolException
   * @throws DaoException
   */
  public static ArrayList<String> getSampleIds(HttpServletRequest request)
      throws ProtocolException, DaoException {
    String samples = request.getParameter(WebService.CASE_LIST);
    String sampleSetId = request.getParameter(WebService.CASE_SET_ID);
    String sampleIdsKey = request.getParameter(WebService.CASE_IDS_KEY);

    if (sampleIdsKey != null) {
      samples = SampleSetUtil.getSampleIds(sampleIdsKey);
    }

    ArrayList<String> sampleList = new ArrayList<String>();
    if (sampleSetId != null && !(sampleSetId.equals("-1"))) {
      DaoSampleList dao = new DaoSampleList();
      SampleList selectedSampleList = dao.getSampleListByStableId(sampleSetId);
      if (selectedSampleList == null) {
        throw new ProtocolException(
            "Invalid " + WebService.CASE_SET_ID + ":  " + sampleSetId + ".");
      }
      sampleList = selectedSampleList.getSampleList();
    } else if (samples != null) {
      for (String _sample : samples.split("[\\s,]+")) {
        _sample = _sample.trim();
        if (_sample.length() == 0) continue;
        sampleList.add(_sample);
      }
    } else if (samples != null) { // todo: this is a hack, samples is just another word for patients
      return new ArrayList(Arrays.asList(samples.split(" ")));
    } else {
      throw new ProtocolException(
          WebService.CASE_SET_ID + " or " + WebService.CASE_LIST + " must be specified.");
    }
    return sampleList;
  }
예제 #2
0
  /**
   * Test importing of Clinical Data File.
   *
   * @throws DaoException Database Access Error.
   * @throws IOException IO Error.
   */
  @Test
  @Ignore("To be fixed")
  public void testImportClinicalDataSlice() throws Exception {

    // TBD: change this to use getResourceAsStream()
    File clinicalFile = new File("target/test-classes/clinical_data.txt");
    ImportClinicalData importClinicalData = new ImportClinicalData(study, clinicalFile);
    importClinicalData.importData();

    List<ClinicalParameterMap> slice =
        DaoClinicalData.getDataSlice(study.getInternalId(), Arrays.asList("PLATINUMSTATUS"));
    assertTrue(slice.size() >= 1);

    ClinicalParameterMap paramMap = slice.get(0);
    assertEquals("PLATINUMSTATUS", paramMap.getName());
    assertEquals("Sensitive", paramMap.getValue("TCGA-A1-A0SD"));
    assertEquals("NA", paramMap.getValue("TCGA-A1-A0SE"));
    assertEquals(2, paramMap.getDistinctCategories().size());
  }