ó
²“Ic           @   s  d  Z  d d l m Z d d l m Z d d l m Z d d l m Z e d „ Z	 d e f d „  ƒ  YZ
 e d	 k rd
 GHd d l m Z e d ƒ Z e e	 e ƒ ƒ Z e e ƒ d k s¿ t ‚ e d ƒ Z y( e e	 e ƒ ƒ Z e sò t d ƒ ‚ Wn e k
 rn Xd GHn  d S(   s  Bio.SeqIO support for the "tab" (simple tab separated) file format.

You are expected to use this module via the Bio.SeqIO functions.

The "tab" format is an ad-hoc plain text file format where each sequence is
on one (long) line.  Each line contains the identifier/description, followed
by a tab, followed by the sequence.  For example, consider the following
short FASTA format file:

>ID123456 possible binding site?
CATCNAGATGACACTACGACTACGACTCAGACTAC
>ID123457 random sequence
ACACTACGACTACGACTCAGACTACAAN

Apart from the descriptions, this can be represented in the simple two column
tab separated format as follows:

ID123456(tab)CATCNAGATGACACTACGACTACGACTCAGACTAC
ID123457(tab)ACACTACGACTACGACTCAGACTACAAN

When reading this file, "ID123456" or "ID123457" will be taken as the record's
.id and .name property.  There is no other information to record.

Similarly, when writing to this format, Biopython will ONLY record the record's
.id and .seq (and not the description or any other information) as in the example
above.
iÿÿÿÿ(   t   single_letter_alphabet(   t   Seq(   t	   SeqRecord(   t   SequentialSequenceWriterc         c   s±   xª |  D]¢ } y | j  d ƒ \ } } WnH | j ƒ  d k rD q n  t d d | j d ƒ t | ƒ f ƒ ‚ n X| j ƒ  } | j ƒ  } t t | | ƒ d | d | ƒVq Wd S(   s£  Iterates over tab separated lines (as SeqRecord objects).

    Each line of the file should contain one tab only, dividing the line
    into an identifier and the full sequence.

    handle - input file
    alphabet - optional alphabet

    The first field is taken as the record's .id and .name (regardless of
    any spaces within the text) and the second field is the sequence.

    Any blank lines are ignored.
    s   	t    s,   Each line should have one tab separating thes.    title and sequence, this line has %i tabs: %st   idt   nameN(   t   splitt   stript
   ValueErrort   countt   reprR   R   (   t   handlet   alphabett   linet   titlet   seq(    (    s‚   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/SeqIO/TabIO.pyt   TabIterator(   s    $t	   TabWriterc           B   s   e  Z d  Z d „  Z RS(   s©   Class to write simple tab separated format files.

    Each line consists of "id(tab)sequence" only.

    Any description, name or other annotation is not recorded.
    c         C   sÓ   |  j  s t ‚ |  j s t ‚ t |  _ |  j | j ƒ } |  j | ƒ } d | k s[ t ‚ d | k sm t ‚ d | k s t ‚ d | k s‘ t ‚ d | k s£ t ‚ d | k sµ t ‚ |  j j	 d | | f ƒ d S(   s$   Write a single tab line to the file.s   	s   
s   s   %s	%s
N(
   t   _header_writtent   AssertionErrort   _footer_writtent   Truet   _record_writtent   cleanR   t   _get_seq_stringR   t   write(   t   selft   recordR   R   (    (    s‚   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/SeqIO/TabIO.pyt   write_recordK   s    	(   t   __name__t
   __module__t   __doc__R   (    (    (    s‚   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/SeqIO/TabIO.pyR   D   s   t   __main__s   Running quick self test(   t   StringIOs   Alpha	AAAAAAA
Beta	CCCCCCC

i   s!   Alpha	AAAAAAA	Extra
Beta	CCCCCCC
s(   Should have reject this invalid example!t   DoneN(   R    t   Bio.AlphabetR    t   Bio.SeqR   t   Bio.SeqRecordR   t
   InterfacesR   R   R   R   R"   R   t   listt   recordst   lenR   t   FalseR	   (    (    (    s‚   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/SeqIO/TabIO.pyt   <module>    s&   