ó
ÉÝ{Tc           @   sp  d  Z  d d l Z d d l Z d d l Z d d l Td d l Z d d l Z d d l Td d l Ti d d 6d d 6d d	 6d
 d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d  d! 6d" d# 6d$ d% 6d& d' 6d( d) 6d* d+ 6d, d- 6d. d/ 6Z	 i d0 d 6d1 d 6d2 d 6d3 d 6d4 d 6d5 d 6d6 d 6d6 d7 6d8 d 6d9 d 6d: d* 6d; d 6d< d. 6d= d 6d> d" 6d? d  6d; d@ 6dA dB 6dA d$ 6dC d& 6dD dE 6dF d, 6Z
 i d' d 6d	 dG 6Z d	 d d d dH d g Z d d d d! g Z dI f  dJ „  ƒ  YZ dK e f dL „  ƒ  YZ dM f  dN „  ƒ  YZ dO „  Z dP „  Z dQ e e j f dR „  ƒ  YZ dS „  Z dT „  Z dU „  Z dV „  Z d S(W   sŸ  
     python/ui/model_selection.py: CCP4MG Molecular Graphics Program
     Copyright (C) 2001-2008 University of York, CCLRC
     Copyright (C) 2009-2011 University of York
     Copyright (C) 2012 STFC

     This library is free software: you can redistribute it and/or
     modify it under the terms of the GNU Lesser General Public License
     version 3, modified in accordance with the provisions of the 
     license to address the requirements of UK law.
 
     You should have received a copy of the modified GNU Lesser General 
     Public License along with this library.  If not, copies may be 
     downloaded from http://www.ccp4.ac.uk/ccp4license.php
 
     This program is distributed in the hope that it will be useful,
     but WITHOUT ANY WARRANTY; without even the implied warranty of
     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     GNU Lesser General Public License for more details.
iÿÿÿÿN(   t   *s	   All atomst   alls   All non-solventt
   allnotsolvs   All peptidet   peptides
   No peptidet	   nopeptides   CA tracet   catraces
   Main chaint   mains   Side chainst   sides   CA+side chainss   CA+sides   peptide linkt   peptide_links
   SS bridgest   ssbonds   All nucleic acidt   nucleics   No nucleic acidt	   nonucleict   Backbonet   backbonet   Basest   bases   Sugar ringst
   sugar_ringt   Saccharidest
   saccharidet   Metalt   metalt   Monomerst   monomerss   Active sitest   sitest   Solventt   solventt   Solutet   solutes   Same as othert   same_ass   allatoms.svgs   allnonsolvent.svgs   allpeptide.svgs   catrace.svgs   mainchain.svgs   sidechain.svgs   ssbridge.svgs   Disulphide bridgess   allnucleic.svgs   backbone.svgs   solvent.svgs	   bases.svgs
   sameas.svgs   peptidelink.svgs   saccharides.svgs   sugarrings.svgt   Nucleotidess	   metal.svgt   Metalss   monomers.svgs
   lipids.svgt   Lipidss
   solute.svgt
   amino_acids   Ca+sidet   SelectionParserc           B   sA   e  Z d  „  Z d „  Z d d „ Z d „  Z d „  Z d „  Z RS(   c         C   s€   |  j  | ƒ } | d d k r) d d g St d d |  ƒ } | j | d | d | d ƒ } | j ƒ  } | j ƒ  d | g Sd S(	   sD   
    Convert an input command string to a python list selection
    i    i   s   Error parsing commandt   TOPt    i   i   N(   t   tokeniset   Cselect_treet   import_command_stringt   gett   cleanup(   t   selft   commandt   tokst   tt   rvt   l(    (    sF   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/python/ui/model_selection.pyt   command_to_list]   s    
!
c         C   s9   t  d d |  ƒ } | j | ƒ | j ƒ  } | j ƒ  | S(   NR"   R#   (   R%   t   sett   export_command_stringR(   (   R)   t   listR,   R-   (    (    sF   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/python/ui/model_selection.pyt   list_to_commandn   s
    
i   c         C   sÄ  d d d d d g } g  } g  } g  } t  j d d | ƒ } t  j d d	 | ƒ } t  j d d
 | ƒ } t  j d | ƒ } t | ƒ d k r¢ t  j d d | ƒ } n  t  j d ƒ }	 d }
 x… |	 j | ƒ D]t } t  j d | ƒ } xC t d t | ƒ ƒ D], } |
 d }
 t  j d | |
 | d ƒ } qõ W| j t j	 | ƒ ƒ qÇ Wx- |	 j | ƒ D] } | j t j	 | ƒ ƒ qOW|  j
 | ƒ } | d d k r’| S| d } t | ƒ d k r´| d d k r÷| d d k r)d d d | d d | d d g Sn2 | d d k r)| d d k r)d d | d g S| j | d ƒ } xt d t | ƒ ƒ D]ú} | j | | ƒ } | | | | d } | rÒ| rÒ| | d k rÒ| | d k rÒd d | | d d | | g Sn  | ru| d k r-| | d k rrd d d | | d d | | d | | d g Squ| | d k ru| | d k rrd d | | d d | | g Squn  | r| d k  rÐ| | d k rd d d | | d d | | d | | d g SqF| | d k rF| | d k rd d | | d d | | g SqFn. | | d d k rF| | d k rFd d g S| } qRW| r{| d d k r±d d | d g Sq´| d d k r´d d d | d d | d d g Sn  d | | | g S(   Nt   andt   ort   xort   exclt   nott   {s    { t   }s    } s    not s   ".*?"i    t   QuOTEs#   \{| and | or | xor | excl | not |\}iÿÿÿÿi   R#   i   s&   Missing operator before open brace at t   't    i   s   Missing element before s   Missing element between s'   Missing operator before open braces at s'   Missing operator after close braces at i   s$   Missing operator between braces } { s   Missing element after final s!   Missing operator after braces at (   t   ret   subt   findallt   lent   compilet   splitt   ranget   appendt   stringt   stript	   getlevelst   count(   R)   t   inp_strt   reportt   stdopst   elementst   opst   levelst   wk_strt   quotedt   rxt   nqt   elet   qut   iit   opR.   t   lopt   it   copt   dlev(    (    sF   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/python/ui/model_selection.pyR$   w   s€     
  
&  %6(6($

&c         C   s©  t  | ƒ } d } xB| t  | ƒ k  rV|  j | | ƒ } | d d k  rW | d } q | d d k rk | S| j | ƒ t  | d ƒ d k r© | j | | d d ƒ q | j | d ƒ | d } | j ƒ  x | D] } | j | | ƒ qÔ W| j | d ƒ | d }	 |	 j ƒ  | j | d ƒ x |	 D] }
 | j | |
 ƒ q)W| j | d ƒ q Wt  | ƒ | k r™|  j | ƒ } | d d k rŒ| S| d } n  d | | | g S(   Ni    i   R#   i   R:   R9   (   RA   t   expand0t   popt   insertt   reverseRH   (   R)   RM   RN   RO   t   initlRY   R+   t	   elements0t   et   ops0t   oR.   (    (    sF   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/python/ui/model_selection.pyt   expandË   s:    

 

  c         C   sV   | d k r d g St  | ƒ } | d } |  j | ƒ } | rK |  j | ƒ Sd g Sd  S(   NR#   iÿÿÿÿi    (   t
   splitWordst   expand_selection_aliasR$   (   R)   t   elementt   wordst   fwordt   expanded(    (    sF   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/python/ui/model_selection.pyR\   ó   s     
c         C   s³   d } g  } x† | D]~ } | d k r? | d } | j  | ƒ q | d k r„ | j  | ƒ | d } | d k  r‘ d d t | ƒ f Sq | j  | ƒ q W| d k r¥ d Sd | f Sd  S(	   Ni    R9   i   R:   i   s   Unmatched closing braces   Unmatched opening brace(   i   s   Unmatched opening bracei    (   RE   RA   (   R)   RN   t   levelRO   RW   (    (    sF   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/python/ui/model_selection.pyRH     s    

(   t   __name__t
   __module__R/   R3   R$   Re   R\   RH   (    (    (    sF   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/python/ui/model_selection.pyR!   X   s   			T	(	t   ModelAnalysisc           B   sð  e  Z d  „  Z d „  Z d „  Z d „  Z d d „ Z d d „ Z d „  Z d „  Z	 d	 „  Z
 d
 „  Z d „  Z d „  Z d „  Z d d d g  d „ Z d d „ Z d „  Z d „  Z e d d „ Z e d d d d „ Z d „  Z d d d „ Z d d d d d „ Z d d d „ Z d d d d „ Z e e d „ Z d „  Z d d d d d d „ Z e e d  „ Z d! d! d! d" d# e e d$ „ Z  d d d% d! d& d e! d' „ Z" d d( e! d) „ Z# e! d* „ Z$ e e! d+ „ Z% d, d d- d! d d d d d d e e d e d. „ Z& d d d d/ „ Z' e d d0 d1 d2 „ Z( d d d d e e d# d d3 d4 „	 Z) e e d5 „ Z* e e d6 „ Z+ e e d7 „ Z, e e d8 „ Z- d e e d d d d9 d d d: „	 Z. d e d e e d; „ Z/ d< e e d= „ Z0 d d> „ Z1 d d? „ Z2 RS(@   c         C   sd   d d d d d d d d d	 d
 d d d g |  _  d d d d d d d d d d d d d g |  _ d  S(   NR   t   spheret   neighbt   one_atomt   terminit
   sseterminit   modelterminit   rangest   slabt   buriedt   ssbondst
   same_namest   symidt	   selectAllt   selectSpheret   selectNeighbt   selectOneAtomt   selectTerminit   selectSSETerminit   selectModelTerminit   selectRangest
   selectSlabt   selectBuriedt   selectSSbondst   selectEquivalentAtomst   selectSymid(   t   selection_commandst   selection_methods(   R)   (    (    sF   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/python/ui/model_selection.pyt   __init__  s    !	c         C   s<  d d  l  } d d  l } d |  _ |  j j ƒ  |  _ |  j d k  rN d |  _ n  |  j r® d  } d |  _ xE | rª |  j |  j k  rª |  j d |  _ |  j j |  j ƒ } qi Wn  g  |  _ g  |  _	 g  |  _
 g  |  _ g  |  _ g  |  _ d |  _ g  |  _ g  |  _ g  |  _ d |  _ g  |  _ g  |  _ d |  _ d } |  j d k rM|  j } n  |  j ƒ  g  } |  j j ƒ  } t ƒ  } t ƒ  } |  j j | t | d t d t d d d d d t ƒ x~ t ƒ  j d d d |  j  ƒ D]^ }	 d	 d
 d g j! |	 ƒ rûd |  _ n  |  j j | t | d t d t d d d |	 d t" ƒ qÑW| j# |  j | | ƒ } | j$ ƒ  }
 x½ |
 d k rt% | d ƒ } | j& | j' ƒ  ƒ }	 | j( |	 ƒ d	 d
 d g j! |	 ƒ r»d |  _ n  |  j j | t | d t d t d d d |	 d t" ƒ | j# |  j | | ƒ } | j$ ƒ  }
 qZW| r!t ƒ  j) d |  j  d d d d ƒ \ } } i  } g  } | rÄ| j* d ƒ rÄxX | d j+ ƒ  D]C \ } } | d k r³x( | D] } | j( | ƒ q™Wqz| | | <qzWn  x% | D] }	 | j( |	 ƒ |	 | |	 <qËW| | d <t ƒ  j, d |  j  d d d d d | ƒ n  |  j j | t | d t d t d d d d d t ƒ |  j j | t d t" ƒ | j# |  j | | ƒ } | j$ ƒ  } x“ | d k r't% | d ƒ } | j- ƒ  } |  j j( | ƒ |  j j | t | d t d t d d d d | t. ƒ | j# |  j | | ƒ } | j$ ƒ  } q•W|  j j/ | ƒ d  S(   Niÿÿÿÿi   i   i    R    t   keyRh   R0   t   Hs    Hs   H t   infot   selection_protocolst   ORDERt   values	   /*/*/*/*:(0   RF   t   mmutt   first_nmr_modelt   molHndt   GetNumberOfModelst
   nmr_modelst   Nonet   GetModelt   chainst   peptidest   nucleicst   solvent_chainsR   R   t   nres_solventt   molecule_typet   chain_colourst   model_colourst   contains_hydrogent   alt_locst   lipidst   ca_onlyt   analyse_restypest   NewSelectiont
   newPPCAtomt   intpt   Selectt
   STYPE_ATOMt   ANY_RESt   SKEY_NEWt	   MODELINFOt	   get_namest
   name_labelRI   t   SKEY_CLRt   GetAtomSelIndexR‘   t	   getPCAtomt   rstript   GetElementNameRE   t   get_infot   has_keyt   itemst   add_infot	   GetAltLoct   SKEY_XORt   DeleteSelection(   R)   RF   R’   t   pMdlt   selmodelRM   t   hydHndt   hydSelt	   selindexpRT   t   nothert   pcatt   statust	   protocolst   selelet   orderRŒ   R‘   t   itemt   naltt   alt(    (    sF   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/python/ui/model_selection.pyt   analyse,  s¦    	 																 
		% #  
c         C   s>  |  j  j ƒ  } g  | j d ƒ D] } | j d ƒ r | ^ q } g  | j d ƒ D] } | j d ƒ rP | ^ qP } i  } xW | D]O } | j | d d !ƒ s® g  | | d d !<n  | | d d !j | d d !ƒ q~ Wd  } i  } xo | D]g } | j d ƒ r| t d ƒ t d ƒ d	 !} qä | rä | j d
 ƒ rä | t d
 ƒ j ƒ  | | <qä qä Wg  } xâ| j	 ƒ  D]Ô\ }	 }
 g  } x‡|
 D]} t | d d !j ƒ  ƒ d k rÝ| j d | d d | d d !j ƒ  d | d	  d ƒ n  t | d d !j ƒ  ƒ d k r<| j d | d d | d d !j ƒ  d | d d !d ƒ n  t | d d !j ƒ  ƒ d k r›| j d | d d | d d !j ƒ  d | d d !d ƒ n  t | d d !j ƒ  ƒ d k r{| j d | d d | d d !j ƒ  d | d d !d ƒ q{q{W| j |	 ƒ rb| j i |	 d  6| |	 d! 6| d" 6ƒ qbqbW| S(#   Ns   
s   SITE  s
   REMARK 800i   i   i   i>   s   REMARK 800 SITE_IDENTIFIER: i   s   REMARK 800 SITE_DESCRIPTION: i   i
   i    s   //t   /i   t   (t   )i   i   i   i   i    i   i   i   i%   i+   i&   i!   i$   t   namet   descriptiont	   selection(
   R”   t   SiteInfoRC   t
   startswithR¶   RE   R—   RA   RG   R·   (   R)   t   siteinfot   xR   t   remarkst   theSitest	   currentIDt	   siteDescst   newSitest   st   vt   selt   vv(    (    sF   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/python/ui/model_selection.pyt   getSitesSelectionª  s<    11# !=@@D-c   3      C   sÎ  d d  l  } d d  l } t ƒ  } t ƒ  } | j |  j |  j | ƒ } | j ƒ  |  _ |  j j ƒ  } t	 ƒ  } |  j j ƒ  } t
 ƒ  }	 t ƒ  j d d d |  j ƒ }
 t ƒ  j d d d |  j ƒ } t ƒ  j d d d |  j ƒ } t ƒ  j d d d |  j ƒ } t ƒ  j d d d |  j ƒ } g  |  _ g  |  _ g  |  _ d	 |  _ g  |  _ g  |  _ g  |  _ g  |  _ g  |  _ g  |  _ g  |  _ |  j ƒ  |  _ x6 |  j D]+ } x" | d
 D] } |  j j | ƒ q§Wq–WxB
t d	 |  j ƒ D].
} t | | ƒ } | j ƒ  } | j ƒ  } |  j j  | t! |  j | t" d t" d d d d d t# ƒ | j$ |  j | | ƒ }	 | j ƒ  } |  j j% | t! |  j | t" d t" d |
 d d d t& ƒ | j$ |  j | | ƒ }	 | | j ƒ  } |  j j  | t! |  j | t" d t" d | d d d t& ƒ | j$ |  j | | ƒ }	 | | | j ƒ  } |  j j  | t! |  j | t" d t" d | d d d t& ƒ | j$ |  j | | ƒ }	 | | | | j ƒ  } |  j j  | t! |  j | t" d t" d | d d d t& ƒ | j$ |  j | | ƒ }	 | | | | | j ƒ  } |  j j  | t! |  j | t" d t" d | | d d t& ƒ | j$ |  j | | ƒ }	 | | | | | | j ƒ  } | rÒt ƒ  j d d d |  j ƒ } | rÒ|  j j ƒ  } |  j j  | t! |  j | t" d t" d | d d d t& ƒ | j$ |  j | | ƒ }	 | j ƒ  } | r¼x¼ t d	 | ƒ D]¨ } t' |	 | ƒ } | j( ƒ  d k rt) j* | j+ d	 ƒ j, ƒ t) j* | j- ƒ  ƒ k r|  j j |  j j. | ƒ ƒ |  j j/ t) j* | j- ƒ  ƒ | j0 t1 ƒ | d } qqWn  |  j j2 | ƒ qÒn  t ƒ  j d d d |  j ƒ }  t ƒ  j d d d |  j ƒ }! |! r%|  d |! }  n  |  j j  | t! |  j | t" d t" d |  d d d t& ƒ | j$ |  j | | ƒ }	 | j ƒ  }" | | | |" }# |  j |# |  _ | d	 k rõ| |  j k rÐ|  j j | ƒ n  | |  j k rõ|  j j | ƒ qõn  | d	 k rH| |  j k r#|  j j | ƒ n  | |  j k rH|  j j | ƒ qHn  | d	 k r›| |  j k rv|  j j | ƒ n  | |  j k r›|  j j | ƒ q›n  | d	 k rî| |  j k rÉ|  j j | ƒ n  | |  j k rî|  j j | ƒ qîn  | d	 k rA| |  j k r|  j j | ƒ n  | |  j k rA|  j j | ƒ qAn  |# d	 k r”| |  j k ro|  j j | ƒ n  | |  j k r”|  j j | ƒ q”n  g  }$ |" d	 k rØd d  l3 }% d d  l  } xEt d	 |" ƒ D]1} t' |	 | ƒ } | j- ƒ  }& |  j j. | ƒ }' |  j j4 | ƒ }( t5 }) |& d k rC	|  j j6 | ƒ }) d G|) GHn  t5 }* | j7 | j8 | j9 g j: |( ƒ sp	|) r1
d G|' G| G| j; G|& | j< k GH| rÙ	| j; d	 k rÙ	|& | j< k rÙ	d G|' GH| j+ d	 ƒ }+ |+ j= }* n  |$ j: |& ƒ r
|* r
t ƒ  j> d d d |  j d |& ƒ n  |* rÕ|  j j |' ƒ qÕn¤| j? | j@ | jA g j: |( ƒ r‰
|$ j: |& ƒ sÕt ƒ  j> d d d |  j d |& ƒ qÕnL| jB | jC | jD g j: |( ƒ rá
|$ j: |& ƒ sÕt ƒ  j> d d d |  j d |& ƒ qÕnô | jE g j: |( ƒ r-|$ j: |& ƒ sÕt ƒ  j> d d d |  j d |& ƒ qÕn¨ | jF g j: |( ƒ ry|$ j: |& ƒ sÕt ƒ  j> d d d |  j d |& ƒ qÕn\ | jG g j: |( ƒ rÅ|$ j: |& ƒ sÕt ƒ  j> d d d |  j d |& ƒ qÕn |  j j |' ƒ |* sï|& d k rÎ|) rÎ|$ j |& ƒ qÎqÎWqØqØW|  j rd d  lH }, t ƒ  jI d |  j d d d d ƒ \ }- }. |. jJ d ƒ sli g  d 6|. d <n  xp |  j D]e }/ d d  l3 }% |% jK d d |% jK d d |/ ƒ ƒ }0 |. d d j: |0 ƒ sv|. d d j |0 ƒ qvqvWt ƒ  jL d |  j d d d d d |. d ƒ }1 n  tM |  j ƒ d	 k r¨|  jN j d ƒ |  j j  | tO d d t" d t" d |
 d d d t# ƒ | jP |  j | | ƒ } | j ƒ  }2 |2 d	 k r¨d |  _Q q¨n  tM |  j ƒ d	 k rÐ|  jN j d  ƒ n  tM |  j ƒ d	 k rø|  jN j d! ƒ n  tM |  j ƒ d	 k r |  jN j d" ƒ n  tM |  j ƒ d	 k rH|  jN j d# ƒ n  tM |  j ƒ d	 k rp|  jN j d$ ƒ n  tM |  j ƒ d	 k r˜|  jN j d% ƒ n  | r±|  j j2 | ƒ n  | rÊ|  j j2 | ƒ n  d  S(&   NiÿÿÿÿRŒ   R    R0   t   nucleic_acidR   t
   nucleotideR   i    RÐ   R    t	   conflictsi   R   R   t   ,t   ACEt   isNTermt   Checkings
   Checking 2t   new_nameRŽ   R�   t   monomerR�   s   \).*R#   s   .+\(R‘   t   PROTEINs   N,C,Ot   NUCLEICt
   SACCHARIDEt   NUCLEOTIDESt   METALt   MONOMERt   LIPID(R   R’   R�   R¨   t   GetChainTableR”   R“   R‘   t   nChainsR¦   R§   t   newPPCResidueR­   t   get_names_stringR¯   R™   R   R   R�   Rš   R›   Rœ   R£   t   saccharidest   nucleotidest   metalsRÞ   t   _sitesRE   RD   t
   getPCChaint
   GetChainIDt   GetNumberOfResiduesR©   t   STYPE_RESIDUER«   R¬   t   GetResidueSelIndext   SelectAminoNotHetRº   t   getPCResiduet   GetNumberOfAtomsRF   RG   t   GetAtomRÎ   t
   GetResNamet   AtomLabel_residue1t   SetCustomRestypet   RESTYPE_NONPOLYt   TrueR»   R>   t   GetRestypeCodet   Falset   isNTerminusBoundt   RESTYPE_PEPTIDEt   RESTYPE_DPEPTIDEt   RESTYPE_LPEPTIDERI   t   nAtomsR    t   Hett   add_namet   RESTYPE_NUCLt   RESTYPE_DNAt   RESTYPE_RNAt   RESTYPE_SACHt   RESTYPE_DSACHt   RESTYPE_LSACHt   RESTYPE_SOLVENTt   RESTYPE_SOLUTEt   RESTYPE_METALt   typesRµ   R¶   R?   R¸   RA   Rž   Rª   R±   R¤   (3   R)   R’   R�   Rð   RÀ   t
   chainTableR¾   R¿   t   resHndt   resSelR    R
   R   Rà   R   RÚ   t   rest   nt   pct   chainIDt   nrest   nrestott   nresaat   nresnat   nressact   nresntt   nresmetRá   t   tmpHndt
   nconflictst   irt   pcresR   R   t   nresligt   nressolt   novel_restypeR>   t   resnamet   residt   restypet
   isNTermACEt
   isAminoHett   atR  RÃ   t   sel_prott   mont   mon_typet   rett   nmainch(    (    sF   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/python/ui/model_selection.pyR¥   Ï  s�   															7 B(             '!$	%!(!((((	 $    R#   c         C   sG   d d d d d d d d d	 d
 d d g j  | ƒ rC t |  | d ƒ Sd  S(   NR–   R™   Rš   R›   Rœ   R   R   R�   Rž   R¡   R¢   R£   R#   (   RI   t   getattr(   R)   t   mode(    (    sF   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/python/ui/model_selection.pyR'   Ü  s    c         C   s|  | j  d ƒ s | d r g  Sd d  l } g  } |  j j ƒ  } t ƒ  } t ƒ  } x| d D]} |  j j | ƒ r… | j | ƒ q] | j	 d | ƒ } | r] | j
 ƒ  j d ƒ }	 |  j j | t d d t d t d |	 d d d t ƒ t j |  j | | ƒ } | j ƒ  }
 |
 d k rdxH t d |
 ƒ D]4 } t | | ƒ } |  j j | ƒ } | j | ƒ q&Wqdq] q] W|  j j | ƒ | S(   NR   iÿÿÿÿs   \(.*\)s   ()i   R    i    (   R¶   R>   R”   R¦   Rñ   R¨   R   RI   RE   t   searcht   groupRG   R©   Rú   R«   R¬   R’   Rû   R‘   RD   Rý   R  R»   (   R)   t   copy_from_paramsR>   t
   equiv_monst   selHndR  RÀ   RÇ   R,   R/  t   nrR(  R)  R.  (    (    sF   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/python/ui/model_selection.pyt   equivalent_monomersä  s2     		c         C   sG   g  } t  |  j ƒ d k rC x% |  j D] } | j d | ƒ q% Wn  | S(   Ni   s   //(   RA   Rš   RE   (   R)   t   mmt   pept(    (    sF   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/python/ui/model_selection.pyt   get_peptide_menu  s
    c         C   sG   g  } t  |  j ƒ d k rC x% |  j D] } | j d | ƒ q% Wn  | S(   Ni   s   //(   RA   R›   RE   (   R)   RA  t   nucl(    (    sF   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/python/ui/model_selection.pyt   get_nucleic_menu  s
    c         C   s   |  j  S(   N(   R   (   R)   (    (    sF   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/python/ui/model_selection.pyt   get_monomer_menu  s    c         C   sX  g  } g  } |  j  rj xl t |  j |  j  d ƒ D]4 } | j d t | ƒ ƒ | j d t | ƒ ƒ q/ Wn | j d ƒ | j d ƒ |  j j ƒ  } | j t g  ƒ rNx¦ t t	 t
 d ƒ ƒ D]‹ } |  j  d | } d t | ƒ d | d | d | d | d | d | d | d | } | j | ƒ | j d t | ƒ ƒ q¼ Wn  | | g S(	   Ni   RË   s   /1t   symopsR=   t   tran_at   tran_bt   tran_c(   R–   RD   R“   RE   t   strt   model_symmetryt   getSymmetrymatesR'   RG  RA   t	   symm_mate(   R)   t   menut   aliasRY   t
   symm_matest   modelt   mod(    (    sF   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/python/ui/model_selection.pyt   get_nmr_models_menu   s     	 Pc         C   s|  t  ƒ  j d | d |  j ƒ } | r( | Sd g j | ƒ d k r£ | d k r£ |  j r™ |  j d } x# |  j d D] } | d | } qp W|  j | ƒ d Sd  Sq£ n  d g j | ƒ d k r| d k r|  j r|  j d } x# |  j d D] } | d | } që W|  j | ƒ d Sd  Sqn  t |  d ƒ rx|  j	 j | ƒ rx|  j	 j
 | ƒ } |  j | j d	 k rx|  j | j Sn  d  S(
   NRP  R0   R   i    i   s    or R   t   objnamest   moldisp(   R­   Rg   R¯   RI   R   R/   R—   R   t   hasattrRU  t   indext   objinstst   object_typeRÐ   (   R)   RP  Rk   t   expnR4  RV   (    (    sF   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/python/ui/model_selection.pyRg   9  s2     	
	
!c         C   s:   t  ƒ  } t ƒ  } t j |  j | | ƒ } | j ƒ  } | S(   N(   R§   R¨   R’   R±   R”   R‘   (   R)   t   selhndt   selAtomsRÀ   t	   nselatoms(    (    sF   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/python/ui/model_selection.pyR  a  s
    		c         C   s:   t  ƒ  } t ƒ  } t j |  j | | ƒ } | j ƒ  } | S(   N(   Rñ   R¨   R’   Rû   R”   R‘   (   R)   R\  t   selResRÀ   t   nselres(    (    sF   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/python/ui/model_selection.pyt	   nResiduesl  s
    		i    c         C   s¹  d d l  m } g  } g  } d } | rE | j d ƒ | j d ƒ n  xU |  j d d ƒ D]A }	 | j |	 j ƒ sX | j |	 j j ƒ  ƒ | j |	 j ƒ qX qX W| r9x“ t d d ƒ D] }
 |
 |  k r³ |
 j	 d	 | ƒ \ } } x& | D] } | j |
 j d
 | ƒ qä Wx) | D] } | j |
 j d | ƒ qWq³ q³ Wn  | r¯t
 ƒ  j d |  j d d ƒ \ } } xI | j ƒ  D]8 } | j | ƒ sp| j | | ƒ ƒ | j | ƒ qpqpWn  | | f S(   Niÿÿÿÿ(   t   tclSafei    s	   All atomsR   RZ  t   MolDispt   MolDatat   excludeR=   t   #R0   RŽ   t   user_selection(   t   utilsRb  RE   t   get_dispobjRI   RÎ   t	   SelHandlet   getLabelt   get_dataobjt   get_selobj_menuR­   Rµ   R¯   t   keys(   R)   R   t   intermolt   user_definedRe  Rb  RA  t   aaRY   t   objt   molt   mmlistt   aalistRÇ   RÃ   Rg  RŒ   (    (    sF   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/python/ui/model_selection.pyRm  x  s6    &c         C   sü  | s
 d S|  j j | ƒ r� | s? d |  j |  j j | ƒ g S|  j |  j j | ƒ } | j ƒ  } | d k  rt d Sd | g Sn| d k rç | s� d d g S|  j d ƒ } | d d k rà | d d k rà | d } d | g Sd Snž t ƒ  j d |  j	 d d	 d
 | ƒ \ } } | r…| j
 | ƒ r…| s7d | g S|  j | | ƒ } | d d k r~| d d k r~| d } d | g Sd Sn  t j | d ƒ d k  r¡d Sd d l m } t j | d ƒ \ }	 }
 t |	 ƒ } | sßd S| d j |
 d | ƒ} | S(   s  
    Interpret the selection string returned from the GUI and
    return either: if return_selHnd=0 => [mode,selection_string]
    or if return_selHnd=0 => [mode,selHnd]
    The mode is 'MolDisp' or 'user' .  If it is user then the
    calling function should delete the selHnd 
    Rc  i    R   t   ALLi   t   userR0   RŽ   Rg  RŒ   Rf  iÿÿÿÿ(   t   moldatat   return_selHndN(   R—   RU  RI   RY  RX  t
   get_selHndt   parse_selectionR­   Rµ   R¯   R¶   RF   t   findRR  Rx  RC   Rl  t   interpret_selobj_alias(   R)   t	   selstringRy  t   dispobjR>  R-   RÃ   Rg  Rx  Rs  t   dispt   molobjR6  (    (    sF   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/python/ui/model_selection.pyR}  ™  sJ    
 
 


 

  c         C   sC   g  } x0 |  j  D]% } | j | k r | j | ƒ q q Wt | ƒ S(   N(   RY  t   selection_labelRE   RA   (   R)   t
   user_aliast   retobjRr  (    (    sF   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/python/ui/model_selection.pyt   if_user_alias_activeÔ  s
     c         C   sh   g  } xU |  j  d d ƒ D]A } | j d k r | j r | j d | k r | j | ƒ q q Wt | ƒ S(   NRZ  Rc  t   rulesi    (   Ri  t   colour_modet   user_schemeRE   RA   (   R)   t   user_colourR„  Rr  (    (    sF   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/python/ui/model_selection.pyt   if_user_colour_activeÞ  s
    +c         C   s˜   | s |  j  |  | ƒ } n  | s% d Sd d  l } | j d ƒ } x! t d d ƒ D] } d | | <qP W|  j j | | ƒ } | sƒ d St j | ƒ d Sd  S(   NR#   iÿÿÿÿi   i    i   (   t   interpretAtomIDt
   pygl_coordt   intaRD   R”   t   ListSecStructureRF   RC   (   R)   t   atomptrt	   atom_nameRŒ  t   maskRY   t   s0(    (    sF   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/python/ui/model_selection.pyt   getSSEé  s       iÿÿÿÿc         C   sâ   t  ƒ  } | d k r | } n4 | j j ƒ  } | j j | t | t ƒ } | rR d  St ƒ  } t j	 | j | | ƒ } | j
 ƒ  }	 |	 d k  r” d  }
 n+ | s§ |	 d k r¹ t | d ƒ }
 n d  }
 | d k  rÞ | j j | ƒ n  |
 S(   Ni    i   (   R¨   R”   R¦   R©   Rª   R¬   R—   R§   R’   R±   R‘   R²   R»   (   R)   Rs  R�  t   force_one_atomR>  RÀ   R\  R-   R]  R^  t   retval(    (    sF   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/python/ui/model_selection.pyR‹  ø  s$    		 		 c         C   sX   |  j  |  | ƒ } | s d S| j ƒ  d } | j d ƒ rT | d | j d ƒ !} n  | S(   NR#   i    t   [(   R‹  t	   GetAtomIDRI   RX  (   R)   R�  t   pAtomt   new(    (    sF   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/python/ui/model_selection.pyt   standardiseAtomID  s      c         C   sq  d  } |  j j ƒ  } |  j j | t | t ƒ } t ƒ  } | r„ | r„ d d  l } | j d d | ƒ } |  j j | t | t ƒ } n  | r™ d d  g }	 nÄ t	 ƒ  } t
 j |  j | | ƒ } | j ƒ  }
 |
 d k rá d d  g }	 n| |
 d k rH| d k r|
 t | d ƒ g }	 q]| d k r9|
 t | |
 d ƒ g }	 q]|
 d  g }	 n d t | d ƒ g }	 |  j j | ƒ |	 S(   Niÿÿÿÿs   \(.*\)R#   i    i   t   firstt   last(   R—   R”   R¦   R©   Rú   R¬   R¨   R>   R?   Rñ   R’   Rû   R‘   Rý   R»   (   R)   R�  R6  t   ignore_nameR_  R\  R-   RÀ   R>   R•  R`  (    (    sF   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/python/ui/model_selection.pyt   interpretResidueID!  s0    		c         C   s   d } d } d  } d  } g  }	 | rÖ | rÖ |  j | ƒ }
 t |
 ƒ d k rÍ t j |
 d d ƒ d k rÍ t j |
 d d ƒ } d |
 d d |
 d d | d } d |
 d d |
 d d | d } qÖ | } n  | rH|  j | d d d	 d ƒ\ } } | rH|  j s|  j j	 ƒ  r6t
 j d
 | ƒ r6d } qE| j ƒ  } qHn  | rr|  j | d d d	 d ƒ\ } } n  | rŠ| rŠd  d g S| sŸd  | g }	 n]| s´d  | g }	 nH| j ƒ  | j ƒ  k rÃ| rÃt | j ƒ  ƒ } | j ƒ  } | r| d | } n  t | j ƒ  ƒ } | j ƒ  } | r=| d | } n  | sU| j | j k rŒd  d t | ƒ d | j ƒ  d | d | g }	 qüd  d t | ƒ d | j ƒ  d | d | g }	 n9 | räd  d | d | g }	 n d  d | d | g }	 |	 S(   Ni    i   i   t   -RË   i   R6  R›  R�  s   /0Rœ  R#   t   .s	   range_cn R=   s   range (   R—   t   splitAtomIDRA   RF   R|  RC   Rž  R–   RL  t   get_symmetry_modelsR>   t   matcht   GetModelNumRø   RK  t	   GetSeqNumt
   GetInsCodeRX  (   R)   t   ranges_firstt   ranges_lastt
   keep_ordert   extendt
   nres_firstt	   nres_lastR›  Rœ  t   selit   split_idt	   split_rest   modelNumt   first_idt   inst   last_id(    (    sF   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/python/ui/model_selection.pyt   interpretRangesG  sZ    .&)	!	$
  44t   residuec         C   sÜ   d d  l  } | d k r d Sd d d d g } | j | ƒ sA | S| j | d ƒ } d	 } xE t d
 t | j | ƒ d t | ƒ ƒ ƒ D] } | d | | } q… Wd G| Gd G| GH| j | | ƒ d	 k rØ | d } n  | S(   NiÿÿÿÿR   s   /*/*/*.*/*:*RR  t   chainRµ  t   atomRË   R#   i   i   s   convertAtomID atomIDt   id(   RF   RI   RC   RD   t   minRX  RA   RG   (   R)   t   outt   atomIDRF   RÆ   t   ssR¸  R  (    (    sF   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/python/ui/model_selection.pyt   convertAtomID„  s      2 c   
      C   s@  d } d } d } d } d } d }	 | j  ƒ  } | rt j | d ƒ }	 t |	 ƒ d k rc | } q|	 d r¢ t |	 ƒ d k  r¢ |	 j d d ƒ |	 j d d ƒ n  t |	 ƒ d k rÁ |	 d } n  t |	 ƒ d k rà |	 d } n  t |	 ƒ d k rRt j |	 d	 d
 ƒ d } t t j |	 d	 d ƒ ƒ d k rR| t j |	 d	 d ƒ d } qRn  t |	 ƒ d	 k r|	 d j d ƒ rš|	 d j d ƒ d d !\ } } q| rt j t j |	 d d ƒ d d ƒ } t | ƒ d k rè| j d ƒ n  | | | d | d | g S|	 d } qn  | r,| | | | | g S| | | | g Sd  S(   NR#   RË   i   i    i   t   1i   i   i   R–  t   ]RŸ  RÌ   R   (   RG   RF   RC   RA   R^   RI   RE   (
   R)   R»  R¯  t	   res_rangeRR  R¶  R  t   res2R·  t   aid(    (    sF   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/python/ui/model_selection.pyR¡  ”  sD    	  "$#& c         C   s‰  | j  ƒ  } | s d } n  d t | j ƒ  ƒ d | d t | j ƒ  ƒ } | j ƒ  rp | d | j ƒ  } n  | sz | Sd } | j  ƒ  | j  ƒ  k r¹ | j ƒ  | j ƒ  k r¹ d } n  t | j ƒ  ƒ } | j ƒ  rî | d | j ƒ  } n  | j  ƒ  } | s	d } n  | r8d t | j ƒ  ƒ d | d | } n  | d | } | sud t | j ƒ  ƒ d | d | } n  | | | | g Sd S(   s”   
    Return text of form chain_id/first_res_id-last_res_id
    PCAtom first_atom,last_atom
    same_chain - flag if residues must be same chain
    R=   RË   R   i   i    RŸ  N(   Rø   RK  R¤  R¥  R¦  (   R)   t
   first_atomt	   last_atomt   chnidR›  t
   diff_chainRœ  RD   (    (    sF   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/python/ui/model_selection.pyt   getResidueIDÁ  s0     	2  	  	))c         C   s¨   t  |  j ƒ } | d k r" d g S|  j j ƒ  } t ƒ  } t ƒ  } x- |  j D]" } |  j j | t | j t	 ƒ qM Wt
 j |  j | | ƒ } | j ƒ  } | | | g Sd S(   sm   
    Return a mmdb selection containing all the atoms selected
    in the (possibly > 1) display objects
    i    N(   RA   RY  R”   R¦   R§   R¨   R©   Rª   R>  t   SKEY_ORR’   R±   R‘   (   R)   R.   t   allHndt   allSelRÀ   RÜ   t   nat(    (    sF   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/python/ui/model_selection.pyt   allselectedatomsá  s    		 i   c         C   sd  | rD t  d d |  d | ƒ} | j | ƒ r½ | j ƒ  d d g Sny | sc |  j j ƒ  } d | g S|  j | ƒ } | d d k r† | St  d d |  d | ƒ} | j | d | d | d	 ƒ | j ƒ  }	 |	 d d k rS| r| j ƒ  }
 | j	 ƒ  } d |
 | g }	 | j ƒ  ~ q`| r>d | j
 g }	 | j d ƒ ~ q`d | j
 | g }	 n | j ƒ  ~ |	 S(
   NR"   R#   R  i   s)   Can not interpret internal selection listi    i   i   i   (   R%   R0   R(   R”   R¦   R$   R&   t   applyt	   nSelAtomsR'   R>  (   R)   t   defnR*   t   testR(   R  R,   R>  R+   R-   t   naR2   (    (    sF   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/python/ui/model_selection.pyR{  ö  s:    



c         C   sk   | s d d g S|  j  j | d d t d t d d d d d | ƒ d } | d k r] d d g Sd | g Sd  S(   Ni   s   No selection handle providedi    R    s   Error selecting all atoms(   R”   t   SelectAtomsR«   (   R)   t   skeyR\  R-   (    (    sF   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/python/ui/model_selection.pyR|   3  s     

g        g      $@R·  c   
      C   sC  t  | ƒ } t  | ƒ } t  | ƒ } t  | ƒ } | s@ d d g S| d k rr |  j j | t | | | | | ƒ d  S|  j j ƒ  } | d k r² |  j j | t | | | | t ƒ nb | d k rã |  j j | t | | | | t ƒ n1 | d k r|  j j | t | | | | t ƒ n  |  j j	 | t | | ƒ }	 |  j j
 | ƒ |	 S(   Ni   s   No selection handle providedR·  Rµ  R¶  RR  (   t   floatR”   t   SelectSphereRª   R¦   Rú   R¬   t   STYPE_CHAINt   STYPE_MODELR©   R»   (
   R)   RÔ   t   yt   zt   rt   typeRÓ  R\  t	   tmpselHndR•  (    (    sF   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/python/ui/model_selection.pyR}   @  s&     
"%%%g      @R   c         K   s�  t  | d ƒ } t  | d ƒ } | r? t | ƒ r? t | ƒ }	 n |  }	 |	 j d | ƒ }
 |
 d re |
 S|
 d } t ƒ  } t ƒ  } t j |	 j | | ƒ } | j ƒ  } | d k rË |	 j j	 | ƒ d d g S|  j j
 ƒ  } |  j j | t | | | | t ƒ |	 j j	 | ƒ | d k r~|  j d | ƒ }
 |
 d rH|  j j	 | ƒ |
 S|
 d } |  j j | t | t ƒ |  j j	 | ƒ n  |  j j
 ƒ  } |  j j | t | t ƒ |  j j	 | ƒ |  j d d ƒ }
 |
 d sP|  j j
 ƒ  } |  j j | t |
 d t ƒ |  j j	 |
 d ƒ | r4|  j j | t | t ƒ qP|  j j | t | t ƒ n  |  j | d	 | ƒ} |  j j	 | ƒ |  j j	 | ƒ d | g S(
   Ng        g      .@R*   i    i   s-   No atoms selected for centre of neighbourhoodR   R   t	   allModels(   t	   safeFloatt   dataR{  R§   R¨   R’   R±   R”   R‘   R»   R¦   t   SelectNeighboursRª   R¬   R©   t   SKEY_ANDRú   R°   t   selection2RangeList(   R)   t   cidRR  t   maxdt   mindt	   qualifiert   invertRÝ  t   keywordst   dobjR-   t   central_selHndR]  RÀ   R^  t   neighb_selHndt   group_selHndt
   res_selHndt   pept_selHndt
   resID_list(    (    sF   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/python/ui/model_selection.pyt   selectNeighbRangesa  sV    
 
		



R   c         K   s9  d d l  } t | | j ƒ r' | } n | j d ƒ } |  j j ƒ  } x' | D] } |  j j | t | t ƒ qL W|  j	 d | ƒ } | d rŸ |  j j
 | ƒ | S| d }	 |  j j ƒ  }
 |  j j |
 t |	 t ƒ |  j j
 |	 ƒ |  j j |
 t | t ƒ |  j |
 d | ƒ} |  j j
 |
 ƒ |  j j
 | ƒ d | g S(   sL   
    Return a list of residue ranges that is the invert of the cid list
    iÿÿÿÿNRâ   R*   i    i   RÝ  (   R  t
   isinstancet   ListTypeRC   R”   R¦   R©   Rú   RÈ  R{  R»   R¬   R°   Râ  (   R)   Rã  Ræ  RÝ  Rè  R  t   cid_listR  R-   t
   allAtomHndt	   allResHndRï  (    (    sF   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/python/ui/model_selection.pyt   selectInvertRangesŸ  s(    	

c         C   sÕ  t  ƒ  } t ƒ  } t j |  j | | ƒ } | j ƒ  } g  } d } xŒ| | k  rÐt | | ƒ } | j ƒ  }	 d }
 x| |
 | k  r‡t | | |
 ƒ } | j ƒ  } | |	 k ró | j |  j	 | t | | |
 d ƒ d | ƒƒ | |
 } d }
 qu | j
 | j
 |
 k r|
 d }
 qu |
 d k rD| j |  j	 | d  d | ƒƒ n0 | j |  j	 | t | | |
 d ƒ d | ƒƒ | |
 } d }
 qu W| |
 | k rE | j |  j	 | t | | d ƒ d | ƒƒ d } qE qE W| S(   Ni    i   RÝ  i?B (   Rñ   R¨   R’   Rû   R”   R‘   Rý   Rø   RE   t   resRangeCidRX  R—   (   R)   Rí  RÝ  R_  RÀ   R`  Rï  R(  R)  RÅ  t   llt   pcres2t   chnid2(    (    sF   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/python/ui/model_selection.pyRâ  Ç  s8    		0
	"0

,c         C   sï   | j  ƒ  } | s d } n  | j ƒ  } | rD | d t | ƒ } n, d t | j ƒ  ƒ d | d t | ƒ } | j ƒ  r“ | d | j ƒ  } n  | rë | | k rë | j ƒ  } | d t | ƒ } | j ƒ  rë | d | j ƒ  } që n  | S(   NR=   RË   R   RŸ  (   Rø   R¥  RK  R¤  R¦  (   R)   R)  Rù  RÝ  RÅ  t   seqnumt   resID(    (    sF   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/python/ui/model_selection.pyR÷  ñ  s     	,  t   NONEg      .@c   *      C   sç  t  |	 ƒ }	 |	 rY |  j j d | d | d d ƒ } | d sY |  j j | d ƒ } qY n  d d d	 g } t t t g } t | d
 ƒ } t | d ƒ } | s¥ d d g Sg  } x4 t j	 | d ƒ D]  } | r¾ | j
 | d ƒ q¾ q¾ Wd } |  } d } d } d g } t ƒ  } d d g j | ƒ s | rzd d  l } | j d | ƒ } | rX| d } n  | j d ƒ rz| j d ƒ qzn  | j d | ƒ } | d rš| S| d } d } t ƒ  } t j | j | | ƒ } | j ƒ  } | d k r3| j j | ƒ d d g Sn3| r| r€d d  l } | j d | ƒ } | sBd d | d g S| d } | j | d d ƒ} | s¯d d | d | g Sn/ |  j | d d ƒ} | s©d d | g S|  } | d } | d d k rÒd } n  t ƒ  } t j | j | | ƒ } | j ƒ  } n1 | r)| d k r)| } | } |  } n
 d d g S| r—|
 d k r¨|  j d | d | j ƒ } | d rs| } q”| d } |  j j ƒ  } |  j j | t | t ƒ qö	| j |
 ƒ ru|  j d | d | j ƒ } | d rå| } q”| d } | | j |
 ƒ }  |  j j ƒ  }! |  j j |! |  | t ƒ |  j j ƒ  } |  j j | t |! t ƒ |  j j |! ƒ |  j j | ƒ qö	|  j j ƒ  }" |  j j ƒ  } |
 d k r®d  d! g }# n1 |
 d" k rÌd# d$ d% g }# n g  }# |# j
 |
 ƒ | j d& ƒ s|# j d# d$ g ƒ n  | j d' ƒ s#|# j
 d% ƒ n  x^|# D]V}$ |  j d |$ ƒ } | d rcd d( |$ d) g } q*| d }% |  j d* |% d | d | j ƒ }& |& d r§d d+ g } q*|& d }' |  j j |" t |' t ƒ |  j j |' t |" t ƒ |$ d! k r.| j d, ƒ r.|  j j |% ƒ |  j d d- ƒ } | d }% n  |  j j |' t |% t  ƒ |  j j | t |' t ƒ |  j j |% ƒ |  j j |' ƒ q*W|  j j |" ƒ n_|
 d k r×|  j j ƒ  } |  j j! | t | | | | t ƒ n| j |
 ƒ rŠ|  j j ƒ  }( | | j |
 ƒ }  |  j j! |( |  | | | | t ƒ |  j j ƒ  } |  j j | t |( t ƒ |  j j |( ƒ d } | d k rö	d d. | g } qö	nl|  j j ƒ  }" |  j j ƒ  }' |  j j ƒ  }) |  j j ƒ  } |  j j! |) t | | | | t ƒ |
 d k rd  d! g }# n' |
 d" k r!d# d$ d% g }# n	 |
 g }# | j d& ƒ sO|# j d# d$ g ƒ n  | j d' ƒ sn|# j
 d% ƒ n  x8|# D]0}$ |  j d |$ ƒ } | d rªd d/ |$ g } qu| d }% |  j j |' t |) t ƒ |  j j |' t |% t  ƒ |  j j |" t |' t ƒ |  j j |' t |" t ƒ |$ d! k rc	| j d, ƒ rc	|  j j |% ƒ |  j d d- ƒ } | d }% n  |  j j |' t |% t  ƒ |  j j | t |' t ƒ |  j j |% ƒ quW|  j j |" ƒ |  j j |) ƒ |  j j |' ƒ | d rö	d d0 | g } n  | d sy| ry| j d ƒ r8
| r8
|  j j | t | t" ƒ n  | j d' ƒ sV
| j d1 ƒ rï
| j d' ƒ rz
|  j d d% ƒ } n |  j d d2 ƒ } | d d k rà
| d d k rà
|  j j | t | d t" ƒ |  j j | d ƒ qï
d d3 g } n  | j d& ƒ rv|  j d d# ƒ } | d d k rd| d d k rd|  j j | t | d t" ƒ |  j j | d ƒ qsd d3 g } qvqyn  | d s«|  j j | t | | ƒ d | g } n  | rÄ| j j | ƒ n  | d k rã|  j j | ƒ n  | S(4   NRÐ   t   radiust	   xtl_limiti   i    i   Rµ  R¶  RR  g        g      .@s   No selection handle providedRâ   iÿÿÿÿRý  R#   RÎ   t   cR*   s-   No atoms selected for centre of neighbourhoods   Unable to find model s    for neighbourhoodRy  s    Unable to find selection object s
    in model Rw  s#   No CID or selection alias specifiedR·  t   other_selHndt	   other_molt	   main_sideR   R   t   solvent_monomersR   R   R   RÚ   t   ms   Error selecting t   atomst   self_selHnds   Error finding hydrogen bondst   as   CA+sides,   Error propagating selection to atoms around s   Error parsing s   Error selecting atoms around t   pR   s   Error excluding solvent(#   t   intRL  t   findSymmetryNeighbourst   buildSymmetryMatesRú   RÖ  R×  RÞ  RF   RC   RE   R¨   RI   t   dataobjRl  t   removeR{  R§   R’   R±   R”   R‘   R»   R}  t   selectHBondedR¦   R©   Rª   R¬   RX  RÈ  Rª  Rá  Rà  R°   (*   R)   Rã  RR  Rä  Rå  R7   t   selobj_aliast   selobj_modelt   hbondedt	   sym_matesR;  RÓ  t   sellistt   nsellistR\  R-   t   nBuiltt   stype_groupst   stypest	   excl_listRÇ   t	   iniselHndt
   iniMolDatat   del_iniselHndt   neighb_selhndR•  RÀ   R  R]  R^  RÜ   t	   hb_selhndt   stypet	   tmpselhndt
   res_selhndt
   alias_listRP  t   sele_selhndt   rv0t
   tmp_selhndRÜ  t   close_selhnd(    (    sF   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/python/ui/model_selection.pyR~     s„   !
 
 		  
 
	
  
 			

	

	
  

!

	  



  
  c   
      C   s  d } | d k  r d d g S| d k  ra |  j  d d ƒ } | d rN d d g S| d } d } n  d d  l } d d  l } | |  j k r¦ | j |  j | | | ƒ } n | j |  j | |  j | ƒ } t d ƒ j | j ƒ | j t	 ƒ | j
 j d ƒ }	 | r|  j j | ƒ n  ~ d |	 g S(	   Ni    i   s#   No selection given for H-bonding toR*   R   s5   Error in searching for HBonds (failed selecting self)iÿÿÿÿt   HBond_param(   R{  R’   t   HBondsR”   t   CHBondt   PMt   updatet	   SetParamst	   CalculateR  t   hbondst   GetSelectionR»   (
   R)   R  R  R  t   del_self_selHndR-   R’   R(  R)  t
   hb_selHnd1(    (    sF   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/python/ui/model_selection.pyR  .  s*    



	 R   t   0c         C   s  | s d d g S|  j  d d t | ƒ d ƒ } | d rL d d | d g S| d } t ƒ  } t ƒ  } t j |  j | | ƒ } | j ƒ  }	 |	 d k rË |  j j | t	 | | ƒ |  j j
 | ƒ d | g St | ƒ d k rÃ|  j j ƒ  }
 x¨t d |  j j ƒ  d ƒ D]Š} |  j j ƒ  } |  j j | t	 | d	 t d	 t d	 d
 d d	 d	 t ƒ |  j j | t	 | t ƒ |  j j | d d ƒ } | d k rj|  j j ƒ  } |  j j | t | t ƒ |  j j | t	 | t ƒ |  j j
 | ƒ | d k r|  j j | t	 d t ƒ qj| d k rj|  j  d | ƒ } | d sg|  j j | t	 | d t ƒ |  j j
 | d ƒ qgqjn  |  j j |
 t	 | t ƒ |  j j
 | ƒ q	W|  j j | t	 |
 | ƒ |  j j
 |
 ƒ n(|  j j | d d ƒ } | d k rÂ|  j j ƒ  } |  j j | t | t ƒ |  j j | t	 | t ƒ |  j j
 | ƒ | d k r`|  j j | t	 d t ƒ qÂ| d k rÂ|  j  d | ƒ } | d s¿|  j j | t	 | d t ƒ |  j j
 | d ƒ q¿qÂn  |  j j | t	 | | ƒ |  j j
 | ƒ |  j j
 | ƒ d | g S(   Ni   s   No selection handle providedR*   RË   s   /*/(CYS)/SG:*i    s   Failed trying to select /R2  R    t   CYSt   SGg      ð?gÍÌÌÌÌÌ@R·  R   s   /*/*/*.*/CB,SG:*Rµ  (   R{  RK  R¨   R§   R’   R±   R”   R‘   R©   Rª   R»   R¦   RD   R•   R«   R¬   Rá  t   FindCloseAtomPairsRú   RÈ  (   R)   RÓ  R\  R;  t	   nmr_modelR-   t   SGhndRÀ   R]  R^  t	   allSelHndRY   t   modelSelHndt   closeHndR  (    (    sF   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/python/ui/model_selection.pyR†   W  sl     
 
 
		
#4

g       @c
         K   sõ  | rs |  } | rF d d  l  } | j d | ƒ } | rF | d } qF n  | j d | ƒ } | d rf | S| d } nq | rÚ d d  l  } | j d | ƒ } | s¡ d S| j j | j ƒ } | d rÄ d S| d } | j } n
 d d g S| r|  j d | ƒ } | d r
