本文整理匯總了Python中xia2.Handlers.Flags.Flags類的典型用法代碼示例。如果您正苦於以下問題:Python Flags類的具體用法?Python Flags怎麽用?Python Flags使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了Flags類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: _updated_aimless
def _updated_aimless(self):
'''Generate a correctly configured Aimless...'''
aimless = None
if not self._scalr_corrections:
aimless = self._factory.Aimless()
else:
aimless = self._factory.Aimless(
partiality_correction = self._scalr_correct_partiality,
absorption_correction = self._scalr_correct_absorption,
decay_correction = self._scalr_correct_decay)
if Flags.get_microcrystal():
# fiddly little data sets - allow more rapid scaling...
aimless.set_scaling_parameters('rotation', 2.0)
if self._scalr_correct_decay:
aimless.set_bfactor(bfactor=True, brotation = 2.0)
if Flags.get_small_molecule():
aimless.set_scaling_parameters('rotation', 15.0)
aimless.set_bfactor(bfactor=False)
aimless.set_surface_tie(PhilIndex.params.ccp4.aimless.surface_tie)
aimless.set_surface_link(PhilIndex.params.ccp4.aimless.surface_link)
return aimless
示例2: _prepare_pointless_hklin
def _prepare_pointless_hklin(working_directory,
hklin,
phi_width):
'''Prepare some data for pointless - this will take only 180 degrees
of data if there is more than this (through a "rebatch" command) else
will simply return hklin.'''
# also remove blank images?
if not Flags.get_microcrystal() and not Flags.get_small_molecule():
Debug.write('Excluding blank images')
hklout = os.path.join(
working_directory,
'%s_noblank.mtz' % (os.path.split(hklin)[-1][:-4]))
FileHandler.record_temporary_file(hklout)
hklin = remove_blank(hklin, hklout)
# find the number of batches
md = Mtzdump()
md.set_working_directory(working_directory)
auto_logfiler(md)
md.set_hklin(hklin)
md.dump()
batches = max(md.get_batches()) - min(md.get_batches())
phi_limit = 180
if batches * phi_width < phi_limit or Flags.get_small_molecule():
return hklin
hklout = os.path.join(
working_directory,
'%s_prepointless.mtz' % (os.path.split(hklin)[-1][:-4]))
rb = Rebatch()
rb.set_working_directory(working_directory)
auto_logfiler(rb)
rb.set_hklin(hklin)
rb.set_hklout(hklout)
first = min(md.get_batches())
last = first + int(phi_limit / phi_width)
Debug.write('Preparing data for pointless - %d batches (%d degrees)' % \
((last - first), phi_limit))
rb.limit_batches(first, last)
# we will want to delete this one exit
FileHandler.record_temporary_file(hklout)
return hklout
示例3: merge
def merge(self):
'''Actually merge the already scaled reflections.'''
self.check_hklin()
self.check_hklout()
if not self._onlymerge:
raise RuntimeError, 'for scaling use scale()'
if not self._scalepack:
self.set_task('Merging scaled reflections from %s => %s' % \
(os.path.split(self.get_hklin())[-1],
os.path.split(self.get_hklout())[-1]))
else:
self.set_task('Merging reflections from %s => scalepack %s' % \
(os.path.split(self.get_hklin())[-1],
os.path.split(self.get_hklout())[-1]))
self._xmlout = os.path.join(self.get_working_directory(),
'%d_aimless.xml' % self.get_xpid())
self.start()
self.input('xmlout %d_aimless.xml' % self.get_xpid())
if not Flags.get_small_molecule():
self.input('bins 20')
self.input('run 1 all')
self.input('scales constant')
self.input('initial unity')
self.input('sdcorrection both noadjust 1.0 0.0 0.0')
if self._anomalous:
self.input('anomalous on')
else:
self.input('anomalous off')
if self._scalepack:
self.input('output polish unmerged')
self.input('output unmerged')
self.close_wait()
# check for errors
try:
self.check_for_errors()
self.check_ccp4_errors()
self.check_aimless_errors()
status = self.get_ccp4_status()
if 'Error' in status:
raise RuntimeError, '[AIMLESS] %s' % status
except RuntimeError, e:
try:
os.remove(self.get_hklout())
except:
pass
raise e
示例4: run
def run(self):
from xia2.Handlers.Streams import Debug
Debug.write('Running %s' %self.get_executable())
self.clear_command_line()
self.add_command_line(self._sweep_filename)
self.add_command_line(self._spot_filename)
nproc = Flags.get_parallel()
self.set_cpu_threads(nproc)
self.add_command_line('nproc=%i' % nproc)
for scan_range in self._scan_ranges:
self.add_command_line('scan_range=%d,%d' % scan_range)
if self._phil_file is not None:
self.add_command_line("%s" %self._phil_file)
self._optimized_filename = os.path.join(
self.get_working_directory(), '%d_optimized_datablock.json' %self.get_xpid())
self.add_command_line("output.datablock=%s" %self._optimized_filename)
self.start()
self.close_wait()
self.check_for_errors()
records = self.get_all_output()
assert os.path.exists(self._optimized_filename), self._optimized_filename
return
示例5: resolution_merged_isigma
def resolution_merged_isigma(self, limit = None, log = None):
'''Compute a resolution limit where either Mn(I/sigma) = 1.0 (limit if
set) or the full extent of the data.'''
if limit is None:
limit = Flags.get_misigma()
bins, ranges = self.get_resolution_bins()
misigma_s = get_positive_values(
[self.calculate_merged_isigma(bin) for bin in bins])
s_s = [1.0 / (r[0] * r[0]) for r in ranges][:len(misigma_s)]
if min(misigma_s) > limit:
return 1.0 / math.sqrt(max(s_s))
misigma_f = log_fit(s_s, misigma_s, 6)
if log:
fout = open(log, 'w')
for j, s in enumerate(s_s):
d = 1.0 / math.sqrt(s)
o = misigma_s[j]
m = misigma_f[j]
fout.write('%f %f %f %f\n' % (s, d, o, m))
fout.close()
try:
r_misigma = 1.0 / math.sqrt(
interpolate_value(s_s, misigma_f, limit))
except:
r_misigma = 1.0 / math.sqrt(max(s_s))
return r_misigma
示例6: update
def update(self):
'''Check to see if any more frames have appeared - if they
have update myself and reset.'''
images = find_matching_images(self._template,
self._directory)
if len(images) > len(self._images):
self._images = images
from xia2.Schema import load_imagesets
imagesets = load_imagesets(
self._template, self._directory, id_image=self._id_image,
use_cache=False, reversephi=Flags.get_reversephi())
max_images = 0
best_sweep = None
for imageset in imagesets:
scan = imageset.get_scan()
if scan is None: continue
if imageset.get_scan().get_num_images() > max_images:
best_sweep = imageset
self._imageset = best_sweep
return
示例7: reindex
def reindex(self):
'''Actually perform the reindexing.'''
if PhilIndex.params.ccp4.reindex.program == 'reindex':
return self.reindex_old()
self.check_hklin()
self.check_hklout()
if not self._spacegroup and not self._operator:
raise RuntimeError, 'reindex requires spacegroup or operator'
if self._operator:
self._operator = self._operator.replace('[', '').replace(']', '')
Debug.write('Reindex... %s %s' % (self._spacegroup, self._operator))
if self._spacegroup and Flags.get_small_molecule() and False:
if not self._operator or self._operator.replace(' ', '') == 'h,k,l':
return self.cctbx_reindex()
self.start()
if self._spacegroup:
if type(self._spacegroup) == type(0):
spacegroup = Syminfo.spacegroup_number_to_name(
self._spacegroup)
elif self._spacegroup[0] in '0123456789':
spacegroup = Syminfo.spacegroup_number_to_name(
int(self._spacegroup))
else:
spacegroup = self._spacegroup
self.input('spacegroup \'%s\'' % spacegroup)
if self._operator:
# likewise
self.input('reindex \'%s\'' % self._operator)
else:
self.input('reindex \'h,k,l\'')
self.close_wait()
# check for errors
try:
self.check_for_errors()
except RuntimeError, e:
try:
os.remove(self.get_hklout())
except:
pass
raise e
示例8: __init__
def __init__(self):
# set up the object ancestors...
DriverInstance.__class__.__init__(self)
# now set myself up...
self._parallel = Flags.get_parallel()
if self._parallel <= 1:
self.set_executable('xscale')
else:
self.set_executable('xscale_par')
self._version = 'new'
# overall information
self._resolution_shells = ''
self._cell = None
self._spacegroup_number = None
self._reindex_matrix = None
# corrections to apply - N.B. default values come from the
# factory function default arguments...
self._correct_decay = correct_decay
self._correct_absorption = correct_absorption
self._correct_modulation = correct_modulation
# input reflections information - including grouping information
# in the same way as the .xinfo files - through the wavelength
# names, which will be used for the output files.
self._input_reflection_files = []
self._input_reflection_wavelength_names = []
self._input_resolution_ranges = []
# these are generated at the run time
self._transposed_input = { }
self._transposed_input_keys = []
# output
self._output_reflection_files = { }
self._remove = []
# decisions about the scaling
self._crystal = None
self._zero_dose = False
self._anomalous = True
self._merge = False
# scale factor output
self._scale_factor = 1.0
# Rmerge values - for the scale model analysis - N.B. get
# one for each data set, obviously...
self._rmerges = { }
return
示例9: _index_prepare
def _index_prepare(self):
if self._indxr_images == []:
self._index_select_images()
if self._mosflm_autoindex_thresh is None and \
Flags.get_microcrystal():
self._mosflm_autoindex_thresh = 5
return
示例10: __init__
def __init__(self, params=None):
super(XDSIntegrateWrapper, self).__init__()
# phil parameters
if not params:
from xia2.Handlers.Phil import master_phil
params = master_phil.extract().xds.integrate
self._params = params
# now set myself up...
self._parallel = Flags.get_parallel()
self.set_cpu_threads(self._parallel)
if self._parallel <= 1:
self.set_executable('xds')
else:
self.set_executable('xds_par')
# generic bits
self._data_range = (0, 0)
self._input_data_files = { }
self._output_data_files = { }
self._input_data_files_list = ['X-CORRECTIONS.cbf',
'Y-CORRECTIONS.cbf',
'BLANK.cbf',
'BKGPIX.cbf',
'GAIN.cbf',
'XPARM.XDS']
self._output_data_files_list = ['FRAME.cbf']
self._refined_xparm = False
self._updates = { }
# note well - INTEGRATE.HKL is not included in this list
# because it is likely to be very large - this is treated
# separately...
self._integrate_hkl = None
# FIXME these will also be wanted by the full integrater
# interface I guess?
self._mean_mosaic = None
self._min_mosaic = None
self._max_mosaic = None
return
示例11: get_cell
def get_cell(self):
'''Compute an average cell.'''
if len(self._cells) < 1:
raise RuntimeError, 'no input unit cell parameters'
# check that the input cells are reasonably uniform -
# be really relaxed and allow 5% variation!
average_cell = [self._cells[0][j] for j in range(6)]
number_cells = 1
for j in range(1, len(self._cells)):
cell = self._cells[j]
for k in range(6):
average = average_cell[k] / number_cells
if math.fabs((cell[k] - average) / average) > 0.05 \
and not Flags.get_relax():
raise RuntimeError, 'incompatible unit cells'
average = average_cell[k] / number_cells
if math.fabs((cell[k] - average) / average) > 0.2:
raise RuntimeError, 'very incompatible unit cells'
# it was ok to remember for later on..
for k in range(6):
average_cell[k] += cell[k]
number_cells += 1
cellparm_inp = open(os.path.join(
self.get_working_directory(), 'CELLPARM.INP'), 'w')
for j in range(len(self._cells)):
cell = self._cells[j]
n_ref = self._n_refs[j]
cellparm_inp.write('UNIT_CELL_CONSTANTS=')
cellparm_inp.write(
'%.3f %.3f %.3f %.3f %.3f %.3f WEIGHT=%d\n' % \
(cell[0], cell[1], cell[2], cell[3], cell[4], cell[5],
n_ref))
cellparm_inp.close()
self.start()
self.close_wait()
# FIXME need to look for errors in here
cellparm_lp = open(os.path.join(
self.get_working_directory(), 'CELLPARM.LP'), 'r')
data = cellparm_lp.readlines()
return map(float, data[-1].split()[:6])
示例12: new_resolution_unmerged_isigma
def new_resolution_unmerged_isigma(self, limit = None, log = None):
'''Compute a resolution limit where either I/sigma = 1.0 (limit if
set) or the full extent of the data.'''
if limit is None:
limit = Flags.get_isigma()
bins, ranges = self.get_resolution_bins()
isigma_s = get_positive_values(
[self.calculate_unmerged_isigma(bin) for bin in bins])
s_s = [1.0 / (r[0] * r[0]) for r in ranges][:len(isigma_s)]
if min(isigma_s) > limit:
return 1.0 / math.sqrt(max(s_s))
for _l, s in enumerate(isigma_s):
if s < limit:
break
if _l > 10 and _l < (len(isigma_s) - 10):
start = _l - 10
end = _l + 10
elif _l <= 10:
start = 0
end = 20
elif _l >= (len(isigma_s) - 10):
start = -20
end = -1
_s_s = s_s[start:end]
_isigma_s = isigma_s[start:end]
_isigma_f = log_fit(_s_s, _isigma_s, 3)
if log:
fout = open(log, 'w')
for j, s in enumerate(_s_s):
d = 1.0 / math.sqrt(s)
o = _isigma_s[j]
m = _isigma_f[j]
fout.write('%f %f %f %f\n' % (s, d, o, m))
fout.close()
try:
r_isigma = 1.0 / math.sqrt(interpolate_value(_s_s, _isigma_f,
limit))
except:
r_isigma = 1.0 / math.sqrt(max(_s_s))
return r_isigma
示例13: _index_select_images
def _index_select_images(self):
'''Select correct images based on image headers.'''
if Flags.get_small_molecule():
return self._index_select_images_small_molecule()
if Flags.get_microcrystal():
return self._index_select_images_microcrystal()
phi_width = self.get_phi_width()
images = self.get_matching_images()
if Flags.get_interactive():
selected_images = index_select_images_user(phi_width, images,
Chatter)
else:
selected_images = index_select_images_lone(phi_width, images)
for image in selected_images:
Debug.write('Selected image %s' % image)
self.add_indexer_image_wedge(image)
return
示例14: __init__
def __init__(self):
super(XDSScalerA, self).__init__()
self._sweep_information = { }
self._reference = None
# spacegroup and unit cell information - these will be
# derived from an average of all of the sweeps which are
# passed in
self._xds_spacegroup = None
self._factory = CCP4Factory()
self._chef_analysis_groups = { }
self._chef_analysis_times = { }
self._chef_analysis_resolutions = { }
self._user_resolution_limits = { }
# scaling correction choices - may be set one on the command line...
if Flags.get_scale_model():
self._scalr_correct_absorption = Flags.get_scale_model_absorption()
self._scalr_correct_modulation = Flags.get_scale_model_modulation()
self._scalr_correct_decay = Flags.get_scale_model_decay()
self._scalr_corrections = True
else:
self._scalr_correct_decay = True
self._scalr_correct_modulation = True
self._scalr_correct_absorption = True
self._scalr_corrections = True
return
示例15: migrate
def migrate(self, directory):
'''Migrate (or not) data to a local directory.'''
if not Flags.get_migrate_data():
# we will not migrate this data
return directory
if directory in self._data_migrate.keys():
# we have already migrated this data
return self._data_migrate[directory]
# create a directory to move data to...
self._data_migrate[directory] = tempfile.mkdtemp()
# copy all files in source directory to new directory
# retaining timestamps etc.
start_time = time.time()
migrated = 0
migrated_dir = 0
for f in os.listdir(directory):
# copy over only files....
if os.path.isfile(os.path.join(directory, f)):
shutil.copy2(os.path.join(directory, f),
self._data_migrate[directory])
migrated += 1
elif os.path.isdir(os.path.join(directory, f)):
shutil.copytree(os.path.join(directory, f),
os.path.join(self._data_migrate[directory],
f))
migrated_dir += 1
Debug.write('Migrated %d files from %s to %s' % \
(migrated, directory, self._data_migrate[directory]))
if migrated_dir > 0:
Debug.write('Migrated %d directories from %s to %s' % \
(migrated_dir, directory,
self._data_migrate[directory]))
end_time = time.time()
duration = end_time - start_time
Debug.write('Migration took %s' % \
time.strftime("%Hh %Mm %Ss", time.gmtime(duration)))
return self._data_migrate[directory]