Changeset 260 for trunk/benchmarking
- Timestamp:
- 11/09/09 02:31:18 (3 years ago)
- Location:
- trunk/benchmarking
- Files:
-
- 1 added
- 2 modified
-
U133A2-randomset.txt (added)
-
src/org/bridgedb/benchmarking/ComparisonScript.java (modified) (11 diffs)
-
src/org/bridgedb/benchmarking/Utils.java (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/benchmarking/src/org/bridgedb/benchmarking/ComparisonScript.java
r257 r260 19 19 import java.io.BufferedReader; 20 20 import java.io.File; 21 import java.io.FileOutputStream; 21 22 import java.io.FileReader; 23 import java.io.FileWriter; 22 24 import java.io.IOException; 25 import java.io.PrintWriter; 23 26 import java.util.ArrayList; 24 27 import java.util.HashMap; … … 118 121 // private Set<Xref> refs = new HashSet<Xref>(); 119 122 public Map<Xref, Set<Xref>> consensus; 123 int all_the_same = 0; 124 120 125 private List<SingleTest> tests = new ArrayList<SingleTest>(); 121 126 private final DataSource base; 122 127 private final DataSource expected; 128 129 private final File reportFile; 123 130 124 131 List<Xref> refs; 125 132 126 TestSet (DataSource base, DataSource expected )133 TestSet (DataSource base, DataSource expected, File dest) 127 134 { 128 135 this.base = base; 129 136 this.expected = expected; 137 this.reportFile = dest; 130 138 } 131 139 … … 156 164 consensus.put (ref, maxVal); 157 165 166 // count how many times all mappers have the same result 167 if (max == tests.size() && maxVal != null && maxVal.size() > 0) all_the_same++; 168 158 169 // count amount of consensus per test 159 170 for (SingleTest test : tests) 160 171 { 161 if (Utils.safeEquals (consensus.get(ref), test.result.get(ref))) 162 { 163 test.consensus++; 164 } 172 if (consensus.get(ref) != null && consensus.get(ref).size() > 0) 173 if (Utils.safeEquals (consensus.get(ref), test.result.get(ref))) 174 { 175 test.consensus++; 176 } 165 177 } 166 178 … … 185 197 } 186 198 187 public void reportMerged() 188 { 189 System.out.print ("service:"); 190 for (SingleTest single : tests) 191 { 192 System.out.print ("\t" + single.connector.name); 193 } 194 System.out.println("\tconsensus"); 195 196 System.out.print ("connecting (msec):"); 197 for (SingleTest single : tests) 198 { 199 System.out.print ("\t" + single.deltaConnect); 200 } 201 System.out.println(); 202 203 System.out.print ("mapping (msec):"); 204 for (SingleTest single : tests) 205 { 206 System.out.print ("\t" + single.deltaMapping); 207 } 208 System.out.println(); 209 210 System.out.print ("success%:"); 211 for (SingleTest single : tests) 212 { 213 System.out.printf ("\t%2d %3.1f%%", single.success, (double)single.success / (double)single.total * 100.0); 214 } 215 System.out.println(); 216 217 System.out.print ("consensus:"); 218 for (SingleTest single : tests) 219 { 220 System.out.printf ("\t%2d %3.1f%%", single.consensus, (double)single.consensus / (double)single.total * 100.0); 221 } 222 System.out.println(); 223 199 public void reportMerged() throws IOException 200 { 201 System.out.println ("Writing to file:" + reportFile.getAbsolutePath()); 202 PrintWriter writer = new PrintWriter (new FileWriter(reportFile)); 203 writer.print ("service:"); 204 for (SingleTest single : tests) 205 { 206 writer.print ("\t" + single.connector.name); 207 } 208 writer.println("\tconsensus"); 209 210 writer.print ("connecting (msec):"); 211 for (SingleTest single : tests) 212 { 213 writer.print ("\t" + single.deltaConnect); 214 } 215 writer.println(); 216 217 writer.print ("mapping (msec):"); 218 for (SingleTest single : tests) 219 { 220 writer.print ("\t" + single.deltaMapping); 221 } 222 writer.println(); 223 224 writer.print ("success%:"); 225 for (SingleTest single : tests) 226 { 227 writer.printf ("\t%2d %3.1f%%", single.success, (double)single.success / (double)single.total * 100.0); 228 } 229 writer.println(); 230 231 writer.print ("consensus:"); 232 for (SingleTest single : tests) 233 { 234 writer.printf ("\t%2d %3.1f%%", single.consensus, (double)single.consensus / (double)single.success * 100.0); 235 } 236 writer.println(); 237 238 writer.print ("overlap:"); 239 writer.printf ("\t%2d", all_the_same); 240 writer.println(); 241 224 242 for (Xref ref : refs) 225 243 { 226 System.out.print (ref);244 writer.print (ref); 227 245 for (SingleTest single : tests) 228 246 { 229 System.out.print ("\t"); 230 Utils.printRefSet(single.result.get(ref)); 231 } 232 233 System.out.print ("\t"); 234 Utils.printRefSet(consensus.get(ref)); 235 236 System.out.println(); 237 } 247 writer.print ("\t"); 248 Utils.printRefSet(writer, single.result.get(ref)); 249 } 250 251 writer.print ("\t"); 252 Utils.printRefSet(writer, consensus.get(ref)); 253 254 writer.println(); 255 } 256 writer.close(); 238 257 } 239 258 … … 302 321 public void run() throws IOException, ClassNotFoundException, IDMapperException 303 322 { 323 String version = "_v1"; 324 File parent = new File ("/home/martijn/Desktop"); 325 304 326 List<TestSet> allTests = new ArrayList<TestSet>(); 305 327 BioDataSource.init(); … … 319 341 // List<Xref> affylist_syn = readList (new File("IDMapping_X_Test.txt"), ); 320 342 321 TestSet ensembl_hgnc = new TestSet(BioDataSource.ENSEMBL, BioDataSource.HUGO );343 TestSet ensembl_hgnc = new TestSet(BioDataSource.ENSEMBL, BioDataSource.HUGO, new File(parent, "comparison-ens-hgnc" + version)); 322 344 ensembl_hgnc.readList(new File("IDMapping_En_Test.txt")); 323 ensembl_hgnc.tests.add (new SingleTest(Connector.DERBY_LOCAL, BioDataSource.ENSEMBL_HUMAN, BioDataSource.HUGO));345 // ensembl_hgnc.tests.add (new SingleTest(Connector.DERBY_LOCAL, BioDataSource.ENSEMBL_HUMAN, BioDataSource.HUGO)); 324 346 325 347 // TODO: Synergizer ensembl produces the symbol of hgnc, not the hgnc identifiers … … 330 352 DataSource.getByFullName("hgnc"))); 331 353 ensembl_hgnc.tests.add (new SingleTest(Connector.BRIDGEWEBSERVICE, BioDataSource.ENSEMBL_HUMAN, BioDataSource.HUGO)); 332 ensembl_hgnc.tests.add (new SingleTest(Connector.BRIDGEWEBSERVICE_LOCAL, BioDataSource.ENSEMBL_HUMAN, BioDataSource.HUGO));354 // ensembl_hgnc.tests.add (new SingleTest(Connector.BRIDGEWEBSERVICE_LOCAL, BioDataSource.ENSEMBL_HUMAN, BioDataSource.HUGO)); 333 355 ensembl_hgnc.tests.add (new SingleTest(Connector.CRONOS, BioDataSource.ENSEMBL_HUMAN, BioDataSource.HUGO)); 334 356 335 357 336 TestSet ensembl_entrez = new TestSet(BioDataSource.ENSEMBL, BioDataSource.ENTREZ_GENE );358 TestSet ensembl_entrez = new TestSet(BioDataSource.ENSEMBL, BioDataSource.ENTREZ_GENE, new File(parent, "comparison-ens-entrez" + version)); 337 359 ensembl_entrez.readList(new File("IDMapping_En_Test.txt")); 338 ensembl_entrez.tests.add (new SingleTest(Connector.DERBY_LOCAL, BioDataSource.ENSEMBL_HUMAN, BioDataSource.ENTREZ_GENE)); 360 // ensembl_entrez.readList(new File("ensembl_genes_X.txt")); 361 // ensembl_entrez.tests.add (new SingleTest(Connector.DERBY_LOCAL, BioDataSource.ENSEMBL_HUMAN, BioDataSource.ENTREZ_GENE)); 339 362 ensembl_entrez.tests.add (new SingleTest(Connector.SYNERGIZER_ENSEMBL, DataSource.getByFullName("ensembl_gene_id"), 340 363 DataSource.getByFullName("entrezgene"))); … … 342 365 DataSource.getByFullName("entrezgene"))); 343 366 ensembl_entrez.tests.add (new SingleTest(Connector.BRIDGEWEBSERVICE, BioDataSource.ENSEMBL_HUMAN, BioDataSource.ENTREZ_GENE)); 344 ensembl_entrez.tests.add (new SingleTest(Connector.BRIDGEWEBSERVICE_LOCAL, BioDataSource.ENSEMBL_HUMAN, BioDataSource.ENTREZ_GENE));367 // ensembl_entrez.tests.add (new SingleTest(Connector.BRIDGEWEBSERVICE_LOCAL, BioDataSource.ENSEMBL_HUMAN, BioDataSource.ENTREZ_GENE)); 345 368 ensembl_entrez.tests.add (new SingleTest(Connector.BIOMART, DataSource.getByFullName("ensembl_gene_id"), 346 369 DataSource.getByFullName("entrezgene"))); … … 348 371 BioDataSource.ENSEMBL_HUMAN, BioDataSource.ENTREZ_GENE)); 349 372 350 TestSet affy = new TestSet(BioDataSource.AFFY, BioDataSource.ENSEMBL); 351 affy.readList (new File("IDMapping_X_Test.txt")); 352 affy.tests.add (new SingleTest(Connector.DERBY_LOCAL, BioDataSource.AFFY, BioDataSource.ENSEMBL_HUMAN)); 353 affy.tests.add (new SingleTest(Connector.SYNERGIZER_ENSEMBL, DataSource.getByFullName("affy_hg_u133a"), 373 TestSet affy = new TestSet(BioDataSource.AFFY, BioDataSource.ENSEMBL, new File(parent, "comparison-affy-ens" + version)); 374 // affy.readList (new File("IDMapping_X_Test.txt")); 375 affy.readList (new File("U133A2-randomset.txt")); 376 // affy.tests.add (new SingleTest(Connector.DERBY_LOCAL, BioDataSource.AFFY, BioDataSource.ENSEMBL_HUMAN)); 377 affy.tests.add (new SingleTest(Connector.SYNERGIZER_ENSEMBL, DataSource.getByFullName("affy_hg_u133a_2"), 354 378 DataSource.getByFullName("ensembl_gene_id"))); 355 379 // affy mapping currently not available in BridgeWebservice 356 // affy.tests.add (new SingleTest(Connector.BRIDGEWEBSERVICE, BioDataSource.AFFY, BioDataSource.ENSEMBL_HUMAN)); 357 affy.tests.add (new SingleTest(Connector.BRIDGEWEBSERVICE_LOCAL, BioDataSource.AFFY, BioDataSource.ENSEMBL_HUMAN)); 380 affy.tests.add (new SingleTest(Connector.BIOMART, DataSource.getByFullName("affy_hg_u133a_2"), 381 DataSource.getByFullName("ensembl_gene_id"))); 382 affy.tests.add (new SingleTest(Connector.BRIDGEWEBSERVICE, BioDataSource.AFFY, BioDataSource.ENSEMBL_HUMAN)); 383 // affy.tests.add (new SingleTest(Connector.BRIDGEWEBSERVICE_LOCAL, BioDataSource.AFFY, BioDataSource.ENSEMBL_HUMAN)); 358 384 affy.tests.add (new SingleTest(Connector.CRONOS, BioDataSource.AFFY, BioDataSource.ENSEMBL_HUMAN)); 359 385 360 TestSet bridgedb_only = new TestSet(BioDataSource.ENSEMBL, BioDataSource.ENTREZ_GENE );386 TestSet bridgedb_only = new TestSet(BioDataSource.ENSEMBL, BioDataSource.ENTREZ_GENE, new File(parent, "comparison-bridgedb-only" + version)); 361 387 bridgedb_only.readList(new File("IDMapping_En_Test.txt")); 362 388 bridgedb_only.tests.add (new SingleTest(Connector.DERBY_LOCAL, BioDataSource.ENSEMBL_HUMAN, BioDataSource.ENTREZ_GENE)); … … 366 392 367 393 // comment test that you want to skip. 368 allTests.add (bridgedb_only);369 //allTests.add (ensembl_entrez);370 //allTests.add (affy);371 //allTests.add (ensembl_hgnc);394 // allTests.add (bridgedb_only); 395 allTests.add (ensembl_entrez); 396 allTests.add (affy); 397 allTests.add (ensembl_hgnc); 372 398 373 399 for (TestSet set : allTests) … … 379 405 380 406 server.stop(); 407 System.out.println ("DONE"); 381 408 382 409 } -
trunk/benchmarking/src/org/bridgedb/benchmarking/Utils.java
r256 r260 1 1 package org.bridgedb.benchmarking; 2 2 3 import java.io.PrintWriter; 3 4 import java.util.HashSet; 4 5 import java.util.Set; … … 30 31 } 31 32 32 public static void printRefSet( Set<Xref> dests)33 public static void printRefSet(PrintWriter writer, Set<Xref> dests) 33 34 { 34 35 boolean first = true; 35 36 if (dests != null) for (Xref dest : dests) 36 37 { 37 if (!first) System.out.print (" /// ");38 System.out.print (dest);38 if (!first) writer.print (" /// "); 39 writer.print (dest); 39 40 first = false; 40 41 }