| S| d } n* |  j d d ƒ } | d r7| S| d } |  j j | t | t	 ƒ |  j
 | ƒ } | d k rd d	 g Sd d  l } |  j j t d
 ƒ } | d k rÄ|  j j t d
 ƒ } n  |  j j t d ƒ } | d k rý|  j j t d ƒ } n  d d  l } | j |  j | | j | ƒ } | j | | ƒ | j ƒ  } | j j | ƒ |  j j | ƒ ~ | d k r”|  j j | t | |	 d | ƒ nW |  j j ƒ  } |  j j | t | |	 d t ƒ |  j j | t | | ƒ |  j j | ƒ d | g S(   NiÿÿÿÿRÎ   i    R*   i   iþÿÿÿs   No selection entereds   not solvents   No atoms selectedt   atom_contactt   residue_contactR·  g33333?�@(   R  Rl  R{  Ri  t   parentRÐ   R”   R©   Rª   R°   R  R’   t   GetUDDHandlet   UDR_ATOMt   RegisterUDRealt   UDR_RESIDUEt   CSASAreat   SetUDDt   Calculate_ContactR»   t	   SelectUDDR¦   Rú   R¬   (   R)   Rã  RR  R7   R  RÓ  R\  R;  t   self_cidt   min_areaRè  t   otherMolDataR  R-   t   otherSelHndt   selobjt   resultt
   selfSelHndt   natomsR’   t   udd_atomt   udd_resRB  R!  (    (    sF   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/python/ui/model_selection.pyR…   ©  sp     
  
 


 
 
 
  "c         C   sÜ  | s d d g S|  j  j ƒ  } |  j  j ƒ  } t ƒ  } t ƒ  j d d d |  j ƒ } |  j  j | t d d t d t d | d d d t	 ƒ t ƒ  j d d	 d |  j ƒ } |  j  j | t d d t d t d | d
 d d t
 ƒ t ƒ  j d d d |  j ƒ } |  j  j | t d d t d t d | d d d t
 ƒ |  j  j | t | t	 ƒ |  j  j | t d d t d t d d d d d t ƒ t ƒ  }	 t j |  j  | | ƒ }	 | j ƒ  }
 xT t d |
 ƒ D]C } t |	 | ƒ } | j d ƒ } |  j  j | | j | j t
 ƒ q·W| t k r“|  j  j ƒ  } |  j  j | t | t	 ƒ |  j  j | t | t	 ƒ |  j  j | t | t ƒ |  j  j | ƒ |  j  j | ƒ d | g } n5 |  j  j | t | | ƒ |  j  j | ƒ d | g } |  j  j | ƒ | S(   Ni   s   No selection handle providedRŒ   R    R0   i    R    t   CARß   t   C1R   t   O(   R”   R¦   R¨   R­   Rò   R¯   R©   Rª   R«   R¬   RÈ  Rú   Rº   Rñ   R’   Rû   R‘   RD   Rý   Rÿ   RÒ  t   serNumRá  R»   (   R)   R\  RÓ  t   oneHndR  RÀ   Rq  RÑ  t   solR_  t   nResR(  t   p_rest   p_atomR&  R•  (    (    sF   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/python/ui/model_selection.pyR   ö  sP     
	
	#c         C   sR   | s d d g S|  j  j ƒ  } |  j  j | t | | ƒ |  j  j | ƒ d | g S(   Ni   s   No selection handle providedi    (   R”   t   SelectChainTerminiR©   Rª   R»   (   R)   R\  RÓ  R&  (    (    sF   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/python/ui/model_selection.pyR€   @  s     
c         C   sÂ   | s d d g S|  j  j ƒ  } xm t d |  j  j ƒ  d ƒ D]O } |  j  j | ƒ j d d d ƒ } | r< |  j  j | | j | j t ƒ q< q< W|  j  j	 | t
 | | ƒ |  j  j | ƒ d | g S(   Ni   s   No selection handle providedi    (   R”   R¦   RD   R•   R˜   Rÿ   RÒ  RS  RÈ  R©   Rª   R»   (   R)   R\  RÓ  R&  R  t   atmptr(    (    sF   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/python/ui/model_selection.pyR‚   O  s     
#!&c         C   s¦   | s d d g S| r+ |  j  j | ƒ } n |  j  j d ƒ } t ƒ  } t ƒ  } t j |  j  | | ƒ } | j ƒ  } |  j  j | t | | ƒ |  j  j	 | ƒ d | g S(   Ni   s   No selection handle providediÿÿÿÿi    (
   R”   t   SelectSSETerminiR§   R¨   R’   R±   R‘   R©   Rª   R»   (   R)   R\  RÓ  R&  t   selAtomRÀ   t   nAtom(    (    sF   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/python/ui/model_selection.pyR�   ^  s     
		g      @c
         K   s0  | s d d g St  | ƒ } | rP | rP |  j d | d | d | d |	 ƒ } n  d d  l } t | | j ƒ rw | } n | j d ƒ } | rÎ |  j d | d t d | d |	 ƒ } | d	 r¾ | S| j | ƒ n  |  j j	 ƒ  } |  j j	 ƒ  } t
 ƒ  } t ƒ  } x“| D]‹} |  j j | t | t ƒ t j |  j | | ƒ } | j ƒ  } | d	 k r|  j j | t | t ƒ | r�t | d	 ƒ } | j d	 k rö| j j | j d ƒ } |  j j | | j ƒ  | j ƒ  | j ƒ  d
 | j ƒ  d
 d
 d d d
 t ƒ n  t | | d ƒ } | j d | j j ƒ  k  r�| j j | j d ƒ } |  j j | | j ƒ  | j ƒ  | j ƒ  d
 | j ƒ  d
 d
 d d
 d
 t ƒ q�q�qqW| rí|  j d | ƒ } | d	 sí|  j j | t | d t ƒ |  j j | d ƒ qín  |  j j | t | | ƒ |  j j | ƒ |  j j | ƒ d	 | g S(   Ni   s   No selection handle providedRã  Rä  Ræ  Rç  iÿÿÿÿRâ   i    R    s   CA,Ct   Cs   CA,NR*   (    R
  Rð  R  Rñ  Rò  RC   t
   neighb_radRª  R”   R¦   Rñ   R¨   R©   Rú   R¬   R’   Rû   R‘   Rª   RÈ  Rý   RX  R¶  t
   GetResidueRÒ  R¤  Rø   R¥  Rù   R{  Rá  R»   (   R)   Rã  R\  RÓ  Rª  Ræ  t
   neighb_cidt   neighb_cutofft   neighb_qualifiert   neighb_invertRè  t   neighb_listR  Ró  R-   t	   tmpResHndR&  R_  RÀ   R`  t   pRest   prevRest   nextRes(    (    sF   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/python/ui/model_selection.pyRƒ   t  sX     
'	$
		.8
c         C   s´  | r• d d l  } t | | j ƒ rV t d | ƒ } | sM d d t | ƒ g S| } n  | j j } t | d ƒ rƒ | j j	 ƒ  } q• | j
 j	 ƒ  } n  t ƒ  } t ƒ  }	 t j | | | ƒ }
 | j ƒ  } |  j j ƒ  } xŠ t | ƒ D]| } t |	 | ƒ } |  j j | | j ƒ  | j ƒ  | j ƒ  | j ƒ  | j ƒ  | j ƒ  | j ƒ  | j ƒ  d | j ƒ  t ƒ qä Wt ƒ  } t j |  j | | ƒ } | j ƒ  } |  j j | t | | ƒ d | g S(	   s  
    other_molHnd and other_selHnd or MMDBManager and selection handle for (probably)
    a different model. Find the atoms in this model which have the same
    names as those in the other model. This expects both structures to have the same sequence.
    iÿÿÿÿNRÎ   i   s"   Can not interpret other selection Rj  R    i    (   R  Rñ  t
   StringTypeRi  RK  R=  R”   RW  Rj  t	   getSelHndt
   SelHandle1R¨   R§   R’   R±   R‘   R¦   RD   R²   RÒ  R¤  Rø   R¥  R¦  R   t   GetAtomNameR¹   RÈ  R©   Rª   (   R)   t   other_DispObjt   other_molHndR  R\  RÓ  R  t   other_DispObj0RÀ   t   other_selAtomsR]  t   other_nAtomst   equiv_selHndRV   RÂ   t   equiv_selAtomst   equiv_nAtoms(    (    sF   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/python/ui/model_selection.pyR‡   Â  s4    
			$)	t   1_555c         K   s®   |  j  j d | d d ƒ } | d r. d } n
 | d } |  j j ƒ  } |  j j | t | d t d t d d d d d t ƒ |  j j | t | | ƒ |  j j | ƒ d | g S(   NR{   t   buildi    i'  i   R    (	   RL  t   symmetryMateModelNoR”   R¦   R©   Rª   R«   R¬   R»   (   R)   R{   R\  RÓ  t   kwR-   t   modelNot   symHnd(    (    sF   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/python/ui/model_selection.pyRˆ   ø  s    
	
c         C   s“   t  j | ƒ } x} | D]u } | r t j d d | ƒ } t j d d | ƒ } |  j d | d d ƒ } | d d k r‹ | d d k r‹ | Sq q Wd S(   Ns   ^"R#   s   "$R*   RÐ  i   i    (   RF   RC   R>   R?   R{  (   R)   t   lineRi   t   wordR-   (    (    sF   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/python/ui/model_selection.pyt   find_cid_in_line		  s     c         C   s­   | d d k r d } n | d d } | t  j | d d !ƒ } | d d k rf | d | d } n  | d t  j | d d	 !ƒ } | d	 d k r© | d
 | d	 } n  | S(   Ni   R=   R#   RË   i   i   R   i   i   t   :(   RF   RG   (   R)   R|  Rã  (    (    sF   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/python/ui/model_selection.pyt   pdbATOM2cid	  s    
	  (3   Rm   Rn   R‹   RÊ   RÞ   R¥   R'   R@  RC  RE  RF  RT  Rg   R  Ra  Rm  R}  R…  RŠ  R—   R“  R‹  Rš  Rž  R´  R½  R¡  RÇ  RÌ  R{  RÈ  R|   R}   R  Rð  Rö  Râ  R÷  R~   R  R†   R…   R   R€   R‚   R�   Rƒ   R‡   Rˆ   R~  R€  (    (    (    sF   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/python/ui/model_selection.pyRo     sr   		~	%	ÿ !								(		!;	
		&	<- 	= =(*ÿ ()RKJM	5R%   c           B   sÂ   e  Z d d d  d „ Z d „  Z d „  Z d d „ Z d „  Z d „  Z d „  Z	 d	 „  Z
 d
 „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d d „ Z d „  Z d „  Z d „  Z d „  Z RS(   R#   c         C   sU   | |  _  | |  _ | |  _ | |  _ d  |  _ d  |  _ g  |  _ d  |  _ d |  _	 d  S(   NR#   (
   RÎ   R=  Rs  R  R—   Rh   RW   t   childrenR>  t
   com_string(   R)   RÎ   R=  Rs  R  (    (    sF   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/python/ui/model_selection.pyR‹   7	  s    								c         C   sF  t  | ƒ d k  r d S| d |  _ |  j s< | d |  _ n|  j d k r— t |  j d |  j |  j d |  j ƒ} | j | d ƒ |  j j	 | ƒ n« t  | ƒ d k r>t |  j d |  j |  j d |  j ƒ} | j | d ƒ |  j j	 | ƒ t |  j d |  j |  j d |  j ƒ} | j | d ƒ |  j j	 | ƒ n d Sd S(   Ni   i    R8   t   _lR  i   t   _r(
   RA   RW   Rh   R%   RÎ   Rs  R  R0   R�  RE   (   R)   RÏ  t   clt   cr(    (    sF   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/python/ui/model_selection.pyR0   E	  s$    	(((c   
      C   s  t  | ƒ d k r# | d |  _ d Sx¯ | j d ƒ d k rÔ t  | ƒ } g  } x* | d | d !D] } | j | d ƒ q_ W| } | d | d !} t  | ƒ } | d | d !} t  | ƒ d k r& | d |  _ d Sq& Wt  | ƒ d } x: | | d k s| | d k r!| d k r!| d } qè W| | |  _ |  j d k r¥t |  j d |  j |  j d |  j ƒ} | j	 | d | d !| d | !| d | !ƒ |  j
 j | ƒ n  t |  j d |  j |  j d |  j ƒ}	 |	 j	 | | d | | d | | d ƒ |  j
 j |	 ƒ d S(   Ni   i    R8   Rƒ  R  R„  (   RA   Rh   RI   RE   RW   R%   RÎ   Rs  R  R&   R�  (
   R)   RM   RN   RO   R.   t   levst   levt   iopR…  R†  (    (    sF   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/python/ui/model_selection.pyR&   ]	  s6     /(,(+i    c         C   sa   |  j  r# | r# |  j |  j  ƒ n  x7 |  j D], } | sL | j  |  j  k r- | j ƒ  q- q- Wd  S(   N(   R>  t   delete_selhndR�  R(   (   R)   t   save_selHndt   child(    (    sF   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/python/ui/model_selection.pyR(   ˆ	  s
     c         C   s   x |  j  D]	 } ~ q
 Wd  S(   N(   R�  (   R)   RŒ  (    (    sF   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/python/ui/model_selection.pyt   __del__‘	  s    c         C   sP   |  j  d k r t S|  j  d k r& t S|  j  d k r9 t S|  j  d k rL t Sd  S(   NR4   R5   R6   R7   (   RW   Rá  RÈ  Rº   R°   (   R)   (    (    sF   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/python/ui/model_selection.pyRÓ  —	  s    c         C   sy  x1 |  j  D]& } | j r
 | j r
 | j ƒ  q
 q
 Wt |  j  ƒ d k rq |  j ƒ  |  _ |  j t |  j ƒ } | S|  j d k rû |  j  d j sÒ |  j ƒ  |  _ |  j t |  j  d j ƒ } | d d k rå | Sn |  j  d j |  _ |  j t	 d ƒ } | S|  j  d j r•|  j  d j r•|  j ƒ  |  _ |  j t |  j  d j ƒ } | d d k r\| S|  j |  j
 ƒ  |  j  d j ƒ } | d d k rl| Sn×|  j  d j r%|  j  d j r%|  j |  j
 ƒ  |  j  d j |  j  d j ƒ } |  j |  j  d j ƒ | d d k r| S|  j  d j |  _ nG|  j  d j r�|  j  d j |  _ |  j |  j
 ƒ  |  j  d j ƒ } | d d k rl| Snë |  j d k rÜ|  j  d j |  _ |  j |  j
 ƒ  |  j  d j ƒ } | d d k rl| Sn� |  j ƒ  |  _ |  j t |  j  d j ƒ } | d d k r| S|  j |  j
 ƒ  |  j |  j  d j ƒ |  j |  j  d j ƒ | d d k rl| Sd |  j g S(   Ni    R8   R   i   R7   (   R�  R>  RW   RÍ  RA   t
   new_selHndt	   interpretR¬   Rh   Rº   RÓ  t   merge_selectionRŠ  (   R)   RŒ  R-   (    (    sF   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/python/ui/model_selection.pyRÍ  ¤	  sf      "    " "  & c         C   s   |  j  j j ƒ  } | S(   N(   Rs  R”   R¦   (   R)   R>  (    (    sF   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/python/ui/model_selection.pyRŽ  ê	  s    c         B   s  | s d d g Se  j | ƒ d k r/ d d g Se | ƒ } e | ƒ d k rW d d g S|  j j | d ƒ } | r| e k r’ |  j |  j ƒ n  |  j j	 | ƒ } | d rÀ d d | d g S| e k rÜ | d |  _ n+ |  j
 | |  j | d ƒ |  j | d ƒ d |  j f Se e  j | d ƒ |  j j ƒ } | d d k rdd |  j j | d d d } xâ | d D]Ö } e j d | ƒ }	 e |	 ƒ d k r5e j d	 |	 d ƒ rÇe j d
 |	 d ƒ sóe j d |	 d ƒ re j d |	 d ƒ r| |	 d d |	 d d } qG| |	 d d |	 d d } qq| d	 | d } qqW| d e |  j ƒ d d e | ƒ d } e ƒ  rÝ| d  U| d d k rª| d |  _ | S| d d |  j j | d d d | d g Sqy] | d  U| d d k r	| d |  _ | S| d d |  j j | d d d | d g SWqd d |  j j | d d g SXn³e j d | ƒ rÏg  }
 | } xÉ| rMe j d | ƒ } | s±d d | g S| j ƒ  } e  j | d ƒ } e  j | d ƒ } |  j | ƒ } | r>d d d d d d d g j | d ƒ } | d k r5d } n  | } ni |  j | ƒ } | r™d d d d d d d g j | d ƒ } | d k r�d } n  | } n d d  | g SyH | d d! k rÉe | ƒ } n% | d d" k rîe e | ƒ ƒ } n  Wn d d# | g SX|
 j | d | d | | g ƒ | d$ rD| d | d$ } q…d } q…W|  j |
 ƒ } | d d k rÈ|  j
 | |  j | d ƒ } |  j | d ƒ | d d k r·d |  j g Sd d% | g Sq| SnH |  j j j |  j e | | ƒ } | d k r	| |  j g S| d& | g Sd  S('   Ni   s   No selectionR#   i    s    Error interpreting expansion of s   rv  = self.mol.RÌ   t   =s   's   '$s   "s   "$Râ   s   ='s   ',s   selhnd=s   skey=RÍ   s   Error interpreting command s   : s   [=><]s'   ([^=><]*)(==|!=|<=|>=|<|>)([^=><]*)(.*)s   Can not interpret i   s   ==s   !=s   <=t   <s   >=t   >i   s   No parameter recognised in RÔ  R
  s   Inappropriate parameter value i   s   Error merging s   Error applying selection CID (   RF   RG   t   splitWords0RA   Rs  Rg   R¬   RŠ  R>  R{  R�  t   matchKeywordt   lowerR‰   RŠ   R>   RC   R£  R:  RK  t	   DEVELOPERt   groupst   interpret_operator_paramRX  RÔ  R
  RE   t   apply_operatorsR”   R©   Rª   (   R)   RÓ  Rh   Ri   t	   expansionR-   Ry  t   cmdt   wt   wwt   sel_opsRT   R,   t   ttt   tt0t   tt2t   paramRW   R‘   t   rv_op(    (    sF   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/python/ui/model_selection.pyR�  ð	  s¸     
 
 
 
" ,,!!-	34$	( 		( 		!

!c         C   sñ   t  j d | ƒ } | s | S| j ƒ  } t | d ƒ } t | d ƒ } d d g j | d ƒ sž | d k  sž | |  j j j ƒ  k sž | d k  sž | d k r¢ | S|  j j j | d d	 | d ƒ } | d k  r× | Sd t	 | ƒ | d
 Sd  S(   Ns   (.*)(\d+)_(\d+)(.*)i   i   R#   RË   i    io   iç  t   _i   (
   R>   R£  R˜  R
  RI   Rs  RL  t   nofCrystalSymopst   getPendingSymmetryMateRK  (   R)   Rh   R  t   gpsRW   t   trant   imodel(    (    sF   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/python/ui/model_selection.pyt   interpretSymop{
  s     $%c      
   C   s¾   t  j | ƒ } xH d d d d d d d d d	 d
 g
 D]" } t j | | ƒ r4 | d g Sq4 Wx- d g D]" } t j | | ƒ rd | d g Sqd Wx- d g D]" } t j | | ƒ r” | d g Sq” Wg  S(   Nt   Bt   OCCt   CHARGEt   Xt   Yt   Zt   ATOM_SASt   RES_SASt   ATOM_BURIEDt
   RES_BURIEDRÔ  t   SERIALR
  t   SECRF   (   RF   t   upperR>   R£  (   R)   R   t   par(    (    sF   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/python/ui/model_selection.pyR™  ‘
  s       c         C   sá  d d  l  } d d  l } d d  l } d d  l } |  j j j ƒ  } t } xŒ| D]„} t j	 j
 | d ƒ so Pn  d d g j
 | d ƒ rž |  j j d d ƒ n  | j d | d ƒ r| j d | d ƒ rì |  j j j t d |  j ƒ }	 qÜ|  j j j t d	 |  j ƒ }	 nÎ | d d
 k rª|  j j j t d ƒ }	 |	 d k rÜt ƒ  }
 |
 j t ƒ |
 j t ƒ |
 j t ƒ | j |
 |  j j d ƒ |  j j j |
 ƒ }	 ~
 qÜn2 t j t j	 j | d ƒ } |  j j j | ƒ }	 |	 d k  r|  j j j | ƒ d d | d g S| d d k rÃ| j j } | j j  } d } | j
 | d ƒ rd| j | d ƒ } n) | j
 | d ƒ r�| j | d ƒ } n  | d k r´t! | ƒ } t! | ƒ } qcd } d } n | d d k râ| d d k rt! | d ƒ } t! | d ƒ } qc| d d k r3t! | d ƒ d } d } qc| d d k r\d } t! | d ƒ } qc| d d k r‰d } t! | d ƒ d } qc| d d k r²d } t! | d ƒ } qc| d d k rcd } t! | d ƒ d } qcn�| d d k rc| d d k rh| d d k r=t" | d ƒ d } t" | d ƒ d } q`t" | d ƒ d } t" | d ƒ d } qc| d d k r¼| d d k rŸt" | d ƒ d } n t" | d ƒ d } d } qc| d d k råd } t" | d ƒ } qc| d d k rd } t" | d ƒ } qc| d d k r7d } t" | d ƒ } qc| d d k rcd } t" | d ƒ } qcn  | j d | d ƒ s‰| d d k rõ|  j j j ƒ  } |  j j j# | t$ |	 | | t ƒ |  j j j% | t& | | ƒ |  j j j | ƒ d } n" |  j j j# | t& |	 | | | ƒ t' } | d d k rO | d d k rZt! | d ƒ d } d } nT | d d k r®| d d k r‘t" | d ƒ d } n t" | d ƒ d } d } n  |  j j j# | t& |	 | | t( ƒ qO qO Wd | g S(   Niÿÿÿÿi    R²  R³  t   reapplyt   BURIEDt   ATOMR;  R<  R¶  t
   atomSeriali   i   s   Error loading data R·  i   i   R
  i
