private void printList(List<String> list) {
   System.out.print("(");
   int ct = 0;
   for (String value : list) {
     if (value.isEmpty()) {
       value = "[]";
     }
     System.out.print(value);
     if (++ct < list.size()) {
       System.out.print(", ");
     }
   }
   System.out.print(")\t\t");
 }
  private Map<String, DiseaseFreeData> getDiseaseFreeDataForMatrix(DataMatrix dataMatrix) {
    Map<String, DiseaseFreeData> diseaseFreeDataMap = new HashMap<String, DiseaseFreeData>();

    List<String> patientIds = getPatientIds(dataMatrix);
    for (int lc = 0; lc < patientIds.size(); lc++) {
      String patientId = patientIds.get(lc);
      DiseaseFreeData df = getDiseaseFreeDataForPatient(lc, dataMatrix);
      if (diseaseFreeDataMap.containsKey(patientId)) {
        df = mergeDiseaseFreeData(diseaseFreeDataMap.get(patientId), df);
      }
      diseaseFreeDataMap.put(patientId, df);
    }

    return diseaseFreeDataMap;
  }
 private List<String> computeOverallSurvivalStatus(Map<String, SurvivalData> survivalData) {
   List<String> osStatus = initializeList(canonicalPatientList.size());
   for (String patientId : survivalData.keySet()) {
     int osStatusIndex = canonicalPatientList.indexOf(patientId);
     SurvivalData sd = survivalData.get(patientId);
     if (VitalStatusAlive.has(sd.vitalStatus)) {
       osStatus.set(osStatusIndex, VitalStatusAlive.LIVING.toString());
     } else if (VitalStatusDead.has(sd.vitalStatus)) {
       osStatus.set(osStatusIndex, VitalStatusDead.DECEASED.toString());
     } else {
       osStatus.set(osStatusIndex, ClinicalAttribute.NA);
     }
   }
   return osStatus;
 }
  private Map<String, SurvivalData> getSurvivalDataForMatrix(DataMatrix dataMatrix) {
    Map<String, SurvivalData> survivalDataMap = new HashMap<String, SurvivalData>();

    List<String> patientIds = getPatientIds(dataMatrix);
    for (int lc = 0; lc < patientIds.size(); lc++) {
      String patientId = patientIds.get(lc);
      SurvivalData sd = getSurvivalDataForPatient(lc, dataMatrix);
      if (survivalDataMap.containsKey(patientId)) {
        sd = mergeSurvivalData(survivalDataMap.get(patientId), sd);
      }
      survivalDataMap.put(patientId, sd);
    }

    return survivalDataMap;
  }
  private List<String> computeOverallSurvivalMonths(Map<String, SurvivalData> survivalData) {
    List<String> osStatusMonths = initializeList(canonicalPatientList.size());
    for (String patientId : survivalData.keySet()) {
      int osStatusMonthsIndex = canonicalPatientList.indexOf(patientId);
      SurvivalData sd = survivalData.get(patientId);
      if (VitalStatusAlive.has(sd.vitalStatus)) {
        osStatusMonths.set(
            osStatusMonthsIndex, convertDaysToMonths(sd.lastFollowUp, sd.lastKnownAlive));
      } else if (VitalStatusDead.has(sd.vitalStatus)) {
        osStatusMonths.set(osStatusMonthsIndex, convertDaysToMonths(sd.daysToDeath));
      } else {
        osStatusMonths.set(osStatusMonthsIndex, ClinicalAttribute.NA);
      }
    }

    return osStatusMonths;
  }
 private List<String> computeDiseaseFreeStatus(Map<String, DiseaseFreeData> diseaseFreeData) {
   List<String> dfStatus = initializeList(canonicalPatientList.size());
   for (String patientId : diseaseFreeData.keySet()) {
     int dfStatusIndex = canonicalPatientList.indexOf(patientId);
     DiseaseFreeData df = diseaseFreeData.get(patientId);
     if (patientIsDiseaseFree(df)) {
       dfStatus.set(dfStatusIndex, DiseaseFreeStatus.DISEASE_FREE.toString());
     } else {
       try {
         Integer.parseInt(df.daysToNewTumorEventAfterInitialTreatment);
         dfStatus.set(dfStatusIndex, DiseaseFreeStatus.DISEASED.toString());
       } catch (NumberFormatException e) {
         dfStatus.set(dfStatusIndex, ClinicalAttribute.NA);
       }
     }
   }
   return dfStatus;
 }
  private List<String> computeDiseaseFreeMonths(Map<String, DiseaseFreeData> diseaseFreeData) {
    List<String> dfStatusMonths = initializeList(canonicalPatientList.size());
    for (String patientId : diseaseFreeData.keySet()) {
      int dfStatusMonthsIndex = canonicalPatientList.indexOf(patientId);
      DiseaseFreeData df = diseaseFreeData.get(patientId);
      try {
        if (patientIsDiseaseFree(df)) {
          dfStatusMonths.set(
              dfStatusMonthsIndex, convertDaysToMonths(df.lastFollowUp, df.lastKnownAlive));
        } else {
          int dfStatusDays = Integer.parseInt(df.daysToNewTumorEventAfterInitialTreatment);
          dfStatusMonths.set(
              dfStatusMonthsIndex, convertDaysToMonths(Integer.toString(dfStatusDays)));
        }
      } catch (NumberFormatException e) {
        dfStatusMonths.set(dfStatusMonthsIndex, ClinicalAttribute.NA);
      }
    }

    return dfStatusMonths;
  }