ó
£žbc           @   s[   d  d „ Z  d  d „ Z d  d „ Z d  d „ Z d  e d „ Z d  d „ Z d d „ Z d S(	   g      I@c         C   s   t  |  | | ƒ \ } } | S(   s8  
    Abstract: Returns the NG50 value of the passed list of numbers.
    Comments: Works for any percentage (e.g. NG60, NG70) with optional argument
    Usage: NG50(numlist, reference_length)

    Based on the definition from this SEQanswers post
    http://seqanswers.com/forums/showpost.php?p=7496&postcount=4
    (modified Broad Institute's definition
    https://www.broad.harvard.edu/crd/wiki/index.php/N50)

    See SEQanswers threads for details:
    http://seqanswers.com/forums/showthread.php?t=2857
    http://seqanswers.com/forums/showthread.php?t=2332
    (   t   NG50_and_LG50(   t   numlistt   reference_lengtht
   percentaget   ng50t   lg50(    (    s<   /home/psgendb/BIRCHDEV/install/quast-5.2.0/quast_libs/N50.pyt   NG50   s    c         C   s   t  |  | | ƒ \ } } | S(   sÄ   
    Abstract: Returns the LG50 value of the passed list of numbers.
    Comments: Works for any percentage (e.g. LG60, LG70) with optional argument
    Usage: LG50(numlist, reference_length)
    (   R    (   R   R   R   R   R   (    (    s<   /home/psgendb/BIRCHDEV/install/quast-5.2.0/quast_libs/N50.pyt   LG50   s    c         C   s   t  |  t |  ƒ | ƒ S(   s®   
    Abstract: Returns the N50 value of the passed list of numbers.
    Comments: Works for any percentage (e.g. N60, N70) with optional argument
    Usage: N50(numlist)
    (   R   t   sum(   R   R   (    (    s<   /home/psgendb/BIRCHDEV/install/quast-5.2.0/quast_libs/N50.pyt   N50%   s    c         C   s   t  |  t |  ƒ | ƒ S(   s®   
    Abstract: Returns the L50 value of the passed list of numbers.
    Comments: Works for any percentage (e.g. L60, L70) with optional argument
    Usage: L50(numlist)
    (   R   R   (   R   R   (    (    s<   /home/psgendb/BIRCHDEV/install/quast-5.2.0/quast_libs/N50.pyt   L50.   s    c   	      C   s    | d k s t  ‚ | d k s$ t  ‚ | r= |  j d t ƒ n  | } | d | d } d } x> |  D]6 } | | 8} | d 7} | | k rb | } | | f Sqb Wd S(   Ng        g      Y@t   reversei    i   (   NN(   t   AssertionErrort   sortt   Truet   None(	   R   R   R   t	   need_sortt   st   limitR   t   lR   (    (    s<   /home/psgendb/BIRCHDEV/install/quast-5.2.0/quast_libs/N50.pyR    7   s    

c         C   s   t  |  t |  ƒ | ƒ S(   N(   R    R   (   R   R   (    (    s<   /home/psgendb/BIRCHDEV/install/quast-5.2.0/quast_libs/N50.pyt   N50_and_L50I   s    c         C   sâ   yÉ t  |  ƒ d k s! t d ƒ ‚ t g  |  D] } t | t t t f ƒ ^ q+ ƒ s^ t d ƒ ‚ | rs t | ƒ } n t t |  ƒ ƒ } | d k s t d ƒ ‚ t t g  |  D] } | d ^ qª ƒ ƒ | SWn t k
 rÝ d SXd S(   s€   
    numlist - length of contigs
    metric explanation http://lh3.github.io/2020/04/08/a-new-metric-on-assembly-contiguity
    i    s   Empty list as inputs   Non-numerical inputg        s   all contigs are 0i   N(	   t   lenR   t   allt
   isinstancet   intt   floatt   complexR   R   (   R   R   t   it   denumt   n(    (    s<   /home/psgendb/BIRCHDEV/install/quast-5.2.0/quast_libs/N50.pyt	   au_metricM   s    =/N(	   R   R   R	   R
   t   FalseR    R   R   R   (    (    (    s<   /home/psgendb/BIRCHDEV/install/quast-5.2.0/quast_libs/N50.pyt   <module>   s   
		