3
:>"^4                 @   s\  d Z ddlmZ ddlZddlZddlZddlZddlZddlZddl	m
Z
 yddlmZ W n  ek
r|   ddlmZ Y nX ejdksej d	ksejdkrej dkreZnddlmZ y(ddlmZ ddlmZ ddlmZ W n ek
 r   dZY nX ejdddZdd ZG dd deZ G dd deZ!G dd deZ"G dd de"Z#dS ) a  Code for more fancy file handles.

Classes:
 - UndoHandle     File object decorator with support for undo-like operations.

Additional private classes used in Bio.SeqIO and Bio.SearchIO for indexing
files are also defined under Bio.File but these are not intended for direct
use.
    )print_functionN)
basestring)UserDict)	DictMixin      ZPyPy   ZCPython)OrderedDict)dbapi2)IntegrityError)OperationalErrorrc             k   s   t tdr.ytj| } W n tk
r,   Y nX t| trtjd dkrZd|krZ|jdd}d|krt	j
| |f|}|V  W dQ R X qt
| |f|}|V  W dQ R X n| V  dS )a  Context manager to ensure we are using a handle.

    Context manager for arguments that can be passed to SeqIO and AlignIO read, write,
    and parse methods: either file objects or path-like objects (strings, pathlib.Path
    instances, or more generally, anything that can be handled by the builtin 'open'
    function).

    When given a path-like object, returns an open file handle to that path, with provided
    mode, which will be closed when the manager exits.

    All other inputs are returned, and are *not* closed.

    Arguments:
     - handleish  - Either a file handle or path-like object (anything which can be
                    passed to the builtin 'open' function: str, bytes, and under
                    Python >= 3.6, pathlib.Path, os.DirEntry)
     - mode       - Mode to open handleish (used only if handleish is a string)
     - kwargs     - Further arguments to pass to open(...)

    Examples
    --------
    >>> from Bio import File
    >>> import os
    >>> with File.as_handle('seqs.fasta', 'w') as fp:
    ...     # Python2/3 docstring workaround, revise for 'Python 3 only'.
    ...     _ = fp.write('>test\nACGT')
    ...
    >>> fp.closed
    True

    >>> handle = open('seqs.fasta', 'w')
    >>> with File.as_handle(handle) as fp:
    ...     # Python 2/3 docstring workaround, revise for 'Python 3 only'.
    ...     _ = fp.write('>test\nACGT')
    ...
    >>> fp.closed
    False
    >>> fp.close()
    >>> os.remove("seqs.fasta")  # tidy up

    Note that if the mode argument includes U (for universal new lines)
    this will be removed under Python 3 where is is redundant and has
    been deprecated (this happens automatically in text mode).

    fspathr   r   U encodingN)hasattrosr   	TypeError
isinstancer   sysversion_inforeplacecodecsopen)Z	handleishmodekwargsfp r   X/home/psgendb/BIRCHDEV/lib-linux-x86_64/python/lib64/python3.5/site-packages/Bio/File.py	as_handle9   s    1

r    c             C   s   t | d}|jd}|jd |dkrddlm} y|jd|dS  tk
r } z&dt|ksbt|j	  td	W Y d
d
}~X nX |S )zOpen a file in binary mode, spot if it is BGZF format etc (PRIVATE).

    This functionality is used by the Bio.SeqIO and Bio.SearchIO index
    and index_db functions.

    If the file is gzipped but not BGZF, a specific ValueError is raised.
    Zrb   r   s      )bgzf)r   ZfileobjZBGZFz[Gzipped files are not suitable for indexing, please use BGZF (blocked gzip format) instead.N)
r   readseekr   r#   Z
BgzfReader
ValueErrorstrAssertionErrorclose)filenamehandlemagicr#   er   r   r   _open_for_random_access~   s    


r.   c               @   s   e Zd ZdZdd Zdd Zdd Zejd d	k r:d
d Z	dd Z
dd Zd#ddZdd Zdd Zdd Zdd Zdd Zdd Zdd  Zd!S )$
UndoHandlezA Python handle that adds functionality for saving lines.

    Saves lines in a LIFO fashion.

    Added methods:
     - saveline    Save a line to be returned next time.
     - peekline    Peek at the next line without consuming it.

    c             C   s2   || _ g | _y|j| _W n tk
