Package bgu.bio.adt.tuples

Examples of bgu.bio.adt.tuples.IntPair


        } else if (secondary.charAt(i) == closeBracket) {
          if (stack.size() == 0) {
            return false;
          }
          final int start = stack.pop();
          ans.add(new IntPair(start, i));
        }
      }
      if (stack.size() != 0) {
        return false;
      }
View Full Code Here


      for (int i = 0; i < secondary.length(); i++) {
        if (secondary.charAt(i) == openBracket) {
          stack.push(i);
        } else if (secondary.charAt(i) == closeBracket) {
          final int start = stack.pop();
          ans.add(new IntPair(start, i));
        }
      }
    }
    return ans;
  }
View Full Code Here

    Collections.sort(pairs, new IntPairComparator());

    ArrayList<ArrayList<IntPair>> stackings = new ArrayList<ArrayList<IntPair>>();

    for (int p = 0; p < pairs.size(); p++) {
      IntPair current = pairs.get(p);
      // check all stackings in data
      boolean found = false;
      for (int s = stackings.size() - 1; s >= 0 && !found; s--) {
        ArrayList<IntPair> currentStacking = stackings.get(s);
        if (isExtends(currentStacking, current, maxGapSize)) {
View Full Code Here

        structure.append('.');
      }
      String sequence = this.primary.substring(current.get(0).getFirst(),
          current.get(0).getSecond() + 1);
      for (int i = 0; i < current.size(); i++) {
        IntPair pair = current.get(i);
        structure.setCharAt(
            pair.getFirst() - current.get(0).getFirst(), '(');
        structure.setCharAt(pair.getSecond()
            - current.get(0).getFirst(), ')');
      }
      String newHeader = this.header;
      try {
        JSONObject json = new JSONObject();
View Full Code Here

  }

  private boolean isExtends(ArrayList<IntPair> currentStacking,
      IntPair current, int maxGapSize) {

    final IntPair edgeOfStack = currentStacking
        .get(currentStacking.size() - 1);
    return (current.getFirst() - edgeOfStack.getFirst() - 1 <= maxGapSize
        && current.getFirst() - edgeOfStack.getFirst() > 0
        && edgeOfStack.getSecond() - current.getSecond() - 1 <= maxGapSize && edgeOfStack
        .getSecond() - current.getSecond() > 0);
  }
View Full Code Here

      sumOfChararcters += danglingRight.size();

      // move the information to a list and sort by size
      counters = new ArrayList<IntPair>();
      for (int i = 0; i < loopCounters.size(); i++) {
        counters.add(new IntPair(i, loopCounters.get(i)));
      }
      Collections.sort(counters, new Comparator<IntPair>() {

        @Override
        public int compare(IntPair o1, IntPair o2) {
View Full Code Here

  @Test
  public void testExtractSimple1() {
    RNA rna = new RNA(1, "test", "AAACCCUUU", "(((...)))");
    ArrayList<IntPair> expList = new ArrayList<IntPair>();
    expList.add(new IntPair(0, 8));
    expList.add(new IntPair(1, 7));
    expList.add(new IntPair(2, 6));

    checkLists(expList, rna.extractPairs());
  }
View Full Code Here

  @Test
  public void testExtractPK1() {
    RNA rna = new RNA(1, "test", "AAACCCUUUAAGGGCCC", "((([[[)))..]]]...");
    ArrayList<IntPair> expList = new ArrayList<IntPair>();
    expList.add(new IntPair(0, 8));
    expList.add(new IntPair(1, 7));
    expList.add(new IntPair(2, 6));
    expList.add(new IntPair(3, 13));
    expList.add(new IntPair(4, 12));
    expList.add(new IntPair(5, 11));
    checkLists(expList, rna.extractPairs());
  }
View Full Code Here

    IntPairComparator comp = new IntPairComparator();

    ArrayList<IntPair> ans = new ArrayList<IntPair>();
    ArrayList<IntPair> exp = new ArrayList<IntPair>();

    ans.add(new IntPair(6, 3));
    ans.add(new IntPair(5, 2));
    ans.add(new IntPair(4, 1));
    for (int i = 0; i < matching[0].size(); ++i) {
      exp.add(new IntPair(matching[0].get(i), matching[1].get(i)));
    }

    Collections.sort(ans, comp);
    Collections.sort(exp, comp);

    isSame(ans, exp);

    Assert.assertEquals("Minimum matching answer is wrong", 7,
        matcher.minCostMatching(), 0.001);

    ans = new ArrayList<IntPair>();
    exp = new ArrayList<IntPair>();

    matching = matcher.getCurrMatching();

    ans.add(new IntPair(3, 5));
    ans.add(new IntPair(0, 4));
    ans.add(new IntPair(6, 3));
    ans.add(new IntPair(5, 2));
    ans.add(new IntPair(4, 1));

    for (int i = 0; i < matching[0].size(); ++i) {
      exp.add(new IntPair(matching[0].get(i), matching[1].get(i)));
    }

    Collections.sort(ans, comp);
    Collections.sort(exp, comp);
View Full Code Here

TOP

Related Classes of bgu.bio.adt.tuples.IntPair

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.