Changeset 260 for trunk/benchmarking

Show
Ignore:
Timestamp:
11/09/09 02:31:18 (3 years ago)
Author:
martijn
Message:

Updated ComparisonScript?, with new 1000 affy id list

Location:
trunk/benchmarking
Files:
1 added
2 modified

Legend:

Unmodified
Added
Removed
  • trunk/benchmarking/src/org/bridgedb/benchmarking/ComparisonScript.java

    r257 r260  
    1919import java.io.BufferedReader; 
    2020import java.io.File; 
     21import java.io.FileOutputStream; 
    2122import java.io.FileReader; 
     23import java.io.FileWriter; 
    2224import java.io.IOException; 
     25import java.io.PrintWriter; 
    2326import java.util.ArrayList; 
    2427import java.util.HashMap; 
     
    118121//              private Set<Xref> refs = new HashSet<Xref>(); 
    119122                public Map<Xref, Set<Xref>> consensus; 
     123                int all_the_same = 0; 
     124                 
    120125                private List<SingleTest> tests = new ArrayList<SingleTest>(); 
    121126                private final DataSource base; 
    122127                private final DataSource expected; 
     128 
     129                private final File reportFile; 
    123130                 
    124131                List<Xref> refs; 
    125132                 
    126                 TestSet (DataSource base, DataSource expected) 
     133                TestSet (DataSource base, DataSource expected, File dest) 
    127134                { 
    128135                        this.base = base; 
    129136                        this.expected = expected; 
     137                        this.reportFile = dest; 
    130138                } 
    131139 
     
    156164                                consensus.put (ref, maxVal); 
    157165                                 
     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                                 
    158169                                // count amount of consensus per test 
    159170                                for (SingleTest test : tests) 
    160171                                { 
    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                                                } 
    165177                                } 
    166178 
     
    185197                } 
    186198                 
    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                         
    224242                        for (Xref ref : refs) 
    225243                        { 
    226                                 System.out.print (ref); 
     244                                writer.print (ref); 
    227245                                for (SingleTest single : tests) 
    228246                                { 
    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(); 
    238257                } 
    239258 
     
    302321        public void run() throws IOException, ClassNotFoundException, IDMapperException 
    303322        { 
     323                String version = "_v1"; 
     324                File parent = new File ("/home/martijn/Desktop"); 
     325                 
    304326                List<TestSet> allTests = new ArrayList<TestSet>(); 
    305327                BioDataSource.init(); 
     
    319341//              List<Xref> affylist_syn = readList (new File("IDMapping_X_Test.txt"), ); 
    320342 
    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)); 
    322344                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));  
    324346                 
    325347                // TODO: Synergizer ensembl produces the symbol of hgnc, not the hgnc identifiers  
     
    330352                                DataSource.getByFullName("hgnc")));  
    331353                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));  
    333355                ensembl_hgnc.tests.add (new SingleTest(Connector.CRONOS, BioDataSource.ENSEMBL_HUMAN, BioDataSource.HUGO));  
    334356 
    335357 
    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)); 
    337359                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));  
    339362                ensembl_entrez.tests.add (new SingleTest(Connector.SYNERGIZER_ENSEMBL, DataSource.getByFullName("ensembl_gene_id"), 
    340363                                DataSource.getByFullName("entrezgene"))); 
     
    342365                                DataSource.getByFullName("entrezgene")));  
    343366                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));  
    345368                ensembl_entrez.tests.add (new SingleTest(Connector.BIOMART, DataSource.getByFullName("ensembl_gene_id"), 
    346369                                DataSource.getByFullName("entrezgene"))); 
     
    348371                                BioDataSource.ENSEMBL_HUMAN, BioDataSource.ENTREZ_GENE)); 
    349372         
    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"), 
    354378                                DataSource.getByFullName("ensembl_gene_id"))); 
    355379                // 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)); 
    358384                affy.tests.add (new SingleTest(Connector.CRONOS, BioDataSource.AFFY, BioDataSource.ENSEMBL_HUMAN));  
    359385                 
    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)); 
    361387                bridgedb_only.readList(new File("IDMapping_En_Test.txt")); 
    362388                bridgedb_only.tests.add (new SingleTest(Connector.DERBY_LOCAL, BioDataSource.ENSEMBL_HUMAN, BioDataSource.ENTREZ_GENE));  
     
    366392 
    367393                // 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); 
    372398                 
    373399                for (TestSet set : allTests) 
     
    379405                 
    380406                server.stop(); 
     407                System.out.println ("DONE"); 
    381408                 
    382409        } 
  • trunk/benchmarking/src/org/bridgedb/benchmarking/Utils.java

    r256 r260  
    11package org.bridgedb.benchmarking; 
    22 
     3import java.io.PrintWriter; 
    34import java.util.HashSet; 
    45import java.util.Set; 
     
    3031        } 
    3132 
    32         public static void printRefSet(Set<Xref> dests) 
     33        public static void printRefSet(PrintWriter writer, Set<Xref> dests) 
    3334        { 
    3435                boolean first = true; 
    3536                if (dests != null) for (Xref dest : dests) 
    3637                { 
    37                         if (!first) System.out.print (" /// "); 
    38                         System.out.print (dest); 
     38                        if (!first) writer.print (" /// "); 
     39                        writer.print (dest); 
    3940                        first = false; 
    4041                }