1   
  2   
  3   
  4   
  5   
  6   
  7   
  8   
  9   
 10   
 11   
 12   
 13   
 14   
 15   
 16   
 17   
 18   
 19   
 20   
 21   
 22   
 23   
 24  """The molecule, residue, spin base classes.""" 
 25   
 26   
 27  from string import split 
 28   
 29   
 30  from generic_fns.mol_res_spin import generate_spin_id, residue_loop, spin_loop 
 31  from generic_fns.pipes import cdp_name 
 32   
 33   
 34  from base import UF_base 
 35  from gui.misc import gui_to_int, gui_to_str, str_to_gui 
 36  from gui.paths import WIZARD_IMAGE_PATH 
 37   
 38   
 40      """The molecule, residue, spin base class.""" 
 41   
 43          """Generate the residue ID from the residue selection. 
 44   
 45          @keyword suffix:    The suffix to be added to the residue data structure name. 
 46          @type suffix:       str 
 47          @return:            The residue ID string. 
 48          @rtype:             str 
 49          """ 
 50   
 51           
 52          obj = getattr(self, 'mol'+suffix) 
 53          mol_name = str(obj.GetValue()) 
 54          if mol_name == '': 
 55              mol_name = None 
 56   
 57           
 58          res_info = self._get_res_info(suffix) 
 59          if not res_info: 
 60              return 
 61          res_num, res_name = res_info 
 62   
 63           
 64          return generate_spin_id(mol_name=mol_name, res_num=res_num, res_name=res_name) 
  65   
 66   
 68          """Extract the residue info from the residue selection. 
 69   
 70          @keyword suffix:    The suffix to be added to the residue data structure name. 
 71          @type suffix:       str 
 72          @return:            The residue number and name from the residue selection self.res. 
 73          @rtype:             int, str 
 74          """ 
 75   
 76           
 77          if hasattr(self, 'res'+suffix): 
 78               
 79              obj = getattr(self, 'res'+suffix) 
 80              res = gui_to_str(obj.GetValue()) 
 81   
 82               
 83              if not res: 
 84                  return None, None 
 85   
 86               
 87              res_num, res_name = split(res) 
 88   
 89               
 90              if res_name in ['', 'None']: 
 91                  res_name = None 
 92              if res_num == '': 
 93                  res_num = None 
 94              else: 
 95                  res_num = int(res_num) 
 96   
 97           
 98          else: 
 99               
100              obj = getattr(self, 'res_num'+suffix) 
101              res_num = gui_to_int(obj.GetValue()) 
102   
103               
104              obj = getattr(self, 'res_name'+suffix) 
105              res_name = gui_to_str(obj.GetValue()) 
106   
107           
108          return res_num, res_name 
 109   
110   
112          """Generate the spin ID from the molecule, residue, and spin selection. 
113   
114          @keyword suffix:    The suffix to be added to the spin data structure name. 
115          @type suffix:       str 
116          @return:            The spin ID string. 
117          @rtype:             str 
118          """ 
119   
120           
121          obj = getattr(self, 'mol'+suffix) 
122          mol_name = str(obj.GetValue()) 
123          if mol_name == '': 
124              mol_name = None 
125   
126           
127          res_num, res_name = self._get_res_info(suffix=suffix) 
128   
129           
130          spin_info = self._get_spin_info(suffix=suffix) 
131          if not spin_info: 
132              return 
133          spin_num, spin_name = spin_info 
134   
135           
136          return generate_spin_id(mol_name=mol_name, res_num=res_num, res_name=res_name, spin_num=spin_num, spin_name=spin_name) 
 137   
138   
140          """Extract the spin info from the spin selection. 
141   
142          @keyword suffix:    The suffix to be added to the spin data structure name. 
143          @type suffix:       str 
144          @return:            The spin number and name from the spin selection self.spin. 
145          @rtype:             int, str 
146          """ 
147   
148           
149          if hasattr(self, 'spin'+suffix): 
150               
151              obj = getattr(self, 'spin'+suffix) 
152              spin = str(obj.GetValue()) 
153   
154               
155              if spin == '': 
156                  return None, None 
157   
158               
159              spin_num, spin_name = split(spin) 
160   
161               
162              if spin_name == '': 
163                  spin_name = None 
164              if spin_num == '': 
165                  spin_num = None 
166              else: 
167                  spin_num = int(spin_num) 
168   
169           
170          else: 
171               
172              obj = getattr(self, 'spin_num'+suffix) 
173              spin_num = gui_to_int(obj.GetValue()) 
174   
175               
176              obj = getattr(self, 'spin_name'+suffix) 
177              spin_name = gui_to_str(obj.GetValue()) 
178   
179           
180          return spin_num, spin_name 
 181   
182   
207   
208   
 231