Skip to content

Commit

Permalink
Unicode support: more base changes
Browse files Browse the repository at this point in the history
  • Loading branch information
bkpoon committed Aug 23, 2016
1 parent 2948f6c commit 0c533d8
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 18 deletions.
8 changes: 5 additions & 3 deletions cootbx/interactive_edit.py
Expand Up @@ -5,6 +5,8 @@
import os
import sys

from libtbx.utils import to_str

t_wait = 250 # in milliseconds

#-----------------------------------------------------------------------
Expand Down Expand Up @@ -110,7 +112,7 @@ def __init__ (self, pdb_file, map_file, needs_rebuild=False) :
toolbar.insert(maps_button, -1)
maps_button.connect("clicked", self.OnNewMaps)
maps_button.show()
self._imol = read_pdb(pdb_file)
self._imol = read_pdb(to_str(pdb_file))
set_molecule_bonds_colour_map_rotation(self._imol, 30)
self._map_mols = []
self.load_maps(map_file)
Expand All @@ -130,9 +132,9 @@ def load_maps (self, map_file) :
close_molecule(imol)
else :
set_colour_map_rotation_for_map(10)
print "Loading %s" % map_file
print "Loading %s" % to_str(map_file)
self._map_mols = []
map_imol = auto_read_make_and_draw_maps(map_file)
map_imol = auto_read_make_and_draw_maps(to_str(map_file))
if (isinstance(map_imol, int)) :
# XXX this may be dangerous, but auto_read_make_and_draw_maps only returns
# the last imol
Expand Down
11 changes: 7 additions & 4 deletions cootbx/ligand_checklist.py
Expand Up @@ -4,6 +4,8 @@
import os
import sys

from libtbx.utils import to_str

t_wait = 250

def start_coot_and_wait (
Expand All @@ -29,6 +31,7 @@ def start_coot_and_wait (
base_script = __file__.replace(".pyc", ".py")
ligand_xyzs = []
for pdb_file in ligand_files :
pdb_file = to_str(pdb_file)
pdb_in = file_reader.any_file(pdb_file, force_type="pdb")
pdb_in.assert_file_type("pdb")
coords = pdb_in.file_object.atoms().extract_xyz()
Expand All @@ -39,10 +42,10 @@ def start_coot_and_wait (
f.write("\n")
f.write("import coot\n")
cootbx.write_disable_nomenclature_errors(f)
f.write("read_pdb(\"%s\")\n" % pdb_file)
f.write("auto_read_make_and_draw_maps(\"%s\")\n" % map_file)
f.write("read_pdb(\"%s\")\n" % to_str(pdb_file))
f.write("auto_read_make_and_draw_maps(\"%s\")\n" % to_str(map_file))
for cif_file in cif_files :
f.write("read_cif_dictionary(\"%s\")\n" % cif_file)
f.write("read_cif_dictionary(\"%s\")\n" % to_str(cif_file))
f.write("m = manager(%s)\n" % str(ligand_info))
f.close()
make_header("Ligand selection in Coot", log)
Expand Down Expand Up @@ -77,7 +80,7 @@ def __init__ (self, ligand_file_info) :
self.ligand_file_info = ligand_file_info
self.ligand_imols = []
for file_name, cc, xyz in ligand_file_info :
self.ligand_imols.append(read_pdb(file_name))
self.ligand_imols.append(read_pdb(to_str(file_name)))
self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
self.window.set_default_size(300, 200)
self.window.set_title(title)
Expand Down
12 changes: 7 additions & 5 deletions cootbx/view_refinement.py
@@ -1,6 +1,8 @@

from __future__ import division

from libtbx.utils import to_str

def load_refinement (
pdb_file,
map_file,
Expand All @@ -23,20 +25,20 @@ def load_refinement (
script_dir = os.path.dirname(script_file)
if (script_dir != "") :
os.chdir(script_dir)
read_pdb(pdb_file)
read_pdb(to_str(pdb_file))
if (peaks_file is not None) and (os.path.isfile(peaks_file)) :
imol = read_pdb(peaks_file)
imol = read_pdb(to_str(peaks_file))
set_mol_displayed(imol, False)
auto_read_make_and_draw_maps(map_file)
auto_read_make_and_draw_maps(to_str(map_file))
if (have_anom_map) :
imol = make_and_draw_map(map_file,"ANOM","PHANOM","",0,0)
imol = make_and_draw_map(to_str(map_file),"ANOM","PHANOM","",0,0)
set_contour_level_in_sigma(imol, 3.0)
if (have_residual_map) :
set_map_colour(imol, 0.0, 1.0, 1.0)
set_map_displayed(imol, False)
else :
set_map_colour(imol, 1.0, 1.0, 0.0)
if (have_residual_map) :
imol = make_and_draw_map(map_file,"ANOMDIFF","PHANOMDIFF","",0,1)
imol = make_and_draw_map(to_str(map_file),"ANOMDIFF","PHANOMDIFF","",0,1)
set_contour_level_in_sigma(imol, 3.0)
set_map_colour(imol, 1.0, 1.0, 0.0)
12 changes: 7 additions & 5 deletions cootbx/watch_file.py
Expand Up @@ -2,6 +2,8 @@
from __future__ import division
import os.path

from libtbx.utils import to_str

class watch_model (object) :
"""
Simple filesystem-only automatic loader for PDB files. Once invoked with
Expand All @@ -22,9 +24,9 @@ def check_file (self) :
if file_mtime > self.last_mtime :
if self.model_imol is not None :
clear_and_update_molecule_from_file(self.model_imol,
self.file_name)
to_str(self.file_name))
else :
self.model_imol = read_pdb(self.file_name)
self.model_imol = read_pdb(to_str(self.file_name))
self.last_mtime = file_mtime


Expand Down Expand Up @@ -56,16 +58,16 @@ def update_files (self) :
import coot # import dependency
if (self.model_imol is not None) :
clear_and_update_molecule_from_file(self.model_imol,
self.pdb_file)
to_str(self.pdb_file))
else :
self.model_imol = read_pdb(self.pdb_file)
self.model_imol = read_pdb(to_str(self.pdb_file))
if (len(self.map_imols) > 0) :
set_colour_map_rotation_for_map(0)
for imol in self._map_mols :
close_molecule(imol)
else :
set_colour_map_rotation_for_map(10)
map_imol = auto_read_make_and_draw_maps(self.map_file)
map_imol = auto_read_make_and_draw_maps(to_str(self.map_file))
if (isinstance(map_imol, int)) :
# XXX this may be dangerous, but auto_read_make_and_draw_maps only returns
# the last imol
Expand Down
4 changes: 3 additions & 1 deletion cootbx/xmlrpc_server.py
Expand Up @@ -16,6 +16,8 @@
import traceback
import os

from libtbx.utils import to_str

try :
import coot_python
except Exception, e :
Expand Down Expand Up @@ -94,7 +96,7 @@ def update_model (self, pdb_file) :
"""
import coot
if (self.current_imol is None) :
self.current_imol = read_pdb(pdb_file)
self.current_imol = read_pdb(to_str(pdb_file))
else :
clear_and_update_molecule_from_file(self.current_imol,
pdb_file)
Expand Down

0 comments on commit 0c533d8

Please sign in to comment.