acedb
Class Ace

java.lang.Object
  extended byacedb.Ace
All Implemented Interfaces:
Constants

public class Ace
extends java.lang.Object
implements Constants

Ace class, A key interface to ACEDB. Some String types can be converted to int types to improve efficiency a little bit. I have not done so yet. This class used Aceclient and Aceconnet. Most of the time the useer does not need to use Aceclient or Aceconnect class. When you are expecting a list of AQL results use execQuery().


Field Summary
static int QUERY_LIMIT
           
 
Fields inherited from interface acedb.Constants
ACESERV_MSGDATA, ACESERV_MSGENCORE, ACESERV_MSGFAIL, ACESERV_MSGKILL, ACESERV_MSGOK, ACESERV_MSGREQ, RESULT_BACKWARD, RESULT_FORWARD, RESULT_RANDOM
 
Constructor Summary
Ace(java.lang.String host, int port, java.lang.String user, java.lang.String pwd)
          Constructing an Ace object.
 
Method Summary
static java.lang.String chopComment(java.lang.String aceoutput)
          remove the comment info at the end of the ace output.
 void close()
           
 java.lang.String exec(java.lang.String query)
          Execute database commands and return the whole result as String.
 Result execQuery(java.lang.String query)
          Execute a AQL query and reture a RESULT_FORWARD Result object.
 Result execQuery(java.lang.String query, int rltProperty)
          use to get random access results if rltProperty == RESULT_RANDOM.
static java.lang.String fasta2String(java.lang.String fasSeq)
          helper function to convert the ace fasta dump into String discarding header line
 Aceobj fetch(Aceobj node)
          follow an Aceobj into the database and retrieve a new object.
 Aceobj fetch(java.lang.String className, java.lang.String objName)
          retrieve an Aceobj from the server.
 Objset fetchMany(java.lang.String keysetCmd)
          keys must be formated as "Keyset-read = CLASS key1;key2;...; .
 Objset fetchMany(java.lang.String classname, java.util.Vector objlist)
          fetch all objects in objlist into an Objset object, then use the next method to iterate through the objcets in the set.
 java.lang.String fetchManyString(java.lang.String className, java.util.Vector objlist)
          fetch all the object in objlist as a large string containing all object.
 java.lang.String getCDS(java.lang.String seqName)
          obtain the CDS sequence from an mRNA object
 java.lang.String getDBInfo()
          get a summary of info about the underlying acedb.
 java.lang.String getDBTitle()
          obtain the title of the underlying acedb.
 java.lang.String getDNA(java.lang.String seqName)
          Retrieve the sequence string only, without \n and header no white characters left.
 java.lang.String getFastaDNA(java.lang.String seqName)
          Retrieve DNA sequence as fasta formated, 50 nt per line, with the header > seqName.
 java.lang.String getFastaPeptide(java.lang.String seqName)
          Retrieve Peptide sequence as fasta formated, 50 aa per line, with the header > seqName.
 java.lang.String getPeptide(java.lang.String seqName)
          Retrieve the peptide string only, without \n and header no white characters left.
 SeqResult getSeqSet(java.lang.String DNA_Peptide)
          Must be called after a regular query that returns sequence sets such as an aql statement or keyset statement.
 SeqResult getSeqSet(java.lang.String DNA_Peptide, java.util.Vector seqlist)
          returns a SeqResult object from a list of protein or sequence names.
 java.lang.String getStatus()
           
 int keyset(java.lang.String keys)
          send a keyset to the server with keys containing the String of keys separated with ";".
 int keyset(java.lang.String type, java.util.Vector keys)
          Use the tace Keyset-Read command to import a keyset into the server database with class=type and all the keys from keys vector.
static java.lang.String reverseComplement(java.lang.String DNA)
          helper function, should be in a separete package
static void writeFasta(java.io.PrintStream pw, java.lang.String seq)
           
static void writeFasta(java.io.PrintStream pw, java.lang.String seq, int lineLen)
          helper function to dump sequence string into pw, lineLen bases per line
static void writeFasta(java.io.PrintWriter pw, java.lang.String seq)
          defalt line 50 nt per line
static void writeFasta(java.io.PrintWriter pw, java.lang.String seq, int len)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

QUERY_LIMIT

public static final int QUERY_LIMIT
See Also:
Constant Field Values
Constructor Detail

Ace

public Ace(java.lang.String host,
           int port,
           java.lang.String user,
           java.lang.String pwd)
Constructing an Ace object. If user=anonymous, then pwd should be "" an empty string when the server has world read accesss

Method Detail

exec

public java.lang.String exec(java.lang.String query)
                      throws AceException
