ExpressionExperimentBibRefFinder { public BibliographicReference locatePrimaryReference( ExpressionExperiment ee ) { if ( ee.getPrimaryPublication() != null ) return ee.getPrimaryPublication(); DatabaseEntry accession = ee.getAccession(); ExternalDatabase ed = accession.getExternalDatabase(); if ( !ed.getName().equals( "GEO" ) ) { ExpressionExperimentBibRefFinder.log.warn( "Don't know how to get references for non-GEO data sets" ); return null; } String geoId = accession.getAccession(); int pubMedId = this.locatePubMedId( geoId ); if ( pubMedId < 0 ) return null; PubMedXMLFetcher fetcher = new PubMedXMLFetcher(); return fetcher.retrieveByHTTP( pubMedId ); }  BibliographicReference locatePrimaryReference( ExpressionExperiment ee );  }
@Test public void testLocatePrimaryReference() throws Exception { ExpressionExperimentBibRefFinder finder = new ExpressionExperimentBibRefFinder(); ExpressionExperiment ee = ExpressionExperiment.Factory.newInstance(); DatabaseEntry de = DatabaseEntry.Factory.newInstance(); ExternalDatabase ed = ExternalDatabase.Factory.newInstance(); ed.setName( "GEO" ); de.setAccession( "GSE3023" ); de.setExternalDatabase( ed ); ee.setAccession( de ); try { BibliographicReference bibref = null; for ( int i = 0; i < 3; i++ ) { bibref = finder.locatePrimaryReference( ee ); if ( bibref != null ) break; Thread.sleep( 1000 ); } assertNotNull( bibref ); assertEquals( "Differential gene expression in anatomical compartments of the human eye.", bibref.getTitle() ); } catch ( Exception e ) { checkCause( e ); } }
@Test public void testLocatePrimaryReferenceInvalidGSE() throws Exception { ExpressionExperimentBibRefFinder finder = new ExpressionExperimentBibRefFinder(); ExpressionExperiment ee = ExpressionExperiment.Factory.newInstance(); DatabaseEntry de = DatabaseEntry.Factory.newInstance(); ExternalDatabase ed = ExternalDatabase.Factory.newInstance(); ed.setName( "GEO" ); de.setAccession( "GSE30231111111111111" ); de.setExternalDatabase( ed ); ee.setAccession( de ); try { BibliographicReference bibref = finder.locatePrimaryReference( ee ); assert ( bibref == null ); } catch ( Exception e ) { checkCause( e ); } }