ó
Å™xTc           @   s½  d  d l  m Z d  d l Z d  d l Z d  d l j Z d  d l m	 Z	 d  d l
 m Z d  d l m Z d  d l Z d Z d Z e Z d g d	 Z d
 e d <d e d <d e d <d e j e j j j f d „  ƒ  YZ d e j e j j j f d „  ƒ  YZ d e j e j j j f d „  ƒ  YZ d d d e j d „ Z e j d „ Z  e j d „ Z! d „  Z" d „  Z# e j d „ Z$ e j d „ Z% d „  Z& d e' f d  „  ƒ  YZ( d! „  Z) d" d# „ Z* d S($   iÿÿÿÿ(   t   divisionN(   t   Sorry(   t
   group_args(   t   sqrts<  
helix
  .multiple = True
  .optional = True
  .style = noauto
{
  selection = None
    .type = atom_selection
    .style = bold
  helix_type = *alpha pi 3_10 unknown
    .type = choice
    .help = Type of helix, defaults to alpha.  Only alpha, pi, and 3_10       helices are used for hydrogen-bond restraints.
    .style = bold
  restraint_sigma = None
    .type = float
  restraint_slack = None
    .type = float
  backbone_only = False
    .type = bool
    .help = Only applies to rigid-body groupings, and not H-bond restraints       which are already backbone-only.
}sì  
sheet
  .multiple = True
  .optional = True
  .style = noauto
{
  first_strand = None
    .type = atom_selection
    .style = bold
  strand
    .multiple = True
    .optional = True
  {
    selection = None
      .type = atom_selection
      .style = bold
    sense = parallel antiparallel *unknown
      .type = choice
      .style = bold
    bond_start_current = None
      .type = atom_selection
      .style = bold
    bond_start_previous = None
      .type = atom_selection
      .style = bold
  }
  restraint_sigma = None
    .type = float
  restraint_slack = None
    .type = float
  backbone_only = False
    .type = bool
    .help = Only applies to rigid-body groupings, and not H-bond restraints       which are already backbone-only.
}
t   unknowni
   t   alphai    t   pii   t   3_10i   t   _annotationc           B   s   e  Z e j d  d d „ Z RS(   t    c   	      C   s�   g  } xB |  j  D]7 } | j | | | ƒ } | d  k	 r | j | ƒ q q WxB |  j D]7 } | j | | | ƒ } | d  k	 rU | j | ƒ qU qU Wd j | ƒ S(   Ns   
(   t   helicest   as_restraint_groupt   Nonet   appendt   sheetst   join(	   t   selft   logt   prefix_scopet	   add_segidt	   phil_strst   helixt
   helix_philt   sheett
   sheet_phil(    (    sP   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/secondary_structure/proteins.pyt   as_restraint_groupsO   s    N(   t   __name__t
   __module__t   syst   stdoutR   R   (    (    (    sP   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/secondary_structure/proteins.pyR   N   s   	t
   _pdb_helixc           B   s   e  Z e j d  d d „ Z RS(   R	   c   	      C   sî   |  j  |  j k r0 | d |  j  |  j f IJd  Sd } t r„ d |  j |  j f } d |  j |  j f } d |  j  | | | f } n d |  j  | |  j |  j f } | d k rÌ | j d ƒ rÌ | d 7} n  d | | t	 |  j
 d f } | S(	   Ns1   Helix chain ID mismatch: starts in %s, ends in %sR	   s   %d%ss$   chain '%s' %sand resid %s through %ss   chain '%s' %sand resseq %d:%dt   .s0   %shelix {
  selection = "%s"
  helix_type = %s
}i   (   t   start_chain_idt   end_chain_idR   t
   use_residst   start_resseqt   start_icodet
   end_resseqt	   end_icodet   endswitht   helix_classest   helix_class(	   R   R   R   R   t   segid_extrat   resid_startt	   resid_endt   selet   rg(    (    sP   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/secondary_structure/proteins.pyR   ]   s     		N(   R   R   R   R   R   R   (    (    (    sP   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/secondary_structure/proteins.pyR   \   s   	t
   _pdb_sheetc           B   s   e  Z e j d  d d „ Z RS(   R	   c         C   s#  t  |  j ƒ d k r d  Sg  } g  } g  } g  } d } xt |  j |  j ƒ D]ý\ }	 }
 t r§ d |	 j |	 j f } d |	 j |	 j	 f } d |	 j
 | | | f } n d |	 j
 | |	 j |	 j f } | j | ƒ |	 j d k rò | j d ƒ nJ |	 j d k r| j d ƒ n+ |	 j d	 k r0| j d
 ƒ n t d ƒ ‚ |
 d  k	 r0t rÕd } d |
 j |
 j f } d |
 j |
 j f } | j | |
 j | | |
 j j ƒ  f ƒ | j | |
 j | | |
 j j ƒ  f ƒ qJ| j d |
 j | |
 j |
 j j ƒ  f ƒ | j d |
 j | |
 j |
 j j ƒ  f ƒ qM | j d  ƒ | j d  ƒ qM Wd } d  } g  } xe t | | | | ƒ D]N \ } } } } | d k r�| } n | j d | | | | f ƒ | d	 7} qvW| d  k	 sÚt ‚ | d k r| j d ƒ r| d 7} n  d | | d j | ƒ f } | S(   Ni    R	   s   %d%ss$   chain '%s' %sand resid %s through %ss   chain '%s' %sand resseq %d:%dR   iÿÿÿÿt   antiparalleli   t   parallels   Sense must be 0, 1, or -1.s%   chain '%s' %sand resid %s and name %ss&   chain '%s' %sand resseq %d and name %sso     strand {
    selection = "%s"
    sense = %s
    bond_start_current = "%s"
    bond_start_previous = "%s"
  }R   s%   
%ssheet {
  first_strand = "%s"
%s
}s   
(   t   lent   strandsR   t   zipt   registrationsR"   R#   R$   R%   R&   R    R   t   senseR   t
   cur_resseqt	   cur_icodet   prev_resseqt
   prev_icodet   cur_chain_idt   cur_atomt   stript   prev_chain_idt	   prev_atomt   AssertionErrorR'   R   (   R   R   R   R   t
   selectionst   sensest   reg_currt   reg_prevR*   t   strandt   registrationR+   R,   R-   t	   sele_baset
   resid_currt
   resid_prevt   nt   first_strandR3   R6   t   currt   prevt   phil_str(    (    sP   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/secondary_structure/proteins.pyR   x   sn    "					(	N(   R   R   R   R   R   R   (    (    (    sP   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/secondary_structure/proteins.pyR/   w   s   	g      ð?c         C   sø  d  } d  } d  g d \ } } } } xJ |  D]B } | j d k rV | } | j ƒ  } q, | j d k r, | } q, q, WxJ | D]B } | j d k r£ | } | j ƒ  } qy | j d k ry | } qy qy W| | | g j d  ƒ d k ræ| r| d  k r| d j ƒ  j ƒ  } | d | IJd S| | j d k rL| d IJ| d	 | j ƒ  IJd S| | j d k r�| d
 IJ| d	 | j ƒ  IJd S| r| d k r| r«| j | ƒ } n | j | ƒ } | | k r| d | | f IJ| d | j ƒ  | j ƒ  f IJd Sn  | r| } n  |
 } |
 d  k r.| j } n  | } | d  k rL| j	 } n  d } | j
 r�| | d |	 | d } d | GHn  | j d | j | j g d | d | d |	 | d d | d | d | j
 ƒ | j | j | j ƒ d S| d IJd Sd  S(   Ni   s    O  s    C  s    N  s    H  i    s     Missing hydrogen at %ds1     WARNING: donor atom is already bonded, skippings       %ss4     WARNING: acceptor atom is already bonded, skippings(     removed outlier: %.3fA (cutoff: %.3fA)s       %s --> %siÿÿÿÿi   s   limit: %.2ft   i_seqst   distance_idealt   distance_cutt   weightt   slackt   limitt   top_outi   s   WARNING: missing atoms!(   R   t   namet   fetch_labelst   countt   resseq_as_intt   i_seqt   id_strt   distancet   sigmaRS   RU   t	   add_proxyt   add_nonbonded_exclusion(   t   acceptor_atomst   donor_atomst   build_proxiest   hbond_countsRP   RQ   t   hbond_paramst   remove_outlierst   use_hydrogensRR   R]   RS   R   t   donor_labelst   acceptor_labelst   donort   acceptort   acceptor_baset   hydrogent   atomt   donor_resseqt   distt   sigma_t   slack_RT   (    (    sP   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/secondary_structure/proteins.pyt   _create_hbond_proxyÂ   s|    



			

c   &      C   s  d  | | g k s t ‚ |  j } | d k r6 d } n< | d k rK d } n' | d k r` d } n | d | IJd Sy | j |  j ƒ } Wn$ t k
 r® } | t | ƒ IJd SX| d k sÁ t ‚ | j | ƒ sÔ d Sd } | j ƒ  } x1| j ƒ  D]#} x| j	 ƒ  D]} x| j
 ƒ  D]õ} | j ƒ  j ƒ  } | j | ƒ } | j ƒ  d k rXqn  | j ƒ  } t | ƒ } d } x•| | | k  r| | } | j ƒ  } | j ƒ  } d  } d  } d  }  d  }! | | d j r | | }" | |" }# |# j ƒ  }$ |# j d	 k r*| d
 | j |$ f IJ| d 7} qynL |$ | | k rv| d | j | j ƒ  | j |# j ƒ  f IJ| d 7} qyn  |# j ƒ  }% | |% d j t k r | t d | d |% d | d | d | d | d | d |	 d |
 d | d |  j d |  j d | ƒ 7} q n  | d 7} qyWqWqWqó W| S(   NR   i   R   i   R   i   s(     Don't know bonding for helix class %s.i    t   PROs)     Proline residue at %s %s - end of helixs-     Confusing residue numbering: %s %s -> %s %si   R`   Ra   Rb   Rc   RP   RQ   Rd   Re   Rf   RR   R]   RS   R   (   i   i   i   (   R   R@   t
   helix_typet	   selectiont	   Exceptiont   strt   is_super_sett
   iselectiont   modelst   chainst
   conformerst   atomst   extract_i_seqt   intersectiont   sizet   residuesR2   RY   RZ   t   resnamet   idt   residt   TrueRr   t   restraint_sigmat   restraint_slack(&   t   paramst   pdb_hierarchyt   selection_cacheRb   RR   Rd   Rc   RP   RQ   Re   Rf   t   master_selectionR   R)   t
   helix_stept   helix_selectiont   et	   n_proxiest   helix_i_seqst   modelt   chaint	   conformert   chain_i_seqst   both_i_seqsR�   t
   n_residuest   j_seqt   residuet
   resi_atomst   resseqRi   Rj   Rk   Rl   t   k_seqt   bonded_resit   bonded_resseqt   bonded_atoms(    (    sP   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/secondary_structure/proteins.pyt"   create_helix_hydrogen_bond_proxies  sŒ    				



%
			c         C   sÇ  d  | | g k s t ‚ | j ƒ  } |  j } | j | ƒ } |
 j | ƒ sO d St d | d | ƒ } d } d } xP| t |  j ƒ k  rÂ|  j | } | j | j ƒ } | j | j	 ƒ } | j | j
 ƒ } | j t ƒ d k sõ | j t ƒ d k rd | j	 | j
 f } t | ƒ ‚ n  t d | d | ƒ } d } } t | ƒ } t | ƒ } | j ƒ  j | ƒ d j j ƒ  d k } | d k rz| d k rzt d | d | ƒ } t d | d | ƒ } | d k rN| d k rNx– d | k  rkd | k  rý| j d	 k s| | d
 k  rk| j d k rk| j d	 k rB| d
 8} | d
 8} qÖ| j d k rÖ| d
 8} | d
 7} qÖqÖW| j d	 k r»| d
 k r¢| r¢| d
 8} | } n  | d
 k rÈ| rÈ| d
 8} | } n  x€| | k  r·| | k  r·| r