r,   Y nX dS )zInitialize the class.N)_handle_savedZurlAttributeError)selfr+   r   r   r   __init__   s    zUndoHandle.__init__c             C   s   | S )z#Iterate over the lines in the File.r   )r3   r   r   r   __iter__   s    zUndoHandle.__iter__c             C   s   | j  }|st|S )zReturn the next line.)readlineStopIteration)r3   nextr   r   r   __next__   s    zUndoHandle.__next__r   r   c             C   s   | j  S )z8Python 2 style alias for Python 3 style __next__ method.)r9   )r3   r   r   r   r8      s    zUndoHandle.nextc             O   s   | j | jj|| }g | _ |S )z6Read all the lines from the file as a list of strings.)r1   r0   	readlines)r3   argskeywdslinesr   r   r   r:      s    zUndoHandle.readlinesc             O   s&   | j r| j jd}n| jj||}|S )z+Read the next line from the file as string.r   )r1   popr0   r6   )r3   r;   r<   liner   r   r   r6      s    zUndoHandle.readliner"   c             C   s   |dkr$dj | j}g | jdd< nd}xz|dkr| jrt| jd |krn|t| jd  }|| jjd }q*|| jd d|  }| jd |d | jd< d}q*W || jj| S )zRead the File.r"   r   Nr   )joinr1   lenr>   r0   r$   )r3   sizeZsavedr   r   r   r$      s    zUndoHandle.readc             C   s   |r|g| j  | _ dS )zStore a line in the cache memory for later use.

        This acts to undo a readline, reflecting the name of the class: UndoHandle.
        N)r1   )r3   r?   r   r   r   saveline   s    zUndoHandle.savelinec             C   s*   | j r| j d }n| jj }| j| |S )zJReturn the next line in the file, but do not move forward though the file.r   )r1   r0   r6   rD   )r3   r?   r   r   r   peekline   s
    

zUndoHandle.peeklinec             C   s   | j j tdd | jD  S )zKReturn the current position of the file read/write pointer within the File.c             s   s   | ]}t |V  qd S )N)rB   ).0r?   r   r   r   	<genexpr>   s    z"UndoHandle.tell.<locals>.<genexpr>)r0   tellsumr1   )r3   r   r   r   rH      s    zUndoHandle.tellc             G   s   g | _ | jj|  dS )z1Set the current position at the offset specified.N)r1   r0   r%   )r3   r;   r   r   r   r%      s    zUndoHandle.seekc             C   s   t | j|S )zReturn File attribute.)getattrr0   )r3   attrr   r   r   __getattr__   s    zUndoHandle.__getattr__c             C   s   | S )zACall special method when opening the file using a with-statement.r   )r3   r   r   r   	__enter__   s    zUndoHandle.__enter__c             C   s   | j j  dS )zACall special method when closing the file using a with-statement.N)r0   r)   )r3   typevalue	tracebackr   r   r   __exit__   s    zUndoHandle.__exit__Nr@   )r@   )__name__
__module____qualname____doc__r4   r5   r9   r   r   r8   r:   r6   r$   rD   rE   rH   r%   rL   rM   rQ   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 )	_IndexedSeqFileProxya3  Base class for file format specific random access (PRIVATE).

    This is subclasses in both Bio.SeqIO for indexing as SeqRecord
    objects, and in Bio.SearchIO for indexing QueryResult objects.

    Subclasses for each file format should define '__iter__', 'get'
    and optionally 'get_raw' methods.
    c             C   s   t ddS )zReturn (identifier, offset, length in bytes) tuples.

        The length can be zero where it is not implemented or not
        possible for a particular file format.
        zSubclass should implement thisN)NotImplementedError)r3   r   r   r   r5     s    z_IndexedSeqFileProxy.__iter__c             C   s   t ddS )z$Return parsed object for this entry.zSubclass should implement thisN)rW   )r3   offsetr   r   r   get  s    z_IndexedSeqFileProxy.getc             C   s   t ddS )zReturn the raw record from the file as a bytes string (if implemented).

        If the key is not found, a KeyError exception is raised.

        This may not have been implemented for all file formats.
        z#Not available for this file format.N)rW   )r3   rX   r   r   r   get_raw   s    z_IndexedSeqFileProxy.get_rawN)rR   rS   rT   rU   r5   rY   rZ   r   r   r   r   rV     s   rV   c               @   s   e Zd ZdZdd Zdd Zdd Zdd	 Zd
