/** * Queries the ego (http://www.ebi.ac.uk/ego) server with given GO term id. * * @param goId the GO term to query the ego server. * * @return the GO term definition. * * @throws IOException for network errors. * @throws GoIdNotFoundException thrown when the server fails to find a response for GO id. */ public GoResponse query( String goId ) throws IOException, GoIdNotFoundException { GoResponse goRes = null; // Query the ego server. GoHandler goHandler ; // = getGoResponse( goId ); try { goHandler = getGoResponse( goId ); } catch( SAXException e ) { throw new GoIdNotFoundException( goId, e ); } if( goHandler == null ) { throw new GoIdNotFoundException( goId ); } // Values from newt stored in goRes = new GoResponse( goId, goHandler.getName(), goHandler.getCategory() ); return goRes; }
public GoXrefHelper(String goId){ if (goId == null){ throw new IllegalArgumentException("The goId shouldn't be null"); } goServer = new GoServerProxy(); try { goResponse = goServer.query(goId); qualifier = goResponse.getCategory(); secondaryId = goResponse.getName(); } catch (IOException e) { System.out.println("The qualifier and the secondaryId corresponding to GoId " + goId + " couldn't be found automatically"); } catch (GoServerProxy.GoIdNotFoundException e) { System.out.println("The qualifier and the secondaryId corresponding to GoId " + goId + " couldn't be found automatically"); } }
public static void main(String[] args) { //C GoXrefHelper goXrefHelper = new GoXrefHelper("GO:0005737"); System.out.println(goXrefHelper.getQualifier()); System.out.println(goXrefHelper.getSecondaryId()); //F goXrefHelper = new GoXrefHelper("GO:0005520"); System.out.println(goXrefHelper.getQualifier()); System.out.println(goXrefHelper.getSecondaryId()); //P goXrefHelper = new GoXrefHelper("GO:0045663"); System.out.println(goXrefHelper.getQualifier()); System.out.println(goXrefHelper.getSecondaryId()); goXrefHelper = new GoXrefHelper("GO:0005856"); System.out.println(goXrefHelper.getQualifier()); System.out.println(goXrefHelper.getSecondaryId()); }
private GoHandler getGoResponse( String goId ) throws IOException, SAXException { String query = SearchReplace.replace( EGO_QUERY, GOID_FLAG, goId ); URL url = new URL( myURL + query ); URLConnection servletConnection = url.openConnection(); // Turn off caching servletConnection.setUseCaches( false ); // Wrting to the server. servletConnection.setDoOutput( true ); // The reader to read response from the server. GoHandler goHandler = null; InputStream inputStream = null; try { inputStream = servletConnection.getInputStream(); goHandler = getGoResponse( inputStream ); } finally { if( inputStream != null ) { try { inputStream.close(); } catch( IOException ioe ) { } } } return goHandler; } // getGoResponse
private GoHandler getGoResponse( InputStream inputStream ) throws IOException, SAXException { GoHandler goHandler = null; InputSource source = new InputSource( inputStream ); SAXParser parser = new SAXParser(); goHandler = new GoHandler(); parser.setContentHandler( goHandler ); try { parser.parse( source ); } catch( IOException e ) { throw e; } return goHandler; }
String secondaryId = null; if ( cvDatabase.getShortLabel().equals( CvDatabase.GO ) ) { GoXrefHelper goXrefHelper = new GoXrefHelper( xrefTag.getId() ); if ( goXrefHelper.getQualifier() != null ) { cvXrefQualifier = IntactContext.getCurrentInstance().getCvContext().getByLabel(CvXrefQualifier.class, goXrefHelper.getQualifier()); if ( goXrefHelper.getSecondaryId() != null ) { secondaryId = goXrefHelper.getSecondaryId();
goHandler = getGoResponse( is ); } catch( SAXException e ) { throw new GoIdNotFoundException( goId, e ); throw new GoIdNotFoundException( goId ); goRes = new GoResponse( goId, goHandler.getName(), goHandler.getCategory() );
String secondaryId = ""; if ( cvDatabase.getShortLabel().equals( CvDatabase.GO ) ) { GoXrefHelper goXrefHelper = new GoXrefHelper( xrefTag.getId() ); if ( goXrefHelper.getQualifier() != null ) { cvXrefQualifier = IntactContext.getCurrentInstance().getDataContext().getDaoFactory().getCvObjectDao(CvXrefQualifier.class).getByShortLabel(goXrefHelper.getQualifier()); if ( goXrefHelper.getSecondaryId() != null ) { secondaryId = goXrefHelper.getSecondaryId();