/* *************************************************************************** Biomolecular Interaction Network Database (BIND) The Blueprint Initiative 522 University Avenue, 9th Floor, Suite 900 Toronto, Ontario, Canada, M5G 1W7 Hogue Lab - University of Toronto Biochemistry Department Samuel Lunenfeld Research Institute, Mount Sinai Hospital Publication to cite: Bader GD, Betel D, Hogue CW. (2003) BIND: the Biomolecular Interaction Network Database. Nucleic Acids Res. 31(1): 248-50 PMID: 12519993 Copyright Notice: Copyright 2003, 2004 Mount Sinai Hospital (MSH) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA or visit http://www.gnu.org/copyleft/gpl.html ***************************************************************************/ package org.blueprint.seqhound; import java.io.BufferedReader; import java.io.File; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.Writer; import java.net.HttpURLConnection; import java.net.MalformedURLException; import java.net.URL; import java.util.Arrays; import java.util.Vector; import java.util.Hashtable; import java.util.logging.Level; import java.util.logging.LogRecord; import java.util.logging.SimpleFormatter; import java.util.logging.StreamHandler; import org.apache.commons.httpclient.HttpClient; import org.apache.commons.httpclient.HttpRecoverableException; import org.apache.commons.httpclient.methods.GetMethod; import org.blueprint.seqhound.SLRIMisc; /** * This class provides a remote interface to the SeqHound database. * It provides a core set of functionality for obtaining * bioinformatics data using alphanumeric keys such as the * taxonomy id, gene info identifier, accession number, and * various other identifiers. *

* @author hao lieu (hlieu@blueprint.org) * */ public class SeqHound { /**************************************************************/ /** * The default configuration file is .shoundremrc. *

* To change the configuration file use constructor: * {@link #SeqHound(String)} */ private String configFile = ".shoundremrc"; /** * The address of the SeqHound server. *

* The value of the server will be read from the configuration file. * To set the server, change the appropriate key in the config file */ private String server; /** * The protocol used to send request to or receive response from the server. */ private String serverProtocol; /** * Path on the server to the cgi-bin directory. * The value of the cgi-path will be read from the configuration * file. To change the cgi-path, set the appropriate key in * the configuration file. */ private String slri_cgi_path; /** * Once SHoundInit is called, this gets set as appropriate */ private boolean isInited = false; /** * used by SHoundGetTaxNameFromTaxIDByClass */ private final int SLRI_TAXON_NAME_CLASS_NONE = 0; /** * used by SHoundGetTaxNameFromTaxIDByClass */ private final int SLRI_TAXON_NAME_CLASS_ACRONYM = 1; /** * used by SHoundGetTaxNameFromTaxIDByClass */ private final int SLRI_TAXON_NAME_CLASS_ANAMORPH = 2; /** * used by SHoundGetTaxNameFromTaxIDByClass */ private final int SLRI_TAXON_NAME_CLASS_BLAST_NAME = 3; /** * used by SHoundGetTaxNameFromTaxIDByClass */ private final int SLRI_TAXON_NAME_CLASS_COMMON_NAME = 4; /** * used by SHoundGetTaxNameFromTaxIDByClass */ private final int SLRI_TAXON_NAME_CLASS_EQUIVALENT_NAME = 5; /** * used by SHoundGetTaxNameFromTaxIDByClass */ private final int SLRI_TAXON_NAME_CLASS_INCLUDES = 6; /** * used by SHoundGetTaxNameFromTaxIDByClass */ private final int SLRI_TAXON_NAME_CLASS_IN_PART = 7; /** * used by SHoundGetTaxNameFromTaxIDByClass */ private final int SLRI_TAXON_NAME_CLASS_MISNOMER = 8; /** * used by SHoundGetTaxNameFromTaxIDByClass */ private final int SLRI_TAXON_NAME_CLASS_MISSPELLING = 9; /** * used by SHoundGetTaxNameFromTaxIDByClass */ private final int SLRI_TAXON_NAME_CLASS_PREFERRED_ACRONYM = 10; /** * used by SHoundGetTaxNameFromTaxIDByClass */ private final int SLRI_TAXON_NAME_CLASS_PREFERRED_COMMON_NAME = 11; /** * used by SHoundGetTaxNameFromTaxIDByClass */ private final int SLRI_TAXON_NAME_CLASS_SCIENTIFIC_NAME = 12; /** * used by SHoundGetTaxNameFromTaxIDByClass */ private final int SLRI_TAXON_NAME_CLASS_SYNONYM = 13; /** * used by SHoundGetTaxNameFromTaxIDByClass */ private final int SLRI_TAXON_NAME_CLASS_TELEOMORPH = 14; /** * used by SHoundGetTaxNameFromTaxIDByClass */ private final int SLRI_TAXON_NAME_CLASS_OTHER = 255; /** * used by SHoundGetTaxLineageFromTaxID */ private final int TAX_LINEAGE_FULL = 10; /** * used by SHoundGetTaxLineageFromTaxID */ private final int TAX_LINEAGE_GENBANK = 20; /** * used by SHoundGetTaxLineageFromTaxID */ private final int TAX_LINEAGE_TAXDBSHORT = 30; /** * used by SHoundProteinReportSetDescription to specify the * 'format' field. Results in a XML string. * @see #SHoundProteinReportSetDescription */ public static final int REPORT_XML = 1; /** * used by SHoundProteinReportSetDescription to specify the * 'format' field. Results in a protein report string. * @see #SHoundProteinReportSetDescription */ public static final int REPORT_ASN_TXT = 2; /** * used by API list functions Handling. A separator for * the return group. */ private static final String GROUP = ";"; /** * used by API list functions Handling. A separator for * each query-return pair. */ private static final String Q_R = "~"; /** * Levels of warning. Warnings that are WARNING and SEVERE get * logged and flushed to System.err. INFO are only logged. */ private Level SH_info = Level.parse("INFO"); /** * Levels of warning. Warnings that are WARNING and SEVERE get * logged and flushed to System.err. INFO are only logged. */ private Level SH_warn = Level.parse("WARNING"); /** * Levels of warning. Warnings that are WARNING and SEVERE get * logged and flushed to System.err. INFO are only logged. */ private Level SH_severe = Level.parse("SEVERE"); /** * Levels of warning. Warnings that are WARNING and SEVERE get * logged and flushed to System.err. INFO are only logged. */ private Level threshold; /** * stream for the log file */ private FileOutputStream out; /** *the stream handler for logging */ private StreamHandler slog; /** * the default log file */ private String default_logfile = "shoundlog_java"; /** * non-default log file. You can set a non-default * log file in the configuration file by creating the section * * [log] * logfile = yourlogfile */ private String logfile; /** * Possible error codes returned by this API. * A server error occurred. */ public final int SEQHOUND_ERROR = -1; /** * Possible error codes returned by this API. * A null value was returned. */ public final int SEQHOUND_NULL = -2; /** * Possible error codes returned by this API. * Everything was okay. */ public final int SEQHOUND_OK = 1; /** * Possible error codes returned by this API. * An unknown error. */ public final int SEQHOUND_ABNORMAL = -3; /** * possible server responses to queries */ private String ERROR = "SEQHOUND_ERROR"; /** * possible server responses to queries */ private String NULL = "SEQHOUND_NULL"; /** * possible server responses to queries */ private String OK = "SEQHOUND_OK"; /** * log statements */ private final String ERROR_STATEMENT = "Returned an error."; /** * log statements */ private final String NULL_STATEMENT = "Null return value."; /** * log statements */ private final String ABNORMAL_STATEMENT = "Abnormal return value."; /**********************************************************************/ /** * Creates a SeqHound object and uses the default configuration file * '.shoundremrc' and default log threshold 'INFO'.
* To specify your own configuration file, use corresponding * constructor. * * @throws FileNotFoundException if the default configuration file is not found * @throws IOException if there is an I/O exception * @see #SeqHound(String) * @see #SeqHound(String, String) */ public SeqHound() throws FileNotFoundException, IOException { this.setLogger(); this.setLogThreshold ( "INFO" ); } /** * Creates a SeqHound object and using the specified configuration file * and the default log threshold 'INFO'. *
* To use the default configuration file, use the corresponding constructor. * * @throws FileNotFoundException * if the default configuration file is not found * @throws IOException * if there is an I/O exception * @see #SeqHound() * @see #SeqHound(String, String) */ public SeqHound(String config) throws FileNotFoundException, IOException { this.configFile = config; this.setLogger(); this.setLogThreshold ( "INFO" ); } /** * Creates a SeqHound object using the specified configuration file * and minimum level for logging. Logging levels are as specified in * java.util.logging.Level : * SEVERE, WARNING, INFO, CONFIG, FINE, FINER, FINEST *
* To use the default configuration file, use the corresponding constructor. * * @throws FileNotFoundException * if the default configuration file is not found * @throws IOException * if there is an I/O exception * @see #SeqHound() * @see #SeqHound(String) */ public SeqHound ( String config, String logThreshold ) throws FileNotFoundException, IOException { this.configFile = config; this.setLogger(); this.setLogThreshold ( logThreshold ); } /** * Logs information/error into the log file. * * @param level the level of the information or exception. * There are 3 levels, SH_info, SH_warn, SH_severe * @param msg the message to be logged */ protected void SHoundLogError(Level level, String msg) { /* 3 levels of warning used by SeqHound lowest to highest: INFO, WARNING, SEVERE. */ LogRecord l = new LogRecord(level, msg.concat("\n")); l.setSourceClassName ( "SeqHound" ); synchronized (this) { /* log only if the error exceeds threshold */ if( level.intValue() >= threshold.intValue() ) { slog.publish(l); slog.flush(); } } /* synchronize */ } /** * Set the threshold for logging. Messages at and above 'minimum' * will get logged, below it, is not logged. 'minium' must be * defined in java.util.logging.Level class: * SEVERE, WARNING, INFO, CONFIG, FINE, FINER, FINEST, otherwise * defaults to "INFO". * */ public void setLogThreshold ( String minium ) { try { threshold = Level.parse ( minium ); } catch ( IllegalArgumentException ill ) { threshold = Level.parse ( "INFO" ); } } /** * determines which log file to use, then initializes the logger and * prints a header to the log file. * */ private void setLogger() throws IOException//FileNotFoundException, IOException { ConfigFileReader con = new ConfigFileReader(configFile); /* search the configuration file for the log file */ if((logfile = con.get("log", "logfile")) != null) { /* log file specified in configuration file so try to use that. * logs get appended to file. */ try { out = new FileOutputStream(new File(logfile), true); } catch (FileNotFoundException e) /* and exception can occur if the specified logfile is invalid, eg ' ' */ { out = new FileOutputStream(new File(default_logfile), true); } } else { /* logfile not specified in config file, so use default */ out = new FileOutputStream(new File(default_logfile), true); } slog = new StreamHandler(out, new SimpleFormatter()); /* synchronized (this){ this.SHoundLogError(SH_info, "**********************SeqHound Accessed*******************"); } */ } /** * Constructs the http call to seqrem. Ex: *
* http://seqhound.mshri.on.ca?fnct=SeqHoundInit&IsNetEntrezOnToo=TRUE&appname=value * @param func the function being called on the cgi server * @param args the querystring arguments to send to the server * @return the http call */ protected String GetFunctionCall(String func, String args) { if(func == null){ return null; } String query = "?fnct=".concat(func); if(args == null){ return this.serverProtocol.concat(this.slri_cgi_path).concat(query); }else{ return this.serverProtocol.concat(this.slri_cgi_path).concat(query).concat("&").concat(args); } } /** * returns the index of the first occurrence of ' \t\n' in content * * @param content the string to find the first occurence of ' \t\n' in * @return the index of the first occurence of ' \t\n' */ private int _IndexOfFirstBreak(String content) { if(content == null){ return -1; } int n, n2, t, t2, s, s2, e, e2; /* sets to 100 if index is -1, else sets to value of token */ n = content.length(); t = (t2 = content.indexOf('\t')) < 0 ? 100 : t2; s = (s2 = content.indexOf(' ')) < 0 ? 100 : s2; /* returns the min value of the 3 index, which is the 1st * occurrence of '\t','\n',' '. */ int min = Math.min(n, t); return Math.min(min, s); } /** * determines whether seqhound server returned SEQHOUND_OK, * SEQHOUND_ERROR, or SEQHOUND_NULL and returns the server * response, else returns SEQHOUND_ABNORMAL. * * @param content the string to parse the return value from * @see #SEQHOUND_ERROR * @see #SEQHOUND_NULL * @see #SEQHOUND_ABNORMAL * @see #SEQHOUND_OK */ protected int _ParseError(String content) { /* locates the first break in the line, which is either a space, tab or carriage return. */ int i = this._IndexOfFirstBreak(content); String code = content.substring(0, i); if(code.compareTo(OK) == 0){ return SEQHOUND_OK; }else if(code.compareTo(NULL) == 0){ return SEQHOUND_NULL; }else if(code.compareTo(ERROR) == 0){ return SEQHOUND_ERROR; }else{ return SEQHOUND_ABNORMAL; } } /** * takes a url address: http://server address/path to cgi?querystring * and sends the call to the remote server. Then it gets the response * from the server and determines the return value of the url. * and return SEQHOUND_OK, SEQHOUND_NULL, SEQHOUND_ERROR based on the * server response. * * @param address the http address * @param result a buffer in which to save the return value from the server * @throws IOException * if there is an I/O exception * @throws MalformedURLException if the address is not valid * @return SEQHOUND_OK, SEQHOUND_ERROR, SEQHOUND_NULL * @see #SEQHOUND_OK * @see #SEQHOUND_NULL * @see #SEQHOUND_ERROR */ protected int ProcessContents(String address, StringBuffer result) throws IOException, MalformedURLException { if( address == null ){ this.SHoundLogError(SH_severe, "[ProcessContents] Null string error: address"); return SEQHOUND_ERROR; } HttpClient client = new HttpClient(); GetMethod method = new GetMethod(address); method.setHttp11(false); int statusCode = -1; for (int attempt = 0; statusCode == -1 && attempt < 3; attempt++) { try { statusCode = client.executeMethod(method); }catch(HttpRecoverableException e) { //SHoundLogError(SH_Severe,e.toString()); }catch(IOException e) { break; } } if(statusCode == -1) { return SEQHOUND_ERROR; } InputStream mytest = method.getResponseBodyAsStream(); /* prepare to read from the response buffer */ BufferedReader bin = new BufferedReader(new InputStreamReader(mytest)); String inputLine; int i = SEQHOUND_ERROR; String test =bin.readLine(); /* read from the response buffer line by line * the first line is one of SEQHOUND_OK, SEQHOUND_NULL, * SEQHOUND_ERROR */ if( (i = this._ParseError(test)) == SEQHOUND_OK ){ /* after the first line is our data */ while((inputLine = bin.readLine()) != null) { result.append(inputLine.concat("\n")); } /* remove the last '\n' since it is not actually part of the response */ try{ result.deleteCharAt(result.length() -1); } catch (StringIndexOutOfBoundsException e){ return SEQHOUND_ERROR; } /* check the response, some times, it is * eg SEQHOUND_OK (null) which is really SEQHOUND_NULL */ String tmp = result.toString(); if(tmp.matches(".*(null).*")){ return SEQHOUND_NULL; }else if(tmp.matches("^-1$")){ return SEQHOUND_NULL; } /*else if(result.matches("^0$")){ return SEQHOUND_NULL; }*/ } /* end if */ bin.close(); method.releaseConnection(); return i; } /** * takes a url address: http://server address/path to cgi?querystring * and sends the call to the remote server. Then it gets the response * from the server and determines the return value of the url. * and return SEQHOUND_OK, SEQHOUND_NULL, SEQHOUND_ERROR based on the * server response. * * @param address the http address * @param out an output where the server response should be directed * @throws IOException * if there is an I/O exception * @throws MalformedURLException if the address is not valid * @return SEQHOUND_OK, SEQHOUND_ERROR, SEQHOUND_NULL * @see #SEQHOUND_OK * @see #SEQHOUND_NULL * @see #SEQHOUND_ERROR */ protected int ProcessContents(String address, Writer out) throws IOException, MalformedURLException { if(address == null){ this.SHoundLogError(SH_severe, "[ProcessContents]: Null address."); return SEQHOUND_ERROR; } if(out == null){ this.SHoundLogError(SH_severe, "[ProcessContents]: Null outputstream."); return SEQHOUND_ERROR; } /* open a connection to the server */ URL url = new URL(address); HttpURLConnection conn = (HttpURLConnection)url.openConnection(); // conn.setRequestMethod("POST"); BufferedReader bin = new BufferedReader(new InputStreamReader(conn.getInputStream())); String inputLine; int i; if( (i = this._ParseError(bin.readLine())) == SEQHOUND_OK ){ while( (inputLine = bin.readLine()) != null ){ out.write(inputLine.concat("\n")); } } return i; } private int _DecodeTaxLineage(String type) { if(type.equals("SHoundGetTaxLineage_FULL")) return TAX_LINEAGE_FULL; else if(type.equals("SHoundGetTaxLineage_GENBANK")) return TAX_LINEAGE_GENBANK; else if(type.equals("SHoundGetTaxLineage_TAXDBSHORT")) return TAX_LINEAGE_TAXDBSHORT; else return TAX_LINEAGE_FULL; } private int _DecipherNameClass(String nameClass) { if(nameClass.equals("SLRI_taxon_name_name_class_none")) return SLRI_TAXON_NAME_CLASS_NONE; else if(nameClass.equals("SLRI_taxon_name_name_class_acronym")) return SLRI_TAXON_NAME_CLASS_ACRONYM; else if(nameClass.equals("SLRI_taxon_name_name_class_anamorph")) return SLRI_TAXON_NAME_CLASS_ANAMORPH; else if(nameClass.equals("SLRI_taxon_name_name_class_blast_name")) return SLRI_TAXON_NAME_CLASS_BLAST_NAME; else if(nameClass.equals("SLRI_taxon_name_name_class_common_name")) return SLRI_TAXON_NAME_CLASS_COMMON_NAME; else if(nameClass.equals("SLRI_taxon_name_name_class_equivalent_name")) return SLRI_TAXON_NAME_CLASS_EQUIVALENT_NAME; else if(nameClass.equals("SLRI_taxon_name_name_class_includes")) return SLRI_TAXON_NAME_CLASS_INCLUDES; else if(nameClass.equals("SLRI_taxon_name_name_class_in_part")) return SLRI_TAXON_NAME_CLASS_IN_PART; else if(nameClass.equals("SLRI_taxon_name_name_class_misnomer")) return SLRI_TAXON_NAME_CLASS_MISNOMER; else if(nameClass.equals("SLRI_taxon_name_name_class_misspelling")) return SLRI_TAXON_NAME_CLASS_MISSPELLING; else if(nameClass.equals("SLRI_taxon_name_name_class_preferred_acronym")) return SLRI_TAXON_NAME_CLASS_PREFERRED_ACRONYM; else if(nameClass.equals("SLRI_taxon_name_name_class_preferred_common_name")) return SLRI_TAXON_NAME_CLASS_PREFERRED_COMMON_NAME; else if(nameClass.equals("SLRI_taxon_name_name_class_scientific_name")) return SLRI_TAXON_NAME_CLASS_SCIENTIFIC_NAME; else if(nameClass.equals("SLRI_taxon_name_name_class_synonym")) return SLRI_TAXON_NAME_CLASS_SYNONYM; else if(nameClass.equals("SLRI_taxon_name_name_class_teleomorph")) return SLRI_TAXON_NAME_CLASS_TELEOMORPH; else if(nameClass.equals("SLRI_taxon_name_name_class_other")) return SLRI_TAXON_NAME_CLASS_OTHER; else return SLRI_TAXON_NAME_CLASS_OTHER; } /** * Sends an http call to the servers to determine if they are up. * * @param configServerKey the key that specifies which server to use * @param path the path to the cgi-bin * @param args the http querystring * @return true/false, is the specified server up * @throws IOException if there is an I/O Exception */ protected boolean SHoundIsServerAlive(String configServerKey, String path, String args) throws IOException { if(configServerKey == null){ this.SHoundLogError(SH_severe, "[SHoundIsServerAlive] Null String error: configServerKey."); return false; } if(path == null){ this.SHoundLogError(SH_severe, "[SHoundIsServerAlive] Null String error: path."); return false; } if(args == null){ this.SHoundLogError(SH_severe, "[SHoundIsServerAlive] Null String error: args."); return false; } /* gets the server info from the configuration file */ ConfigFileReader con = new ConfigFileReader(configFile); if( (this.server = con.get("remote", configServerKey)) == null ){ return false; } /* construct the http call */ this.serverProtocol = "http://".concat(this.server); this.slri_cgi_path = path; String address = this.GetFunctionCall("SeqHoundInit", args); /* send the http call and get the response */ StringBuffer result = new StringBuffer(); int i; if((i = this.ProcessContents(address, result)) == SEQHOUND_OK){ return (new Boolean(result.toString())).booleanValue(); }else if (i == SEQHOUND_NULL){ this.SHoundLogError(SH_warn, "[SHoundInit] ".concat(NULL_STATEMENT)); }else if( i == SEQHOUND_ERROR){ this.SHoundLogError(SH_warn, "[SHoundInit] ".concat(ERROR_STATEMENT)); }else{ this.SHoundLogError(SH_warn, "[SHoundInit] ".concat(ABNORMAL_STATEMENT)); } return false; } /** * Initializes the SeqHound object. * this function must be called before any other seqhound functions * can be used. It tests for an active seqhound server and sets * this object to use that server. * * @param NetEntrezOnToo turn on net entrez on * @param appname the applicaton name * @return true if SeqHound initialized properly, else false * @throws IOException if an I/O Exception occurred */ public boolean SHoundInit(boolean NetEntrezOnToo, String appname) throws IOException { if(appname == null){ this.SHoundLogError(SH_severe, "[SHoundInit] Null string error: appname."); return false; } /* ready the configuration file, get the CGI path */ ConfigFileReader con = new ConfigFileReader(configFile); if( (slri_cgi_path = con.get("remote", "CGI")) == null ){ System.err.println("[SHoundInit] Failed to get the CGI path"); return false; } /* set the query string */ String boo = String.valueOf(NetEntrezOnToo); //.toUpperCase(); String args = "NetEntrezOnToo=".concat(boo).concat("&").concat("appname=").concat(appname); /* try our two servers to see one that works */ if(this.SHoundIsServerAlive("server1", slri_cgi_path, args)){ return (isInited = true); }else if(this.SHoundIsServerAlive("server2", slri_cgi_path, args)){ return (isInited = true); } /* failed to find a working server */ return false; } /** * Clean up SeqHound * @return true * @throws IOException */ public boolean SHoundFini() throws IOException { String args = "NULL"; String address = this.GetFunctionCall("SeqHoundFini", args); this.SHoundLogError(SH_info, "[SeqHoundFini]: ".concat(args)); int i; StringBuffer result = new StringBuffer(); if( (i = this.ProcessContents(address, result)) == SEQHOUND_OK ) { return (new Boolean(result.toString())).booleanValue(); }else if(i == SEQHOUND_ERROR){ this.SHoundLogError(SH_warn, "[SeqHoundFini]: ".concat(ERROR_STATEMENT)); }else if(i == SEQHOUND_NULL){ this.SHoundLogError(SH_warn, "[SeqHoundFini]: ".concat(NULL_STATEMENT)); }else{ this.SHoundLogError(SH_warn, "[SeqHoundFini]: ".concat(ABNORMAL_STATEMENT)); } return true; } /** * Checks if net entrez is enabled. Returns true if enabled, * else returns false; * @return true if net entrez enabled, else false * @throws IOException */ public boolean SHoundIsNetEntrezOn() throws IOException { String args = "NULL"; String address = this.GetFunctionCall("SeqHoundIsNetEntrezOn", args); this.SHoundLogError(SH_info, "[SeqHoundIsNetEntrezOn]: ".concat(args)); int i; StringBuffer result = new StringBuffer(); if( (i = this.ProcessContents(address, result)) == SEQHOUND_OK ) { return (new Boolean(result.toString())).booleanValue(); }else if(i == SEQHOUND_ERROR){ this.SHoundLogError(SH_warn, "[SeqHoundIsNetEntrezOn]: ".concat(ERROR_STATEMENT)); }else if( i == SEQHOUND_NULL){ this.SHoundLogError(SH_warn, "[SeqHoundIsNetEntrezOn]: ".concat(NULL_STATEMENT)); }else{ this.SHoundLogError(SH_warn, "[SeqHoundIsNetEntrezOn]: ".concat(ABNORMAL_STATEMENT)); } return false; } /** * Check if SeqHound has been initialized. * @return true if initialized, else false */ public boolean SHoundIsInited() { return isInited; } /** * Initializes net entrez. * @param appname the application name * @return true if net entrez initialized else, false * @throws IOException */ public boolean SHoundNetEntrezInit(String appname) throws IOException { if(appname == null){ this.SHoundLogError(SH_severe, "[SHoundNetEntrezInit] Null string error: appname."); return false; } /* construct the http call */ String args = "appname=".concat(appname); String address = this.GetFunctionCall("SeqHoundNetEntrezInit", args); this.SHoundLogError(SH_info, "[SeqHoundNetEntrezInit]: ".concat(args)); StringBuffer result = new StringBuffer(); int i; /* send the call to the server and get the response */ if( (i = this.ProcessContents(address, result)) == SEQHOUND_OK ) { return (new Boolean(result.toString())).booleanValue(); }else if(i == SEQHOUND_ERROR){ this.SHoundLogError(SH_warn, "[SeqHoundNetEntrezInit]: ".concat(ERROR_STATEMENT)); }else if(i == SEQHOUND_NULL){ this.SHoundLogError(SH_warn, "[SeqHoundNetEntrezInit]: ".concat(NULL_STATEMENT)); }else{ this.SHoundLogError(SH_warn, "[SeqHoundNetEntrezInit]: ".concat(ABNORMAL_STATEMENT)); } return false; } /** * Retrieves a gi from an accession value. * @param acc the accession value * @return the gi or a SEQHOUND_ERROR, SEQHOUND_NULL, SEQHOUND_ABNORMAL * if not found * @throws IOException */ public int SHoundFindAcc(String acc) throws IOException { if(acc == null){ this.SHoundLogError(SH_severe, "[SHoundFindAcc] Null string error: acc."); return SEQHOUND_ERROR; } /* constructs the http call to the server */ String args = "acc=".concat(acc); String address = this.GetFunctionCall("SeqHoundFindAcc", args); /* logs this call */ this.SHoundLogError(SH_info, "[SeqHoundFindAcc]: ".concat(args)); int i; /* get the server response */ StringBuffer result = new StringBuffer(); if( (i = this.ProcessContents(address, result)) == SEQHOUND_OK ) { return Integer.parseInt(result.toString()); }else if(i == SEQHOUND_ERROR){ this.SHoundLogError(SH_warn, "[SeqHoundFindAcc]: ".concat(ERROR_STATEMENT)); }else if(i == SEQHOUND_NULL){ this.SHoundLogError(SH_warn, "[SeqHoundFindAcc]: ".concat(NULL_STATEMENT)); }else{ this.SHoundLogError(SH_warn, "[SeqHoundFindAcc]: ".concat(ABNORMAL_STATEMENT)); } return SEQHOUND_ERROR; } /** * Retrieves a list of gi's given a list of accession values. * @param accList the list of accession values * @return a list of gi's, or null * @throws IOException * @see #SHoundFindAcc(String) */ public int[] SHoundFindAccList(String[] accList) throws IOException { if(accList == null){ this.SHoundLogError(SH_severe, "[SHoundFindAccList] Null array: accList."); return null; } if(accList.length < 1){ this.SHoundLogError(SH_severe, "[SHoundFindAccList] Empty array: accList."); return null; } /* copy over the list of accessions so that it does not get changed. */ Vector tmpV = SLRIMisc.CopyArray(accList); int[] iRet = new int[0]; String args, address; StringBuffer result; /* iterate through the list of accessions */ while(tmpV.size() > 0){ /* new buffer to read the responses */ result = new StringBuffer(); /* we will be sending the server requests in batches of MAXQ=700 because the server may have trouble with larger lists */ String[] itmp = SLRIMisc.MaxSizeStrList(tmpV); /* make the http call */ args = "pacc=".concat(SLRIMisc.SaveArrAsString(itmp)); address = this.GetFunctionCall("SeqHoundFindAccList", args); /* log each time we hit the server */ this.SHoundLogError(SH_info, "[SeqHoundFindAccList]: ".concat(args)); int i; /* get each server response and save it into our return list */ if((i = this.ProcessContents(address, result)) == SEQHOUND_OK) { iRet = SLRIMisc.MergeLists(SLRIMisc.StrInt2IntArr(result.toString(), ","), iRet); }else if(i == SEQHOUND_ERROR){ this.SHoundLogError(SH_warn, "[SeqHoundFindAccList]: ".concat(ERROR_STATEMENT)); }else if(i == SEQHOUND_NULL){ this.SHoundLogError(SH_warn, "[SeqHoundFindAccList]: ".concat(NULL_STATEMENT)); }else{ this.SHoundLogError(SH_warn, "[SeqHoundFindAccList]: ".concat(ABNORMAL_STATEMENT)); } } /* sort the return value, is this really necessary? */ Arrays.sort(iRet); return iRet; } /** * Converts PDB, EMBL, Siwss-Prot, PIR sequence identifier into a GI. * Note thatEMBL shares accession numbers with GenBank. EMBL GenInfo * identifiers may be returned using these accessions; for example * SHoundFindAcc(X13776) will return GI 45269. EMBL also has its own * identifiers (which the NCBI and SeqHound refer to as 'name'). * So the same GI may be returned by SHoundFindName(PAAMIR). * @param name the name * @return gi or a negative value * @throws IOException */ public int SHoundFindName(String name) throws IOException { if(name == null){ this.SHoundLogError(SH_severe, "[SHoundFindName] Null string: name."); return SEQHOUND_ERROR; } /* construct the http call */ String args = "name=".concat(name); String address = this.GetFunctionCall("SeqHoundFindName", args); /* log the request */ this.SHoundLogError(SH_info, "[SeqHoundFindName]: ".concat(args)); int i; /* prepare a response buffer */ StringBuffer result = new StringBuffer(); if((i = this.ProcessContents(address, result)) == SEQHOUND_OK) { return Integer.parseInt(result.toString()); }else if(i == SEQHOUND_ERROR){ this.SHoundLogError(SH_warn, "[SeqHoundFindName]: ".concat(ERROR_STATEMENT)); }else if(i == SEQHOUND_NULL){ this.SHoundLogError(SH_warn, "[SeqHoundFindName]: ".concat(NULL_STATEMENT)); }else{ this.SHoundLogError(SH_warn, "[SeqHoundFindName]: ".concat(ABNORMAL_STATEMENT)); } return SEQHOUND_ERROR; } /** * Given a list of ID from PDB, SwissProt, or PIR sequence identifiers, * retrieves a list of gi's. * Note that EMBL shares accession numbers with GenBank. EMBL GenInfo * identifiers may be returned using these accessions; for example * SHoundFindAcc(X13776) will return GI 45269. EMBL also has its own * identifiers (which the NCBI and SeqHound refer to as 'name'). * So the same GI may be returned by SHoundFindName("PAAMIR"). * @param nameList the list of names * @return list of gi's or null * @throws IOException * @see #SHoundFindName(String) */ public int[] SHoundFindNameList(String[] nameList) throws IOException { if(nameList == null){ this.SHoundLogError(SH_severe, "[SHoundFindNameList] Null array: nameList."); return null; } if(nameList.length < 1){ this.SHoundLogError(SH_severe, "[SHoundFindNameList] Empty array: nameList."); return null; } /* copy over the input list so that we don't alter the list */ Vector tmpV = SLRIMisc.CopyArray(nameList); int[] iRet = new int[0]; String args, address; StringBuffer result; /* while there are more to get */ while(tmpV.size() > 0){ result = new StringBuffer(); /* we do a batch request, 700 names at a time */ String[] itmp = SLRIMisc.MaxSizeStrList(tmpV); /* make the http call */ args = "pname=".concat(SLRIMisc.SaveArrAsString(itmp)); address = this.GetFunctionCall("SeqHoundFindNameList", args); /* log the request */ this.SHoundLogError(SH_info, "[SeqHoundFindNameList]: ".concat(args)); int i; /* get the server response */ if((i = this.ProcessContents(address, result)) == SEQHOUND_OK) { iRet = SLRIMisc.MergeLists(iRet, SLRIMisc.StrInt2IntArr(result.toString(), ",")); }else if(i == SEQHOUND_ERROR){ this.SHoundLogError(SH_warn, "[SeqHoundFindNameList]: ".concat(ERROR_STATEMENT)); }else if(i == SEQHOUND_NULL){ this.SHoundLogError(SH_warn, "[SeqHoundFindNameList]: ".concat(NULL_STATEMENT)); }else{ this.SHoundLogError(SH_warn, "[SeqHoundFindNameList]: ".concat(ABNORMAL_STATEMENT)); } } return iRet; } /** * Gets an accession value given a gi value. * @param gi the gi to look up * @return the accession value * @throws IOException */ public String SHoundAccFromGi(int gi) throws IOException { if(gi <= 0){ this.SHoundLogError(SH_severe, "[SHoundAccFromGi] Invalid gi."); return null; } /* the http call */ String args = "gi=".concat(String.valueOf(gi)); String address = this.GetFunctionCall("SeqHoundAccFromGi", args); /* log it */ this.SHoundLogError(SH_info, "[SeqHoundAccFromGi]: ".concat(args)); int i; /* save response */ StringBuffer result = new StringBuffer(); if((i = this.ProcessContents(address, result)) == SEQHOUND_OK){ return result.toString(); }else if(i == SEQHOUND_ERROR){ this.SHoundLogError(SH_warn, "[SeqHoundAccFromGi]: ".concat(ERROR_STATEMENT)); }else if(i == SEQHOUND_NULL){ this.SHoundLogError(SH_warn, "[SeqHoundAccFromGi]: ".concat(NULL_STATEMENT)); }else{ this.SHoundLogError(SH_warn, "[SeqHoundAccFromGi]: ".concat(ABNORMAL_STATEMENT)); } return null; } /** * Retrieves a list of accession given a list of gi's * @param giList the list of gi's * @return the list of accessions or null * @throws IOException * @see #SHoundAccFromGi(int) */ public String[] SHoundAccFromGiList(int[] giList) throws IOException { if(giList == null){ this.SHoundLogError(SH_severe, "[SHoundAccFromGiList] Null array: giList."); return null; } if(giList.length < 1){ this.SHoundLogError(SH_severe, "[SHoundAccFromGiList] Empty array: giList"); return null; } /* copy over to not alter original */ Vector tmpV = SLRIMisc.CopyArray(giList); String[] strRet = new String[0]; String args, address; StringBuffer result; /* iterate through the list */ while(tmpV.size() > 0){ result = new StringBuffer(); /* we send requests in batches of 700 so the server does not overload */ int[] itmp = SLRIMisc.MaxSizeIntList(tmpV); args = "pgi=".concat(SLRIMisc.SaveArrAsString(itmp)); address = this.GetFunctionCall("SeqHoundAccFromGiList", args); /* log the request */ this.SHoundLogError(SH_info, "[SeqHoundAccFromGiList]: ".concat(args)); int i; /* send the request, and save the response */ if((i = this.ProcessContents(address, result)) == SEQHOUND_OK){ strRet = SLRIMisc.MergeLists(strRet, SLRIMisc.StrStr2StrArr(result.toString(), ",")); }else if(i == SEQHOUND_ERROR){ this.SHoundLogError(SH_warn, "[SeqHoundAccFromGiList]: ".concat(ERROR_STATEMENT)); }else if(i == SEQHOUND_NULL){ this.SHoundLogError(SH_warn, "[SeqHoundAccFromGiList]: ".concat(NULL_STATEMENT)); }else{ this.SHoundLogError(SH_warn, "[SeqHoundAccFromGiList]: ".concat(ABNORMAL_STATEMENT)); } } return strRet; } /** * Gets a SeqId object given a gi. SeqId object is an ASN formatted * string with relevant gi information. * @param gi the gi to retrieve the SeqId for * @return the SeqId * @throws IOException */ public String SHoundSeqIdFromGi(int gi) throws IOException { if(gi <= 0){ this.SHoundLogError(SH_severe, "[SHoundSeqIdFromGi] Invalid gi."); return null; } /* construct the http call */ String args = "gi=".concat(String.valueOf(gi)); String address = this.GetFunctionCall("SeqHoundSeqIdFromGiPL", args); /* log the request */ this.SHoundLogError(SH_info, "[SeqHoundSeqIdFromGi]: ".concat(args)); int i; /* prepare response buffer */ StringBuffer result = new StringBuffer(); if((i = this.ProcessContents(address, result)) == SEQHOUND_OK){ return result.toString(); }else if(i == SEQHOUND_ERROR){ this.SHoundLogError(SH_warn, "[SeqHoundSeqIdFromGi]: ".concat(ERROR_STATEMENT)); }else if(i == SEQHOUND_NULL){ this.SHoundLogError(SH_warn, "[SeqHoundSeqIdFromGi]: ".concat(NULL_STATEMENT)); }else{ this.SHoundLogError(SH_warn, "[SeqHoundSeqIdFromGi]: ".concat(ABNORMAL_STATEMENT)); } return null; } /** * Get the SeqId's given a gi list. The SeqId's will be one big string * formatted in ASN. * @param giList the list of gi * @return the ASN formatted string or null * @throws IOException * @see #SHoundSeqIdFromGi(int) */ public String SHoundSeqIdFromGiList(int[] giList) throws IOException { if(giList == null){ this.SHoundLogError(SH_severe, "[SHoundSeqIdFromGiList] Null array: giList"); return null; } if(giList.length < 1){ this.SHoundLogError(SH_severe, "[SHoundSeqIdFromGiList] Empty array: giList"); return null; } /* copy over so we don't change the original list */ Vector tmpV = SLRIMisc.CopyArray(giList); StringBuffer strRet = new StringBuffer(); StringBuffer result; String args, address; /* iterate until list all is requested */ while(tmpV.size() > 0){ result = new StringBuffer(); int[] itmp = SLRIMisc.MaxSizeIntList(tmpV); /* our http call */ args = "pgi=".concat(SLRIMisc.SaveArrAsString(itmp)); address = this.GetFunctionCall("SeqHoundSeqIdFromGiListPL", args); /* log each http call */ this.SHoundLogError(SH_info, "[SeqHoundSeqIdFromGiList]: ".concat(args)); int i; /* get our response */ if((i = this.ProcessContents(address, result)) == SEQHOUND_OK){ strRet.append(result.append("\n")); }else if(i == SEQHOUND_ERROR){ this.SHoundLogError(SH_warn, "[SeqHoundSeqIdFromGiList]: ".concat(ERROR_STATEMENT)); }else if(i == SEQHOUND_NULL){ this.SHoundLogError(SH_warn, "[SeqHoundSeqIdFromGiList]: ".concat(NULL_STATEMENT)); }else{ this.SHoundLogError(SH_warn, "[SeqHoundSeqIdFromGiList]: ".concat(ABNORMAL_STATEMENT)); } } if(strRet.length() == 0) return null; return strRet.substring(0, strRet.length() - 1); } /** * determines the molecular type given a gi * @param gi the gi to be determined * @return a string description of the molecule type. * Possible values include: protein, DNA, RNA or a null * @throws IOException */ public String SHoundMoleculeType(int gi) throws IOException { if(gi <= 0){ this.SHoundLogError(SH_severe, "[SHoundMoleculeType] Invalid gi."); return null; } /* make http call */ String args = "gi=".concat(String.valueOf(gi)); String address = this.GetFunctionCall("SeqHoundMoleculeType", args); /* log the request */ this.SHoundLogError(SH_info, "[SeqHoundMoleculeType]: ".concat(args)); int i; /* get the response */ StringBuffer result = new StringBuffer(); if((i = this.ProcessContents(address, result)) == SEQHOUND_OK){ return result.toString(); }else if(i == SEQHOUND_ERROR){ this.SHoundLogError(SH_warn, "[SeqHoundMoleculeType]: ".concat(ERROR_STATEMENT)); }else if(i == SEQHOUND_NULL){ this.SHoundLogError(SH_warn, "[SeqHoundMoleculeType]: ".concat(NULL_STATEMENT)); }else{ this.SHoundLogError(SH_warn, "[SeqHoundMoleculeType]: ".concat(ABNORMAL_STATEMENT)); } return null; } /** * retrieves the length of a sequence. * @param gi the sequence to get the length of * @return the length of the sequence * @throws IOException */ public int SHoundSequenceLength(int gi) throws IOException { if(gi <= 0){ this.SHoundLogError(SH_severe, "[SHoundSequenceLength] Invalid gi."); return SEQHOUND_ERROR; } /* construct the http call */ String args = "gi=".concat(String.valueOf(gi)); String address = this.GetFunctionCall("SeqHoundSequenceLength", args); /* log the request */ this.SHoundLogError(SH_info, "[SeqHoundSequenceLength]: ".concat(args)); int i; /* get the response */ StringBuffer result = new StringBuffer(); if((i = this.ProcessContents(address, result)) == SEQHOUND_OK){ return Integer.parseInt(result.toString()); }else if(i == SEQHOUND_ERROR){ this.SHoundLogError(SH_warn, "[SeqHoundSequenceLength]: ".concat(ERROR_STATEMENT)); }else if(i == SEQHOUND_NULL){ this.SHoundLogError(SH_warn, "[SeqHoundSequenceLength]: ".concat(NULL_STATEMENT)); }else{ this.SHoundLogError(SH_warn, "[SeqHoundSequenceLength]: ".concat(ABNORMAL_STATEMENT)); } return SEQHOUND_ERROR; } /** * Returns where a given gi is a protein or not. * @param gi the gi to determine * @return true if gi is protein, else false * @deprecated replaced by {@link #SHoundMoleculeType(int)} * @throws IOException */ public boolean SHoundIsProtein(int gi) throws IOException { if(gi <= 0){ this.SHoundLogError(SH_severe, "[SHoundIsProtein] Invalid gi."); return false; } /* construct the http call */ String args = "gi=".concat(String.valueOf(gi)); String address = this.GetFunctionCall("SeqHoundIsProtein", args); /* logs the information */ this.SHoundLogError(SH_info, "[SeqHoundIsProtein]: ".concat(args)); int i; /* prepare response buffer and save response */ StringBuffer result = new StringBuffer(); if((i = this.ProcessContents(address, result)) == SEQHOUND_OK){ return (new Boolean(result.toString())).booleanValue(); }else if(i == SEQHOUND_ERROR){ this.SHoundLogError(SH_warn, "[SeqHoundIsProtein]: ".concat(ERROR_STATEMENT)); }else if(i == SEQHOUND_NULL){ this.SHoundLogError(SH_warn, "[SeqHoundIsProtein]: ".concat(NULL_STATEMENT)); }else{ this.SHoundLogError(SH_warn, "[SeqHoundIsProtein]: ".concat(ABNORMAL_STATEMENT)); } return false; } /** * Reports if a given GI identifier represents the best annotated version * from a group of database entries referring to the same protein sequence * (so called redundant proteins). * @param gi the gi * @return true if best annotated else false * @throws IOException */ public boolean SHoundIsNRFirst(int gi) throws IOException { if(gi <= 0){ this.SHoundLogError(SH_severe, "[SHoundIsNRFirst] Invalid gi."); return false; } /* construct the http call */ String args = "gi=".concat(String.valueOf(gi)); String address = this.GetFunctionCall("SeqHoundIsNRFirst", args); /* log the request */ this.SHoundLogError(SH_info, "[SeqHoundIsNRFirst]: ".concat(args)); int i; /* save the response */ StringBuffer result = new StringBuffer(); if((i = this.ProcessContents(address, result)) == SEQHOUND_OK){ return (new Boolean(result.toString())).booleanValue(); }else if(i == SEQHOUND_ERROR){ this.SHoundLogError(SH_warn, "[SeqHoundIsNRFirst]: ".concat(ERROR_STATEMENT)); }else if(i == SEQHOUND_NULL){ this.SHoundLogError(SH_warn, "[SeqHoundIsNRFirst]: ".concat(NULL_STATEMENT)); }else{ this.SHoundLogError(SH_warn, "[SeqHoundIsNRFirst]: ".concat(ABNORMAL_STATEMENT)); } return false; } /** * reports whether a given gi exists in the SeqHound database. * @param gi the gi to request * @return true if the gi is present in SeqHound, else false * @throws IOException */ public boolean SHoundExists(int gi) throws IOException { if(gi <= 0){ this.SHoundLogError(SH_severe, "[SHoundExists] Invalid gi."); return false; } /* the http call */ String args = "gi=".concat(String.valueOf(gi)); String address = this.GetFunctionCall("SeqHoundExists", args); /* log request */ this.SHoundLogError(SH_info, "[SeqHoundExists]: ".concat(args)); int i; StringBuffer result = new StringBuffer(); if((i = this.ProcessContents(address, result)) == SEQHOUND_OK){ return (new Boolean(result.toString())).booleanValue(); }else if(i == SEQHOUND_ERROR){ this.SHoundLogError(SH_warn, "[SeqHoundExists]: ".concat(ERROR_STATEMENT)); }else if(i == SEQHOUND_NULL){ this.SHoundLogError(SH_warn, "[SeqHoundExists]: ".concat(NULL_STATEMENT)); }else{ this.SHoundLogError(SH_warn, "[SeqHoundExists]: ".concat(ABNORMAL_STATEMENT)); } return false; } /** * Finds out what kind of molecules are contained in a 3-D structure. * @param mmdbid the 3D structure ID * @return 1 is a polymer, 2 is a protein, 4 is a DNA, 8 is a heteroatom * 16 is solvent, 32 is water, 64 is RNA, 138 is ion * @throws IOException */ public int SHound3DbWhat(int mmdbid) throws IOException { if(mmdbid <= 0){ this.SHoundLogError(SH_severe, "[SHound3DbWhat] Invalid mmdbid."); return SEQHOUND_ERROR; } /* construct the http call */ String args = "mmdbid=".concat(String.valueOf(mmdbid)); String address = this.GetFunctionCall("SeqHound3DbWhat", args); /* log the request */ this.SHoundLogError(SH_info, "[SeqHound3DbWhat]: ".concat(args)); int i; /* get the server response */ StringBuffer result = new StringBuffer(); if((i = this.ProcessContents(address, result)) == SEQHOUND_OK){ return Integer.parseInt(result.toString()); }else if(i == SEQHOUND_ERROR){ this.SHoundLogError(SH_warn, "[SeqHound3DbWhat]: ".concat(ERROR_STATEMENT)); }else if(i == SEQHOUND_NULL){ this.SHoundLogError(SH_warn, "[SeqHound3DbWhat]: ".concat(NULL_STATEMENT)); }else{ this.SHoundLogError(SH_warn, "[SeqHound3DbWhat]: ".concat(ABNORMAL_STATEMENT)); } return SEQHOUND_ERROR; } /** * return the largest mmdbid * @return mmdbid the 3D structure ID * @throws IOException */ public int SHoundGetLargestMMDBID() throws IOException { String args = "NULL"; String address = this.GetFunctionCall("SeqHoundGetLargestMMDBID", args); this.SHoundLogError(SH_info, "[SeqHoundGetLargestMMDBID]: ".concat(args)); int i; StringBuffer result = new StringBuffer(); if( (i = this.ProcessContents(address, result)) == SEQHOUND_OK ) { return Integer.parseInt(result.toString()); }else if(i == SEQHOUND_ERROR){ this.SHoundLogError(SH_warn, "[SeqHoundGetLargestMMDBID]: ".concat(ERROR_STATEMENT)); }else if(i == SEQHOUND_NULL){ this.SHoundLogError(SH_warn, "[SeqHoundGetLargestMMDBID]: ".concat(NULL_STATEMENT)); }else{ this.SHoundLogError(SH_warn, "[SeqHoundGetLargestMMDBID]: ".concat(ABNORMAL_STATEMENT)); } return SEQHOUND_ERROR; } /** * Finds out whether a given structural ID (mmdbid) exists in the * SeqHound database. * @param mmdbid the structural ID * @return true if in SeqHound, else false * @throws IOException */ public boolean SHound3DExists(int mmdbid) throws IOException { if(mmdbid <= 0){ this.SHoundLogError(SH_severe, "[SHound3DExists] Invalid mmdbid."); return false; } /* construct the http call */ String args = "mmdbid=".concat(String.valueOf(mmdbid)); String address = this.GetFunctionCall("SeqHound3DExists", args); /* log request */ this.SHoundLogError(SH_info, "[SeqHound3DExists]: ".concat(args)); int i; /* get response */ StringBuffer result = new StringBuffer(); if((i = this.ProcessContents(address, result)) == SEQHOUND_OK){ return (new Boolean(result.toString())).booleanValue(); }else if(i == SEQHOUND_ERROR){ this.SHoundLogError(SH_warn, "[SeqHound3DbExists]: ".concat(ERROR_STATEMENT)); }else if(i == SEQHOUND_NULL){ this.SHoundLogError(SH_warn, "[SeqHound3DExists]: ".concat(NULL_STATEMENT)); }else{ this.SHoundLogError(SH_warn, "[SeqHound3DExists]: ".concat(ABNORMAL_STATEMENT)); } return false; } /** * Retrieves the PMID's in the LocusLink database for a given gi and * gene ontology id. * @param gi the gene info id * @param goid a geneontology id * @return an array of PMID associated with the inputs * @throws IOException */ public int[] SHoundGOPMIDFromGiAndGOID(int gi, int goid) throws IOException { if(gi <= 0 || goid <=0){ this.SHoundLogError(SH_severe, "[SHoundGOPMIDFromGiAndGOID] Invalid gi or goid."); return null; } /* construct the http call */ String args = "gi=".concat(String.valueOf(gi))+"&goid=".concat(String.valueOf(goid)); String address = this.GetFunctionCall("SeqHoundGOPMIDFromGiAndGOID", args); /* log the http request */ this.SHoundLogError(SH_info, "[SeqHoundGOPMIDFromGiAndGOID]: ".concat(args)); int i; StringBuffer result = new StringBuffer(); if((i = this.ProcessContents(address, result)) == SEQHOUND_OK){ return (SLRIMisc.StrInt2IntArr(result.toString(), ",")); }else if(i == SEQHOUND_ERROR){ this.SHoundLogError(SH_warn, "[SeqHoundGOPMIDFromGiAndGOID]: ".concat(ERROR_STATEMENT)); }else if(i == SEQHOUND_NULL){ this.SHoundLogError(SH_warn, "[SeqHoundGOPMIDFromGiAndGOID]: ".concat(NULL_STATEMENT)); }else{ this.SHoundLogError(SH_warn, "[SeqHoundGOPMIDFromGi]: ".concat(ABNORMAL_STATEMENT)); } return null; } /** * Retrieves all the evidence code from locuslink for a given gi and gene ontology id. * @param gi the gi * @param goid the gene ontology id * @return an array of evidence code from the locuslink database. * @throws IOException */ public String[] SHoundGOECodeFromGiAndGOID(int gi, int goid) throws IOException { if(gi <= 0 || goid <=0){ this.SHoundLogError(SH_severe, "[SHoundGOECodeFromGiAndGOID] Invalid gi or goid."); return null; } String args = "gi=".concat(String.valueOf(gi))+"&goid=".concat(String.valueOf(goid)); String address = this.GetFunctionCall("SeqHoundGOECodeFromGiAndGOID", args); this.SHoundLogError(SH_info, "[SeqHoundGOECodeFromGiAndGOID]: ".concat(args)); int i; StringBuffer result = new StringBuffer(); if((i = this.ProcessContents(address, result)) == SEQHOUND_OK){ return (SLRIMisc.StrStr2StrArr(result.toString(),",")); }else if(i == SEQHOUND_ERROR){ this.SHoundLogError(SH_warn, "[SeqHoundGOECodeFromGiAndGOID]: ".concat(ERROR_STATEMENT)); }else if(i == SEQHOUND_NULL){ this.SHoundLogError(SH_warn, "[SeqHoundGOECodeFromGiAndGOID]: ".concat(NULL_STATEMENT)); }else{ this.SHoundLogError(SH_warn, "[SeqHoundGOECodeFromGiAndGOID]: ".concat(ABNORMAL_STATEMENT)); } return null; } /** * Retrieves the MUID or PMID for a given gi. * @param gi the gi * @param reftype specifies whether to return PMID or MUID. * Set reftype to 1 for MUID, 2 for PMID. * @return an array of reference ids. */ public int[] SHoundGetReferenceIDFromGi(int gi, int reftype) throws IOException { if(gi <= 0 || reftype <=0){ this.SHoundLogError(SH_severe, "[SHoundGetReferenceIDFromGi]; Invalid gi or reftype."); return null; } String args = "gi=".concat(String.valueOf(gi))+"&referencetype=".concat(String.valueOf(reftype)); String address = this.GetFunctionCall("SeqHoundGetReferenceIDFromGi", args); this.SHoundLogError(SH_info, "[SeqHoundGetReferenceIDFromGi]: ".concat(args)); int i; StringBuffer result = new StringBuffer(); if((i = this.ProcessContents(address, result)) == SEQHOUND_OK){ return (SLRIMisc.StrInt2IntArr(result.toString(), ",")); }else if(i == SEQHOUND_ERROR){ this.SHoundLogError(SH_warn, "[SeqHoundGetReferenceIDFromGi]: ".concat(ERROR_STATEMENT)); }else if(i == SEQHOUND_NULL){ this.SHoundLogError(SH_warn, "[SeqHoundGetReferenceIDFromGi]: ".concat(NULL_STATEMENT)); }else{ this.SHoundLogError(SH_warn, "[SeqHoundGetReferenceIDFromGi]: ".concat(ABNORMAL_STATEMENT)); } return null; } /** * Retrieves the MUID or PMID for a given gi. * @param giList the gilist * @param reftype specifies whether to return PMID or MUID. * Set reftype to 1 for MUID, 2 for PMID. * @return an array of reference ids. */ public int[] SHoundGetReferenceIDFromGiList(int[] giList, int reftype) throws IOException { if(giList == null){ this.SHoundLogError(SH_severe, "[SHoundGetReferenceIDFromGiList] Empty array: giList"); return null; } if(giList.length < 1){ this.SHoundLogError(SH_severe, "[SHoundGetReferenceIDFromGiList] Empty array: giList"); return null; } if (reftype <= 0) { this.SHoundLogError(SH_severe, "[SHoundGetReferenceIDFromGiList] Invalid reftype"); return null; } Vector tmpV = SLRIMisc.CopyArray(giList); int[] iRet = new int[0]; String args, address; StringBuffer result; while(tmpV.size() > 0){ result = new StringBuffer(); int[] itmp = SLRIMisc.MaxSizeIntList(tmpV); args = "gilist=".concat(SLRIMisc.SaveArrAsString(itmp))+"&reftype=".concat(String.valueOf(reftype)); address = this.GetFunctionCall("SeqHoundGetReferenceIDFromGiList", args); this.SHoundLogError(SH_info, "[SeqHoundGetReferenceIDFromGiList]: ".concat(args)); int i; if((i = this.ProcessContents(address, result)) == SEQHOUND_OK){ iRet = SLRIMisc.MergeLists(iRet, SLRIMisc.StrInt2IntArr(result.toString(), ",")); }else if(i == SEQHOUND_ERROR){ this.SHoundLogError(SH_warn, "[SeqHoundGetReferenceIDFromGiList]: ".concat(ERROR_STATEMENT)); }else if(i == SEQHOUND_NULL){ this.SHoundLogError(SH_warn, "[SeqHoundGetReferenceIDFromGiList]: ".concat(NULL_STATEMENT)); }else{ this.SHoundLogError(SH_warn, "[SeqHoundGetReferenceIDFromGiList]: ".concat(ABNORMAL_STATEMENT)); } } return iRet; } /** * Retrieves the gi's associated with a publication. * @param refid the publication id * @param reftype the publication type. Set reftype to 1 if refid is a PMID * Set reftype to 2 if refid is a MUID. * @return an array of integers that are gis, or null * @throws IOException */ public int[] SHoundGiFromReferenceID(int refid, int reftype) throws IOException { if(refid <= 0 || reftype <=0){ this.SHoundLogError(SH_severe, "[SHoundGiFromReferenceID] Invalid refid or reftype."); return null; } String args = "referenceid=".concat(String.valueOf(refid))+"&referencetype=".concat(String.valueOf(reftype)); String address = this.GetFunctionCall("SeqHoundGiFromReferenceID", args); this.SHoundLogError(SH_info, "[SeqHoundGiFromReferenceID]: ".concat(args)); int i; StringBuffer result = new StringBuffer(); if((i = this.ProcessContents(address, result)) == SEQHOUND_OK){ return (SLRIMisc.StrInt2IntArr(result.toString(), ",")); }else if(i == SEQHOUND_ERROR){ this.SHoundLogError(SH_warn, "[SeqHoundGiFromReferenceID]: ".concat(ERROR_STATEMENT)); }else if(i == SEQHOUND_NULL){ this.SHoundLogError(SH_warn, "[SeqHoundGiFromReferenceID]: ".concat(NULL_STATEMENT)); }else{ this.SHoundLogError(SH_warn, "[SeqHoundGiFromReferenceID]: ".concat(ABNORMAL_STATEMENT)); } return null; } /** * Retrieves the gi's associated with a publication list. * @param refList the publication list * @param reftype the publication type. Set reftype to 1 if refid is a PMID * Set reftype to 2 if refid is a MUID. * @return an array of integers that are gis, or null * @throws IOException */ public int[] SHoundGiFromReferenceList(int[] refList, int reftype) throws IOException { if(refList == null){ this.SHoundLogError(SH_severe, "[SHoundGiFromReferenceList] Empty array: refList"); return null; } if(refList.length < 1){ this.SHoundLogError(SH_severe, "[SHoundGiFromReferenceList] Empty array: refList"); return null; } if (reftype <= 0) { this.SHoundLogError(SH_severe, "[SHoundGiFromReferenceList] Invalid reftype"); return null; } Vector tmpV = SLRIMisc.CopyArray(refList); int[] iRet = new int[0]; String args, address; StringBuffer result; while(tmpV.size() > 0){ result = new StringBuffer(); int[] itmp = SLRIMisc.MaxSizeIntList(tmpV); args = "reflist=".concat(SLRIMisc.SaveArrAsString(itmp))+"&reftype=".concat(String.valueOf(reftype)); address = this.GetFunctionCall("SeqHoundGiFromReferenceList", args); this.SHoundLogError(SH_info, "[SeqHoundGiFromReferenceList]: ".concat(args)); int i; if((i = this.ProcessContents(address, result)) == SEQHOUND_OK){ iRet = SLRIMisc.MergeLists(iRet, SLRIMisc.StrInt2IntArr(result.toString(), ",")); }else if(i == SEQHOUND_ERROR){ this.SHoundLogError(SH_warn, "[SeqHoundGiFromReferenceList]: ".concat(ERROR_STATEMENT)); }else if(i == SEQHOUND_NULL){ this.SHoundLogError(SH_warn, "[SeqHoundGiFromReferenceList]: ".concat(NULL_STATEMENT)); }else{ this.SHoundLogError(SH_warn, "[SeqHoundGiFromReferenceList]: ".concat(ABNORMAL_STATEMENT)); } } return iRet; } /** * fetches a string formated in ASN representing a sequence information. * The seqence information is called a Bioseq and it contains all * the available annotation. * @param gi the gi * @return the string ASN Bioseq * @throws IOException */ public String SHoundGetBioseq(int gi) throws IOException { if(gi <= 0){ this.SHoundLogError(SH_severe, "[SHoundGetBioseq] Invalid gi."); return null; } /* construct the http */ String args = "gi=".concat(String.valueOf(gi)); String address = this.GetFunctionCall("SeqHoundGetBioseqPL", args); /* log the request */ this.SHoundLogError(SH_info, "[SeqHoundGetBioseq]: ".concat(args)); int i; /* prepare the response */ StringBuffer result = new StringBuffer(); if((i = this.ProcessContents(address, result)) == SEQHOUND_OK){ return result.toString(); }else if(i == SEQHOUND_ERROR){ this.SHoundLogError(SH_warn, "[SeqHoundGetBioseq]: ".concat(ERROR_STATEMENT)); }else if(i == SEQHOUND_NULL){ this.SHoundLogError(SH_warn, "[SeqHoundGetBioseq]: ".concat(NULL_STATEMENT)); }else{ this.SHoundLogError(SH_warn, "[SeqHoundGetBioseq]: ".concat(ABNORMAL_STATEMENT)); } return null; } /** * Get a list of ASN.1 formatted sequence information and available * annotations. * @param giList the list of gi * @return a string ASN * @throws IOException * @see #SHoundGetBioseq(int) */ public String SHoundGetBioseqList(int[] giList) throws IOException { if(giList == null){ this.SHoundLogError(SH_severe, "[SHoundGetBioseqList] Null array: giList"); return null; } if(giList.length < 1){ this.SHoundLogError(SH_severe, "[SHoundGetBioseqList] Empty array: giList"); return null; } /* copy the gi list over so we don't alter the original */ Vector tmpV = SLRIMisc.CopyArray(giList); StringBuffer strRet = new StringBuffer(); StringBuffer result; String args, address; /* iterate through the list */ while(tmpV.size() > 0){ /* response buffer*/ result = new StringBuffer(); /* sending requests in batches of 700 */ int[] itmp = SLRIMisc.MaxSizeIntList(tmpV); /* the htpp calls */ args = "pgi=".concat(SLRIMisc.SaveArrAsString(itmp)); address = this.GetFunctionCall("SeqHoundGetBioseqListPL", args); /* log the request */ this.SHoundLogError(SH_info, "[SeqHoundGetBioseqList]: ".concat(args)); int i; if((i = this.ProcessContents(address, result)) == SEQHOUND_OK){ strRet.append(result.append("\n")); }else if(i == SEQHOUND_ERROR){ this.SHoundLogError(SH_warn, "[SeqHoundGetBioseqList]: ".concat(ERROR_STATEMENT)); }else if(i == SEQHOUND_NULL){ this.SHoundLogError(SH_warn, "[SeqHoundGetBioseqList]: ".concat(NULL_STATEMENT)); }else{ this.SHoundLogError(SH_warn, "[SeqHoundGetBioseqList]: ".concat(ABNORMAL_STATEMENT)); } } if(strRet.length() == 0) return null; return strRet.substring(0, strRet.length() - 1); } /** * Get an XML Formated Bioseq structure which contains * sequence information and all available annotations. * @param gi the gi * @return the XML string * @throws IOException * @see #SHoundGetBioseq(int) */ public String SHoundGetXMLBioseq(int gi) throws IOException { if(gi <= 0){ this.SHoundLogError(SH_severe, "[SHoundGetXMLBioseq] Invalid gi."); return null; } /* construct the http call */ String args = "gi=".concat(String.valueOf(gi)); String address = this.GetFunctionCall("SeqHoundXMLBioseqPL", args); /* logs the request */ this.SHoundLogError(SH_info, "[SeqHoundGetXMLBioseq]: ".concat(args)); int i; /* the response */ StringBuffer result = new StringBuffer(); if((i = this.ProcessContents(address, result)) == SEQHOUND_OK){ return result.toString(); }else if(i == SEQHOUND_ERROR){ this.SHoundLogError(SH_warn, "[SeqHoundGetXMLBioseq]: ".concat(ERROR_STATEMENT)); }else if(i == SEQHOUND_NULL){ this.SHoundLogError(SH_warn, "[SeqHoundGetXMLBioseq]: ".concat(NULL_STATEMENT)); }else{ this.SHoundLogError(SH_warn, "[SeqHoundGetXMLBioseq]: ".concat(ABNORMAL_STATEMENT)); } return null; } /** * A wrap function to get an XML Formated Bioseq structure which contains * sequence information and all available annotations. To consist with other * remote APIs * @param gi the gi * @return the XML string * @throws IOException */ public String SHoundXMLBioseq(int gi) throws IOException { if(gi <= 0){ this.SHoundLogError(SH_severe, "[SHoundXMLBioseq] Invalid gi."); return null; } return this.SHoundGetXMLBioseq(gi); } /** * Fetches ASN.1 representation of a sequence called SeqEntry. * SeqEntry contains a single sequence or a group of sequences * if they are logically related (e.g. gene and its protein product). * @param gi the gi * @return an XML formatted string represented the SeqEntry or null * @throws IOException */ public String SHoundGetSeqEntry(int gi) throws IOException { if(gi <= 0){ this.SHoundLogError(SH_severe, "[SHoundGetSeqEntry] Invalid gi."); return null; } /* the http call */ String args = "gi=".concat(String.valueOf(gi)); String address = this.GetFunctionCall("SeqHoundGetSeqEntryPL", args); /* log the request */ this.SHoundLogError(SH_info, "[SeqHoundGetSeqEntry]: ".concat(args)); int i; /* the response */ StringBuffer result = new StringBuffer(); if((i = this.ProcessContents(address, result)) == SEQHOUND_OK){ return result.toString(); }else if(i == SEQHOUND_ERROR){ this.SHoundLogError(SH_warn, "[SeqHoundGetSeqEntry]: ".concat(ERROR_STATEMENT)); }else if(i == SEQHOUND_NULL){ this.SHoundLogError(SH_warn, "[SeqHoundGetSeqEntry]: ".concat(NULL_STATEMENT)); }else{ this.SHoundLogError(SH_warn, "[SeqHoundGetSeqEntry]: ".concat(ABNORMAL_STATEMENT)); } return null; } /** * Retrieves a list of seqentry from a list of gi * * @param giList the gi list * @return an ASN formated string containing the seqentry * @throws IOException * @see #SHoundGetSeqEntry(int) */ public String SHoundGetSeqEntryList(int[] giList) throws IOException { if(giList == null){ this.SHoundLogError(SH_severe, "[SHoundGetSeqEntryList] Null array: giList"); return null; } if(giList.length < 1){ this.SHoundLogError(SH_severe, "[SHoundGetSeqEntryList] Empty array: giList"); return null; } /* copy over the input array */ Vector tmpV = SLRIMisc.CopyArray(giList); StringBuffer strRet = new StringBuffer(); StringBuffer result; String args, address; /* iterate through each one */ while(tmpV.size() > 0){ result = new StringBuffer(); /* send requests 700 gi at a time */ int[] itmp = SLRIMisc.MaxSizeIntList(tmpV); /* construct the http call */ args = "pgi=".concat(SLRIMisc.SaveArrAsString(itmp)); address = this.GetFunctionCall("SeqHoundGetSeqEntryListPL", args); /* log the request */ this.SHoundLogError(SH_info, "[SeqHoundGetSeqEntry]: ".concat(args)); int i; /* save response */ if((i = this.ProcessContents(address, result)) == SEQHOUND_OK){ strRet.append(result.append("\n")); }else if(i == SEQHOUND_ERROR){ this.SHoundLogError(SH_warn, "[SeqHoundGetSeqEntryList]: ".concat(ERROR_STATEMENT)); }else if(i == SEQHOUND_NULL){ this.SHoundLogError(SH_warn, "[SeqHoundGetSeqEntryList]: ".concat(NULL_STATEMENT)); }else{ this.SHoundLogError(SH_warn, "[SeqHoundGetSeqEntryList]: ".concat(ABNORMAL_STATEMENT)); } } if( strRet.length() == 0) return null; return strRet.substring(0, strRet.length() - 1); } /** * retrieves the a XML formated string of a seqentry * @param gi the gi * @return the string in xml format * @throws IOException * @see #SHoundGetSeqEntry(int) */ public String SHoundGetXMLSeqEntry(int gi) throws IOException { if(gi <= 0){ this.SHoundLogError(SH_severe, "[SHoundGetXMLSeqEntry] Invalid gi."); return null; } /* construct the http call */ String args = "gi=".concat(String.valueOf(gi)); String address = this.GetFunctionCall("SeqHoundGetXMLSeqEntryPL", args); /* log the request */ this.SHoundLogError(SH_info, "[SeqHoundGetXMLSeqEntry]: ".concat(args)); int i; /* get response */ StringBuffer result = new StringBuffer(); if(( i = this.ProcessContents(address, result) ) == SEQHOUND_OK){ return result.toString(); }else if(i == SEQHOUND_ERROR){ this.SHoundLogError(SH_warn, "[SeqHoundGetXMLSeqEntry]: ".concat(ERROR_STATEMENT)); }else if(i == SEQHOUND_NULL){ this.SHoundLogError(SH_warn, "[SeqHoundGetXMLSeqEntry]: ".concat(NULL_STATEMENT)); }else{ this.SHoundLogError(SH_warn, "[SeqHoundGetXMLSeqEntry]: ".concat(ABNORMAL_STATEMENT)); } return null; } /** * retrieves the fetches ASN.1 representation of a sequence * called BioseqSet. BioseqSet exists only if there is more * than one sequence in logical group of sequences (e.g. gene and its protein product). * @param gi the gi * @return an ASN formatted string containing the bioseqset * @throws IOException */ public String SHoundGetBioseqSet(int gi) throws IOException { if( gi <= 0 ){ this.SHoundLogError(SH_severe, "[SHoundGetBioseqSet] Invalid gi."); return null; } /* construct the http call */ String args = "gi=".concat(String.valueOf(gi)); String address = this.GetFunctionCall("SeqHoundGetBioseqSetPL", args); /* log the http request */ this.SHoundLogError(SH_info, "[SeqHoundGetBioseqSet]: ".concat(args)); int i; /* prepare a response buffer */ StringBuffer result = new StringBuffer(); if((i = this.ProcessContents(address, result)) == SEQHOUND_OK){ return result.toString(); }else if(i == SEQHOUND_ERROR){ this.SHoundLogError(SH_warn, "[SeqHoundGetBioseqSet]: ".concat(ERROR_STATEMENT)); }else if(i == SEQHOUND_NULL){ this.SHoundLogError(SH_warn, "[SeqHoundGetBioseqSet]: ".concat(NULL_STATEMENT)); }else{ this.SHoundLogError(SH_warn, "[SeqHoundGetBioseqSet]: ".concat(ABNORMAL_STATEMENT)); } return null; } /** * retrieves a string contain the bioseqset for a list of gi's * @param giList an array of gi's * @return an ASN formated string * @throws IOException * @see #SHoundGetBioseqSet(int) */ public String SHoundGetBioseqSetList(int[] giList) throws IOException { if(giList == null){ this.SHoundLogError(SH_severe, "[SHoundGetBioseqSetList] Null array: giList"); return null; } if(giList.length < 1){ this.SHoundLogError(SH_severe, "[SHoundGetBioseqSetList] Empty array: giList"); return null; } /* copy over the array so we can manipulate it */ Vector tmpV = SLRIMisc.CopyArray(giList); StringBuffer strRet = new StringBuffer(); StringBuffer result; String args, address; /* iterate through the array */ while(tmpV.size() > 0){ result = new StringBuffer(); /* send request 700 gi at a time */ int[] itmp = SLRIMisc.MaxSizeIntList(tmpV); /* construct the http call on the list of 700 */ args = "pgi=".concat(SLRIMisc.SaveArrAsString(itmp)); address = this.GetFunctionCall("SeqHoundGetBioseqSetListPL", args); /* log the request */ this.SHoundLogError(SH_info, "[SeqHoundGetBioseqSetList]: ".concat(args)); int i; /* save the response buffer */ if((i = this.ProcessContents(address, result)) == SEQHOUND_OK){ strRet.append(result.append("\n")); }else if(i == SEQHOUND_ERROR){ this.SHoundLogError(SH_warn, "[SeqHoundGetBioseqSetList]: ".concat(ERROR_STATEMENT)); }else if(i == SEQHOUND_NULL){ this.SHoundLogError(SH_warn, "[SeqHoundGetBioseqSetList]: ".concat(NULL_STATEMENT)); }else{ this.SHoundLogError(SH_warn, "[SeqHoundGetBioseqSetList]: ".concat(ABNORMAL_STATEMENT)); } } if(strRet.length() == 0) return null; return strRet.substring(0, strRet.length() - 1); } /** * Defline contains the gi, accession number and other valuable information * together with a short description of the sequence * @param gi the gi * @return the definition line * @throws IOException */ public String SHoundGetDefline(int gi) throws IOException { if(gi <= 0){ this.SHoundLogError(SH_severe, "[SHoundGetDefline] Invalid gi."); return null; } /* construct the http call */ String args = "gi=".concat(String.valueOf(gi)); String address = this.GetFunctionCall("SeqHoundGetDefline", args); /* log the http call */ this.SHoundLogError(SH_info, "[SeqHoundGetDefline]: ".concat(args)); int i; /* get the response */ StringBuffer result = new StringBuffer(); if((i = this.ProcessContents(address, result)) == SEQHOUND_OK){ return result.toString(); }else if(i == SEQHOUND_ERROR){ this.SHoundLogError(SH_warn, "[SeqHoundGetDefline]: ".concat(ERROR_STATEMENT)); }else if(i == SEQHOUND_NULL){ this.SHoundLogError(SH_warn, "[SeqHoundGetDefline]: ".concat(NULL_STATEMENT)); }else{ this.SHoundLogError(SH_warn, "[SeqHoundGetDefline]: ".concat(ABNORMAL_STATEMENT)); } return null; } /** * retrieves a list of defline lines * @param giList the array of gi's * @return an array of deflines * @throws IOException * @see #SHoundGetDefline(int) */ public String[] SHoundGetDeflineList(int[] giList) throws IOException { if(giList == null){ this.SHoundLogError(SH_severe, "[SHoundGetDeflineList] Null array: giList."); return null; } if(giList.length < 1){ this.SHoundLogError(SH_severe, "[SHoundGetDeflineList] Empty array: giList"); return null; } /* copy the input array */ Vector tmpV = SLRIMisc.CopyArray(giList); String[] strRet = new String[0]; String args, address; StringBuffer result; /* iterate through the array */ while(tmpV.size() > 0){ result = new StringBuffer(); /* batch request 700 gi each http call */ int[] itmp = SLRIMisc.MaxSizeIntList(tmpV); args = "pgi=".concat(SLRIMisc.SaveArrAsString(itmp)); address = this.GetFunctionCall("SeqHoundGetDeflineList", args); /* log each http call */ this.SHoundLogError(SH_info, "[SeqHoundGetDeflineList]: ".concat(args)); int i; /* get the response */ if(( i = this.ProcessContents(address, result) ) == SEQHOUND_OK){ strRet = SLRIMisc.MergeLists(strRet, SLRIMisc.StrStr2StrArr(result.toString(), ",")); }else if(i == SEQHOUND_ERROR){ this.SHoundLogError(SH_warn, "[SeqHoundGetDeflineList]: ".concat(ERROR_STATEMENT)); }else if(i == SEQHOUND_NULL){ this.SHoundLogError(SH_warn, "[SeqHoundGetDeflineList]: ".concat(NULL_STATEMENT)); }else{ this.SHoundLogError(SH_warn, "[SeqHoundGetDeflineList]: ".concat(ABNORMAL_STATEMENT)); } } return strRet; } /** * The FASTA format is widely used in bioinformatics community; * it consists of a definition line, new line followed by a * sequence terminated by a second new line. * @param gi the gi * @return a string fasta * @throws IOException */ public String SHoundGetFasta(int gi) throws IOException { if(gi <= 0){ this.SHoundLogError(SH_severe, "[SHoundGetFasta] Invalid gi."); return null; } String args = "gi=".concat(String.valueOf(gi)); String address = this.GetFunctionCall("SeqHoundGetFastaPL", args); this.SHoundLogError(SH_info, "[SeqHoundGetFasta]: ".concat(args)); int i; StringBuffer result = new StringBuffer(); if((i = this.ProcessContents(address, result)) == SEQHOUND_OK){ return result.toString(); }else if(i == SEQHOUND_ERROR){ this.SHoundLogError(SH_warn, "[SeqHoundGetFasta]: ".concat(ERROR_STATEMENT)); }else if(i == SEQHOUND_NULL){ this.SHoundLogError(SH_warn, "[SeqHoundGetFasta]: ".concat(NULL_STATEMENT)); }else{ this.SHoundLogError(SH_warn, "[SeqHoundGetFasta]: ".concat(ABNORMAL_STATEMENT)); } return null; } private String[] _FastaStr2Array(String fastaStr) { if(fastaStr == null){ return null; } String[] s = fastaStr.split("\n"); String[] s2 = new String[s.length/2]; for(int i = 0; i < s2.length;i++){ s2[i] = s[2*i] + "\n" + s[2*i+1]; } return s2; } /** * retrieves a list of fasta * @param giList an array of gi's * @return an array of fasta strings * @throws IOException * @see #SHoundGetFasta(int) */ public String[] SHoundGetFastaList(int[] giList) throws IOException { if(giList == null){ this.SHoundLogError(SH_severe, "[SHoundGetFastaList] Null array: giList"); return null; } if(giList.length < 1){ this.SHoundLogError(SH_severe, "[SHoundGetFastaList] Empty array: giList"); return null; } /* copy the array */ Vector tmpV = SLRIMisc.CopyArray(giList); StringBuffer strRet = new StringBuffer(); StringBuffer result; String args, address; /* iterate through the array */ while(tmpV.size() > 0){ result = new StringBuffer(); /* each request contains max of 700 gi */ int[] itmp = SLRIMisc.MaxSizeIntList(tmpV); /* construct the http call */ args = "pgi=".concat(SLRIMisc.SaveArrAsString(itmp)); address = this.GetFunctionCall("SeqHoundGetFastaListPL", args); /* log the request */ this.SHoundLogError(SH_info, "[SeqHoundGetFasta]: ".concat(args)); int i; /* read from the server */ if((i = this.ProcessContents(address, result)) == SEQHOUND_OK){ strRet.append(result.append("\n")); }else if(i == SEQHOUND_ERROR){ this.SHoundLogError(SH_warn, "[SeqHoundGetFastaList]: ".concat(ERROR_STATEMENT)); }else if(i == SEQHOUND_NULL){ this.SHoundLogError(SH_warn, "[SeqHoundGetFastaList]: ".concat(NULL_STATEMENT)); }else{ this.SHoundLogError(SH_warn, "[SeqHoundGetFastaList]: ".concat(ABNORMAL_STATEMENT)); } } if(strRet.length() == 0) return null; return this._FastaStr2Array(strRet.substring(0, strRet.length() - 1)); } /** * writes a series of fasta data into a writer object pointed to by out. * Use this function to print a list of fasta data to a file. * @param giList array of gi's * @param out the writer object * @return true if successfully wrote to out, else false * @throws IOException * @see #SHoundGetFastaList(int[]) */ public boolean SHoundGetFastaList(int[] giList, Writer out) throws IOException { if(giList == null) { this.SHoundLogError(SH_severe, "[SHoundGetFastaList] Null array: giList"); return false; } if(out == null){ this.SHoundLogError(SH_severe, "[SHoundGetFastaList] Null OutputStream"); return false; } String address, args; /* copy the array */ Vector tmpV = SLRIMisc.CopyArray(giList); /* iterate through the array */ while(tmpV.size() > 0) { int[] tmp = SLRIMisc.MaxSizeIntList(tmpV); /* construct the http call */ args = "pgi=".concat(SLRIMisc.SaveArrAsString(tmp)); address = this.GetFunctionCall("SeqHoundGetFastaListPL", args); /* log the http call */ this.SHoundLogError(SH_info, "[SeqHoundGetFastaList]: ".concat(args)); int i; if((i = this.ProcessContents(address, out)) == SEQHOUND_OK) { out.flush(); //return true; }else if(i == SEQHOUND_ERROR){ this.SHoundLogError(SH_warn, "[SeqHoundGetFastaList]: ".concat(ERROR_STATEMENT)); }else if(i == SEQHOUND_NULL){ this.SHoundLogError(SH_warn, "[SeqHoundGetFastaList]: ".concat(NULL_STATEMENT)); }else { this.SHoundLogError(SH_warn, "[SeqHoundGetFastaList]: ".concat(ABNORMAL_STATEMENT)); } } return false; } /** * GenBank flat file contains comprehensive full annotation of a sequence. * * @param gi the gi to retrieve * @return a string of the genbank format * @throws IOException */ public String SHoundGetGenBankff(int gi) throws IOException { if(gi <= 0){ this.SHoundLogError(SH_severe, "[SHoundGetGenBankff] Invalid gi."); return null; } /* construct the http call */ String args = "gi=".concat(String.valueOf(gi)); String address = this.GetFunctionCall("SeqHoundGetGenBankff", args); /* log the request */ this.SHoundLogError(SH_info, "[SeqHoundGetGenBankff]: ".concat(args)); int i; /* get the response */ StringBuffer result = new StringBuffer(); if((i = this.ProcessContents(address, result)) == SEQHOUND_OK){ return result.toString(); }else if(i == SEQHOUND_ERROR){ this.SHoundLogError(SH_warn, "[SeqHoundGetGenBankff]: ".concat(ERROR_STATEMENT)); }else if(i == SEQHOUND_NULL){ this.SHoundLogError(SH_warn, "[SeqHoundGetGenBankff]: ".concat(NULL_STATEMENT)); }else{ this.SHoundLogError(SH_warn, "[SeqHoundGetGenBankff]: ".concat(ABNORMAL_STATEMENT)); } return null; } /** * retrieves an array of strings formated in genbank ff. * @param giList an array of gi's * @return an array of genbank ff * @throws IOException * @see #SHoundGetGenBankff */ public String[] SHoundGetGenBankffList(int[] giList) throws IOException { if(giList == null){ this.SHoundLogError(SH_severe, "[SHoundGetGenBankffList] Null array: giList"); return null; } if(giList.length < 1){ this.SHoundLogError(SH_severe, "[SHoundGetGenBankffList] Empty array: giList"); return null; } /* copy the array for local use */ Vector tmpV = SLRIMisc.CopyArray(giList); String[] strRet = new String[0]; String args, address; StringBuffer result; /* iterator through the array */ while(tmpV.size() > 0){ result = new StringBuffer(); /* send requests of 700 gi's at a time */ int[] itmp = SLRIMisc.MaxSizeIntList(tmpV); /* construct an http call */ args = "pgi=".concat(SLRIMisc.SaveArrAsString(itmp)); address = this.GetFunctionCall("SeqHoundGetGenBankffList", args); /* log request */ this.SHoundLogError(SH_info, "[SeqHoundGetGenBankffList]: ".concat(args)); int i; if((i = this.ProcessContents(address, result)) == SEQHOUND_OK){ strRet = SLRIMisc.MergeLists(strRet, SLRIMisc.StrStr2StrArr(result.toString(), "//")); }else if(i == SEQHOUND_ERROR){ this.SHoundLogError(SH_warn, "[SeqHoundGetGenBankffList]: ".concat(ERROR_STATEMENT)); }else if(i == SEQHOUND_NULL){ this.SHoundLogError(SH_warn, "[SeqHoundGetGenBankffList]: ".concat(NULL_STATEMENT)); }else{ this.SHoundLogError(SH_warn, "[SeqHoundGetGenBankffList]: ".concat(ABNORMAL_STATEMENT)); } } return strRet; } /** * Fetches ASN.1 representation of 3-D structure called Biostruc. * Biostrucs represent data model in Molecular Modeling database. * @param mmdbid the mmdb id * @return a string ASN.1 formated 3-D biostruc * @throws IOException */ public String SHoundGet3D(int mmdbid) throws IOException { if(mmdbid <= 0){ this.SHoundLogError(SH_severe, "[SHoundGet3D] Invalid mmdbid"); return null; } /* construct the http call */ String args = "mmdbid=".concat(String.valueOf(mmdbid)); String address = this.GetFunctionCall("SeqHoundGet3DPL", args); /* log the error */ this.SHoundLogError(SH_info, "[SeqHoundGet3D]: ".concat(args)); int i; /* retrieve the buffer */ StringBuffer result = new StringBuffer(); if((i = this.ProcessContents(address, result)) == SEQHOUND_OK){ return result.toString(); }else if(i == SEQHOUND_ERROR){ this.SHoundLogError(SH_warn, "[SeqHoundGet3D]: ".concat(ERROR_STATEMENT)); }else if(i == SEQHOUND_NULL){ this.SHoundLogError(SH_warn, "[SeqHoundGet3D]: ".concat(NULL_STATEMENT)); }else{ this.SHoundLogError(SH_warn, "[SeqHoundGet3D]: ".concat(ABNORMAL_STATEMENT)); } return null; } /** * Fetches ASN.1 representation of 3-D structure called Biostruc. * Biostrucs represent data model in Molecular Modeling database. * @param pdbid the PDB identifier * @return a string ASN.1 representation * @throws IOException */ public String SHoundGet3DfromPdbId(String pdbid) throws IOException { if(pdbid == null){ this.SHoundLogError(SH_severe, "[SHoundGet3DfromPdbId] Null string error: pdbid"); return null; } /* construct the http call */ String args = "pdbid=".concat(pdbid); String address = this.GetFunctionCall("SeqHoundGet3DfromPdbIdPL", args); /* log the request */ this.SHoundLogError(SH_info, "[SeqHoundGet3DfromPdbId]: ".concat(args)); int i; StringBuffer result = new StringBuffer(); if((i = this.ProcessContents(address, result)) == SEQHOUND_OK){ return result.toString(); }else if(i == SEQHOUND_ERROR){ this.SHoundLogError(SH_warn, "[SeqHoundGet3DfromPdbId]: ".concat(ERROR_STATEMENT)); }else if(i == SEQHOUND_NULL){ this.SHoundLogError(SH_warn, "[SeqHoundGet3DfromPdbId]: ".concat(NULL_STATEMENT)); }else{ this.SHoundLogError(SH_warn, "[SeqHoundGet3DfromPdbId]: ".concat(ABNORMAL_STATEMENT)); } return null; } /** * Retrieves an XML representation of a 3-D structure * @param mmdbid the MMDB identifier * @return a string XML formated biostruc * @throws IOException */ public String SHoundGetXML3D(int mmdbid) throws IOException { if(mmdbid <= 0){ this.SHoundLogError(SH_severe, "[SHoundGetXML3D] Invalid mmdbid."); return null; } /* construct the http call */ String args = "mmdbid=".concat(String.valueOf(mmdbid)); String address = this.GetFunctionCall("SeqHoundGetXML3DPL", args); /* log the request */ this.SHoundLogError(SH_info, "[SeqHoundGetXML3D]: ".concat(args)); int i; /* get the response */ StringBuffer result = new StringBuffer(); if((i = this.ProcessContents(address, result)) == SEQHOUND_OK){ return result.toString(); }else if(i == SEQHOUND_ERROR){ this.SHoundLogError(SH_warn, "[SeqHoundGetXMLFrom3D]: ".concat(ERROR_STATEMENT)); }else if(i == SEQHOUND_NULL){ this.SHoundLogError(SH_warn, "[SeqHoundGetXMLFrom3D]: ".concat(NULL_STATEMENT)); }else{ this.SHoundLogError(SH_warn, "[SeqHoundGetXMLFrom3D]: ".concat(ABNORMAL_STATEMENT)); } return null; } /** * Retrieves an PDB representation of a 3-D structure * @param mmdbid the MMDB identifier * @return a string PDB formated biostruc * @throws IOException */ public String SHoundGetPDB3D(int mmdbid) throws IOException { if(mmdbid <= 0){ this.SHoundLogError(SH_severe, "[SHoundGetPDB3D] Invalid mmdbid"); return null; } /* the http call */ String args = "mmdbid=".concat(String.valueOf(mmdbid)); String address = this.GetFunctionCall("SeqHoundGetPDB3DPL", args); /* log the request */ this.SHoundLogError(SH_info, "[SeqHoundGetPDB3D]: ".concat(args)); int i; /* the response buffer */ StringBuffer result = new StringBuffer(); if((i = this.ProcessContents(address, result)) == SEQHOUND_OK){ return result.toString(); }else if(i == SEQHOUND_ERROR){ this.SHoundLogError(SH_warn, "[SeqHoundGetPDB3D]: ".concat(ERROR_STATEMENT)); }else if(i == SEQHOUND_NULL){ this.SHoundLogError(SH_warn, "[SeqHoundGetPDB3D]: ".concat(NULL_STATEMENT)); }else{ this.SHoundLogError(SH_warn, "[SeqHoundGetPDB3D]: ".concat(ABNORMAL_STATEMENT)); } return null; } /** * retrieves the gi given a mmdbid * @param mmdbid the MMDB identifier * @param ProteinOnly get the protein gi * @return an array of the gi's in the 3 D structure * @throws IOException */ public int[] SHoundGiFrom3D(int mmdbid, boolean ProteinOnly) throws IOException { if(mmdbid <= 0){ this.SHoundLogError(SH_severe, "[SHoundGiFrom3D] Invalid mmdbid."); return null; } /* construct the http call */ String args = "mmdbid=".concat(String.valueOf(mmdbid)); args += "&ProteinOnly=".concat(String.valueOf(ProteinOnly).toUpperCase()); String address = this.GetFunctionCall("SeqHoundGiFrom3D", args); /* log the request */ this.SHoundLogError(SH_info, "[SeqHoundGiFrom3D]: ".concat(args)); int i; StringBuffer result = new StringBuffer(); if((i = this.ProcessContents(address, result)) == SEQHOUND_OK){ return SLRIMisc.StrInt2IntArr(result.toString(), ","); }else if(i == SEQHOUND_ERROR){ this.SHoundLogError(SH_warn, "[SeqHoundGiFrom3D]: ".concat(ERROR_STATEMENT)); }else if(i == SEQHOUND_NULL){ this.SHoundLogError(SH_warn, "[SeqHoundGiFrom3D]: ".concat(NULL_STATEMENT)); }else{ this.SHoundLogError(SH_warn, "[SeqHoundGiFrom3D]: ".concat(ABNORMAL_STATEMENT)); } return null; } /** * retrieve an array of gi's from the MMDB identifiers * @param mmdbidList the list of MMDB identifiers * @param ProteinOnly protein or non-protein gi's to retrieve * @return array of gi's * @throws IOException * @see #SHoundGiFrom3D(int, boolean) */ public int[] SHoundGiFrom3DList(int[] mmdbidList, boolean ProteinOnly) throws IOException { if(mmdbidList == null){ this.SHoundLogError(SH_severe, "[SHoundGiFrom3DList] Null array: mmdbidList"); return null; } if(mmdbidList.length < 1){ this.SHoundLogError(SH_severe, "[SHoundGiFrom3DList] Empty array: mmdbidList"); return null; } /* copy the iput array */ Vector tmpV = SLRIMisc.CopyArray(mmdbidList); int[] iRet = new int[0]; String args, address; StringBuffer result; /* iterate until entire array dealt with */ while(tmpV.size() > 0){ result = new StringBuffer(); /* send 700 gi a request */ int[] itmp = SLRIMisc.MaxSizeIntList(tmpV); /* make http call */ args = "pmmdbid=".concat(SLRIMisc.SaveArrAsString(itmp)); args += "&ProteinOnly=".concat(String.valueOf(ProteinOnly).toUpperCase()); address = this.GetFunctionCall("SeqHoundGiFrom3DList", args); /* log http request */ this.SHoundLogError(SH_info, "[SeqHoundGiFrom3DList]: ".concat(args)); int i; if((i = this.ProcessContents(address, result)) == SEQHOUND_OK){ iRet = SLRIMisc.MergeLists(iRet, SLRIMisc.StrInt2IntArr(result.toString(), ",")); }else if(i == SEQHOUND_ERROR){ this.SHoundLogError(SH_warn, "[SeqHoundGiFrom3DList]: ".concat(ERROR_STATEMENT)); }else if(i == SEQHOUND_NULL){ this.SHoundLogError(SH_warn, "[SeqHoundGiFrom3DList]: ".concat(NULL_STATEMENT)); }else{ this.SHoundLogError(SH_warn, "[SeqHoundGiFrom3DList]: ".concat(ABNORMAL_STATEMENT)); } } return iRet; } /** * retrieve an array of gi's from the PDB identifiers * @param pdbcode the PDB identifier * @param chain the chain on the PDB structure * @return gi in the chain, -1 if not found or zero * @throws IOException * @see #SHoundGiFromPDBchain(String, String) */ public int SHoundGiFromPDBchain(String pdbcode, String chain) throws IOException { if(pdbcode == null){ this.SHoundLogError(SH_severe, "[SHoundGiFromPDBchain] Null string error: pdbcode"); return SEQHOUND_ERROR; } if(chain == null){ this.SHoundLogError(SH_severe, "[SHoundGiFromPDBchain] Null string error: chain"); return SEQHOUND_ERROR; } /* make the http call */ String args = "pdbcode=" + pdbcode + "&chain=" + chain; String address = this.GetFunctionCall("SeqHoundGiFromPDBchain", args); /* log the http request */ this.SHoundLogError(SH_info, "[SeqHoundGiFromPDBchain]: ".concat(args)); int i; /* get the response */ StringBuffer result = new StringBuffer(); if((i = this.ProcessContents(address, result)) == SEQHOUND_OK){ return Integer.parseInt(result.toString()); }else if(i == SEQHOUND_ERROR){ this.SHoundLogError(SH_warn, "[SeqHoundGiFromPDBchain]: ".concat(ERROR_STATEMENT)); }else if(i == SEQHOUND_NULL){ this.SHoundLogError(SH_warn, "[SeqHoundGiFromPDBchain]: ".concat(NULL_STATEMENT)); }else{ this.SHoundLogError(SH_warn, "[SeqHoundGiFromPDBchain]: ".concat(ABNORMAL_STATEMENT)); } return SEQHOUND_ERROR; } /** * Get the MMDB identifier for a given gi * @param gi the gi * @return an MMDB identifier or -1 or zero * @throws IOException */ public int SHound3DFromGi(int gi) throws IOException { if(gi <= 0){ this.SHoundLogError(SH_severe, "[SHound3DFromGi] Invalid gi."); return SEQHOUND_ERROR; } /* construct the http call */ String args = "gi=".concat(String.valueOf(gi)); String address = this.GetFunctionCall("SeqHound3DFromGi", args); /* log */ this.SHoundLogError(SH_info, "[SeqHound3DFromGi]: ".concat(args)); int i; /* get response */ StringBuffer result = new StringBuffer(); if((i = this.ProcessContents(address, result)) == SEQHOUND_OK){ return Integer.parseInt(result.toString()); }else if(i == SEQHOUND_ERROR){ this.SHoundLogError(SH_warn, "[SeqHound3DFromGi]: ".concat(ERROR_STATEMENT)); }else if(i == SEQHOUND_NULL){ this.SHoundLogError(SH_warn, "[SeqHound3DFromGi]: ".concat(NULL_STATEMENT)); }else{ this.SHoundLogError(SH_warn, "[SeqHound3DFromGi]: ".concat(ABNORMAL_STATEMENT)); } return SEQHOUND_ERROR; } /** * Get an array of MMDB identifiers for a given gi array * @param giList the array of gi's * @return an array of MMDB identifier or null * @throws IOException */ public int[] SHound3DFromGiList(int[] giList) throws IOException { if(giList == null){ this.SHoundLogError(SH_severe, "[SHound3DFromGiList] Null array: giList"); return null; } if(giList.length < 1){ this.SHoundLogError(SH_severe, "[SHound3DFromGiList] Empty array: giList"); return null; } /* copy the array */ Vector tmpV = SLRIMisc.CopyArray(giList); int[] iRet = new int[0]; String args, address; StringBuffer result; while(tmpV.size() > 0){ result = new StringBuffer(); /* deal with 700 per request */ int[] itmp = SLRIMisc.MaxSizeIntList(tmpV); /* construct the http call */ args = "pgi=".concat(SLRIMisc.SaveArrAsString(itmp)); address = this.GetFunctionCall("SeqHound3DFromGiList", args); /* log the errors */ this.SHoundLogError(SH_info, "[SeqHound3DFromGiList]: ".concat(args)); int i; if((i = this.ProcessContents(address, result)) == SEQHOUND_OK){ iRet = SLRIMisc.MergeLists(iRet, SLRIMisc.StrInt2IntArr(result.toString(), ",")); }else if(i == SEQHOUND_ERROR){ this.SHoundLogError(SH_warn, "[SeqHound3DFromGiList]: ".concat(ERROR_STATEMENT)); }else if(i == SEQHOUND_NULL){ this.SHoundLogError(SH_warn, "[SeqHound3DFromGiList]: ".concat(NULL_STATEMENT)); }else{ this.SHoundLogError(SH_warn, "[SeqHound3DFromGiList]: ".concat(ABNORMAL_STATEMENT)); } } return iRet; } /** * Get the dna gi fro a given gi * @param gi the gi * @return the corresponding dna gi * @throws IOException */ public int SHoundDNAFromProtein(int gi) throws IOException { if(gi <= 0){ this.SHoundLogError(SH_severe, "[SHoundDNAFromProtein] Invalid gi."); return SEQHOUND_ERROR; } /* construct the http call */ String args = "gi=".concat(String.valueOf(gi)); String address = this.GetFunctionCall("SeqHoundDNAFromProtein", args); /* log the request */ this.SHoundLogError(SH_info, "[SeqHoundDNAFromProtein]: ".concat(args)); int i; /* get the response */ StringBuffer result = new StringBuffer(); if((i = this.ProcessContents(address, result)) == SEQHOUND_OK){ return Integer.parseInt(result.toString()); }else if(i == SEQHOUND_ERROR){ this.SHoundLogError(SH_warn, "[SeqHoundDNAFromProtein]: ".concat(ERROR_STATEMENT)); }else if(i == SEQHOUND_NULL){ this.SHoundLogError(SH_warn, "[SeqHoundDNAFromProtein]: ".concat(NULL_STATEMENT)); }else{ this.SHoundLogError(SH_warn, "[SeqHoundDNAFromProtein]: ".concat(ABNORMAL_STATEMENT)); } return SEQHOUND_ERROR; } /** * Get an array of dna gi for a given array of gi * @param giList the array of gi * @return an array of dna gi or null * @throws IOException * @see #SHoundDNAFromProtein(int) */ public int[] SHoundDNAFromProteinList(int[] giList) throws IOException { if(giList == null){ this.SHoundLogError(SH_severe, "[SHoundDNAFromProteinList] Null array: giList"); return null; } if(giList.length < 0){ this.SHoundLogError(SH_severe, "[SHoundDNAFromProteinList] Empty array: giList"); return null; } /* copy the input */ Vector tmpV = SLRIMisc.CopyArray(giList); int[] iRet = new int[0]; String args, address; StringBuffer result; /* iterate through the list */ while(tmpV.size() > 0){ result = new StringBuffer(); int[] itmp = SLRIMisc.MaxSizeIntList(tmpV); /* construct the http call */ args = "pgi=".concat(SLRIMisc.SaveArrAsString(itmp)); address = this.GetFunctionCall("SeqHoundDNAFromProteinList", args); /* log the request */ this.SHoundLogError(SH_info, "[SeqHoundDNAFromProteinList]: ".concat(args)); int i; if((i = this.ProcessContents(address, result)) == SEQHOUND_OK){ iRet = SLRIMisc.MergeLists(iRet, SLRIMisc.StrInt2IntArr(result.toString(), ",")); }else if(i == SEQHOUND_ERROR){ this.SHoundLogError(SH_warn, "[SeqHoundDNAFromProteinList]: ".concat(ERROR_STATEMENT)); }else if(i == SEQHOUND_NULL){ this.SHoundLogError(SH_warn, "[SeqHoundDNAFromProteinList]: ".concat(NULL_STATEMENT)); }else{ this.SHoundLogError(SH_warn, "[SeqHoundDNAFromProteinList]: ".concat(ABNORMAL_STATEMENT)); } } return iRet; } /** * Get the protein gi for a given gi * @param gi the gi * @return a protein gi * @throws IOException */ public int[] SHoundProteinFromDNA(int gi) throws IOException { if(gi <= 0){ this.SHoundLogError(SH_severe, "[SHoundProteinFromDNA] Invalid gi."); return null; } /* construct the http call */ String args = "gi=".concat(String.valueOf(gi)); String address = this.GetFunctionCall("SeqHoundProteinFromDNA", args); this.SHoundLogError(SH_info, "[SeqHoundProteinFromDNA]: ".concat(args)); int i; /* get the buffer */ StringBuffer result = new StringBuffer(); if((i = this.ProcessContents(address, result)) == SEQHOUND_OK){ return SLRIMisc.StrInt2IntArr(result.toString(), ","); }else if(i == SEQHOUND_ERROR){ this.SHoundLogError(SH_warn, "[SeqHoundProteinFromDNA]: ".concat(ERROR_STATEMENT)); }else if(i == SEQHOUND_NULL){ this.SHoundLogError(SH_warn, "[SeqHoundProteinFromDNA]: ".concat(NULL_STATEMENT)); }else{ this.SHoundLogError(SH_warn, "[SeqHoundProteinFromDNA]: ".concat(ABNORMAL_STATEMENT)); } return null; } /** * Get an array of protein gi's given an array of gi's * @param giList the array of gi * @return an array of gi's * @throws IOException * @see #SHoundProteinFromDNA(int) */ public int[] SHoundProteinFromDNAList(int[] giList) throws IOException { if(giList == null){ this.SHoundLogError(SH_severe, "[SHoundProteinFromDNAList] Null array: giList"); return null; } if(giList.length < 1){ this.SHoundLogError(SH_severe, "[SHoundProteinFromDNAList] Empty array: giList"); return null; } /* copy the array */ Vector tmpV = SLRIMisc.CopyArray(giList); int[] iRet = new int[0]; String args, address; StringBuffer result; /* iterate the array */ while(tmpV.size() > 0){ result = new StringBuffer(); int[] itmp = SLRIMisc.MaxSizeIntList(tmpV); /* construct the http call */ args = "pgi=".concat(SLRIMisc.SaveArrAsString(itmp)); address = this.GetFunctionCall("SeqHoundProteinFromDNAList", args); /* log the request */ this.SHoundLogError(SH_info, "[SeqHoundProteinFromDNAList]: ".concat(args)); int i; if((i = this.ProcessContents(address, result)) == SEQHOUND_OK){ iRet = SLRIMisc.MergeLists(iRet, SLRIMisc.StrInt2IntArr(result.toString(), ",")); }else if(i == SEQHOUND_ERROR){ this.SHoundLogError(SH_warn, "[SeqHoundProteinFromDNAList]: ".concat(ERROR_STATEMENT)); }else if(i == SEQHOUND_NULL){ this.SHoundLogError(SH_warn, "[SeqHoundProteinFromDNAList]: ".concat(NULL_STATEMENT)); }else{ this.SHoundLogError(SH_warn, "[SeqHoundProteinFromDNAList]: ".concat(ABNORMAL_STATEMENT)); } } return iRet; } /** * Get the MUID for a given gi * @param gi the gi * @return an array of MUID or -1 or zero * @throws IOException * @deprecated replaced by {@link #SHoundGetReferenceIDFromGi(int, int)} */ public int[] SHoundMuidFromGi(int gi) throws IOException { if(gi <= 0){ this.SHoundLogError(SH_severe, "[SHoundMuidFromGi] Invalid gi."); return null; } /* construct the http call */ String args = "gi=".concat(String.valueOf(gi)); String address = this.GetFunctionCall("SeqHoundMuidFromGi", args); /* log the request */ this.SHoundLogError(SH_info, "[SeqHoundMuidFromGi]: ".concat(args)); int i; StringBuffer result = new StringBuffer(); if((i = this.ProcessContents(address, result)) == SEQHOUND_OK){ return SLRIMisc.StrInt2IntArr(result.toString(), ","); }else if(i == SEQHOUND_ERROR){ this.SHoundLogError(SH_warn, "[SeqHoundMuidFromGi]: ".concat(ERROR_STATEMENT)); }else if(i == SEQHOUND_NULL){ this.SHoundLogError(SH_warn, "[SeqHoundMuidFromGi]: ".concat(NULL_STATEMENT)); }else{ this.SHoundLogError(SH_warn, "[SeqHoundMuidFromGi]: ".concat(ABNORMAL_STATEMENT)); } return null; } /** * Get the MUIDs for a given array of gi's * @param giList the gi array * @return an array of MUID or null * @throws IOException * @deprecated replaced by {@link #SHoundGetReferenceIDFromGiList(int[], int)} */ public int[] SHoundMuidFromGiList(int[] giList) throws IOException { if(giList == null){ this.SHoundLogError(SH_severe, "[SHoundMuidFromGiList] Empty array: giList"); return null; } if(giList.length < 1){ this.SHoundLogError(SH_severe, "[SHoundMuidFromGiList] Empty array: giList"); return null; } /* copy array */ Vector tmpV = SLRIMisc.CopyArray(giList); int[] iRet = new int[0]; String args, address; StringBuffer result; /* iterate through the array */ while(tmpV.size() > 0){ result = new StringBuffer(); int[] itmp = SLRIMisc.MaxSizeIntList(tmpV); /* construct an http call */ args = "pgi=".concat(SLRIMisc.SaveArrAsString(itmp)); address = this.GetFunctionCall("SeqHoundMuidFromGiList", args); this.SHoundLogError(SH_info, "[SeqHoundMuidFromGiList]: ".concat(args)); int i; if((i = this.ProcessContents(address, result)) == SEQHOUND_OK){ iRet = SLRIMisc.MergeLists(iRet, SLRIMisc.StrInt2IntArr(result.toString(), ",")); }else if(i == SEQHOUND_ERROR){ this.SHoundLogError(SH_warn, "[SeqHoundMuidFromGiList]: ".concat(ERROR_STATEMENT)); }else if(i == SEQHOUND_NULL){ this.SHoundLogError(SH_warn, "[SeqHoundMuidFromGiList]: ".concat(NULL_STATEMENT)); }else{ this.SHoundLogError(SH_warn, "[SeqHoundMuidFromGiList]: ".concat(ABNORMAL_STATEMENT)); } } return iRet; } /** * Get the MUID for a given MMDB identifier * @param mmdbid MMDB identifier * @return an MUID or -1 or zero * @throws IOException */ public int[] SHoundMuidFrom3D(int mmdbid) throws IOException { if(mmdbid <= 0){ this.SHoundLogError(SH_severe, "[SHoundMuidFrom3D] Invalid mmdbid"); return null; } /* construct the http request */ String args = "mmdbid=".concat(String.valueOf(mmdbid)); String address = this.GetFunctionCall("SeqHoundMuidFrom3D", args); /* log the request */ this.SHoundLogError(SH_info, "[SeqHoundMuidFrom3D]: ".concat(args)); int i; StringBuffer result = new StringBuffer(); if((i = this.ProcessContents(address, result)) == SEQHOUND_OK){ return SLRIMisc.StrInt2IntArr(result.toString(), ","); }else if(i == SEQHOUND_ERROR){ this.SHoundLogError(SH_warn, "[SeqHoundMuidFrom3D]: ".concat(ERROR_STATEMENT)); }else if(i == SEQHOUND_NULL){ this.SHoundLogError(SH_warn, "[SeqHoundMuidFrom3D]: ".concat(NULL_STATEMENT)); }else{ this.SHoundLogError(SH_warn, "[SeqHoundMuidFrom3D]: ".concat(ABNORMAL_STATEMENT)); } return null; } /** * Get the MUID list for a given gi array * @param giList the gi array * @return an MUID array or null * @throws IOException */ public int[] SHoundMuidFrom3DList(int[] giList) throws IOException { if(giList == null){ this.SHoundLogError(SH_severe, "[SHoundMuidFrom3DList] Empty array: giList"); return null; } if(giList.length < 1){ this.SHoundLogError(SH_severe, "[SHoundMuidFrom3DList] Empty array: giList"); return null; } /* copy the array */ Vector tmpV = SLRIMisc.CopyArray(giList); int[] iRet = new int[0]; String args, address; StringBuffer result; /* iterate through the array */ while(tmpV.size() > 0){ result = new StringBuffer(); int[] itmp = SLRIMisc.MaxSizeIntList(tmpV); /* construct the http call */ args = "pmmdbid=".concat(SLRIMisc.SaveArrAsString(itmp)); address = this.GetFunctionCall("SeqHoundMuidFrom3DList", args); /* log the request */ this.SHoundLogError(SH_info, "[SeqHoundMuidFrom3DList]: ".concat(args)); int i; if((i = this.ProcessContents(address, result)) == SEQHOUND_OK){ iRet = SLRIMisc.MergeLists(iRet, SLRIMisc.StrInt2IntArr(result.toString(), ",")); }else if(i == SEQHOUND_ERROR){ this.SHoundLogError(SH_warn, "[SeqHoundMuidFrom3DList]: ".concat(ERROR_STATEMENT)); }else if(i == SEQHOUND_NULL){ this.SHoundLogError(SH_warn, "[SeqHoundMuidFrom3DList]: ".concat(NULL_STATEMENT)); }else{ this.SHoundLogError(SH_warn, "[SeqHoundMuidFrom3DList]: ".concat(ABNORMAL_STATEMENT)); } } return iRet; } /** * Get the taxid for a given gi * @param gi the gi * @return an taxonomy identifier or -1 or zero * @throws IOException */ public int SHoundTaxIDFromGi(int gi) throws IOException { if(gi <= 0){ this.SHoundLogError(SH_severe, "[SHoundTaxIDFromGi] Invalid gi."); return SEQHOUND_ERROR; } /* construct the http call */ String args = "gi=".concat(String.valueOf(gi)); String address = this.GetFunctionCall("SeqHoundTaxIDFromGi", args); /* log the request */ this.SHoundLogError(SH_info, "[SeqHoundTaxIDFromGi]: ".concat(args)); int i; StringBuffer result = new StringBuffer(); if((i = this.ProcessContents(address, result)) == SEQHOUND_OK){ return Integer.parseInt(result.toString()); }else if(i == SEQHOUND_ERROR){ this.SHoundLogError(SH_warn, "[SeqHoundTaxIDFromGi]: ".concat(ERROR_STATEMENT)); }else if(i == SEQHOUND_NULL){ this.SHoundLogError(SH_warn, "[SeqHoundTaxIDFromGi]: ".concat(NULL_STATEMENT)); }else{ this.SHoundLogError(SH_warn, "[SeqHoundTaxIDFromGi]: ".concat(ABNORMAL_STATEMENT)); } return SEQHOUND_ERROR; } /** * Get an array of taxonomy identifiers from an array of gi * @param giList an array of gi's * @return an array of taxonomy id's or null * @throws IOException * @see #SHoundTaxIDFromGi(int) */ public int[] SHoundTaxIDFromGiList(int[] giList) throws IOException { if(giList == null){ this.SHoundLogError(SH_severe, "[SHoundTaxIDFromGiList] Empty array: gilist."); return null; } if(giList.length < 0){ this.SHoundLogError(SH_severe, "[SHoundTaxIDFromGiList] Empty array: gilist."); return null; } /* copy the input array */ Vector tmpV = SLRIMisc.CopyArray(giList); int[] iRet = new int[0]; String args, address; StringBuffer result; /* iterate through the array */ while(tmpV.size() > 0){ result = new StringBuffer(); int[] itmp = SLRIMisc.MaxSizeIntList(tmpV); args = "pgi=".concat(SLRIMisc.SaveArrAsString(itmp)); address = this.GetFunctionCall("SeqHoundTaxIDFromGiList", args); this.SHoundLogError(SH_info, "[SeqHoundTaxIDFromGiList]: ".concat(args)); int i; if((i = this.ProcessContents(address, result)) == SEQHOUND_OK){ iRet = SLRIMisc.MergeLists(iRet, SLRIMisc.StrInt2IntArr(result.toString(), ",")); }else if(i == SEQHOUND_ERROR){ this.SHoundLogError(SH_warn, "[SeqHoundTaxIDFromGiList]: ".concat(ERROR_STATEMENT)); }else if(i == SEQHOUND_NULL){ this.SHoundLogError(SH_warn, "[SeqHoundTaxIDFromGiList]: ".concat(NULL_STATEMENT)); }else{ this.SHoundLogError(SH_warn, "[SeqHoundTaxIDFromGiList]: ".concat(ABNORMAL_STATEMENT)); } } return iRet; } /** * Get a taxid for a given gi * @param mmdbid the gi * @return an taxid * @throws IOException */ public int SHoundTaxIDFrom3D(int mmdbid) throws IOException { if(mmdbid <= 0){ this.SHoundLogError(SH_severe, "[SHoundTaxIDFrom3D] Invalid mmdbid."); return SEQHOUND_ERROR; } /* construct the http call */ String args = "mmdbid=".concat(String.valueOf(mmdbid)); String address = this.GetFunctionCall("SeqHoundTaxIDFrom3D", args); this.SHoundLogError(SH_info, "[SeqHoundTaxIDFrom3D]: ".concat(args)); int i; StringBuffer result = new StringBuffer(); if((i = this.ProcessContents(address, result)) == SEQHOUND_OK){ return Integer.parseInt(result.toString()); }else if(i == SEQHOUND_ERROR){ this.SHoundLogError(SH_warn, "[SeqHoundTaxIDFrom3D]: ".concat(ERROR_STATEMENT)); }else if(i == SEQHOUND_NULL){ this.SHoundLogError(SH_warn, "[SeqHoundTaxIDFrom3D]: ".concat(NULL_STATEMENT)); }else{ this.SHoundLogError(SH_warn, "[SeqHoundTaxIDFrom3D]: ".concat(ABNORMAL_STATEMENT)); } return SEQHOUND_ERROR; } /** * Get an array of taxid from an array of MMDB identifier * @param mmdbidList an array of MMDB identifier * @return an array of taxonomy identifier * @throws IOException * @see #SHoundTaxIDFrom3D(int) */ public int[] SHoundTaxIDFrom3DList(int[] mmdbidList) throws IOException { if(mmdbidList == null){ this.SHoundLogError(SH_severe, "[SHoundTaxIDFrom3DList] Empty array: mmdbidList"); return null; } if(mmdbidList.length < 1){ this.SHoundLogError(SH_severe, "[SHoundTaxIDFrom3DList] Empty array: mmdbidList"); return null; } Vector tmpV = SLRIMisc.CopyArray(mmdbidList); int[] iRet = new int[0]; String args, address; StringBuffer result; while(tmpV.size() > 0){ result = new StringBuffer(); int[] itmp = SLRIMisc.MaxSizeIntList(tmpV); /* construct the http call */ args = "pmmdbid=".concat(SLRIMisc.SaveArrAsString(itmp)); address = this.GetFunctionCall("SeqHoundTaxIDFrom3DList", args); this.SHoundLogError(SH_info, "[SeqHoundTaxIDFrom3DList] :".concat(args)); int i; if((i = this.ProcessContents(address, result)) == SEQHOUND_OK){ iRet = SLRIMisc.MergeLists(iRet, SLRIMisc.StrInt2IntArr(result.toString(), ",")); }else if(i == SEQHOUND_ERROR){ this.SHoundLogError(SH_warn, "[SeqHoundTaxIDFrom3DList]: ".concat(ERROR_STATEMENT)); }else if(i == SEQHOUND_NULL){ this.SHoundLogError(SH_warn, "[SeqHoundTaxIDFrom3DList]: ".concat(NULL_STATEMENT)); }else{ this.SHoundLogError(SH_warn, "[SeqHoundTaxIDFrom3DList]: ".concat(ABNORMAL_STATEMENT)); } } return iRet; } /** * Get the protein gi's for a given taxonomy * @param taxid the taxonomy identifier * @return an array of protein gi's * @throws IOException */ public int[] SHoundProteinsFromTaxID(int taxid) throws IOException { if(taxid <= 0){ this.SHoundLogError(SH_severe, "[SHoundProteinsFromTaxID] Invalid taxid."); return null; } /* construct the http call */ String args = "taxid=".concat(String.valueOf(taxid)); String address = this.GetFunctionCall("SeqHoundProteinsFromTaxID", args); this.SHoundLogError(SH_info, "[SeqHoundProteinsFromTaxID] :".concat(args)); int i; StringBuffer result = new StringBuffer(); if((i = this.ProcessContents(address, result)) == SEQHOUND_OK){ return SLRIMisc.StrInt2IntArr(result.toString(), ","); }else if(i == SEQHOUND_ERROR){ this.SHoundLogError(SH_warn, "[SeqHoundProteinsFromTaxID]: ".concat(ERROR_STATEMENT)); }else if(i == SEQHOUND_NULL){ this.SHoundLogError(SH_warn, "[SeqHoundProteinsFromTaxID]: ".concat(NULL_STATEMENT)); }else{ this.SHoundLogError(SH_warn, "[SeqHoundProteinsFromTaxID]: ".concat(ABNORMAL_STATEMENT)); } return null; } /** * get an array of proteins from an array of taxonomy identifier * @param taxList the array of taxonomy * @return an array of protein gi's * @throws IOException */ public int[] SHoundProteinsFromTaxIDList(int[] taxList) throws IOException { if(taxList == null){ this.SHoundLogError(SH_severe, "[SHoundProteinsFromTaxIDList] Empty array: taxList"); return null; } if(taxList.length < 1){ this.SHoundLogError(SH_severe, "[SHoundProteinsFromTaxIDList] Empty array: taxList"); return null; } Vector tmpV = SLRIMisc.CopyArray(taxList); int[] iRet = new int[0]; String args, address; StringBuffer result; while(tmpV.size() > 0){ result = new StringBuffer(); int[] itmp = SLRIMisc.MaxSizeIntList(tmpV); args = "ptaxid=".concat(SLRIMisc.SaveArrAsString(itmp)); address = this.GetFunctionCall("SeqHoundProteinsFromTaxIDList", args); this.SHoundLogError(SH_info, "[SeqHoundProteinsFromTaxIDList] :".concat(args)); int i; if((i = this.ProcessContents(address, result)) == SEQHOUND_OK){ iRet = SLRIMisc.MergeLists(iRet, SLRIMisc.StrInt2IntArr(result.toString(), ",")); }else if(i == SEQHOUND_ERROR){ this.SHoundLogError(SH_warn, "[SeqHoundProteinsFromTaxIDList]: ".concat(ERROR_STATEMENT)); }else if(i == SEQHOUND_NULL){ this.SHoundLogError(SH_warn, "[SeqHoundProteinsFromTaxIDList]: ".concat(NULL_STATEMENT)); }else{ this.SHoundLogError(SH_warn, "[SeqHoundProteinsFromTaxIDList]: ".concat(ABNORMAL_STATEMENT)); } } return iRet; } /** * Get an array of protein gi's for a given taxonomy identifier. * Uses precomputed searches if appropriate, to speed up the search. * @param taxid the given taxonomy identifier * @return an array of taxonomy identifier * @throws IOException */ public int[] SHoundProteinsFromTaxIDIII(int taxid) throws IOException { if(taxid <= 0){ this.SHoundLogError(SH_severe, "[SHoundProteinsFromTaxIDIII] Invalid taxid."); return null; } String args = "taxid=".concat(String.valueOf(taxid)); String address = this.GetFunctionCall("SeqHoundProteinsFromTaxIDIII", args); this.SHoundLogError(SH_info, "[SeqHoundProteinsFromTaxIDIII] :".concat(args)); int i; StringBuffer result = new StringBuffer(); if((i = this.ProcessContents(address, result)) == SEQHOUND_OK){ return SLRIMisc.StrInt2IntArr(result.toString(), ","); }else if(i == SEQHOUND_ERROR){ this.SHoundLogError(SH_warn, "[SeqHoundProteinsFromTaxIDIII]: ".concat(ERROR_STATEMENT)); }else if(i == SEQHOUND_NULL){ this.SHoundLogError(SH_warn, "[SeqHoundProteinsFromTaxIDIII]: ".concat(NULL_STATEMENT)); }else{ this.SHoundLogError(SH_warn, "[SeqHoundProteinsFromTaxIDIII]: ".concat(ABNORMAL_STATEMENT)); } return null; } /** * Get the DNA gi's for a given taxonomy id * @param taxid the taxonomy identifier * @return an array of dna gi's * @throws IOException */ public int[] SHoundDNAFromTaxID(int taxid) throws IOException { if(taxid <= 0){ this.SHoundLogError(SH_severe, "[SHoundDNAFromTaxID] Invalid taxid."); return null; } String args = "taxid=".concat(String.valueOf(taxid)); String address = this.GetFunctionCall("SeqHoundDNAFromTaxID", args); this.SHoundLogError(SH_info, "[SeqHoundDNAFromTaxID]: ".concat(args)); int i; StringBuffer result = new StringBuffer(); if((i = this.ProcessContents(address, result)) == SEQHOUND_OK){ return SLRIMisc.StrInt2IntArr(result.toString(), ","); }else if(i == SEQHOUND_ERROR){ this.SHoundLogError(SH_warn, "[SeqHoundDNAFromTaxID]: ".concat(ERROR_STATEMENT)); }else if(i == SEQHOUND_NULL){ this.SHoundLogError(SH_warn, "[SeqHoundDNAFromTaxID]: ".concat(NULL_STATEMENT)); }else{ this.SHoundLogError(SH_warn, "[SeqHoundDNAFromTaxID]: ".concat(ABNORMAL_STATEMENT)); } return null; } /** * get an array of dna gi's for an array of taxonomy identifiers * @param taxList an array of taxid * @return an array of dna gi's * @throws IOException */ public int[] SHoundDNAFromTaxIDList(int[] taxList) throws IOException { if(taxList == null){ this.SHoundLogError(SH_severe, "[SHoundDNAFromTaxIDList] Empty array: taxList"); return null; } if(taxList.length < 1){ this.SHoundLogError(SH_severe, "[SHoundDNAFromTaxIDList] Empty array: taxList"); return null; } Vector tmpV = SLRIMisc.CopyArray(taxList); int[] iRet = new int[0]; String args, address; StringBuffer result; while(tmpV.size() > 0){ result = new StringBuffer(); int[] itmp = SLRIMisc.MaxSizeIntList(tmpV); args = "ptaxid=".concat(SLRIMisc.SaveArrAsString(itmp)); address = this.GetFunctionCall("SeqHoundDNAFromTaxIDList", args); this.SHoundLogError(SH_info, "[SeqHoundDNAFromTaxIDList]: ".concat(args)); int i; if((i = this.ProcessContents(address, result)) == SEQHOUND_OK){ iRet = SLRIMisc.MergeLists(iRet, SLRIMisc.StrInt2IntArr(result.toString(), ",")); }else if(i == SEQHOUND_ERROR){ this.SHoundLogError(SH_warn, "[SeqHoundDNAFromTaxIDList]: ".concat(ERROR_STATEMENT)); }else if(i == SEQHOUND_NULL){ this.SHoundLogError(SH_warn, "[SeqHoundDNAFromTaxIDList]: ".concat(NULL_STATEMENT)); }else{ this.SHoundLogError(SH_warn, "[SeqHoundDNAFromTaxIDList]: ".concat(ABNORMAL_STATEMENT)); } } return iRet; } /** * Get the dna gi's for a given taxid. Uses precomputed searches to * speed up search where appropriate. * @param taxid * @return an array of DNA gi's * @throws IOException */ public int[] SHoundDNAFromTaxIDIII(int taxid) throws IOException { if(taxid <= 0){ this.SHoundLogError(SH_severe, "[SHoundDNAFromTaxIDIII] Invalid taxid."); return null; } String args = "taxid=".concat(String.valueOf(taxid)); String address = this.GetFunctionCall("SeqHoundDNAFromTaxIDIII", args); this.SHoundLogError(SH_info, "[SeqHoundDNAFromTaxIDIII]: ".concat(args)); int i; StringBuffer result = new StringBuffer(); if((i = this.ProcessContents(address, result)) == SEQHOUND_OK){ return SLRIMisc.StrInt2IntArr(result.toString(), ","); }else if(i == SEQHOUND_ERROR){ this.SHoundLogError(SH_warn, "[SeqHoundDNAFromTaxIDIII]: ".concat(ERROR_STATEMENT)); }else if(i == SEQHOUND_NULL){ this.SHoundLogError(SH_warn, "[SeqHoundDNAFromTaxIDIII]: ".concat(NULL_STATEMENT)); }else{ this.SHoundLogError(SH_warn, "[SeqHoundDNAFromTaxIDIII]: ".concat(ABNORMAL_STATEMENT)); } return null; } /** * Get the proteins for a given taxonomy. Chromflags is the DNA molecule * type, where each bit is reserved for one kind of DNA molecule. * @param taxid the taxonomy identifier * @param chromflags use hex notations: 0x40 for phage, 0x10 extra-chromosomal, 0x08 plasmid, * 0x04 chloroplast, 0x02 mitochondrion, 0x01 chromosome, * 0xFF all * @return an array of protein gi's * @throws IOException */ public int[] SHoundProteinsFromOrganism(int taxid, int chromflags) throws IOException { if(taxid <= 0){ this.SHoundLogError(SH_severe, "[SHoundProteinsFromOrganism] Invalid taxid."); return null; } if(chromflags <= 0){ this.SHoundLogError(SH_severe, "[SHoundProteinsFromOrganism] Invalid chromflags."); return null; } String args = "taxid=".concat(String.valueOf(taxid)); args += "&chromflags=".concat(String.valueOf(chromflags)); String address = this.GetFunctionCall("SeqHoundProteinsFromOrganism", args); this.SHoundLogError(SH_info, "[SeqHoundProteinsFromOrganism]: ".concat(args)); int i; StringBuffer result = new StringBuffer(); if((i = this.ProcessContents(address, result)) == SEQHOUND_OK){ return SLRIMisc.StrInt2IntArr(result.toString(), ","); }else if(i == SEQHOUND_ERROR){ this.SHoundLogError(SH_warn, "[SeqHoundProteinsFromOrganim]: ".concat(ERROR_STATEMENT)); }else if(i == SEQHOUND_NULL){ this.SHoundLogError(SH_warn, "[SeqHoundProteinsFromOrganim]: ".concat(NULL_STATEMENT)); }else{ this.SHoundLogError(SH_warn, "[SeqHoundProteinsFromOrganim]: ".concat(ABNORMAL_STATEMENT)); } return null; } /** * Get the protein gi's for a given taxonomy array, use bit notation for chromflags * * @param taxList the array of taxonomy identifier * @param chromflags see {@link #SHoundProteinsFromOrganism(int, int)} * @return an array of protein identifiers * @throws IOException */ public int[] SHoundProteinsFromOrganismList(int[] taxList, int chromflags) throws IOException { if(taxList == null){ this.SHoundLogError(SH_severe, "[SHoundProteinsFromOrganismList] Empty array: taxList"); return null; } if(taxList.length < 1){ this.SHoundLogError(SH_severe, "[SHoundProteinsFromOrganismList] Empty array: taxList"); return null; } if(chromflags <= 0){ this.SHoundLogError(SH_severe, "[SHoundProteinsFromOrganismList] Invalid chromflags."); return null; } Vector tmpV = SLRIMisc.CopyArray(taxList); int[] iRet = new int[0]; String args, address; StringBuffer result; while(tmpV.size() > 0){ result = new StringBuffer(); int[] itmp = SLRIMisc.MaxSizeIntList(tmpV); args = "ptaxid=".concat(SLRIMisc.SaveArrAsString(itmp)); args += "&chromflags=".concat(String.valueOf(chromflags)); address = this.GetFunctionCall("SeqHoundProteinsFromOrganismList", args); this.SHoundLogError(SH_info, "[SeqHoundProteinsFromOrganismList]: ".concat(args)); int i; if((i = this.ProcessContents(address, result)) == SEQHOUND_OK){ iRet = SLRIMisc.MergeLists(iRet, SLRIMisc.StrInt2IntArr(result.toString(), ",")); }else if(i == SEQHOUND_ERROR){ this.SHoundLogError(SH_warn, "[SeqHoundProteinsFromOrganismList]: ".concat(ERROR_STATEMENT)); }else if(i == SEQHOUND_NULL){ this.SHoundLogError(SH_warn, "[SeqHoundProteinsFromOrganismList]: ".concat(NULL_STATEMENT)); }else{ this.SHoundLogError(SH_warn, "[SeqHoundProteinsFromOrganismList]: ".concat(ABNORMAL_STATEMENT)); } } return iRet; } /** * Get the protein gi's for a given chromosome identifier * @param chromid the chromosome identifier * @return an array of protein gi's * @throws IOException */ public int[] SHoundProteinsFromChromosome(int chromid) throws IOException { if(chromid <= 0){ this.SHoundLogError(SH_severe, "[SHoundProteinsFromChromosome] Invalid chromid."); return null; } String args = "chromid=".concat(String.valueOf(chromid)); String address = this.GetFunctionCall("SeqHoundProteinsFromChromosome", args); this.SHoundLogError(SH_info, "[SeqHoundProteinsFromChromosome]: ".concat(args)); int i; StringBuffer result = new StringBuffer(); if((i = this.ProcessContents(address, result)) == SEQHOUND_OK){ return SLRIMisc.StrInt2IntArr(result.toString(), ","); }else if(i == SEQHOUND_ERROR){ this.SHoundLogError(SH_warn, "[SeqHoundProteinsFromChromosome]: ".concat(ERROR_STATEMENT)); }else if(i == SEQHOUND_NULL){ this.SHoundLogError(SH_warn, "[SeqHoundProteinsFromChromosome]: ".concat(NULL_STATEMENT)); }else{ this.SHoundLogError(SH_warn, "[SeqHoundProteinsFromChromosome]: ".concat(ABNORMAL_STATEMENT)); } return null; } /** * Get the protein gi's for an array of chromosome identifiers * @param chromList an array of chromosomes * @return an array of protein gi's * @throws IOException */ public int[] SHoundProteinsFromChromosomeList(int[] chromList) throws IOException { if(chromList == null){ this.SHoundLogError(SH_severe, "[SHoundProteinsFromChromosomeList] Empty array: chromList"); return null; } if(chromList.length < 1){ this.SHoundLogError(SH_severe, "[SHoundProteinsFromChromosomeList] Empty array: chromList"); return null; } Vector tmpV = SLRIMisc.CopyArray(chromList); int[] iRet = new int[0]; String args, address; StringBuffer result; while(tmpV.size() > 0){ result = new StringBuffer(); int[] itmp = SLRIMisc.MaxSizeIntList(tmpV); args = "pchromid=".concat(SLRIMisc.SaveArrAsString(itmp)); address = this.GetFunctionCall("SeqHoundProteinsFromChromosomeList", args); this.SHoundLogError(SH_info, "[SeqHoundProteinsFromChromsomeList]: ".concat(args)); int i; if((i = this.ProcessContents(address, result)) == SEQHOUND_OK){ iRet = SLRIMisc.MergeLists(iRet, SLRIMisc.StrInt2IntArr(result.toString(), ",")); }else if(i == SEQHOUND_ERROR){ this.SHoundLogError(SH_warn, "[SeqHoundProteinsFromChromosomeList]: ".concat(ERROR_STATEMENT)); }else if(i == SEQHOUND_NULL){ this.SHoundLogError(SH_warn, "[SeqHoundProteinsFromChromosomeList]: ".concat(NULL_STATEMENT)); }else{ this.SHoundLogError(SH_warn, "[SeqHoundProteinsFromChromosomeList]: ".concat(ABNORMAL_STATEMENT)); } } return iRet; } /** * Get an array of taxonomy identifiers for all complete genomes * present in the SeqHound system. * * @return an array of taxonomy identifiers * @throws IOException */ public int[] SHoundAllGenomes() throws IOException { String args = ""; String address = this.GetFunctionCall("SeqHoundAllGenomes", args); this.SHoundLogError(SH_info, "[SeqHoundAllGenomes]: ".concat(args)); int i; StringBuffer result = new StringBuffer(); if((i = this.ProcessContents(address, result)) == SEQHOUND_OK){ return SLRIMisc.StrInt2IntArr(result.toString(), ","); }else if(i == SEQHOUND_ERROR){ this.SHoundLogError(SH_warn, "[SeqHoundAllGenomes]: ".concat(ERROR_STATEMENT)); }else if(i == SEQHOUND_NULL){ this.SHoundLogError(SH_warn, "[SeqHoundAllGenomes]: ".concat(NULL_STATEMENT)); }else{ this.SHoundLogError(SH_warn, "[SeqHoundAllGenomes]: ".concat(ABNORMAL_STATEMENT)); } return null; } /** * Get all the chromosomes for a given taxonomy identifier and the molecule * @param taxid the taxonomy identifier * @param chromflags see {@link #SHoundProteinsFromOrganism(int, int)} * @return an array of chromsome identifier or null * @throws IOException */ public int[] SHoundChromosomeFromGenome(int taxid, int chromflags) throws IOException { if(taxid <= 0){ this.SHoundLogError(SH_severe, "[SHoundChromosomeFromGenome] Invalid taxid."); return null; } if(chromflags <= 0){ this.SHoundLogError(SH_severe, "[SHoundChromosomeFromGenome] Invalid chromflags."); return null; } String args = "taxid=".concat(String.valueOf(taxid)); args += "&chromflags=".concat(String.valueOf(chromflags)); String address = this.GetFunctionCall("SeqHoundChromosomeFromGenome", args); this.SHoundLogError(SH_info, "[SeqHoundChromosomeFromGenome]: ".concat(args)); int i; StringBuffer result = new StringBuffer(); if((i = this.ProcessContents(address, result)) == SEQHOUND_OK){ return SLRIMisc.StrInt2IntArr(result.toString(), ","); }else if(i == SEQHOUND_ERROR){ this.SHoundLogError(SH_warn, "[SeqHoundChromosomeFromGenome]: ".concat(ERROR_STATEMENT)); }else if(i == SEQHOUND_NULL){ this.SHoundLogError(SH_warn, "[SeqHoundChromosomeFromGenome]: ".concat(NULL_STATEMENT)); }else{ this.SHoundLogError(SH_warn, "[SeqHoundChromosomeFromGenome]: ".concat(ABNORMAL_STATEMENT)); } return null; } /** * Gets an array of chromosome identifiers for a given taxonomy list * @param taxList the taxonomy list * @param chromflags see {@link #SHoundProteinsFromOrganism(int, int)} * @return an array of chromosome identifiers * @throws IOException */ public int[] SHoundChromosomeFromGenomeList(int[] taxList, int chromflags) throws IOException { if(taxList == null){ this.SHoundLogError(SH_severe, "[SHoundChromosomeFromGenomeList] Empty array: taxlist"); return null; } if(taxList.length < 1){ this.SHoundLogError(SH_severe, "[SHoundChromosomeFromGenomeList] Empty array: taxlist"); return null; } if(chromflags <= 0){ this.SHoundLogError(SH_severe, "[SHoundChromosomeFromGenomeList] Invalid chromflags"); return null; } Vector tmpV = SLRIMisc.CopyArray(taxList); int[] iRet = new int[0]; String args, address; StringBuffer result; while(tmpV.size() > 0){ result = new StringBuffer(); int[] itmp = SLRIMisc.MaxSizeIntList(tmpV); args = "ptaxid=".concat(SLRIMisc.SaveArrAsString(itmp)); args += "&chromflags=".concat(String.valueOf(chromflags)); address = this.GetFunctionCall("SeqHoundChromosomeFromGenomeList", args); this.SHoundLogError(SH_info, "[SeqHoundChromsomeFromGenomeList]: ".concat(args)); int i; if((i = this.ProcessContents(address, result)) == SEQHOUND_OK){ iRet = SLRIMisc.MergeLists(iRet, SLRIMisc.StrInt2IntArr(result.toString(), ",")); }else if(i == SEQHOUND_ERROR){ this.SHoundLogError(SH_warn, "[SeqHoundChromosomeFromGenomeList]: ".concat(ERROR_STATEMENT)); }else if(i == SEQHOUND_NULL){ this.SHoundLogError(SH_warn, "[SeqHoundChromosomeFromGenomeList]: ".concat(NULL_STATEMENT)); }else{ this.SHoundLogError(SH_warn, "[SeqHoundChromosomeFromGenomeList]: ".concat(ABNORMAL_STATEMENT)); } } return iRet; } /** * Get an array of dna gi's for a given organism * @param taxid the taxonomy identifier * @param chromflags see {@link #SHoundProteinsFromOrganism(int, int)} * @return array of dna identifier * @throws IOException */ public int[] SHoundDNAFromOrganism(int taxid, int chromflags) throws IOException { if(taxid <= 0){ this.SHoundLogError(SH_severe, "[SHoundDNAFromOrganism] Invalid taxid."); return null; } if(chromflags <= 0){ this.SHoundLogError(SH_severe, "[SHoundDNAFromOrganism] Invalid chromflags."); return null; } String args = "taxid=".concat(String.valueOf(taxid)); args += "&chromflags=".concat(String.valueOf(chromflags)); String address = this.GetFunctionCall("SeqHoundDNAFromOrganism", args); this.SHoundLogError(SH_info, "[SeqHoundDNAFromOrganism]: ".concat(args)); int i; StringBuffer result = new StringBuffer(); if((i = this.ProcessContents(address, result)) == SEQHOUND_OK){ return SLRIMisc.StrInt2IntArr(result.toString(), ","); }else if(i == SEQHOUND_ERROR){ this.SHoundLogError(SH_warn, "[SeqHoundDNAFromOrganism]: ".concat(ERROR_STATEMENT)); }else if(i == SEQHOUND_NULL){ this.SHoundLogError(SH_warn, "[SeqHoundDNAFromOrganism]: ".concat(NULL_STATEMENT)); }else{ this.SHoundLogError(SH_warn, "[SeqHoundDNAFromOrganims]: ".concat(ABNORMAL_STATEMENT)); } return null; } /** * Get an array of dna gi's for a given taxonomy array * @param taxList the taxonomy array * @param chromflags see {@link #SHoundProteinsFromOrganism(int, int)} * @return an array of DNA gi's * @throws IOException */ public int[] SHoundDNAFromOrganismList(int[] taxList, int chromflags) throws IOException { if(taxList == null){ this.SHoundLogError(SH_severe, "[SHoundDNAFromOrganism] Empty array: taxList."); return null; } if(taxList.length < 1){ this.SHoundLogError(SH_severe, "[SHoundDNAFromOrganism] Empty array: taxList."); return null; } if(chromflags <= 0){ this.SHoundLogError(SH_severe, "[SHoundDNAFromOrganism] Invalid chromflags."); return null; } Vector tmpV = SLRIMisc.CopyArray(taxList); int[] iRet = new int[0]; String args, address; StringBuffer result; while(tmpV.size() > 0){ result = new StringBuffer(); int[] itmp = SLRIMisc.MaxSizeIntList(tmpV); args = "ptaxid=".concat(SLRIMisc.SaveArrAsString(itmp)); args += "&chromflags=".concat(String.valueOf(chromflags)); address = this.GetFunctionCall("SeqHoundDNAFromOrganismList", args); this.SHoundLogError(SH_info, "[SeqHoundDNAFromOrganimsList]: ".concat(args)); int i; if((i = this.ProcessContents(address, result)) == SEQHOUND_OK){ iRet = SLRIMisc.MergeLists(iRet, SLRIMisc.StrInt2IntArr(result.toString(), ",")); }else if(i == SEQHOUND_ERROR){ this.SHoundLogError(SH_warn, "[SeqHoundDNAFromOrganismList]: ".concat(ERROR_STATEMENT)); }else if(i == SEQHOUND_NULL){ this.SHoundLogError(SH_warn, "[SeqHoundDNAFromOrganismList]: ".concat(NULL_STATEMENT)); }else{ this.SHoundLogError(SH_warn, "[SeqHoundDNAFromOrganimsList]: ".concat(ABNORMAL_STATEMENT)); } } return iRet; } /** * Get an array of dna gi's for a given chromosome identifier * @param chromid the chromosome identifier * @return an array fo dna gi's * @throws IOException */ public int[] SHoundDNAFromChromosome(int chromid) throws IOException { if(chromid <= 0){ this.SHoundLogError(SH_severe, "[SHoundDNAFromChromosome] Invalid chromid."); return null; } String args = "chromid=".concat(String.valueOf(chromid)); String address = this.GetFunctionCall("SeqHoundDNAFromChromosome", args); this.SHoundLogError(SH_info, "[SeqHoundDNAFromChromosome]: ".concat(args)); int i; StringBuffer result = new StringBuffer(); if((i = this.ProcessContents(address, result)) == SEQHOUND_OK){ return SLRIMisc.StrInt2IntArr(result.toString(), ","); }else if(i == SEQHOUND_ERROR){ this.SHoundLogError(SH_warn, "[SeqHoundDNAFromChromosome]: ".concat(ERROR_STATEMENT)); }else if(i == SEQHOUND_NULL){ this.SHoundLogError(SH_warn, "[SeqHoundDNAFromChromosome]: ".concat(NULL_STATEMENT)); }else{ this.SHoundLogError(SH_warn, "[SeqHoundDNAFromChromosome]: ".concat(ABNORMAL_STATEMENT)); } return null; } /** * Get an array of dna gi's for an input of chromosome array * @param chromList an array of chromsome identifiers * @return an array of dna gi's * @throws IOException */ public int[] SHoundDNAFromChromosomeList(int[] chromList) throws IOException { if(chromList == null){ this.SHoundLogError(SH_severe, "[SHoundDNAFromChromosomeList] Empty array: chromList"); return null; } if(chromList.length < 1){ this.SHoundLogError(SH_severe, "[SHoundDNAFromChromosomeList] Empty array: chromList"); return null; } Vector tmpV = SLRIMisc.CopyArray(chromList); int[] iRet = new int[0]; String args, address; StringBuffer result; while(tmpV.size() > 0){ result = new StringBuffer(); int[] itmp = SLRIMisc.MaxSizeIntList(tmpV); args = "pchromid=".concat(SLRIMisc.SaveArrAsString(itmp)); address = this.GetFunctionCall("SeqHoundDNAFromChromosomeList", args); this.SHoundLogError(SH_info, "[SeqHoundDNAFromChromosomeList]: ".concat(args)); int i; if((i = this.ProcessContents(address, result)) == SEQHOUND_OK){ iRet = SLRIMisc.MergeLists(iRet, SLRIMisc.StrInt2IntArr(result.toString(), ",")); }else if(i == SEQHOUND_ERROR){ this.SHoundLogError(SH_warn, "[SeqHoundDNAFromChromosomeList]: ".concat(ERROR_STATEMENT)); }else if(i == SEQHOUND_NULL){ this.SHoundLogError(SH_warn, "[SeqHoundDNAFromChromosomeList]: ".concat(NULL_STATEMENT)); }else{ this.SHoundLogError(SH_warn, "[SeqHoundDNAFromChromosomeList]: ".concat(ABNORMAL_STATEMENT)); } } return iRet; } /** * Gets all protein entries with the same sequence from the system * @param gi the gi * @return an array of protein gi's * @throws IOException */ public int[] SHoundRedundantGroup(int gi) throws IOException { if(gi <= 0){ this.SHoundLogError(SH_severe, "[SHoundRedundantGroup] Invalid gi."); return null; } String args = "gi=".concat(String.valueOf(gi)); String address = this.GetFunctionCall("SeqHoundRedundantGroup", args); this.SHoundLogError(SH_info, "[SeqHoundRedundantGroup]: ".concat(args)); int i; StringBuffer result = new StringBuffer(); if((i = this.ProcessContents(address, result)) == SEQHOUND_OK){ return SLRIMisc.StrInt2IntArr(result.toString(), ","); }else if(i == SEQHOUND_ERROR){ this.SHoundLogError(SH_warn, "[SeqHoundRedundantGroup]: ".concat(ERROR_STATEMENT)); }else if(i == SEQHOUND_NULL){ this.SHoundLogError(SH_warn, "[SeqHoundRedundantGroup]: ".concat(NULL_STATEMENT)); }else{ this.SHoundLogError(SH_warn, "[SeqHoundRedundantGroup]: ".concat(ABNORMAL_STATEMENT)); } return null; } /** * Gets all protein entries with the same sequence from the system * @param giList * @return an array of protein gi's * @throws IOException */ public int[] SHoundRedundantGroupList(int[] giList) throws IOException { if(giList == null){ this.SHoundLogError(SH_severe, "[SHoundRedundantGroupList] Empty array: giList"); return null; } if(giList.length < 1){ this.SHoundLogError(SH_severe, "[SHoundRedundantGroupList] Empty array: giList"); return null; } Vector tmpV = SLRIMisc.CopyArray(giList); int[] iRet = new int[0]; String args, address; StringBuffer result; while(tmpV.size() > 0){ result = new StringBuffer(); int[] itmp = SLRIMisc.MaxSizeIntList(tmpV); args = "pgi=".concat(SLRIMisc.SaveArrAsString(itmp)); address = this.GetFunctionCall("SeqHoundRedundantGroupList", args); this.SHoundLogError(SH_info, "[SeqHoundRedundantGroupList]: ".concat(args)); int i; if((i = this.ProcessContents(address, result)) == SEQHOUND_OK){ iRet = SLRIMisc.MergeLists(iRet, SLRIMisc.StrInt2IntArr(result.toString(), ",")); }else if(i == SEQHOUND_ERROR){ this.SHoundLogError(SH_warn, "[SeqHoundRedundantGroupList]: ".concat(ERROR_STATEMENT)); }else if(i == SEQHOUND_NULL){ this.SHoundLogError(SH_warn, "[SeqHoundRedundantGroupList]: ".concat(NULL_STATEMENT)); }else{ this.SHoundLogError(SH_warn, "[SeqHoundRedundantGroupList]: ".concat(ABNORMAL_STATEMENT)); } } return iRet; } /** * Entrez collection of databases contains redundant entries i.e. * proteins with the same sequence but different annotations. * The function gets an arbitrary redundant group identifier for * a protein sequence. The redundant group identifiers can only be * used temporarily, they change every day. * @param gi the gi * @return a temporary group id * @throws IOException */ public int SHoundRedundantGroupIDFromGi(int gi) throws IOException { if(gi <= 0){ this.SHoundLogError(SH_severe, "[SHoundRedundantGroupIDFromGI] Invalid gi."); return SEQHOUND_ERROR; } String args = "gi=".concat(String.valueOf(gi)); String address = this.GetFunctionCall("SeqHoundRedundantGroupIDFromGI", args); this.SHoundLogError(SH_info, "[SeqHoundRedundantGroupIDFromGI]: ".concat(args)); int i; StringBuffer result = new StringBuffer(); if((i = this.ProcessContents(address, result)) == SEQHOUND_OK){ return Integer.parseInt(result.toString()); }else if(i == SEQHOUND_ERROR){ this.SHoundLogError(SH_warn, "[SeqHoundRedundantGroupIDFromGI]: ".concat(ERROR_STATEMENT)); }else if(i == SEQHOUND_NULL){ this.SHoundLogError(SH_warn, "[SeqHoundRedundantGroupIDFromGI]: ".concat(NULL_STATEMENT)); }else{ this.SHoundLogError(SH_warn, "[SeqHoundRedundantGroupIDFromGI]: ".concat(ABNORMAL_STATEMENT)); } return SEQHOUND_ERROR; } /** * Entrez collection of databases contains redundant entries i.e. * proteins with the same sequence but different annotations. * The function gets an arbitrary redundant group identifier for * a list of protein sequences. The redundant group identifiers * can only be used temporarily, they change every day. * @param giList an arrary of gi * @return an array of group id * @throws IOException */ public int[] SHoundRedundantGroupIDFromGiList(int[] giList) throws IOException { if(giList == null){ this.SHoundLogError(SH_severe, "[SHoundRedundantGroupIDFromGIList] Empty array: giList"); return null; } if(giList.length < 1){ this.SHoundLogError(SH_severe, "[SHoundRedundantGroupIDFromGIList] Empty array: giList"); return null; } Vector tmpV = SLRIMisc.CopyArray(giList); int[] iRet = new int[0]; String args, address; StringBuffer result; while(tmpV.size() > 0){ result = new StringBuffer(); int[] itmp = SLRIMisc.MaxSizeIntList(tmpV); args = "pgi=".concat(SLRIMisc.SaveArrAsString(itmp)); address = this.GetFunctionCall("SeqHoundRedundantGroupIDFromGIList", args); this.SHoundLogError(SH_info, "[SeqHoundRedundantGroupIDFromGIList]: ".concat(args)); int i; if((i =this.ProcessContents(address, result)) == SEQHOUND_OK){ iRet = SLRIMisc.MergeLists(iRet, SLRIMisc.StrInt2IntArr(result.toString(), ",")); }else if(i == SEQHOUND_ERROR){ this.SHoundLogError(SH_warn, "[SeqHoundRedundantGroupIDFromGIList]: ".concat(ERROR_STATEMENT)); }else if(i == SEQHOUND_NULL){ this.SHoundLogError(SH_warn, "[SeqHoundRedundantGroupIDFromGIList]: ".concat(NULL_STATEMENT)); }else{ this.SHoundLogError(SH_warn, "[SeqHoundRedundantGroupIDFromGIList]: ".concat(ABNORMAL_STATEMENT)); } } return iRet; } /** * returns an array of gi's in the same group. * The group id changes everyday * @param group id the group identifier * @return array of gi in the same group * @throws IOException */ public int[] SHoundRedundantGroupFromID(int group) throws IOException { if(group <= 0){ this.SHoundLogError(SH_severe, "[SHoundRedundantGroupFromID] Invalid group"); return null; } String args = "group=".concat(String.valueOf(group)); String address = this.GetFunctionCall("SeqHoundRedundantGroupFromID", args); this.SHoundLogError(SH_info, "[SeqHoundRedundantGroupFromID]: ".concat(args)); int i; StringBuffer result = new StringBuffer(); if((i = this.ProcessContents(address, result)) == SEQHOUND_OK){ return SLRIMisc.StrInt2IntArr(result.toString(), ","); }else if(i == SEQHOUND_ERROR){ this.SHoundLogError(SH_warn, "[SeqHoundRedundantGroupFromID]: ".concat(ERROR_STATEMENT)); }else if(i == SEQHOUND_NULL){ this.SHoundLogError(SH_warn, "[SeqHoundRedundantGroupFromID]: ".concat(NULL_STATEMENT)); }else{ this.SHoundLogError(SH_warn, "[SeqHoundRedundantGroupFromID]: ".concat(ABNORMAL_STATEMENT)); } return null; } /** * returns an array of redundant protein gi's for an array of redundant group id's. * The group id's change daily. * @param groupList an array of group id * @return an array of redundant protein gi's * @throws IOException */ public int[] SHoundRedundantGroupFromIDList(int[] groupList) throws IOException { if(groupList == null){ this.SHoundLogError(SH_severe, "[SHoundRedundantGroupFromIDList] Empty array: groupList"); return null; } if(groupList.length < 1){ this.SHoundLogError(SH_severe, "[SHoundRedundantGroupFromIDList] Empty array: groupList"); return null; } Vector tmpV = SLRIMisc.CopyArray(groupList); int[] iRet = new int[0]; String args, address; StringBuffer result; while(tmpV.size() > 0){ result = new StringBuffer(); int[] itmp = SLRIMisc.MaxSizeIntList(tmpV); args = "pgroup=".concat(SLRIMisc.SaveArrAsString(itmp)); address = this.GetFunctionCall("SeqHoundRedundantGroupFromIDList", args); this.SHoundLogError(SH_info, "[SeqHoundRedundantGroupFromIDList]: ".concat(args)); int i; if((i = this.ProcessContents(address, result)) == SEQHOUND_OK){ iRet = SLRIMisc.MergeLists(iRet, SLRIMisc.StrInt2IntArr(result.toString(), ",")); }else if(i == SEQHOUND_ERROR){ this.SHoundLogError(SH_warn, "[SeqHoundRedundantGroupFromIDList]: ".concat(ERROR_STATEMENT)); }else if(i == SEQHOUND_NULL){ this.SHoundLogError(SH_warn, "[SeqHoundRedundantGroupFromIDList]: ".concat(NULL_STATEMENT)); }else{ this.SHoundLogError(SH_warn, "[SeqHoundRedundantGroupFromIDList]: ".concat(ABNORMAL_STATEMENT)); } } return iRet; } /** * Entrez collection of databases contains redundant entries i.e. * proteins with the same sequence but different annotations. The * function gets a representative entry (generally the one with best * annotation such as PDB, RefSeq or SwissProt entry) given a redundant * group identifier. The redundant group identifiers can only be used * temporarily, they change every day. * @param group the group id * @return the best annotation gi for a given group * @throws IOException */ public int SHoundFirstOfRedundantGroupFromID(int group) throws IOException { if(group <= 0){ this.SHoundLogError(SH_severe, "[SHoundFirstOfRedundantGroupFromID] Invalid group."); return SEQHOUND_ERROR; } String args = "group=".concat(String.valueOf(group)); String address = this.GetFunctionCall("SeqHoundFirstOfRedundantGroupFromID", args); this.SHoundLogError(SH_info, "[SeqHoundFirstOfRedundantGroupFromID]: ".concat(args)); int i; StringBuffer result = new StringBuffer(); if((i = this.ProcessContents(address, result)) == SEQHOUND_OK){ return Integer.parseInt(result.toString()); }else if(i == SEQHOUND_ERROR){ this.SHoundLogError(SH_warn, "[SeqHoundFirstOfRedundantGroupFromID]: ".concat(ERROR_STATEMENT)); }else if(i == SEQHOUND_NULL){ this.SHoundLogError(SH_warn, "[SeqHoundFirstOfRedundantGroupFromID]: ".concat(NULL_STATEMENT)); }else{ this.SHoundLogError(SH_warn, "[SeqHoundFirstOfRedundantGroupFromID]: ".concat(ABNORMAL_STATEMENT)); } return SEQHOUND_ERROR; } /** * Gets the gi of the best annotated sequence given an array of group id. * @param group array of group identifier * @return an array of the best annotated gi * @throws IOException */ public int[] SHoundFirstOfRedundantGroupFromIDList(int[] group) throws IOException { if(group == null){ this.SHoundLogError(SH_severe, "[SHoundFirstOfRedundantGroupFromIDList] Empty array: group"); return null; } if(group.length < 1){ this.SHoundLogError(SH_severe, "[SHoundFirstOfRedundantGroupFromIDList] Empty array: group"); return null; } Vector tmpV = SLRIMisc.CopyArray(group); int[] iRet = new int[0]; String args, address; StringBuffer result; while(tmpV.size() > 0){ result = new StringBuffer(); int[] itmp = SLRIMisc.MaxSizeIntList(tmpV); args = "pgroup=".concat(SLRIMisc.SaveArrAsString(itmp)); address = this.GetFunctionCall("SeqHoundFirstOfRedundantGroupFromIDList", args); this.SHoundLogError(SH_info, "[SeqHoundFirstOfRedundantGroupFromIDList]: ".concat(args)); int i; if((i = this.ProcessContents(address, result)) == SEQHOUND_OK){ iRet = SLRIMisc.MergeLists(iRet, SLRIMisc.StrInt2IntArr(result.toString(), ",")); }else if(i == SEQHOUND_ERROR){ this.SHoundLogError(SH_warn, "[SeqHoundFirstOfRedundantGroupFromIDList]: ".concat(ERROR_STATEMENT)); }else if(i == SEQHOUND_NULL){ this.SHoundLogError(SH_warn, "[SeqHoundFirstOfRedundantGroupFromIDList]: ".concat(NULL_STATEMENT)); }else{ this.SHoundLogError(SH_warn, "[SeqHoundFirstOfRedundantGroupFromIDList]: ".concat(ABNORMAL_STATEMENT)); } } return iRet; } /** * operates on NCBI's taxonomy tree. It retrieves all taxons * situated directly below a given taxon in the taxonomy tree. * @param taxid the taxonomy * @return an array of taxonomy id that are children of taxid * @throws IOException */ public int[] SHoundGetTaxChildNodes(int taxid) throws IOException { if(taxid <= 0){ this.SHoundLogError(SH_severe, "[SHoundGetTaxChildNodes] Invalid taxid"); return null; } String args = "taxid=".concat(String.valueOf(taxid)); String address = this.GetFunctionCall("SeqHoundGetTaxChildNodes", args); this.SHoundLogError(SH_info, "[SeqHoundGetTaxChildNodes]: ".concat(args)); int i; StringBuffer result = new StringBuffer(); if((i = this.ProcessContents(address, result)) == SEQHOUND_OK){ return SLRIMisc.StrInt2IntArr(result.toString(), ","); }else if(i == SEQHOUND_ERROR){ this.SHoundLogError(SH_warn, "[SeqHoundGetTaxChildNodes]: ".concat(ERROR_STATEMENT)); }else if(i == SEQHOUND_NULL){ this.SHoundLogError(SH_warn, "[SeqHoundGetTaxChildNodes]: ".concat(NULL_STATEMENT)); }else{ this.SHoundLogError(SH_warn, "[SeqHoundGetTaxChildNodes]: ".concat(ABNORMAL_STATEMENT)); } return null; } /** * Get the children taxonomy id of an array of taxid inputs * @param taxList an array of taxonomy * @return an array of taxonomy id * @throws IOException */ public int[] SHoundGetTaxChildNodesList(int[] taxList) throws IOException { if(taxList == null){ this.SHoundLogError(SH_severe, "[SHoundGetTaxChildNodesList] Empty array: taxList"); return null; } if(taxList.length < 1){ this.SHoundLogError(SH_severe, "[SHoundGetTaxChildNodesList] Empty array: taxList"); return null; } Vector tmpV = SLRIMisc.CopyArray(taxList); int[] iRet = new int[0]; String args, address; StringBuffer result; while(tmpV.size() > 0){ result = new StringBuffer(); int[] itmp = SLRIMisc.MaxSizeIntList(tmpV); args = "ptaxid=".concat(SLRIMisc.SaveArrAsString(itmp)); address = this.GetFunctionCall("SeqHoundGetTaxChildNodesList", args); this.SHoundLogError(SH_info, "[SeqHoundGetTaxChildNodesList]: ".concat(args)); int i; if((i = this.ProcessContents(address, result)) == SEQHOUND_OK){ iRet = SLRIMisc.MergeLists(iRet, SLRIMisc.StrInt2IntArr(result.toString(), ",")); }else if(i == SEQHOUND_ERROR){ this.SHoundLogError(SH_warn, "[SeqHoundGetTaxChildNodesList]: ".concat(ERROR_STATEMENT)); }else if(i == SEQHOUND_NULL){ this.SHoundLogError(SH_warn, "[SeqHoundGetTaxChildNodesList]: ".concat(NULL_STATEMENT)); }else{ this.SHoundLogError(SH_warn, "[SeqHoundGetTaxChildNodesList]: ".concat(ABNORMAL_STATEMENT)); } } return iRet; } /** * operates on NCBI's taxonomy tree. It retrieves all taxons * (the whole subtree) situated below a given taxon in the taxonomy tree. * @param taxid the taxonomy id * @return an array of taxid * @throws IOException */ public int[] SHoundGetAllTaxProgeny(int taxid) throws IOException { if(taxid <= 0){ this.SHoundLogError(SH_severe, "[SHoundGetTallTaxProgeny] Invalid taxid."); return null; } String args = "taxid=".concat(String.valueOf(taxid)); String address = this.GetFunctionCall("SeqHoundGetAllTaxProgeny", args); this.SHoundLogError(SH_info, "[SeqHoundGetAlLTaxProgeny]: ".concat(args)); int i; StringBuffer result = new StringBuffer(); if((i = this.ProcessContents(address, result)) == SEQHOUND_OK){ return SLRIMisc.StrInt2IntArr(result.toString(), ","); }else if(i == SEQHOUND_ERROR){ this.SHoundLogError(SH_warn, "[SeqHoundGetAllTaxProgeny]: ".concat(ERROR_STATEMENT)); }else if(i == SEQHOUND_NULL){ this.SHoundLogError(SH_warn, "[SeqHoundGetAllTaxProgeny]: ".concat(NULL_STATEMENT)); }else{ this.SHoundLogError(SH_warn, "[SeqHoundGetAllTaxProgeny]: ".concat(ABNORMAL_STATEMENT)); } return null; } /** * Retrieve the tax id situated directly above a given tax id * @param taxid a taxonomy identifier * @return a taxid * @throws IOException */ public int SHoundGetTaxParent(int taxid) throws IOException { if(taxid <= 0){ this.SHoundLogError(SH_severe, "[SHoundGetTaxParent] Invalid taxid."); return SEQHOUND_ERROR; } String args = "taxid=".concat(String.valueOf(taxid)); String address = this.GetFunctionCall("SeqHoundGetTaxParent", args); this.SHoundLogError(SH_info, "[SeqHoundGetTaxParent]: ".concat(args)); int i; StringBuffer result = new StringBuffer(); if((i = this.ProcessContents(address, result)) == SEQHOUND_OK){ return Integer.parseInt(result.toString()); }else if(i == SEQHOUND_ERROR){ this.SHoundLogError(SH_warn, "[SeqHoundGetTaxParent]: ".concat(ERROR_STATEMENT)); }else if(i == SEQHOUND_NULL){ this.SHoundLogError(SH_warn, "[SeqHoundGetTaxParent]: ".concat(NULL_STATEMENT)); }else{ this.SHoundLogError(SH_warn, "[SeqHoundGetTaxParent]: ".concat(ABNORMAL_STATEMENT)); } return SEQHOUND_ERROR; } /** * Retrieves all taxid (the whole subtree) above a given taxid * @param taxid a taxonomy identifier * @return a taxonomy identifier * @throws IOException */ public int[] SHoundGetAllTaxAncestors(int taxid) throws IOException { if(taxid <= 0){ this.SHoundLogError(SH_severe, "[SHoundGetAllTaxAncestors] Invalid taxid."); return null; } String args = "taxid=".concat(String.valueOf(taxid)); String address = this.GetFunctionCall("SeqHoundGetAllTaxAncestors", args); this.SHoundLogError(SH_info, "[SeqHoundGetAlLTaxAncestors]: ".concat(args)); int i; StringBuffer result = new StringBuffer(); if((i = this.ProcessContents(address, result)) == SEQHOUND_OK){ return SLRIMisc.StrInt2IntArr(result.toString(), ","); }else if(i == SEQHOUND_ERROR){ this.SHoundLogError(SH_warn, "[SeqHoundGetAllTaxAncestors]: ".concat(ERROR_STATEMENT)); }else if(i == SEQHOUND_NULL){ this.SHoundLogError(SH_warn, "[SeqHoundGetAllTaxAncestors]: ".concat(NULL_STATEMENT)); }else{ this.SHoundLogError(SH_warn, "[SeqHoundGetAllTaxAncestors]: ".concat(ABNORMAL_STATEMENT)); } return null; } /** * reports if a given taxonomy identifier has been renamed * @param taxid a taxonomy identifier * @return true if taxid has been renamed, else false * @throws IOException */ public boolean SHoundIsTaxMerged(int taxid) throws IOException { if(taxid <= 0){ this.SHoundLogError(SH_severe, "[SHoundIsTaxMerged] Invalid taxid."); return false; } String args = "taxid=".concat(String.valueOf(taxid)); String address = this.GetFunctionCall("SeqHoundIsTaxMerged", args); this.SHoundLogError(SH_info, "[SeqHoundIsTaxMerged]: ".concat(args)); int i; StringBuffer result = new StringBuffer(); if(( i = this.ProcessContents(address, result)) == SEQHOUND_OK){ return (new Boolean(result.toString())).booleanValue(); }else if(i == SEQHOUND_ERROR){ this.SHoundLogError(SH_warn, "[SeqHoundIsTaxMerged]: ".concat(ERROR_STATEMENT)); }else if(i == SEQHOUND_NULL){ this.SHoundLogError(SH_warn, "[SeqHoundIsTaxMerged]: ".concat(NULL_STATEMENT)); }else{ this.SHoundLogError(SH_warn, "[SeqHoundIsTaxMerged]: ".concat(ABNORMAL_STATEMENT)); } return false; } /** * reports whether a taxid has been deleted from the tree * @param taxid an taxon id * @return true if taxid deleted, else false * @throws IOException */ public boolean SHoundIsTaxDeleted(int taxid) throws IOException { if(taxid <= 0){ this.SHoundLogError(SH_severe, "[SHoundIsTaxDeleted] Invalid taxid."); return false; } String args = "taxid=".concat(String.valueOf(taxid)); String address = this.GetFunctionCall("SeqHoundIsTaxDeleted", args); this.SHoundLogError(SH_info, "[SeqHoundIsTaxDeleted]: ".concat(args)); int i; StringBuffer result = new StringBuffer(); if((i = this.ProcessContents(address, result)) == SEQHOUND_OK){ return (new Boolean(result.toString())).booleanValue(); }else if(i == SEQHOUND_ERROR){ this.SHoundLogError(SH_warn, "[SeqHoundIsTaxDeleted]: ".concat(ERROR_STATEMENT)); }else if(i == SEQHOUND_NULL){ this.SHoundLogError(SH_warn, "[SeqHoundIsTaxDeleted]: ".concat(NULL_STATEMENT)); }else{ this.SHoundLogError(SH_warn, "[SeqHoundIsTaxDeleted]: ".concat(ABNORMAL_STATEMENT)); } return false; } /** * gets a taxon name in a specified style * @param taxid a taxonomy identifier * @param nameClass one of: *
SLRI_taxon_name_name_class_none *
SLRI_taxon_name_name_class_acronym *
SLRI_taxon_name_name_class_anamorph *
SLRI_taxon_name_name_class_blast_name *
SLRI_taxon_name_name_class_common_name *
SLRI_taxon_name_name_class_equivalent_name *
SLRI_taxon_name_name_class_includes *
SLRI_taxon_name_name_class_in_part *
SLRI_taxon_name_name_class_misnomer *
SLRI_taxon_name_name_class_misspelling *
SLRI_taxon_name_name_class_preferred_acronym *
SLRI_taxon_name_name_class_preferred_common_name *
SLRI_taxon_name_name_class_scientific_name *
SLRI_taxon_name_name_class_synonym *
SLRI_taxon_name_name_class_teleomorph *
SLRI_taxon_name_name_class_other * @return a taxon name * @throws IOException */ public String SHoundGetTaxNameFromTaxIDByClass(int taxid, String nameClass) throws IOException { if(nameClass == null){ this.SHoundLogError(SH_severe, "[SHoundGetTaxNameFromTaxIDByClass] Null string error: nameClass"); return null; } if(taxid <= 0){ this.SHoundLogError(SH_severe, "[SHoundGetTaxNameFromTaxIDByClass] Invalid taxid."); return null; } int j = this._DecipherNameClass(nameClass); String args = "taxid=".concat(String.valueOf(taxid)); args += "&type=".concat(String.valueOf(j)); String address = this.GetFunctionCall("SeqHoundGetTaxNameFromTaxIDByClass", args); this.SHoundLogError(SH_info, "[SeqHoundGetTaxNameFromTaxIDByClass]: ".concat(args)); int i; StringBuffer result = new StringBuffer(); if((i = this.ProcessContents(address, result)) == SEQHOUND_OK){ return result.toString(); }else if(i == SEQHOUND_ERROR){ this.SHoundLogError(SH_warn, "[SeqHoundGetTaxNameFromTaxIDByClass]: ".concat(ERROR_STATEMENT)); }else if(i == SEQHOUND_NULL){ this.SHoundLogError(SH_warn, "[SeqHoundGetTaxNameFromTaxIDByClass]: ".concat(NULL_STATEMENT)); }else{ this.SHoundLogError(SH_warn, "[SeqHoundGetTaxNameFromTaxIDByClass]: ".concat(ABNORMAL_STATEMENT)); } return null; } /** * fetches a taxonomy name in scientific form * @param taxid * @return a taxonomy name * @throws IOException */ public String SHoundGetTaxNameFromTaxID(int taxid) throws IOException { if(taxid <= 0){ this.SHoundLogError(SH_severe, "[SHoundGetTaxNameFromTaxID] Invalid taxid."); return null; } String args = "taxid=".concat(String.valueOf(taxid)); String address = this.GetFunctionCall("SeqHoundGetTaxNameFromTaxID", args); this.SHoundLogError(SH_info, "[SeqHoundGetTaxNameFromTaxID]: ".concat(args)); int i; StringBuffer result = new StringBuffer(); if((i = this.ProcessContents(address, result)) == SEQHOUND_OK){ return result.toString(); }else if(i == SEQHOUND_ERROR){ this.SHoundLogError(SH_warn, "[SeqHoundGetTaxNameFromTaxID]: ".concat(ERROR_STATEMENT)); }else if(i == SEQHOUND_NULL){ this.SHoundLogError(SH_warn, "[SeqHoundGetTaxNameFromTaxID]: ".concat(NULL_STATEMENT)); }else{ this.SHoundLogError(SH_warn, "[SeqHoundGetTaxNameFromTaxID]: ".concat(ABNORMAL_STATEMENT)); } return null; } /** * fetches a taxonomy lineage in a specified form. * @param taxid a taxonomy id * @param type a string specifying the form. One of: *
SHoundGetTaxLineage_FULL *
SHoundGetTaxLineage_GENBANK *
SHoundGetTaxLineage_TAXDBSHORT * @return a taxonomy lineage * @throws IOException */ public String SHoundGetTaxLineageFromTaxID(int taxid, String type) throws IOException { if(taxid <= 0){ this.SHoundLogError(SH_severe, "[SHoundGetTaxLineageFromTaxID] Invalid taxid"); return null; } if(type == null){ this.SHoundLogError(SH_severe, "[SHoundGetTaxLineageFromTaxID] Null string error: type."); return null; } String args = "taxid=".concat(String.valueOf(taxid)); int j = this._DecodeTaxLineage(type); args += "&type=".concat(String.valueOf(j)); String address = this.GetFunctionCall("SeqHoundGetTaxLineageFromTaxID", args); this.SHoundLogError(SH_info, "[SeqHoundGetTaxLineageFromTaxID]: ".concat(args)); int i; StringBuffer result = new StringBuffer(); if((i = this.ProcessContents(address, result)) == SEQHOUND_OK){ return result.toString(); }else if(i == SEQHOUND_ERROR){ this.SHoundLogError(SH_warn, "[SeqHoundGetTaxNameFromTaxID]: ".concat(ERROR_STATEMENT)); }else if(i == SEQHOUND_NULL){ this.SHoundLogError(SH_warn, "[SeqHoundGetTaxNameFromTaxID]: ".concat(NULL_STATEMENT)); }else{ this.SHoundLogError(SH_warn, "[SeqHoundGetTaxNameFromTaxID]: ".concat(ABNORMAL_STATEMENT)); } return null; } /** * retrieves an array of gi with specified the specified gene ontology identifier * @param go the gene ontology identifier * @return an array of gi's * @throws IOException */ public int[] SHoundGiFromGOID(int go) throws IOException { if(go <= 0){ this.SHoundLogError(SH_severe, "[SHoundGiFromGOID] Invalid go."); return null; } String args = "goid=".concat(String.valueOf(go)); String address = this.GetFunctionCall("SeqHoundGiFromGOID", args); this.SHoundLogError(SH_info, "[SeqHoundGiFromGOID]: ".concat(args)); int i; StringBuffer result = new StringBuffer(); if((i = this.ProcessContents(address, result)) == SEQHOUND_OK){ return SLRIMisc.StrInt2IntArr(result.toString(), ","); }else if(i == SEQHOUND_ERROR){ this.SHoundLogError(SH_warn, "[SeqHoundGiFromGOID]: ".concat(ERROR_STATEMENT)); }else if(i == SEQHOUND_NULL){ this.SHoundLogError(SH_warn, "[SeqHoundGiFromGOID]: ".concat(NULL_STATEMENT)); }else{ this.SHoundLogError(SH_warn, "[SeqHoundGiFromGOID]: ".concat(ABNORMAL_STATEMENT)); } return null; } /** * retrieves an array of gis that have been annotated with the specified goid * @param goList the array of goid * @return an array of gi's * @throws IOException */ public int[] SHoundGiFromGOIDList(int[] goList) throws IOException { if(goList == null){ this.SHoundLogError(SH_severe, "[SHoundGiFromGOIDList] Empty array: goList"); return null; } if(goList.length < 1){ this.SHoundLogError(SH_severe, "[SHoundGiFromGOIDList] Empty array: goList"); return null; } Vector tmpV = SLRIMisc.CopyArray(goList); int[] iRet = new int[0]; String args, address; StringBuffer result; while(tmpV.size() > 0){ result = new StringBuffer(); int[] itmp = SLRIMisc.MaxSizeIntList(tmpV); args = "vnpgo=".concat(SLRIMisc.SaveArrAsString(itmp)); address = this.GetFunctionCall("SeqHoundGiFromGOIDList", args); this.SHoundLogError(SH_info, "[SeqHoundGiFroMGOIDList]: ".concat(args)); int i; if((i = this.ProcessContents(address, result)) == SEQHOUND_OK){ iRet = SLRIMisc.MergeLists(iRet, SLRIMisc.StrInt2IntArr(result.toString(), ",")); }else if(i == SEQHOUND_ERROR){ this.SHoundLogError(SH_warn, "[SeqHoundGiFromGOIDList]: ".concat(ERROR_STATEMENT)); }else if(i == SEQHOUND_NULL){ this.SHoundLogError(SH_warn, "[SeqHoundGiFromGOIDList]: ".concat(NULL_STATEMENT)); }else{ this.SHoundLogError(SH_warn, "[SeqHoundGiFromGOIDList]: ".concat(ABNORMAL_STATEMENT)); } } return iRet; } /** * retrieves an array of gis that have been annotated with the specified goid list and * the evidence code * @param goList the array of goid * @param ecode the go evidence code * @return an array of gi's * @throws IOException */ public int[] SHoundGiFromGOIDListAndECode(int[] goList, String ecode) throws IOException { if(goList == null){ this.SHoundLogError(SH_severe, "[SHoundGiFromGOIDListAndECode] Empty array: goList"); return null; } if(goList.length < 1){ this.SHoundLogError(SH_severe, "[SHoundGiFromGOIDListAndECode] Empty array: goList"); return null; } if (ecode == null) { this.SHoundLogError(SH_severe, "[SHoundGiFromGOIDListAndECode] Null string error: ecode"); return null; } Vector tmpV = SLRIMisc.CopyArray(goList); int[] iRet = new int[0]; String args, address; StringBuffer result; while(tmpV.size() > 0){ result = new StringBuffer(); int[] itmp = SLRIMisc.MaxSizeIntList(tmpV); args = "golist=".concat(SLRIMisc.SaveArrAsString(itmp))+"&ecode=".concat(ecode);; address = this.GetFunctionCall("SeqHoundGiFromGOIDListAndECode", args); this.SHoundLogError(SH_info, "[SeqHoundGiFromGOIDListAndECode]: ".concat(args)); int i; if((i = this.ProcessContents(address, result)) == SEQHOUND_OK){ iRet = SLRIMisc.MergeLists(iRet, SLRIMisc.StrInt2IntArr(result.toString(), ",")); }else if(i == SEQHOUND_ERROR){ this.SHoundLogError(SH_warn, "[SeqHoundGiFromGOIDListAndECode]: ".concat(ERROR_STATEMENT)); }else if(i == SEQHOUND_NULL){ this.SHoundLogError(SH_warn, "[SeqHoundGiFromGOIDListAndECode]: ".concat(NULL_STATEMENT)); }else{ this.SHoundLogError(SH_warn, "[SeqHoundGiFromGOIDListAndECode]: ".concat(ABNORMAL_STATEMENT)); } } return iRet; } /** * retrieves an array of goid for a specified gi * @param gi the gi * @return an array of goid's * @throws IOException */ public int[] SHoundGOIDFromGi(int gi) throws IOException { if(gi <= 0){ this.SHoundLogError(SH_severe, "[SHoundGOIDFromGi] Invalid gi."); return null; } String args = "gi=".concat(String.valueOf(gi)); String address = this.GetFunctionCall("SeqHoundGOIDFromGi", args); this.SHoundLogError(SH_info, "[SeqHoundGOIDFromGi]: ".concat(args)); int i; StringBuffer result = new StringBuffer(); if((i = this.ProcessContents(address, result)) == SEQHOUND_OK){ return SLRIMisc.StrInt2IntArr(result.toString(), ","); }else if(i == SEQHOUND_ERROR){ this.SHoundLogError(SH_warn, "[SeqHoundGOIDFromGi]: ".concat(ERROR_STATEMENT)); }else if(i == SEQHOUND_NULL){ this.SHoundLogError(SH_warn, "[SeqHoundGOIDFromGi]: ".concat(NULL_STATEMENT)); }else{ this.SHoundLogError(SH_warn, "[SeqHoundGOIDFromGi]: ".concat(ABNORMAL_STATEMENT)); } return null; } /** * retrieves an array of goid for a specified array of gi's * @param giList the array of gi's * @return an array of goid's * @throws IOException */ public int[] SHoundGOIDFromGiList(int[] giList) throws IOException { if(giList == null){ this.SHoundLogError(SH_severe, "[SHoundGOIDFromGiList] Empty array: giList."); return null; } if(giList.length < 1){ this.SHoundLogError(SH_severe, "[SHoundGOIDFromGiList] Empty array: giList."); return null; } Vector tmpV = SLRIMisc.CopyArray(giList); int[] iRet = new int[0]; String args, address; StringBuffer result; while(tmpV.size() > 0){ result = new StringBuffer(); int[] itmp = SLRIMisc.MaxSizeIntList(tmpV); args = "vnpgi=".concat(SLRIMisc.SaveArrAsString(itmp)); address = this.GetFunctionCall("SeqHoundGOIDFromGiList", args); this.SHoundLogError(SH_info, "[SeqHoundGOIDFromGiList]: ".concat(args)); int i; if((i =this.ProcessContents(address, result)) == SEQHOUND_OK){ iRet = SLRIMisc.MergeLists(iRet, SLRIMisc.StrInt2IntArr(result.toString(), ",")); }else if(i == SEQHOUND_ERROR){ this.SHoundLogError(SH_warn, "[SeqHoundGOIDFromGiList]: ".concat(ERROR_STATEMENT)); }else if(i == SEQHOUND_NULL){ this.SHoundLogError(SH_warn, "[SeqHoundGOIDFromGiList]: ".concat(NULL_STATEMENT)); }else{ this.SHoundLogError(SH_warn, "[SeqHoundGOIDFromGiList]: ".concat(ABNORMAL_STATEMENT)); } } return iRet; } /** * Return all the gi's with the given goid and evidence code. * @param goid a gene ontology identifier * @param ecode an evidence code * @return an array of gi's * @throws IOException */ public int[] SHoundGiFromGOIDAndECode(int goid, String ecode) throws IOException { if(goid <= 0 || ecode == null){ this.SHoundLogError(SH_severe, "[SHoundGiFromGOIDAndECode] Invalid goid or ecode is NULL."); return null; } String args = "goid=".concat(String.valueOf(goid))+"&ecode=".concat(ecode); String address = this.GetFunctionCall("SeqHoundGiFromGOIDAndECode", args); this.SHoundLogError(SH_info, "[SeqHoundGiFromGOIDAndECode]: ".concat(args)); int i; StringBuffer result = new StringBuffer(); if((i = this.ProcessContents(address, result)) == SEQHOUND_OK){ return (SLRIMisc.StrInt2IntArr(result.toString(), ",")); }else if(i == SEQHOUND_ERROR){ this.SHoundLogError(SH_warn, "[SeqHoundGiFromGOIDAndECode]: ".concat(ERROR_STATEMENT)); }else if(i == SEQHOUND_NULL){ this.SHoundLogError(SH_warn, "[SeqHoundGiFromGOIDAndECode]: ".concat(NULL_STATEMENT)); }else{ this.SHoundLogError(SH_warn, "[SeqHoundGiFromGOIDAndECode]: ".concat(ABNORMAL_STATEMENT)); } return null; } /** * Retrieves an array of goid (Gene Ontology identifiers) from a protein gi. * Uses redundancy information for the query gi identifier. * This means that if the query fails for the input gi identifier, * then the query will be retried for all other gi identifiers that belong * to the same redundant group. * @param gi the gi * @return an array of goid * @throws IOException */ public int[] SHoundGOIDFromRedundantGi(int gi) throws IOException { if(gi <= 0){ this.SHoundLogError(SH_severe, "[SHoundGOIDFromRedundantGi] Invalid gi."); return null; } String args = "gi=".concat(String.valueOf(gi)); String address = this.GetFunctionCall("SeqHoundGOIDFromRedundantGi", args); this.SHoundLogError(SH_info, "[SeqHoundGOIDFromRedundantGi]: ".concat(args)); int i; StringBuffer result = new StringBuffer(); if((i = this.ProcessContents(address, result)) == SEQHOUND_OK){ return SLRIMisc.StrInt2IntArr(result.toString(), ","); }else if(i == SEQHOUND_ERROR){ this.SHoundLogError(SH_warn, "[SeqHoundGOIDFromGiList]: ".concat(ERROR_STATEMENT)); }else if(i == SEQHOUND_NULL){ this.SHoundLogError(SH_warn, "[SeqHoundGOIDFromGiList]: ".concat(NULL_STATEMENT)); }else{ this.SHoundLogError(SH_warn, "[SeqHoundGOIDFromGiList]: ".concat(ABNORMAL_STATEMENT)); } return null; } /** * Retrieves an array of goid (Gene Ontology identifiers) from a * given array of protein gi's * Uses redundancy information for the query gi identifier. * This means that if the query fails for the input gi identifier, * then the query will be retried for all other gi identifiers that belong * to the same redundant group. * @param giList the gi array * @return an array of goid * @throws IOException */ public int[] SHoundGOIDFromRedundantGiList(int[] giList) throws IOException { if(giList == null){ this.SHoundLogError(SH_severe, "[SHoundGOIDFromRedundantGiList] Empty array: giList"); return null; } if(giList.length < 1){ this.SHoundLogError(SH_severe, "[SHoundGOIDFromRedundantGiList] Empty array: giList"); return null; } Vector tmpV = SLRIMisc.CopyArray(giList); int[] iRet = new int[0]; String args, address; StringBuffer result; while(tmpV.size() > 0){ result = new StringBuffer(); int[] itmp = SLRIMisc.MaxSizeIntList(tmpV); args = "vnpgi=".concat(SLRIMisc.SaveArrAsString(itmp)); address = this.GetFunctionCall("SeqHoundGOIDFromRedundantGiList", args); this.SHoundLogError(SH_info, "[SeqHoundGOIDFromRedundantGiList]: ".concat(args)); int i; if((i = this.ProcessContents(address, result)) == SEQHOUND_OK){ iRet = SLRIMisc.MergeLists(iRet, SLRIMisc.StrInt2IntArr(result.toString(), ",")); }else if(i == SEQHOUND_ERROR){ this.SHoundLogError(SH_warn, "[SeqHoundGOIDFromRedundantGiList]: ".concat(ERROR_STATEMENT)); }else if(i == SEQHOUND_NULL){ this.SHoundLogError(SH_warn, "[SeqHoundGOIDFromRedundantGiList]: ".concat(NULL_STATEMENT)); }else{ this.SHoundLogError(SH_warn, "[SeqHoundGOIDFromRedundantGiList]: ".concat(ABNORMAL_STATEMENT)); } } return iRet; } /** * retrieves a gene ontology evidence code for a given gi * @param gi the gi * @return an evidence code * @throws IOException */ /* public String SHoundGOECodeFromGi(int gi) throws IOException { if(gi <= 0){ this.SHoundLogError(SH_severe, "[SHoundGOECodeFromGi] Invalid gi."); return null; } String args = "gi=".concat(String.valueOf(gi)); String address = this.GetFunctionCall("SeqHoundGOECodeFromGi", args); this.SHoundLogError(SH_info, "[SeqHoundGOECodeFromGi]: ".concat(args)); int i; StringBuffer result = new StringBuffer(); if((i = this.ProcessContents(address, result)) == SEQHOUND_OK){ return result.toString(); }else if(i == SEQHOUND_ERROR){ this.SHoundLogError(SH_warn, "[SeqHoundGOECodeFromGi]: ".concat(ERROR_STATEMENT)); }else if(i == SEQHOUND_NULL){ this.SHoundLogError(SH_warn, "[SeqHoundGOECodeFromGi]: ".concat(NULL_STATEMENT)); }else{ this.SHoundLogError(SH_warn, "[SeqHoundGOECodeFromGi]: ".concat(ABNORMAL_STATEMENT)); } return null; } */ /** * get an array of pmids for a given gi * @param gi the gi * @return an array of pmids * @throws IOException */ /* public int[] SHoundGOPMIDFromGi(int gi) throws IOException { if(gi <= 0){ this.SHoundLogError(SH_severe, "[SHoundGOPMID] Invalid gi."); return null; } String args = "gi=".concat(String.valueOf(gi)); String address = this.GetFunctionCall("SeqHoundGOPMIDFromGi", args); this.SHoundLogError(SH_info, "[SeqHoundGOPMIDFromGi]: ".concat(args)); int i; StringBuffer result = new StringBuffer(); if((i = this.ProcessContents(address, result)) == SEQHOUND_OK){ return (SLRIMisc.StrInt2IntArr(result.toString(), ",")); }else if(i == SEQHOUND_ERROR){ this.SHoundLogError(SH_warn, "[SeqHoundGOPMIDFromGi]: ".concat(ERROR_STATEMENT)); }else if(i == SEQHOUND_NULL){ this.SHoundLogError(SH_warn, "[SeqHoundGOPMIDFromGi]: ".concat(NULL_STATEMENT)); }else{ this.SHoundLogError(SH_warn, "[SeqHoundGOPMIDFromGi]: ".concat(ABNORMAL_STATEMENT)); } return null; } */ /** * retrieves an array of protein gi with the domain specified by input * @param cddid the domain identifier * @return an array of protein gi's * @throws IOException */ public int[] SHoundGiFromCDDID(String cddid) throws IOException { if(cddid == null){ this.SHoundLogError(SH_severe, "[SHoundGiFromCDDID] Null string error: cddid."); return null; } String args = "cddid=".concat(cddid); String address = this.GetFunctionCall("SeqHoundGiFromCDDID", args); this.SHoundLogError(SH_info, "[SeqHoundGiFromCDDID]: ".concat(args)); int i; StringBuffer result = new StringBuffer(); if((i = this.ProcessContents(address, result)) == SEQHOUND_OK){ return (SLRIMisc.StrInt2IntArr(result.toString(), ",")); }else if(i == SEQHOUND_ERROR){ this.SHoundLogError(SH_warn, "[SeqHoundGiFromCDDID]: ".concat(ERROR_STATEMENT)); }else if(i == SEQHOUND_NULL){ this.SHoundLogError(SH_warn, "[SeqHoundGiFromCDDID]: ".concat(NULL_STATEMENT)); }else{ this.SHoundLogError(SH_warn, "[SeqHoundGiFromCDDID]: ".concat(ABNORMAL_STATEMENT)); } return null; } /** * get the protein gi's with the specified domains * @param cddidList an array of domain identifiers * @return an array of protein gi's * @throws IOException */ public int[] SHoundGiFromCDDIDList(String[] cddidList) throws IOException { if(cddidList == null){ this.SHoundLogError(SH_severe, "[SHoundGiFromCDDIDList] Empty array: cddidList"); return null; } if(cddidList.length < 1){ this.SHoundLogError(SH_severe, "[SHoundGiFromCDDIDList] Empty array: cddidList"); return null; } Vector tmpV = SLRIMisc.CopyArray(cddidList); int[] iRet = new int[0]; String args, address; StringBuffer result; while(tmpV.size() > 0){ result = new StringBuffer(); String[] itmp = SLRIMisc.MaxSizeStrList(tmpV); args = "vnpcdd=".concat(SLRIMisc.SaveArrAsString(itmp)); address = this.GetFunctionCall("SeqHoundGiFromCDDIDList", args); this.SHoundLogError(SH_info, "[SeqHoundGiFromCDDIDList]: ".concat(args)); int i; if((i = this.ProcessContents(address, result)) == SEQHOUND_OK){ iRet = SLRIMisc.MergeLists(iRet, SLRIMisc.StrInt2IntArr(result.toString(), ",")); }else if(i == SEQHOUND_ERROR){ this.SHoundLogError(SH_warn, "[SeqHoundGiFromCDDIDList]: ".concat(ERROR_STATEMENT)); }else if(i == SEQHOUND_NULL){ this.SHoundLogError(SH_warn, "[SeqHoundGiFromCDDIDList]: ".concat(NULL_STATEMENT)); }else{ this.SHoundLogError(SH_warn, "[SeqHoundGiFromCDDIDList]: ".concat(ABNORMAL_STATEMENT)); } } return iRet; } /** * retrieves the domains for a specified protein gi. * Information returned by this function was originally retrieved * for proteins found in NCBI's LocusLink database. * If the query protein gi identifier is not used by the LocusLink record * then no information will be returned. * The query protein gi identifier could be used to first retrieve * a list of redundant (identical) sequence gi identifiers * using {@link #SHoundRedundantGroup(int)} and then using these returned * protein gi identifiers to query the LocusLink data. * For more conserved domain information (for all proteins found * in NCBI's nr dataset) see API functions under RPS BLAST DOMAINS * @param gi the gi (must be a protein gi identifier) * @return an array of domain identifiers * @throws IOException */ public String[] SHoundCDDIDFromGi(int gi) throws IOException { if(gi <= 0){ this.SHoundLogError(SH_severe, "[SHoundCDDIDFromGi] Invalid gi."); return null; } String args = "gi=".concat(String.valueOf(gi)); String address = this.GetFunctionCall("SeqHoundCDDIDFromGi", args); this.SHoundLogError(SH_info, "[SeqHoundCDDIDFromGi]: ".concat(args)); int i; StringBuffer result = new StringBuffer(); if((i = this.ProcessContents(address, result)) == SEQHOUND_OK){ return SLRIMisc.StrStr2StrArr(result.toString(), ","); }else if(i == SEQHOUND_ERROR){ this.SHoundLogError(SH_warn, "[SeqHoundCDDIDFromGi]: ".concat(ERROR_STATEMENT)); }else if(i == SEQHOUND_NULL){ this.SHoundLogError(SH_warn, "[SeqHoundCDDIDFromGi]: ".concat(NULL_STATEMENT)); }else{ this.SHoundLogError(SH_warn, "[SeqHoundCDDIDFromGi]: ".concat(ABNORMAL_STATEMENT)); } return null; } /** * retrieve the domain identifiers for a specified protein gi array. * Information returned by this function was originally retrieved * for proteins found in NCBI's LocusLink database. * If the query protein gi identifier is not used by the LocusLink record * then no information will be returned. * The query protein gi identifier could be used to first retrieve * a list of redundant (identical) sequence gi identifiers * using {@link #SHoundRedundantGroup(int)} and then using these returned * protein gi identifiers to query the LocusLink data. * For more conserved domain information (for all proteins found * in NCBI's nr dataset) see API functions under RPS BLAST DOMAINS * @param giList an array of gi's (must be protein gi identifiers) * @return an array of domain names * @throws IOException */ public String[] SHoundCDDIDFromGiList(int[] giList) throws IOException { if(giList == null){ this.SHoundLogError(SH_severe, "[SHoundCDDIDFromGiList] Empty array: giList"); return null; } if(giList.length < 1){ this.SHoundLogError(SH_severe, "[SHoundCDDIDFromGiList] Empty array: giList"); return null; } Vector tmpV = SLRIMisc.CopyArray(giList); String[] strRet = new String[0]; String args, address; StringBuffer result; while(tmpV.size() > 0){ result = new StringBuffer(); int[] itmp = SLRIMisc.MaxSizeIntList(tmpV); args = "vnpgi=".concat(SLRIMisc.SaveArrAsString(itmp)); address = this.GetFunctionCall("SeqHoundCDDIDFromGiList", args); this.SHoundLogError(SH_info, "[SeqHoundCDDIDFromGiList]: ".concat(args)); int i; if((i = this.ProcessContents(address, result)) == SEQHOUND_OK){ strRet = SLRIMisc.MergeLists(strRet, SLRIMisc.StrStr2StrArr(result.toString(), ",")); }else if(i == SEQHOUND_ERROR){ this.SHoundLogError(SH_warn, "[SeqHoundCDDIDFromGiList]: ".concat(ERROR_STATEMENT)); }else if(i == SEQHOUND_NULL){ this.SHoundLogError(SH_warn, "[SeqHoundCDDIDFromGiList]: ".concat(NULL_STATEMENT)); }else{ this.SHoundLogError(SH_warn, "[SeqHoundCDDIDFromGiList]: ".concat(ABNORMAL_STATEMENT)); } } return strRet; } /** * retrieves protein gi's from an omim * @param omimid the omid identifier * @return an array of protein gi's * @throws IOException */ public int[] SHoundGiFromOMIM(int omimid) throws IOException { if(omimid <= 0){ this.SHoundLogError(SH_severe, "[SHoundGiFromOMIM] Invalid omimid."); return null; } String args = "omimid=".concat(String.valueOf(omimid)); String address = this.GetFunctionCall("SeqHoundGiFromOMIM", args); this.SHoundLogError(SH_info, "[SeqHoundGiFromOMIM]: ".concat(args)); int i; StringBuffer result = new StringBuffer(); if((i = this.ProcessContents(address, result)) == SEQHOUND_OK){ return (SLRIMisc.StrInt2IntArr(result.toString(), ",")); }else if(i == SEQHOUND_ERROR){ this.SHoundLogError(SH_warn, "[SeqHoundGiFromOMIM]: ".concat(ERROR_STATEMENT)); }else if(i == SEQHOUND_NULL){ this.SHoundLogError(SH_warn, "[SeqHoundGiFromOMIM]: ".concat(NULL_STATEMENT)); }else{ this.SHoundLogError(SH_warn, "[SeqHoundGiFromOMIM]: ".concat(ABNORMAL_STATEMENT)); } return null; } /** * retrieves protein gi's associated with a omim * @param omimList an array of omim * @return an array of protein gi's * @throws IOException */ public int[] SHoundGiFromOMIMList(int[] omimList) throws IOException { if(omimList == null){ this.SHoundLogError(SH_severe, "[SHoundGiFromOMIMList] Empty array: omimList."); return null; } if(omimList.length < 1){ this.SHoundLogError(SH_severe, "[SHoundGiFromOMIMList] Empty array: omimList."); return null; } Vector tmpV = SLRIMisc.CopyArray(omimList); int[] iRet = new int[0]; String args, address; StringBuffer result; while(tmpV.size() > 0){ result = new StringBuffer(); int[] itmp = SLRIMisc.MaxSizeIntList(tmpV); args = "vnpomim=".concat(SLRIMisc.SaveArrAsString(itmp)); address = this.GetFunctionCall("SeqHoundGiFromOMIMList", args); this.SHoundLogError(SH_info, "[SeqHoundGiFromOMIMList]: ".concat(args)); int i; if((i = this.ProcessContents(address, result)) == SEQHOUND_OK){ iRet = SLRIMisc.MergeLists(iRet, SLRIMisc.StrInt2IntArr(result.toString(), ",")); }else if(i == SEQHOUND_ERROR){ this.SHoundLogError(SH_warn, "[SeqHoundGiFromOMIMList]: ".concat(ERROR_STATEMENT)); }else if(i == SEQHOUND_NULL){ this.SHoundLogError(SH_warn, "[SeqHoundGiFromOMIMList]: ".concat(NULL_STATEMENT)); }else{ this.SHoundLogError(SH_warn, "[SeqHoundGiFromOMIMList]: ".concat(ABNORMAL_STATEMENT)); } } return iRet; } /** * retrieves omim associated with a protein gi * @param gi the gi (must be protein gi identifier) * @return an array of omim * @throws IOException */ public int[] SHoundOMIMFromGi(int gi) throws IOException { if(gi <= 0){ this.SHoundLogError(SH_severe, "[SHoundOMIMFromGi] Invalid gi."); return null; } String args = "gi=".concat(String.valueOf(gi)); String address = this.GetFunctionCall("SeqHoundOMIMFromGi", args); this.SHoundLogError(SH_info, "[SeqHoundOMIMFromGi]: ".concat(args)); int i; StringBuffer result = new StringBuffer(); if((i = this.ProcessContents(address, result)) == SEQHOUND_OK){ return (SLRIMisc.StrInt2IntArr(result.toString(), ",")); }else if(i == SEQHOUND_ERROR){ this.SHoundLogError(SH_warn, "[SeqHoundOMIMFromGi]: ".concat(ERROR_STATEMENT)); }else if(i == SEQHOUND_NULL){ this.SHoundLogError(SH_warn, "[SeqHoundOMIMFromGi]: ".concat(NULL_STATEMENT)); }else{ this.SHoundLogError(SH_warn, "[SeqHoundOMIMFromGi]: ".concat(ABNORMAL_STATEMENT)); } return null; } /** * get the associated omim for an array of protein gi's * @param giList the gi array (must be protein gi identifiers) * @return an array of omim's * @throws IOException */ public int[] SHoundOMIMFromGiList(int[] giList) throws IOException { if(giList == null){ this.SHoundLogError(SH_severe, "[SHoundOMIMFromGiList] Empty array: giList."); return null; } if(giList.length < 1){ this.SHoundLogError(SH_severe, "[SHoundOMIMFromGiList] Empty array: giList."); return null; } Vector tmpV = SLRIMisc.CopyArray(giList); int[] iRet = new int[0]; String args, address; StringBuffer result; while(tmpV.size() > 0){ result = new StringBuffer(); int[] itmp = SLRIMisc.MaxSizeIntList(tmpV); args = "vnpgi=".concat(SLRIMisc.SaveArrAsString(itmp)); address = this.GetFunctionCall("SeqHoundOMIMFromGiList", args); this.SHoundLogError(SH_info, "[SeqHoundOMIMFromGiList]: ".concat(args)); int i; if((i = this.ProcessContents(address, result)) == SEQHOUND_OK){ iRet = SLRIMisc.MergeLists(iRet, SLRIMisc.StrInt2IntArr(result.toString(), ",")); }else if(i == SEQHOUND_ERROR){ this.SHoundLogError(SH_warn, "[SeqHoundOMIMFromGiList]: ".concat(ERROR_STATEMENT)); }else if(i == SEQHOUND_NULL){ this.SHoundLogError(SH_warn, "[SeqHoundOMIMFromGiList]: ".concat(NULL_STATEMENT)); }else{ this.SHoundLogError(SH_warn, "[SeqHoundOMIMFromGiList]: ".concat(ABNORMAL_STATEMENT)); } } return iRet; } /** * Get the score for a Conserved domain database domain. * Information returned by this function was originally retrieved * for proteins found in NCBI's LocusLink database. * If the query protein gi identifier is not used by the LocusLink record * then no information will be returned. * The query protein gi identifier could be used to first retrieve * a list of redundant (identical) sequence gi identifiers * using {@link #SHoundRedundantGroup(int)} and then using these returned * protein gi identifiers to query the LocusLink data. * Note that currently this function does not return meaningful results * because there are no evalues associated with the records. * @param gi the gi (must be protein gi identifier) * @param cddid the CDD identifier * @return an CDD score * @throws IOException */ public float SHoundCDDScoreFromGi(int gi, String cddid) throws IOException { if(gi <= 0){ this.SHoundLogError(SH_severe, "[SHoundCDDScoreFromGi] Invalid gi."); return SEQHOUND_ERROR; } if(cddid == null){ this.SHoundLogError(SH_severe, "[SHoundCDDScoreFromGi] Null string error: cddid."); return SEQHOUND_ERROR; } String args = "gi=".concat(String.valueOf(gi)); args += "&cddid=".concat(cddid); String address = this.GetFunctionCall("SeqHoundCDDScoreFromGi", args); this.SHoundLogError(SH_info, "[SeqHoundCDDScoreFromGi]: ".concat(args)); int i; StringBuffer result = new StringBuffer(); if((i = this.ProcessContents(address, result)) == SEQHOUND_OK){ return Float.parseFloat(result.toString()); }else if(i == SEQHOUND_ERROR){ this.SHoundLogError(SH_warn, "[SeqHoundCDDScoreFromGi]: ".concat(ERROR_STATEMENT)); }else if(i == SEQHOUND_NULL){ this.SHoundLogError(SH_warn, "[SeqHoundCDDScoreFromGi]: ".concat(NULL_STATEMENT)); }else{ this.SHoundLogError(SH_warn, "[SeqHoundCDDScoreFromGi]: ".concat(ABNORMAL_STATEMENT)); } return SEQHOUND_ERROR; } /** * Get protein gi associated with a locuslink identifier * @param llid a locuslink id * @return an array of gi's * @throws IOException */ public int[] SHoundGiFromLLID(int llid) throws IOException { if(llid <= 0){ this.SHoundLogError(SH_severe, "[SHoundGiFromLLID] Invalid llid."); return null; } String args = "llid=".concat(String.valueOf(llid)); String address = this.GetFunctionCall("SeqHoundGiFromLLID", args); this.SHoundLogError(SH_info, "[SeqHoundGiFromLLID]: ".concat(args)); int i; StringBuffer result = new StringBuffer(); if((i = this.ProcessContents(address, result)) == SEQHOUND_OK){ return (SLRIMisc.StrInt2IntArr(result.toString(), ",")); }else if(i == SEQHOUND_ERROR){ this.SHoundLogError(SH_warn, "[SeqHoundGiFromLLID]: ".concat(ERROR_STATEMENT)); }else if(i == SEQHOUND_NULL){ this.SHoundLogError(SH_warn, "[SeqHoundGiFromLLID]: ".concat(NULL_STATEMENT)); }else{ this.SHoundLogError(SH_warn, "[SeqHoundGiFromLLID]: ".concat(ABNORMAL_STATEMENT)); } return null; } /** * get the protein gi's associated with the locuslink id * @param llidList an array of locuslink id * @return an array of gi's * @throws IOException */ public int[] SHoundGiFromLLIDList(int[] llidList) throws IOException { if(llidList == null){ this.SHoundLogError(SH_severe, "[SHoundGiFromLLIDList] Empty array: llidList."); return null; } if(llidList.length < 1){ this.SHoundLogError(SH_severe, "[SHoundGiFromLLIDList] Empty array: llidList."); return null; } Vector tmpV = SLRIMisc.CopyArray(llidList); int[] iRet = new int[0]; String args, address; StringBuffer result; while(tmpV.size() > 0){ result = new StringBuffer(); int[] itmp = SLRIMisc.MaxSizeIntList(tmpV); args = "vnpll=".concat(SLRIMisc.SaveArrAsString(itmp)); address = this.GetFunctionCall("SeqHoundGiFromLLIDList", args); this.SHoundLogError(SH_info, "[SeqHoundGiFromLLIDList]: ".concat(args)); int i; if((i = this.ProcessContents(address, result)) == SEQHOUND_OK){ iRet = SLRIMisc.MergeLists(iRet,SLRIMisc.StrInt2IntArr(result.toString(), ",")); }else if(i == SEQHOUND_ERROR){ this.SHoundLogError(SH_warn, "[SeqHoundGiFromLLIDList]: ".concat(ERROR_STATEMENT)); }else if(i == SEQHOUND_NULL){ this.SHoundLogError(SH_warn, "[SeqHoundGiFromLLIDList]: ".concat(NULL_STATEMENT)); }else{ this.SHoundLogError(SH_warn, "[SeqHoundGiFromLLIDList]: ".concat(ABNORMAL_STATEMENT)); } } return iRet; } /** * retrieves locuslink id for a given protein gi * @param gi the gi (must be protein gi identifier) * @return an array of locuslink id * @throws IOException */ public int[] SHoundLLIDFromGi(int gi) throws IOException { if(gi <= 0){ this.SHoundLogError(SH_severe, "[SHoundLLIDFromGi] Invalid gi."); return null; } String args = "gi=".concat(String.valueOf(gi)); String address = this.GetFunctionCall("SeqHoundLLIDFromGi", args); this.SHoundLogError(SH_info, "[SeqHoundLLIDFromGi]: ".concat(args)); int i; StringBuffer result = new StringBuffer(); if((i = this.ProcessContents(address, result)) == SEQHOUND_OK){ return SLRIMisc.StrInt2IntArr(result.toString(), ","); }else if(i == SEQHOUND_ERROR){ this.SHoundLogError(SH_warn, "[SeqHoundLLIDFromGi]: ".concat(ERROR_STATEMENT)); }else if(i == SEQHOUND_NULL){ this.SHoundLogError(SH_warn, "[SeqHoundLLIDFromGi]: ".concat(NULL_STATEMENT)); }else{ this.SHoundLogError(SH_warn, "[SeqHoundLLIDFromGi]: ".concat(ABNORMAL_STATEMENT)); } return null; } /** * retrievs locuslink id for a given protein gi array * @param giList the array of gi's (must be protein gi identifiers) * @return an array of locuslink id * @throws IOException */ public int[] SHoundLLIDFromGiList(int[] giList) throws IOException { if(giList == null){ this.SHoundLogError(SH_severe, "[SHoundLLIDFromGiList] Empty array: giList."); return null; } if(giList.length < 1){ this.SHoundLogError(SH_severe, "[SHoundLLIDFromGiList] Empty array: giList."); return null; } Vector tmpV = SLRIMisc.CopyArray(giList); int[] iRet = new int[0]; String args, address; StringBuffer result; while(tmpV.size() > 0){ result = new StringBuffer(); int[] itmp = SLRIMisc.MaxSizeIntList(tmpV); args = "vnpgi=".concat(SLRIMisc.SaveArrAsString(itmp)); address = this.GetFunctionCall("SeqHoundLLIDFromGiList", args); this.SHoundLogError(SH_info, "[SeqHoundLLIDFromGiList]: ".concat(args)); int i; if((i = this.ProcessContents(address, result)) == SEQHOUND_OK){ iRet = SLRIMisc.MergeLists(iRet, SLRIMisc.StrInt2IntArr(result.toString(), ",")); }else if(i == SEQHOUND_ERROR){ this.SHoundLogError(SH_warn, "[SeqHoundLLIDFromGiList]: ".concat(ERROR_STATEMENT)); }else if(i == SEQHOUND_NULL){ this.SHoundLogError(SH_warn, "[SeqHoundLLIDFromGiList]: ".concat(NULL_STATEMENT)); }else{ this.SHoundLogError(SH_warn, "[SeqHoundLLIDFromGiList]: ".concat(ABNORMAL_STATEMENT)); } } return iRet; } /** * retrieves the locus for a given protein gi * @param gi the gi (must be protein gi identifier) * @return a locuslink locus * @throws IOException */ public String SHoundLocusFromGi(int gi) throws IOException { if(gi <= 0){ this.SHoundLogError(SH_severe, "[SHoundLocusFromGi] Invalid gi."); return null; } String args = "gi=".concat(String.valueOf(gi)); String address= this.GetFunctionCall("SeqHoundLocusFromGi", args); this.SHoundLogError(SH_info, "[SeqHoundLocusFromGi]: ".concat(args)); int i; StringBuffer result = new StringBuffer(); if((i = this.ProcessContents(address, result)) == SEQHOUND_OK){ return result.toString(); }else if(i == SEQHOUND_ERROR){ this.SHoundLogError(SH_warn, "[SeqHoundLocusFromGi]: ".concat(ERROR_STATEMENT)); }else if(i == SEQHOUND_NULL){ this.SHoundLogError(SH_warn, "[SeqHoundLocusFromGi]: ".concat(NULL_STATEMENT)); }else{ this.SHoundLogError(SH_warn, "[SeqHoundLocusFromGi]: ".concat(ABNORMAL_STATEMENT)); } return null; } /** * retrieve the gene ontology id by geneontology reference type * @param refType the reference type, eg "EC", * @return an array of goid * @throws IOException */ public int[] SHoundGODBGetRecordByReference(String refType) throws IOException { if(refType == null){ this.SHoundLogError(SH_severe, "[SHoundGODBGetRecordByReference] Null string error: refType."); return null; } String args = "refType=".concat(refType); String address = this.GetFunctionCall("SeqHoundGODBGetRecordByReference", args); this.SHoundLogError(SH_info, "[SeqHoundGODBGetRecordByReference]: ".concat(args)); int i; StringBuffer result = new StringBuffer(); if((i = this.ProcessContents(address, result)) == SEQHOUND_OK){ return SLRIMisc.StrInt2IntArr(result.toString(), ","); }else if(i == SEQHOUND_ERROR){ this.SHoundLogError(SH_warn, "[SeqHoundGODBGetRecordByReference]: ".concat(ERROR_STATEMENT)); }else if(i == SEQHOUND_NULL){ this.SHoundLogError(SH_warn, "[SeqHoundGODBGetRecordByReference]: ".concat(NULL_STATEMENT)); }else{ this.SHoundLogError(SH_warn, "[SeqHoundGODBGetRecordByReference]: ".concat(ABNORMAL_STATEMENT)); } return null; } /** * retrieves all the children of a given gene ontology id * @param goid the gene ontology id * @return an array of the goid * @throws IOException */ public int[] SHoundGODBGetChildrenOf(int goid) throws IOException { if(goid <= 0){ this.SHoundLogError(SH_severe, "[SHoundGODBGetChildrenOf] Invalid goid."); return null; } String args = "goid=".concat(String.valueOf(goid)); String address = this.GetFunctionCall("SeqHoundGODBGetChildrenOf", args); this.SHoundLogError(SH_info, "[SeqHoundGODBGetChildrenOf]: ".concat(args)); int i; StringBuffer result = new StringBuffer(); if((i = this.ProcessContents(address, result)) == SEQHOUND_OK){ return SLRIMisc.StrInt2IntArr(result.toString(), ","); }else if(i == SEQHOUND_ERROR){ this.SHoundLogError(SH_warn, "[SeqHoundGODBGetChildrenOf]: ".concat(ERROR_STATEMENT)); }else if(i == SEQHOUND_NULL){ this.SHoundLogError(SH_warn, "[SeqHoundGODBGetChildrenOf]: ".concat(NULL_STATEMENT)); }else{ this.SHoundLogError(SH_warn, "[SeqHoundGODBGetChildrenOf]: ".concat(ABNORMAL_STATEMENT)); } return null; } /** * retrieves an array of the parents of a given goid * @param goid the input gene ontology id * @return an array of goid that are the parent of the input * @throws IOException */ public int[] SHoundGODBGetParentOf(int goid) throws IOException { if(goid <= 0){ this.SHoundLogError(SH_severe, "[SHoundGODBGetParentOf] Invalid goid."); return null; } String args = "goid=".concat(String.valueOf(goid)); String address = this.GetFunctionCall("SeqHoundGODBGetParentOf", args); this.SHoundLogError(SH_info, "[SeqHoundGODBGetParentOf]: ".concat(args)); int i; StringBuffer result = new StringBuffer(); if((i = this.ProcessContents(address, result)) == SEQHOUND_OK){ return SLRIMisc.StrInt2IntArr(result.toString(), ","); }else if(i == SEQHOUND_ERROR){ this.SHoundLogError(SH_warn, "[SeqHoundGODBGetParentOf]: ".concat(ERROR_STATEMENT)); }else if(i == SEQHOUND_NULL){ this.SHoundLogError(SH_warn, "[SeqHoundGODBGetParentOf]: ".concat(NULL_STATEMENT)); }else{ this.SHoundLogError(SH_warn, "[SeqHoundGODBGetParentOf]: ".concat(ABNORMAL_STATEMENT)); } return null; } /** * retrieves all the ancestors (parents, grandparents ...) of a given gene ontology id. * @param goid the goid * @return an array of goid * @throws IOException */ public int[] SHoundGODBGetAllAncestors(int goid) throws IOException { if(goid <= 0){ this.SHoundLogError(SH_severe, "[SHoundGODBGetAllAncestors] Invalid goid."); return null; } String args = "goid=".concat(String.valueOf(goid)); String address = this.GetFunctionCall("SeqHoundGODBGetAllAncestors", args); this.SHoundLogError(SH_info, "[SeqHoundGODBGetAllAncestors]: ".concat(args)); int i; StringBuffer result = new StringBuffer(); if((i = this.ProcessContents(address, result)) == SEQHOUND_OK){ return SLRIMisc.StrInt2IntArr(result.toString(), ","); }else if(i == SEQHOUND_ERROR){ this.SHoundLogError(SH_warn, "[SeqHoundGODBGetAllAncestors]: ".concat(ERROR_STATEMENT)); }else if(i == SEQHOUND_NULL){ this.SHoundLogError(SH_warn, "[SeqHoundGODBGetAllAncestors]: ".concat(NULL_STATEMENT)); }else{ this.SHoundLogError(SH_warn, "[SeqHoundGODBGetAllAncestors]: ".concat(ABNORMAL_STATEMENT)); } return null; } /** * retrieve all children of a given gene ontology id * @param goid a given goid * @return an array of the children of the input * @throws IOException */ public int[] SHoundGODBGetAllChildren(int goid) throws IOException { if(goid <= 0){ this.SHoundLogError(SH_severe, "[SHoundGODBGetAllChildren] Invalid goid."); return null; } String args = "goid=".concat(String.valueOf(goid)); String address = this.GetFunctionCall("SeqHoundGODBGetAllChildren", args); this.SHoundLogError(SH_info, "[SeqHoundGODBGetAllChildren]: ".concat(args)); int i; StringBuffer result = new StringBuffer(); if((i = this.ProcessContents(address, result)) == SEQHOUND_OK){ return SLRIMisc.StrInt2IntArr(result.toString(), ","); }else if(i == SEQHOUND_ERROR){ this.SHoundLogError(SH_warn, "[SeqHoundGODBGetAllChildren]: ".concat(ERROR_STATEMENT)); }else if(i == SEQHOUND_NULL){ this.SHoundLogError(SH_warn, "[SeqHoundGODBGetAllChildren]: ".concat(NULL_STATEMENT)); }else{ this.SHoundLogError(SH_warn, "[SeqHoundGODBGetAllChildren]: ".concat(ABNORMAL_STATEMENT)); } return null; } /** * retrieves the name of a given goid * @param goid the goid * @return the name * @throws IOException */ public String SHoundGODBGetNameByID(int goid) throws IOException { if(goid <= 0){ this.SHoundLogError(SH_severe, "[SHoundGODBGetNameByID] Invalid goid."); return null; } String args = "goid=".concat(String.valueOf(goid)); String address = this.GetFunctionCall("SeqHoundGODBGetNameByID", args); this.SHoundLogError(SH_info, "[SeqHoundGODBGetNameByID]: ".concat(args)); int i; StringBuffer result = new StringBuffer(); if((i = this.ProcessContents(address, result)) == SEQHOUND_OK){ return result.toString(); }else if(i == SEQHOUND_ERROR){ this.SHoundLogError(SH_warn, "[SeqHoundGODBGetNameByID]: ".concat(ERROR_STATEMENT)); }else if(i == SEQHOUND_NULL){ this.SHoundLogError(SH_warn, "[SeqHoundGODBGetNameByID]: ".concat(NULL_STATEMENT)); }else{ this.SHoundLogError(SH_warn, "[SeqHoundGODBGetNameByID]: ".concat(ABNORMAL_STATEMENT)); } return null; } /** * retrieve the ontology classification for a given goid * @param goid the given goid * @return the classification goid falls into * @throws IOException */ public String SHoundGODBGetClassification(int goid) throws IOException { if(goid <= 0){ this.SHoundLogError(SH_severe, "[SHoundGODBGetClassification] Invalid goid."); return null; } String args = "goid=".concat(String.valueOf(goid)); String address = this.GetFunctionCall("SeqHoundGODBGetClassification", args); this.SHoundLogError(SH_info, "[SeqHoundGODBGetClassification]: ".concat(args)); int i; StringBuffer result = new StringBuffer(); if((i = this.ProcessContents(address, result)) == SEQHOUND_OK){ return result.toString(); }else if(i == SEQHOUND_ERROR){ this.SHoundLogError(SH_warn, "[SeqHoundGODBGetClassification]: ".concat(ERROR_STATEMENT)); }else if(i == SEQHOUND_NULL){ this.SHoundLogError(SH_warn, "[SeqHoundGODBGetClassification]: ".concat(NULL_STATEMENT)); }else{ this.SHoundLogError(SH_warn, "[SeqHoundGODBGetClassification]: ".concat(ABNORMAL_STATEMENT)); } return null; } /** * Retrieves a list of protein BLAST neighbours. * Uses redundancy information for the query protein. * This means that if the query fails for the input gi identifier, * then the query will be retried for all other gi identifiers that * belong to the same redundant group. * The BLAST protein neighbours were calculated using 0.01 maximum E-value cutoff. * @param gi the gi * @param eValue the e-value cutoff * @param bLimit limit the return list to 100 gi's * @return an array of gi's * @throws IOException */ public int[] SHoundNeighboursFromGi(int gi, double eValue, boolean bLimit) throws IOException { if(gi <= 0){ this.SHoundLogError(SH_severe, "[SHoundNeighboursFromGi] Invalid gi."); return null; } if(eValue < 0){ this.SHoundLogError(SH_severe, "[SHoundNeighboursFromGi] Invalid eValue."); return null; } String args = "gi=".concat(String.valueOf(gi)); args += "&evalue=".concat(String.valueOf(eValue)); args += "&bLimit=".concat(String.valueOf(bLimit).toUpperCase()); String address = this.GetFunctionCall("SeqHoundNeighboursFromGiPL", args); this.SHoundLogError(SH_info, "[SeqHoundNeighboursFromGi]: ".concat(args)); int i; StringBuffer result = new StringBuffer(); if((i = this.ProcessContents(address, result)) == SEQHOUND_OK){ return SLRIMisc.StrInt2IntArr(result.toString(), ","); }else if(i == SEQHOUND_ERROR){ this.SHoundLogError(SH_warn, "[SeqHoundNeighboursFromGi]: ".concat(ERROR_STATEMENT)); }else if(i == SEQHOUND_NULL){ this.SHoundLogError(SH_warn, "[SeqHoundNeighboursFromGi]: ".concat(NULL_STATEMENT)); }else{ this.SHoundLogError(SH_warn, "[SeqHoundNeighboursFromGi]: ".concat(ABNORMAL_STATEMENT)); } return null; } /** * Retrieves a list of protein BLAST neighbours. * Uses redundancy information for the query protein. * This means that if the query fails for the input gi identifier, * then the query will be retried for all other gi identifiers that * belong to the same redundant group. * The BLAST protein neighbours were calculated using 0.01 maximum E-value cutoff. * @param giList the list of gi * @param eValue the e value cutoff * @param bLimit limit the return to 100 gi's * @return an array of gi's * @throws IOException */ public int[] SHoundNeighboursFromGiList(int[] giList, double eValue, boolean bLimit) throws IOException { if(giList == null){ this.SHoundLogError(SH_severe, "[SHoundNeighboursFromGiList] Empty array: giList."); return null; } if(giList.length < 1){ this.SHoundLogError(SH_severe, "[SHoundNeighboursFromGiList] Empty array: giList."); return null; } if(eValue < 0){ this.SHoundLogError(SH_severe, "[SHoundNeighboursFromGiList] Invalid eValue."); return null; } Vector tmpV = SLRIMisc.CopyArray(giList); int[] iRet = new int[0]; String args, address; StringBuffer result; while(tmpV.size() > 0){ result = new StringBuffer(); int[] itmp = SLRIMisc.MaxSizeIntList(tmpV); args = "gilist=".concat(SLRIMisc.SaveArrAsString(itmp)); args += "&evalue=".concat(String.valueOf(eValue)); args += "&bLimit=".concat(String.valueOf(bLimit).toUpperCase()); address = this.GetFunctionCall("SeqHoundNeighboursFromGiListPL", args); this.SHoundLogError(SH_info, "[SeqHoundNeighboursFromGiList]: ".concat(args)); int i; if((i = this.ProcessContents(address, result)) == SEQHOUND_OK){ iRet = SLRIMisc.MergeLists(iRet, SLRIMisc.StrInt2IntArr(result.toString(), ",")); }else if(i == SEQHOUND_ERROR){ this.SHoundLogError(SH_warn, "[SeqHoundNeighboursFromGiList]: ".concat(ERROR_STATEMENT)); }else if(i == SEQHOUND_NULL){ this.SHoundLogError(SH_warn, "[SeqHoundNeighboursFromGiList]: ".concat(NULL_STATEMENT)); }else{ this.SHoundLogError(SH_warn, "[SeqHoundNeighboursFromGiList]: ".concat(ABNORMAL_STATEMENT)); } } return iRet; } /** * Retrieves a list of protein BLAST neighbours using a list of * proteins belonging to a complete genome as a query. Uses * redundancy information for the query proteins. The BLAST * protein neighbours were calculated using 0.01 maximum E-value cutoff. * @param taxid the taxonomy identifier * @param eValue the evalue cutoff * @return an array of gi's * @throws IOException */ public int[] SHoundNeighboursFromTaxID(int taxid, double eValue) throws IOException { if(taxid <= 0){ this.SHoundLogError(SH_severe, "[SHoundNeighboursFromTaxID] Invalid taxid."); return null; } if(eValue < 0){ this.SHoundLogError(SH_severe, "[SHoundNeighboursFromTaxID] Invalid eValue."); return null; } String args = "taxid=".concat(String.valueOf(taxid)); args += "&evalue=".concat(String.valueOf(eValue)); String address = this.GetFunctionCall("SeqHoundNeighboursFromTaxIDPL", args); this.SHoundLogError(SH_info, "[SeqHoundNeighboursFromTaxID]: ".concat(args)); int i; StringBuffer result = new StringBuffer(); if((i = this.ProcessContents(address, result)) == SEQHOUND_OK){ return SLRIMisc.StrInt2IntArr(result.toString(), ","); }else if(i == SEQHOUND_ERROR){ this.SHoundLogError(SH_warn, "[SeqHoundNeighboursFromTaxID]: ".concat(ERROR_STATEMENT)); }else if(i == SEQHOUND_NULL){ this.SHoundLogError(SH_warn, "[SeqHoundNeighboursFromTaxID]: ".concat(NULL_STATEMENT)); }else{ this.SHoundLogError(SH_warn, "[SeqHoundNeighboursFromTaxID]: ".concat(ABNORMAL_STATEMENT)); } return null; } /** * Retrieves a list of protein BLAST neighbours possessing 3-D * structure. Uses redundancy information for the query protein. * This means that if the query fails for the input gi identifier, * then the query will be retried for all other gi identifiers that * belong to the same redundant group. * The BLAST protein neighbours were calculated using * 0.01 maximum E-value cutoff. * @param gi the gi * @param eValue the evalue cutoff * @return an array of gi's * @throws IOException */ public int[] SHound3DNeighboursFromGi(int gi, double eValue) throws IOException { if(gi <= 0){ this.SHoundLogError(SH_severe, "[SHound3DNeighboursFromGi] Invalid gi."); return null; } if(eValue < 0){ this.SHoundLogError(SH_severe, "[SHound3DNeighboursFromGi] Invalid eValue."); return null; } String args = "gi=".concat(String.valueOf(gi)); args += "&evalue=".concat(String.valueOf(eValue)); String address = this.GetFunctionCall("SeqHound3DNeighboursFromGiPL", args); this.SHoundLogError(SH_info, "[SeqHound3DNeighboursFromGi]: ".concat(args)); int i; StringBuffer result = new StringBuffer(); if((i = this.ProcessContents(address, result)) == SEQHOUND_OK){ return SLRIMisc.StrInt2IntArr(result.toString(), ","); }else if(i == SEQHOUND_ERROR){ this.SHoundLogError(SH_warn, "[SeqHound3DNeighboursFromGi]: ".concat(ERROR_STATEMENT)); }else if(i == SEQHOUND_NULL){ this.SHoundLogError(SH_warn, "[SeqHound3DNeighboursFromGi]: ".concat(NULL_STATEMENT)); }else{ this.SHoundLogError(SH_warn, "[SeqHound3DNeighboursFromGi]: ".concat(ABNORMAL_STATEMENT)); } return null; } /** * Retrieves a list of protein BLAST neighbours possessing * 3-D structure using a list of proteins belonging to a * complete genome as a query. Uses redundancy information * for the query protein. The BLAST protein neighbours were * calculated using 0.01 maximum E-value cutoff. * @param taxid the taxonomy id * @param eValue the evalue cutoff * @return an array of gi's * @throws IOException */ public int[] SHound3DNeighboursFromTaxID(int taxid, double eValue) throws IOException { if(taxid <= 0){ this.SHoundLogError(SH_severe, "[SHoundNeighboursFromTaxID] Invalid taxid."); return null; } if(eValue < 0){ this.SHoundLogError(SH_severe, "[SHoundNeighboursFromTaxID] Invalid eValue."); return null; } String args = "taxid=".concat(String.valueOf(taxid)); args += "&evalue=".concat(String.valueOf(eValue)); String address = this.GetFunctionCall("SeqHound3DNeighboursFromTaxIDPL", args); this.SHoundLogError(SH_info, "[SeqHound3DNeighboursFromTaxID]: ".concat(args)); int i; StringBuffer result = new StringBuffer(); if((i = this.ProcessContents(address, result)) == SEQHOUND_OK){ return SLRIMisc.StrInt2IntArr(result.toString(), ","); }else if(i == SEQHOUND_ERROR){ this.SHoundLogError(SH_warn, "[SeqHound3DNeighboursFromTaxID]: ".concat(ERROR_STATEMENT)); }else if(i == SEQHOUND_NULL){ this.SHoundLogError(SH_warn, "[SeqHound3DNeighboursFromTaxID]: ".concat(NULL_STATEMENT)); }else{ this.SHoundLogError(SH_warn, "[SeqHound3DNeighboursFromTaxID]: ".concat(ABNORMAL_STATEMENT)); } return null; } /* * Get the MMDB identifier for a given gi * @param gi the gi * @return an MMDB identifier or -1 or zero * @throws IOException */ /*public int[] SHoundGODBGetHierarchyLevel(int goid) throws IOException { if(goid < 0){ this.SHoundLogError(SH_severe, "[SHoundGODBGetHierarchyLevel] Invalid goid."); return new int[0]; } String args = "goid=".concat((new Integer(goid)).toString()); String address = this.GetFunctionCall("SeqHoundAllGODBGetHierarchyLevel", args); int i; StringBuffer result = new StringBuffer(); if((i = this.ProcessContents(address, result)) == SEQHOUND_OK){ return SLRIMisc.StrInt2IntArr(result.toString(), ","); }else if(i == SEQHOUND_ERROR){ this.SHoundLogError(SH_warn, "[SeqHoundGODBGetHierarchyLevel]: ".concat(ERROR_STATEMENT)); }else if(i == SEQHOUND_NULL){ this.SHoundLogError(SH_warn, "[SeqHoundGODBGetHierarchyLevel]: ".concat(NULL_STATEMENT)); }else{ this.SHoundLogError(SH_warn, "[SeqHoundGODBGetHierarchyLevel]: ".concat(ABNORMAL_STATEMENT)); } return new int[0]; }*/ /** * retrieves all the gi's with the specified number of domains * @param numdoms the number of domains * @return an array of gi's * @throws IOException */ public int[] SHoundGetGisByNumberOfDomains(int numdoms) throws IOException { if(numdoms <= 0){ this.SHoundLogError(SH_severe, "[SHoundGetGisByNumberOfDomains] Invalid numdoms."); return null; } String args = "numdom=".concat(String.valueOf(numdoms)); String address = this.GetFunctionCall("SeqHoundGetGisByNumberOfDomains", args); this.SHoundLogError(SH_info, "[SeqHoundGetGisByNumberOfDomains]: ".concat(args)); int i; StringBuffer result = new StringBuffer(); if((i = this.ProcessContents(address, result)) == SEQHOUND_OK){ return SLRIMisc.StrInt2IntArr(result.toString(), ","); }else if(i == SEQHOUND_ERROR){ this.SHoundLogError(SH_warn, "[SeqHoundGetGisByNumberOfDomains]: ".concat(ERROR_STATEMENT)); }else if(i == SEQHOUND_NULL){ this.SHoundLogError(SH_warn, "[SeqHoundGetGisByNumberOfDomains]: ".concat(NULL_STATEMENT)); }else{ this.SHoundLogError(SH_warn, "[SeqHoundGetGisByNumberOfDomains]: ".concat(ABNORMAL_STATEMENT)); } return null; } /** * retrieves the domain id given a label * @param label the domain label * @return an array of domain id * @throws IOException */ public String[] SHoundGetDomainIdFromLabel(String label) throws IOException { if(label == null){ this.SHoundLogError(SH_severe, "[SHoundGetDomainsIdFromLabel] Null string error: label."); return null; } String args = "label=".concat(label); String address = this.GetFunctionCall("SeqHoundGetDomainIdFromLabel", args); this.SHoundLogError(SH_info, "[SeqHoundGetDomainIdFromLabel]: ".concat(args)); int i; StringBuffer result = new StringBuffer(); if((i = this.ProcessContents(address, result)) == SEQHOUND_OK){ return SLRIMisc.StrStr2StrArr(result.toString(), ","); }else if(i == SEQHOUND_ERROR){ this.SHoundLogError(SH_warn, "[SeqHoundGetDomainIdFromLabel]: ".concat(ERROR_STATEMENT)); }else if(i == SEQHOUND_NULL){ this.SHoundLogError(SH_warn, "[SeqHoundGetDomainIdFromLabel]: ".concat(NULL_STATEMENT)); }else{ this.SHoundLogError(SH_warn, "[SeqHoundGetDomainIdFromLabel]: ".concat(ABNORMAL_STATEMENT)); } return null; } /** * retrieve the gi's having a domain id * @param domain the domain id * @return an array of gi's * @throws IOException */ public int[] SHoundGetGisByDomainId(String domain) throws IOException { if(domain == null){ this.SHoundLogError(SH_severe, "[SHoundGetGisByDomainId] Null string error: domain."); return null; } String args = "domain_id=".concat(domain); String address = this.GetFunctionCall("SeqHoundGetGisByDomainId", args); this.SHoundLogError(SH_info, "[SeqHoundGetGisByDomainsId]: ".concat(args)); int i; StringBuffer result = new StringBuffer(); if((i = this.ProcessContents(address, result)) == SEQHOUND_OK){ return SLRIMisc.StrInt2IntArr(result.toString(), ","); }else if(i == SEQHOUND_ERROR){ this.SHoundLogError(SH_warn, "[SeqHoundGetGisByDomainId]: ".concat(ERROR_STATEMENT)); }else if(i == SEQHOUND_NULL){ this.SHoundLogError(SH_warn, "[SeqHoundGetGisByDomainId]: ".concat(NULL_STATEMENT)); }else{ this.SHoundLogError(SH_warn, "[SeqHoundGetGisByDomainId]: ".concat(ABNORMAL_STATEMENT)); } return null; } /** * Returns a short non-unique label given a domain for a * Conserved Domain Database (CDD). The above labels are * preferred amongst scientific community. * @param accession the accession number * @return an array of domain labels * @throws IOException */ public String[] SHoundGetDomainLabelFromDomainId(String accession) throws IOException { if(accession == null){ this.SHoundLogError(SH_severe, "[SHoundGetDomainLabelFromDomainsId] Null string error: accession"); return null; } String args = "accession=".concat(accession); String address = this.GetFunctionCall("SeqHoundGetDomainLabelFromDomainId", args); this.SHoundLogError(SH_info, "[SeqHoundGetDomainsLabelFromDomainId]: ".concat(args)); int i; StringBuffer result = new StringBuffer(); if((i = this.ProcessContents(address, result)) == SEQHOUND_OK){ return SLRIMisc.StrStr2StrArr(result.toString(), ","); }else if(i == SEQHOUND_ERROR){ this.SHoundLogError(SH_warn, "[SeqHoundGetDomainLabelFromDomainId]: ".concat(ERROR_STATEMENT)); }else if(i == SEQHOUND_NULL){ this.SHoundLogError(SH_warn, "[SeqHoundGetDomainLabelFromDomainId]: ".concat(NULL_STATEMENT)); }else{ this.SHoundLogError(SH_warn, "[SeqHoundGetDomainLabelFromDomainId]: ".concat(ABNORMAL_STATEMENT)); } return null; } /** * Fetches protein sequences on which a domain from * the Conserved Domain Database (CDD) was identified by * Reverse Position Specific BLAST. The function uses an E-value * cutoff for reporting results. * @param domain the domain id * @param evalue the evalue cutoff * @return an array of gi's * @throws IOException */ public int[] SHoundGetGisByDomainIdAndEvalue(String domain, double evalue) throws IOException { if(domain == null){ this.SHoundLogError(SH_severe, "[SHoundGetGisByDomainIdAndEvalue] Null string error: domain"); return null; } if(evalue < 0){ this.SHoundLogError(SH_severe, "[SHoundGetGisByDomainIdAndEvalue] Invalid evalue."); return null; } String args = "accession=".concat(domain); args += "&evalue=".concat(String.valueOf(evalue)); String address = this.GetFunctionCall("SeqHoundGetGisByDomainIdAndEvalue", args); this.SHoundLogError(SH_info, "[SeqHoundGetGisByDomainIdAndEvalue]: ".concat(args)); int i; StringBuffer result = new StringBuffer(); if((i = this.ProcessContents(address, result)) == SEQHOUND_OK){ return SLRIMisc.StrInt2IntArr(result.toString(), ","); }else if(i == SEQHOUND_ERROR){ this.SHoundLogError(SH_warn, "[SeqHoundGetGisByDomainIdAndEvalue]: ".concat(ERROR_STATEMENT)); }else if(i == SEQHOUND_NULL){ this.SHoundLogError(SH_warn, "[SeqHoundGetGisByDomainIdAndEvalue]: ".concat(NULL_STATEMENT)); }else{ this.SHoundLogError(SH_warn, "[SeqHoundGetGisByDomainIdAndEvalue]: ".concat(ABNORMAL_STATEMENT)); } return null; } /** * Fetches information about domains from the Conserved * Domain Database (CDD) as assigned by Reverse Position * Specific BLAST to a given protein sequence. * Uses redundancy information for the query protein. * This means that if the query fails for the input gi identifier, * then the query will be retried for all other gi identifiers that * belong to the same redundant group. * @param gi the gi * @return domain identifier * @throws IOException */ public String SHoundGetDomainsFromGi(int gi) throws IOException { if(gi <= 0){ this.SHoundLogError(SH_severe, "[SHoundGetDomainsFromGi] Invalid gi."); return null; } String args = "gi=".concat(String.valueOf(gi)); String address = this.GetFunctionCall("SeqHoundGetDomainsFromGiPL", args); this.SHoundLogError(SH_info, "[SeqHoundGetDomainsFromGi]: ".concat(args)); int i; StringBuffer result = new StringBuffer(); if((i = this.ProcessContents(address, result)) == SEQHOUND_OK){ return result.toString(); }else if(i == SEQHOUND_ERROR){ this.SHoundLogError(SH_warn, "[SeqHoundGetDomainsFromGi]: ".concat(ERROR_STATEMENT)); }else if(i == SEQHOUND_NULL){ this.SHoundLogError(SH_warn, "[SeqHoundGetDomainsFromGi]: ".concat(NULL_STATEMENT)); }else{ this.SHoundLogError(SH_warn, "[SeqHoundGetDomainsFromGi]: ".concat(ABNORMAL_STATEMENT)); } return null; } /** * Fetches information about domains from the Conserved * Domain Database (CDD) as assigned by Reverse Position * Specific BLAST to a given protein sequence. * Uses redundancy information for the query protein. * This means that if the query fails for the input gi identifier, * then the query will be retried for all other gi identifiers that * belong to the same redundant group. * The function uses an E-value cutoff for reporting results. * @param gi the gi * @param eValue the evalue cutoff * @return an MMDB identifier or -1 or zero * @throws IOException */ public String SHoundGetDomainsFromGiWithEvalue(int gi, double eValue) throws IOException { if(gi <= 0){ this.SHoundLogError(SH_severe, "[SHoundGetDomainsFromGiWithEvalue] Invalid gi."); return null; } if(eValue < 0){ this.SHoundLogError(SH_severe, "[SHoundGetDomainsFromGiWithEvalue] Invalid eValue."); return null; } String args = "gi=".concat(String.valueOf(gi)); args += "&evalue=".concat(String.valueOf(eValue)); String address = this.GetFunctionCall("SeqHoundGetDomainsFromGiWithEvaluePL", args); this.SHoundLogError(SH_info, "[SeqHoundGetDomainsFromGiWithEvalue]: ".concat(args)); int i; StringBuffer result = new StringBuffer(); if((i = this.ProcessContents(address, result)) == SEQHOUND_OK){ return result.toString(); }else if(i == SEQHOUND_ERROR){ this.SHoundLogError(SH_warn, "[SeqHoundGetDomainsFromGiWithEvalue]: ".concat(ERROR_STATEMENT)); }else if(i == SEQHOUND_NULL){ this.SHoundLogError(SH_warn, "[SeqHoundGetDomainsFromGiWithEvalue]: ".concat(NULL_STATEMENT)); }else{ this.SHoundLogError(SH_warn, "[SeqHoundGetDomainsFromGiWithEvalue]: ".concat(ABNORMAL_STATEMENT)); } return null; } /** * Returns accession number for the given retired gi. * @param gi a retired gi * @return an accession string or null. * @throws IOException */ public String SHoundGetAccFromRetiredGi(int gi) throws IOException { if(gi <= 0){ this.SHoundLogError(SH_severe, "[SHoundGetAccFromRetiredGi] Invalid gi."); return null; } String args = "gi=".concat(String.valueOf(gi)); String address = this.GetFunctionCall("SeqHoundGetAccFromRetiredGi", args); this.SHoundLogError(SH_info, "[SeqHoundGetAccFromRetiredGi]: ".concat(args)); int i; StringBuffer result = new StringBuffer(); if((i = this.ProcessContents(address, result)) == SEQHOUND_OK){ return result.toString(); }else if(i == SEQHOUND_ERROR){ this.SHoundLogError(SH_warn, "[SeqHoundGetAccFromRetiredGi]: ".concat(ERROR_STATEMENT)); }else if(i == SEQHOUND_NULL){ this.SHoundLogError(SH_warn, "[SeqHoundGetAccFromRetiredGi]: ".concat(NULL_STATEMENT)); }else{ this.SHoundLogError(SH_warn, "[SeqHoundGetAccFromRetiredGi]: ".concat(ABNORMAL_STATEMENT)); } return null; } /** * Get a protein report set description for a given gi. * The set description is a comprehensive description for a gi. * @param gi the gi * @param format the format of the description. Either REPORT_XML or REPORT_ASN_TXT * @return the protein report string * @throws IOException */ public String SHoundProteinReportSetDescription(int gi, int format) throws IOException { if(gi <= 0){ this.SHoundLogError(SH_severe, "[SHoundProteinReportSetDescription] Invalid gi."); return null; } /* construct the http call */ String args = "gi=".concat(String.valueOf(gi)); args += "&format=" + Integer.toString(format); String address = this.GetFunctionCall("SeqHoundProteinReportSetDescription", args); /* logs the request */ this.SHoundLogError(SH_info, "[SeqHoundProteinReportSetDescription]: ".concat(args)); int i; /* the response */ StringBuffer result = new StringBuffer(); if((i = this.ProcessContents(address, result)) == SEQHOUND_OK){ return result.toString(); }else if(i == SEQHOUND_ERROR){ this.SHoundLogError(SH_warn, "[SeqHoundProteinReportSetDescription]: ".concat(ERROR_STATEMENT)); }else if(i == SEQHOUND_NULL){ this.SHoundLogError(SH_warn, "[SeqHoundProteinReportSetDescription]: ".concat(NULL_STATEMENT)); }else{ this.SHoundLogError(SH_warn, "[SeqHoundProteinReportSetDescription]: ".concat(ABNORMAL_STATEMENT)); } return null; } /** * retrieves fasta list for the given gilist * @param giList an array of gi's * @return a hashtable with gi-fasta pair * @throws IOException */ public Hashtable SHoundGetFastaKeyedList(int[] giList) throws IOException { if(giList == null){ this.SHoundLogError(SH_severe, "[SHoundGetFastaKeyedList] Null array: giList"); return null; } if(giList.length < 1){ this.SHoundLogError(SH_severe, "[SHoundGetFastaKeyedList] Empty array: giList"); return null; } /* copy the array */ Vector tmpV = SLRIMisc.CopyArray(giList); StringBuffer result; String args, address, str; Hashtable h = new Hashtable(); /* iterate through the array */ while(tmpV.size() > 0){ result = new StringBuffer(); /* each request contains max of 700 gi */ int[] itmp = SLRIMisc.MaxSizeIntList(tmpV); /* construct the http call */ args = "pgi=".concat(SLRIMisc.SaveArrAsString(itmp)); address = this.GetFunctionCall("SeqHoundGetFastaKeyedList", args); /* log the request */ this.SHoundLogError(SH_info, "[SeqHoundGetFastaKeyedList]: ".concat(args)); int i; /* read from the server */ if((i = this.ProcessContents(address, result)) == SEQHOUND_OK){ h = this.ProcessRetStr(h, result.toString()); }else if(i == SEQHOUND_ERROR){ this.SHoundLogError(SH_warn, "[SeqHoundGetFastaKeyedList]: ".concat(ERROR_STATEMENT)); }else if(i == SEQHOUND_NULL){ this.SHoundLogError(SH_warn, "[SeqHoundGetFastaKeyedList]: ".concat(NULL_STATEMENT)); }else{ this.SHoundLogError(SH_warn, "[SeqHoundGetFastaKeyedList]: ".concat(ABNORMAL_STATEMENT)); } } return h; } /** * Gets all protein entries with the same sequence from the system * @param gilist * @return a hashtable of query gi and associated return protein gi's * @throws IOException */ public Hashtable SHoundRedundantGroupKeyedList(int[] giList) throws IOException { if(giList == null){ this.SHoundLogError(SH_severe, "[SHoundRedundantGroupKeyedList] Empty array: giList"); return null; } if(giList.length < 1){ this.SHoundLogError(SH_severe, "[SHoundRedundantGroupKeyedList] Empty array: giList"); return null; } Vector tmpV = SLRIMisc.CopyArray(giList); String args, address,str; StringBuffer result; Hashtable h = new Hashtable(); while(tmpV.size() > 0){ result = new StringBuffer(); int[] itmp = SLRIMisc.MaxSizeIntList(tmpV); args = "pgi=".concat(SLRIMisc.SaveArrAsString(itmp)); address = this.GetFunctionCall("SeqHoundRedundantGroupKeyedList", args); this.SHoundLogError(SH_info, "[SeqHoundRedundantGroupKeyedList]: ".concat(args)); int i; if((i = this.ProcessContents(address, result)) == SEQHOUND_OK){ h = this.ProcessRetStr(h, result.toString()); }else if(i == SEQHOUND_ERROR){ this.SHoundLogError(SH_warn, "[SeqHoundRedundantGroupKeyedList]: ".concat(ERROR_STATEMENT)); }else if(i == SEQHOUND_NULL){ this.SHoundLogError(SH_warn, "[SeqHoundRedundantGroupKeyedList]: ".concat(NULL_STATEMENT)); }else{ this.SHoundLogError(SH_warn, "[SeqHoundRedundantGroupKeyedList]: ".concat(ABNORMAL_STATEMENT)); } } return h; } /** * The FASTA format is widely used in bioinformatics community; * it consists of a definition line, new line followed by a * sequence terminated by a second new line. * @param gid the redundant group id * @return a string fasta * @throws IOException */ public String SHoundGetFastaFromRedundantGroupID(int gid) throws IOException { if(gid <= 0){ this.SHoundLogError(SH_severe, "[SHoundGetFastaFromRedundantGroupID] Invalid gid."); return null; } String args = "gid=".concat(String.valueOf(gid)); String address = this.GetFunctionCall("SeqHoundGetFastaFromRedundantGroupID", args); this.SHoundLogError(SH_info, "[SeqHoundGetFastaFromRedundantGroupID]: ".concat(args)); int i; StringBuffer result = new StringBuffer(); if((i = this.ProcessContents(address, result)) == SEQHOUND_OK){ return result.toString(); }else if(i == SEQHOUND_ERROR){ this.SHoundLogError(SH_warn, "[SeqHoundGetFastaFromRedundantGroupID]: ".concat(ERROR_STATEMENT)); }else if(i == SEQHOUND_NULL){ this.SHoundLogError(SH_warn, "[SeqHoundGetFastaFromRedundantGroupID]: ".concat(NULL_STATEMENT)); }else{ this.SHoundLogError(SH_warn, "[SeqHoundGetFastaFromRedundantGroupID]: ".concat(ABNORMAL_STATEMENT)); } return null; } /** * retrieves fasta list for the given redundant group id list * @param gidList an array of redundant group ids * @return a hashtable with groupid-fasta pair * @throws IOException */ public Hashtable SHoundGetFastaFromRedundantGroupIDKeyedList(int[] gidList) throws IOException { if(gidList == null){ this.SHoundLogError(SH_severe, "[SHoundGetFastaFromRedundantGroupIDKeyedList] Null array: giList"); return null; } if(gidList.length < 1){ this.SHoundLogError(SH_severe, "[SHoundGetFastaFromRedundantGroupIDKeyedList] Empty array: giList"); return null; } /* copy the array */ Vector tmpV = SLRIMisc.CopyArray(gidList); StringBuffer result; String args, address, str; Hashtable h = new Hashtable(); /* iterate through the array */ while(tmpV.size() > 0){ result = new StringBuffer(); /* each request contains max of 700 gi */ int[] itmp = SLRIMisc.MaxSizeIntList(tmpV); /* construct the http call */ args = "pgid=".concat(SLRIMisc.SaveArrAsString(itmp)); address = this.GetFunctionCall("SeqHoundGetFastaFromRedundantGroupIDKeyedList", args); /* log the request */ this.SHoundLogError(SH_info, "[SeqHoundGetFastaFromRedundantGroupIDKeyedList]: ".concat(args)); int i; /* read from the server */ if((i = this.ProcessContents(address, result)) == SEQHOUND_OK){ h = this.ProcessRetStr(h, result.toString()); }else if(i == SEQHOUND_ERROR){ this.SHoundLogError(SH_warn, "[SeqHoundGetFastaKeyedList]: ".concat(ERROR_STATEMENT)); }else if(i == SEQHOUND_NULL){ this.SHoundLogError(SH_warn, "[SeqHoundGetFastaKeyedList]: ".concat(NULL_STATEMENT)); }else{ this.SHoundLogError(SH_warn, "[SeqHoundGetFastaKeyedList]: ".concat(ABNORMAL_STATEMENT)); } } return h; } /** * Process the return string from server to a hashtable * @param str is the return string from server * @return a hashtable with query-return pair * @throws IOException */ public Hashtable ProcessRetStr(Hashtable h, String str) throws IOException { String[] strArr = str.split(GROUP); h = SLRIMisc.StrArr2Hash(strArr, h, Q_R); return h; } }