úi   iÿàõi   RÔ  g        gq¬‹Ûh ð?g§èH.ÿï?gÍÌÌüÏcÁg33ÿ_ Âg33ÿ_ Bt   RES()   RR  R>   RF   Rh  Rs  R”   R¦   R¬   Rj  t   property_aliasRI   t   update_sasareaR:  R£  R>  R?  R  RA  t   Managert   SetFlagt   MMDBF_IgnoreRemarkst   MMDBF_IgnoreBlankLinest   MMDBF_IgnoreHasht   ReadCoorFilet   filenamet
   LoadSerialt   property_enumRX  t   LoadUDDDataR»   Rd  t   secstr_codet   secstr_aliasR
  RÔ  RE  Rú   R©   Rª   Rá  RÈ  (   R)   RŸ  RR  R>   RF   Rh  R>  RÓ  RW   t   uddt   serial_molHndt	   prop_enumt   sec_codet	   sec_aliasR¼  R¹  t   maxt	   resSelHnd(    (    sF   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/python/ui/model_selection.pyRš  Ÿ
  sÚ     ""					&			c         C   s&   |  j  j j | t | | ƒ d | g S(   Ni    (   Rs  R”   R©   Rª   (   R)   RÓ  t   selHnd1t   selHnd2(    (    sF   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/python/ui/model_selection.pyR�  +  s    c         C   s,   | d k r" |  j  j j | ƒ n  d } d  S(   Ni    iÿÿÿÿ(   Rs  R”   R»   (   R)   R>  (    (    sF   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/python/ui/model_selection.pyRŠ  4  s     c         C   sU   | s |  j  } n  t ƒ  } t ƒ  |  _ t j |  j j | | ƒ |  _ | j ƒ  } | S(   N(	   R>  R¨   R§   R]  R’   R±   Rs  R”   R‘   (   R)   R\  RÀ   R^  (    (    sF   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/python/ui/model_selection.pyRÎ  :  s     	c         C   sœ  x' |  j  D] } | j s
 | j ƒ  q
 q
 Wt |  j  ƒ d k rN |  j |  _ nA|  j d k r± t |  j  d j  ƒ d k r— d |  j  d j d |  _ q�d |  j  d j |  _ nÞ |  j  d j sÛ |  j  d j |  j k r |  j  d j d |  j d |  _ n& d |  j  d j d	 |  j d |  _ |  j  d j sP|  j  d j |  j k rm|  j |  j  d j |  _ n" |  j d
 |  j  d j d |  _ d |  j g S(   Ni    R8   i   s   not {R:   s   not R=   s    {s   } R9   (   R�  R‚  R1   RA   Rh   RW   (   R)   RŒ  (    (    sF   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/python/ui/model_selection.pyR1   H  s     	*%&*"c         C   sA   |  j  | ƒ } g  } x% | D] } | j | d j ƒ  ƒ q W| S(   Ni   (   t   search0RE   R'   (   R)   t   keywordt   hitst   hitdefnst   hit(    (    sF   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/python/ui/model_selection.pyR:  i  s
    c         C   s  t  |  j ƒ d k r8 |  j | k r1 d |  g g Sg  Sn  g  } x' |  j D] } | j | j | ƒ ƒ qH Wg  } t  | ƒ d k r|  j d k ré x | D]L } | d d k r¼ | j | ƒ q– | d d k r– | j d |  g ƒ q– q– Wqx( | D] } | j d | d g ƒ qð Wn  | S(   Ni    i   R4   i   (   RA   R�  Rh   Rª  RÖ  RW   RE   (   R)   R×  RØ  RŒ  t   newhitsRÚ  (    (    sF   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/python/ui/model_selection.pyRÖ  w  s$     c         C   sj   |  j  s d  |  j g S|  j  d k r< d |  j d j ƒ  g S|  j  |  j d j ƒ  |  j d j ƒ  g Sd  S(   NR8   i    i   (   RW   R—   Rh   R�  R'   (   R)   (    (    sF   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/python/ui/model_selection.pyR'   •  s
    	N(   Rm   Rn   R—   R‹   R0   R&   R(   R�  RÓ  RÍ  RŽ  R�  R«  R™  Rš  R�  RŠ  RÎ  R1   R:  RÖ  R'   (    (    (    sF   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/python/ui/model_selection.pyR%   2	  s&   		+				F		‹			Œ				!		c         C   s6   t  d d ƒ } | j |  ƒ | j ƒ  } | j ƒ  | S(   NR"   R#   (   R%   R0   R1   R(   (   R2   R,   R-   (    (    sF   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/python/ui/model_selection.pyR3   £  s
    
c         C   s†   t  ƒ  } | j |  ƒ } | d d k r2 d d g St d d ƒ } | j | d | d | d ƒ } | j ƒ  } | j ƒ  d | g Sd S(	   s@   
  Convert an input command string to a python list selection
  i    i   s   Error parsing commandR"   R#   i   i   N(   R!   R$   R%   R&   R'   R(   (   R*   t   parserR+   R,   R-   R.   (    (    sF   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/python/ui/model_selection.pyR/   ¬  s    	
!
Rj  c           B   sÀ  e  Z i1 d  d 6d d 6g  d 6g  d 6g  d 6d d 6d d	 6d d
 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6g  d  6g  d! 6g  d" 6g  d# 6g  d$ 6g  d% 6g  d& 6d d' 6d d( 6d d) 6d* d+ 6d d, 6d d- 6d d. 6d  d/ 6d d0 6g  d1 6d d2 6d d3 6d d4 6g  d5 6g  d6 6g  d7 6e d8 6d d9 6Z d: d; d< d= d> d? d@ dA dB dC dD g Z dE dF d< d= d> dG dG dH dH dI dJ g Z e j e j e j	 e j
 e j e j e j e j e j e j e j g Z dK dL dM dN dO dP dQ g Z dR dS dT dU dV dW dX g Z dY Z dZ d i  d d d[ „ Z d\ „  Z d d d] „ Z d d^ „ Z d d_ „ Z d d` „ Z i  d da „ Z db „  Z dc „  Z e d dd „ Z  de „  Z! e d df „ Z" e d dg „ Z# d  dh „ Z$ d  di „ Z% dj „  Z& dk „  Z' dl „  Z( d dm „ Z) dn „  Z* d do „ Z+ d dp d e dq „ Z, d dr „ Z- d ds „ Z. d dt d du „ Z/ d dp dv „ Z0 i  dw „ Z1 dx „  Z2 dy „  Z3 d dZ dz „ Z4 d d d{ „ Z5 RS(|   R   t   selecti    t   nothydrogent   restypest   elementtypesR–   R#   R{   t
   neighb_selt
   neighb_mols   4.0R_  Rµ  t   neighb_groupt	   neighb_hbi   t   neighb_exclt   neighb_excl_solventt   neighb_excl_monomert
   neighb_symt   neighb_selobjt
   buried_selR·  t   buried_groupt
   buried_molt   buried_and_selectiont   featurest   contact_selt   contact_molR4   t   property_joint   property_gt_opt   property_gt_valuet   propertyt   property_lt_opt   property_lt_valuet   secstrRv   t   ranges_extendt   ranges_qualifiert   ranges_invertg      @t   ranges_neighb_cutofft   ranges_neighb_modelt   ranges_neighb_selectiont   ranges_neighb_invertt   ranges_neighb_qualifiert   user_selR¢   t
   as_MolDispt   selection_schemet   atomtypeR™   R   R   t   use_all_modelsRã  R¬  R­  R¯  R°  R±  R²  R³  R´  Rµ  R·  R¶  t   Tempt   Occt   SASt   Buriedt   Secstrt   Serials   Disulphide bridgesR   R   R   s   Nucleic backbones   Nucleic sugar rings   Nucleic baseR	   R   R   R£   R   R   R   id   iÿÿÿÿc         C   sº   | |  _  | |  _ d |  _ | |  _ d |  _ g  |  _ d |  _ t j j	 |  ƒ | d k rq |  j
 | d d ƒn  i  |  _ |  j j t j ƒ |  j | d | ƒ| r¶ |  j | ƒ n  d  S(   Niÿÿÿÿi    R#   t   resetCommandt   dispobj_name(   t   moldata_namet   maintainHistoryR>  R  R   R*   t   labelR  t
   DependencyR‹   t	   setSelHndt	   selparamsR+  Rj  t   selection_initialisationt   setSaveParamst
   setCommand(   R)   R  R>  R*   R  R  t   history(    (    sF   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/python/ui/model_selection.pyR‹   
  s    							 	 c         C   sQ   |  j  d k r= t |  j ƒ } | r= | j j |  j  ƒ q= n  t j j |  ƒ d  S(   Ni    (   R>  Rß  R  R”   R»   R  R  t   delete(   R)   Rs  (    (    sF   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/python/ui/model_selection.pyR�     s
     c         C   sö   t  |  j ƒ } | d k  rL |  j d k r@ | j j |  j ƒ n  | |  _ nw | r• |  j d k  rv | j j ƒ  |  _ n  | j j |  j t | t ƒ n. |  j d k rº | j j |  j ƒ n  | |  _ | rå g  |  _	 |  j
 d d  ƒ n  |  j d ƒ d  S(   Ni    R   RÐ   (   Rß  R  R>  R”   R»   R¦   R©   Rª   R¬   R*   t	   setSameAsR—   t   update_dependents(   R)   R>  R  t   copyRx  (    (    sF   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/python/ui/model_selection.pyR  )  s        		c         C   s  d } g  |  _  t | t j ƒ rS | |  _  |  j | ƒ } | d s‚ | d } q‚ n/ |  j | ƒ } | d s‚ | d |  _  | } n  d |  j d <| |  j d <|  j | ƒ |  j rê | rê |  j	 |  j
 ƒ  d d g ƒ d |  _ d |  _ n  |  j d d	 d ƒd  S(
   NR#   i    i   Rã  RÝ  RÐ   R  iÿÿÿÿR  (   R*   Rñ  R  Rò  R3   R/   R  t   setLabelR   t   remove_dependencyt   get_same_as_SelHandleR  R  (   R)   R*   t   retain_sameAst   text_commandR-   (    (    sF   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/python/ui/model_selection.pyR  @  s&    		
 
		c         C   ss   t  j | ƒ } t j | d ƒ } | r3 | |  _ n< t | ƒ t j k rf | d t j d !d |  _ n	 | |  _ d  S(   NR#   i    i   s   ..(   RF   RG   t   SELECTION_LABELSR'   R  RA   Rj  t   maxLabelLength(   R)   R  t   labRP  (    (    sF   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/python/ui/model_selection.pyR  `  s    	c         C   sñ  | j  d ƒ r¯ t d ƒ } | r¯ t | d ƒ r¯ t | j ƒ r¯ | j ƒ  } | j  d ƒ r¬ | d } | r© t | d ƒ \ } } | d k r¦ d | d <| | d <q¦ q© q¬ q¯ n  t j  | j d d ƒ ƒ rß t | d | d <n  | j  d	 ƒ r;| d	 r.| j  d
 ƒ r8| d
 rd | d <q+d | d <q8q;d | d <n  | j d d ƒ d k ru| j d d ƒ su| | d <qun  | j  d ƒ spd } g  } d d d d d d d d g j | j d d ƒ ƒ r| j d g  ƒ rê| j d g  ƒ } q¡| j d g  ƒ r¡| j d g  ƒ } q¡n� d d g j | j d d ƒ ƒ r\| j d g  ƒ r\| j d g  ƒ } nE d g j | j d d ƒ ƒ r¡| j d g  ƒ r¡| j d g  ƒ } n  | rWd } x | D] }	 | |	 d } q´W| d d !} d d d d d d d d g j | j d d ƒ ƒ r!| d | d } n  | | d <d | d <d  d  l	 }
 |
 j
 | ƒ | d <qp| j d d ƒ | d <n  i  } x7 t j j ƒ  D]& } | j  | ƒ r†| | | | <q†q†W|  j | ƒ | j  d ƒ rí| d rí|  j d | d ƒ n  d  S(!   Nt   oldSelectiont   save_session_optionst	   getparamst   interpret_old_selectionsi    Rã  RÝ  R#   t   neighb_wholerest   neighb_excl_mainR   Rã  Rµ  R·  R   R*   R   R   s   CA+sideR   R   R   R   Rv   R™   R   R   t   strandss    or iüÿÿÿs    and iÿÿÿÿ(   R¶   R*  RW  t   callableR%  R3   t   REVISED_SELECTION_COMMANDSR'   RI   R  t   deepcopyRj  R  Rn  t   setSelParamsR  (   R)   t	   oldparamsR  t   pmt   session_paramst   useOldR-   R*   t   old_listt   rngR  t   paramsRŒ   (    (    sF   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/python/ui/model_selection.pyR  v  sl    $



3303

c         K   sÉ   d d  l  } | j | ƒ |  j r2 |  j d  ƒ n  |  j d | ƒ } | d sÅ x+ | d j ƒ  D] \ } } | |  j | <q_ W|  j d ƒ | rÅ |  j	 |  j
 |  j ƒ ƒ | d |  _ |  j ƒ  qÅ n  d  S(   NiÿÿÿÿR  i    i   RÐ   i   (   Rh  R+  R   R  R—   t   interpret_selectionR·   R  R  R  t   makeSelectionLabelR*   t   applyCommand(   R)   R  RÍ  Ry  Rh  R-   RŒ   R‘   (    (    sF   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/python/ui/model_selection.pyR-  Ö  s    	 
c   	      C   s·  d } |  j  r* |  j  |  j k r* d } np| d d k rC d } nW| d d k r | d rn d | d	 } qšd
 | d	 } n| d d k r  d | d } nú| d d k ræ t j j | d ƒ ræ t j t j j | d ƒ } n´| d d k rVt | d d ƒ | d d t j t j	 j | d d ƒ | d d t | d d ƒ } nD| d d k r·t
 | d ƒ d k r�| d d } n  x
