Changeset 168
- Timestamp:
- 08/22/09 20:23:17 (2 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 2 modified
-
bio/test/org/bridgedb/bio/TestStack.java (modified) (2 diffs)
-
corelib/src/org/bridgedb/IDMapperStack.java (modified) (1 diff)
-
test-data/Nugo-hs-custom.txt (added)
Legend:
- Unmodified
- Added
- Removed
-
trunk/bio/test/org/bridgedb/bio/TestStack.java
r66 r168 18 18 public class TestStack extends TestCase 19 19 { 20 21 static final String GDB_HUMAN = 20 private static final String GDB_HUMAN = 22 21 System.getProperty ("user.home") + File.separator + 23 22 "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"); 25 25 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 31 35 public void setUp() throws ClassNotFoundException 32 36 { … … 82 86 assertEquals (expected, refmap.get(RAD51)); 83 87 } 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); 84 96 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 } 85 127 } -
trunk/corelib/src/org/bridgedb/IDMapperStack.java
r163 r168 398 398 private Set<Xref> mapIDtransitive(Xref ref, Set<DataSource> resultDs) throws IDMapperException 399 399 { 400 throw new UnsupportedOperationException(); 400 // first round 401 Set<Xref> round1 = new HashSet<Xref>(); 402 for (IDMapper child : gdbs) 403 { 404 if (child != null && child.isConnected()) 405 { 406 round1.addAll (child.mapID(ref, null)); 407 } 408 } 409 // second round 410 Set<Xref> round2 = new HashSet<Xref>(); 411 for (IDMapper child : gdbs) 412 { 413 if (child != null && child.isConnected()) 414 { 415 for (Set<Xref> set : child.mapID(round1, resultDs).values()) 416 round2.addAll (set); 417 } 418 } 419 return round2; 401 420 } 402 421
