Package net.sourceforge.align.filter

Examples of net.sourceforge.align.filter.Filter


   * Test of selecting from empty list returns empty list and does not
   * throw an exception.
   */
  @Test
  public void testEmpty() {
    Filter filter = new FractionSelector(0.8f);
    List<Alignment> alignmentList = new ArrayList<Alignment>();
    alignmentList = filter.apply(alignmentList);
    assertEquals(0, alignmentList.size());
  }
View Full Code Here


   * Test if a selecting from a list containing one element returns empty
   * list if fraction is < 0.5, and one element list if fraction >= 0.5.
   */
  @Test
  public void testSingleton() {
    Filter filter;
    List<Alignment> alignmentList = new ArrayList<Alignment>();
    List<Alignment> filteredAlignmentList;
    Alignment alignment = new Alignment();
    alignment.setScore(1.0f);
    alignmentList.add(alignment);
    filter = new FractionSelector(0.4999f);
    filteredAlignmentList = filter.apply(alignmentList);
    assertEquals(0, filteredAlignmentList.size());
    filter = new FractionSelector(0.5f);
    filteredAlignmentList = filter.apply(alignmentList);
    assertEquals(1, filteredAlignmentList.size());
  }
View Full Code Here

   * Test if the list contains elements with identical score,
   * they will all be returned if fraction > 0.
   */
  @Test
  public void testIdentical() {
    Filter filter = new FractionSelector(0.79f);
    List<Alignment> alignmentList = createAlignmentList(
        new float[]{2.0f, 2.0f, 2.0f, 2.0f, 2.0f});
    alignmentList = filter.apply(alignmentList);
    assertEquals(5, alignmentList.size());
  }
View Full Code Here

  /**
   * Tests if fraction selector selects correct number of elements.
   */
  @Test
  public void testDifferent() {
    Filter filter = new FractionSelector(0.79f);
    List<Alignment> alignmentList = createAlignmentList(
        new float[]{1.0f, 4.0f, 2.0f, 5.0f, 2.0f});
    alignmentList = filter.apply(alignmentList);
    assertEquals(4, alignmentList.size());
 
View Full Code Here

    List<Alignment> rightAlignmentList = new ArrayList<Alignment>();
    rightAlignmentList.add(new Alignment(new String[]{"a"}, new String[]{"1"}));
    rightAlignmentList.add(new Alignment(new String[]{"b"}, new String[]{"2"}));
    rightAlignmentList.add(new Alignment(new String[]{"c"}, new String[]{"3"}));

    Filter filter = new DifferenceSelector(rightAlignmentList);
    List<Alignment> resultAlignmentList = filter.apply(leftAlignmentList);

    assertEquals(1, resultAlignmentList.size());
    assertEquals(leftAlignmentList.get(1), resultAlignmentList.get(0));

  }
View Full Code Here

   */
  @Test
  public void compare() {
    List<Alignment> alignmentList = createAlignmentList(
        SOURCE_ARRAY, TARGET_ARRAY);
    Filter filter = new OneToOneSelector();
    List<Alignment> resultAlignmentList = filter.apply(alignmentList);
    assertAlignmentListEquals(
        filterSegmentArray(SOURCE_ARRAY, RESULT_INDEXES),
        filterSegmentArray(TARGET_ARRAY, RESULT_INDEXES),
        resultAlignmentList);
  }
View Full Code Here

    List<Alignment> rightAlignmentList = new ArrayList<Alignment>();
    rightAlignmentList.add(new Alignment(new String[]{"a"}, new String[]{"1"}));
    rightAlignmentList.add(new Alignment(new String[]{"b"}, new String[]{"2"}));
    rightAlignmentList.add(new Alignment(new String[]{"c"}, new String[]{"3"}));

    Filter filter = new IntersectionSelector(rightAlignmentList);
    List<Alignment> resultAlignmentList = filter.apply(leftAlignmentList);

    assertEquals(2, resultAlignmentList.size());
    assertEquals(rightAlignmentList.get(0), resultAlignmentList.get(0));
    assertEquals(rightAlignmentList.get(2), resultAlignmentList.get(1));
View Full Code Here

      new ForwardBackwardAlgorithmFactory();
   
    AlignAlgorithm algorithm =
      new AdaptiveBandAlgorithm(algorithmFactory, calculator);
   
    Filter filter = new Aligner(algorithm);
   
    return filter.apply(alignmentList);

  }
View Full Code Here

    String cls = commandLine.getOptionValue('c');
    if (cls == null) {
      throw new MissingParameterException("class");
    }

    Filter filter;
    if (cls.equals("galechurch")) {
      filter = new GaleAndChurchMacro();
    } else if (cls.equals("moore")) {
      filter = new MooreMacro();
    } else if (cls.equals("poisson")) {
      filter = new PoissonMacro();
    } else if (cls.equals("translation")) {
      filter = new TranslationMacro();
    } else if (cls.equals("poisson-translation")) {
      filter = new PoissonTranslationMacro();
    } else {
      throw new UnknownParameterException("class");
    }

    filter = FilterDecorators.decorate(filter);

    Parser parser = new AlParser(getIn());
    Formatter formatter = new AlFormatter(getOut());
    List<Alignment> alignmentList = parser.parse();
    alignmentList = filter.apply(alignmentList);
    formatter.format(alignmentList);
  }
View Full Code Here

   
    filterList.add(new OneToOneSelector());
   
    filterList.add(new FractionSelector(SELECT_FRACTION));
   
    Filter filter = new CompositeFilter(filterList);   
   
    return filter.apply(alignmentList);
   
  }
View Full Code Here

TOP

Related Classes of net.sourceforge.align.filter.Filter

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.