| d d D] } | d | } qœWnã| d d k rt
 | j d g  ƒ ƒ d k r| d d } x¤| d d D] } | d | } qWn}d d d g j | d ƒ rO|  j | d ƒ } nK| d d k rl| d } n.| d d k r‰| d } nd g j | d ƒ rö| j d d ƒ rí| d d d } x- | d d D] } | d | } qÒWqšd  } n¤d! g j | d ƒ r]| j d! d ƒ rš| d! d d } x' | d! d D] } | d | } q?Wqšn=d" d# d$ d% d& d' d( d) d* d+ d, d- d. g j | d ƒ rš|  j | d ƒ } | j d' d ƒ r$d% d( g j | d ƒ rÞd } n
 | d } | | d' d } xš | d' d D] } | d | } q	Wqš| j d/ d ƒ ršd& g j | d ƒ rUd } n
 | d } | d/ d } x' | d/ d D] } | d | } q|Wqšn  | j d0 d ƒ rï| rïd1 | d0 d } x' | d0 d D] } | d | } qÔWn  | j d2 d ƒ r”t |  j ƒ j s7t
 t |  j ƒ j j ƒ  ƒ d k r”| s”d3 t j | d2 d d4 ƒ } x3 | d2 d D]  } | d t j | d4 ƒ } qjWq”n  | j d5 d ƒ r³d6 | } n  | S(7   NR#   s   Same as otherRÝ  t   clears   No atomsRq   Rä  s   HBond toRá  s	   Nhood of Rx   s
   Buried by Rê  Rî  Rô  Ró  i    Rò  Rõ  Rö  Rß  i   Râ   Rà  R   R   R   Rã  R  R   R=   R   Rv   R   R   R   R    R
   R™   R   t   traceR	   R   R   R   R   R)  R¢   s   Alt locsR–   t   ModelsRË   t	   notselects   Not (   R   R  Rj  t   features_aliasRI   t   features_menuRX  RK  t   property_shortR¿  RA   R'   t   commandToLabelRß  R  R–   RL  R¢  RF   RG   (	   R)   t   sel_outRP  t   rtt   etR4  t   chnRÇ   t   nmr(    (    sF   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/python/ui/model_selection.pyR6  î  sŽ    		
 H.	:	
	
H$c         C   sW   |  j  rS t d |  j  ƒ } | rS t | d ƒ r7 | j St | d ƒ rP | j SqS n  d  S(   NRÎ   Rj  Rl  (   R   Ri  RW  Rj  Rl  R—   (   R)   R  (    (    sF   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/python/ui/model_selection.pyR  J  s    	c         C   sb  | rd  } t | t j ƒ r' | } n$ t | t j ƒ rK t d | ƒ } n  | sq t | d ƒ pm t | d ƒ ru d  S|  j r¯ |  j	 |  j
 ƒ  d d g ƒ d |  _ d |  _ n  | j |  j k rÍ d |  _ n	 d |  _ | j |  _ |  j |  j
 ƒ  d d g |  j |  j g ƒ |  j ƒ  n: |  j rT|  j	 |  j
 ƒ  d d g ƒ d |  _ d |  _ n  |  j ƒ  d  S(   NRÎ   Rj  Rl  RÐ   R  R#   s   Same as other(   R—   Rñ  R  t   DispObjR  Rj  Ri  RW  R   R  R  R  RÎ   R  t   add_dependencyt   selectSameAst   updateSameAsR7  (   R)   R   R  R  (    (    sF   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/python/ui/model_selection.pyR  V  s.    	&			+		c         C   s   t  |  d d ƒ S(   NR   i    (   R8  (   R)   (    (    sF   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/python/ui/model_selection.pyt	   getSameAs|  s    c         C   s#  |  j  ƒ  } | s d S| j d d ƒ |  j k r5 d  S|  j j | j ƒ  ƒ | j d d ƒ |  _ |  j d d d ƒ|  j |  j ƒ |  _ |  j	 rt
 d |  j	 ƒ j ƒ  t ƒ  s´ d  St ƒ  j d |  j	 ƒ } | rt
 | j ƒ  ƒ } | sû t | d ƒ rÿ d  S| j d	 ƒ | j d
 ƒ qn  d  S(   NR#   t   internali   iÿÿÿÿR  i    RÎ   t
   SelHandle2t
   selection1t
   selection2(   R  t
   getCommandR*   R  R+  t   getSelParamsR  R6  R  R  Ri  t   set_reapply_selectiont   DISPLAYTABLEt
   getDispObjt
   objectNameRW  t   updateLabel(   R)   t   mastert	   attributet   same_as_selt   gobjt   target(    (    sF   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/python/ui/model_selection.pyRG  ‚  s(      		 c         C   s#   | d k r |  j  d d  ƒ n  d  S(   NR  R   (   R  R—   (   R)   RU  RV  (    (    sF   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/python/ui/model_selection.pyRH  œ  s    c         C   s�   i  } x€ t  j j ƒ  D]o \ } } t | t j ƒ ro g  | | <xD |  j j | ƒ D] } | | j | ƒ qQ Wq |  j j | ƒ | | <q W| S(   N(	   Rj  R  R·   Rñ  R  Rò  R  R'   RE   (   R)   R   t   parsRŒ   R‘   RÇ   (    (    sF   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/python/ui/model_selection.pyRO  ¢  s    
c         C   s­   i  } x€ t  j j ƒ  D]o \ } } t | t j ƒ ro g  | | <xD |  j j | ƒ D] } | | j | ƒ qQ Wq |  j j | ƒ | | <q W|  j	 ƒ  | d <|  j
 ƒ  | d <| S(   NR*   R   (   Rj  R  R·   Rñ  R  Rò  R  R'   RE   RN  RI  (   R)   R   R4  RŒ   R‘   RÇ   (    (    sF   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/python/ui/model_selection.pyt   getSaveParams²  s    
c         C   s   |  j  S(   N(   R  (   R)   (    (    sF   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/python/ui/model_selection.pyt
   getMolDataÇ  s    c         C   s   t  |  j ƒ j S(   N(   Rß  R  R”   (   R)   (    (    sF   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/python/ui/model_selection.pyt	   getMolHndÌ  s    c         C   s=   |  j  r |  j  S|  j r5 |  j |  j ƒ \ } } | Sd Sd  S(   NR#   (   R  R*   R3   (   R)   R-   t   com(    (    sF   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/python/ui/model_selection.pyRk  Ñ  s    		 c         C   s)   |  j  d k r" |  j d | ƒ n  |  j  S(   Niÿÿÿÿt   always(   R>  R7  (   R)   R_  (    (    sF   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/python/ui/model_selection.pyRk  â  s     c         C   sN   |  j  d k r |  j ƒ  n  |  j  d k  r/ d St |  j ƒ j |  j  ƒ } | S(   Niÿÿÿÿi    (   R>  R7  Rß  R  R  (   R)   RË  (    (    sF   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/python/ui/model_selection.pyt   getNofAtomsë  s      c         C   s‘   |  j  r' t |  j ƒ j |  j  ƒ } n d } | d rl | r\ t |  j ƒ j j ƒ  |  _ d Sd |  _ d Sn! |  j | d d d d d ƒd Sd  S(   Ni   s
   No commandi    iþÿÿÿR  R  (   i   s
   No command(   R*   Rß  R  R{  R”   R¦   R>  R  (   R)   R_  R-   (    (    sF   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/python/ui/model_selection.pyR7  ô  s    	
	R™  c         C   sý   g  } | r^ t  | t j ƒ rU |  j | ƒ \ } } | r= d S| r[ d | g } q[ qy | } n | ry | j d d ƒ } n  | sƒ d  S| d k s³ d d  d  d g g  g j |  j ƒ rÃ |  j | ƒ n |  j | |  j | g ƒ |  j	 |  j
 |  j ƒ d ƒ d  S(   Ni   R8   RJ  R™  R#   (   Rñ  R  Rj  R/   RN  R—   RI   R*   R  R  R3   (   R)   R*   RW   t   notopRj  R^  R-   (    (    sF   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/python/ui/model_selection.pyt   mergeSelection  s"      	0c         C   sD   | r |  j  S|  j  s d S|  j |  j  ƒ \ } } | s< | Sd Sd  S(   NR#   (   R*   R3   (   R)   RJ  R-   R^  (    (    sF   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/python/ui/model_selection.pyRN  "  s    	c         C   s‡   |  j  d k r" |  j d | ƒ n  |  j  d k  r; d d g St ƒ  } t ƒ  } t j t |  j ƒ j |  j  | ƒ } | j	 ƒ  } | | f S(   NiÿÿÿÿR_  i    s   No selection(
   R>  R7  R§   R¨   R’   R±   Rß  R  R”   R‘   (   R)   R_  R]  RÀ   R^  (    (    sF   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/python/ui/model_selection.pyt   getSelIndex0  s      
		$t   thisc   	   	   C   sï   |  j  s d S| s d Sd d  l } | j | ƒ } | d k rJ |  j } n  t ƒ  j d | d d d | d |  j  ƒ } | së | j t j |  j	 ƒ \ } } } t ƒ  j d | d d d | d | ƒ t ƒ  j
 d |  j d	 t |  j ƒ j ƒ n  d  S(
   NiÿÿÿÿRd  R0   RŽ   Rg  RŒ   R‘   t   user_selparamsRÇ  (   R*   Rh  t   oneWordR  R­   R¸   t
   dict_diffsRj  R  R  t   saveRß  RÇ  (	   R)   RÎ   t	   save_modet	   overwriteRh  RÃ   R-   t   diffst   undiffs(    (    sF   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/python/ui/model_selection.pyt   saveSelectionA  s    	   !c      	   C   s¬   t  ƒ  j d |  j d g d d d | d d ƒ \ } } | j | g  ƒ } | sU | rv t ƒ  j d | d	 d
 d ƒn2 |  j d | d | ƒ | d k r¨ |  j | ƒ n  d  S(   NR0   t   genericRŽ   Rg  RŒ   R›  i   s
   Selection s    not recognisedR=  t   DisplayTableR*   RW   R™  (   R­   Rµ   R  R'   t   MGGUIt   WarningMessageRb  R  (   R)   RÎ   RW   R•  Rg  R*   (    (    sF   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/python/ui/model_selection.pyt   restoreSelectionV  s    
 c   #      K   sÖ  d d  l  } | j | ƒ i  } x' t j j ƒ  D] \ } } | | | <q/ W| j | ƒ g  } d } | d d k r� d  d g } nÊ	| d d k rÃ| d d k r® | d } n  | d rW| d	 rØ t d
 | d	 ƒ }	 n t |  j ƒ }	 |	 sô d g S|	 d }	 |	 j d | d d d ƒ }
 |
 d d k r7| d } q�|
 d d k r�| d } q�nF | d r“t	 |  j ƒ j
 | d ƒ } | s�| d } q�n
 | d } | d r| rt j | d d ƒ } t | ƒ d k ròd | d d | d } q=d | d } n: d t j | d ƒ d } | d	 r=| d | d	 } n  | d t | d ƒ } | d | d } | d rŒ| d t | d ƒ } n  | d  r±| d! t | d  ƒ } n  d } | j d" d ƒ rÖ| d# } n  | j d$ d ƒ rõ| d% } n  | j d& d ƒ r| d' } n  | j d( d ƒ r3| d) } n  | j d* d ƒ rR| d+ } n  | rm| d, | d } n  d  | g } | j d- d ƒ rK
