Back to index

python-biopython  1.60
Namespaces | Classes | Functions
Bio.UniGene Namespace Reference

Namespaces

namespace  UniGene

Classes

class  SequenceLine
class  ProtsimLine
class  STSLine
class  Record

Functions

def parse
def read
def _read

Function Documentation

def Bio.UniGene._read (   handle) [private]

Definition at line 271 of file __init__.py.

00271 
00272 def _read(handle):
00273     UG_INDENT = 12
00274     record = None
00275     for line in handle:
00276         tag, value = line[:UG_INDENT].rstrip(), line[UG_INDENT:].rstrip()
00277         line = line.rstrip()
00278         if tag=="ID":
00279             record = Record()
00280             record.ID = value
00281             record.species = record.ID.split('.')[0]
00282         elif tag=="TITLE":
00283             record.title = value
00284         elif tag=="GENE":
00285             record.symbol = value
00286         elif tag=="GENE_ID":
00287             record.gene_id = value
00288         elif tag=="LOCUSLINK":
00289             record.locuslink = value
00290         elif tag=="HOMOL":
00291             if value=="YES":
00292                 record.homol = True
00293             elif value=="NO":
00294                 record.homol = True
00295             else:
00296                 raise ValueError, "Cannot parse HOMOL line %s" % line
00297         elif tag=="EXPRESS":
00298             record.express = [word.strip() for word in value.split("|")]
00299         elif tag=="RESTR_EXPR":
00300             record.restr_expr = [word.strip() for word in value.split("|")]
00301         elif tag=="CHROMOSOME":
00302             record.chromosome = value
00303         elif tag=="CYTOBAND":
00304             record.cytoband = value
00305         elif tag=="PROTSIM":
00306             protsim = ProtsimLine(value)
00307             record.protsim.append(protsim)
00308         elif tag=="SCOUNT":
00309             scount = int(value)
00310         elif tag=="SEQUENCE":
00311             sequence = SequenceLine(value)
00312             record.sequence.append(sequence)
00313         elif tag=="STS":
00314             sts = STSLine(value)
00315             record.sts.append(sts)
00316         elif tag=='//':
00317             if len(record.sequence)!=scount:
00318                 raise ValueError, "The number of sequences specified in the record (%d) does not agree with the number of sequences found (%d)" % (scount, len(record.sequence))
00319             return record
00320         else:
00321             raise ValueError, "Unknown tag %s" % tag
00322     if record:
00323         raise ValueError("Unexpected end of stream.")

Here is the caller graph for this function:

def Bio.UniGene.parse (   handle)

Definition at line 249 of file __init__.py.

00249 
00250 def parse(handle):
00251     while True:
00252         record = _read(handle)
00253         if not record:
00254             return
00255         yield record
00256 

Here is the call graph for this function:

def Bio.UniGene.read (   handle)

Definition at line 257 of file __init__.py.

00257 
00258 def read(handle):
00259     record = _read(handle)
00260     if not record:
00261         raise ValueError("No SwissProt record found")
00262     # We should have reached the end of the record by now
00263     remainder = handle.read()
00264     if remainder:
00265         raise ValueError("More than one SwissProt record found")
00266     return record
00267 
00268 
00269 # Everything below is private
00270 

Here is the call graph for this function: