Esempio n. 1
0
  /**
   * *********************************************************************
   *
   * <p>Synopsis [ ]
   *
   * <p>*********************************************************************
   */
  public static void simulateHistogramREU(Gate g, GateLibrary gate_library, Args options) {

    if (g.is_unvisited()) {

      g.set_unvisited(false);

      ArrayList<Gate> children = g.getChildren();
      for (Gate child : children) {
        if (child.is_unvisited()) {
          simulateHistogramREU(child, gate_library, options);
        }
      }

      // initialize
      g.get_histogram_reus().clear();
      for (int i = 0; i < g.get_logics().size(); ++i) { // rows in truth table

        g.get_histogram_reus().add(new double[g.get_histogram_bins().get_NBINS()]);
        for (int j = 0; j < g.get_histogram_bins().get_NBINS(); ++j) {
          g.get_histogram_reus().get(i)[j] = 0.0;
        }
      }

      if (g.Type == GateType.OUTPUT_OR || g.Type == GateType.OUTPUT) {
        g.set_histogram_reus(GateUtil.getSumOfGateInputHistograms(g, gate_library, options));
      } else if (g.Type == GateType.AND) {
        g.set_histogram_reus(GateUtil.getANDOfGateInputHistograms(g));
      } else if (g.Type == GateType.NOT || g.Type == GateType.NOR) {
        // 2. For each row: for each bin: for each output bin: add normalizeToValue
        ArrayList<double[]> input_convreus =
            GateUtil.getSumOfGateInputHistograms(g, gate_library, options);
        g.set_in_histogram_reus(input_convreus);

        for (int i = 0; i < input_convreus.size(); ++i) {

          /*if(Args.dontcare_rows.contains(i)) {
              for(int bin=0; bin< g.get_histogram_reus().get(i).length; ++bin) {
                  g.get_histogram_reus().get(i)[bin] = 0.0;
              }
              continue;
          }*/

          double[] convhist = input_convreus.get(i);

          for (int bin = 0; bin < g.get_histogram_bins().get_NBINS(); ++bin) {
            double fractional_counts = convhist[bin];
            double[] xslice = g.get_xfer_hist().get_xfer_interp().get(bin);

            for (int xslice_bin = 0;
                xslice_bin < g.get_histogram_bins().get_NBINS();
                ++xslice_bin) {
              g.get_histogram_reus().get(i)[xslice_bin] += xslice[xslice_bin] * fractional_counts;
            }
          }
        }
      }

      // evaluateGateHistogramOverlap(g); //to compute gate scores

    }
  }
  @Override
  public ArrayList<Map> getObjects() {

    ArrayList<Map> objects = new ArrayList<>();

    ArrayList<Double> REU_TITR = new ArrayList<Double>();
    REU_TITR.add(0.018806664);
    REU_TITR.add(0.028666538);
    REU_TITR.add(0.051722065);
    REU_TITR.add(0.14837545);
    REU_TITR.add(0.261559417);
    REU_TITR.add(0.447725869);
    REU_TITR.add(0.687508549);
    REU_TITR.add(1.131011516);
    REU_TITR.add(1.891798237);
    REU_TITR.add(3.27479675);
    REU_TITR.add(4.549973162);
    REU_TITR.add(8.687342616);

    HistogramBins hbins = new HistogramBins();
    hbins.init();
    GateLibrary gate_library = new GateLibrary(0, 0);

    ArrayList<String> gate_names = new ArrayList<String>();
    gate_names.add("an0_AmeR");
    gate_names.add("js2_AmtR");
    gate_names.add("js2_BM3R1");
    gate_names.add("js2_BetI");
    gate_names.add("js2_HlyIIR");
    gate_names.add("js2_IcaRA");
    gate_names.add("js2_LitR");
    gate_names.add("js2_PhlF");
    gate_names.add("js2_SrpR");
    gate_names.add("js_QacR");
    gate_names.add("js2_LitR");

    for (String gate_name : gate_names) {
      Gate g = new Gate();
      g.Name = gate_name;
      gate_library.get_GATES_BY_NAME().put(g.Name, g);
    }

    for (Gate g : gate_library.get_GATES_BY_NAME().values()) {
      String gate_name = g.Name;

      String rootpath = collection_writer.getRootPath();
      String filepath = rootpath + "/resources/data/nor_gates/cytometry_cb1/";
      HistogramUtil.getTransferFunctionHistogramTitrations(
          gate_name, gate_library, hbins, filepath);

      LinkedHashMap obj = new LinkedHashMap();
      obj.put("collection", "gate_cytometry"); // tag

      obj.put("gate_name", gate_name);

      ArrayList<LinkedHashMap> titrations = new ArrayList<LinkedHashMap>();

      for (int i = 0; i < REU_TITR.size(); ++i) {
        Double inREU = REU_TITR.get(i);

        ArrayList<Double> out_reu_bins = new ArrayList<Double>();
        ArrayList<Double> out_reu_counts = new ArrayList<Double>();

        for (int j = 0; j < hbins.get_NBINS(); ++j) {
          double[] normalized = HistogramUtil.normalize(g.get_xfer_hist().get_xfer_binned().get(i));
          out_reu_bins.add(Math.pow(10, hbins.get_LOG_BIN_CENTERS()[j]));
          out_reu_counts.add(normalized[j]);
        }

        LinkedHashMap titration = new LinkedHashMap();
        titration.put("maps_to_variable", "x");
        titration.put("input", inREU);
        titration.put("output_bins", out_reu_bins);
        titration.put("output_counts", out_reu_counts);
        titrations.add(titration);
      }

      obj.put("cytometry_data", titrations);

      objects.add(obj);
      // org.cellocad.ucf_writers_tetr.ConstraintFileWriter.JSONPrettyPrint(obj,
      // "resources/UCF/Eco1C1G1T1.gate_cytometry.json", true);

    }

    return objects;
  }