| | } | | } | d
 7} n | | } | | } | d
 7} | } | j j ƒ  d k rË| t d | j ƒ  d | j ƒ  d | d | d | d | d | d | d |	 d | d |  j d |  j d | ƒ 7} qËqËWqw| j d k r"x~| | k  r| d k r| | j j ƒ  d k rv| t d | | j ƒ  d | | j ƒ  d | d | d | d | d | d | d |	 d | d |  j d |  j d | ƒ 7} n  | | j j ƒ  d k r| t d | | j ƒ  d | | j ƒ  d | d | d | d | d | d | d |	 d | d |  j d |  j d | ƒ 7} n  | d
 7} | d
 8} qÍWqw| d IJ| d | IJ| d | j IJq£| d IJ| d | IJ| d | j IJn) | d IJ| d | IJ| d | j IJ| d 7} | } | } | } qs W| S(   Ni    R‰   t   strand_selectioni   sÙ   Wrong registration in SHEET record. One of these selections
"%s" or "%s"
yielded zero or several atoms. Possible reason for it is the presence of
insertion codes or alternative conformations for one of these residues.t   NR�   t   start_selectionR1   i   R0   Rs   R`   Ra   Rb   Rc   RP   RQ   Rd   Re   Rf   RR   R]   RS   R   s(     WARNING: strand direction not defined!s       previous: %ss       current: %ss3     WARNING: can't find start of bonding for strands!s*     WARNING: can't find one or more strands!(   R   R@   t   atom_selection_cacheRK   Ru   Rx   t   _get_strand_residuesR2   RE   t   bond_start_currentt   bond_start_previousRX   R…   R   R}   t   selectRV   R=   t   _find_start_residueR6   R‚   Rr   R†   R‡   (   t   sheet_paramsR‰   Rb   RR   Rd   Rc   RP   RQ   Re   Rf   R‹   R   t   cachet   prev_strandt   prev_selectiont   prev_residuesR�   t   kt   curr_strandt   curr_selectiont
   curr_startt
   prev_startt	   error_msgt   curr_residuest   it   jt   len_prev_residuest   len_curr_residuest   current_start_res_is_donort   donor_residuet   acceptor_residue(    (    sP   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/secondary_structure/proteins.pyt"   create_sheet_hydrogen_bond_proxiesn  sö    		*	
(		










									





c         C   s^   | j  ƒ  } xK t |  ƒ D]= \ } } | j ƒ  j ƒ  } | j | ƒ j ƒ  d k r | Sq Wd S(   Ni    iÿÿÿÿ(   Ry   t	   enumerateR}   R~   R   R€   (   R�   R¢   t   start_i_seqsRµ   R˜   t   atom_i_seqs(    (    sP   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/secondary_structure/proteins.pyR¨     s    c         C   s>  | j  ƒ  } g  } x%|  j ƒ  D]} xø | j ƒ  D]ê } xË | j ƒ  D]½ } | j ƒ  j ƒ  } | j | ƒ } | j ƒ  d k r„ qE n  | j ƒ  }	 t	 |	 ƒ }
 xM t
 |	 ƒ D]? \ } } | j ƒ  } | | d j t k r© | j | ƒ q© q© Wt	 | ƒ d k rE PqE qE Wt	 | ƒ d k r2 Pq2 q2 Wt	 | ƒ d k r Pq q W| S(   Ni    (   Ry   Rz   R{   R|   R}   R~   R   R€   R�   R2   R½   RZ   R…   R   (   R‰   R    t   strand_i_seqst   strand_residuesR‘   R’   R“   R”   R•   R�   R–   R—   R˜   R™   (    (    sP   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/secondary_structure/proteins.pyR¤     s,    c         C   sn  |  j  ƒ  j } g  |  j ƒ  D] } | ^ q } g  } x3t | ƒ D]%\ } } | j d  k rt | d | d IJqA n  d | j }	 | |	 ƒ }
 | |
 d } | |
 d } | j d k rÁ d } n t j | j ƒ } t	 j
 j j d | d d	 | d d
 | j d | j d | j d | j d | j d | j d | j d | j d | d d d |
 j ƒ  ƒ } | j | ƒ qA W| S(   Ns   Empty helix at serial %d.i   s0   (%s) and (name N) and (altloc 'A' or altloc ' ')i    iÿÿÿÿR   i   t   serialt   helix_idt   start_resnameR    R#   R$   t   end_resnameR!   R%   R&   R)   t   commentR	   t   length(   R£   Ry   t   atoms_with_labelsR½   Ru   R   Rt   R(   t   indext   iotbxt   pdbt   secondary_structuret	   pdb_helixR‚   t   chain_idRš   t   icodeR€   R   (   R‰   R
   R   t   iselt   aR}   t   pdb_helicesRµ   t   helix_paramst   sele_strt
   amide_iselt
   start_atomt   end_atomR)   t   current_helix(    (    sP   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/secondary_structure/proteins.pyt   restraint_groups_as_pdb_helices&  s>    
	

								c         C   sM  |  j  ƒ  j } g  |  j ƒ  D] } | ^ q } g  } xt | ƒ D]\ } } t j | }	 | j d  k rz | d |	 IJn  t j	 j
 j d |	 d d t | j ƒ d g  d g  ƒ }
 t d | d | j d	 | d
 | d d  ƒ } |
 j | ƒ |
 j d  ƒ d } x:| j D]/} t d | d | j d	 | d
 | d | j ƒ } |
 j | ƒ | | j } | | j } | | ƒ } | | ƒ } | j ƒ  d k s›| j ƒ  d k r®|
 j d  ƒ qn  | | d } | | d } t d t d | j d | j d | j d | j d | j d d d | j d | j d | j ƒ 
} |
 j | ƒ qW| j |
 ƒ qA W| S(   Ns    Missing first strand in sheet %st   sheet_idt	   n_strandsi   R3   R5   RÐ   Ru   R}   R   R6   s.   (%s) and name N and (altloc 'A' or altloc ' ')i    R<   t   cur_resnameR;   R7   R8   R?   t   prev_resnamet   OR>   R9   R:   (   R£   Ry   RÈ   R½   t   stringt	   uppercaseRK   R   RÊ   RË   RÌ   t	   pdb_sheetR2   RE   t   _strand_group_as_pdb_strandt
   add_strandt   add_registrationRu   R6   R¥   R¦   R€   R   t
   donor_nameR‚   RÎ   Rš   RÏ   RV   R   (   R‰   R   R   RÐ   RÑ   R}   t
   pdb_sheetsRµ   R   RÚ   t   current_sheetRK   t	   base_seleRE   t
   pdb_strandt   s1t   s2t   reg_curr_iselt   reg_prev_iselt   reg_curr_atomt   reg_prev_atomRF   (    (    sP   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/secondary_structure/proteins.pyt   restraint_groups_as_pdb_sheetsH  sd    				$							c   
      C   sâ   | d  k s | d k r! d } n* | d k r6 d } n | d k rK d } n  |  d | ƒ } | | d } | | d } t d t d	 t d d
 | j d | j d | j d | j d | j d | j d | j d | j d | ƒ }	 |	 S(   NR   i    R1   i   R0   iÿÿÿÿs.   (%s) and name N and (altloc 'A' or altloc ' ')RÚ   t	   strand_idRÄ   R    R#   R$   RÅ   R!   R%   R&   R6   (   R   R   RÚ   Rµ   R‚   RÎ   Rš   RÏ   (
   RÐ   Ru   R}   R   R6   t	   int_senset   strand_iselRÖ   R×   Ré   (    (    sP   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/secondary_structure/proteins.pyRâ   |  s.    			

									t   find_helices_simplec           B   se   e  Z d  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z	 d „  Z
 e j d	 „ Z RS(
   s  
  Identify helical regions, defined as any three or more contiguous residues
  with phi and psi within specified limits:
    -120 < phi < -20
    -80 < psi < -10
  This is much more tolerant of distorted models than KSDSSP, but will still
  miss helices in poor structures.
  c         C   s)   | |  _  g  |  _ g  |  _ |  j ƒ  d  S(   N(   R‰   t   _helicest   _current_helixt   run(   R   R‰   (    (    sP   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/secondary_structure/proteins.pyt   __init__¡  s    			c         C   s8   t  |  j ƒ d k r+ |  j j |  j ƒ n  g  |  _ d  S(   Ni   (   R2   Rö   Rõ   R   (   R   (    (    sP   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/secondary_structure/proteins.pyt   process_break§  s    c         C   sf   t  |  j ƒ d k rP |  j d \ } } | | k rb |  j j | | f ƒ qb n | | f g |  _ d  S(   Ni    iÿÿÿÿ(   R2   Rö   R   (   R   RÎ   Rš   t
   last_chaint   last_resseq(    (    sP   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/secondary_structure/proteins.pyt	   push_back¬  s
    c      
   C   s.  d d  l  } d d  l } | j j } |  j j ƒ  } | j ƒ  } g  } xâ|  j j ƒ  D]Ñ} xÈ| j ƒ  D]º} | j	 ƒ  d }	 |	 j
 ƒ  }
 x•t t |
 ƒ d ƒ D]}} |
 | } | | j ƒ d k r¡ d  } | d k ré |
 | d } n  |
 | d } | j ƒ  } | j ƒ  } | d  k	 r| | d k sI| | k r| j | j k r| j ƒ  } | | d k sƒ| | k r| j | j k r| j j d | d | d | ƒ } | j d  ƒ d k r¿q¡ n  | j j d | d	 | ƒ \ } } t | | ƒ r|  j | j | ƒ q¡ qqqn  |  j ƒ  q¡ q¡ Wqh WqU Wd  S(
   Niÿÿÿÿi    i   t   common_amino_acidt   prev_resR˜   t   next_resRO   t
   sites_cart(   t   mmtbx.rotamert	   iotbx.pdbRË   t   common_residue_names_get_classR‰   R}   t   extract_xyzRz   R{   R|   R�   t   rangeR2   R‚   R   RY   RÏ   t   rotamert   get_phi_psi_indicesRX   t   phi_psi_from_sitest   is_approximately_helicalRü   Rƒ   Rù   (   R   t   mmtbxRÊ   t	   get_classR}   R   RØ   R‘   R’   t	   main_confR�   t   i_rest   residue1t   residue0t   residue2t   resseq1t   resseq2t   resseq0t   phi_psi_i_seqst   phit   psi(    (    sP   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/secondary_structure/proteins.pyR÷   ´  sP    
		c         C   sd   g  } xW |  j  D]L } | d d } d | d d | d d | d d f } | j | ƒ q W| S(   Ni    s   chain '%s' and resseq %d:%di   iÿÿÿÿ(   Rõ   R   (   R   t   atom_selectionsR   RÎ   Ru   (    (    sP   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/secondary_structure/proteins.pyt   build_selectionsß  s    c         C   s‡   g  } x+ |  j  ƒ  D] } d | } | j | ƒ q Wt | ƒ d k rƒ t j j t ƒ } t j j d j | ƒ ƒ } | j d | ƒ Sd  S(   Ns   helix {
  selection = "%s"
}i    s   
t   source(
   R  R   R2   RÊ   t   philt   parset   helix_group_params_strR   t   fetchR   (   R   R   Ru   t	   helix_strt   master_philR   (    (    sP   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/secondary_structure/proteins.pyt   as_restraint_group_philè  s    
c         C   s&   |  j  ƒ  } | d  k	 r" | j ƒ  Sd  S(   N(   R   R   t   extract(   R   R   (    (    sP   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/secondary_structure/proteins.pyR   ó  s    
c         C   s   d  S(   N(    (   R   (    (    sP   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/secondary_structure/proteins.pyt   as_pdb_recordsù  s    c         C   sb   t  |  j ƒ d k r" | d IJn | d t  |  j ƒ IJx" |  j ƒ  D] } | d | IJqF Wd  S(   Ni    s   No recognizable helices.s   %d helix-like regions found:s     %s(   R2   Rõ   R  (   R   t   outRu   (    (    sP   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/secondary_structure/proteins.pyt   showü  s
    (   R   R   t   __doc__Rø   Rù   Rü   R÷   R  R   R   R"  R   R   R$  (    (    (    sP   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/secondary_structure/proteins.pyRô   ˜  s   				+					c         C   s@   d |  k  o d k  n r< d | k  o3 d k  n r< t  St S(   Niˆÿÿÿiìÿÿÿi°ÿÿÿiöÿÿÿ(   R…   t   False(   R  R  (    (    sP   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/secondary_structure/proteins.pyR	    s    8g      @c         C   sù   | d k s t  ‚ | j ƒ  | j ƒ  k s0 t  ‚ | j ƒ  | j ƒ  k sN t  ‚ |  j ƒ  } | } d }	 xŒ | D]„ }
 x{ | D]s } | |
 \ } } } | | \ } } } t | | d | | d | | d ƒ } | | k  rz |
 t f }	 qz qz Wqm W|	 S(   NR   i   (   NN(   R@   R€   R  R   R   t   acceptor_i_seq(   R}   t   prev_strand_donorst   prev_strand_acceptorst   curr_strand_donorst   curr_strand_acceptorsR6   t   max_distance_cutoffR   t   min_distt	   best_pairt   donor_i_seqt   acceptor_j_seqt   x1t   y1t   z1t   x2t   y2t   z2Ro   (    (    sP   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/secondary_structure/proteins.pyt   _find_strand_bonding_start
  s    ,(+   t
   __future__R    t   iotbx.pdb.secondary_structureRÊ   t
   iotbx.philt   libtbx.object_oriented_patternst   object_oriented_patternst   oopt   libtbx.utilsR   t   libtbxR   t   mathR   R   R  t   sheet_group_params_strR…   R"   R(   t   injectorRË   RÌ   t
   annotationR   RÍ   R   Rá   R/   R   R   Rr   RŸ   R¼   R¨   R¤   RÙ   Rð   Râ   t   objectRô   R	  R7  (    (    (    sP   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/secondary_structure/proteins.pyt   <module>   s>   %


%%%UO\ˆ	
	"4	l	