def test_molecule_loop(self): """Test the proper operation of the molecule loop with molecule selection. The function tested is pipe_control.mol_res_spin.molecule_loop(). """ # Loop over the molecules. for mol in mol_res_spin.molecule_loop('#RNA'): # Test the molecule name. self.assertEqual(mol.name, 'RNA') # Test loop length. self.assertEqual(len(list(mol_res_spin.molecule_loop('#RNA'))), 1)
def update(self, pipe_name=None): """Update the tree view using the given data pipe.""" # Acquire the pipe and spin locks. status.pipe_lock.acquire('spin viewer window') status.spin_lock.acquire('spin viewer window') try: # The data pipe. if not pipe_name: pipe = cdp else: pipe = get_pipe(pipe_name) # No data pipe, so delete everything and return. if not pipe: self.tree.DeleteChildren(self.root) return # Update the molecules. for mol, mol_id in molecule_loop(return_id=True): self.update_mol(mol, mol_id) # Remove any deleted molecules. self.prune_mol() # Release the locks. finally: status.pipe_lock.release('spin viewer window') status.spin_lock.release('spin viewer window')
def update_data(self): """Method called from self.build_element_safe() to update the list data.""" # Expand the number of rows to match the number of molecules, and add the data. i = 0 for mol, mol_id in molecule_loop(return_id=True): # Set the index. self.element.InsertStringItem(i, str_to_gui(mol_id)) # Set the molecule name. if mol.name != None: self.element.SetStringItem(i, 1, str_to_gui(mol.name)) # Set the molecule type. if hasattr(mol, 'type'): self.element.SetStringItem(i, 2, str_to_gui(mol.type)) # Set the thiol state. if hasattr(cdp, 'exp_info') and hasattr(cdp.exp_info, 'thiol_state'): self.element.SetStringItem( i, 3, str_to_gui(cdp.exp_info.thiol_state)) # Increment the counter. i += 1
def is_complete(self): """Determine if the data input is complete. @return: A list of all the missing components. @rtype: list of str """ # Initialise. missing = [] # Relaxation data metadata. if hasattr(cdp, 'ri_ids'): # Loop over the data. for i in range(len(cdp.ri_ids)): # Check the peak intensity types. if not hasattr(cdp, 'exp_info') or not hasattr( cdp.exp_info, 'peak_intensity_type' ) or not cdp.ri_ids[i] in cdp.exp_info.peak_intensity_type: missing.append( "The peak intensity type for the relaxation data ID '%s'." % cdp.ri_ids[i]) # Check the temperature calibration methods. if not hasattr(cdp, 'exp_info') or not hasattr( cdp.exp_info, 'temp_calibration' ) or not cdp.ri_ids[i] in cdp.exp_info.temp_calibration: missing.append( "The temperature calibration method for the relaxation data ID '%s'." % cdp.ri_ids[i]) # Check the temperature control methods. if not hasattr(cdp, 'exp_info') or not hasattr( cdp.exp_info, 'temp_control' ) or not cdp.ri_ids[i] in cdp.exp_info.temp_control: missing.append( "The temperature control method for the relaxation data ID '%s'." % cdp.ri_ids[i]) # Loop over the molecules. for mol, mol_id in molecule_loop(return_id=True): # No name. if mol.name == None: missing.append("The name of the molecule for %s." % mol_id) continue # No molecule type. if not hasattr(mol, 'type') or mol.type == None: missing.append("The type of the molecule %s." % mol_id) # No thiol state. if not hasattr(cdp, 'exp_info') or not hasattr( cdp.exp_info, 'thiol_state'): missing.append("The thiol state of the molecule %s." % mol_id) # Return the list of missing data. return missing
def test_molecule_loop_no_selection(self): """Test the proper operation of the molecule loop when no selection is present. The function tested is pipe_control.mol_res_spin.molecule_loop(). """ # Molecule data. name = ['Ap4Aase', 'RNA'] # Loop over the molecules. i = 0 for mol in mol_res_spin.molecule_loop(): # Test the molecule names. self.assertEqual(mol.name, name[i]) # Increment i. i = i + 1 # Test loop length. self.assertEqual(len(list(mol_res_spin.molecule_loop())), 2)
def is_complete(self): """Determine if the data input is complete. @return: A list of all the missing components. @rtype: list of str """ # Initialise. missing = [] # Relaxation data metadata. if hasattr(cdp, 'ri_ids'): # Loop over the data. for i in range(len(cdp.ri_ids)): # Check the peak intensity types. if not hasattr(cdp, 'exp_info') or not hasattr(cdp.exp_info, 'peak_intensity_type') or not cdp.ri_ids[i] in cdp.exp_info.peak_intensity_type.keys(): missing.append("The peak intensity type for the relaxation data ID '%s'." % cdp.ri_ids[i]) # Check the temperature calibration methods. if not hasattr(cdp, 'exp_info') or not hasattr(cdp.exp_info, 'temp_calibration') or not cdp.ri_ids[i] in cdp.exp_info.temp_calibration.keys(): missing.append("The temperature calibration method for the relaxation data ID '%s'." % cdp.ri_ids[i]) # Check the temperature control methods. if not hasattr(cdp, 'exp_info') or not hasattr(cdp.exp_info, 'temp_control') or not cdp.ri_ids[i] in cdp.exp_info.temp_control.keys(): missing.append("The temperature control method for the relaxation data ID '%s'." % cdp.ri_ids[i]) # Loop over the molecules. for mol, mol_id in molecule_loop(return_id=True): # No name. if mol.name == None: missing.append("The name of the molecule for %s." % mol_id) continue # No molecule type. if not hasattr(mol, 'type') or mol.type == None: missing.append("The type of the molecule %s." % mol_id) # No thiol state. if not hasattr(cdp, 'exp_info') or not hasattr(cdp.exp_info, 'thiol_state'): missing.append("The thiol state of the molecule %s." % mol_id) # Return the list of missing data. return missing
def test_molecule_loop_no_data(self): """Test the proper operation of the molecule loop when no data is present. The function tested is pipe_control.mol_res_spin.molecule_loop(). """ # Reset relax. reset() # Add a data pipe to the data store. ds.add(pipe_name='orig', pipe_type='mf') # Loop over the molecules. i = 0 for molecule in mol_res_spin.molecule_loop(): i = i + 1 # Test loop length. self.assertEqual(i, 0)
def update_data(self): """Method called from self.build_element_safe() to update the list data.""" # Expand the number of rows to match the number of molecules, and add the data. i = 0 for mol, mol_id in molecule_loop(return_id=True): # Set the index. self.element.InsertStringItem(i, str_to_gui(mol_id)) # Set the molecule name. if mol.name != None: self.element.SetStringItem(i, 1, str_to_gui(mol.name)) # Set the molecule type. if hasattr(mol, 'type'): self.element.SetStringItem(i, 2, str_to_gui(mol.type)) # Set the thiol state. if hasattr(cdp, 'exp_info') and hasattr(cdp.exp_info, 'thiol_state'): self.element.SetStringItem(i, 3, str_to_gui(cdp.exp_info.thiol_state)) # Increment the counter. i += 1
def is_complete(self): """Determine if the data input is complete. @return: The answer to the question. @rtype: bool """ # Loop over the molecules. for mol in molecule_loop(): # No name. if mol.name == None: return False # No molecule type. if not hasattr(mol, 'type') or mol.type == None: return False # No thiol state. if not hasattr(cdp, 'exp_info') or not hasattr(cdp.exp_info, 'thiol_state'): return False # Data input is complete. return True
def is_complete(self): """Determine if the data input is complete. @return: The answer to the question. @rtype: bool """ # Loop over the molecules. for mol in molecule_loop(): # No name. if mol.name == None: return False # No molecule type. if not hasattr(mol, 'type') or mol.type == None: return False # No thiol state. if not hasattr(cdp, 'exp_info') or not hasattr( cdp.exp_info, 'thiol_state'): return False # Data input is complete. return True
def fail_test(): for molecule in mol_res_spin.molecule_loop(): pass