Execute database commands and return the whole result as String. if returned message too long it may cause trouble. Do not use for long results! Use the execCommand() method instead (in the parent class.

Parameters:
query - should not exceed 20400 bytes
Returns:
query result as string
Throws:
AceException

keyset

public int keyset(java.lang.String type,
                  java.util.Vector keys)
           throws AceException
Use the tace Keyset-Read command to import a keyset into the server database with class=type and all the keys from keys vector. The keys when translated into stirng should not execeed 20400 bytes. When keyset are too large you have to sent command in separate trunks.

Parameters:
type - is a legal class name in acedb
keys - are valid object ids limit to 20400 bytes
Returns:
number of valid keys in keyset read by server
Throws:
AceException

keyset

public int keyset(java.lang.String keys)
           throws AceException
send a keyset to the server with keys containing the String of keys separated with ";". Right now the QUERY_LIMIT is 20400.

Parameters:
keys - Keyset-read = CLASSNAME k1;k2;k3;..;kn;
Returns:
number of valid keys, -1 if keys longer than QUERY_LIMIT
Throws:
AceException

getSeqSet

public SeqResult getSeqSet(java.lang.String DNA_Peptide)
                    throws AceException
Must be called after a regular query that returns sequence sets such as an aql statement or keyset statement.

Parameters:
DNA_Peptide - can only be either DNA or Peptide nothing else
Returns:
a SeqResult object for iteration
Throws:
AceException

getSeqSet

public SeqResult getSeqSet(java.lang.String DNA_Peptide,
                           java.util.Vector seqlist)
                    throws AceException
returns a SeqResult object from a list of protein or sequence names. An overloaded version of getSeqSet(String DNA_Peptide). There is no need to execute query that returns keyset of sequence or protein objects before calling this method.

Throws:
AceException

execQuery

public Result execQuery(java.lang.String query)
                 throws AceException
Execute a AQL query and reture a RESULT_FORWARD Result object. You need to used the Result object to iterate through the result. For random accessed Result, you need to use execQuery(query, RESULT_RANDOM). If the result is too large (needs ENCORE), then it will open another connection that will be closed when next() reaches the end.

Parameters:
query - in the AQL querery syntax only. Other syntax will cause trouble.
Returns:
a Result object with RESULT_FORWARD property, for iterating throught the resulting table. If retrieved 0 objects then Result object will be empty.
Throws:
AceException
See Also:
Result.next()

execQuery

public Result execQuery(java.lang.String query,
                        int rltProperty)
                 throws AceException
use to get random access results if rltProperty == RESULT_RANDOM. Currently, only RESULT_FORWARD (default) and RESULT_RANDOM implemented.

Parameters:
rltProperty - takes two values now: RESULT_FORWARD or RESULT_RANDOM. RESULT_BACKWARD not implemented yet.
Returns:
a Result object, use this object to iterate through the result in a table format.
Throws:
AceException

fetch

public Aceobj fetch(java.lang.String className,
                    java.lang.String objName)
             throws AceException
retrieve an Aceobj from the server.

Throws:
if - found none or more than one objects
AceException

fetch

public Aceobj fetch(Aceobj node)
             throws AceException
follow an Aceobj into the database and retrieve a new object.

Throws:
will - throw an exception if node is not an authetic object in Acedb, such as Sequence, Author, etc.
AceException

fetchMany

public Objset fetchMany(java.lang.String classname,
                        java.util.Vector objlist)
                 throws AceException
fetch all objects in objlist into an Objset object, then use the next method to iterate through the objcets in the set. Note: one pass only iteration.

Throws:
AceException
See Also:
Objset.next()

fetchMany

public Objset fetchMany(java.lang.String keysetCmd)
                 throws AceException
keys must be formated as "Keyset-read = CLASS key1;key2;...; . The keyset method know how mamy object are not present in the server. This method does not know because we don't have a vector as input so we could not easily count.

Parameters:
keysetCmd - a proper keyset-read command
Throws:
AceException

fetchManyString

public java.lang.String fetchManyString(java.lang.String className,
                                        java.util.Vector objlist)
                                 throws AceException
fetch all the object in objlist as a large string containing all object. This is for human to read. The default is "show -h"

Throws:
AceException

getFastaDNA

public java.lang.String getFastaDNA(java.lang.String seqName)
                             throws AceException,
                                    AceObjectNotFoundException
Retrieve DNA sequence as fasta formated, 50 nt per line, with the header > seqName. The format is the default from ace.

Throws:
AceException
AceObjectNotFoundException

getFastaPeptide

public java.lang.String getFastaPeptide(java.lang.String seqName)
                                 throws AceException,
                                        AceObjectNotFoundException
Retrieve Peptide sequence as fasta formated, 50 aa per line, with the header > seqName. The format is the default from ace. The definition line is not retrieved.

Throws:
AceException
AceObjectNotFoundException

getDNA

public java.lang.String getDNA(java.lang.String seqName)
                        throws AceException
Retrieve the sequence string only, without \n and header no white characters left. Extra work done to format the fasta formated sequence into a simple string.

Throws:
AceException

getPeptide

public java.lang.String getPeptide(java.lang.String seqName)
                            throws AceException
Retrieve the peptide string only, without \n and header no white characters left. Extra work done to format the fasta formated sequence into a simple string.

Throws:
AceException

getCDS

public java.lang.String getCDS(java.lang.String seqName)
                        throws AceException
obtain the CDS sequence from an mRNA object

Throws:
AceException

chopComment

public static java.lang.String chopComment(java.lang.String aceoutput)
remove the comment info at the end of the ace output. example: RESULT here // 58 objects dumped // 58 Active Objects


fasta2String

public static java.lang.String fasta2String(java.lang.String fasSeq)
helper function to convert the ace fasta dump into String discarding header line


writeFasta

public static void writeFasta(java.io.PrintWriter pw,
                              java.lang.String seq)
defalt line 50 nt per line


writeFasta

public static void writeFasta(java.io.PrintWriter pw,
                              java.lang.String seq,
                              int len)

writeFasta

public static void writeFasta(java.io.PrintStream pw,
                              java.lang.String seq)

writeFasta

public static void writeFasta(java.io.PrintStream pw,
                              java.lang.String seq,
                              int lineLen)
helper function to dump sequence string into pw, lineLen bases per line


reverseComplement

public static java.lang.String reverseComplement(java.lang.String DNA)
helper function, should be in a separete package


getStatus

public java.lang.String getStatus()
                           throws AceException
Throws:
AceException

getDBInfo

public java.lang.String getDBInfo()
                           throws AceException
get a summary of info about the underlying acedb.

Throws:
AceException

getDBTitle

public java.lang.String getDBTitle()
                            throws AceException
obtain the title of the underlying acedb.

Throws:
AceException

close

public void close()