def __init__(self, s): r_info = sgtbx.rot_mx_info(s.r()) t_info = sgtbx.translation_part_info(s) self.type = r_info.type() self.ev = r_info.ev() self.trans = t_info.intrinsic_part()
def __init__(self, s ): r_info = sgtbx.rot_mx_info( s.r() ) t_info = sgtbx.translation_part_info( s ) self.type = r_info.type() self.ev = r_info.ev() self.trans= t_info.intrinsic_part()
def rt_mx_analysis(s): print "<tr>" print "<td><tt>" + str(s) + "</tt>" r_info = sgtbx.rot_mx_info(s.r()) t_info = sgtbx.translation_part_info(s) if (r_info.type() == 1): print "<td>1<td>-<td>-<td>-" elif (r_info.type() == -1): print "<td>%d<td>-<td>-<td>%s" % ( r_info.type(), str(t_info.origin_shift())) elif (abs(r_info.type()) == 2): print "<td>%d<td>%s<td>%s<td>%s" % ( r_info.type(), str_ev(r_info.ev()), str(t_info.intrinsic_part()), str(t_info.origin_shift())) else: print "<td>%d^%d<td>%s<td>%s<td>%s" % ( r_info.type(), r_info.sense(), str_ev(r_info.ev()), str(t_info.intrinsic_part()), str(t_info.origin_shift())) print "</tr>"
def change_origin(self, origin): o = self.raw_origin - origin t_l = self.one_minus_r*o t_l = sgtbx.tr_vec((sg_t_den*t_l).as_int(), tr_den=sg_t_den) self.rt = sgtbx.rt_mx(self.r, self.t_i.plus(t_l).new_denominator(sg_t_den)) tr_info = sgtbx.translation_part_info(self.rt) self.origin = tr_info.origin_shift() self.t_i = tr_info.intrinsic_part()
def browse(self): for self.symbol in sgtbx.space_group_symbol_iterator(): self.sg = sgtbx.space_group(self.symbol.hall()).make_tidy() self.z2p_op = self.sg.z2p_op() self.sg_p = self.sg.change_basis(self.z2p_op) self.on_new_space_group() for self.op in self.sg_p: self.rot_info = self.op.r().info() self.tr_info = sgtbx.translation_part_info(self.op) if self.tr_info.origin_shift().is_zero(): continue self.on_new_symmetry()
def rt_mx_analysis(s): r_info = sgtbx.rot_mx_info(s.r()) t_info = sgtbx.translation_part_info(s) t_intrinsic = str(t_info.intrinsic_part().mod_positive()) t_shift = str(t_info.origin_shift().mod_positive()) if (r_info.type() == 1): return ("1", "-", "-", "-") if (r_info.type() == -1): return (str(r_info.type()), "-", "-", "(%s)" % (t_shift, )) if (abs(r_info.type()) == 2): return (str(r_info.type()), str_ev(r_info.ev()), "(%s)" % (t_intrinsic, ), "(%s)" % (t_shift, )) return (str(r_info.type()), str_ev(r_info.ev()), "(%s)" % (t_intrinsic, ), "(%s)" % (t_shift, ))
def rt_mx_analysis(s): r_info = sgtbx.rot_mx_info(s.r()) t_info = sgtbx.translation_part_info(s) t_intrinsic = str(t_info.intrinsic_part().mod_positive()) t_shift = str(t_info.origin_shift().mod_positive()) if (r_info.type() == 1): return ("1", "-", "-", "-") if (r_info.type() == -1): return (str(r_info.type()), "-", "-", "location=(%s)" % (t_shift, )) if (abs(r_info.type()) == 2): return (str(r_info.type()), "axis=" + str_ev(r_info.ev()), "(%s)" % (t_intrinsic, ), "location=(%s)" % (t_shift, )) sense = "+" if (r_info.sense() < 0): sense = "-" return (str(r_info.type()) + sense, "axis=" + str_ev(r_info.ev()), "(%s)" % (t_intrinsic, ), "location=(%s)" % (t_shift, ))
def rt_mx_analysis(s): r_info = sgtbx.rot_mx_info(s.r()) t_info = sgtbx.translation_part_info(s) t_intrinsic = str(t_info.intrinsic_part().mod_positive()) t_shift = str(t_info.origin_shift().mod_positive()) if (r_info.type() == 1): return ("1", "-", "-", "-") if (r_info.type() == -1): return (str(r_info.type()), "-", "-", "(%s)" % (t_shift,)) if (abs(r_info.type()) == 2): return (str(r_info.type()), str_ev(r_info.ev()), "(%s)" % (t_intrinsic,), "(%s)" % (t_shift,)) return (str(r_info.type()), str_ev(r_info.ev()), "(%s)" % (t_intrinsic,), "(%s)" % (t_shift,))
def rt_mx_analysis(s): print("<tr>") print("<td><tt>" + str(s) + "</tt>") r_info = sgtbx.rot_mx_info(s.r()) t_info = sgtbx.translation_part_info(s) if (r_info.type() == 1): print("<td>1<td>-<td>-<td>-") elif (r_info.type() == -1): print("<td>%d<td>-<td>-<td>%s" % (r_info.type(), str(t_info.origin_shift()))) elif (abs(r_info.type()) == 2): print("<td>%d<td>%s<td>%s<td>%s" % (r_info.type(), str_ev(r_info.ev()), str( t_info.intrinsic_part()), str(t_info.origin_shift()))) else: print("<td>%d^%d<td>%s<td>%s<td>%s" % (r_info.type(), r_info.sense(), str_ev(r_info.ev()), str(t_info.intrinsic_part()), str(t_info.origin_shift()))) print("</tr>")
status.in_table = False print print "Additional generators of Euclidean normalizer:" ss = sgtbx.structure_seminvariants(sg) ss_vm = ss.vectors_and_moduli() print " Number of structure-seminvariant vectors and moduli:", len(ss_vm) if (len(ss_vm)): print " Vector Modulus" for vm in ss_vm: print " ", vm.v, vm.m k2l = sg_type.addl_generators_of_euclidean_normalizer(True, False) l2n = sg_type.addl_generators_of_euclidean_normalizer(False, True) if (len(k2l)): print " Inversion through a centre at:", assert len(k2l) == 1 print sgtbx.translation_part_info(k2l[0]).origin_shift() if (len(l2n)): print " Further generators:" print "</pre><table border=2 cellpadding=2>" status.in_table = True rt_mx_analysis_header() for s in l2n: rt_mx_analysis(s) print "</table><pre>" status.in_table = False print print "Grid factors implied by symmetries:" grid_sg = sg.gridding() grid_ss = ss.gridding() eucl_sg = sg_type.expand_addl_generators_of_euclidean_normalizer(True,True) grid_eucl = eucl_sg.refine_gridding(grid_ss)
def run(server_info, inp, status): print("<pre>") symbols_inp = None lookup_symbol = inp.sgsymbol if (lookup_symbol == ""): lookup_symbol = "P 1" if (inp.convention == "Hall"): hall_symbol = lookup_symbol else: symbols_inp = sgtbx.space_group_symbols(lookup_symbol, inp.convention) hall_symbol = symbols_inp.hall() if (symbols_inp.number() == 0): symbols_inp = None inp.convention = "Hall" else: print("Result of symbol lookup:") show_symbols(symbols_inp) print() try: ps = sgtbx.parse_string(hall_symbol) sg = sgtbx.space_group(ps) except RuntimeError as e: print("-->" + ps.string() + "<--") print(("-" * (ps.where() + 3)) + "^") raise io_utils.show_input_symbol(inp.sgsymbol, inp.convention) if (len(inp.shelx_latt) != 0): for n_fld in inp.shelx_latt: expand_shelx_latt(sg, n_fld) if (len(inp.symxyz) != 0): print("Addition of symmetry operations:") print("</pre><table border=2 cellpadding=2>") status.in_table = True rt_mx_analysis_header() for s in inp.symxyz: ps = sgtbx.parse_string(s) try: s = sgtbx.rt_mx(ps) except RuntimeError as e: print("</table><pre>") status.in_table = False print("-->" + ps.string() + "<--") print(("-" * (ps.where() + 3)) + "^") raise rt_mx_analysis(s) sg.expand_smx(s) print("</table><pre>") status.in_table = False print() sg_type = sg.type() show_group_generic(sg_type, status) if (inp.convention == "Hall" or len(inp.shelx_latt) != 0 or len(inp.symxyz) != 0): symbols_match = sg.match_tabulated_settings() if (symbols_match.number() != 0): if (symbols_inp is None or symbols_inp.universal_hermann_mauguin() != symbols_match.universal_hermann_mauguin()): print("Symmetry operations match:") show_symbols(symbols_match) print() else: print("Additional symmetry operations are redundant.") print() else: print("Space group number:", sg_type.number()) print("Conventional Hermann-Mauguin symbol:", \ sgtbx.space_group_symbols(sg_type.number()) \ .universal_hermann_mauguin()) print("Universal Hermann-Mauguin symbol:", \ sg_type.universal_hermann_mauguin_symbol()) print("Hall symbol:", sg_type.hall_symbol()) print("Change-of-basis matrix:", sg_type.cb_op().c()) print(" Inverse:", sg_type.cb_op().c_inv()) print() wyckoff_table = sgtbx.wyckoff_table(sg_type) print("List of Wyckoff positions:") print("</pre><table border=2 cellpadding=2>") status.in_table = True print("<tr>") print("<th>Wyckoff letter") print("<th>Multiplicity") print("<th>Site symmetry<br>point group type") print("<th>Representative special position operator") print("</tr>") for i_position in range(wyckoff_table.size()): position = wyckoff_table.position(i_position) print("<tr>") print("<td>%s<td>%d<td>%s<td><tt>%s</tt>" % (position.letter(), position.multiplicity(), position.point_group_type(), str(position.special_op_simplified()))) print("</tr>") print("</table><pre>") status.in_table = False print() print("Harker planes:") print("</pre><table border=2 cellpadding=2>") status.in_table = True print("<tr>") print("<th>Algebraic") print("<th>Normal vector") print("<th>A point in the plane") print("</tr>") planes = harker.planes_fractional(sg) for plane in planes.list: print("<tr>") print("<td><tt>%s</tt><td>%s<td>%s" % (plane.algebraic(), str_ev(plane.n), str(plane.p))) print("</tr>") print("</table><pre>") status.in_table = False print() print("Additional generators of Euclidean normalizer:") ss = sgtbx.structure_seminvariants(sg) ss_vm = ss.vectors_and_moduli() print(" Number of structure-seminvariant vectors and moduli:", len(ss_vm)) if (len(ss_vm)): print(" Vector Modulus") for vm in ss_vm: print(" ", vm.v, vm.m) k2l = sg_type.addl_generators_of_euclidean_normalizer(True, False) l2n = sg_type.addl_generators_of_euclidean_normalizer(False, True) if (len(k2l)): print(" Inversion through a centre at:", end=' ') assert len(k2l) == 1 print(sgtbx.translation_part_info(k2l[0]).origin_shift()) if (len(l2n)): print(" Further generators:") print("</pre><table border=2 cellpadding=2>") status.in_table = True rt_mx_analysis_header() for s in l2n: rt_mx_analysis(s) print("</table><pre>") status.in_table = False print() print("Grid factors implied by symmetries:") grid_sg = sg.gridding() grid_ss = ss.gridding() eucl_sg = sg_type.expand_addl_generators_of_euclidean_normalizer( True, True) grid_eucl = eucl_sg.refine_gridding(grid_ss) print(" Space group:", grid_sg) print(" Structure-seminvariant vectors and moduli:", grid_ss) print(" Euclidean normalizer:", grid_eucl) print() print(" All points of a grid over the unit cell are mapped") print(" exactly onto other grid points only if the factors") print(" shown above are factors of the grid.") print() print("</pre>")
print print "Additional generators of Euclidean normalizer:" ss = sgtbx.structure_seminvariants(sg) ss_vm = ss.vectors_and_moduli() print " Number of structure-seminvariant vectors and moduli:", len(ss_vm) if (len(ss_vm)): print " Vector Modulus" for vm in ss_vm: print " ", vm.v, vm.m k2l = sg_type.addl_generators_of_euclidean_normalizer(True, False) l2n = sg_type.addl_generators_of_euclidean_normalizer(False, True) if (len(k2l)): print " Inversion through a centre at:", assert len(k2l) == 1 print sgtbx.translation_part_info(k2l[0]).origin_shift() if (len(l2n)): print " Further generators:" print "</pre><table border=2 cellpadding=2>" status.in_table = True rt_mx_analysis_header() for s in l2n: rt_mx_analysis(s) print "</table><pre>" status.in_table = False print print "Grid factors implied by symmetries:" grid_sg = sg.gridding() grid_ss = ss.gridding() eucl_sg = sg_type.expand_addl_generators_of_euclidean_normalizer(
def rlc_RTMxAnalysis(M): r_info = sgtbx.rot_mx_info(M.r()) t_info = sgtbx.translation_part_info(M) t_intrinsic = t_info.intrinsic_part().mod_positive().as_double() t_shift = t_info.origin_shift().mod_positive().as_double() #End = list_plus(Start + map(None,r_info.ev())) ####debug ### trans = 0 ### length = 0 ####debug #if (r_info.type() == 1): if (r_info.type() < 2): #(rt, start, end) = ('1',(0,0,0),(0,0,0)) return None #elif (r_info.type() == -1): # (rt, start, end) = (str(r_info.type()),t_shift,()) elif (abs(r_info.type()) == 2): trans = reduce(lambda x,y:x+y,t_intrinsic) if trans == 0: maxr = max([abs(x) for x in r_info.ev()]) r = [float(x)/maxr for x in r_info.ev()] (rt, start, end) = (str(r_info.type()),t_shift,tuple(list_plus(t_shift,r))) #(rt, start, end) = (str(r_info.type()),t_shift,tuple(list_plus(t_shift,r_info.ev()))) else: maxr = max([abs(x) for x in r_info.ev()]) r = [float(x)/maxr for x in r_info.ev()] (rt, start, end) = (str(r_info.type())+"^1",t_shift,tuple(list_plus(t_shift,r))) #(rt, start, end) = (str(r_info.type())+"^1",t_shift,tuple(list_plus(t_shift,r_info.ev()))) elif (r_info.type() == 3): if (r_info.sense() >= 0) : # ignore opposite sense of rotation axes since they superimpose trans = N.sqrt(reduce(lambda x,y:x+y,(map(lambda x,y:(y-x)*(y-x),(0,0,0),t_intrinsic)))) # trans = N.sqrt(t_intrinsic[0]**2 + t_intrinsic[1]**2 + t_intrinsic[2]**2) if trans == 0: maxr = max([abs(x) for x in r_info.ev()]) r = [float(x)/maxr for x in r_info.ev()] # fudge to make sure that PyMOL actually draws the axis (move it slightly off [1,-1,1]) !!! r[0] = r[0]*1.000001 (rt, start, end) = (str(r_info.type()),t_shift,tuple(list_plus(t_shift,r))) #(rt, start, end) = (str(r_info.type()),t_shift, tuple(list_plus(t_shift,r_info.ev()))) else: maxr = max([abs(x) for x in r_info.ev()]) r = [float(x)/maxr for x in r_info.ev()] #(rt, start, end) = (str(r_info.type())+ "^" + subscript ,t_shift,tuple(list_plus(t_shift,r))) (start, end) = (t_shift,tuple(list_plus(t_shift,r))) length = N.sqrt(reduce(lambda x,y:x+y,(map(lambda x,y:(y-x)*(y-x),start, end)))) # r_info.sense() for 3^1 and 3^2 seems always to be "1" ??? # if r_info.sense() < 0: # subscript = str(1-r_info.sense()) # else: # subscript = str(r_info.sense()) # use ratio of trans to length to get the correct axis symbol: # fudged the value to get the right numbers. (using length/2., rather than length/3.) if trans < length*0.5 : subscript = '1' else: subscript = '2' rt = str(r_info.type())+ "^" + subscript #(rt, start, end) = (str(r_info.type()) + "^" + subscript,t_shift, tuple(list_plus(t_shift,r_info.ev()))) ### print "Type, sense, Start, End, length, trans", rt, r_info.sense(), start, end, length, trans # print "type: %s, sense: %s, trans: %s, length: %s," % (r_info.type(), r_info.sense(), trans, length) # print "(rt, start, end)", (rt,start,end) else: return None #return (r_info.type(),r_info.ev(), t_intrinsic, t_shift) elif (r_info.sense() > 0): # ignore opposite sense of rotation axes since they superimpose trans = reduce(lambda x,y:x+y,t_intrinsic) if trans == 0: maxr = max([abs(x) for x in r_info.ev()]) r = [float(x)/maxr for x in r_info.ev()] (rt, start, end) = (str(r_info.type()),t_shift,tuple(list_plus(t_shift,r))) #(rt, start, end) = (str(r_info.type()),t_shift, tuple(list_plus(t_shift,r_info.ev()))) else: maxr = max([abs(x) for x in r_info.ev()]) r = [float(x)/maxr for x in r_info.ev()] subscript = str(int(trans*r_info.type()+.5)) # add 0.5 to fix rounding errors (rt, start, end) = (str(r_info.type())+ "^" + subscript ,t_shift,tuple(list_plus(t_shift,r))) #(rt, start, end) = (str(r_info.type()) + "^" + subscript,t_shift, tuple(list_plus(t_shift,r_info.ev()))) #return (r_info.type(),r_info.ev(), t_intrinsic, t_shift) else: return None # print "type: %s, sense: %s, trans: %s, length: %s," % (r_info.type(), r_info.sense(), trans, length), # print "(rt, start, end)", (rt,start,end) return (rt, start, end)
def __init__(self,symop): self.symop = symop # an instance of rt_mx from cctbx import sgtbx self.r_info = sgtbx.rot_mx_info(self.symop.r()) self.t_info = sgtbx.translation_part_info(self.symop)
def rlc_RTMxAnalysis(M): r_info = sgtbx.rot_mx_info(M.r()) t_info = sgtbx.translation_part_info(M) t_intrinsic = t_info.intrinsic_part().mod_positive().as_double() t_shift = t_info.origin_shift().mod_positive().as_double() #End = list_plus(Start + map(None,r_info.ev())) ####debug ### trans = 0 ### length = 0 ####debug #if r_info.type() == 1: if r_info.type() < 2: #(rt, start, end) = ('1',(0,0,0),(0,0,0)) return None #elif r_info.type() == -1: # (rt, start, end) = (str(r_info.type()),t_shift,()) elif abs(r_info.type()) == 2: trans = sum(t_intrinsic) if trans == 0: maxr = max([abs(x) for x in r_info.ev()]) r = [float(x) / maxr for x in r_info.ev()] (rt, start, end) = (str(r_info.type()), t_shift, tuple(list_plus(t_shift, r))) #(rt, start, end) = (str(r_info.type()),t_shift,tuple(list_plus(t_shift,r_info.ev()))) else: maxr = max([abs(x) for x in r_info.ev()]) r = [float(x) / maxr for x in r_info.ev()] (rt, start, end) = (str(r_info.type()) + "^1", t_shift, tuple(list_plus(t_shift, r))) #(rt, start, end) = (str(r_info.type())+"^1",t_shift,tuple(list_plus(t_shift,r_info.ev()))) elif r_info.type() == 3: if r_info.sense() >= 0: # ignore opposite sense of rotation axes since they superimpose trans = N.sqrt( sum((map(lambda x, y: (y - x) * (y - x), (0, 0, 0), t_intrinsic)))) # trans = N.sqrt(t_intrinsic[0]**2 + t_intrinsic[1]**2 + t_intrinsic[2]**2) if trans == 0: maxr = max([abs(x) for x in r_info.ev()]) r = [float(x) / maxr for x in r_info.ev()] # fudge to make sure that PyMOL actually draws the axis (move it slightly off [1,-1,1]) !!! r[0] = r[0] * 1.000001 (rt, start, end) = (str(r_info.type()), t_shift, tuple(list_plus(t_shift, r))) #(rt, start, end) = (str(r_info.type()),t_shift, tuple(list_plus(t_shift,r_info.ev()))) else: maxr = max([abs(x) for x in r_info.ev()]) r = [float(x) / maxr for x in r_info.ev()] #(rt, start, end) = (str(r_info.type())+ "^" + subscript ,t_shift,tuple(list_plus(t_shift,r))) (start, end) = (t_shift, tuple(list_plus(t_shift, r))) length = N.sqrt( sum((map(lambda x, y: (y - x) * (y - x), start, end)))) # r_info.sense() for 3^1 and 3^2 seems always to be "1" ??? # if r_info.sense() < 0: # subscript = str(1-r_info.sense()) # else: # subscript = str(r_info.sense()) # use ratio of trans to length to get the correct axis symbol: # fudged the value to get the right numbers. (using length/2., rather than length/3.) if trans < length * 0.5: subscript = '1' else: subscript = '2' rt = str(r_info.type()) + "^" + subscript #(rt, start, end) = (str(r_info.type()) + "^" + subscript,t_shift, tuple(list_plus(t_shift,r_info.ev()))) ### print "Type, sense, Start, End, length, trans", rt, r_info.sense(), start, end, length, trans # print "type: %s, sense: %s, trans: %s, length: %s," % (r_info.type(), r_info.sense(), trans, length) # print "(rt, start, end)", (rt,start,end) else: return None #return (r_info.type(),r_info.ev(), t_intrinsic, t_shift) elif r_info.sense() > 0: # ignore opposite sense of rotation axes since they superimpose trans = sum(t_intrinsic) if trans == 0: maxr = max([abs(x) for x in r_info.ev()]) r = [float(x) / maxr for x in r_info.ev()] (rt, start, end) = (str(r_info.type()), t_shift, tuple(list_plus(t_shift, r))) #(rt, start, end) = (str(r_info.type()),t_shift, tuple(list_plus(t_shift,r_info.ev()))) else: maxr = max([abs(x) for x in r_info.ev()]) r = [float(x) / maxr for x in r_info.ev()] subscript = str(int(trans * r_info.type() + .5)) # add 0.5 to fix rounding errors (rt, start, end) = (str(r_info.type()) + "^" + subscript, t_shift, tuple(list_plus(t_shift, r))) #(rt, start, end) = (str(r_info.type()) + "^" + subscript,t_shift, tuple(list_plus(t_shift,r_info.ev()))) #return (r_info.type(),r_info.ev(), t_intrinsic, t_shift) else: return None # print "type: %s, sense: %s, trans: %s, length: %s," % (r_info.type(), r_info.sense(), trans, length), # print "(rt, start, end)", (rt,start,end) return (rt, start, end)
def __init__(self, symop): self.symop = symop # an instance of rt_mx from cctbx import sgtbx self.r_info = sgtbx.rot_mx_info(self.symop.r()) self.t_info = sgtbx.translation_part_info(self.symop)