Back to index

python-biopython  1.60
Classes | Functions | Variables
Bio.SeqIO.UniprotIO Namespace Reference

Classes

class  Parser

Functions

def UniprotIterator

Variables

string NS = "{http://uniprot.org/uniprot}"
string REFERENCE_JOURNAL = "%(name)s %(volume)s:%(first)s-%(last)s(%(pub_date)s)"

Function Documentation

def Bio.SeqIO.UniprotIO.UniprotIterator (   handle,
  alphabet = Alphabet.ProteinAlphabet(),
  return_raw_comments = False 
)
Generator function to parse UniProt XML as SeqRecord objects.

parses an XML entry at a time from any UniProt XML file 
returns a SeqRecord for each iteration

This generator can be used in Bio.SeqIO

return_raw_comments = True --> comment fields are returned as complete xml to allow further processing
skip_parsing_errors = True --> if parsing errors are found, skip to next entry

Definition at line 43 of file UniprotIO.py.

00043 
00044 def UniprotIterator(handle, alphabet=Alphabet.ProteinAlphabet(), return_raw_comments=False):
00045     """Generator function to parse UniProt XML as SeqRecord objects.
00046     
00047     parses an XML entry at a time from any UniProt XML file 
00048     returns a SeqRecord for each iteration
00049     
00050     This generator can be used in Bio.SeqIO
00051     
00052     return_raw_comments = True --> comment fields are returned as complete xml to allow further processing
00053     skip_parsing_errors = True --> if parsing errors are found, skip to next entry
00054     """
00055     if isinstance(alphabet, Alphabet.NucleotideAlphabet):
00056         raise ValueError, "Wrong alphabet %r" % alphabet
00057     if isinstance(alphabet, Alphabet.Gapped):
00058         if isinstance(alphabet.alphabet, Alphabet.NucleotideAlphabet):
00059             raise ValueError, "Wrong alphabet %r" % alphabet
00060 
00061     if not hasattr(handle, "read"):
00062         if type(handle)==type(''):
00063             handle=StringIO(handle)
00064         else:
00065             raise Exception('An XML-containing handler or an XML string must be passed')
00066 
00067     if ElementTree is None:
00068         from Bio import MissingExternalDependencyError
00069         raise MissingExternalDependencyError(
00070                 "No ElementTree module was found. "
00071                 "Use Python 2.5+, lxml or elementtree if you "
00072                 "want to use Bio.SeqIO.UniprotIO.")
00073         
00074     for event, elem in ElementTree.iterparse(handle, events=("start", "end")):
00075         if event=="end" and elem.tag == NS + "entry":
00076             yield Parser(elem, alphabet=alphabet, return_raw_comments=return_raw_comments).parse()
00077             elem.clear()

Here is the call graph for this function:


Variable Documentation

string Bio.SeqIO.UniprotIO.NS = "{http://uniprot.org/uniprot}"

Definition at line 40 of file UniprotIO.py.

string Bio.SeqIO.UniprotIO.REFERENCE_JOURNAL = "%(name)s %(volume)s:%(first)s-%(last)s(%(pub_date)s)"

Definition at line 41 of file UniprotIO.py.