[pygr-notify] [pygr commit] r77 - wiki
codesite-noreply at google.com
codesite-noreply at google.com
Tue Jul 22 11:20:49 PDT 2008
Author: titus at idyll.org
Date: Tue Jul 22 11:20:04 2008
New Revision: 77
Added:
wiki/SimpleAnnotationDB.wiki
Log:
Created wiki page through web user interface.
Added: wiki/SimpleAnnotationDB.wiki
==============================================================================
--- (empty file)
+++ wiki/SimpleAnnotationDB.wiki Tue Jul 22 11:20:04 2008
@@ -0,0 +1,43 @@
+#summary Notes on making the simplest possible (?) annotation DB
+
+= Introduction =
+
+Sometimes it's nice to know exactly what behavior you need to
implement to get
+something minimal going. Here are some notes on doing that with an AnnotationDB-a-like
+object that doesn't support pickling or anything fancy; it just acts
as an AnnotationDB.
+
+
+= Details =
+
+Here's the basic code:
+
+{{{
+class MyAnno(SeqPath):
+ step = 1
+
+ def __init__(self,id,db,parent,start,stop):
+ self.id = id # unique name of this feature
+ self.db = db # annotation database for lookups
+ # self.start -> 0
+ self.stop = stop-start # reset to start at 0
+ self._anno_seq = parent # actual sequence
+ self._anno_start = start # offset within sequence
+ self.path = self # simple SeqPath obj
+
+class MyAnnoDB(object):
+ def __init__(self, seqDB):
+ self.d = {}
+ self.seqDB = seqDB
+
+ def add(self, f):
+ self.d[f.id] = f
+
+ def __getitem__(self, k):
+ return self.d[k]
+
+}}}
+
+OK, a few notes:
+
+ - MyAnnoDB.seqDB is necessay for lookups, e.g. annotation.sequence
will look for annodb.seqDB.
+ - apart from that, MyAnnoDB really only needs to implement the
__getitem__ protocol for retrieving values by key.
\ No newline at end of file
More information about the pygr-notify
mailing list