
    {Tiv
                         d Z ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ eeeedZ		 dd	lm
Z
 e
e	d
<   d Zd Zd ZddZy# e$ r Y w xY w)zI/O function wrappers for phylogenetic tree formats.

This API follows the same semantics as Biopython's ``SeqIO`` and
``AlignIO``.
    )File)BaseTree)NewickIO)NeXMLIO)NexusIO)
PhyloXMLIO)newicknexusphyloxmlnexml)CDAOIOcdaoc              +      K   t        j                  |       5 } t        t        |   d      |fi |E d{    ddd       y7 # 1 sw Y   yxY ww)al  Parse a file iteratively, and yield each of the trees it contains.

    If a file only contains one tree, this still returns an iterable object that
    contains one element.

    Examples
    --------
    >>> import Bio.Phylo
    >>> trees = Bio.Phylo.parse('PhyloXML/apaf.xml', 'phyloxml')
    >>> for tree in trees:
    ...     print(tree.rooted)
    True

    parseN)r   	as_handlegetattrsupported_formats)fileformatkwargsfps       @/home/agent/.local/lib/python3.12/site-packages/Bio/Phylo/_io.pyr   r   $   sZ      
	 M>7,V4g>rLVLLLM MLM Ms+   AAAA	AAAAc                     	 t        | |fi |}t        |      }	 t        |       t        d      # t        $ r t        d      dw xY w# t        $ r |cY S w xY w)zParse a file in the given format and return a single tree.

    Raises a ``ValueError`` if there are zero or multiple trees -- if this
    occurs, use ``parse`` instead to get the complete sequence of trees.
    z There are no trees in this file.Nz;There are multiple trees in this file; use parse() instead.)r   nextStopIteration
ValueError)r   r   r   tree_gentrees        r   readr   7   ss    Gv00H~XX VWW  G;<$FG  s   1 A
 A
AAc                     t        | t        j                  t        j                  f      r| g} t	        j
                  |d      5 } t        t        |   d      | |fi |}ddd       |S # 1 sw Y   S xY w)z6Write a sequence of trees to file in the given format.zw+writeN)
isinstancer   TreeClader   r   r   r   )treesr   r   r   r   ns         r   r!   r!   J   sm    %(--89	d	# Mr7G%f-w7rLVLMHMHs   A**A4Nc                 @    |i }t        | |fi |}t        |||fi |S )z&Convert between two tree file formats.)r   r!   )in_file	in_formatout_file
out_format
parse_argsr   r%   s          r   convertr-   T   s2    
'93
3E*777    )N)__doc__Bior   	Bio.Phylor   r   r   r   r   r   r   ImportErrorr   r   r!   r-    r.   r   <module>r4      sr           	 	  &f
M&X&8i  		s   A AA