| j d. d ƒ rK
d/ | |  j | d. ƒ d g } qK
nˆ| d d0 k rüt j j | d0 ƒ rüd  | d0 g } nO| d d1 k r | j d2 d ƒ rç| j d3 d ƒ rt d
 | d3 ƒ }	 |	 sPd g S|	 d }	 |	 t	 |  j ƒ k rŽd | d3 <qŽn t	 |  j ƒ }	 |	 j d | d2 d d ƒ }
 |
 d d k rÇ| d4 } q5|
 d d k r5| d5 } q5nN | j d6 d ƒ r+t	 |  j ƒ j
 | d6 ƒ } | s5| d7 } q5n
 | d8 } | j d6 d ƒ r�t j | d6 d ƒ } t | ƒ d k rŒd9 | d d | d } qßd9 | d6 } nB d: t j | d2 ƒ d } | j d3 d ƒ rß| d | d3 } n  | d; | j d< d ƒ d= | j d> d? ƒ d } d  | g } n+| d d@ k ryxt d t | j d@ g  ƒ ƒ ƒ D] } d } d } | dA | rÏ| dB | s”| dB | dC k rÏ| t | dB | ƒ dD | dA | dD | d@ | } n dD | d@ | } | dE | rD| dF | s| dF | dC k rD| | dD | dE | dD t | dF | ƒ } n  | rf| dG | d  | g g } qRd  | g } qRWnÒ| d dH k rüt | j dH g  ƒ ƒ d k rK
