Commits

Marko Toplak committed c25fb8a

Renamed BufferSQLite -> CacheSQLite. dicty documentation updates.

Comments (0)

Files changed (4)

docs/rst/reference/dicty.rst

 
 .. py:currentmodule:: Orange.bio.dicty
 
+.. autoclass:: Orange.bio.dicty.PIPAx
+   :members: __init__, genomes, get_data, mappings, result_types, results_list
+
 .. autoclass:: Orange.bio.dicty.DictyExpress
-   :members: objects, annotationTypes, annotations, get_data, search
+   :members: __init__, objects, annotationTypes, annotations, get_data, search
 
-.. autoclass:: Orange.bio.dicty.PIPA
-   :members:
+Auxillary functionality
+-----------------------
 
-.. autoclass:: Orange.bio.dicty.PIPAx
-   :members:
+.. autoclass:: Orange.bio.dicty.CacheSQLite
+    :members: __init__, list, contains, add, get, commit, clear
 
-
-

orangecontrib/bio/dicty/__init__.py

 
 class PIPA(DBCommon):
 
-    def __init__(self, address=defaddresspipa, buffer=None, username=None, password=None):
+    def __init__(self, address=defaddresspipa, cache=None, username=None, password=None):
         self.address = address
         self.db=DBInterface(address)
         self.db_coverage=DBInterface(defaddresspipa_coverage) #temporary
-        self.buffer = buffer
+        self.buffer = cache
         self.username = None
         if username != None:
             self.username = username
 
     API_ADDRESS = "https://pipa.biolab.si/pipax/api.py"
 
-    def __init__(self, address=API_ADDRESS, buffer=None,
+    def __init__(self, address=API_ADDRESS, cache=None,
                  username=None, password=None):
         self.address = address
         self.db = DBInterface(address)
-        self.buffer = buffer
+        self.buffer = cache
         self.username = username
         self.password = password
 
 extractions extractions
 chips chips""")
 
-    def __init__(self, address=defaddress, buffer=None):
+    def __init__(self, address=defaddress, cache=None):
         self.address = address
         self.db = DBInterface(address)
-        self.buffer = buffer
+        self.buffer = cache
         self.preload()
 
     def preload(self):
             self.fn()
             self.cbs += 1
 
-class BufferSQLite(object):
+class CacheSQLite(object):
+    """
+    An SQLite-based cache. 
+    """
 
     def __init__(self, filename, compress=True):
+        """
+        Creates a new buffer.
+
+        :param str filename: The filename.
+        :param bool compress: Whether to use on-the-fly compression.
+        """
         self.compress = compress
         self.filename = filename
         self.conn = self.connect()
 
     def clear(self):
         """
-        Removes all entries in the buffer
+        Remove all entries in the buffer.
         """
         self.conn.close()
         os.remove(self.filename)
         return conn
 
     def contains(self, addr):
-        """ Returns version or False, if it does not exists """
+        """ Return the element's version or False, if the element does not exists. 
+
+        :param addr: Element address.
+        """
         c = self.conn.cursor()
         c.execute('select time from buf where address=?', (addr,))
         lc = list(c)
             return lc[0][0]
 
     def list(self):
+        """ List all element addresses in the cache. """
         c = self.conn.cursor()
         c.execute('select address from buf')
         return nth(list(c), 0)
 
     def add(self, addr, con, version="0", autocommit=True):
+        """ Inserts an element into the cache. 
+        
+        :param addr: Element address.
+        :param con: Contents.
+        :param version: Version.
+        """
         import cPickle, zlib, sqlite3
         if verbose:
             print "Adding", addr
             self.commit()
 
     def commit(self):
+        """ Commit the changes. Run only if previous :obj:`~CacheSQLite.add`
+        was called without autocommit."""
         self.conn.commit()
 
     def get(self, addr):
+        """ Loads an element from the cache.
+
+        :param addr: Element address.
+        """
         import cPickle, zlib
         if verbose:
             print "getting from buffer", addr
     a = DictyBase()
     print len(a.info)
 
-    dbc = DictyExpress(buffer=BufferSQLite("../tmpbufnew"))
+    dbc = DictyExpress(cache=CacheSQLite("../tmpbufnew"))
 
     print dbc.annotationOptions()
 
     printet(et)
     """
 
-    d = PIPA(buffer=BufferSQLite("../tmpbufnewpipa"))
+    d = PIPA(cache=CacheSQLite("../tmpbufnewpipa"))
 
     print d.gene_expression_types()
 

orangecontrib/bio/widgets/OWDicty.py

         self.platform = None
 
         self.selectedExperiments = []
-        self.buffer = obiDicty.BufferSQLite(bufferfile)
+        self.buffer = obiDicty.CacheSQLite(bufferfile)
 
         self.searchString = ""
         self.excludeconstant = False
             address += "token="+self.serverToken+"&"
         try:
             #obiDicty.verbose = 1
-            self.dbc = obiDicty.DatabaseConnection(address, buffer=self.buffer)
+            self.dbc = obiDicty.DatabaseConnection(address, cache=self.buffer)
         except Exception, ex:
             from traceback import print_exception
             print_exception(*sys.exc_info())

orangecontrib/bio/widgets/OWPIPAx.py

         self.rtypei = 5 #hardcoded rpkm mapability polya
 
         self.selectedExperiments = []
-        self.buffer = obiDicty.BufferSQLite(bufferfile)
+        self.buffer = obiDicty.CacheSQLite(bufferfile)
 
         self.searchString = ""
         self.excludeconstant = False
         def en(x):
             return x if len(x) else None
 
-        self.dbc = obiDicty.PIPAx(buffer=self.buffer,
+        self.dbc = obiDicty.PIPAx(cache=self.buffer,
                                   username=en(self.username),
                                   password=self.password)