
Ic           @   sU  d  Z  d d l Td d l Z d d l m Z d d l m Z d d l m Z d d l m Z d d l m Z d d l	 Td	   Z
 d
   Z d Z d f  d     YZ d f  d     YZ d f  d     YZ d f  d     YZ d e f d     YZ d e f d     YZ d f  d     YZ d e f d     YZ d e f d     YZ e d  Z d S(   s  
This module provides code to work with the sprotXX.dat file from
Utilities for working with FASTA-formatted sequences (OBSOLETE).
http://www.expasy.ch/sprot/sprot-top.html

Please see Bio.SwissProt for alternatives for the functionality in this module.

Tested with:
Release 37, Release 38, Release 39

Limited testing with:
Release 51, 54


Classes:
Record             Holds SwissProt data.
Reference          Holds reference data from a SwissProt entry.
Iterator           Iterates over entries in a SwissProt file.
Dictionary         Accesses a SwissProt file using a dictionary interface.
RecordParser       Parses a SwissProt record into a Record object.
SequenceParser     Parses a SwissProt record into a SeqRecord object.

_Scanner           Scans SwissProt-formatted data.
_RecordConsumer    Consumes SwissProt data to a SProt.Record object.
_SequenceConsumer  Consumes SwissProt data to a SeqRecord object.


Functions:
index_file         Index a SwissProt file for a Dictionary.

i(   t   *N(   t   File(   t   Index(   t   Alphabet(   t   Seq(   t	   SeqRecordc         c   s   d d l  m } d d  l } |   } d } xT |  D]L } | | 7} | d  d k r2 | j |  }  | j |   } d } | Vq2 q2 Wd  S(   Ni(   t   RecordParsert    i   s   //(   t   SProtR   t	   cStringIOt   StringIOt   parse(   t   handleR   R	   t   parsert   textt   linet   record(    (    s   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/SwissProt/SProt.pyR   0   s    	
c         C   s   d d l  m } |   } y | j |   } Wn: t k
 rh } | j j d  r_ t d   qi |  n X|  j   } | r t d   n  | S(   Ni(   R   s   Line does not start with 'ID':s   No SwissProt record founds$   More than one SwissProt record found(   R   R   R   t
   ValueErrort   messaget
   startswitht   read(   R   R   R   R   t   errort	   remainder(    (    s   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/SwissProt/SProt.pyR   =   s    	
s    
	.,;t   Recordc           B   s   e  Z d  Z d   Z RS(   s  Holds information from a SwissProt record.

    Members:
    entry_name        Name of this entry, e.g. RL1_ECOLI.
    data_class        Either 'STANDARD' or 'PRELIMINARY'.
    molecule_type     Type of molecule, 'PRT',
    sequence_length   Number of residues.

    accessions        List of the accession numbers, e.g. ['P00321']
    created           A tuple of (date, release).
    sequence_update   A tuple of (date, release).
    annotation_update A tuple of (date, release).

    description       Free-format description.
    gene_name         Gene name.  See userman.txt for description.
    organism          The source of the sequence.
    organelle         The origin of the sequence.
    organism_classification  The taxonomy classification.  List of strings.
                             (http://www.ncbi.nlm.nih.gov/Taxonomy/)
    taxonomy_id       A list of NCBI taxonomy id's.
    host_organism     A list of NCBI taxonomy id's of the hosts of a virus,
                      if any.
    references        List of Reference objects.
    comments          List of strings.
    cross_references  List of tuples (db, id1[, id2][, id3]).  See the docs.
    keywords          List of the keywords.
    features          List of tuples (key name, from, to, description).
                      from and to can be either integers for the residue
                      numbers, '<', '>', or '?'

    seqinfo           tuple of (length, molecular weight, CRC32 value)
    sequence          The sequence.
    
    c         C   s   d  |  _ d  |  _ d  |  _ d  |  _ g  |  _ d  |  _ d  |  _ d  |  _ d |  _	 d |  _
 d |  _ d |  _ g  |  _ g  |  _ g  |  _ g  |  _ g  |  _ g  |  _ g  |  _ g  |  _ d  |  _ d |  _ d  S(   NR   (   t   Nonet
   entry_namet
   data_classt   molecule_typet   sequence_lengtht
   accessionst   createdt   sequence_updatet   annotation_updatet   descriptiont	   gene_namet   organismt	   organellet   organism_classificationt   taxonomy_idt   host_organismt
   referencest   commentst   cross_referencest   keywordst   featurest   seqinfot   sequence(   t   self(    (    s   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/SwissProt/SProt.pyt   __init__s   s,    																					(   t   __name__t
   __module__t   __doc__R0   (    (    (    s   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/SwissProt/SProt.pyR   P   s   "t	   Referencec           B   s   e  Z d  Z d   Z RS(   s  Holds information from 1 references in a SwissProt entry.

    Members:
    number      Number of reference in an entry.
    positions   Describes extent of work.  list of strings.
    comments    Comments.  List of (token, text).
    references  References.  List of (dbname, identifier)
    authors     The authors of the work.
    title       Title of the work.
    location    A citation for the work.
    
    c         C   sC   d  |  _ g  |  _ g  |  _ g  |  _ d |  _ d |  _ d |  _ d  S(   NR   (   R   t   numbert	   positionsR)   R(   t   authorst   titlet   location(   R/   (    (    s   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/SwissProt/SProt.pyR0      s    						(   R1   R2   R3   R0   (    (    (    s   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/SwissProt/SProt.pyR4      s   t   Iteratorc           B   s,   e  Z d  Z d d  Z d   Z d   Z RS(   s   Returns one record at a time from a SwissProt file.

    Methods:
    next   Return the next record from the stream, or None.

    c         C   sn   d d l  } | j d t  t |  t k	 rO t |  t k	 rO t d   n  t j |  |  _	 | |  _
 d S(   s  __init__(self, handle, parser=None)

        Create a new iterator.  handle is a file-like object.  parser
        is an optional Parser object to change the results into another form.
        If set to None, then the raw contents of the file will be returned.

        iNs:  Bio.SwissProt.SProt.Iterator is deprecated. Please use the function Bio.SwissProt.parse instead if you want to get a SwissProt.SProt.Record, or Bio.SeqIO.parse if you want to get a SeqRecord. If these solutions do not work for you, please get in contact with the Biopython developers (biopython-dev@biopython.org).s,   I expected a file handle or file-like object(   t   warningst   warnt   DeprecationWarningt   typet   FileTypet   InstanceTypeR   R   t
   UndoHandlet   _uhandlet   _parser(   R/   R   R   R;   (    (    s   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/SwissProt/SProt.pyR0      s    	$c         C   s   g  } x> |  j  j   } | s" Pn  | j |  | d  d k r	 Pq	 q	 W| sQ d Sd j |  } |  j d k	 r |  j j t j |   S| S(   s   next(self) -> object

        Return the next swissprot record from the file.  If no more records,
        return None.

        i   s   //R   N(	   RB   t   readlinet   appendR   t   joinRC   R   R   t   StringHandle(   R/   t   linesR   t   data(    (    s   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/SwissProt/SProt.pyt   next   s    c         C   s   t  |  j d   S(   N(   t   iterRJ   R   (   R/   (    (    s   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/SwissProt/SProt.pyt   __iter__   s    N(   R1   R2   R3   R   R0   RJ   RL   (    (    (    s   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/SwissProt/SProt.pyR:      s   	t
   Dictionaryc           B   sD   e  Z d  Z d Z d d  Z d   Z d   Z d   Z d   Z	 RS(   s=   Accesses a SwissProt file using a dictionary interface.

    t
   __filenamec         C   s8   t  j  |  |  _ t |  j |  j  |  _ | |  _ d S(   s  __init__(self, indexname, parser=None)

        Open a SwissProt Dictionary.  indexname is the name of the
        index for the dictionary.  The index should have been created
        using the index_file function.  parser is an optional Parser
        object to change the results into another form.  If set to None,
        then the raw contents of the file will be returned.

        N(   R   t   _indext   opent   _Dictionary__filename_keyt   _handleRC   (   R/   t	   indexnameR   (    (    s   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/SwissProt/SProt.pyR0      s    
c         C   s   t  |  j  S(   N(   t   lenRO   (   R/   (    (    s   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/SwissProt/SProt.pyt   __len__   s    c         C   sa   |  j  | \ } } |  j j |  |  j j |  } |  j d  k	 r] |  j j t j |   S| S(   N(	   RO   RR   t   seekR   RC   R   R   R   RG   (   R/   t   keyt   startRT   RI   (    (    s   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/SwissProt/SProt.pyt   __getitem__   s    c         C   s   t  |  j |  S(   N(   t   getattrRO   (   R/   t   name(    (    s   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/SwissProt/SProt.pyt   __getattr__   s    c         C   s#   |  j  j   } | j |  j  | S(   N(   RO   t   keyst   removeRQ   (   R/   t   k(    (    s   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/SwissProt/SProt.pyR]      s    N(
   R1   R2   R3   RQ   R   R0   RU   RY   R\   R]   (    (    (    s   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/SwissProt/SProt.pyRM      s   			R   c           B   s    e  Z d  Z d   Z d   Z RS(   s1   Parses SwissProt data into a Record object.

    c         C   s   t    |  _ t   |  _ d  S(   N(   t   _Scannert   _scannert   _RecordConsumert	   _consumer(   R/   (    (    s   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/SwissProt/SProt.pyR0     s    c         C   s    |  j  j | |  j  |  j j S(   N(   Ra   t   feedRc   RI   (   R/   R   (    (    s   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/SwissProt/SProt.pyR     s    (   R1   R2   R3   R0   R   (    (    (    s   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/SwissProt/SProt.pyR      s   	t   SequenceParserc           B   s&   e  Z d  Z e j d  Z d   Z RS(   s<   Parses SwissProt data into a standard SeqRecord object.
    c         C   s   t    |  _ t |  |  _ d S(   s   Initialize a SequenceParser.

        Arguments:
        o alphabet - The alphabet to use for the generated Seq objects. If
        not supplied this will default to the generic protein alphabet.
        N(   R`   Ra   t   _SequenceConsumerRc   (   R/   t   alphabet(    (    s   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/SwissProt/SProt.pyR0     s    c         C   s    |  j  j | |  j  |  j j S(   N(   Ra   Rd   Rc   RI   (   R/   R   (    (    s   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/SwissProt/SProt.pyR     s    (   R1   R2   R3   R   t   generic_proteinR0   R   (    (    (    s   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/SwissProt/SProt.pyRe     s   
R`   c           B   sg  e  Z d  Z d   Z d   Z d   Z d d d d d  Z d   Z d   Z	 d   Z
 d   Z d	   Z d
   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z  d   Z! e e	 e
 e e e e e e e e e e e e e e e  e! g Z" RS(    sT   Scans SwissProt-formatted data.

    Tested with:
    Release 37
    Release 38
    c         C   s>   t  | t j  r | } n t j |  } |  j | |  d S(   s   feed(self, handle, consumer)

        Feed in SwissProt data for scanning.  handle is a file-like
        object that contains swissprot data.  consumer is a
        Consumer object that will receive events as the report is scanned.

        N(   t
   isinstanceR   RA   t   _scan_record(   R/   R   t   consumert   uhandle(    (    s   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/SwissProt/SProt.pyRd   %  s    	c         C   s-   x& d | j    d  k r( | j   } q Wd S(   s   Ignores any lines starting **s   **i   N(   t   peeklineRD   (   R/   Rl   t   skip(    (    s   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/SwissProt/SProt.pyt   _skip_starstar3  s    	c         C   s~   | j    xc |  j D]X } |  j |  | |  | |  | |  j j k r |  j | |  |  j | |  q q W| j   d  S(   N(   t   start_recordt	   _scan_fnsRo   t   _scan_drt   im_funct   _scan_cct
   end_record(   R/   Rl   Rk   t   fn(    (    s   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/SwissProt/SProt.pyRj   @  s    
c         C   sq   | s | r" t  | | d | n  | s. | rQ x  t | | d | s1 Pq1 q1 Wn  | rm t | | d | n  d  S(   NRX   (   t   read_and_callt   attempt_read_and_call(   R/   t	   line_typeRl   t   event_fnt   exactly_onet   one_or_moret
   any_numbert	   up_to_one(    (    s   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/SwissProt/SProt.pyt
   _scan_lineN  s    	c         C   s    |  j  d | | j d d d  S(   Nt   IDR{   i   (   R   t   identification(   R/   Rl   Rk   (    (    s   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/SwissProt/SProt.pyt   _scan_idc  s    c         C   s    |  j  d | | j d d d  S(   Nt   ACR}   i   (   R   t	   accession(   R/   Rl   Rk   (    (    s   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/SwissProt/SProt.pyt   _scan_acf  s    c         C   sX   |  j  d | | j d d |  j  d | | j d d |  j  d | | j d d d  S(   Nt   DTR{   i   R~   (   R   t   date(   R/   Rl   Rk   (    (    s   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/SwissProt/SProt.pyt   _scan_dtl  s    c         C   s    |  j  d | | j d d d  S(   Nt   DER}   i   (   R   R!   (   R/   Rl   Rk   (    (    s   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/SwissProt/SProt.pyt   _scan_der  s    c         C   s    |  j  d | | j d d d  S(   Nt   GNR}   i   (   R   R"   (   R/   Rl   Rk   (    (    s   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/SwissProt/SProt.pyt   _scan_gnv  s    c         C   s    |  j  d | | j d d d  S(   Nt   OSR|   i   (   R   t   organism_species(   R/   Rl   Rk   (    (    s   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/SwissProt/SProt.pyt   _scan_osy  s    c         C   s    |  j  d | | j d d d  S(   Nt   OGR}   i   (   R   R$   (   R/   Rl   Rk   (    (    s   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/SwissProt/SProt.pyt   _scan_og}  s    c         C   s    |  j  d | | j d d d  S(   Nt   OCR|   i   (   R   R%   (   R/   Rl   Rk   (    (    s   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/SwissProt/SProt.pyt   _scan_oc  s    c         C   s    |  j  d | | j d d d  S(   Nt   OXR}   i   (   R   R&   (   R/   Rl   Rk   (    (    s   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/SwissProt/SProt.pyt   _scan_ox  s    c         C   s    |  j  d | | j d d d  S(   Nt   OHR}   i   (   R   t   organism_host(   R/   Rl   Rk   (    (    s   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/SwissProt/SProt.pyt   _scan_oh  s    c         C   s   x t  r t |  d  d k r# Pn  |  j | |  |  j | |  |  j | |  |  j | |  |  j | |  |  j | |  |  j |  |  j	 | |  |  j | |  q Wd  S(   Ni   t   RN(
   t   Truet   safe_peeklinet   _scan_rnt   _scan_rpt   _scan_rct   _scan_rxt   _scan_rlt   _scan_raRo   t   _scan_rt(   R/   Rl   Rk   (    (    s   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/SwissProt/SProt.pyt   _scan_reference  s    	c         C   s    |  j  d | | j d d d  S(   NR   R{   i   (   R   t   reference_number(   R/   Rl   Rk   (    (    s   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/SwissProt/SProt.pyR     s    c         C   s    |  j  d | | j d d d  S(   Nt   RPR|   i   (   R   t   reference_position(   R/   Rl   Rk   (    (    s   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/SwissProt/SProt.pyR     s    c         C   s    |  j  d | | j d d d  S(   Nt   RCR}   i   (   R   t   reference_comment(   R/   Rl   Rk   (    (    s   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/SwissProt/SProt.pyR     s    c         C   s    |  j  d | | j d d d  S(   Nt   RXR}   i   (   R   t   reference_cross_reference(   R/   Rl   Rk   (    (    s   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/SwissProt/SProt.pyR     s    c         C   sX   |  j  d | | j d d |  j  d | | j d d |  j  d | | j d d d  S(   Nt   RAR}   i   t   RG(   R   t   reference_author(   R/   Rl   Rk   (    (    s   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/SwissProt/SProt.pyR     s    c         C   s    |  j  d | | j d d d  S(   Nt   RTR}   i   (   R   t   reference_title(   R/   Rl   Rk   (    (    s   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/SwissProt/SProt.pyR     s    c         C   s    |  j  d | | j d d d  S(   Nt   RLR}   i   (   R   t   reference_location(   R/   Rl   Rk   (    (    s   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/SwissProt/SProt.pyR     s    c         C   s    |  j  d | | j d d d  S(   Nt   CCR}   i   (   R   t   comment(   R/   Rl   Rk   (    (    s   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/SwissProt/SProt.pyRt     s    c         C   s    |  j  d | | j d d d  S(   Nt   DRR}   i   (   R   t   database_cross_reference(   R/   Rl   Rk   (    (    s   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/SwissProt/SProt.pyRr     s    c         C   s    |  j  d | | j d d d  S(   Nt   KWR}   i   (   R   t   keyword(   R/   Rl   Rk   (    (    s   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/SwissProt/SProt.pyt   _scan_kw  s    c         C   s    |  j  d | | j d d d  S(   Nt   FTR}   i   (   R   t   feature_table(   R/   Rl   Rk   (    (    s   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/SwissProt/SProt.pyt   _scan_ft  s    c         C   s    |  j  d | | j d d d  S(   Nt   PER}   i   (   R   t   protein_existence(   R/   Rl   Rk   (    (    s   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/SwissProt/SProt.pyt   _scan_pe  s    c         C   s    |  j  d | | j d d d  S(   Nt   SQR{   i   (   R   t   sequence_header(   R/   Rl   Rk   (    (    s   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/SwissProt/SProt.pyt   _scan_sq  s    c         C   s    |  j  d | | j d d d  S(   Ns     R|   i   (   R   t   sequence_data(   R/   Rl   Rk   (    (    s   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/SwissProt/SProt.pyt   _scan_sequence_data  s    c         C   s    |  j  d | | j d d d  S(   Ns   //R{   i   (   R   t
   terminator(   R/   Rl   Rk   (    (    s   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/SwissProt/SProt.pyt   _scan_terminator  s    N(#   R1   R2   R3   Rd   Ro   Rj   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   Rt   Rr   R   R   R   R   R   R   Rq   (    (    (    s   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/SwissProt/SProt.pyR`     sf   																														Rb   c           B   s.  e  Z d  Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z	 d   Z
 d	   Z d
   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z  d   Z! d    Z" RS(!   sy   Consumer that converts a SwissProt record to a Record object.

    Members:
    data    Record with SwissProt data.

    c         C   s   d  |  _ d  S(   N(   R   RI   (   R/   (    (    s   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/SwissProt/SProt.pyR0     s    c         C   s   d S(   Ns%   Bio.SwissProt.SProt._RecordConsumer()(    (   R/   (    (    s   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/SwissProt/SProt.pyt   __repr__  s    c         C   s   t    |  _ g  |  _ d  S(   N(   R   RI   t   _sequence_lines(   R/   (    (    s   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/SwissProt/SProt.pyRp     s    c         C   s,   |  j  |  j  d j |  j  |  j _ d  S(   NR   (   t   _clean_recordRI   RF   R   R.   (   R/   (    (    s   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/SwissProt/SProt.pyRu     s    c         C   sa  | j    } t |  d k ry | d |  j _ | d j t  |  j _ | d j t  |  j _ t | d  |  j _	 np t |  d k r | d |  j _ | d j t  |  j _ d  |  j _ t | d  |  j _	 n t d |   |  j j d k rt d |  j j | f   n  |  j j d  k	 r]|  j j d k r]t d |  j j | f   n  d  S(   Ni   i   i   i   i   i   s!   ID line has unrecognised format:
t   STANDARDt   PRELIMINARYt   IPIt   Reviewedt
   Unrevieweds%   Unrecognized data class %s in line
%st   PRTs(   Unrecognized molecule type %s in line
%s(   R   R   R   R   R   (   t   splitRT   RI   R   t   rstript   _CHOMPR   R   t   intR   R   R   (   R/   R   t   cols(    (    s   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/SwissProt/SProt.pyR   
  s(    			c         C   s_   | d j  t  j   j d  } x6 | D]. } | j   r) |  j j j | j    q) q) Wd  S(   Ni   t   ;(   R   R   t   stripR   RI   R   RE   (   R/   R   R   t   ac(    (    s   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/SwissProt/SProt.pyR   0  s    "c   
      C   s  | j    } | j   j   } | j d  d k s] | j d  d k s] | j d  d k r| j   } d } x< t t |   D]( } | | j d  d k r | } q q W| d k s t d |   | d } | | j t  } | d	 k r d }	 n* | j d
  d k r| }	 n t |  }	 | j d  d k rT| d |	 f |  j	 _
 q| j d  d k r| d |	 f |  j	 _ q| j d  d k r| d |	 f |  j	 _ qt st d   n| j d  d k s| j d  d k s| j d  d k ry t | d  }	 Wn t k
 r1d }	 n X| j d  d k r`| d |	 f |  j	 _
 q| j d  d k r| d |	 f |  j	 _ q| j d  d k r| d |	 f |  j	 _ qt st d   n t d |   d  S(   Nt   CREATEDi    s   LAST SEQUENCE UPDATEs   LAST ANNOTATION UPDATEis   REL.s"   Could not find Rel. in DT line: %si   R   t   .s   Shouldn't reach this line!s   INTEGRATED INTOs   SEQUENCE VERSIONs   ENTRY VERSIONt
   INTEGRATEDs#   I don't understand the date line %s(   t   upperR   R   t   findt   rangeRT   t   AssertionErrorR   R   RI   R   R   R    t   FalseR   (
   R/   R   t   uprlineR   t   uprcolst	   rel_indext   indext   version_indext   str_versiont   version(    (    s   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/SwissProt/SProt.pyR   7  sR    
		
c         C   s   |  j  j | d 7_ d  S(   Ni   (   RI   R!   (   R/   R   (    (    s   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/SwissProt/SProt.pyR!     s    c         C   s   |  j  j | d 7_ d  S(   Ni   (   RI   R"   (   R/   R   (    (    s   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/SwissProt/SProt.pyR"     s    c         C   s   |  j  j | d 7_ d  S(   Ni   (   RI   R#   (   R/   R   (    (    s   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/SwissProt/SProt.pyR     s    c         C   s   |  j  j | d 7_ d  S(   Ni   (   RI   R$   (   R/   R   (    (    s   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/SwissProt/SProt.pyR$     s    c         C   sP   | d j  t  } | j d  } x' | D] } |  j j j | j    q) Wd  S(   Ni   R   (   R   R   R   RI   R%   RE   t   lstrip(   R/   R   R   t   col(    (    s   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/SwissProt/SProt.pyR%     s    c         C   s   | d j  t  } | j d  } | d k rn | |  } | d k sT t d |   | | d j d  } n | j d  } |  j j j g  | D] } | j   ^ q  d  S(   Ni   t   =i    t
   NCBI_TaxIDs   Unexpected taxonomy type %si   t   ,(	   R   R   R   R   R   RI   R&   t   extendR   (   R/   R   R   t   descrt   idst   id(    (    s   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/SwissProt/SProt.pyR&     s    
c         C   s   | d j  t  } | j d  } | d k rn | |  } | d k sT t d |   | | d j d  } n | j d  } |  j j j g  | D] } | j   ^ q  d  S(   Ni   R   i    R   s   Unexpected taxonomy type %si   R   (	   R   R   R   R   R   RI   R'   R   R   (   R/   R   R   R   R   R   (    (    s   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/SwissProt/SProt.pyR     s    
c         C   sv   | d j    } | d d k r0 | d d k s@ t d |   t   } t | d d ! | _ |  j j j |  d  S(   Ni   i    t   [it   ]s   Missing brackets %si   (   R   R   R4   R   R5   RI   R(   RE   (   R/   R   t   rnt   ref(    (    s   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/SwissProt/SProt.pyR     s
    0	c         C   s@   |  j  j s t d   |  j  j d j j | d j    d  S(   Ns   RP: missing RNii   (   RI   R(   R   R6   RE   R   (   R/   R   (    (    s   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/SwissProt/SProt.pyR     s    c         C   s   |  j  j s t d   | d j   j d  } |  j  j d } x^ | D]V } | sZ qH n  | j d  } | |  | | d } } | j j | j   | f  qH Wd  S(   Ns   RC: missing RNi   R   iR   i   (	   RI   R(   R   R   R   R   R)   RE   R   (   R/   R   R   R   R   R   t   tokenR   (    (    s   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/SwissProt/SProt.pyR     s    c   	      C   s  |  j  j s t d   | j d  } | d k r@ | |  } n  | j d  d k r8| d j d  } g  | D] } | j   ^ qo } g  | D] } | r | ^ q } x | D] } | j d  } t |  d k s t d |   | d j t  | d	 j t  } } |  j  j d j } | j	 | | f  q Wnh | j   } t |  d
 k sft d |   |  j  j d j j	 | d	 j t  | d j t  f  d  S(   Ns   RX: missing RNs   [NCBI, ExPASy, Israel, Japan]i    R   ii   s   ; s   I don't understand RX line %si   i   (
   RI   R(   R   R   R   R   RT   R   R   RE   (	   R/   R   t   indR   t   xR   RW   t   valueR   (    (    s   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/SwissProt/SProt.pyR     s$    		"'"c         C   s?   |  j  j s t d   |  j  j d } | j | d 7_ d  S(   Ns   RA: missing RNii   (   RI   R(   R   R7   (   R/   R   R   (    (    s   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/SwissProt/SProt.pyR     s    c         C   s?   |  j  j s t d   |  j  j d } | j | d 7_ d  S(   Ns   RT: missing RNii   (   RI   R(   R   R8   (   R/   R   R   (    (    s   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/SwissProt/SProt.pyR     s    c         C   s?   |  j  j s t d   |  j  j d } | j | d 7_ d  S(   Ns   RL: missing RNii   (   RI   R(   R   R9   (   R/   R   R   (    (    s   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/SwissProt/SProt.pyR     s    c         C   s  | d d !d k r- |  j  j j | d  n | d d !d k r |  j  j sf |  j  j j | d  q|  j  j d c | d 7<n | d d !d k r |  j  j s |  j  j d d  d k r |  j  j j | d  q|  j  j d c | d 7<n |  j  j d c | d 7<d  S(	   Ni   i   s   -!-i	   s      is   ---i   (   RI   R)   RE   (   R/   R   (    (    s   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/SwissProt/SProt.pyR   $  s    'c         C   s   | d } | j  d  } | d k r2 | |  } n  | j t  j d  } g  | D] } | j   ^ qQ } |  j j j t |   d  S(   Ni   R   i    R   (	   R   R   R   R   R   RI   R*   RE   t   tuple(   R/   R   t   iR   R   (    (    s   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/SwissProt/SProt.pyR   7  s    
c         C   sL   | d j  t  j d  } |  j j j g  | D] } | j   ^ q/  d  S(   Ni   R   (   R   R   R   RI   R+   R   R   (   R/   R   R   t   c(    (    s   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/SwissProt/SProt.pyR   E  s    c   	      C   s|  | d } | d d !j    } y t | d d ! } Wn$ t k
 rZ | d d !j   } n Xy t | d d ! } Wn$ t k
 r | d d !j   } n X| d d	 !j    } | d d
 !d k r | d
 d	 !j    d  } n d } | sV| r | s t  |  j j d \ } } } } } |  j j d =d | | f } | d k rV|  j |  } qVn  |  j j j | | | | | f  d  S(   Ni   i    i   i	   i   i   i   i   iF   i#   s   /FTId=iR   s   %s %st   VARSPLIC(	   R   R   R   R   R   RI   R,   t   _fix_varsplic_sequencesRE   (	   R/   R   R[   t   from_rest   to_resR!   t   ft_idt   old_descriptiont	   old_ft_id(    (    s   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/SwissProt/SProt.pyR   I  s,    
c         C   s   | j  d  } t |  d k r | d } | d } d } | j d  } | d k rm | | } | |  } n  | j d d  } | j d d  } | d | | } n  | S(	   s  Remove unwanted spaces in sequences.

        During line carryover, the sequences in VARSPLIC can get mangled
        with unwanted spaces like:
        'DISSTKLQALPSHGLESIQT -> PCRATGWSPFRRSSPC LPTH'
        We want to check for this case and correct it as it happens.
        s    -> i   i    i   R   s    (it    (   R   RT   R   t   replace(   R/   R!   t
   descr_colst	   first_seqt
   second_seqt
   extra_infot   extra_info_pos(    (    s   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/SwissProt/SProt.pyR   e  s    


c         C   s   d  S(   N(    (   R/   R   (    (    s   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/SwissProt/SProt.pyR     s    c         C   s_   | j    } t |  d k s. t d |   t | d  t | d  | d f |  j _ d  S(   Ni   s   I don't understand SQ line %si   i   i   (   R   RT   R   R   RI   R-   (   R/   R   R   (    (    s   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/SwissProt/SProt.pyR     s    "c         C   s&   |  j  j | j d d  j    d  S(   NR  R   (   R   RE   R  R   (   R/   R   (    (    s   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/SwissProt/SProt.pyR     s    c         C   s   d  S(   N(    (   R/   R   (    (    s   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/SwissProt/SProt.pyR     s    c         C   sm   d d d d g } x3 | D]+ } t  | |  } t | | | j    q Wx | j D] } |  j |  qR Wd  S(   NR!   R"   R#   R$   (   RZ   t   setattrR   R(   t   _clean_references(   R/   t   rect   memberst   mt   attrR   (    (    s   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/SwissProt/SProt.pyR     s    c         C   sI   d d d g } x3 | D]+ } t  | |  } t | | | j    q Wd  S(   NR7   R8   R9   (   RZ   R  R   (   R/   R   R  R  R  (    (    s   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/SwissProt/SProt.pyR	    s    (#   R1   R2   R3   R0   R   Rp   Ru   R   R   R   R!   R"   R   R$   R%   R&   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R	  (    (    (    s   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/SwissProt/SProt.pyRb     sB   					&		[											'														Rf   c           B   s   e  Z d  Z e j d  Z d   Z d   Z d   Z d   Z	 d   Z
 d   Z d   Z d	   Z d
   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z RS(   s   Consumer that converts a SwissProt record to a SeqRecord object.

    Members:
    data      Record with SwissProt data.
    alphabet  The alphabet the generated Seq objects will have.
    c         C   s   d |  _ | |  _ d S(   s   Initialize a Sequence Consumer

        Arguments:
        o alphabet - The alphabet to use for the generated Seq objects. If
        not supplied this will default to the generic protein alphabet.
        N(   R   RI   Rg   (   R/   Rg   (    (    s   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/SwissProt/SProt.pyR0     s    	c         C   sU   t  j  d |  j  } t j |  |  _ d |  j _ d |  j _ d  |  _ g  |  _ d  S(   NR   (	   R   Rg   R   RI   R!   R[   R   t   _current_refR   (   R/   t   seq(    (    s   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/SwissProt/SProt.pyRp     s    	c         C   sx   |  j  d  k	 r5 |  j j d j |  j   d  |  _  n  |  j j j   |  j _ t j d j |  j	  |  j
  |  j _ d  S(   NR(   R   (   R  R   RI   t   annotationsRE   R!   R   R   RF   R   Rg   R  (   R/   (    (    s   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/SwissProt/SProt.pyRu     s
    c         C   s    | j    } | d |  j _ d  S(   Ni   (   R   RI   R[   (   R/   R   R   (    (    s   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/SwissProt/SProt.pyR     s    c         C   s   | d j    j d  } g  | D] } | j    r  | j    ^ q  } y |  j j d j |  Wn! t k
 r | |  j j d <n X|  j j d d |  j _ d  S(   Ni   R   R   i    (   R   R   RI   R  R   t   KeyErrorR   (   R/   R   R   R   (    (    s   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/SwissProt/SProt.pyR     s    +c         C   s(   |  j  j | d j   d |  j  _ d  S(   Ni   s   
(   RI   R!   R   (   R/   R   (    (    s   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/SwissProt/SProt.pyR!     s    c         C   s&   |  j  j | j d d  j    d  S(   NR  R   (   R   RE   R  R   (   R/   R   (    (    s   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/SwissProt/SProt.pyR     s    c         C   sJ   y |  j  j d c | d 7<Wn% t k
 rE | d |  j  j d <n Xd  S(   NR"   i   (   RI   R  R  (   R/   R   (    (    s   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/SwissProt/SProt.pyR"     s    c         C   sN   y" |  j  j d c d | d 7<Wn% t k
 rI | d |  j  j d <n Xd  S(   NR   s   
i   (   RI   R  R  (   R/   R   (    (    s   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/SwissProt/SProt.pyR     s    "c         C   s   g  | d j  t  j d  D] } | j    ^ q } t |  d k r d | d | d f } | |  j j k r |  j j j |  q n  d  S(   Ni   R   i   s   %s:%si    (   R   R   R   RT   RI   t   dbxrefsRE   (   R/   R   R   t   partsR   (    (    s   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/SwissProt/SProt.pyR     s
    5c         C   s   | j    d } | j   } | j d  d k rD | |  j j d <nP | j d  d k rl | |  j j d <n( | j d  d k r | |  j j d <n  d  S(   Ni    R   R   s   LAST SEQUENCE UPDATEt   date_last_sequence_updates   LAST ANNOTATION UPDATEt   date_last_annotation_update(   R   R   R   RI   R  (   R/   R   t   date_strR   (    (    s   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/SwissProt/SProt.pyR     s    c         C   s   | d j  t  j d  } g  | D] } | j   ^ q# } t d  |  } y |  j j d j |  Wn! t	 k
 r | |  j j d <n Xd  S(   Ni   R   R+   (
   R   R   R   R   t   filterR   RI   R  R   R  (   R/   R   R   R   (    (    s   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/SwissProt/SProt.pyR     s    c         C   sY   | d j  t  } y |  j j d c d | 7<Wn! t k
 rT | |  j j d <n Xd  S(   Ni   R#   R  (   R   R   RI   R  R  (   R/   R   RI   (    (    s   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/SwissProt/SProt.pyR   '  s
    c         C   s   | d j  t  } | j d  } | d k rn | |  } | d k sT t d |   | | d j d  } n | j d  } y |  j j d j |  Wn! t k
 r | |  j j d <n Xd  S(	   Ni   R   i    R   s   Unexpected taxonomy type %si   R   R   (	   R   R   R   R   R   RI   R  R   R  (   R/   R   RI   R   R   R   (    (    s   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/SwissProt/SProt.pyR   1  s    
c         C   s~   | d j  t  } g  | j d  D] } | j   ^ q# } y |  j j d j |  Wn! t k
 ry | |  j j d <n Xd  S(   Ni   R   t   taxonomy(   R   R   R   R   RI   R  R   R  (   R/   R   R   R   (    (    s   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/SwissProt/SProt.pyR%   B  s    (c         C   s   | d j  t  } | j d  } | d k rn | |  } | d k sT t d |   | | d j d  } n | j d  } y |  j j d j |  Wn! t k
 r | |  j j d <n Xd  S(	   Ni   R   i    R   s   Unexpected taxonomy type %si   R   t
   ncbi_taxid(	   R   R   R   R   R   RI   R  R   R  (   R/   R   R   R   R   (    (    s   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/SwissProt/SProt.pyR&   O  s    
c         C   s\   d d l  m } |  j d k	 r< |  j j d j |  j  n g  |  j j d <|   |  _ d S(   s3   RN line, reference number (start of new reference).i(   R4   R(   N(   t   Bio.SeqFeatureR4   R  R   RI   R  RE   (   R/   R   R4   (    (    s   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/SwissProt/SProt.pyR   d  s
    c         C   s   |  j  d k	 s t d   d S(   s   RP line, reference position.s   RP: missing RNN(   R  R   R   (   R/   R   (    (    s   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/SwissProt/SProt.pyR   p  s    c         C   s  |  j  d k	 s t d   | j d  d k r#| d j d  } g  | D] } | j   ^ qJ } g  | D] } | ri | ^ qi } xQ| D] } | j d  } t |  d k s t d |   | d j t  | d j t  } } | d	 k r| |  j  _	 q | d
 k r | |  j  _
 q q Wn | j d  } | d k rK| |  } n  | j   } t |  d k syt d |   | d j t  } | d j t  } | d	 k r| |  j  _	 n | d
 k r| |  j  _
 n  d S(   s$   RX line, reference cross-references.s   RX: missing RNR   ii   s   ; s   I don't understand RX line %si    i   t   MEDLINEt   PubMeds   [NCBI, ExPASy, Israel, Japan]i   N(   R  R   R   R   R   R   RT   R   R   t
   medline_idt	   pubmed_id(   R/   R   R   R   R   RW   R   R   (    (    s   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/SwissProt/SProt.pyR   x  s4    "'"c         C   s>   |  j  d k	 s t d   |  j  j | d j d  7_ d S(   s   RA line, reference author(s).s   RA: missing RNi   s   
N(   R  R   R   R7   R   (   R/   R   (    (    s   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/SwissProt/SProt.pyR     s    c         C   s>   |  j  d k	 s t d   |  j  j | d j d  7_ d S(   s   RT line, reference title.s   RT: missing RNi   s   
N(   R  R   R   R8   R   (   R/   R   (    (    s   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/SwissProt/SProt.pyR     s    c         C   s>   |  j  d k	 s t d   |  j  j | d j d  7_ d S(   s=   RL line, reference 'location' - journal, volume, pages, year.s   RL: missing RNi   s   
N(   R  R   R   t   journalR   (   R/   R   (    (    s   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/SwissProt/SProt.pyR     s    c         C   s>   |  j  d k	 s t d   |  j  j | d j d  7_ d S(   s   RC line, reference comment.s   RC: missing RNi   s   
N(   R  R   R   R   R   (   R/   R   (    (    s   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/SwissProt/SProt.pyR     s    (   R1   R2   R3   R   Rh   R0   Rp   Ru   R   R   R!   R   R"   R   R   R   R   R   R   R%   R&   R   R   R   R   R   R   R   (    (    (    s   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/SwissProt/SProt.pyRf     s0   
								
				
						0			c         C   s  d d l  m } t j j |   s5 t d |    n  t j | d d } |  | t j <t	 |   } | |  } d } x | D] } | }	 t
 | j    } | |	 }
 | d	 k	 r | |  } n	 | j } | s t d   n | | k r t d |   n  |	 |
 f | | <q| Wd	 S(
   sX  index_file(filename, indexname, rec2key=None)

    Index a SwissProt file.  filename is the name of the file.
    indexname is the name of the dictionary.  rec2key is an
    optional callback that takes a Record and generates a unique key
    (e.g. the accession number) for the record.  If not specified,
    the entry name will be used.

    i(   R   s   %s does not existt   truncatei   l    s   empty sequence key was produceds   duplicate key %s foundN(   t   Bio.SwissProtR   t   ost   patht   existsR   R   RM   RQ   RP   t   longt   tellR   R   R  (   t   filenameRS   t   rec2keyR   R   R   t   recordst   endR   RX   t   lengthRW   (    (    s   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/SwissProt/SProt.pyt
   index_file  s(    

	(   R3   t   typesR"  t   BioR   R   R   R   R   t   Bio.ParserSupportR   R   R   R   R4   R:   RM   t   AbstractParserR   Re   R`   t   AbstractConsumerRb   Rf   R   R,  (    (    (    s   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/SwissProt/SProt.pyt   <module>$   s.   

		>3)  