ó
ZIc           @   s\   d  Z  d d l m Z m Z d d
 d „  ƒ  YZ d d d „  ƒ  YZ d e f d „  ƒ  YZ d	 S(   sÅ   
AlignIO support module (not for general use).

Unless you are writing a new parser or writer for Bio.AlignIO, you should not
use this module.  It provides base classes to try and simplify things.
iÿÿÿÿ(   t   single_letter_alphabett   Gappedt   AlignmentIteratorc           B   s/   e  Z d  Z d e d „ Z d „  Z d „  Z RS(   s²   Base class for building Alignment iterators.

    You should write a next() method to return Aligment
    objects.  You may wish to redefine the __init__
    method as well.
    c         C   s   | |  _  | |  _ | |  _ d S(   s  Create an AlignmentIterator object.

        handle   - input file
        count    - optional, expected number of records per alignment
                   Recommend for fasta file format.
        alphabet - optional, e.g. Bio.Alphabet.generic_protein

        Note when subclassing:
        - there should be a single non-optional argument, the handle,
          and optional count and alphabet IN THAT ORDER.
        - you do not have to require an alphabet (?).
        - you can add additional optional arguments.N(   t   handlet   records_per_alignmentt   alphabet(   t   selfR   t	   seq_countR   (    (    s‰   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/AlignIO/Interfaces.pyt   __init__   s    		c         C   s   t  d ƒ ‚ d S(   s‹   Return the next alignment in the file.
        
        This method should be replaced by any derived class to do something
        useful.s    This object should be subclassedN(   t   NotImplementedError(   R   (    (    s‰   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/AlignIO/Interfaces.pyt   next-   s    c         C   s   t  |  j d ƒ S(   s`  Iterate over the entries as Alignment objects.

        Example usage for (concatenated) PHYLIP files:

        myFile = open("many.phy","r")
        for alignment in PhylipIterator(myFile) :
            print "New alignment:"
            for record in alignment :
                print record.id
                print record.seq
        myFile.close()N(   t   iterR
   t   None(   R   (    (    s‰   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/AlignIO/Interfaces.pyt   __iter__9   s    N(   t   __name__t
   __module__t   __doc__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/AlignIO/Interfaces.pyR      s
   	t   AlignmentWriterc           B   s)   e  Z d  Z d „  Z d „  Z d „  Z RS(   s™   Base class for building Alignment writers.
    
    You should write a write_alignment() method.
    You may wish to redefine the __init__ method as wellc         C   s   | |  _  d  S(   N(   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/AlignIO/Interfaces.pyR   M   s    c         C   s   t  d ƒ ‚ d S(   sY  Use this to write an entire file containing the given alignments.

        alignments - A list or iterator returning Alignment objects

        In general, this method can only be called once per file.
        
        This method should be replaced by any derived class to do something
        useful.  It should return the number of alignmentss    This object should be subclassedN(   R	   (   R   t
   alignments(    (    s‰   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/AlignIO/Interfaces.pyt
   write_fileP   s    	c         C   s?   | } x& d d g D] } | j  | d ƒ } q W| j  d d ƒ S(   s1   Use this to avoid getting newlines in the output.s   
s   t    s     (   t   replace(   R   t   textt   answert   x(    (    s‰   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/AlignIO/Interfaces.pyt   clean_   s    (   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/AlignIO/Interfaces.pyR   G   s   		t   SequentialAlignmentWriterc           B   s;   e  Z d  Z d „  Z d „  Z d „  Z d „  Z d „  Z RS(   sÝ   Base class for building Alignment writers.
    
    This assumes each alignment can be simply appended to the file.
    You should write a write_alignment() method.
    You may wish to redefine the __init__ method as wellc         C   s   | |  _  d  S(   N(   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/AlignIO/Interfaces.pyR   m   s    c         C   sF   |  j  ƒ  d } x% | D] } |  j | ƒ | d 7} q W|  j ƒ  | S(   sÉ   Use this to write an entire file containing the given alignments.

        alignments - A list or iterator returning Alignment objects

        In general, this method can only be called once per file.i    i   (   t   write_headert   write_alignmentt   write_footer(   R   R   t   countt	   alignment(    (    s‰   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/AlignIO/Interfaces.pyR   p   s    

c         C   s   d S(   s‚   Use this to write any header.
        
        This method should be replaced by any derived class to do something
        useful.N(    (   R   (    (    s‰   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/AlignIO/Interfaces.pyR   ~   s    c         C   s   d S(   s‚   Use this to write any footer.
        
        This method should be replaced by any derived class to do something
        useful.N(    (   R   (    (    s‰   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/AlignIO/Interfaces.pyR   …   s    c         C   s   t  d ƒ ‚ d S(   sŠ   Use this to write a single alignment.
        
        This method should be replaced by any derived class to do something
        useful.s    This object should be subclassedN(   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/AlignIO/Interfaces.pyR   Œ   s    (   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/AlignIO/Interfaces.pyR   f   s   				N(    (    (   R   t   Bio.AlphabetR    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/AlignIO/Interfaces.pyt   <module>
   s   9