ó
Y_Sc           @@  sR   d  Z  d d l m Z d d l Td d l Td Z d Z d
 d „ Z d
 d	 „ Z	 d
 S(   sT   Read GenBank flat files. 

Currently only reads sequence data and not annotations.

i    (   t   absolute_importi   (   t   *t   genbankt   gbt   gbkc         C@  s,   g  t  |  | ƒ D] } | ^ q } t | ƒ S(   s  Read and parse a file of genbank records. 

    Args:
    fin -- A stream or file to read
    alphabet -- The expected alphabet of the data, if given
    
    Returns: 
    SeqList -- A list of sequences
    
    Raises: 
    ValueError -- If the file is unparsable
    (   t   iterseqt   SeqList(   t   fint   alphabett   st   seqs(    (    sC   /home/psgendb/BIRCHDEV/pkg/weblogo-3.4/corebio/seq_io/genbank_io.pyt   read   s    "c         c@  sÿ   t  | ƒ } g  } d „  } t t |  ƒ ƒ } xË t rú | j | ƒ } | j d ƒ sm t d | j ƒ  ƒ ‚ n  | j d „  ƒ } | j d ƒ rŸ t d | ƒ Vq0 xU | D]M } | j d ƒ rÜ t d j	 | ƒ | ƒ Vg  } Pn  | j
 | j ƒ  d ƒ q¦ Wq0 Wd S(	   s   Iterate over genbank records
    
    Args:
    fin -- A stream or file to read
    alphabet -- The expected alphabet of the data, if given    
    
    Yeilds: 
    Seq -- One alphabetic sequence at a time.
    
    Raises: 
    ValueError -- If the file is unparsable
    c         S@  s   t  |  ƒ S(   N(   t   isblank(   t   string(    (    sC   /home/psgendb/BIRCHDEV/pkg/weblogo-3.4/corebio/seq_io/genbank_io.pyt   notblank6   s    t   LOCUSs&   Cannot find start of record at line %dc         S@  s   |  j  d ƒ p |  j  d ƒ S(   Nt   ORIGINs   //(   t
   startswith(   R	   (    (    sC   /home/psgendb/BIRCHDEV/pkg/weblogo-3.4/corebio/seq_io/genbank_io.pyt   <lambda>B   s   s   //t    i   N(   t   Alphabett	   Reiteratet   itert   Truet   filterR   t
   ValueErrort   indext   Seqt   joint   extendt   split(   R   R   t   seqR   t   linest   line(    (    sC   /home/psgendb/BIRCHDEV/pkg/weblogo-3.4/corebio/seq_io/genbank_io.pyR   %   s$    		N(   R   (   R   R   s   gbk(
   t   __doc__t
   __future__R    t   utilsR   t   namest
   extensionst   NoneR   R   (    (    (    sC   /home/psgendb/BIRCHDEV/pkg/weblogo-3.4/corebio/seq_io/genbank_io.pyt   <module>   s   

