本文整理汇总了Python中xia2.Handlers.Streams.Debug类的典型用法代码示例。如果您正苦于以下问题:Python Debug类的具体用法?Python Debug怎么用?Python Debug使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Debug类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: close_wait
def close_wait(self):
'''Close the standard input channel and wait for the standard
output to stop. Note that the results can still be obtained through
self.get_all_output()...'''
self.close()
while True:
line = self.output()
if not line:
break
if self._log_file:
# close the existing log file: also add a comment at the end containing the
# command-line (replacing working directory & executable path for brevity)
command_line = '%s ' % os.path.split(self._executable)[-1]
for c in self._command_line:
command_line += ' \'%s\'' % c.replace(self._working_directory + os.sep, '')
self._log_file.write('# command line:\n')
self._log_file.write('# %s\n' % command_line)
self._log_file.close()
self._log_file = None
from xia2.Handlers.Streams import Debug
with open(self._log_file_name, 'rb') as f:
lines = f.readlines()
n = min(50, len(lines))
Debug.write('Last %i lines of %s:' %(n, self._log_file_name))
for line in lines[-n:]:
Debug.write(line.rstrip('\n'), strip=False)
self.cleanup()
示例2: _integrate_finish
def _integrate_finish(self):
'''Finish the integration - if necessary performing reindexing
based on the pointgroup and the reindexing operator.'''
if self._intgr_reindex_operator is None and \
self._intgr_spacegroup_number == lattice_to_spacegroup(
self.get_integrater_refiner().get_refiner_lattice()):
return self._mosflm_hklout
if self._intgr_reindex_operator is None and \
self._intgr_spacegroup_number == 0:
return self._mosflm_hklout
Debug.write('Reindexing to spacegroup %d (%s)' % \
(self._intgr_spacegroup_number,
self._intgr_reindex_operator))
hklin = self._mosflm_hklout
reindex = Reindex()
reindex.set_working_directory(self.get_working_directory())
auto_logfiler(reindex)
reindex.set_operator(self._intgr_reindex_operator)
if self._intgr_spacegroup_number:
reindex.set_spacegroup(self._intgr_spacegroup_number)
hklout = '%s_reindex.mtz' % hklin[:-4]
reindex.set_hklin(hklin)
reindex.set_hklout(hklout)
reindex.reindex()
return hklout
示例3: _integrate_select_images_wedges
def _integrate_select_images_wedges(self):
'''Select correct images based on image headers.'''
phi_width = self.get_phi_width()
images = self.get_matching_images()
# characterise the images - are there just two (e.g. dna-style
# reference images) or is there a full block?
wedges = []
if len(images) < 3:
# work on the assumption that this is a reference pair
wedges.append(images[0])
if len(images) > 1:
wedges.append(images[1])
else:
block_size = min(len(images), int(math.ceil(5/phi_width)))
Debug.write('Adding images for indexer: %d -> %d' % \
(images[0], images[block_size - 1]))
wedges.append((images[0], images[block_size - 1]))
if int(90.0 / phi_width) + block_size in images:
# assume we can add a wedge around 45 degrees as well...
Debug.write('Adding images for indexer: %d -> %d' % \
(int(45.0 / phi_width) + images[0],
int(45.0 / phi_width) + images[0] +
block_size - 1))
Debug.write('Adding images for indexer: %d -> %d' % \
(int(90.0 / phi_width) + images[0],
int(90.0 / phi_width) + images[0] +
block_size - 1))
wedges.append(
(int(45.0 / phi_width) + images[0],
int(45.0 / phi_width) + images[0] + block_size - 1))
wedges.append(
(int(90.0 / phi_width) + images[0],
int(90.0 / phi_width) + images[0] + block_size - 1))
else:
# add some half-way anyway
first = (len(images) // 2) - (block_size // 2) + images[0] - 1
if first > wedges[0][1]:
last = first + block_size - 1
Debug.write('Adding images for indexer: %d -> %d' % \
(first, last))
wedges.append((first, last))
if len(images) > block_size:
Debug.write('Adding images for indexer: %d -> %d' % \
(images[- block_size], images[-1]))
wedges.append((images[- block_size], images[-1]))
return wedges
示例4: _index_remove_masked_regions
def _index_remove_masked_regions(self):
if not PhilIndex.params.xia2.settings.untrusted_rectangle_indexing:
return
untrusted_rectangle_indexing \
= PhilIndex.params.xia2.settings.untrusted_rectangle_indexing
limits = untrusted_rectangle_indexing
spot_xds = []
removed = 0
lines = open(self._indxr_payload['SPOT.XDS'], 'rb').readlines()
for record in lines:
if not record.strip():
continue
remove = False
x, y, phi, i = map(float, record.split()[:4])
for limits in untrusted_rectangle_indexing:
if x > limits[0] and x < limits[1] and \
y > limits[2] and y < limits[3]:
removed += 1
remove = True
break
if not remove:
spot_xds.append('%s' % record)
Debug.write('Removed %d peaks from SPOT.XDS' % removed)
masked_spot_xds = os.path.splitext(self._indxr_payload['SPOT.XDS'])[0] + '_masked.XDS'
with open(masked_spot_xds, 'wb') as f:
f.writelines(spot_xds)
self._indxr_payload['SPOT.XDS'] = masked_spot_xds
return
示例5: run
def run(self):
from xia2.Handlers.Streams import Debug
Debug.write('Running dials.reindex')
wd = self.get_working_directory()
self.clear_command_line()
if self._experiments_filename is not None:
self.add_command_line(self._experiments_filename)
self._reindexed_experiments_filename = os.path.join(
wd, "%d_experiments_reindexed.json" %self.get_xpid())
self.add_command_line(
"output.experiments=%s" %self._reindexed_experiments_filename)
if self._indexed_filename is not None:
self.add_command_line(self._indexed_filename)
self._reindexed_reflections_filename = os.path.join(
wd, "%d_reflections_reindexed.pickle" %self.get_xpid())
self.add_command_line(
"output.reflections=%s" %self._reindexed_reflections_filename)
if self._reference_filename is not None:
self.add_command_line("reference=%s" % self._reference_filename)
if self._cb_op:
self.add_command_line("change_of_basis_op=%s" % self._cb_op)
if self._space_group:
self.add_command_line("space_group=%s" % self._space_group)
if self._hkl_offset is not None:
self.add_command_line("hkl_offset=%i,%i,%i" %self._hkl_offset)
self.start()
self.close_wait()
self.check_for_errors()
示例6: _setup
def _setup(self):
if self._is_setup:
return
self._is_setup = True
harvest_directory = self.generate_directory('Harvest')
self.setenv('HARVESTHOME', harvest_directory)
# create a USER environment variable, to allow harvesting
# in Mosflm to work (hacky, I know, but it really doesn't
# matter too much...
if not 'USER' in os.environ:
if 'USERNAME' in os.environ:
os.environ['USER'] = os.environ['USERNAME']
else:
os.environ['USER'] = 'xia2'
# define a local CCP4_SCR
ccp4_scr = tempfile.mkdtemp()
os.environ['CCP4_SCR'] = ccp4_scr
Debug.write('Created CCP4_SCR: %s' % ccp4_scr)
self._is_setup = True
return
示例7: __call__
def __call__(self, fp, images = None):
from xia2.Handlers.Streams import Debug
if images is None:
images = self.select_images(fp)
images_str = ' '.join(map(str, images))
if self._spot_file:
Debug.write('Running mosflm to autoindex from %s' %
self._spot_file)
else:
Debug.write('Running mosflm to autoindex from images %s' %
images_str)
self.start()
self.input('template "%s"' % fp.get_template())
self.input('directory "%s"' % fp.get_directory())
self.input('beam %f %f' % fp.get_beam_centre())
self.input('distance %f' % fp.get_distance())
self.input('wavelength %f' % fp.get_wavelength())
if self._spot_file:
self.input('autoindex dps refine image %s file %s' %
(images_str, self._spot_file))
else:
self.input('autoindex dps refine image %s' % images_str)
self.input('go')
self.close_wait()
from AutoindexHelpers import parse_index_log
return parse_index_log(self.get_all_output())
示例8: _index_select_images
def _index_select_images(self):
'''Select correct images based on image headers. This will in
general use the 20 frames. N.B. only if they have good
spots on them!'''
phi_width = self.get_phi_width()
images = self.get_matching_images()
# N.B. now bodging this to use up to 20 frames which have decent
# spots on, spaced from throughout the data set.
spacing = max(1, int(len(images) // 20))
selected = []
for j in range(0, len(images), spacing):
selected.append(images[j])
for image in selected[:20]:
ld = LabelitDistl()
ld.set_working_directory(self.get_working_directory())
auto_logfiler(ld)
ld.add_image(self.get_image_name(image))
ld.distl()
spots = ld.get_statistics(
self.get_image_name(image))['spots_good']
Debug.write('Image %d good spots %d' % (image, spots))
if spots > 10:
self.add_indexer_image_wedge(image)
return
示例9: _index_finish
def _index_finish(self):
'''Check that the autoindexing gave a convincing result, and
if not (i.e. it gave a centred lattice where a primitive one
would be correct) pick up the correct solution.'''
if self._indxr_input_lattice:
return
if self.get_indexer_sweep():
if self.get_indexer_sweep().get_user_lattice():
return
try:
status, lattice, matrix, cell = mosflm_check_indexer_solution(
self)
except:
return
if status is False or status is None:
return
# ok need to update internals...
self._indxr_lattice = lattice
self._indxr_cell = cell
Debug.write('Inserting solution: %s ' % lattice +
'%6.2f %6.2f %6.2f %6.2f %6.2f %6.2f' % cell)
self._indxr_replace(lattice, cell)
self._indxr_payload['mosflm_orientation_matrix'] = matrix
return
示例10: _index_select_images_small_molecule
def _index_select_images_small_molecule(self):
'''Select correct images based on image headers. This one is for
when you have small molecule data so want more images.'''
phi_width = self.get_phi_width()
images = self.get_matching_images()
Debug.write('Selected image %s' % images[0])
self.add_indexer_image_wedge(images[0])
offset = images[0] - 1
# add an image every 15 degrees up to 90 degrees
for j in range(6):
image_number = offset + int(15 * (j + 1) / phi_width)
if not image_number in images:
break
Debug.write('Selected image %s' % image_number)
self.add_indexer_image_wedge(image_number)
return
示例11: digest_template
def digest_template(template, images):
'''Digest the template and image numbers to copy as much of the
common characters in the numbers as possible to the template to
give smaller image numbers.'''
length = template.count('#')
format = '%%0%dd' % length
strings = [format % i for i in images]
offset = 0
if len(strings) > 1:
prefix = common_prefix(strings)
if prefix:
offset = int(prefix + '0' * (length - len(prefix)))
template = template.replace(len(prefix) * '#', prefix, 1)
images = [int(s.replace(prefix, '', 1)) for s in strings]
try:
template, images, offset = ensure_no_batches_numbered_zero(
template, images, offset)
except RuntimeError, e:
Debug.write('Throwing away image 0 from template %s' % template)
template, images, offset = ensure_no_batches_numbered_zero(
template, images[1:], offset)
示例12: run
def run(self):
from xia2.Handlers.Streams import Debug
Debug.write('Running xia2.integrate')
self.clear_command_line()
if self._phil_file is not None:
self.add_command_line('%s' % self._phil_file)
for arg in self._argv:
self.add_command_line(arg)
if self._nproc is not None:
self.set_cpu_threads(self._nproc)
self.add_command_line('nproc=%i' %self._nproc)
if self._njob is not None:
self.add_command_line('njob=%i' %self._njob)
if self._mp_mode is not None:
self.add_command_line('multiprocessing.mode=%s' %self._mp_mode)
self.start()
self.close_wait()
self.check_for_errors()
for line in self.get_all_output():
if 'Status: error' in line:
raise RuntimeError(line.split('error')[-1].strip())
return
示例13: run
def run(self):
from xia2.Handlers.Streams import Debug
Debug.write("Running cctbx.brehm_diederichs")
self.clear_command_line()
if self._asymmetric is not None:
assert isinstance(self._asymmetric, int)
self.add_command_line("asymmetric=%i" % self._asymmetric)
self.add_command_line("show_plot=False")
self.add_command_line("save_plot=True")
for filename in self._input_filenames:
self.add_command_line(filename)
self.start()
self.close_wait()
self.check_for_errors()
import os
results_filename = os.path.join(self.get_working_directory(), "reindex.txt")
assert os.path.exists(results_filename)
with open(results_filename, "rb") as f:
for line in f.readlines():
filename, reindex_op = line.strip().rsplit(" ", 1)
self._reindexing_dict[os.path.abspath(filename)] = reindex_op
return
示例14: run
def run(self):
assert(self._hklin)
cl = [self._hklin]
cl.append('nbins=%s' % self._nbins)
cl.append('rmerge=%s' % self._limit_rmerge)
cl.append('completeness=%s' % self._limit_completeness)
cl.append('cc_half=%s' % self._limit_cc_half)
cl.append('cc_half_significance_level=%s' % self._cc_half_significance_level)
cl.append('isigma=%s' % self._limit_isigma)
cl.append('misigma=%s' % self._limit_misigma)
if self._batch_range is not None:
cl.append('batch_range=%i,%i' % self._batch_range)
for c in cl:
self.add_command_line(c)
Debug.write('Resolution analysis: %s' % (' '.join(cl)))
self.start()
self.close_wait()
for record in self.get_all_output():
if 'Resolution rmerge' in record:
self._resolution_rmerge = float(record.split()[-1])
if 'Resolution completeness' in record:
self._resolution_completeness = float(record.split()[-1])
if 'Resolution cc_half' in record:
self._resolution_cc_half = float(record.split()[-1])
if 'Resolution I/sig' in record:
self._resolution_isigma = float(record.split()[-1])
if 'Resolution Mn(I/sig)' in record:
self._resolution_misigma = float(record.split()[-1])
return
示例15: set_spacegroup
def set_spacegroup(self, spacegroup):
'''A handler for the command-line option -spacegroup - this will
set the spacegroup and derive from this the pointgroup and lattice
appropriate for such...'''
from xia2.Handlers.Syminfo import Syminfo
spacegroup = spacegroup.upper()
# validate by deriving the pointgroup and lattice...
pointgroup = Syminfo.get_pointgroup(spacegroup)
lattice = Syminfo.get_lattice(spacegroup)
# assign
self._spacegroup = spacegroup
self._pointgroup = pointgroup
self._lattice = lattice
# debug print
from xia2.Handlers.Streams import Debug
Debug.write('Derived information from spacegroup flag: %s' % \
spacegroup)
Debug.write('Pointgroup: %s Lattice: %s' % (pointgroup, lattice))
# indicate that since this has been assigned, we do not wish to
# test it!
self.set_no_lattice_test(True)
return