    1   package baseCode.dataFilter;
    2
    3   import java.util.HashSet;
    4   import java.util.Set;
    5
    6   import baseCode.dataFilter.RowNameFilter;
    7   import baseCode.dataStructure.matrix.DenseDoubleMatrix2DNamed;
    8   import baseCode.dataStructure.matrix.StringMatrix2DNamed;
    9
    10  /***
    11   * @author Pavlidis
    12   * @version $Id: TestRowNameFilter.java,v 1.1 2005/03/17 13:58:41 pavlidis Exp $
    13   *
    14   */
    15
    16  public class TestRowNameFilter extends AbstractTestFilter {
    17
    18     protected Set testfilterlist;
    19
    20     protected void setUp() throws Exception {
    21        super.setUp();
    22
    23        testfilterlist = new HashSet();
    24        testfilterlist.add( "gene1_at" );
    25        testfilterlist.add( "gene4_at" );
    26        testfilterlist.add( "gene13_s_at" );
    27        testfilterlist.add( "AFFXgene30_at" );
    28        testfilterlist.add( "fooblydoobly" ); // shouldn't care.
    29     }
    30
    31     protected void tearDown() throws Exception {
    32        super.tearDown();
    33        testfilterlist = null;
    34     }
    35
    36     public void testFilter() {
    37        RowNameFilter fi = new RowNameFilter( testfilterlist );
    38        DenseDoubleMatrix2DNamed filtered = ( DenseDoubleMatrix2DNamed ) fi
    39              .filter( testdata );
    40        int expectedReturn = 4;
    41        int actualReturn = filtered.rows();
    42        assertEquals( "return value", expectedReturn, actualReturn );
    43     }
    44
    45     public void testFilterExclude() {
    46        RowNameFilter fi = new RowNameFilter( testfilterlist, true );
    47        DenseDoubleMatrix2DNamed filtered = ( DenseDoubleMatrix2DNamed ) fi
    48              .filter( testdata );
    49        int expectedReturn = testdata.rows() - 4;
    50        int actualReturn = filtered.rows();
    51        assertEquals( "return value", expectedReturn, actualReturn );
    52     }
    53
    54     public void testFilterString() {
    55        RowNameFilter fi = new RowNameFilter( testfilterlist );
    56        StringMatrix2DNamed filtered = ( StringMatrix2DNamed ) fi
    57              .filter( teststringdata );
    58        int expectedReturn = 4;
    59        int actualReturn = filtered.rows();
    60        assertEquals( "return value", expectedReturn, actualReturn );
    61     }
    62
    63     public void testFilterStringExclude() {
    64        RowNameFilter fi = new RowNameFilter( testfilterlist, true );
    65        StringMatrix2DNamed filtered = ( StringMatrix2DNamed ) fi
    66              .filter( teststringdata );
    67        int expectedReturn = teststringdata.rows() - 4;
    68        int actualReturn = filtered.rows();
    69        assertEquals( "return value", expectedReturn, actualReturn );
    70     }
    71
    72  }