コード例 #1
0
ファイル: HeatMapData.java プロジェクト: vagisha/msdapl
  public HeatMapData(ProteinGroupComparisonDataset grpComparison) {

    datasetLabels = new ArrayList<String>(grpComparison.getDatasetCount() + 1);

    for (Dataset ds : grpComparison.getDatasets()) {
      if (ds.getDatasetName() != null && ds.getDatasetName().length() > 0) {
        datasetLabels.add((ds.getDatasetName() + "(ID" + ds.getDatasetId()) + ")");
      } else {
        datasetLabels.add(("ID_" + ds.getDatasetId()));
      }
    }

    rows = new ArrayList<HeatMapRow>(grpComparison.getTotalProteinGroupCount() + 1);

    int index = 0;
    for (ComparisonProteinGroup grp : grpComparison.getProteinsGroups()) {

      HeatMapRow row = new HeatMapRow();
      row.setIndexInList(index);
      index += grp.getProteins().size();
      rows.add(row);

      ComparisonProtein protein = grp.getProteins().get(0);

      List<HeatMapCell> cells = new ArrayList<HeatMapCell>();

      // add cell for molecular wt.
      String molWtCellColor = getColorForMolWt(protein.getMolecularWeight());
      HeatMapCell cell1 = new HeatMapCell();
      cell1.setLabel("");
      cell1.setHexColor(molWtCellColor);
      cells.add(cell1);

      row.setRowName(protein.getProteinListing().getFastaReferences().get(0).getShortAccession());

      List<String> allNames = new ArrayList<String>();
      for (ComparisonProtein prot : grp.getProteins()) {
        allNames.add(prot.getProteinListing().getFastaReferences().get(0).getShortAccession());
      }
      row.setRowAllNames(allNames);

      for (Dataset ds : grpComparison.getDatasets()) {

        HeatMapCell cell = new HeatMapCell();
        cells.add(cell);
        cell.setLabel("");
        DatasetProteinInformation dpi = protein.getDatasetProteinInformation(ds);
        if (dpi == null || !dpi.isPresent()) {
          cell.setHexColor("#FFFFFF");
        } else {
          float heatMapSpectrumCount = dpi.getHeatMapSpectrumCount();
          cell.setHexColor(grpComparison.getHeatMapColor(heatMapSpectrumCount));
        }
      }

      // http://chart.apis.google.com/chart?chs=320x200&cht=bvs&chd=t:1,19,27,53,61&chds=0,61&chco=FFCC33&chxt=x,y&chxr=1,0,61,10&chxl=0:|Jan|Feb|Mar|Apr|May
      String plotUrl = getPlotUrl(protein, grpComparison.getDatasets());

      row.setPlotUrl(plotUrl);

      row.setCells(cells);
    }
  }
コード例 #2
0
ファイル: HeatMapData.java プロジェクト: vagisha/msdapl
  private String getColorForMolWt(float molecularWeight) {

    //		int r = 255;
    //		int g = 255;
    //		int b = 0;
    //
    //		int bin = (int) (molecularWeight / 10000);
    //		//r += 25 * bin;
    //		g -= 25 * bin;
    //		//b -= 25 * bin;
    //		r = Math.min(255, r);
    //		g = Math.max(0, g);
    //		//b = Math.max(0, bin);
    if (molecularWeight > 0 && molecularWeight <= 12000)
      return ProteinGroupComparisonDataset.hexValue(255, 255, 0); //  0 to 12000; yellow
    else if (molecularWeight > 12000 && molecularWeight <= 18000)
      return ProteinGroupComparisonDataset.hexValue(255, 180, 0); // 12000 to 18000;  orange
    else if (molecularWeight > 18000 && molecularWeight <= 22000)
      return ProteinGroupComparisonDataset.hexValue(255, 0, 0); // 18000 to 22000; red
    else if (molecularWeight > 22000 && molecularWeight <= 25000)
      return ProteinGroupComparisonDataset.hexValue(255, 0, 180); // 22000 to 25000;
    else if (molecularWeight > 25000 && molecularWeight <= 35000)
      return ProteinGroupComparisonDataset.hexValue(255, 0, 255); // 25000 to 35000; magenta
    else if (molecularWeight > 35000 && molecularWeight <= 40000)
      return ProteinGroupComparisonDataset.hexValue(180, 0, 255); // 35000 to 40000
    else if (molecularWeight > 40000 && molecularWeight <= 50000)
      return ProteinGroupComparisonDataset.hexValue(0, 0, 255); // 40000 to 50000; blue
    else if (molecularWeight > 50000 && molecularWeight <= 60000)
      return ProteinGroupComparisonDataset.hexValue(0, 180, 255); // 50000 to 60000;
    else if (molecularWeight > 60000 && molecularWeight <= 70000)
      return ProteinGroupComparisonDataset.hexValue(0, 255, 255); // 60000 to 70000; cyan
    else if (molecularWeight > 70000 && molecularWeight <= 80000)
      return ProteinGroupComparisonDataset.hexValue(0, 255, 180); // 70000 to 80000;
    else if (molecularWeight > 80000 && molecularWeight <= 90000)
      return ProteinGroupComparisonDataset.hexValue(0, 255, 0); // 80000 to 90000; green
    else return ProteinGroupComparisonDataset.hexValue(0, 0, 0); // 90000 to 100000; black
    // return ProteinGroupComparisonDataset.hexValue(r, g, b);
  }