d Zdd Z	dd Z
dd Zeedrndd Zdd Zdd Zdd Zdd Zd2ddZd d! Zd"d# Zd$d% Zd3d&d'Zd(d) Zd*d+ Zd4d,d-Zd.d/ Zd0d1 ZdS )5_IndexedSeqFileDicta5  Read only dictionary interface to a sequential record file.

    This code is used in both Bio.SeqIO for indexing as SeqRecord
    objects, and in Bio.SearchIO for indexing QueryResult objects.

    Keeps the keys and associated file offsets in memory, reads the file
    to access entries as objects parsing them on demand. This approach
    is memory limited, but will work even with millions of records.

    Note duplicate keys are not allowed. If this happens, a ValueError
    exception is raised.

    As used in Bio.SeqIO, by default the SeqRecord's id string is used
    as the dictionary key. In Bio.SearchIO, the query's id string is
    used. This can be changed by supplying an optional key_function,
    a callback function which will be given the record id and must
    return the desired key. For example, this allows you to parse
    NCBI style FASTA identifiers, and extract the GI number to use
    as the dictionary key.

    Note that this dictionary is essentially read only. You cannot
    add or change values, pop values, nor clear the dictionary.
    c       
         s   || _  | _|| _|| _ r0 fdd|D }n|}t }x<|D ]4\}}}	||krl| j jj  td| q@|||< q@W || _dS )zInitialize the class.c             3   s"   | ]\}}} |||fV  qd S )Nr   )rF   kol)key_functionr   r   rG   N  s    z/_IndexedSeqFileDict.__init__.<locals>.<genexpr>zDuplicate key '%s'N)	_proxy_key_function_repr	_obj_repr_dictr0   r)   r&   _offsets)
r3   random_access_proxyr_   reprZobj_reproffset_iterZoffsetskeyrX   lengthr   )r_   r   r4   D  s    
z_IndexedSeqFileDict.__init__c             C   s   | j S )z2Return a string representation of the File object.)rb   )r3   r   r   r   __repr__c  s    z_IndexedSeqFileDict.__repr__c             C   s&   | rdt | j d | jf S dS dS )z2Create a string representation of the File object.z{%r : %s(...), ...}r   z{}N)listkeysrc   )r3   r   r   r   __str__g  s    z_IndexedSeqFileDict.__str__c             C   s
   || j kS )z2Return key if contained in the offsets dictionary.)re   )r3   ri   r   r   r   __contains__o  s    z _IndexedSeqFileDict.__contains__c             C   s
   t | jS )zReturn the number of records.)rB   re   )r3   r   r   r   __len__s  s    z_IndexedSeqFileDict.__len__c             c   s&   x | j  D ]}|| j|fV  q
W dS )zIterate over the (key, SeqRecord) items.

        This tries to act like a Python 3 dictionary, and does not return
        a list of (key, value) pairs due to memory concerns.
        N)r5   __getitem__)r3   ri   r   r   r   itemsw  s    z_IndexedSeqFileDict.itemsc             c   s"   x| j  D ]}| j|V  q
W dS )zIterate over the SeqRecord items.

        This tries to act like a Python 3 dictionary, and does not return
        a list of value due to memory concerns.
        N)r5   rq   )r3   ri   r   r   r   values  s    z_IndexedSeqFileDict.valuesc             C   s   | j  S )zIterate over the keys.

        This tries to act like a Python 3 dictionary, and does not return
        a list of keys due to memory concerns.
        )r5   )r3   r   r   r   rm     s    z_IndexedSeqFileDict.keys	iteritemsc             c   s"   x| j  D ]}| j|V  q
