Package bgu.bio.adt.graphs

Examples of bgu.bio.adt.graphs.Tree


import bgu.bio.algorithms.graphs.hsa.matchers.UnorderedMatcherFactory;

public class TestHSAOnInteger {

  private static void run(String file1, String file2) throws IOException {
    Tree t = buildTree(file1);
    Tree s = buildTree(file2);
    t.toDotFile("/home/milon/1.dot", true);
    s.toDotFile("/home/milon/2.dot", true);

    CostFunction w = new CostFunction() {

      @Override
      public double cost(NodeLabel l1, NodeLabel l2) {
        if (l1.equals(l2)) {
          return -2;
        }

        return Double.POSITIVE_INFINITY;
      }
    };

    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) + "), ");
    }

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


    for (int i = 0; i < tEdges.length; i++) {
      tLabels[i] = new NodeLabel(id2Label.get(i));
    }

    Tree t = new Tree(tEdges, tWeights, tSmoothing, tLabels);
    return t;
  }
View Full Code Here

    NodeLabel[] tLabels = { new NodeLabel("0"), new NodeLabel("1"),
        new NodeLabel("2"), new NodeLabel("3"), new NodeLabel("4"),
        new NodeLabel("5"), new NodeLabel("6"), new NodeLabel("7"),
        new NodeLabel("8"), new NodeLabel("9"), };

    Tree t = new Tree(tEdges, tWeights, tSmooth, tLabels);

    // TODO Auto-generated method stub
    int[][] sEdges = { { 1, 2, 3, 4, 5 }, { 0 }, { 0 }, { 0 }, { 0 },
        { 0 }, };

    double[][] sWeights = { { 10, 20, 30, 40, 50 }, { 10 }, { 20 }, { 30 },
        { 40 }, { 50 }, };

    double[] sSmooth = { 2, 2, 2, 2, 2, 2 };
    NodeLabel[] sLabels = { new NodeLabel("0"), new NodeLabel("1"),
        new NodeLabel("2"), new NodeLabel("3"), new NodeLabel("4"),
        new NodeLabel("5"), };

    Tree s = new Tree(sEdges, sWeights, sSmooth, sLabels);

    CostFunction w = new CostFunction() {

      @Override
      public double cost(NodeLabel l1, NodeLabel l2) {
View Full Code Here

    NodeLabel[] tLabels = { new NodeLabel("h"), new NodeLabel("d"),
        new NodeLabel("c"), new NodeLabel("g"), new NodeLabel("b"),
        new NodeLabel("a"), new NodeLabel("e"), new NodeLabel("f"),
        new NodeLabel("i"), };

    Tree t = new Tree(tEdges, tWeights, tSmooth, tLabels);

    int[][] sEdges = { { 3 }, { 2, 8 }, { 3, 1 }, { 0, 4, 2 },
        { 3, 6, 5, 7 }, { 4 }, { 4 }, { 4 }, { 1 } };

    double[][] sWeights = { { 30 }, { 20, 1 }, { 30, 10 }, { 10, 40, 20 },
        { 30, 60, 1, 70 }, { 40 }, { 40 }, { 40 }, { 10 } };

    double[] sSmooth = { 2, 2, 1.2, 2, 2, 2, 2, 2, 2 };
    NodeLabel[] sLabels = { new NodeLabel("a"), new NodeLabel("c"),
        new NodeLabel("j"), new NodeLabel("b"), new NodeLabel("d"),
        new NodeLabel("i"), new NodeLabel("e"), new NodeLabel("f"),
        new NodeLabel("k"), };

    CostFunction w = new CostFunction() {

      @Override
      public double cost(NodeLabel l1, NodeLabel l2) {
        if (Arrays.equals(l1.getLabelValue().toArray(), l2
            .getLabelValue().toArray()))
          return -3;
        else
          return 5;
      }
    };

    Tree s = new Tree(sEdges, sWeights, sSmooth, sLabels);

    checkTrees(t, w, s);

    // checking for rooting problems:

    final double INF = MathOperations.INFINITY;

    w = new CostFunction() {
      @Override
      public double cost(NodeLabel l1, NodeLabel l2) {
        if (Arrays.equals(l1.getLabelValue().toArray(), l2
            .getLabelValue().toArray()))
          return -3;
        else if (l1.getLabelValue().get(0) == 'b'
            || l2.getLabelValue().get(0) == 'b') {
          return INF;
        } else
          return 5;
      }
    };

    tWeights = new double[][] { { INF, 10, 1 }, { INF, 70, 60 }, { INF },
        { INF }, { 50, 1, 10, 20 }, { INF }, { INF }, { INF }, { INF } };

    t = new Tree(tEdges, tWeights, tSmooth, tLabels);

    sWeights = new double[][] { { INF }, { INF, 1 }, { INF, 10 },
        { 10, 40, 20 }, { INF, 60, 1, 70 }, { INF }, { INF }, { INF },
        { INF } };

    s = new Tree(sEdges, sWeights, sSmooth, sLabels);

    checkTrees(t, w, s);

  }
View Full Code Here

  public static void testTree() {
    int[][] neighbors = { { 4 }, { 6 }, { 4 }, { 5 }, { 2, 6, 7, 0 },
        { 6, 3, 9, 8 }, { 1, 4, 5 }, { 4 }, { 5 }, { 5 }, };

    Tree tree = new Tree(neighbors, null, null, null);
  }
View Full Code Here

    NodeLabel[] tLabels = { new NodeLabel("0"), new NodeLabel("1"),
        new NodeLabel("2"), new NodeLabel("3"), new NodeLabel("4"),
        new NodeLabel("5"), new NodeLabel("6"), new NodeLabel("7"),
        new NodeLabel("8"), new NodeLabel("9"), };

    Tree t = new Tree(tEdges, tWeights, tSmooth, tLabels);

    int[][] sEdges = { { 1, 2, 3, 4, 5 }, { 0 }, { 0 }, { 0 }, { 0 },
        { 0 }, };

    double[][] sWeights = { { 10, 20, 30, 40, 50 }, { 10 }, { 20 }, { 30 },
        { 40 }, { 50 }, };

    double[] sSmooth = { 2, 2, 2, 2, 2, 2 };
    NodeLabel[] sLabels = { new NodeLabel("0"), new NodeLabel("1"),
        new NodeLabel("2"), new NodeLabel("3"), new NodeLabel("4"),
        new NodeLabel("5"), };

    Tree s = new Tree(sEdges, sWeights, sSmooth, sLabels);

    CostFunction w = new CostFunction() {

      @Override
      public double cost(NodeLabel l1, NodeLabel l2) {
View Full Code Here

    NodeLabel[] tLabels = { new NodeLabel("h"), new NodeLabel("d"),
        new NodeLabel("c"), new NodeLabel("g"), new NodeLabel("b"),
        new NodeLabel("a"), new NodeLabel("e"), new NodeLabel("f"),
        new NodeLabel("i"), };

    Tree t = new Tree(tEdges, tWeights, tSmooth, tLabels);

    int[][] sEdges = { { 3 }, { 2, 8 }, { 3, 1 }, { 0, 4, 2 },
        { 3, 6, 5, 7 }, { 4 }, { 4 }, { 4 }, { 1 } };

    double[][] sWeights = { { 30 }, { 20, 1 }, { 30, 10 }, { 10, 40, 20 },
        { 30, 60, 1, 70 }, { 40 }, { 40 }, { 40 }, { 10 } };

    double[] sSmooth = { 2, 2, 1.2, 2, 2, 2, 2, 2, 2 };
    NodeLabel[] sLabels = { new NodeLabel("a"), new NodeLabel("c"),
        new NodeLabel("j"), new NodeLabel("b"), new NodeLabel("d"),
        new NodeLabel("i"), new NodeLabel("e"), new NodeLabel("f"),
        new NodeLabel("k"), };

    CostFunction w = new CostFunction() {

      @Override
      public double cost(NodeLabel l1, NodeLabel l2) {
        if (Arrays.equals(l1.getLabelValue().toArray(), l2
            .getLabelValue().toArray()))
          return -3;
        else
          return 5;
      }
    };

    Tree s = new Tree(sEdges, sWeights, sSmooth, sLabels);

    checkTrees(t, w, s);

    // checking for rooting problems:

    final double INF = MathOperations.INFINITY;

    w = new CostFunction() {
      @Override
      public double cost(NodeLabel l1, NodeLabel l2) {
        if (Arrays.equals(l1.getLabelValue().toArray(), l2
            .getLabelValue().toArray()))
          return -3;
        else if (l1.getLabelValue().get(0) == 'b'
            || l2.getLabelValue().get(0) == 'b') {
          return INF;
        } else
          return 5;
      }
    };

    tWeights = new double[][] { { INF, 10, 1 }, { INF, 70, 60 }, { INF },
        { INF }, { 50, 1, 10, 20 }, { INF }, { INF }, { INF }, { INF } };

    t = new Tree(tEdges, tWeights, tSmooth, tLabels);

    sWeights = new double[][] { { INF }, { INF, 1 }, { INF, 10 },
        { 10, 40, 20 }, { INF, 60, 1, 70 }, { INF }, { INF }, { INF },
        { INF } };

    s = new Tree(sEdges, sWeights, sSmooth, sLabels);

    checkTrees(t, w, s);

  }
View Full Code Here

  public static void testTree() {
    int[][] neighbors = { { 4 }, { 6 }, { 4 }, { 5 }, { 2, 6, 7, 0 },
        { 6, 3, 9, 8 }, { 1, 4, 5 }, { 4 }, { 5 }, { 5 }, };

    Tree tree = new Tree(neighbors, null, null, null);
  }
View Full Code Here

TOP

Related Classes of bgu.bio.adt.graphs.Tree

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.