dI | dH d } x$ | dH d D] } | dJ | } qÈW| dK } d  | g } qK
nO| d dL k r|t | j dL g  ƒ ƒ d k r|dM | dL d } x$ | dL d D] } | dJ | } qKW| dN } d  | g } nÏdO dP dQ dR dS dT g j | d ƒ rÀd d  l } d  | d g } n‹| d dU k r	|  j | dU ƒ \ } } | röd g Sd | | g SnE| d dV k rK
t ƒ  j dW |  j dX g dY dZ d[ | dV d\ d ƒ \ } } | s]	| r÷	| dU r÷	|  j | dU ƒ \ }
 } |
 sô	t ƒ  j dW |  j dY dZ d[ | dV d] | ƒ } t ƒ  j dW |  j dX g dY dZ d[ | dV d\ d ƒ \ } } qô	q÷	n  | s
| j | dV ƒ r:
t ƒ  j d^ | dV d_ d` da ƒd g S| | dV } n  db g j | d ƒ rå
| j db d ƒ rÖ
d  | db d g } x+ | db d D] } dc | d  | g g } q–
W| rÍ
dc | | g } qâ
| } qå
d  db g } n  dd g j | d ƒ r| j dd d ƒ rpd  | dd d g } x+ | dd d D] } dc | d  | g g } q0W| rgdc | | g } q|| } qød  dd g } nyde df dg dh di dj dk dl dm dn do dp g j | d ƒ r|dk dq dl g j | d ƒ såd  | d g } n  | j dk d ƒ rbd  | dk d dr g } x/ | dk d D] } dc | d  | dr g g } qW| rYd/ | | g } qy| } qø| j ds d ƒ rÐd  | ds d dr g } x/ | ds d D] } dc | d  | dr g g } q›Wd/ | | g } qø| j dt d ƒ rø| d du k rød  | dt d j dv ƒ j dw ƒ g } x= | dt d D]- } dc | d  | j dv ƒ j dw ƒ g g } q'W| rpd/ | | g } qy| } qøn|| j d d ƒ dq k rø| j dq g  ƒ s¸| j dx g  ƒ rød  } | dq rŒ| dx rŒt	 |  j ƒ j dU | dx dy | j dz d ƒ d{ | j d| d} ƒ d~ | j d dO ƒ d€ | j d� d ƒ d‚ | j dƒ t ƒ ƒ }
 |
 d s2g  | dq <x& |
 d D] } | dq j | ƒ qkWq2n¦ | dq r2| j d„ d ƒ r2t	 |  j ƒ j  dU | dq d… de d‚ | j dƒ t ƒ ƒ }
 d† G|
 GH|
 d s2g  | dq <x# |
 d D] } | dq j | ƒ qWd | d„ <q2n  | dq rŽd‡ | dq d j ƒ  } x* | dq d D] } | dJ | j ƒ  } qcW| d } n  | rø| dˆ t | j d‰ d ƒ ƒ dŠ | j d‹ dO ƒ } | ræd/ | d  | g g } qõd  | g } qøn  | j dŒ d ƒ r"| r"d� | g } q"n  | j dQ d ƒ r¥| sM| d  d g k rkdc d  dQ g d  dŽ g g } q¥| d d k r¥dc | dc d  dQ g d  dŽ g g g } q¥n  | j d� d ƒ rØ| rØd� | d  d‘ g g } qØn  | j d’ d ƒ rÚ| d’ d d“ k rd  d” g } d• } n& d  d” | d’ d g } | d’ d } xk | d’ d D][ } | d“ k r|dc | d  d” g g } | d– } qHdc | d  d” | g g } | dJ | } qHW| rÑ| d  dO g k rÑd/ | | g } qÚ| } n  | j d— d ƒ rÉt	 |  j ƒ j! s"t t	 |  j ƒ j" j# ƒ  ƒ d k rÉ| d— d }  t j |  d˜ ƒ }! d  | d— d g }" x= | d— d D]- }  dc |" d  |  g g }" t j |  d˜ ƒ }! qeW| rÀ| d  dO g k rÀd/ | |" g } qÉ|" } n  d | | g S(™   NiÿÿÿÿR#   RÝ  R8  Rq   R_  s   Neighbourhood radius undefined
Rá  Râ  RÎ   i   i    R*   RÐ  s(   Neighbourhood selection uninterpretable
s'   Neighbourhood selection finds no atoms
Ré  s0   Neighbourhood selection alias not interpretable
s$   Neighbourhood selection not defined
Rf  i   s   neighb selobj_alias=s    selobj_model=s   neighb cid="t   "s    model=s    maxd=s    group=Rã  Rä  s	    hbonded=Rè  s    sym_mates=Rå  s   ,centralRæ  s   ,solventRç  s   ,monomert   neighb_excl_sites   ,sitet   neighb_excl_peptides   ,peptides    excl=t
   neighb_andt   neighb_and_selectionR4   Rî  Rx   Rê  Rì  s&   Buried area selection uninterpretable
s%   Buried area selection finds no atoms
t   buried_selobjs.   Buried area selection alias not interpretable
s"   Buried area selection not defined
s   buried selobj_alias=s   buried cid="s    self_cid="Rí  s	   " group="Rë  R·  Rô  Rò  Ró  g        R=   Rõ  Rö  Rñ  Rß  s   /*/*/(Râ   s   )/*:*Rà  s	   /*/*/*/*[s   ]:*R   R   R   R   Rà   R   Rã  R  R0   Rn  RŽ   Rg  RŒ   R›  R‘   s
   Selection s    not recognisedR=  Ro  R   R5   R   R   R   R   R   R    R
   R™   R9  R	   R   R   R   Rv   s   /*.*/*:*R)  R÷  R   s   H s   S Rý  RR  Rü  Rä  Rû  g      @R;  Rÿ  Rç  Rþ  RÝ  R  Rú  Ræ  s,   interpret_selection after selectInvertRangess   ranges cid="s    extend=Rø  s    qualifier=Rù  R;  R8   R   RÞ  R7   s   /*/*/*,*/*[H]:*R¢   t   no_alts	   /*/*/*/*:R—   s   ,NoneR–   RË   ($   RR  R+  Rj  R  R·   R—   Rl  R  R{  Rß  R}  RF   RC   RA   RG   RK  R'   R/   R<  RI   RD   R�   R­   Rµ   R¸   R¶   Rp  Rq  t   lstripRð  R  RE   Rö  R–   RL  R¢  (#   R)   R  Rè  RR  R@  RŒ   R‘   RÜ   t   warningt   data_objR-   t	   selobj_rvt   selot   sel0t   n_exclRY   t   sel1RÇ   R�   RÃ   R•  Rg  t   monselR4  t   chnselRC  t   sect   comdt   selet   altselt   alRÉ   RD  t	   nmr_splitt   nmrsel(    (    sF   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/python/ui/model_selection.pyR5  f  sô   

 




 

      $& 
	
	 2(";"3 
. 
% 
(		7		"&+<y

 7	

 
 4 * 		H	c         C   s   t  j | d ƒ S(   s•  
    sel_menu = ['All','All peptide','All peptide','Main chain','CA trace','Side chains',
                     'No peptide','All nucleic acid','No nucleic acid','Monomers' ,'Trace']
    sel_command = ['all','amino_acid','peptide','main','catrace','side',                  'nopeptide','nucleic','nonucleic','monomers' , 'trace']
      return sel_menu[sel_command.index(item)]
    else:
      return ''
    R#   (   R   R'   (   R)   RÇ   (    (    sF   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/python/ui/model_selection.pyR?  ä  s    c         C   s   d  S(   N(    (   R)   (    (    sF   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/python/ui/model_selection.pyt
   popHistoryò  s    c         C   sµ   |  j  d k  r |  j ƒ  n  |  j  d k  r5 d d g St |  j ƒ } | rŠ | j rŠ | j j |  j  d d t d t d d d d d t ƒ n  | d k r± | j j	 |  j  | ƒ } n  d  S(   Ni    iÿÿÿÿs   No selectionR    R�   (
   R>  R7  Rß  R  R¡   R”   RÒ  R«   R°   t   ExcludeOverlappedAtoms(   R)   t	   hydrogenst   closeRx  t	   nexcluded(    (    sF   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/python/ui/model_selection.pyt   cleanSelectionø  s      
!c   
      C   s³  |  j  d k  r |  j ƒ  n  |  j  d k  r5 d d g Sd } t |  j ƒ } | j sW d St ƒ  } | rEg  } | j j ƒ  } t ƒ  } x› | j D]� }	 | j j	 | t
 d d t d t d d d d |	 t ƒ | j j	 | t
 |  j  t ƒ t j | j | | ƒ } | j ƒ  d k rŽ | j |	 ƒ qŽ qŽ W| j j | ƒ t | ƒ | } n	 | j } t | ƒ | k r¯xL | | D]= }	 | j j	 |  j  t
 d d t d t d d d d |	 t ƒ qkWn  | S(   Ni    iÿÿÿÿs   No selectionR    (   R>  R7  Rß  R  R¢   R¨   R”   R¦   R§   R©   Rª   R«   R¬   Rá  R’   R±   R‘   RE   R»   RA   R°   (
   R)   t   allowRÐ  R-   Rx  RÀ   t   selected_altst   altHndt   altSelRÉ   (    (    sF   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/python/ui/model_selection.pyt   cleanAltLocs  s8      
	 		 	&(6   Rm   Rn   R  R  R¿  R>  R’   t
   PROPERTY_Bt   PROPERTY_OCCt
   PROPERTY_Xt
   PROPERTY_Yt
   PROPERTY_Zt   PROPERTY_ATOM_SASt   PROPERTY_RES_SASt   PROPERTY_ATOM_CONTACTt   PROPERTY_RES_CONTACTt   PROPERTY_SECt   PROPERTY_SERIALRÉ  R=  R<  R!  R‹   R�  R  R  R  R  R-  R6  R  R—   R  RI  RG  RH  RO  R[  R\  R]  Rk  Rk  R`  R7  Rb  RN  Rc  Rm  Rr  R5  R?  R‹  R�  R•  (    (    (    sF   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/python/ui/model_selection.pyRj  À  s¼   

		 `	\	&							ÿ 		c         C   s?  d d  l  } d } t ƒ  } t ƒ  } t ƒ  } |  j ƒ  } |  j ƒ  } |  j ƒ  }	 |  j ƒ  }
 |  j ƒ  } |  j ƒ  } |  j | d d t d t d d d d d t ƒ |  j | t	 | t ƒ |  j | t	 | t
 ƒ |  j |	 t | t ƒ |  j |
 t | t ƒ |  j |
 t |	 t
 ƒ t ƒ  } t j |  |
 | ƒ } | j ƒ  } | d k râd } t | d ƒ } | } xg | | k  rËt | | ƒ } | j | j d k rŸ| } n | t | | ƒ } | } | } | d } qeW| t | | ƒ } n  |  j | t	 |
 t ƒ |  j | t	 | t
 ƒ t j |  | | ƒ } | j ƒ  } | rÑd } t | d ƒ g } xn | | k  r½t | | ƒ } | j j | d j j k r—| j | ƒ n | t | ƒ } | g } | d } qPW| t | ƒ } n  | rç| d d !} n  |  j | ƒ |  j | ƒ |  j |	 ƒ |  j |
 ƒ |  j | ƒ |  j | ƒ d | g S(   NiÿÿÿÿR#   i    R    i   iüÿÿÿ(   R  R§   Rñ   t   newPPCChainR¦   RÒ  R«   R¬   R©   Rª   R°   Rú   R¨   R’   Rû   R‘   Rý   RX  t   mmdbHandleResComR±   R²   Rµ  RE   t   mmdbHandleAtomComR»   (   R”   R>  R  R*   R\  R_  t   selChainR8  t	   notSelHndt   notResSelHndRÓ  t	   chnSelHndt   notChnSelHndRÀ   t   nSelResRV   t   ifrest   ilrest   irest   nSelAtomt   iat_listt   iat(    (    sF   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/python/ui/model_selection.pyt   mmdbHandle2Command3  st    						 c         C   s8  |  j  j ƒ  } d d g j | ƒ r- d } n  |  j | j k r› |  j ƒ  r} | d t |  j ƒ d t |  j ƒ  ƒ d } q4| d t |  j ƒ d } n™ | d t |  j ƒ } |  j ƒ  rÛ | d t |  j ƒ  ƒ } n  | j ƒ  r| d t | j ƒ d t | j ƒ  ƒ d } n | d t | j ƒ d } | S(   NR#   R=   s   // RË   R   s    or RŸ  (   R¶  Rø   RI   RX  R¦  RK  t   seqNum(   Rª  R«  t   chainidR*   (    (    sF   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/python/ui/model_selection.pyR¢  £  s     	2 2c         C   s  d d  l  } |  d j } | j j ƒ  } d d g j | ƒ rF d } n  | j ƒ  r„ | d t | j ƒ d t | j ƒ  ƒ d } n | d t | j ƒ d } xn |  D]f } | j ƒ  rï | | j	 | j
 ƒ  ƒ d | j	 | j ƒ  ƒ d	 } q¦ | | j	 | j
 ƒ  ƒ d	 } q¦ W| d d !d
 S(   Niÿÿÿÿi    R#   R=   s   // RË   R   R  Râ   s    or (   RF   Rµ  R¶  Rø   RI   R¦  RK  R±  R¹   RG   Rm  (   R®  RF   R¬  R²  R*   R¯  (    (    sF   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/python/ui/model_selection.pyR£  ·  s     	27!c         C   s9   |  j  d d ƒ r5 d |  d <|  j  d d ƒ |  d <n  |  S(   NR*   R#   Rã  RÝ  (   R'   (   R  (    (    sF   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/python/ui/model_selection.pyt   fix_v108É  s    
(   t   __doc__R>   RF   R  t   mmdb2R’   R  Rh  t   global_definitionsR   t   SELECTION_ICONSR+  t   PEPTIDE_ATOMTYPE_MENUt   NUCLEIC_ATOMTYPE_MENUR!   Ro   R%   R3   R/   R  Rj  R°  R¢  R£  R³  (    (    (    sF   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/python/ui/model_selection.pyt   <module>   sœ   $








Àÿ ÿ ÿ ÿ ÿ ÿ ÿ ÿ "ÿ ÿ s			ÿ ÿ ÿ ÿ w	p		