X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=forester%2Fjava%2Fsrc%2Forg%2Fforester%2Fws%2Fseqdb%2FSequenceDbWsTools.java;h=b56a6330457c998553478de66be69d6a5477662b;hb=4cdad3c78a8ce85b18a977a916ed7ed91a350f3a;hp=f8d23e3fb73818753e3cb9cff1b59a7b9508853c;hpb=67e2a07291484a4b991cea06368443f6d1680de5;p=jalview.git diff --git a/forester/java/src/org/forester/ws/seqdb/SequenceDbWsTools.java b/forester/java/src/org/forester/ws/seqdb/SequenceDbWsTools.java index f8d23e3..b56a633 100644 --- a/forester/java/src/org/forester/ws/seqdb/SequenceDbWsTools.java +++ b/forester/java/src/org/forester/ws/seqdb/SequenceDbWsTools.java @@ -47,12 +47,11 @@ public final class SequenceDbWsTools { public enum Db { UNKNOWN, UNIPROT; } - public final static String BASE_UNIPROT_URL = "http://www.uniprot.org/"; - public final static String BASE_EMBL_DB_URL = "http://www.ebi.ac.uk/Tools/dbfetch/dbfetch/"; - public final static String EMBL_DBS_EMBL = "embl"; - public final static String EMBL_DBS_REFSEQ_P = "refseqp"; - public final static String EMBL_DBS_REFSEQ_N = "refseqn"; - + public final static String BASE_UNIPROT_URL = "http://www.uniprot.org/"; + public final static String BASE_EMBL_DB_URL = "http://www.ebi.ac.uk/Tools/dbfetch/dbfetch/"; + public final static String EMBL_DBS_EMBL = "embl"; + public final static String EMBL_DBS_REFSEQ_P = "refseqp"; + public final static String EMBL_DBS_REFSEQ_N = "refseqn"; private final static String URL_ENC = "UTF-8"; // uniprot/expasy accession number format (6 chars): // letter digit letter-or-digit letter-or-digit letter-or-digit digit @@ -328,25 +327,20 @@ public final class SequenceDbWsTools { } public static List queryEmblDb( final Identifier id, final int max_lines_to_return ) throws IOException { - - StringBuilder url_sb = new StringBuilder(); + final StringBuilder url_sb = new StringBuilder(); url_sb.append( BASE_EMBL_DB_URL ); - - if ( ForesterUtil.isEmpty( id.getProvider() ) || id.getProvider().equalsIgnoreCase( Identifier.NCBI ) ) { - + if ( ForesterUtil.isEmpty( id.getProvider() ) || id.getProvider().equalsIgnoreCase( Identifier.NCBI ) ) { url_sb.append( SequenceDbWsTools.EMBL_DBS_EMBL ); - url_sb.append( '/'); + url_sb.append( '/' ); } else if ( id.getProvider().equalsIgnoreCase( Identifier.REFSEQ ) ) { if ( id.getValue().toUpperCase().indexOf( 'P' ) == 1 ) { - url_sb.append( SequenceDbWsTools.EMBL_DBS_REFSEQ_P ); - url_sb.append( '/'); + url_sb.append( '/' ); } else { - url_sb.append( SequenceDbWsTools.EMBL_DBS_REFSEQ_N ); - url_sb.append( '/'); + url_sb.append( '/' ); } } return queryDb( id.getValue(), max_lines_to_return, url_sb.toString() ); @@ -382,6 +376,13 @@ public final class SequenceDbWsTools { } } in.close(); + try { + // To prevent accessing online dbs in too quick succession. + Thread.sleep( 20 ); + } + catch ( final InterruptedException e ) { + e.printStackTrace(); + } return result; } @@ -399,7 +400,7 @@ public final class SequenceDbWsTools { public static SequenceDatabaseEntry obtainEmblEntry( final Identifier id, final int max_lines_to_return ) throws IOException { - final List lines = queryEmblDb( id , max_lines_to_return ); + final List lines = queryEmblDb( id, max_lines_to_return ); return EbiDbEntry.createInstanceFromPlainText( lines ); } }