o
    Rŀg                     @   s4   d Z G dd dZG dd dZG dd deZdS )zAlignIO 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.
c                   @   s*   e Zd ZdZd	ddZdd Zdd ZdS )
AlignmentIteratorzBase class for building MultipleSeqAlignment iterators.

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

        Arguments:
         - handle   - input file
         - count    - optional, expected number of records per alignment
           Recommend for fasta file format.

        Note when subclassing:
         - there should be a single non-optional argument, the handle,
           and optional count IN THAT ORDER.
         - you can add additional optional arguments.

        N)handlerecords_per_alignment)selfr   	seq_count r   J/var/www/html/myenv/lib/python3.10/site-packages/Bio/AlignIO/Interfaces.py__init__   s   
zAlignmentIterator.__init__c                 C      t d)zReturn the next alignment in the file.

        This method should be replaced by any derived class to do something
        useful.
         This object should be subclassedNotImplementedErrorr   r   r   r   __next__,      zAlignmentIterator.__next__c                 C   s   t | jdS )a  Iterate over the entries as MultipleSeqAlignment objects.

        Example usage for (concatenated) PHYLIP files::

            with open("many.phy","r") as myFile:
                for alignment in PhylipIterator(myFile):
                    print("New alignment:")
                    for record in alignment:
                        print(record.id)
                        print(record.seq)

        N)iterr   r   r   r   r   __iter__9   s   zAlignmentIterator.__iter__)N)__name__
__module____qualname____doc__r   r   r   r   r   r   r   r      s
    
r   c                   @   s(   e Zd ZdZdd Zdd Zdd ZdS )	AlignmentWriterzBase class for building MultipleSeqAlignment writers.

    You should write a write_alignment() method.
    You may wish to redefine the __init__ method as well.
    c                 C   
   || _ dS zInitialize the class.Nr   r   r   r   r   r   r   P      
zAlignmentWriter.__init__c                 C   r	   )a}  Use this to write an entire file containing the given alignments.

        Arguments:
         - alignments - A list or iterator returning MultipleSeqAlignment 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 alignments..
        r
   r   )r   
alignmentsr   r   r   
write_fileT   s   zAlignmentWriter.write_filec                 C   s   | dd ddS )z1Use this to avoid getting newlines in the output.
 )replace)r   textr   r   r   cleane   s   zAlignmentWriter.cleanN)r   r   r   r   r   r   r#   r   r   r   r   r   I   s
    r   c                   @   s8   e Zd ZdZdd Zdd Zdd Zdd	 Zd
d ZdS )SequentialAlignmentWriterzBase class for building MultipleSeqAlignment 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 well.
    c                 C   r   r   r   r   r   r   r   r   r   r   z"SequentialAlignmentWriter.__init__c                 C   s4   |    d}|D ]}| | |d7 }q|   |S )zUse this to write an entire file containing the given alignments.

        Arguments:
         - alignments - A list or iterator returning MultipleSeqAlignment objects

        In general, this method can only be called once per file.
               )write_headerwrite_alignmentwrite_footer)r   r   count	alignmentr   r   r   r   v   s   

z$SequentialAlignmentWriter.write_filec                 C      dS )zUse this to write any header.

        This method should be replaced by any derived class to do something
        useful.
        Nr   r   r   r   r   r'          z&SequentialAlignmentWriter.write_headerc                 C   r,   )zUse this to write any footer.

        This method should be replaced by any derived class to do something
        useful.
        Nr   r   r   r   r   r)      r-   z&SequentialAlignmentWriter.write_footerc                 C   r	   )zUse this to write a single alignment.

        This method should be replaced by any derived class to do something
        useful.
        r
   r   )r   r+   r   r   r   r(      r   z)SequentialAlignmentWriter.write_alignmentN)	r   r   r   r   r   r   r'   r)   r(   r   r   r   r   r$   j   s    r$   N)r   r   r   r$   r   r   r   r   <module>   s   ;!