Author: bugman Date: Thu Nov 22 10:33:30 2012 New Revision: 18017 URL: http://svn.gna.org/viewcvs/relax?rev=18017&view=rev Log: The PyMOL and Molmol open_pdb() methods now check for the absolute file path. If the PDB file cannot be found on the current or relative paths, then the absolute file path is also checked for and used if the PDB file can be found there. This allows results and save files to be in non-standard locations. Modified: branches/frame_order_testing/generic_fns/molmol.py branches/frame_order_testing/generic_fns/pymol_control.py Modified: branches/frame_order_testing/generic_fns/molmol.py URL: http://svn.gna.org/viewcvs/relax/branches/frame_order_testing/generic_fns/molmol.py?rev=18017&r1=18016&r2=18017&view=diff ============================================================================== --- branches/frame_order_testing/generic_fns/molmol.py (original) +++ branches/frame_order_testing/generic_fns/molmol.py Thu Nov 22 10:33:30 2012 @@ -26,7 +26,7 @@ import dep_check # Python module imports. -from os import sep +from os import F_OK, access, sep PIPE, Popen = None, None if dep_check.subprocess_module: from subprocess import PIPE, Popen @@ -127,20 +127,36 @@ open_files = [] for model in cdp.structure.structural_data: for mol in model.mol: - # The file path. - file = mol.file_name - if mol.file_path: - file = mol.file_path + sep + file + # The file path as the current directory. + file_path = None + if access(mol.file_name, F_OK): + file_path = mol.file_name + + # The file path using the relative path. + if file_path == None and hasattr(mol, 'file_path') and mol.file_path != None: + file_path = mol.file_path + sep + mol.file_name + if not access(file_path, F_OK): + file_path = None + + # The file path using the relative path. + if file_path == None and hasattr(mol, 'file_path_abs') and mol.file_path_abs != None: + file_path = mol.file_path_abs + sep + mol.file_name + if not access(file_path, F_OK): + file_path = None + + # Fall back. + if file_path == None: + file_path = mol.file_name # Already loaded. - if file in open_files: + if file_path in open_files: continue # Open the file in Molmol. - self.exec_cmd("ReadPdb " + file) + self.exec_cmd("ReadPdb " + file_path) # Add to the open file list. - open_files.append(file) + open_files.append(file_path) def running(self): Modified: branches/frame_order_testing/generic_fns/pymol_control.py URL: http://svn.gna.org/viewcvs/relax/branches/frame_order_testing/generic_fns/pymol_control.py?rev=18017&r1=18016&r2=18017&view=diff ============================================================================== --- branches/frame_order_testing/generic_fns/pymol_control.py (original) +++ branches/frame_order_testing/generic_fns/pymol_control.py Thu Nov 22 10:33:30 2012 @@ -30,7 +30,7 @@ import pymol from math import pi from numpy import float64, transpose, zeros -from os import sep +from os import F_OK, access, sep PIPE, Popen = None, None if dep_check.subprocess_module: from subprocess import PIPE, Popen @@ -147,20 +147,46 @@ open_files = [] for model in cdp.structure.structural_data: for mol in model.mol: - # The file path. - file = mol.file_name - if mol.file_path: - file = mol.file_path + sep + file + # The file path as the current directory. + file_path = None + if access(mol.file_name, F_OK): + file_path = mol.file_name + print "A" + print file_path + + # The file path using the relative path. + if file_path == None and hasattr(mol, 'file_path') and mol.file_path != None: + file_path = mol.file_path + sep + mol.file_name + print "b" + print file_path + if not access(file_path, F_OK): + file_path = None + + # The file path using the relative path. + if file_path == None and hasattr(mol, 'file_path_abs') and mol.file_path_abs != None: + file_path = mol.file_path_abs + sep + mol.file_name + print "c" + print file_path + if not access(file_path, F_OK): + file_path = None + + # Fall back. + if file_path == None: + file_path = mol.file_name # Already loaded. - if file in open_files: + if file_path in open_files: continue + # Already loaded. + if file_path in open_files: + continue + # Open the file in PyMOL. - self.exec_cmd("load " + file) + self.exec_cmd("load " + file_path) # Add to the open file list. - open_files.append(file) + open_files.append(file_path) def running(self):