Show
Ignore:
Timestamp:
08/22/09 20:23:17 (3 years ago)
Author:
martijn
Message:

Work on transitive mapping in Stack
Also added unit test and data file
Not yet implemented for mapID(Set<Xref>, ...

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/bio/test/org/bridgedb/bio/TestStack.java

    r66 r168  
    1818public class TestStack extends TestCase 
    1919{ 
    20  
    21         static final String GDB_HUMAN =  
     20        private static final String GDB_HUMAN =  
    2221                System.getProperty ("user.home") + File.separator +  
    2322                "PathVisio-Data/gene databases/Hs_Derby_20081119.pgdb"; 
    24         static final File YEAST_ID_MAPPING = new File ("../test-data/yeast_id_mapping.txt"); 
     23        private static final File YEAST_ID_MAPPING = new File ("../test-data/yeast_id_mapping.txt"); 
     24        private static final File NUGO_CUSTOM_MAPPINGS = new File ("/home/martijn/prg/bridgedb/test-data/Nugo-hs-custom.txt"); 
    2525 
    26         Set<Xref> src = new HashSet<Xref>(); 
    27         Set<DataSource> dsset = new HashSet<DataSource>(); 
    28         static final Xref RAD51 = new Xref ("YER095W", BioDataSource.ENSEMBL_SCEREVISIAE); 
    29         static final Xref INSR = new Xref ("Hs.705877", BioDataSource.UNIGENE); 
    30          
     26        private Set<Xref> src = new HashSet<Xref>(); 
     27        private Set<DataSource> dsset = new HashSet<DataSource>(); 
     28        private static final Xref RAD51 = new Xref ("YER095W", BioDataSource.ENSEMBL_SCEREVISIAE); 
     29        private static final Xref INSR = new Xref ("Hs.705877", BioDataSource.UNIGENE); 
     30 
     31        private static final Xref NUGO = new Xref ("NuGO_eht0320285_at", BioDataSource.AFFY); 
     32        private static final Xref ENSEMBL = new Xref ("ENSG00000026652", BioDataSource.ENSEMBL); 
     33        private static final Xref ENTREZ = new Xref ("56895", BioDataSource.ENTREZ_GENE); 
     34 
    3135        public void setUp() throws ClassNotFoundException 
    3236        { 
     
    8286                assertEquals (expected, refmap.get(RAD51)); 
    8387        } 
     88 
     89        public void testTransitive() throws IDMapperException, ClassNotFoundException, MalformedURLException 
     90        {                 
     91                IDMapper textMapper = BridgeDb.connect ("idmapper-text:" + NUGO_CUSTOM_MAPPINGS.toURL()); 
     92                IDMapper derbyMapper = BridgeDb.connect ("idmapper-pgdb:" + GDB_HUMAN); 
     93                IDMapperStack stack = new IDMapperStack(); 
     94                stack.addIDMapper(derbyMapper); 
     95                stack.addIDMapper(textMapper); 
    8496         
     97                stack.setTransitive(false); 
     98                 
     99                // test the link between NUGO and ENSEMBL that only occurs in text               
     100                Set<Xref> result = stack.mapID(NUGO, null); 
     101                assertTrue(result.contains(ENSEMBL)); 
     102                assertFalse(result.contains(ENTREZ)); 
     103                                 
     104                // test the link between ENTREZ and ENSEMBL that only occurs in pgdb 
     105                result = stack.mapID(ENTREZ, null);              
     106                assertFalse(result.contains(NUGO)); 
     107                assertTrue(result.contains(ENSEMBL)); 
     108                 
     109                stack.setTransitive(true); 
     110 
     111                // test transitive 
     112                result = stack.mapID(NUGO, null); 
     113                assertTrue(result.contains(ENTREZ)); 
     114                assertTrue(result.contains(ENSEMBL)); 
     115                 
     116                // and the other way around 
     117                result = stack.mapID(ENTREZ, null); 
     118                assertTrue(result.contains(NUGO)); 
     119                assertTrue(result.contains(ENSEMBL)); 
     120 
     121                // map multiple IDs 
     122                Set<Xref> set1 = new HashSet<Xref>(); 
     123                set1.add (ENTREZ); 
     124                Map<Xref, Set<Xref>> result2 = stack.mapID(set1, null); 
     125                assertTrue (result2.get(ENTREZ).contains(NUGO)); 
     126        } 
    85127}