ó
Y_Sc           @@  sp   d  Z  d d l m Z d d l m Z m Z m Z d d l m Z m	 Z	 d Z
 d Z d d „ Z d d „ Z d S(   sí   Read the sequence data from a nexus file.

This IO code only gives read access to the sequence data.

Reference:
'NEXUS: An extensible file format for systematic information'
Maddison, Swofford, Maddison. 1997. Syst. Biol. 46(4):590-621
i    (   t   absolute_importi   (   t   Seqt   SeqListt   Alphabeti   (   t   Nexust   safenamet   nexust   paupt   next   nxsc         C@  s   t  t |  | ƒ ƒ S(   s'   Iterate over the sequences in the file.(   t   itert   read(   t   fint   alphabet(    (    sA   /home/psgendb/BIRCHDEV/pkg/weblogo-3.4/corebio/seq_io/nexus_io.pyt   iterseq-   s    c         C@  s¹   t  |  ƒ } g  } xy | j D]n } t | ƒ } | j | } | d k re t | d | d | j ƒ} n t | d | d | ƒ} | j | ƒ q Wt | ƒ d k r¯ t	 d ƒ ‚ n  t
 | ƒ S(   s)    Extract sequence data from a nexus file.t   nameR   i    s   Cannot parse fileN(   R   t	   taxlabelsR   t   matrixt   NoneR   R   t   appendt   lent
   ValueErrorR   (   R   R   t   nt   seqst   taxonR   t   rt   s(    (    sA   /home/psgendb/BIRCHDEV/pkg/weblogo-3.4/corebio/seq_io/nexus_io.pyR   3   s    N(   R   R   (   R   R   R   R	   (   t   __doc__t
   __future__R    t   seqR   R   R   t   _nexusR   R   t   namest
   extensionsR   R   R   (    (    (    sA   /home/psgendb/BIRCHDEV/pkg/weblogo-3.4/corebio/seq_io/nexus_io.pyt   <module>#   s   