コード例 #1
0
  /**
   * Compares two realisations
   *
   * @throws TopologyException
   * @throws NewickIOException
   * @params realisation
   * @params Vertices-Realisation Points Map returns the populated map
   */
  public static void verticesDistribution(
      String real, LinkedHashMap<Integer, List<Double>> vrMap, RBTreeArcDiscretiser dtimes)
      throws NewickIOException, TopologyException {
    boolean flag = true;
    Realisation r = UnparsedRealisation.parseRealisation(real);
    RootedBifurcatingTree t = r.getTree();
    int noofvertices = t.getNoOfVertices();

    for (int i = 0; i < noofvertices; i++) {
      if (vrMap.get(i) != null) {
        List<Double> list = vrMap.get(i);
        String meta = r.getPlacements().get(i);
        int[] point = {0, 0};
        point[0] = Integer.parseInt(meta.substring(meta.indexOf("(") + 1, meta.lastIndexOf(",")));
        point[1] = Integer.parseInt(meta.substring(meta.indexOf(",") + 1, meta.lastIndexOf(")")));
        Double time = dtimes.getDiscretisationTime(point[0], point[1]);
        list.add(time);
        vrMap.put(i, list);
      } else {
        List<Double> list = new ArrayList<Double>();
        String meta = r.getPlacements().get(i);
        int[] point = {0, 0};
        point[0] = Integer.parseInt(meta.substring(meta.indexOf("(") + 1, meta.lastIndexOf(",")));
        point[1] = Integer.parseInt(meta.substring(meta.indexOf(",") + 1, meta.lastIndexOf(")")));
        Double time = dtimes.getDiscretisationTime(point[0], point[1]);
        list.add(time);
        vrMap.put(i, list);
      }
    }
  }
コード例 #2
0
  /**
   * Compares two realisations
   *
   * @throws TopologyException
   * @throws NewickIOException
   * @params realisation1
   * @params realisation2 returns true if similar or false otherwise
   */
  public static boolean compareRealisation(String real1, String real2)
      throws NewickIOException, TopologyException {
    boolean flag = true;

    Realisation r1 = UnparsedRealisation.parseRealisation(real1);
    Realisation r2 = UnparsedRealisation.parseRealisation(real2);
    RootedBifurcatingTree t1 = r1.getTree();
    RootedBifurcatingTree t2 = r2.getTree();
    assert (t1
        == t2); // Assumes the realisations have same gene tree otherwise comparing realisation
                // makes no sense

    int noofvertices = r1.getTree().getNoOfVertices();

    for (int i = 0; i < noofvertices; i++) {
      if (Integer.parseInt(
                  r1.getPlacements()
                      .get(i)
                      .substring(
                          r1.getPlacements().get(i).indexOf("(") + 1,
                          r1.getPlacements().get(i).indexOf(",")))
              != Integer.parseInt(
                  r2.getPlacements()
                      .get(i)
                      .substring(
                          r2.getPlacements().get(i).indexOf("(") + 1,
                          r2.getPlacements().get(i).indexOf(",")))
          || (Integer.parseInt(
                  r1.getPlacements()
                      .get(i)
                      .substring(
                          r1.getPlacements().get(i).indexOf(",") + 1,
                          r1.getPlacements().get(i).indexOf(")")))
              != Integer.parseInt(
                  r2.getPlacements()
                      .get(i)
                      .substring(
                          r2.getPlacements().get(i).indexOf(",") + 1,
                          r2.getPlacements().get(i).indexOf(")"))))) return false;
    }
    return flag;
  }