Back to index

python-biopython  1.60
Public Member Functions | Public Attributes
getgene.DB_Index Class Reference

List of all members.

Public Member Functions

def __init__
def Create
def Open
def Close
def Get
def Get_Organism
def FixOS
def Get_Taxonomy
def Get_Kingdom
def Get_Gene
def Get_OS_OC_GN
def Get_OS_OC_OG
def Get_SQ
def Get_XX
def Get_Keywords

Public Attributes

 db
 datafile
 fid

Detailed Description

Definition at line 38 of file getgene.py.


Constructor & Destructor Documentation

def getgene.DB_Index.__init__ (   self,
  open = 1 
)

Definition at line 39 of file getgene.py.

00039 
00040     def __init__(self, open = 1):
00041         if open: self.Open()
            

Here is the call graph for this function:


Member Function Documentation

def getgene.DB_Index.Close (   self)

Definition at line 82 of file getgene.py.

00082 
00083     def Close(self):
00084         self.db.close()
        

Here is the caller graph for this function:

def getgene.DB_Index.Create (   self,
  infile,
  outfile 
)

Definition at line 42 of file getgene.py.

00042 
00043     def Create(self, infile, outfile):
00044         db = gdbm.open(outfile, 'n')
00045         fid = open(infile)
00046 
00047         db['datafile'] = os.path.abspath(infile)
00048         
00049         while 1:
00050             line = fid.readline()
00051             if not line or not len(line): break
00052 
00053             if line[:3] == 'ID ':
00054                 id = string.split(line)[1]
00055                 start = fid.tell() - len(line)
00056 
00057             elif line[:3] == 'AC ':
00058                 acc = string.split(line)[1]
00059                 if acc[-1] ==';': acc = acc[:-1]
00060 
00061             elif line[:2] =='//':
00062                 stop = fid.tell()
00063                 try:
00064                     value = '%d %d' % (start, stop)
00065                     db[id] = value
00066                     db[acc] = value
00067                     id, acc, start, stop = None, None, None, None
00068                 except:
00069                     print 'AARRGGGG', start, stop, type(start), type(stop)
00070                     print id, acc
00071                     
00072         db.close()
00073         fid.close()

Here is the call graph for this function:

def getgene.DB_Index.FixOS (   self,
  os 
)

Definition at line 106 of file getgene.py.

00106 
00107     def FixOS(self, os):
00108         os = string.split(os,',')[0]
00109         os = string.split(os,'(')[0]
00110         return string.strip(os)
    
def getgene.DB_Index.Get (   self,
  id 
)

Definition at line 85 of file getgene.py.

00085 
00086     def Get(self, id):
00087         try:
00088             values = self.db[id]
00089         except:
00090             return None
00091         start, stop= map(int,string.split(values))
00092         self.fid.seek(start)
00093         txt = self.fid.read(stop - start)
00094         return txt
        

Here is the caller graph for this function:

def getgene.DB_Index.Get_Gene (   self,
  id 
)

Definition at line 135 of file getgene.py.

00135 
00136     def Get_Gene(self, id):
00137         entry = self.Get(id)
00138         if not entry: return None
00139         GN = ''
00140         for line in string.split(entry, '\n'):
00141             if line[0:5] == 'GN   ':
00142                 GN = string.strip(line[5:])
00143                 if GN[-1] ==".": GN = GN[0:-1]
00144                 return GN
00145             if line[0:2] =="//": break
00146         return GN
00147 

Here is the call graph for this function:

def getgene.DB_Index.Get_Keywords (   self,
  id 
)

Definition at line 207 of file getgene.py.

00207 
00208     def Get_Keywords(self, id):
00209         entry = self.Get(id)
00210         if not entry: return []
00211         keywords = []
00212         for line in string.split(entry, '\n'):
00213             if line[0:5] == 'KW   ':
00214                 for i in string.split(string.strip(line[5:]),';'):
00215                     kw = string.strip(i)
00216                     if len(kw) < 2: continue
00217                     if kw[-1] == '.': kw = kw[:-1]
00218                     keywords.append(kw)
00219             if line[0:2] =="//": break
00220         return keywords
00221 
00222 

Here is the call graph for this function:

def getgene.DB_Index.Get_Kingdom (   self,
  id 
)

Definition at line 122 of file getgene.py.

00122 
00123     def Get_Kingdom(self, id):
00124         res = self.Get_Taxonomy(id)
00125         #print id, res
00126         if not res: return "U"
00127         kd = string.strip(string.split(res,";")[0])
00128         if kd == "Eubacteria" or kd == "Prokaryota" or kd == "Bacteria": return "B"
00129         elif kd == "Eukaryota" or kd =="Eukaryotae": return "E"
00130         elif kd == "Archaebacteria" or kd == "Archaea": return "A"
00131         elif kd == "Viridae" or kd == "Viruses": return "V"
00132         else:
00133             print kd, "UNKNOWN"
00134             return "U"
        

Here is the call graph for this function:

def getgene.DB_Index.Get_Organism (   self,
  id 
)

