org.xerial.db.storage
Interface XerialStorageContext


public interface XerialStorageContext

An example table data:

 Gene Table
 ---------------------
 |id   | start | end |
 |-------------------| 
 |1    | 10    | 100 |
 |2    | 120   | 300 |
 |-------------------|
 

possible annotations for this table:

  species="human", chromosome="chr18", genome.revision="hg18", creater="leo", 
  created_at="2007/07/06" 
 

Some user may generate the following table, containing annotations:

 Gene Table with annotation
 --------------------------------------------
 |id   | start | end | species | chromosome |
 |-------------------------------------------
 |1    | 10    | 100 | human   | chr18      |
 |2    | 120   | 300 | human   | chr18      |
 |-------------------------------------------
 

In both cases, we want to use the same syntax to query these tables. For example, to retrieve gene data of human chromosome 18:

 select id, start, end from gene_table where species="human" and chromosome="chr18"
 

Corresponding AmoebaQuery representation:

 select gene.id, gene.start, gene.end from (species = "human", chromosome="chr18")
 
Annotating table data can be deferred until you insert the gene object data:
  XreialFS fs = (initialization of XerialfS)
  XerialStorageContext db = fs.open("/home/leo/genedata");
  db.append("gene(id=1, start=10, end=100)");   // insert a gene object 
  db.append("gene(id=2, start=120, end=300)");  
  
  // add annotations to all gene objects
  db.append("gene", "species=human, chromosome=chr18, created_at='2007/07/06'");
  
  // add additional annotations for a gene with id = 1
  db.append("gene(id=1)", "description='my gene', author='leo'");
 

Adding exon data to individual genes:

  db.append("gene:(id=1)", "exon:(start=10, end=15)");
  db.append("gene:(id=1)", "exon:(start=20, end=30, description='my exon')");
  db.append("gene:(id=2)", "exon:(start=125, end=130)");
 
If you forget to add id for each gene, you can add such IDs later:
 int count = 1;
 for(AmeobaQueryResultSetHandler handler = db.retrieve("gene"); handler.hasNext(); )
 {
    handler.next().append("id=" + count++);
 }
 
 

Author:
leo

Method Summary
 void append(AmoebaQuery contest, AmoebaTuple tuple)
          Appends the data into the given context
 void append(AmoebaTuple tuple)
          Appends the data without specifying a particular context, i.e., the data will be inserted into the global context
 AmoebaQueryResultSetHandler retrieve(AmoebaQuery query)
          Retrieves database data
 AmoebaQueryResultSetHandler retrieve(AmoebaQuery context, AmoebaQuery query)
          Retreives database data within the specified context
 void write(AmoebaQuery context, AmoebaTuple tuple)
          Overwrites the data within the specified context
 void write(AmoebaTuple tuple)
          Overwrites the data in the global context of the database file
 

Method Detail

retrieve

AmoebaQueryResultSetHandler retrieve(AmoebaQuery query)
                                     throws DBException
Retrieves database data

Parameters:
query - the query
Returns:
ResultSetHandler for amoeba query
Throws:
XerialFSException
DBException

retrieve

AmoebaQueryResultSetHandler retrieve(AmoebaQuery context,
                                     AmoebaQuery query)
                                     throws DBException
Retreives database data within the specified context

Parameters:
context - the context
query - the query
Returns:
ResultSetHandler for amoeba query
Throws:
XerialFSException
DBException

append

void append(AmoebaTuple tuple)
            throws DBException
Appends the data without specifying a particular context, i.e., the data will be inserted into the global context

Parameters:
tuple - a data to insert
Throws:
XerialFSException
DBException

append

void append(AmoebaQuery contest,
            AmoebaTuple tuple)
            throws DBException
Appends the data into the given context

Parameters:
context - the update context
tuple - a data to write
Throws:
XerialFSException
DBException

write

void write(AmoebaTuple tuple)
           throws DBException
Overwrites the data in the global context of the database file

Parameters:
tuple - a data to write
Throws:
XerialFSException
DBException

write

void write(AmoebaQuery context,
           AmoebaTuple tuple)
           throws DBException
Overwrites the data within the specified context

Parameters:
conetxt - the update context
tuple - a data to write
Throws:
XerialFSException
DBException


Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 2.1 Japan License.