Package bgu.bio.algorithms.graphs.hsa

Examples of bgu.bio.algorithms.graphs.hsa.HSA


    };

    TIntArrayList[] alignment = new TIntArrayList[3];

    UnorderedMatcherFactory matcherFactory = new UnorderedMatcherFactory();
    HSA hsa = new HSA(w, matcherFactory,false);

    System.out.println("Cost t-s: " + hsa.computeHSA(t, s, alignment));
    for (int i = 0; i < alignment[0].size(); ++i) {
      System.out.print("(" + alignment[0].get(i) + ","
          + alignment[1].get(i) + "), ");
    }
View Full Code Here


   
   
    double ans1 = 0,ans2 = 0;
   
    //reuse
    HSA hsaEngine2 = new HSA(1, 1, cost, new UnorderedMatcherFactory(),
        true);
    double temp = hsaEngine2.computeHSA(t, s);
    ans1 = hsaEngine2.computeHSA(t, sR);
   
    //no reuse
    hsaEngine2 = new HSA(1, 1, cost, new UnorderedMatcherFactory(),
        true);
   
    temp = hsaEngine2.computeHSA(t, s);
    hsaEngine2.setFactory(new UnorderedMatcherFactory());
    ans2 = hsaEngine2.computeHSA(t, sR);
    if (!MathOperations.equals(ans1, ans2)){
      System.out.println("Got problem with matchers");
    }
  }
View Full Code Here

    };

    TIntArrayList[] alignment = new TIntArrayList[3];

    UnorderedMatcherFactory matcherFactory = new UnorderedMatcherFactory();
    HSA hsa = new HSA(w, matcherFactory);

    System.out.println("Cost t-s: " + hsa.computeHSA(t, s, alignment));
    for (int i = 0; i < alignment[0].size(); ++i) {
      System.out.print("(" + alignment[0].get(i) + ","
          + alignment[1].get(i) + "), ");
    }

    System.out.println("\nCost s-t: " + hsa.computeHSA(s, t, alignment));
    for (int i = 0; i < alignment[0].size(); ++i) {
      System.out.print("(" + alignment[0].get(i) + ","
          + alignment[1].get(i) + "), ");
    }

    System.out.println("\nCost t-t: " + hsa.computeHSA(t, t, alignment));
    for (int i = 0; i < alignment[0].size(); ++i) {
      System.out.print("(" + alignment[0].get(i) + ","
          + alignment[1].get(i) + "), ");
    }

    System.out.println("\nCost s-s: " + hsa.computeHSA(s, s, alignment));
    for (int i = 0; i < alignment[0].size(); ++i) {
      System.out.print("(" + alignment[0].get(i) + ","
          + alignment[1].get(i) + "), ");
    }

    long start = System.currentTimeMillis();
    int iters = 10000;
    for (int i = 0; i < iters; ++i) {
      hsa.computeHSA(t, s);
    }
    System.out.println("\nTime of " + iters + " iterations for t-s: "
        + (System.currentTimeMillis() - start));

    start = System.currentTimeMillis();
    for (int i = 0; i < iters; ++i) {
      hsa.computeHSA(s, t);
    }
    System.out.println("\nTime of " + iters + " iterations for s-t: "
        + (System.currentTimeMillis() - start));

    start = System.currentTimeMillis();
    for (int i = 0; i < iters; ++i) {
      hsa.computeHSA(t, t);
    }
    System.out.println("\nTime of " + iters + " iterations for t-t: "
        + (System.currentTimeMillis() - start));

    start = System.currentTimeMillis();
    for (int i = 0; i < iters; ++i) {
      hsa.computeHSA(s, s);
    }
    System.out.println("\nTime of " + iters + " iterations for s-s: "
        + (System.currentTimeMillis() - start));

    String flowType;
