Package specific_analyses :: Package frame_order :: Module data
[hide private]
[frames] | no frames]

Source Code for Module specific_analyses.frame_order.data

  1  ############################################################################### 
  2  #                                                                             # 
  3  # Copyright (C) 2009-2014 Edward d'Auvergne                                   # 
  4  #                                                                             # 
  5  # This file is part of the program relax (http://www.nmr-relax.com).          # 
  6  #                                                                             # 
  7  # This program is free software: you can redistribute it and/or modify        # 
  8  # it under the terms of the GNU General Public License as published by        # 
  9  # the Free Software Foundation, either version 3 of the License, or           # 
 10  # (at your option) any later version.                                         # 
 11  #                                                                             # 
 12  # This program is distributed in the hope that it will be useful,             # 
 13  # but WITHOUT ANY WARRANTY; without even the implied warranty of              # 
 14  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               # 
 15  # GNU General Public License for more details.                                # 
 16  #                                                                             # 
 17  # You should have received a copy of the GNU General Public License           # 
 18  # along with this program.  If not, see <http://www.gnu.org/licenses/>.       # 
 19  #                                                                             # 
 20  ############################################################################### 
 21   
 22  # Module docstring. 
 23  """Module for handling the frame order data in the relax data store.""" 
 24   
 25  # relax module imports. 
 26  from lib.errors import RelaxError 
 27  from pipe_control.interatomic import interatomic_loop 
 28  from pipe_control.mol_res_spin import spin_loop 
 29   
 30   
31 -def base_data_types():
32 """Determine all the base data types. 33 34 The base data types can include:: 35 - 'rdc', residual dipolar couplings. 36 - 'pcs', pseudo-contact shifts. 37 38 @return: A list of all the base data types. 39 @rtype: list of str 40 """ 41 42 # Array of data types. 43 list = [] 44 45 # RDC search. 46 for interatom in interatomic_loop(selection1=domain_moving()): 47 if hasattr(interatom, 'rdc'): 48 list.append('rdc') 49 break 50 51 # PCS search. 52 for spin in spin_loop(selection=domain_moving()): 53 if hasattr(spin, 'pcs'): 54 list.append('pcs') 55 break 56 57 # No data is present. 58 if not list: 59 raise RelaxError("Neither RDCs nor PCSs are present.") 60 61 # Return the list. 62 return list
63 64
65 -def domain_moving():
66 """Return the spin ID string corresponding to the moving domain. 67 68 @return: The spin ID string defining the moving domain. 69 @rtype: str 70 """ 71 72 # Check that the domain is defined. 73 if not hasattr(cdp, 'domain'): 74 raise RelaxError("No domains have been defined. Please use the domain user function.") 75 76 # Only support for 2 domains. 77 if len(list(cdp.domain.keys())) > 2: 78 raise RelaxError("Only two domains are supported in the frame order analysis.") 79 80 # Reference domain not set yet, so return nothing. 81 if not hasattr(cdp, 'ref_domain'): 82 return None 83 84 # Loop over the domains. 85 for id in list(cdp.domain.keys()): 86 # Reference domain. 87 if id == cdp.ref_domain: 88 continue 89 90 # Return the ID. 91 return cdp.domain[id]
92 93
94 -def pivot_fixed():
95 """Determine if the pivot is fixed or not. 96 97 @return: The answer to the question. 98 @rtype: bool 99 """ 100 101 # A pivot point is not supported by the model. 102 if cdp.model in ['rigid']: 103 return True 104 105 # The PCS is loaded. 106 if 'pcs' in base_data_types(): 107 # The fixed flag is not set. 108 if hasattr(cdp, 'pivot_fixed') and not cdp.pivot_fixed: 109 return False 110 111 # The point is fixed. 112 return True
113 114
115 -def tensor_loop(red=False):
116 """Generator method for looping over the full or reduced tensors. 117 118 @keyword red: A flag which if True causes the reduced tensors to be returned, and if False 119 the full tensors are returned. 120 @type red: bool 121 @return: The tensor index and the tensor. 122 @rtype: (int, AlignTensorData instance) 123 """ 124 125 # Number of tensor pairs. 126 n = len(cdp.align_tensors.reduction) 127 128 # Alias. 129 data = cdp.align_tensors 130 list = data.reduction 131 132 # Full or reduced index. 133 if red: 134 index = 1 135 else: 136 index = 0 137 138 # Loop over the reduction list. 139 for i in range(n): 140 yield i, data[list[i][index]]
141 142
143 -def translation_fixed():
144 """Is the translation of the average domain position fixed? 145 146 @return: The answer to the question. 147 @rtype: bool 148 """ 149 150 # PCS data must be present. 151 if 'pcs' in base_data_types(): 152 # The fixed flag is not set. 153 if hasattr(cdp, 'ave_pos_translation') and cdp.ave_pos_translation: 154 return False 155 156 # Default to being fixed. 157 return True
158