W dS )z"Iterate over the SeqRecord) items.N)r5   rq   )r3   ri   r   r   r   
itervalues  s    z_IndexedSeqFileDict.itervaluesc             c   s&   x | j  D ]}|| j|fV  q
W dS )z(Iterate over the (key, SeqRecord) items.N)r5   rq   )r3   ri   r   r   r   rt     s    z_IndexedSeqFileDict.iteritemsc             C   s   | j  S )zIterate over the keys.)r5   )r3   r   r   r   iterkeys  s    z_IndexedSeqFileDict.iterkeysc             C   s
   t | jS )zIterate over the keys.)iterre   )r3   r   r   r   r5     s    z_IndexedSeqFileDict.__iter__c             C   sH   | j j| j| }| jr&| j|j}n|j}||krDtd||f |S )z$Return record for the specified key.zKey did not match (%s vs %s))r`   rY   re   ra   idr&   )r3   ri   recordkey2r   r   r   rq     s    z_IndexedSeqFileDict.__getitem__Nc             C   s$   y
| j |S  tk
r   |S X dS )zReturn the value in the dictionary.

        If the key (k) is not found, this returns None unless a
        default (d) is specified.
        N)rq   KeyError)r3   r\   dr   r   r   rY     s    
z_IndexedSeqFileDict.getc             C   s   | j j| j| S )zReturn the raw record from the file as a bytes string.

        If the key is not found, a KeyError exception is raised.
        )r`   rZ   re   )r3   ri   r   r   r   rZ     s    z_IndexedSeqFileDict.get_rawc             C   s   t ddS )zWould allow setting or replacing records, but not implemented.

        Python dictionaries provide this method for modifying data in the
        dictionary. This class mimics the dictionary interface but is read only.
        z(An indexed a sequence file is read only.N)rW   )r3   ri   rO   r   r   r   __setitem__  s    z_IndexedSeqFileDict.__setitem__c             O   s   t ddS )zWould allow adding more values, but not implemented.

        Python dictionaries provide this method for modifying data in the
        dictionary. This class mimics the dictionary interface but is read only.
        z(An indexed a sequence file is read only.N)rW   )r3   r;   r   r   r   r   update  s    z_IndexedSeqFileDict.updatec             C   s   t ddS )zWould remove specified record, but not implemented.

        Python dictionaries provide this method for modifying data in the
        dictionary. This class mimics the dictionary interface but is read only.
        z(An indexed a sequence file is read only.N)rW   )r3   ri   defaultr   r   r   r>     s    z_IndexedSeqFileDict.popc             C   s   t ddS )zWould remove and return a SeqRecord, but not implemented.

        Python dictionaries provide this method for modifying data in the
        dictionary. This class mimics the dictionary interface but is read only.
        z(An indexed a sequence file is read only.N)rW   )r3   r   r   r   popitem  s    z_IndexedSeqFileDict.popitemc             C   s   t ddS )zWould clear dictionary, but not implemented.

        Python dictionaries provide this method for modifying data in the
        dictionary. This class mimics the dictionary interface but is read only.
        z(An indexed a sequence file is read only.N)rW   )r3   r   r   r   clear  s    z_IndexedSeqFileDict.clearc             C   s   t ddS )zWould return a new dictionary with keys and values, but not implemented.

        Python dictionaries provide this method for modifying data in the
        dictionary. This class mimics the dictionary interface but is read only.
        z0An indexed a sequence file doesn't support this.N)rW   )r3   rm   rO   r   r   r   fromkeys  s    z_IndexedSeqFileDict.fromkeysc             C   s   t ddS )zWould copy a dictionary, but not implemented.

        Python dictionaries provide this method for modifying data in the
        dictionary. This class mimics the dictionary interface but is read only.
        z0An indexed a sequence file doesn't support this.N)rW   )r3   r   r   r   copy  s    z_IndexedSeqFileDict.copyc             C   s   | j jj  dS )a?  Close the file handle being used to read the data.

        Once called, further use of the index won't work. The sole purpose
        of this method is to allow explicit handle closure - for example
        if you wish to delete the file, on Windows you must first close
        all open handles to that file.
        N)r`   r0   r)   )r3   r   r   r   r)     s    z_IndexedSeqFileDict.close)N)N)N)rR   rS   rT   rU   r4   rk   rn   ro   rp   rr   rs   rm   r   dictru   rt   rv   r5   rq   rY   rZ   r}   r~   r>   r   r   r   r   r)   r   r   r   r   r[   +  s2   		



		r[   c               @   s~   e Zd ZdZdddZdd Zdd Zd	d
 Zdd Zdd Z	dd Z
eedrXdd Zdd ZdddZdd Zdd ZdS )_SQLiteManySeqFilesDictaK  Read only dictionary interface to many sequential record files.

    This code is used in both Bio.SeqIO for indexing as SeqRecord
    objects, and in Bio.SearchIO for indexing QueryResult objects.

    Keeps the keys, file-numbers and offsets in an SQLite database. To access
    a record by key, reads from the offset in the appropriate file and then
    parses the record into an object.

    There are OS limits on the number of files that can be open at once,
    so a pool are kept. If a record is required from a closed file, then
    one of the open handles is closed first.
    
   c       	      C   s   t sddlm} |d|dk	r(t|}|| _|| _|| _|| _|| _|| _	|| _
i | _tjjtjj|| _tjj|r| j  n| j  dS )zInitialize the class.r   )MissingPythonDependencyErrorz/Requires sqlite3, which is included Python 2.5+N)_sqliteBior   rl   _index_filename
_filenames_formatra   _proxy_factoryrb   	_max_open_proxiesr   pathabspathdirname_relative_pathisfile_load_index_build_index)	r3   index_filename	filenamesproxy_factoryformatr_   rg   max_openr   r   r   r   r4     s"    	
z _SQLiteManySeqFilesDict.__init__c             C   s  | j }| j}| j}| j}| j}tj|dd}|| _yP|jddj	 \}t
|| _| jdkrl|j  td|jdj	 \}| jt
|kr|j  tdt
|| jf |jddj	 \| _|r|| jkr|j  td
| j|f y"|jddj	 \}|j dk}W n tk
r    d}Y nX dd |jdj D | _|rtjjtjj|}g }	xJ| jD ]@}
tjj|
r|	j|
 n |	jtjj||
jdtjj qbW |	| _~	|rt|t| jkr|j  tdt| jt|f |r|| jkrxt| j|D ]t\}}tjj|tjj|kr
|j  |r\tdtjj|tjj|f n tdtjj|tjj|f q
W W n8 tk
r } z|j  td| W Y dd}~X nX || js|j  td| j dS )z9Call from __init__ to re-use an existing index (PRIVATE).F)Zcheck_same_threadz(SELECT value FROM meta_data WHERE key=?;countr"   zUnfinished/partial databasez%SELECT MAX(_ROWID_) FROM offset_data;z#Corrupt database? %i entries not %ir   z!Index file says format %s, not %sfilenames_relative_to_indexZTRUEc             S   s   g | ]}|d  qS )r   r   )rF   rowr   r   r   
<listcomp>i  s    z7_SQLiteManySeqFilesDict._load_index.<locals>.<listcomp>z0SELECT name FROM file_data ORDER BY file_number;/z Index file says %i files, not %iz1Index file has different filenames, e.g. %r != %rzIndex file has different filenames [This is an old index where any relative paths were relative to the original working directory]. e.g. %r != %rz"Not a Biopython index database? %sNzUnsupported format '%s')r   r@   )r   )r   )r   r   r   r   r   r   connect_conexecutefetchoneint_lengthr)   r&   upperr   fetchallr   r   r   r   isabsappendrA   r   seprB   zip_OperationalError)r3   r   relative_pathr   r   r   conr   r   Ztmpfoldnewerrr   r   r   r   <  s    


&&z#_SQLiteManySeqFilesDict._load_indexc                s  | j }| j}| j}| j}| j| j}| j}| j}| s<| rHtd| ||s\td| t	j
|}|| _|jd |jd |jd |jdd |jdd	|f |jdd |jd |jd d}	xdt|D ]V\ }
tjj|
}tjj|
 r(tjj| r(tjj|
|jtjjd}n\tjjtjj|
tjj j|tjj rtjj|
|jtjjd}|jd st||jd |f |||
}r fdd|D }n fdd|D }x>ttj|d}|sP |jd| |j  |	t|7 }	qW t||k r$|| < q|jj  qW |	| _ y|jd W nF t!k
r } z(|| _| j  |j  td| W Y dd}~X nX |jd |jd|	df |j  dS )z3Call from __init__ to create a new index (PRIVATE).z2Filenames to index and format required to build %rzUnsupported format '%s'zPRAGMA synchronous=OFFzPRAGMA locking_mode=EXCLUSIVEz.CREATE TABLE meta_data (key TEXT, value TEXT);z0INSERT INTO meta_data (key, value) VALUES (?,?);r   r"   r   r   Truez8CREATE TABLE file_data (file_number INTEGER, name TEXT);zYCREATE TABLE offset_data (key TEXT, file_number INTEGER, offset INTEGER, length INTEGER);r   r   z../z7INSERT INTO file_data (file_number, name) VALUES (?,?);c             3   s$   | ]\}}}| ||fV  qd S )Nr   )rF   r\   r]   r^   )ir_   r   r   rG     s   z7_SQLiteManySeqFilesDict._build_index.<locals>.<genexpr>c             3   s    | ]\}}}| ||fV  qd S )Nr   )rF   r\   r]   r^   )r   r   r   rG     s   d   zIINSERT INTO offset_data (key,file_number,offset,length) VALUES (?,?,?,?);z@CREATE UNIQUE INDEX IF NOT EXISTS key_index ON offset_data(key);zDuplicate key? %sNzPRAGMA locking_mode=NORMALz-UPDATE meta_data SET value = ? WHERE key = ?;r@   )r   r@   )r   r   )"r   r   r   r   ra   r   r   r   r&   r   r   r   r   	enumerater   r   r   r   relpathr   r   r   
startswithr(   rl   	itertoolsZisliceZexecutemanyZcommitrB   r0   r)   r   _IntegrityError)r3   r   r   r   r   r   r   Zrandom_access_proxiesr   r   r*   r   rf   rh   Zbatchr   r   )r   r_   r   r     s    





 






z$_SQLiteManySeqFilesDict._build_indexc             C   s   | j S )N)rb   )r3   r   r   r   rk     s    z _SQLiteManySeqFilesDict.__repr__c             C   s   t | jjd|fj S )Nz(SELECT key FROM offset_data WHERE key=?;)boolr   r   r   )r3   ri   r   r   r   ro     s    z$_SQLiteManySeqFilesDict.__contains__c             C   s   | j S )z%Return the number of records indexed.)r   )r3   r   r   r   rp     s    z_SQLiteManySeqFilesDict.__len__c             c   s(   x"| j jdD ]}t|d V  qW dS )zIterate over the keys.z9SELECT key FROM offset_data ORDER BY file_number, offset;r   N)r   r   r'   )r3   r   r   r   r   r5     s    z _SQLiteManySeqFilesDict.__iter__rt   c             C   s   dd | j jdj D S )zIterate over the keys.

            This tries to act like a Python 3 dictionary, and does not return
            a list of keys due to memory concerns.
            c             S   s   g | ]}t |d  qS )r   )r'   )rF   r   r   r   r   r     s    z0_SQLiteManySeqFilesDict.keys.<locals>.<listcomp>zSELECT key FROM offset_data;)r   r   r   )r3   r   r   r   rm   
  s    z_SQLiteManySeqFilesDict.keysc       	      C   s   | j jd|fj }|st|\}}| j}||krB|| j|}nFt|| jkrb|j d j	j
  | j| j| j| }|j|}|||< | jr| j|j}n|j}||krtd||f |S )z$Return record for the specified key.z8SELECT file_number, offset FROM offset_data WHERE key=?;r"   zKey did not match (%s vs %s))r   r   r   r{   r   rY   rB   r   r   r0   r)   r   r   r   ra   rx   r&   )	r3   ri   r   file_numberrX   proxiesry   proxyrz   r   r   r   rq     s(    
z#_SQLiteManySeqFilesDict.__getitem__Nc             C   s$   y
| j |S  tk
r   |S X dS )zReturn the value in the dictionary.

        If the key (k) is not found, this returns None unless a
        default (d) is specified.
        N)rq   r{   )r3   r\   r|   r   r   r   rY   /  s    
z_SQLiteManySeqFilesDict.getc       	      C   s   | j jd|fj }|st|\}}}| j}||krf|rV|| j}|j| |j|S || j|S ndt	|| j
kr|j d jj  | j| j| j| }|||< |r|j}|j| |j|S |j|S dS )zReturn the raw record from the file as a bytes string.

        If the key is not found, a KeyError exception is raised.
        z@SELECT file_number, offset, length FROM offset_data WHERE key=?;r"   N)r   r   r   r{   r   r0   r%   r$   rZ   rB   r   r   r)   r   r   r   )	r3   ri   r   r   rX   rj   r   hr   r   r   r   rZ   :  s,    





z_SQLiteManySeqFilesDict.get_rawc             C   s&   | j }x|r |j d jj  qW dS )zClose any open file handles.r"   N)r   r   r0   r)   )r3   r   r   r   r   r)   _  s    z_SQLiteManySeqFilesDict.close)r   )N)rR   rS   rT   rU   r4   r   r   rk   ro   rp   r5   r   r   rm   rq   rY   rZ   r)   r   r   r   r   r   	  s   
"Xa
	
%r   )r   r   )r   r   )r   )$rU   
__future__r   r   r   r   Z
contextlibr   platformZ	Bio._py3kr   Zcollectionsr   Z
_dict_baseImportErrorr   r   Zpython_implementationr   rd   r	   Zsqlite3r
   r   r   r   r   r   Zcontextmanagerr    r.   objectr/   rV   r[   r   r   r   r   r   <module>   sB   

Dn# _