View Full Code Here

  }

  private static void checkTrees(Tree t, CostFunction w, Tree s) {
    TIntArrayList[] alignment = new TIntArrayList[3];
    MatcherFactory matcherFactory = new UnorderedMatcherFactory();
    HSA hsa = new HSA(w, matcherFactory);

    double cost = hsa.computeHSA(t, s, alignment);
    System.out.println("Cost: " + cost);
    for (int i = 0; i < alignment[0].size(); ++i) {
      System.out.print("(" + alignment[0].get(i) + ","
          + alignment[1].get(i) + "), ");
    }
    System.out.println();

    // checking for pooling problems:
    double currCost;
    int i = 0;
    int iters = 0;
    for (; i < iters; ++i) {
      hsa = new HSA(w, matcherFactory);

      currCost = hsa.computeHSA(t, s);
      if (!MathOperations.equals(cost, currCost)) {
        System.err.println("Different costs at repeated runs: " + cost
            + ", " + currCost);
        break;
      }
    }
    if (i == iters) {
      System.out.println("Repeated runs OK.");
    }

    // checking for symmetry problems:

    alignment = new TIntArrayList[3];
    currCost = hsa.computeHSA(s, t, alignment);
    System.out.println("Cost: " + cost);
    for (int j = 0; j < alignment[0].size(); ++j) {
      System.out.print("(" + alignment[0].get(j) + ","
          + alignment[1].get(j) + "), ");
    }
    System.out.println();

    // checking for pooling problems:
    i = 0;
    for (; i < iters; ++i) {
      hsa = new HSA(w, matcherFactory);

      currCost = hsa.computeHSA(s, t);
      if (!MathOperations.equals(cost, currCost)) {
        System.err.println("Different costs at repeated runs: " + cost
            + ", " + currCost);
        break;
      }
View Full Code Here

    smooth.calculateCost(s);

    TIntArrayList[] alignment = new TIntArrayList[3];
    MatcherFactory matcherFactory = new UnorderedMatcherFactory();
    // MatcherFactory matcherFactory = new OrderedMatcherFactory();
    HSA hsa = new HSA(cost, matcherFactory);

    System.out.println("Cost: " + hsa.computeHSA(s, t, alignment));
    for (int i = 0; i < alignment[0].size(); ++i) {
      System.out.print("(" + alignment[0].get(i) + ","
          + alignment[1].get(i) + "), ");
    }

    // System.out.println("\nCost: " + hsa.computeHSA(s, t,alignment));

    System.out.println("\nCost: " + hsa.computeHSA(t, s, alignment));
    for (int i = 0; i < alignment[0].size(); ++i) {
      System.out.print("(" + alignment[0].get(i) + ","
          + alignment[1].get(i) + "), ");
    }

    long start = System.currentTimeMillis();
    int iters = 30;
    for (int i = 0; i < iters; ++i) {
      hsa.computeHSA(t, s);
    }
    System.out.println("\nTime of " + iters + " iterations: "
        + (System.currentTimeMillis() - start));
    String flowType;
//    if (matcherFactory.make(3, 3) instanceof UnorderedBipartiteCavityMatcherMinCostMaxFlow) {
View Full Code Here

  }

  private static void checkTrees(Tree t, CostFunction w, Tree s) {
    TIntArrayList[] alignment = new TIntArrayList[3];
    MatcherFactory matcherFactory = new UnorderedMatcherFactory();
    HSA hsa = new HSA(w, matcherFactory);

    double cost = hsa.computeHSA(t, s, alignment);
    System.out.println("Cost: " + cost);
    for (int i = 0; i < alignment[0].size(); ++i) {
      System.out.print("(" + alignment[0].get(i) + ","
          + alignment[1].get(i) + "), ");
    }
    System.out.println();

    // checking for pooling problems:
    double currCost;
    int i = 0;
    int iters = 0;
    for (; i < iters; ++i) {
      hsa = new HSA(w, matcherFactory);

      currCost = hsa.computeHSA(t, s);
      if (!MathOperations.equals(cost, currCost)) {
        System.err.println("Different costs at repeated runs: " + cost
            + ", " + currCost);
        break;
      }
    }
    if (i == iters) {
      System.out.println("Repeated runs OK.");
    }

    // checking for symmetry problems:

    alignment = new TIntArrayList[3];
    currCost = hsa.computeHSA(s, t, alignment);
    System.out.println("Cost: " + cost);
    for (int j = 0; j < alignment[0].size(); ++j) {
      System.out.print("(" + alignment[0].get(j) + ","
          + alignment[1].get(j) + "), ");
    }
    System.out.println();

    // checking for pooling problems:
    i = 0;
    for (; i < iters; ++i) {
      hsa = new HSA(w, matcherFactory);

      currCost = hsa.computeHSA(s, t);
      if (!MathOperations.equals(cost, currCost)) {
        System.err.println("Different costs at repeated runs: " + cost
            + ", " + currCost);
        break;
      }
View Full Code Here

    smooth.calculateCost(s);

    TIntArrayList[] alignment = new TIntArrayList[3];
    MatcherFactory matcherFactory = new UnorderedMatcherFactory();
    // MatcherFactory matcherFactory = new OrderedMatcherFactory();
    HSA hsa = new HSA(cost, matcherFactory);

    System.out.println("Cost: " + hsa.computeHSA(s, t, alignment));
    for (int i = 0; i < alignment[0].size(); ++i) {
      System.out.print("(" + alignment[0].get(i) + ","
          + alignment[1].get(i) + "), ");
    }

    // System.out.println("\nCost: " + hsa.computeHSA(s, t,alignment));

    System.out.println("\nCost: " + hsa.computeHSA(t, s, alignment));
    for (int i = 0; i < alignment[0].size(); ++i) {
      System.out.print("(" + alignment[0].get(i) + ","
          + alignment[1].get(i) + "), ");
    }

    long start = System.currentTimeMillis();
    int iters = 30;
    for (int i = 0; i < iters; ++i) {
      hsa.computeHSA(t, s);
    }
    System.out.println("\nTime of " + iters + " iterations: "
        + (System.currentTimeMillis() - start));
    String flowType;
    // if (matcherFactory.make(3, 3) instanceof
View Full Code Here

    smooth.calculateCost(sR);

    double ans1 = 0, ans2 = 0;

    // reuse
    HSA hsaEngine2 = new HSA(1, 1, cost, new UnorderedMatcherFactory(),
        true);
    hsaEngine2.computeHSA(t, s);
    ans1 = hsaEngine2.computeHSA(t, sR);

    // no reuse
    hsaEngine2 = new HSA(1, 1, cost, new UnorderedMatcherFactory(), true);

    hsaEngine2.computeHSA(t, s);
    hsaEngine2.setFactory(new UnorderedMatcherFactory());
    ans2 = hsaEngine2.computeHSA(t, sR);
    Assert.assertEquals("Got a problem with the matchers", true,
        MathOperations.equals(ans1, ans2));
  }
View Full Code Here

    smooth.calculateCost(s);

    double ans1 = 0, ans2 = 0;

    // reuse
    HSA hsaEngine = new HSA(1, 1, cost, new OrderedMatcherFactory(), true);

    pruneRooted.calculateCost(t);
    pruneRooted.calculateCost(s);
    ans1 = hsaEngine.computeHSA(t, s);

    pruneUnrooted.calculateCost(t);
    pruneUnrooted.calculateCost(s);
    TIntArrayList[] tb = new TIntArrayList[3];
    ans2 = hsaEngine.computeHSA(t, s, tb);
    for (int i = 0; i < tb[0].size(); i++) {
      System.out.println(tb[0].getQuick(i) + " -> " + tb[1].getQuick(i));
    }
    Assert.assertEquals("Should be unrooted alignment", false,
        MathOperations.equals(ans1, ans2));
View Full Code Here

    }
 
    double ans1 = 0, ans2 = 0;

    // reuse
    HSA hsaEngine2 = new HSA(1, 1, cost, new OrderedMatcherFactory(),
        true);
    TIntArrayList[] trace = new TIntArrayList[3];
    ans1 = hsaEngine2.computeHSA(t, t, trace);

    Assert.assertEquals("trace should be the same", trace[0], trace[1]);
    ans2 = hsaEngine2.computeHSA(t, trace);
   
    System.out.println(ans1);
    System.out.println(ans2);

    Assert.assertEquals(
View Full Code Here

TOP

Related Classes of bgu.bio.algorithms.graphs.hsa.HSA

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.