Author: bugman Date: Tue Jan 21 10:23:35 2014 New Revision: 22032 URL: http://svn.gna.org/viewcvs/relax?rev=22032&view=rev Log: The structure.write_pdb user function can now handle a file instance for the file argument. This is for the Structure.test_bug_21522_master_record_atom_count system test, to allow a dummy file object to be used. This can also be useful for power users. Modified: trunk/pipe_control/structure/main.py trunk/user_functions/structure.py Modified: trunk/pipe_control/structure/main.py URL: http://svn.gna.org/viewcvs/relax/trunk/pipe_control/structure/main.py?rev=22032&r1=22031&r2=22032&view=diff ============================================================================== --- trunk/pipe_control/structure/main.py (original) +++ trunk/pipe_control/structure/main.py Tue Jan 21 10:23:35 2014 @@ -1179,8 +1179,8 @@ def write_pdb(file=None, dir=None, model_num=None, compress_type=0, force=False): """The PDB writing function. - @keyword file: The name of the PDB file to write. - @type file: str + @keyword file: The name of the PDB file to write. This can also be a file instance. + @type file: str or file instance @keyword dir: The directory where the PDB file will be placed. If set to None, then the file will be placed in the current directory. @type dir: str or None @keyword model_num: The model to place into the PDB file. If not supplied, then all models will be placed into the file. @@ -1198,15 +1198,17 @@ if not hasattr(cdp, 'structure'): raise RelaxError("No structural data is present in the current data pipe.") - # The file path. - file_path = get_file_path(file, dir) - - # Add '.pdb' to the end of the file path if it isn't there yet. - if not search(".pdb$", file_path): - file_path = file_path + '.pdb' + # Path handling. + if isinstance(file, str): + # The file path. + file = get_file_path(file, dir) + + # Add '.pdb' to the end of the file path if it isn't there yet. + if not search(".pdb$", file): + file = file + '.pdb' # Open the file for writing. - file = open_write_file(file_path, compress_type=compress_type, force=force) + file = open_write_file(file, compress_type=compress_type, force=force) # Write the structures. cdp.structure.write_pdb(file, model_num=model_num) Modified: trunk/user_functions/structure.py URL: http://svn.gna.org/viewcvs/relax/trunk/user_functions/structure.py?rev=22032&r1=22031&r2=22032&view=diff ============================================================================== --- trunk/user_functions/structure.py (original) +++ trunk/user_functions/structure.py Tue Jan 21 10:23:35 2014 @@ -1058,7 +1058,7 @@ uf.title_short = "PDB writing." uf.add_keyarg( name = "file", - py_type = "str", + py_type = "str_or_inst", arg_type = "file sel", desc_short = "file name", desc = "The name of the PDB file.",