ó
gbc           @   sÅ  d  d l  m Z m Z d  d l  m Z d  d l m Z d  d l m Z m Z d  d l	 Z	 d e
 f d „  ƒ  YZ e d d	 d
 e ƒ Z d „  Z d e f d „  ƒ  YZ d „  Z d e f d „  ƒ  YZ d e f d „  ƒ  YZ d e f d „  ƒ  YZ d e f d „  ƒ  YZ d e f d „  ƒ  YZ d e f d „  ƒ  YZ d e f d „  ƒ  YZ d e f d „  ƒ  YZ d „  Z d  e f d! „  ƒ  YZ d" „  Z d# e f d$ „  ƒ  YZ d% e f d& „  ƒ  YZ d' „  Z  d( „  Z! d S()   iÿÿÿÿ(   t   skipWhiteLineIteratort   multiLineWrapper(   t   universalOpen(   t   genericEntryIteratorGenerator(   t   debugt   warningNt   FileFormatErrorc           B   s   e  Z d  Z RS(   s7   
       An error derived from the class Exception.
    (   t   __name__t
   __module__t   __doc__(    (    (    s2   lib/python2.7/site-packages/obitools/obo/parser.pyR      s   t   endEntrys   ^ *$t   stripc         C   s"   t  |  ƒ }  t |  ƒ }  t |  ƒ S(   sf  
    Iterator of stanza. The stanza are the basic units of OBO files.
    
    @param inputfile: a stream of strings from an opened OBO file.
    @type inputfile: a stream of strings
    
    @return: a stream of stanza
    @rtype: a stream of aggregated strings
    
    @note: The iterator constructs stanza by aggregate strings from the
    OBO file.
    (   R   R   t   _oboEntryIterator(   t	   inputfile(    (    s2   lib/python2.7/site-packages/obitools/obo/parser.pyt   stanzaIterator   s    t   TrailingModifierc           B   s&   e  Z d  Z e j d ƒ Z d „  Z RS(   s™   
       A class object which inherits from the class dict. Trailing modifiers can be found
       at the end of TaggedValue objects when they exist.
    s   (?<=\ {)[^\]]*(\}) *( !|$)c         C   s\   t  j j | ƒ } | rX | j d ƒ j ƒ  } | GHt j |  d „  | j d ƒ Dƒ ƒ n  d  S(   Ni    c         s   s'   |  ] } | j  ƒ  j d  d ƒ Vq d S(   t   =i   N(   R   t   split(   t   .0t   x(    (    s2   lib/python2.7/site-packages/obitools/obo/parser.pys	   <genexpr>A   s    t   ,(   R   t   _match_bracet   searcht   groupR   t   dictt   __init__R   (   t   selft   stringt   trailing_modifiers(    (    s2   lib/python2.7/site-packages/obitools/obo/parser.pyR   7   s
    (   R   R   R	   t   ret   compileR   R   (    (    (    s2   lib/python2.7/site-packages/obitools/obo/parser.pyR   /   s   c         C   s   t  |  ƒ } | s d } n  | S(   s¥  
    Dispatcher of trailing modifiers.
    
    @param string: a string from a TaggedValue object with a trailing modifiers signal.
    @type string: string
    
    @return: a class object
    
    @note: The dispatcher is currently very simple. Only one case is treated by the function.
    `the function returns a class object inherited from the class dict if the trailing modifiers
    exist, None if they don't.
    N(   R   t   None(   R   R   (    (    s2   lib/python2.7/site-packages/obitools/obo/parser.pyt   trailingModifierFactoryD   s    	t   TaggedValuec           B   se   e  Z d  Z e j d ƒ Z e j d ƒ Z e j d ƒ Z e j d ƒ Z d „  Z	 d „  Z
 d „  Z RS(   s1   
       A couple 'tag:value' of an OBOEntry.
    s'   (("(\\"|[^"])*")|(\\"|[^"]))*?( !| {|$)s   ^!| !s   (?<=")(\\"|[^"])*(?=")s
   \[[^\]]*\]c   	      C   s=  t  d | ƒ d } d } | j d d ƒ \ } } t j j | ƒ j d ƒ } t  d | ƒ | rñ | d d k rñ t | ƒ } | | d j ƒ  } t j	 j | d ƒ } t | ƒ d k rË | d j ƒ  } n  | d } t
 | ƒ } | d d !} n  | d	 k rd
 } t d ‚ n  | j ƒ  |  _ | |  _ | |  _ | |  _ d S(   s  
        Constructor of the class TaggedValue.
        
        @param line: a line of an OBOEntry composed of a tag and a value.
        @type line: string
        
        @note: The constructor separates tags from right terms. 'value' is extracted 
        from right terms using a regular expression (value is at the beginning of the
        string, between quotes or not). Then, 'comment' is extracted from the rest of the 
        string using another regular expression ('comment' is at the end of the string 
        after a '!'. By default, 'comment' is set to None). Finally, 'trailing_modifiers'
        are extracted from the last string using another regular expression.
        The tag, the value, the comment and the trailing_modifiers are saved.
        s   tagValueParser : %st   :i   i    s   Extracted value : %siÿÿÿÿs   !{i   t   use_termt   considers>   user_term is a deprecated tag, you should instead use considerN(   R   R   R   R!   t   _match_valueR   R   t   lenR   t   _split_commentR    t   DeprecationWarningt   valuet   tagR	   R   (	   R   t   lineR   t   commentR*   t   rigthR)   t   lvaluet   extra(    (    s2   lib/python2.7/site-packages/obitools/obo/parser.pyR   g   s,    
		c         C   s   t  |  j ƒ S(   N(   t   strR)   (   R   (    (    s2   lib/python2.7/site-packages/obitools/obo/parser.pyt   __str__ž   s    c         C   s   d t  |  ƒ S(   Ns   """%s"""(   R0   (   R   (    (    s2   lib/python2.7/site-packages/obitools/obo/parser.pyt   __repr__¡   s    (   R   R   R	   R   R   R%   R'   t   _match_quotedStringt   _match_bracketR   R1   R2   (    (    (    s2   lib/python2.7/site-packages/obitools/obo/parser.pyR!   ]   s   	7	t	   NameValuec           B   s   e  Z d  Z d „  Z RS(   sb   
       A couple 'name:value' inherited from the class TaggedValue. Used to manage name tags.
    c         C   sF   | j  d d ƒ \ } } | j ƒ  |  _ d |  _ d  |  _ d  |  _ d  S(   NR"   i   t   name(   R   R   R)   R*   R   R	   R   (   R   R+   R*   R-   (    (    s2   lib/python2.7/site-packages/obitools/obo/parser.pyR   ª   s
    		(   R   R   R	   R   (    (    (    s2   lib/python2.7/site-packages/obitools/obo/parser.pyR5   ¥   s   t   DefValuec           B   s   e  Z d  Z d „  Z RS(   s`   
       A couple 'def:value' inherited from the class TaggedValue. Used to manage def tags.
    c         C   s•   t  j |  | ƒ t  j j |  j ƒ j d ƒ } |  j j | d ƒ } | j d d ƒ } t  j j | ƒ j d ƒ } d |  _ | |  _ t	 | ƒ |  _
 d S(   s‰  
        Constructor of the class DefValue.
        
        @param line: a line of an OBOEntry composed of a tag named 'def' and a value.
        @type line: string
        
        @note: The constructor calls the TaggedValue constructor. A regular expression 
        is used to extract the 'definition' from TaggedValue.value (definition is a not 
        quoted TaggedValue.value). A regular expression is used to extract 'dbxrefs' 
        from the aggedValue.value without the definition (dbxrefs are between brackets
        and definition can be so). Definition is saved as the new value of the DefValue.
        dbxrefs are saved.
        i    t    s     t    t   defN(   R!   R   R3   R   R)   R   t   replaceR4   R*   t   xrefFactoryt   dbxrefs(   R   R+   t
   definitiont
   cleanvalueR=   (    (    s2   lib/python2.7/site-packages/obitools/obo/parser.pyR   ¼   s    		(   R   R   R	   R   (    (    (    s2   lib/python2.7/site-packages/obitools/obo/parser.pyR7   ·   s   t   SynonymValuec           B   s8   e  Z d  Z e j d ƒ Z d „  Z d „  Z d „  Z RS(   s°   
       A couple 'synonym:value' inherited from the class TaggedValue. Used to manage 
       synonym tags, exact_synonym tags, broad_synonym tags and narrow_synonym tags.
    s   (?<="")[^\[]*(?=\[|$)c   	      C   sñ  t  j |  | ƒ t  j j |  j ƒ j d ƒ } |  j j | d ƒ } | j d d ƒ } t t j	 j | ƒ j d ƒ j
 ƒ  j ƒ  ƒ } | t d d d d g ƒ @} | | } t | ƒ d	 k  sÆ t d
 ƒ ‚ | rÛ | j ƒ  } n d } |  j d k rt d ‚ d |  _ d } n  |  j d k r5t d ‚ d |  _ d } n  |  j d k r_t d ‚ d |  _ d } n  |  j d k r€d |  _ d } n  |  j d k s¢t d |  j ƒ ‚ t  j j | ƒ j d ƒ } | |  _ t | ƒ |  _ | |  _ t | ƒ |  _ d S(   s”  
        Constructor of the class SynonymValue.
        
        @param line: a line of an OBOEntry composed of a tag named 'synonym' or
        'exact_synonym' or 'broad_synonym' or 'narrow_synonym' and a value.
        @type line: string
        
        @note: SynonymValue is composed of a tag, a value, a scope, a list of types and 
        dbxrefs.
        The constructor calls the TaggedValue constructor. A regular expression 
        is used to extract 'definition' from TaggedValue.value (definition is a not 
        quoted TaggedValue.value). Definition is saved as the new value of the class
        SynonymValue.
        A regular expression is used to extract 'attributes' from the rest of the
        string. Attributes may contain an optional synonym scope and an optional list 
        of synonym types. The scope is extracted from attributes or set by default to
        'RELATED'. It is saved as the scope of the class. The types are the rest of the 
        attributes and are saved as the list of types of the class.
        For deprecated tags 'exact_synonym', 'broad_synonym' and 'narrow_synonym', tag
        is set to 'synonym' and scope is set respectively to 'EXACT', 'BROAD' and 'NARROW'.
        A regular expression is used to extract 'dbxrefs' from the TaggedValue.value 
        without the definition (dbxrefs are between brackets and definition can be so).
        dbxrefs are saved.
        i    R8   s     R9   t   RELATEDt   EXACTt   BROADt   NARROWi   s   Only one synonym scope allowedt   exact_synonyms9   exact_synonym is a deprecated tag use instead synonym tagt   synonymt   broad_synonyms9   broad_synonym is a deprecated tag use instead synonym tagt   narrow_synonyms:   narrow_synonym is a deprecated tag use instead synonym tagt   systematic_synonymt
   SYSTEMATICs   %s synonym type is not managedN(   R!   R   R3   R   R)   R   R;   t   setR@   t   _match_scopeR   R   R&   t   AssertionErrort   popR*   R(   R4   R<   R=   t   scopet   listt   types(	   R   R+   R>   R?   t
   attributest   scopesRQ   RO   R=   (    (    s2   lib/python2.7/site-packages/obitools/obo/parser.pyR   ç   s@    -
											"		c         C   s|   |  j  | j  k o{ |  j | j k o{ |  j | j k o{ |  j | j k o{ |  j | j k o{ |  j | j k o{ |  j | j k S(   N(   R)   R=   RO   RQ   R	   R*   R   (   R   t   b(    (    s2   lib/python2.7/site-packages/obitools/obo/parser.pyt   __eq__B  s    $$$c      
   C   sW   t  d „  d „  |  j |  j t |  j ƒ |  j t |  j ƒ |  j |  j g Dƒ d ƒ d S(   Nc         S   s   |  | S(   N(    (   R   t   y(    (    s2   lib/python2.7/site-packages/obitools/obo/parser.pyt   <lambda>I  s    c         s   s   |  ] } t  | ƒ Vq d  S(   N(   t   hash(   R   t   z(    (    s2   lib/python2.7/site-packages/obitools/obo/parser.pys	   <genexpr>I  s    i    i   i   I   €    (	   t   reduceR	   R)   t	   frozensetR=   RO   RQ   R*   R   (   R   (    (    s2   lib/python2.7/site-packages/obitools/obo/parser.pyt   __hash__H  s    (	   R   R   R	   R   R   RL   R   RU   R\   (    (    (    s2   lib/python2.7/site-packages/obitools/obo/parser.pyR@   ß   s
   	[	t	   XrefValuec           B   s   e  Z d  Z d „  Z RS(   sj   
       A couple 'xref:value' inherited from the class TaggedValue. Used to manage 
       xref tags.
    c         C   sf   t  j |  | ƒ t |  j ƒ |  _ |  j d k rM t d |  j ‚ d |  _ n  |  j d k sb t ‚ d  S(   Nt   xref_analogt   xref_unks/   %s is a deprecated tag use instead sysnonym tagt   xref(   R^   R_   (   R!   R   R<   R)   R*   R(   RM   (   R   R+   (    (    s2   lib/python2.7/site-packages/obitools/obo/parser.pyR   X  s    (   R   R   R	   R   (    (    (    s2   lib/python2.7/site-packages/obitools/obo/parser.pyR]   R  s   t   RelationshipValuec           B   s   e  Z d  Z d „  Z RS(   sj   
       A couple 'xref:value' inherited from the class TaggedValue. Used to manage 
       xref tags.
    c         C   st   t  j |  | ƒ |  j j d  d ƒ } t | ƒ d k rN | d } | d } n d } | d } | |  _ | |  _ d  S(   Ni   i   i    t   is_a(   R!   R   R)   R   R   R&   t   relationship(   R   R+   R)   Rc   t   term(    (    s2   lib/python2.7/site-packages/obitools/obo/parser.pyR   n  s    

	(   R   R   R	   R   (    (    (    s2   lib/python2.7/site-packages/obitools/obo/parser.pyRa   h  s   t   NamespaceValuec           B   s   e  Z d  „  Z RS(   c         C   s   t  j |  | ƒ d  S(   N(   R!   R   (   R   R+   (    (    s2   lib/python2.7/site-packages/obitools/obo/parser.pyR   …  s    (   R   R   R   (    (    (    s2   lib/python2.7/site-packages/obitools/obo/parser.pyRe   „  s   t   RemarkValuec           B   s   e  Z d  „  Z RS(   c         C   sY   t  j |  | ƒ |  j j d d ƒ \ } } | j ƒ  } | j ƒ  } | |  _ | |  _ d  S(   NR"   i   (   R!   R   R)   R   R   t   label(   R   R+   Rg   R)   (    (    s2   lib/python2.7/site-packages/obitools/obo/parser.pyR   ‰  s    	(   R   R   R   (    (    (    s2   lib/python2.7/site-packages/obitools/obo/parser.pyRf   ˆ  s   c         C   s^  |  d d !d k s& |  d d !d k r0 t  |  ƒ S|  d d !d k rM t |  ƒ S|  d d !d	 k rs |  d d
 !d k s¬ |  d d !d k s¬ |  d d !d k s¬ |  d d
 !d k r¶ t |  ƒ S|  d d !d k rÓ t |  ƒ S|  d d !d k rð t |  ƒ S|  d d !d k s)|  d d !d k s)|  d d !d k r3t |  ƒ S|  d d !d k rPt |  ƒ St |  ƒ Sd S(   sú   
    A function used to dispatch lines of an OBOEntry between the class TaggedValue
    and its inherited classes.
    
    @param line: a line of an OBOEntry composed of a tag and a value.
    @type line: string
    
    @return: a class object
    i    i	   t	   namespacei   s   default-namespacei   R:   i   RF   i   t   synonymtypedefi   RE   RG   RH   i   R`   R6   i   t   intersection_ofi   t   union_ofi   Rc   i   t   remarkN(   Re   R7   R@   R]   R5   Ra   Rf   R!   (   R+   (    (    s2   lib/python2.7/site-packages/obitools/obo/parser.pyt   taggedValueFactory’  s*    

&




t   Xrefc           B   s8   e  Z d  Z e j d ƒ Z d „  Z d „  Z d „  Z RS(   s”   
       A xref object of an OBOentry. It may be the 'dbxrefs' of SynonymValue and 
       DefValue objects or the 'value' of XrefValue objects.
    s
    +(?=["{])c         C   sÐ   | d k r d  } d } n t j j | d ƒ } | d } d  } d  } t | ƒ d k r± | d } t j j | ƒ } | d  k	 r¢ | j d ƒ } | j	 | d ƒ n  t
 | ƒ } n  | |  _ | |  _ | |  _ d  S(   NR8   i   i    (   R   Rn   t   __splitdata__R   R&   R!   R3   R   R   R;   R    t	   referencet   descriptionR   (   R   t   reft   dataRq   R   R/   (    (    s2   lib/python2.7/site-packages/obitools/obo/parser.pyR   É  s"    	

		c         C   s4   |  j  | j  k o3 |  j | j k o3 |  j | j k S(   N(   Rp   Rq   R   (   R   RT   (    (    s2   lib/python2.7/site-packages/obitools/obo/parser.pyRU   Ý  s    $c         C   s3   t  d „  d „  |  j |  j |  j g Dƒ d ƒ d S(   Nc         S   s   |  | S(   N(    (   R   RV   (    (    s2   lib/python2.7/site-packages/obitools/obo/parser.pyRW   â  s    c         s   s   |  ] } t  | ƒ Vq d  S(   N(   RX   (   R   RY   (    (    s2   lib/python2.7/site-packages/obitools/obo/parser.pys	   <genexpr>â  s    i    i   i   I   €    (   RZ   Rp   Rq   R   (   R   (    (    s2   lib/python2.7/site-packages/obitools/obo/parser.pyR\   á  s    (	   R   R   R	   R   R   Ro   R   RU   R\   (    (    (    s2   lib/python2.7/site-packages/obitools/obo/parser.pyRn   Á  s
   		c         C   s]   |  j  ƒ  }  |  d d k rO g  |  d d !j d ƒ D] } t | j  ƒ  ƒ ^ q3 St |  ƒ Sd S(   s#  
    Dispatcher of xrefs.
    
    @param string: a string (between brackets) from an inherited TaggedValue object with a dbxrefs 
                   signal (actually, the signal can only be found into SynonymValue and DefValue 
                   objects) or a string (without brackets) from a XrefValue object.
    @type string: string
    
    @return: a class object
    
    @note: The dispatcher treats differently the strings between brackets (from SynonymValue and 
    DefValue objects) and without brackets (from XrefValue objects).
    i    t   [i   iÿÿÿÿR   N(   R   R   Rn   (   R   R   (    (    s2   lib/python2.7/site-packages/obitools/obo/parser.pyR<   ç  s    3t   OBOEntryc           B   s;   e  Z d  Z e j d ƒ Z d „  Z d „  Z e e ƒ Z RS(   sª   
       An entry of an OBOFile. It can be a header (without a stanza name) or
       a stanza (with a stanza name between brackets). It inherits from the class dict.
    s   (?<=^\[)[^\]]*(?=\])c         C   s¼   | d d k |  _  | j d ƒ } |  j  se | d j ƒ  d d !|  _ | d } | j ƒ  g |  d <n  xP | D]H } t | ƒ } | j |  k r¤ |  | j j | ƒ ql | g |  | j <ql Wd  S(   Ni    Rt   s   
i   iÿÿÿÿt   stanza(   t   isHeaderR   R   t
   stanzaNameRm   R*   t   append(   R   Rv   t   linesR+   t   taggedvalue(    (    s2   lib/python2.7/site-packages/obitools/obo/parser.pyR   	  s    	
c         C   s-   t  j j |  ƒ } | r% | j d ƒ Sd  Sd  S(   Ni    (   Ru   t   _match_stanza_nameR   R   R   (   Rv   t   sm(    (    s2   lib/python2.7/site-packages/obitools/obo/parser.pyt   parseStanzaName  s    (	   R   R   R	   R   R   R|   R   R~   t   staticmethod(    (    (    s2   lib/python2.7/site-packages/obitools/obo/parser.pyRu     s
   		t   OBOTermc           B   sý  e  Z d  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z	 d „  Z
 d	 „  Z d
 „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z e e d d ƒ Z e e d d ƒ Z e e d d ƒ Z e e d d ƒ Z e e d d ƒ Z e e	 d d ƒ Z e e
 d d ƒ Z e e d d ƒ Z e e d d ƒ Z  e e d d ƒ Z! e e d d ƒ Z" e e d d ƒ Z# e e d d ƒ Z$ e e d d ƒ Z% e e d d ƒ Z& e e d d ƒ Z' e e d d ƒ Z( e e d d ƒ Z) RS(   sH   
       A stanza named 'Term'. It inherits from the class OBOEntry.
    c         C   s"  t  j |  | ƒ |  j d k s% t ‚ d |  k s7 t ‚ d |  k rY t |  d ƒ d k se t d ƒ ‚ d |  k r‡ t |  d ƒ d k s“ t d ƒ ‚ d |  k sÁ t |  d ƒ d k sÁ t d	 ƒ ‚ d
 |  k sï t |  d
 ƒ d k sï t d ƒ ‚ d |  k st |  d ƒ d k st d ƒ ‚ d |  k sKt |  d ƒ d k sKt d ƒ ‚ d |  k syt |  d ƒ d k syt d ƒ ‚ |  j ƒ  râd |  k s—t ‚ d |  k s©t ‚ d |  k s»t ‚ d |  k sÍt ‚ d |  k sât ‚ n  d |  k s |  j ƒ  s t ‚ d |  k s|  j ƒ  st ‚ d  S(   Nt   TermRv   t   idi   s   An OBOTerm must have an idR6   s   An OBOTerm must have a nameRh   s-   Only one namespace is allowed for an OBO termR:   s.   Only one definition is allowed for an OBO termR,   s+   Only one comment is allowed for an OBO termRk   i   s6   Only one union relationship is allowed for an OBO termRj   s=   Only one intersection relationship is allowed for an OBO termRc   t
   inverse_oft   disjoint_fromt   replaced_byR$   (   Ru   R   Rx   RM   R&   t   _isObsolete(   R   Rv   (    (    s2   lib/python2.7/site-packages/obitools/obo/parser.pyR   ,  s$    .......c         C   s   |  d d S(   NRv   i    (    (   R   (    (    s2   lib/python2.7/site-packages/obitools/obo/parser.pyt
   _getStanzaH  s    c         C   s   d |  k r |  d d Sd  S(   NR:   i    (   R   (   R   (    (    s2   lib/python2.7/site-packages/obitools/obo/parser.pyt   _getDefinitionL  s    c         C   s   |  d d S(   NR‚   i    (    (   R   (    (    s2   lib/python2.7/site-packages/obitools/obo/parser.pyt   _getIdQ  s    c         C   s   |  d d S(   NRh   i    (    (   R   (    (    s2   lib/python2.7/site-packages/obitools/obo/parser.pyt   _getNamespaceT  s    c         C   s   |  d d S(   NR6   i    (    (   R   (    (    s2   lib/python2.7/site-packages/obitools/obo/parser.pyt   _getNameW  s    c         C   s   d |  k r |  d d Sd  S(   NR,   i    (   R   (   R   (    (    s2   lib/python2.7/site-packages/obitools/obo/parser.pyt   _getCommentZ  s    c         C   s,   d |  k r( t  t |  j d d  ƒ ƒ ƒ Sd  S(   Nt   alt_id(   RP   RK   t   getR   (   R   (    (    s2   lib/python2.7/site-packages/obitools/obo/parser.pyt
   _getAltIds_  s    c         C   s,   d |  k r( t  t |  j d d  ƒ ƒ ƒ Sd  S(   NRb   (   RP   RK   RŽ   R   (   R   (    (    s2   lib/python2.7/site-packages/obitools/obo/parser.pyt   _getIsAd  s    c         C   s,   d |  k r( t  t |  j d d  ƒ ƒ ƒ Sd  S(   NRF   (   RP   RK   RŽ   R   (   R   (    (    s2   lib/python2.7/site-packages/obitools/obo/parser.pyt   _getSynonymi  s    c         C   s<   |  j  d d  ƒ d  k r4 t t |  j  d d  ƒ ƒ ƒ Sd  Sd  S(   Nt   subset(   RŽ   R   RP   RK   (   R   (    (    s2   lib/python2.7/site-packages/obitools/obo/parser.pyt
   _getSubsetn  s    c         C   s,   d |  k r( t  t |  j d d  ƒ ƒ ƒ Sd  S(   NR`   (   RP   RK   RŽ   R   (   R   (    (    s2   lib/python2.7/site-packages/obitools/obo/parser.pyt   _getXreft  s    c         C   s,   d |  k r( t  t |  j d d  ƒ ƒ ƒ Sd  S(   NRc   (   RP   RK   RŽ   R   (   R   (    (    s2   lib/python2.7/site-packages/obitools/obo/parser.pyt   _getRelationShipy  s    c         C   s   t  t |  j d d  ƒ ƒ ƒ S(   NRk   (   RP   RK   RŽ   R   (   R   (    (    s2   lib/python2.7/site-packages/obitools/obo/parser.pyt	   _getUnion~  s    c         C   s   t  t |  j d d  ƒ ƒ ƒ S(   NRj   (   RP   RK   RŽ   R   (   R   (    (    s2   lib/python2.7/site-packages/obitools/obo/parser.pyt   _getIntersection  s    c         C   s   t  t |  j d d  ƒ ƒ ƒ S(   NR„   (   RP   RK   RŽ   R   (   R   (    (    s2   lib/python2.7/site-packages/obitools/obo/parser.pyt   _getDisjonction„  s    c         C   s$   d |  k o# t  |  d d ƒ d k S(   Nt   is_obsoletei    t   true(   R0   (   R   (    (    s2   lib/python2.7/site-packages/obitools/obo/parser.pyR†   ‡  s    c         C   s,   d |  k r( t  t |  j d d  ƒ ƒ ƒ Sd  S(   NR…   (   RP   RK   RŽ   R   (   R   (    (    s2   lib/python2.7/site-packages/obitools/obo/parser.pyt   _getReplacedByŠ  s    c         C   s,   d |  k r( t  t |  j d d  ƒ ƒ ƒ Sd  S(   NR$   (   RP   RK   RŽ   R   (   R   (    (    s2   lib/python2.7/site-packages/obitools/obo/parser.pyt   _getConsider  s    N(*   R   R   R	   R   R‡   Rˆ   R‰   RŠ   R‹   RŒ   R   R   R‘   R“   R”   R•   R–   R—   R˜   R†   R›   Rœ   t   propertyR   Rv   R>   R‚   Rh   R6   R,   t   alt_idsRb   t   synonymst   subsetst   xrefsRc   Rk   Rj   R„   R™   R…   R$   (    (    (    s2   lib/python2.7/site-packages/obitools/obo/parser.pyR€   (  sL   																			c         C   s3   t  j |  ƒ } | d k r% t |  ƒ St  |  ƒ Sd S(   s  
    Dispatcher of stanza.
    
    @param stanza: a stanza composed of several lines.
    @type stanza: text
    
    @return: an C{OBOTerm} | C{OBOEntry} instance
    
    @note: The dispatcher treats differently the stanza which are OBO "Term"
    and the others.
    R   N(   Ru   R~   R€   (   Rv   t
   stanzaType(    (    s2   lib/python2.7/site-packages/obitools/obo/parser.pyt   OBOEntryFactory©  s    
c         c   s6   t  |  ƒ } x# | D] } t | ƒ t | ƒ Vq Wd  S(   N(   R   R   R£   (   t   filet   entriest   e(    (    s2   lib/python2.7/site-packages/obitools/obo/parser.pyt   OBOEntryIterator½  s    
("   t   obitools.utilsR    R   R   t   obitools.format.genericparserR   t   loggingR   R   R   t	   ExceptionR   t   TrueR   R   R   R   R    t   objectR!   R5   R7   R@   R]   Ra   Re   Rf   Rm   Rn   R<   Ru   R€   R£   R§   (    (    (    s2   lib/python2.7/site-packages/obitools/obo/parser.pyt   <module>   s2   			H(s
	/&	&	