Definition at line 95 of file getgene.py.

00095 
00096     def Get_Organism(self, id):
00097         entry = self.Get(id)
00098         if not entry: return None
00099         for line in string.split(entry, '\n'):
00100             if line[0:5] == 'OS   ':
00101                 OS = string.strip(line[5:])
00102                 if OS[-1] ==".": OS = OS[0:-1]
00103                 return OS
00104             if line[0:2] =="//": break
00105         return OS

Here is the call graph for this function:

def getgene.DB_Index.Get_OS_OC_GN (   self,
  id 
)

Definition at line 148 of file getgene.py.

00148 
00149     def Get_OS_OC_GN(self, id):
00150         entry = self.Get(id)
00151         if not entry: return None, None, None
00152         OS, OC, GN = "","",""
00153         for line in string.split(entry, '\n'):
00154             if line[0:5] == 'OS   ':
00155                 OS = string.strip(line[5:])
00156                 if OS[-1] ==".": OS = OS[0:-1]
00157             if line[0:5] == 'OC   ':
00158                 OC = OC + string.strip(line[5:])
00159                 if OC[-1] ==".": OC = OC[0:-1]
00160             if line[0:5] == 'GN   ':
00161                 GN = string.strip(line[5:])
00162                 if GN[-1] ==".": GN = GN[0:-1]
00163             if line[0:2] =="//": break
00164         return OS, OC, GN
    

Here is the call graph for this function:

def getgene.DB_Index.Get_OS_OC_OG (   self,
  id 
)

Definition at line 165 of file getgene.py.

00165 
00166     def Get_OS_OC_OG(self, id):
00167         entry = self.Get(id)
00168         if not entry: return None, None, None
00169         OS, OC, OG = "","",""
00170         for line in string.split(entry, '\n'):
00171             if line[0:5] == 'OS   ':
00172                 OS = string.strip(line[5:])
00173                 if OS[-1] ==".": OS = OS[0:-1]
00174             if line[0:5] == 'OC   ':
00175                 OC = OC + string.strip(line[5:])
00176                 if OC[-1] ==".": OC = OC[0:-1]
00177             if line[0:5] == 'OG   ':
00178                 OG = string.strip(line[5:])
00179                 if OG[-1] ==".": OG = OG[0:-1]
00180             if line[0:2] =="//": break
00181         return OS, OC, OG

Here is the call graph for this function:

def getgene.DB_Index.Get_SQ (   self,
  id,
  fasta = 1 
)

Definition at line 182 of file getgene.py.

00182 
00183     def Get_SQ(self, id, fasta = 1):
00184         entry = self.Get(id)
00185         if not entry: return ""
00186         SQ = ""
00187         record = 0
00188         for line in string.split(entry, '\n'):
00189             if record: SQ = SQ + string.strip(line[5:])
00190             if line[0:5] == 'SQ   ': record = 1
00191             if line[0:2] =="//": break
00192 
00193         SQ = re.sub('[ \n]','',SQ)
00194         if fasta: SQ = '>%s\n%s' % (id, re.sub('(.{60})','\\1\n',SQ))
00195         return SQ

Here is the call graph for this function:

def getgene.DB_Index.Get_Taxonomy (   self,
  id 
)

Definition at line 111 of file getgene.py.

00111 
00112     def Get_Taxonomy(self, id):
00113         entry = self.Get(id)
00114         if not entry: return None
00115         OC = ""
00116         for line in string.split(entry, '\n'):
00117             if line[0:5] == 'OC   ':
00118                 OC = OC + string.strip(line[5:])
00119                 if OC[-1] ==".": OC = OC[0:-1]
00120             if line[0:2] =="//": break
00121         return OC
    

Here is the call graph for this function:

Here is the caller graph for this function:

def getgene.DB_Index.Get_XX (   self,
  id,
  xx 
)

Definition at line 196 of file getgene.py.

00196 
00197     def Get_XX(self, id, xx):
00198         entry = self.Get(id)
00199         if not entry: return ""
00200         XX = ""
00201         for line in string.split(entry, '\n'):
00202             if line[0:5] == '%s   ' % xx:
00203                 XX = XX + string.strip(line[5:])
00204                 if XX[-1] ==".": XX = XX[0:-1]
00205             if line[0:2] =="//": break
00206         return XX
        

Here is the call graph for this function:

def getgene.DB_Index.Open (   self,
  indexfile = None 
)

Definition at line 74 of file getgene.py.

00074 
00075     def Open(self, indexfile = None):
00076         if not indexfile:
00077             indexfile = os.path.join(os.environ['PYPHY'],'nr.dat.indexed')
00078 
00079         self.db = gdbm.open(indexfile)
00080         self.datafile = self.db['datafile']
00081         self.fid = open(self.datafile)

Here is the caller graph for this function:


Member Data Documentation

Definition at line 79 of file getgene.py.

Definition at line 78 of file getgene.py.

Definition at line 80 of file getgene.py.


The documentation for this class was generated from the following file: