bugged
stringlengths 4
228k
| fixed
stringlengths 0
96.3M
| __index_level_0__
int64 0
481k
|
|---|---|---|
def draw_tls_surface(self, Lx_eigen_vec, Lx_eigen_val, Lx_rho, Lx_pitch): """Draws the TLS probability surface for a single non-intersecting screw axis. Lx_eigen_val is the vaiance (mean square deviation MSD) of the rotation about the Lx_eigen_vec axis. """ ## create a unique list of bonds which will be used to ## render the TLS surface; this list may be passed in a argument ## to avoid multiple calculations for each screw-rotation axis bond_list = [] in_dict = {}
|
defself.driver.glr_lighting_disable() draw_tls_surface(self,self.driver.glr_lighting_disable() Lx_eigen_vec,self.driver.glr_lighting_disable() Lx_eigen_val,self.driver.glr_lighting_disable() Lx_rho,self.driver.glr_lighting_disable() Lx_pitch):self.driver.glr_lighting_disable() """Drawsself.driver.glr_lighting_disable() theself.driver.glr_lighting_disable() TLSself.driver.glr_lighting_disable() probabilityself.driver.glr_lighting_disable() surfaceself.driver.glr_lighting_disable() forself.driver.glr_lighting_disable() aself.driver.glr_lighting_disable() singleself.driver.glr_lighting_disable() non-intersectingself.driver.glr_lighting_disable() screwself.driver.glr_lighting_disable() axis.self.driver.glr_lighting_disable() self.driver.glr_lighting_disable() Lx_eigen_valself.driver.glr_lighting_disable() isself.driver.glr_lighting_disable() theself.driver.glr_lighting_disable() vaianceself.driver.glr_lighting_disable() (meanself.driver.glr_lighting_disable() squareself.driver.glr_lighting_disable() deviationself.driver.glr_lighting_disable() MSD)self.driver.glr_lighting_disable() ofself.driver.glr_lighting_disable() theself.driver.glr_lighting_disable() rotationself.driver.glr_lighting_disable() aboutself.driver.glr_lighting_disable() theself.driver.glr_lighting_disable() Lx_eigen_vecself.driver.glr_lighting_disable() axis.self.driver.glr_lighting_disable() """self.driver.glr_lighting_disable() ##self.driver.glr_lighting_disable() createself.driver.glr_lighting_disable() aself.driver.glr_lighting_disable() uniqueself.driver.glr_lighting_disable() listself.driver.glr_lighting_disable() ofself.driver.glr_lighting_disable() bondsself.driver.glr_lighting_disable() whichself.driver.glr_lighting_disable() willself.driver.glr_lighting_disable() beself.driver.glr_lighting_disable() usedself.driver.glr_lighting_disable() toself.driver.glr_lighting_disable() ##self.driver.glr_lighting_disable() renderself.driver.glr_lighting_disable() theself.driver.glr_lighting_disable() TLSself.driver.glr_lighting_disable() surface;self.driver.glr_lighting_disable() thisself.driver.glr_lighting_disable() listself.driver.glr_lighting_disable() mayself.driver.glr_lighting_disable() beself.driver.glr_lighting_disable() passedself.driver.glr_lighting_disable() inself.driver.glr_lighting_disable() aself.driver.glr_lighting_disable() argumentself.driver.glr_lighting_disable() ##self.driver.glr_lighting_disable() toself.driver.glr_lighting_disable() avoidself.driver.glr_lighting_disable() multipleself.driver.glr_lighting_disable() calculationsself.driver.glr_lighting_disable() forself.driver.glr_lighting_disable() eachself.driver.glr_lighting_disable() screw-rotationself.driver.glr_lighting_disable() axisself.driver.glr_lighting_disable() bond_listself.driver.glr_lighting_disable() =self.driver.glr_lighting_disable() []self.driver.glr_lighting_disable() in_dictself.driver.glr_lighting_disable() self.driver.glr_lighting_disable() self.driver.glr_lighting_disable() =self.driver.glr_lighting_disable() {}
| 6,500
|
def atom_common(arec1, arec2): arec2["serial"] = arec1["serial"] arec2["chainID"] = arec1["chainID"] arec2["resName"] = arec1["resName"] arec2["resSeq"] = arec1["resSeq"] arec2["iCode"] = arec1["iCode"] arec2["name"] = arec1["name"] arec2["altLoc"] = arec1["altLoc"] arec2["element"] = arec1["element"] arec2["charge"] = arec1["charge"]
|
def atom_common(arec1, arec2): arec2["serial"] = arec1["serial"] arec2["chainID"] = arec1["chainID"] arec2["resName"] = arec1["resName"] arec2["resSeq"] = arec1["resSeq"] arec2["iCode"] = arec1["iCode"] arec2["name"] = arec1["name"] arec2["altLoc"] = arec1["altLoc"] arec2["element"] = arec1["element"] arec2["charge"] = arec1["charge"]
| 6,501
|
def process(self, recs): """Returns a dictionary with attributes chain_id, num_res, and sequence_list """ seqres = {}
|
def process(self, recs): """Returns a dictionary with attributes chain_id, num_res, and sequence_list """ seqres = {}
| 6,502
|
def calc_atom_weight(atm): """Weight the least-squares fit according to this function. """
|
def calc_atom_weight(atm): """Weight the least-squares fit according to this function. """
| 6,503
|
def __init__(self, form, text=None): Page.__init__(self, form) self.text = text
|
def __init__(self, form, text): Page.__init__(self, form) self.text = text
| 6,504
|
def main(): form = cgi.FieldStorage() page = None job_id = check_job_id(form) if job_id==None: page = ErrorPage("The Job ID seems to be expired.") else: page = RefinePrepPage(form) try: print page.html_page() except RefinePrepError, err: text = '<center><p>%s</p></center>' % (err.text) page = ErrorPage(form, text) print page.html_page() except xmlrpclib.Fault, err: page = ErrorPage(form, "xmlrpclib.Fault: " +str(err)) print page.html_page() except socket.error, err: page = ErrorPage(form, "socket.error: " + str(err)) print page.html_page()
|
def main(): form = cgi.FieldStorage() page = None job_id = check_job_id(form) if job_id==None: page = ErrorPage(form, "The Job ID seems to be expired.") else: page = RefinePrepPage(form) try: print page.html_page() except RefinePrepError, err: text = '<center><p>%s</p></center>' % (err.text) page = ErrorPage(form, text) print page.html_page() except xmlrpclib.Fault, err: page = ErrorPage(form, "xmlrpclib.Fault: " +str(err)) print page.html_page() except socket.error, err: page = ErrorPage(form, "socket.error: " + str(err)) print page.html_page()
| 6,505
|
def next_chain_id(suggest_chain_id): if suggest_chain_id != "": try: self.struct[suggest_chain_id] except KeyError: return suggest_chain_id for chain_id in "ABCDEFGHIJKLMNOPQRSTUVWXYZ": try: self.struct[chain_id] except KeyError: return chain_id
|
def next_chain_id(suggest_chain_id): if suggest_chain_id != "": try: self.struct[suggest_chain_id] except IndexError: return suggest_chain_id for chain_id in "ABCDEFGHIJKLMNOPQRSTUVWXYZ": try: self.struct[chain_id] except IndexError: return chain_id
| 6,506
|
def lsq_fit_segment(self, frag_id1, frag_id2): """Performs a LSQ fit of TLS parameters for the protein segment starting with fragment index ifrag_start to (and including) the fragment ifrag_end. """ ## all return values here fit_info = {} ## calculate the start/end indexes of the start fragment ## and end fragment so the A matrix and b vector can be sliced ## in the correct placees
|
def lsq_fit_segment(self, frag_id1, frag_id2): """Performs a LSQ fit of TLS parameters for the protein segment starting with fragment index ifrag_start to (and including) the fragment ifrag_end. """ ## all return values here fit_info = {} ## calculate the start/end indexes of the start fragment ## and end fragment so the A matrix and b vector can be sliced ## in the correct placees
| 6,507
|
def lsq_fit_segment(self, frag_id1, frag_id2): """Performs a LSQ fit of TLS parameters for the protein segment starting with fragment index ifrag_start to (and including) the fragment ifrag_end. """ ## all return values here fit_info = {} ## calculate the start/end indexes of the start fragment ## and end fragment so the A matrix and b vector can be sliced ## in the correct placees
|
def lsq_fit_segment(self, frag_id1, frag_id2): """Performs a LSQ fit of TLS parameters for the protein segment starting with fragment index ifrag_start to (and including) the fragment ifrag_end. """ ## all return values here fit_info = {} ## calculate the start/end indexes of the start fragment ## and end fragment so the A matrix and b vector can be sliced ## in the correct placees
| 6,508
|
def lsq_fit_segment(self, frag_id1, frag_id2): """Performs a LSQ fit of TLS parameters for the protein segment starting with fragment index ifrag_start to (and including) the fragment ifrag_end. """ ## all return values here fit_info = {} ## calculate the start/end indexes of the start fragment ## and end fragment so the A matrix and b vector can be sliced ## in the correct placees
|
def lsq_fit_segment(self, frag_id1, frag_id2): """Performs a LSQ fit of TLS parameters for the protein segment starting with fragment index ifrag_start to (and including) the fragment ifrag_end. """ ## all return values here fit_info = {} ## calculate the start/end indexes of the start fragment ## and end fragment so the A matrix and b vector can be sliced ## in the correct placees
| 6,509
|
def lsq_fit_segment(self, frag_id1, frag_id2): """Performs a LSQ fit of TLS parameters for the protein segment starting with fragment index ifrag_start to (and including) the fragment ifrag_end. """ ## all return values here fit_info = {} ## calculate the start/end indexes of the start fragment ## and end fragment so the A matrix and b vector can be sliced ## in the correct placees
|
def lsq_fit_segment(self, frag_id1, frag_id2): """Performs a LSQ fit of TLS parameters for the protein segment starting with fragment index ifrag_start to (and including) the fragment ifrag_end. """ ## all return values here fit_info = {} ## calculate the start/end indexes of the start fragment ## and end fragment so the A matrix and b vector can be sliced ## in the correct placees
| 6,510
|
def lsq_fit_segment(self, frag_id1, frag_id2): """Performs a LSQ fit of TLS parameters for the protein segment starting with fragment index ifrag_start to (and including) the fragment ifrag_end. """ ## all return values here fit_info = {} ## calculate the start/end indexes of the start fragment ## and end fragment so the A matrix and b vector can be sliced ## in the correct placees
|
def lsq_fit_segment(self, frag_id1, frag_id2): """Performs a LSQ fit of TLS parameters for the protein segment starting with fragment index ifrag_start to (and including) the fragment ifrag_end. """ ## all return values here fit_info = {} ## calculate the start/end indexes of the start fragment ## and end fragment so the A matrix and b vector can be sliced ## in the correct placees
| 6,511
|
def NewTLSGraphChain0(tls_model): """Generate and return the proper TLSGraphChain subclass for the requested TLS model. """ if tls_model=="HYBRID": return TLSGraphChainFastHybrid() if tls_model=="ANISO": return TLSGraphChainAnisotropic() if tls_model=="PLUGIN": return TLSGraphChainPlugin() raise Exception()
|
def NewTLSGraphChain0(tls_model): """Generate and return the proper TLSGraphChain subclass for the requested TLS model. """ if tls_model=="HYBRID": if USE_TLSMDMODULE==True: return TLSGraphChainFastHybrid() else: return TLSGraphChainHybrid() if tls_model=="ANISO": return TLSGraphChainAnisotropic() if tls_model=="PLUGIN": return TLSGraphChainPlugin() raise Exception()
| 6,512
|
def html_chain_alignment_plot(self, chain): """generate a plot comparing all segmentations """ plot = sequence_plot.TLSSegmentAlignmentPlot() for ntls, cpartition in chain.partition_collection.iter_ntls_chain_partitions(): plot.add_tls_segmentation(cpartition)
|
def html_chain_alignment_plot(self, chain): """generate a plot comparing all segmentations """ plot = sequence_plot.TLSSegmentAlignmentPlot() for ntls, cpartition in chain.partition_collection.iter_ntls_chain_partitions(): plot.add_tls_segmentation(cpartition)
| 6,513
|
def html_chain_alignment_plot(self, chain): """generate a plot comparing all segmentations """ plot = sequence_plot.TLSSegmentAlignmentPlot() for ntls, cpartition in chain.partition_collection.iter_ntls_chain_partitions(): plot.add_tls_segmentation(cpartition)
|
def html_chain_alignment_plot(self, chain): """generate a plot comparing all segmentations """ plot = sequence_plot.TLSSegmentAlignmentPlot() for ntls, cpartition in chain.partition_collection.iter_ntls_chain_partitions(): plot.add_tls_segmentation(cpartition)
| 6,514
|
def gldl_iter_multidraw_animate(self): """ """ ## optimization: if a rotation of 0.0 degrees was already ## drawn, then there is no need to draw it again zero_rot = False for Lx_axis, Lx_rho, Lx_pitch, Lx_rot, Lx_scale in ( ("L1_eigen_vec", "L1_rho", "L1_pitch", "L1_rot", "L1_scale"), ("L2_eigen_vec", "L2_rho", "L2_pitch", "L2_rot", "L2_scale"), ("L3_eigen_vec", "L3_rho", "L3_pitch", "L3_rot", "L3_scale") ):
|
def gldl_iter_multidraw_animate(self): """ """ ## optimization: if a rotation of 0.0 degrees was already ## drawn, then there is no need to draw it again zero_rot = False for Lx_axis, Lx_rho, Lx_pitch, Lx_rot, Lx_scale in ( ("L1_eigen_vec", "L1_rho", "L1_pitch", "L1_rot", "L1_scale"), ("L2_eigen_vec", "L2_rho", "L2_pitch", "L2_rot", "L2_scale"), ("L3_eigen_vec", "L3_rho", "L3_pitch", "L3_rot", "L3_scale") ):
| 6,515
|
def gldl_iter_multidraw_animate(self): """ """ ## optimization: if a rotation of 0.0 degrees was already ## drawn, then there is no need to draw it again zero_rot = False for Lx_axis, Lx_rho, Lx_pitch, Lx_rot, Lx_scale in ( ("L1_eigen_vec", "L1_rho", "L1_pitch", "L1_rot", "L1_scale"), ("L2_eigen_vec", "L2_rho", "L2_pitch", "L2_rot", "L2_scale"), ("L3_eigen_vec", "L3_rho", "L3_pitch", "L3_rot", "L3_scale") ):
|
def gldl_iter_multidraw_animate(self): """ """ ## optimization: if a rotation of 0.0 degrees was already ## drawn, then there is no need to draw it again zero_rot = False for Lx_axis, Lx_rho, Lx_pitch, Lx_rot, Lx_scale in ( ("L1_eigen_vec", "L1_rho", "L1_pitch", "L1_rot", "L1_scale"), ("L2_eigen_vec", "L2_rho", "L2_pitch", "L2_rot", "L2_scale"), ("L3_eigen_vec", "L3_rho", "L3_pitch", "L3_rot", "L3_scale") ):
| 6,516
|
def gldl_iter_multidraw_animate(self): """ """ ## optimization: if a rotation of 0.0 degrees was already ## drawn, then there is no need to draw it again zero_rot = False for Lx_axis, Lx_rho, Lx_pitch, Lx_rot, Lx_scale in ( ("L1_eigen_vec", "L1_rho", "L1_pitch", "L1_rot", "L1_scale"), ("L2_eigen_vec", "L2_rho", "L2_pitch", "L2_rot", "L2_scale"), ("L3_eigen_vec", "L3_rho", "L3_pitch", "L3_rot", "L3_scale") ):
|
def gldl_iter_multidraw_animate(self): """ """ ## optimization: if a rotation of 0.0 degrees was already ## drawn, then there is no need to draw it again zero_rot = False for Lx_axis, Lx_rho, Lx_pitch, Lx_rot, Lx_scale in ( ("L1_eigen_vec", "L1_rho", "L1_pitch", "L1_rot", "L1_scale"), ("L2_eigen_vec", "L2_rho", "L2_pitch", "L2_rot", "L2_scale"), ("L3_eigen_vec", "L3_rho", "L3_pitch", "L3_rot", "L3_scale") ):
| 6,517
|
def update_time(self): """Changes the time of the TLS group simulating harmonic motion. """ if self.tls_group.is_null(): return
|
def update_time(self): """Changes the time of the TLS group simulating harmonic motion. """ if self.tls_group.is_null(): return
| 6,518
|
def update_time(self): """Changes the time of the TLS group simulating harmonic motion. """ if self.tls_group.is_null(): return
|
def update_time(self): """Changes the time of the TLS group simulating harmonic motion. """ if self.tls_group.is_null(): return
| 6,519
|
def update_time(self): """Changes the time of the TLS group simulating harmonic motion. """ if self.tls_group.is_null(): return
|
def update_time(self): """Changes the time of the TLS group simulating harmonic motion. """ if self.tls_group.is_null(): return
| 6,520
|
def draw_tls_surface(self, Lx_eigen_vec, Lx_eigen_val, Lx_rho, Lx_pitch): """Draws the TLS probability surface for a single non-intersecting screw axis. Lx_eigen_val is the vaiance (mean square deviation MSD) of the rotation about the Lx_eigen_vec axis. """ ## create a unique list of bonds which will be used to ## render the TLS surface; this list may be passed in a argument ## to avoid multiple calculations for each screw-rotation axis bond_list = [] in_dict = {}
|
def draw_tls_surface(self, Lx_eigen_vec, Lx_eigen_val, Lx_rho, Lx_pitch): """Draws the TLS probability surface for a single non-intersecting screw axis. Lx_eigen_val is the vaiance (mean square deviation MSD) of the rotation about the Lx_eigen_vec axis. """ ## create a unique list of bonds which will be used to ## render the TLS surface; this list may be passed in a argument ## to avoid multiple calculations for each screw-rotation axis bond_list = [] in_dict = {}
| 6,521
|
def draw_tls_surface(self, Lx_eigen_vec, Lx_eigen_val, Lx_rho, Lx_pitch): """Draws the TLS probability surface for a single non-intersecting screw axis. Lx_eigen_val is the vaiance (mean square deviation MSD) of the rotation about the Lx_eigen_vec axis. """ ## create a unique list of bonds which will be used to ## render the TLS surface; this list may be passed in a argument ## to avoid multiple calculations for each screw-rotation axis bond_list = [] in_dict = {}
|
def draw_tls_surface(self, Lx_eigen_vec, Lx_eigen_val, Lx_rho, Lx_pitch): """Draws the TLS probability surface for a single non-intersecting screw axis. Lx_eigen_val is the vaiance (mean square deviation MSD) of the rotation about the Lx_eigen_vec axis. """ ## create a unique list of bonds which will be used to ## render the TLS surface; this list may be passed in a argument ## to avoid multiple calculations for each screw-rotation axis bond_list = [] in_dict = {}
| 6,522
|
def draw_tls_surface(self, Lx_eigen_vec, Lx_eigen_val, Lx_rho, Lx_pitch): """Draws the TLS probability surface for a single non-intersecting screw axis. Lx_eigen_val is the vaiance (mean square deviation MSD) of the rotation about the Lx_eigen_vec axis. """ ## create a unique list of bonds which will be used to ## render the TLS surface; this list may be passed in a argument ## to avoid multiple calculations for each screw-rotation axis bond_list = [] in_dict = {}
|
def draw_tls_surface(self, Lx_eigen_vec, Lx_eigen_val, Lx_rho, Lx_pitch): """Draws the TLS probability surface for a single non-intersecting screw axis. Lx_eigen_val is the vaiance (mean square deviation MSD) of the rotation about the Lx_eigen_vec axis. """ ## create a unique list of bonds which will be used to ## render the TLS surface; this list may be passed in a argument ## to avoid multiple calculations for each screw-rotation axis bond_list = [] in_dict = {}
| 6,523
|
def write_mstring(self, mstring): self.write(self.form_string(mstring))
|
def write_mstring(self, mstring): self.write(self.form_string(mstring))
| 6,524
|
def SendEmail(address, subject, body): if not os.path.isfile(conf.MSMTP): sys.stderr.write("Mail Client %s Not Found" % (conf.MSMTP)) return mlist = ["To: %s" % (address), "Subject: %s" % (subject), "", body] ## send mail using msmtp pobj = subprocess.Popen([conf.MSMTP, address], stdin = subprocess.PIPE, stdout = subprocess.PIPE, stderr = subprocess.STDOUT, close_fds = True, bufsize = 8192) pobj.stdin.write("\n".join(mlist)) pobj.wait()
|
def SendEmail(address, subject, body): if not os.path.isfile(conf.MSMTP): sys.stderr.write("mail client not found: %s" % (conf.MSMTP)) return mlist = ["To: %s" % (address), "Subject: %s" % (subject), "", body] ## send mail using msmtp pobj = subprocess.Popen([conf.MSMTP, address], stdin = subprocess.PIPE, stdout = subprocess.PIPE, stderr = subprocess.STDOUT, close_fds = True, bufsize = 8192) pobj.stdin.write("\n".join(mlist)) pobj.wait()
| 6,525
|
def SendEmail(address, subject, body): if not os.path.isfile(conf.MSMTP): sys.stderr.write("Mail Client %s Not Found" % (conf.MSMTP)) return mlist = ["To: %s" % (address), "Subject: %s" % (subject), "", body] ## send mail using msmtp pobj = subprocess.Popen([conf.MSMTP, address], stdin = subprocess.PIPE, stdout = subprocess.PIPE, stderr = subprocess.STDOUT, close_fds = True, bufsize = 8192) pobj.stdin.write("\n".join(mlist)) pobj.wait()
|
def SendEmail(address, subject, body): if not os.path.isfile(conf.MSMTP): sys.stderr.write("Mail Client %s Not Found" % (conf.MSMTP)) return mlist = ["To: %s" % (address), "Subject: %s" % (subject), "", body] ## send mail using msmtp try: pobj = subprocess.Popen([conf.MSMTP, address], stdin = subprocess.PIPE, stdout = subprocess.PIPE, stderr = subprocess.STDOUT, close_fds = True, bufsize = 8192) except OSError: sys.stderr.write("[ERROR] mail client failed to execute: %s" % (conf.MSMTP)) return pobj.stdin.write("\n".join(mlist)) pobj.wait()
| 6,526
|
def read_pdb(path): sec = time.time() records = pdbmodule.read(path) sec = time.time() - sec if records != None: print "%s: %d records in %.2f seconds" % ( path, len(records), sec) else: print "%s: NO RECORDS" % (path) for rec in records: if rec["RECORD"] == "REMARK": try: text = rec["text"] except KeyError: pass else: if text.find("RESOLUTION RANGE HIGH") == 1: print text
|
def read_pdb(path): sec = time.time() records = pdbmodule.read(path) sec = time.time() - sec stats = {} stats["time"] = sec for rec in records: if rec["RECORD"] == "REMARK": try: text = rec["text"] except KeyError: pass else: if text.find("RESOLUTION RANGE HIGH") == 1: print text
| 6,527
|
def read_pdb(path): sec = time.time() records = pdbmodule.read(path) sec = time.time() - sec if records != None: print "%s: %d records in %.2f seconds" % ( path, len(records), sec) else: print "%s: NO RECORDS" % (path) for rec in records: if rec["RECORD"] == "REMARK": try: text = rec["text"] except KeyError: pass else: if text.find("RESOLUTION RANGE HIGH") == 1: print text
|
def read_pdb(path): sec = time.time() records = pdbmodule.read(path) sec = time.time() - sec if records != None: print "%s: %d records in %.2f seconds" % ( path, len(records), sec) else: print "%s: NO RECORDS" % (path) for rec in records: rec_type = rec["RECORD"] if rec_type == "REMARK": try: text = rec["text"] except KeyError: pass else: if text.find("RESOLUTION RANGE HIGH") == 1: print text
| 6,528
|
def read_pdb(path): sec = time.time() records = pdbmodule.read(path) sec = time.time() - sec if records != None: print "%s: %d records in %.2f seconds" % ( path, len(records), sec) else: print "%s: NO RECORDS" % (path) for rec in records: if rec["RECORD"] == "REMARK": try: text = rec["text"] except KeyError: pass else: if text.find("RESOLUTION RANGE HIGH") == 1: print text
|
def read_pdb(path): sec = time.time() records = pdbmodule.read(path) sec = time.time() - sec if records != None: print "%s: %d records in %.2f seconds" % ( path, len(records), sec) else: print "%s: NO RECORDS" % (path) for rec in records: if rec["RECORD"] == "REMARK": try: text = rec["text"] except KeyError: continue if text.find("RESOLUTION RANGE HIGH") == 1: try: stats["res"] = float(text[33:]) except ValueError: pass elif rec_type == "ATOM " or rec_type == "HETATM": try: stats["atoms"] += 1 except KeyError: stats["atoms"] = 1 elif rec_type == "ANISOU": try: stats["anisou"] += 1 except KeyError: stats["anisou"] = 1 return stats
| 6,529
|
def read_pdb(path): sec = time.time() records = pdbmodule.read(path) sec = time.time() - sec if records != None: print "%s: %d records in %.2f seconds" % ( path, len(records), sec) else: print "%s: NO RECORDS" % (path) for rec in records: if rec["RECORD"] == "REMARK": try: text = rec["text"] except KeyError: pass else: if text.find("RESOLUTION RANGE HIGH") == 1: print text
|
defread_pdb(path):sec=time.time()records=pdbmodule.read(path)sec=time.time()-secifrecords!=None:print"%s:%drecordsin%.2fseconds"%(path,len(records),sec)else:print"%s:NORECORDS"%(path)forrecinrecords:ifrec["RECORD"]=="REMARK":try:text=rec["text"]exceptKeyError:passelse:iftext.find("RESOLUTIONRANGEHIGH")==1:printtext
| 6,530
|
def read_pdb(path): sec = time.time() records = pdbmodule.read(path) sec = time.time() - sec if records != None: print "%s: %d records in %.2f seconds" % ( path, len(records), sec) else: print "%s: NO RECORDS" % (path) for rec in records: if rec["RECORD"] == "REMARK": try: text = rec["text"] except KeyError: pass else: if text.find("RESOLUTION RANGE HIGH") == 1: print text
|
defread_pdb(path):sec=time.time()records=pdbmodule.read(path)sec=time.time()-secifrecords!=None:print"%s:%drecordsin%.2fseconds"%(path,len(records),sec)else:print"%s:NORECORDS"%(path)forrecinrecords:ifrec["RECORD"]=="REMARK":try:text=rec["text"]exceptKeyError:passelse:iftext.find("RESOLUTIONRANGEHIGH")==1:printtext
| 6,531
|
def read_pdb(path): sec = time.time() records = pdbmodule.read(path) sec = time.time() - sec if records != None: print "%s: %d records in %.2f seconds" % ( path, len(records), sec) else: print "%s: NO RECORDS" % (path) for rec in records: if rec["RECORD"] == "REMARK": try: text = rec["text"] except KeyError: pass else: if text.find("RESOLUTION RANGE HIGH") == 1: print text
|
def read_pdb(path): sec = time.time() records = pdbmodule.read(path) sec = time.time() - sec if records != None: print "%s: %d records in %.2f seconds" % ( path, len(records), sec) else: print "%s: NO RECORDS" % (path) for rec in records: if rec["RECORD"] == "REMARK": try: text = rec["text"] except KeyError: pass else: if text.find("RESOLUTION RANGE HIGH") == 1: print text
| 6,532
|
def log_job_end(jdict): ln = "" ln += "[%s]: " % (time.asctime(time.localtime(time.time()))) ln += "Finished Job %s" % (jdict["job_id"]) log_write(ln) ## write to a special log file if jdict.get("private_job", True): private_text = "private" else: private_text = "public" submit_time = jdict.get('submit_time', 0.0) run_time_begin = jdict.get('run_time_begin', 0.0) run_time_end = jdict.get('run_time_end', 0.0) processing_time = timediff(run_time_begin, run_time_end) l = ["[Submit time: %s]" % (timestring(submit_time)), "[Start time: %s] " % (timestring(run_time_begin)), "[End time: %s] " % (timestring(run_time_end)), "[Processing time: %s] " % (processing_time), "[IP : %s] " % (jdict.get("ip_addr", "000.000.000.000")), "[Email: %s] " % (jdict.get("email", "nobody@nowhere.com")), "[Privacy: %s] " % (private_text), "[Job ID: %s] " % (jdict.get("job_id", "EEK!!")), "[Structure ID: %s] " % (jdict.get("structure_id", "----")), "[Chain sizes: %s] " % (chain_size_string(jdict)), "[TLS Model: %s] " % (jdict.get('tls_model', 'None')), "[Weight: %s] " % (jdict.get('weight', 'None')), "[Atoms: %s] " % (jdict.get('include_atoms', 'None')), "[Status: %s] " % (jdict.get('status', 'None'))] try: open(conf.LOG_PATH, "a").write(" ".join(l) + "\n") except IOError: log_write("ERROR: cannot open logfile %s" % (conf.LOG_PATH))
|
def log_job_end(jdict): ln = "" ln += "[%s]: " % (time.asctime(time.localtime(time.time()))) ln += "Finished Job %s" % (jdict["job_id"]) log_write(ln) ## write to a special log file if jdict.get("private_job", True): private_text = "private" else: private_text = "public" submit_time = jdict.get('submit_time', 0.0) run_time_begin = jdict.get('run_time_begin', 0.0) run_time_end = jdict.get('run_time_end', 0.0) processing_time = timediff(run_time_begin, run_time_end) l = ["[Submit time: %s]" % (timestring(submit_time)), "[Start time: %s] " % (timestring(run_time_begin)), "[End time: %s] " % (timestring(run_time_end)), "[Processing time: %s] " % (processing_time), "[IP : %s] " % (jdict.get("ip_addr", "000.000.000.000")), "[Email: %s] " % (jdict.get("email", "nobody@nowhere.com")), "[Privacy: %s] " % (private_text), "[Job ID: %s] " % (jdict.get("job_id", "EEK!!")), "[Structure ID: %s] " % (jdict.get("structure_id", "----")), "[Chain sizes: %s] " % (chain_size_string(jdict)), "[TLS Model: %s] " % (jdict.get('tls_model', 'None')), "[Weight: %s] " % (jdict.get('weight', 'None')), "[Atoms: %s] " % (jdict.get('include_atoms', 'None')), "[State: %s] " % (jdict.get('state', 'None'))] try: open(conf.LOG_PATH, "a").write(" ".join(l) + "\n") except IOError: log_write("ERROR: cannot open logfile %s" % (conf.LOG_PATH))
| 6,533
|
def iter_protein_atoms(sobjx): for fragx in sobjx.iter_amino_acids(): for atmx in fragx.iter_atoms(): if atmx.name=="CA": yield atmx
|
def iter_protein_atoms(sobjx): for fragx in sobjx.iter_amino_acids(): for atmx in fragx.iter_atoms(): if atmx.name=="CA": yield atmx
| 6,534
|
def iter_atoms(self): """Iterates over all Atom objects. The iteration is preformed in order according to the Chain and Fragment ordering rules the Atom object is a part of. """ for chain in self.iter_chains(): for atm in chain.iter_atoms(): yield atm
|
def iter_atoms(self): """Iterates over all Atom objects according to the Structure defaults. """ for chain in self.iter_chains(): for atm in chain.iter_atoms(): yield atm
| 6,535
|
def count_atoms(self): """Counts all Atom objects in the Structure's default alt_loc. """ n = 0 for atm in self.iter_atoms(): n += 1 return n
|
def count_atoms(self): """Counts all Atom objects in according to the Structure defaults. """ n = 0 for atm in self.iter_atoms(): n += 1 return n
| 6,536
|
def iter_all_atoms(self): """ """ for chain in self.iter_chains(): for atm in chain.iter_all_atoms(): yield atm
|
def iter_all_atoms(self): """Iterates over all Atom objects including all atoms in multiple conformations. """Iterates over all Atom objects including all atoms in multiple conformations. for chain in self.iter_chains(): for atm in chain.iter_all_atoms(): yield atm
| 6,537
|
def count_all_atoms(self): """Counts all Atom objects. """ n = 0 for atm in self.iter_all_atoms(): n += 1 return n
|
def count_all_atoms(self): """Counts all Atom objects including all atoms in multiple conformations. """ n = 0 for atm in self.iter_all_atoms(): n += 1 return n
| 6,538
|
def __init__(self): gtk.Dialog.__init__(self, "About mmCIF Editor", None, 0) self.add_button(gtk.STOCK_CLOSE, gtk.RESPONSE_CLOSE) self.connect("delete-event", self.delete_event_cb) self.connect("response", self.delete_event_cb)
|
def __init__(self): gtk.Dialog.__init__(self, "About mmCIF Editor", None, 0) self.add_button(gtk.STOCK_CLOSE, gtk.RESPONSE_CLOSE) self.connect("delete-event", self.delete_event_cb) self.connect("response", self.delete_event_cb)
| 6,539
|
def refmac5_prep(xyzin, tlsin, xyzout, tlsout): """Use TLS model + Uiso for each atom. Output xyzout with the residual Uiso only. """ os.umask(022) ## load structure struct = LoadStructure(fil = xyzin) ## load and construct TLS groups tls_group_list = [] tls_file = TLSFile() tls_file.set_file_format(TLSFileFormatTLSOUT()) tls_file.load(open(tlsin, "r")) for tls_desc in tls_file.tls_desc_list: tls_group = tls_desc.construct_tls_group_with_atoms(struct) fit_tls_group(tls_group) tls_group.tls_desc = tls_desc tls_group_list.append(tls_group) ## set the extra Uiso for each atom for tls_group in tls_group_list: ## minimal/maximal amount of Uiso which has to be added ## to the group's atoms to to make Uiso == Uiso_tls min_Uiso = 0.0 max_Uiso = 0.0 n = 0 sum_diff2 = 0.0 for atm, Utls in tls_group.iter_atm_Utls(): for aatm in atm.iter_alt_loc(): tls_tf = trace(Utls)/3.0 ref_tf = trace(aatm.get_U())/3.0 n += 1 sum_diff2 += (tls_tf - ref_tf)**2 if ref_tf>tls_tf: max_Uiso = max(ref_tf - tls_tf, max_Uiso) else: min_Uiso = max(tls_tf - ref_tf, min_Uiso) msd = sum_diff2 / n rmsd = math.sqrt(msd) ## report the percentage of atoms with Uiso within the RMSD ntotal = 0 nrmsd = 0 for atm, Utls in tls_group.iter_atm_Utls(): for aatm in atm.iter_alt_loc(): tls_tf = trace(Utls)/3.0 ref_tf = trace(aatm.get_U())/3.0 ntotal += 1 deviation = math.sqrt((tls_tf - ref_tf)**2) if deviation<=rmsd: nrmsd += 1 ## reduce the TLS group T tensor by min_Uiso so that ## a PDB file can be written out where all atoms ## Uiso == Uiso_tls ## we must rotate the T tensor to its primary axes before ## subtracting min_Uiso magnitude from it (T_eval, TR) = eigenvectors(tls_group.T) T = matrixmultiply(TR, matrixmultiply(tls_group.T, transpose(TR))) assert allclose(T[0,1], 0.0) assert allclose(T[0,2], 0.0) assert allclose(T[1,2], 0.0) T[0,0] = T[0,0] - min_Uiso T[1,1] = T[1,1] - min_Uiso T[2,2] = T[2,2] - min_Uiso ## now take half of the smallest principal component of T and ## move it into the individual atomic temperature factors min_T = min(T[0,0], min(T[1,1], T[2,2])) sub_T = min_T * 0.80 add_Uiso = min_T - sub_T T[0,0] = T[0,0] - sub_T T[1,1] = T[1,1] - sub_T T[2,2] = T[2,2] - sub_T ## rotate T back to original orientation tls_group.T = matrixmultiply(transpose(TR), matrixmultiply(T, TR)) ## reset the TLS tensor values in the TLSDesc object so they can be ## saved tls_group.tls_desc.set_tls_group(tls_group) ## set atm.temp_factor for atm, Utls in tls_group.iter_atm_Utls(): for aatm in atm.iter_alt_loc(): tls_tf = trace(Utls)/3.0 ref_tf = trace(aatm.get_U())/3.0 if ref_tf>tls_tf: aatm.temp_factor = ((add_Uiso) + ref_tf - tls_tf)*U2B aatm.U = None else: aatm.temp_factor = (add_Uiso) * U2B aatm.U = None SaveStructure(fil=xyzout, struct=struct) tls_file.save(open(tlsout, "w"))
|
def refmac5_prep(xyzin, tlsin_list, xyzout, tlsout): """Use TLS model + Uiso for each atom. Output xyzout with the residual Uiso only. """ os.umask(022) ## load structure struct = LoadStructure(fil = xyzin) ## load and construct TLS groups tls_group_list = [] tls_file = TLSFile() tls_file.set_file_format(TLSFileFormatTLSOUT()) tls_file.load(open(tlsin, "r")) for tls_desc in tls_file.tls_desc_list: tls_group = tls_desc.construct_tls_group_with_atoms(struct) fit_tls_group(tls_group) tls_group.tls_desc = tls_desc tls_group_list.append(tls_group) ## set the extra Uiso for each atom for tls_group in tls_group_list: ## minimal/maximal amount of Uiso which has to be added ## to the group's atoms to to make Uiso == Uiso_tls min_Uiso = 0.0 max_Uiso = 0.0 n = 0 sum_diff2 = 0.0 for atm, Utls in tls_group.iter_atm_Utls(): for aatm in atm.iter_alt_loc(): tls_tf = trace(Utls)/3.0 ref_tf = trace(aatm.get_U())/3.0 n += 1 sum_diff2 += (tls_tf - ref_tf)**2 if ref_tf>tls_tf: max_Uiso = max(ref_tf - tls_tf, max_Uiso) else: min_Uiso = max(tls_tf - ref_tf, min_Uiso) msd = sum_diff2 / n rmsd = math.sqrt(msd) ## report the percentage of atoms with Uiso within the RMSD ntotal = 0 nrmsd = 0 for atm, Utls in tls_group.iter_atm_Utls(): for aatm in atm.iter_alt_loc(): tls_tf = trace(Utls)/3.0 ref_tf = trace(aatm.get_U())/3.0 ntotal += 1 deviation = math.sqrt((tls_tf - ref_tf)**2) if deviation<=rmsd: nrmsd += 1 ## reduce the TLS group T tensor by min_Uiso so that ## a PDB file can be written out where all atoms ## Uiso == Uiso_tls ## we must rotate the T tensor to its primary axes before ## subtracting min_Uiso magnitude from it (T_eval, TR) = eigenvectors(tls_group.T) T = matrixmultiply(TR, matrixmultiply(tls_group.T, transpose(TR))) assert allclose(T[0,1], 0.0) assert allclose(T[0,2], 0.0) assert allclose(T[1,2], 0.0) T[0,0] = T[0,0] - min_Uiso T[1,1] = T[1,1] - min_Uiso T[2,2] = T[2,2] - min_Uiso ## now take half of the smallest principal component of T and ## move it into the individual atomic temperature factors min_T = min(T[0,0], min(T[1,1], T[2,2])) sub_T = min_T * 0.80 add_Uiso = min_T - sub_T T[0,0] = T[0,0] - sub_T T[1,1] = T[1,1] - sub_T T[2,2] = T[2,2] - sub_T ## rotate T back to original orientation tls_group.T = matrixmultiply(transpose(TR), matrixmultiply(T, TR)) ## reset the TLS tensor values in the TLSDesc object so they can be ## saved tls_group.tls_desc.set_tls_group(tls_group) ## set atm.temp_factor for atm, Utls in tls_group.iter_atm_Utls(): for aatm in atm.iter_alt_loc(): tls_tf = trace(Utls)/3.0 ref_tf = trace(aatm.get_U())/3.0 if ref_tf>tls_tf: aatm.temp_factor = ((add_Uiso) + ref_tf - tls_tf)*U2B aatm.U = None else: aatm.temp_factor = (add_Uiso) * U2B aatm.U = None SaveStructure(fil=xyzout, struct=struct) tls_file.save(open(tlsout, "w"))
| 6,540
|
def refmac5_prep(xyzin, tlsin, xyzout, tlsout): """Use TLS model + Uiso for each atom. Output xyzout with the residual Uiso only. """ os.umask(022) ## load structure struct = LoadStructure(fil = xyzin) ## load and construct TLS groups tls_group_list = [] tls_file = TLSFile() tls_file.set_file_format(TLSFileFormatTLSOUT()) tls_file.load(open(tlsin, "r")) for tls_desc in tls_file.tls_desc_list: tls_group = tls_desc.construct_tls_group_with_atoms(struct) fit_tls_group(tls_group) tls_group.tls_desc = tls_desc tls_group_list.append(tls_group) ## set the extra Uiso for each atom for tls_group in tls_group_list: ## minimal/maximal amount of Uiso which has to be added ## to the group's atoms to to make Uiso == Uiso_tls min_Uiso = 0.0 max_Uiso = 0.0 n = 0 sum_diff2 = 0.0 for atm, Utls in tls_group.iter_atm_Utls(): for aatm in atm.iter_alt_loc(): tls_tf = trace(Utls)/3.0 ref_tf = trace(aatm.get_U())/3.0 n += 1 sum_diff2 += (tls_tf - ref_tf)**2 if ref_tf>tls_tf: max_Uiso = max(ref_tf - tls_tf, max_Uiso) else: min_Uiso = max(tls_tf - ref_tf, min_Uiso) msd = sum_diff2 / n rmsd = math.sqrt(msd) ## report the percentage of atoms with Uiso within the RMSD ntotal = 0 nrmsd = 0 for atm, Utls in tls_group.iter_atm_Utls(): for aatm in atm.iter_alt_loc(): tls_tf = trace(Utls)/3.0 ref_tf = trace(aatm.get_U())/3.0 ntotal += 1 deviation = math.sqrt((tls_tf - ref_tf)**2) if deviation<=rmsd: nrmsd += 1 ## reduce the TLS group T tensor by min_Uiso so that ## a PDB file can be written out where all atoms ## Uiso == Uiso_tls ## we must rotate the T tensor to its primary axes before ## subtracting min_Uiso magnitude from it (T_eval, TR) = eigenvectors(tls_group.T) T = matrixmultiply(TR, matrixmultiply(tls_group.T, transpose(TR))) assert allclose(T[0,1], 0.0) assert allclose(T[0,2], 0.0) assert allclose(T[1,2], 0.0) T[0,0] = T[0,0] - min_Uiso T[1,1] = T[1,1] - min_Uiso T[2,2] = T[2,2] - min_Uiso ## now take half of the smallest principal component of T and ## move it into the individual atomic temperature factors min_T = min(T[0,0], min(T[1,1], T[2,2])) sub_T = min_T * 0.80 add_Uiso = min_T - sub_T T[0,0] = T[0,0] - sub_T T[1,1] = T[1,1] - sub_T T[2,2] = T[2,2] - sub_T ## rotate T back to original orientation tls_group.T = matrixmultiply(transpose(TR), matrixmultiply(T, TR)) ## reset the TLS tensor values in the TLSDesc object so they can be ## saved tls_group.tls_desc.set_tls_group(tls_group) ## set atm.temp_factor for atm, Utls in tls_group.iter_atm_Utls(): for aatm in atm.iter_alt_loc(): tls_tf = trace(Utls)/3.0 ref_tf = trace(aatm.get_U())/3.0 if ref_tf>tls_tf: aatm.temp_factor = ((add_Uiso) + ref_tf - tls_tf)*U2B aatm.U = None else: aatm.temp_factor = (add_Uiso) * U2B aatm.U = None SaveStructure(fil=xyzout, struct=struct) tls_file.save(open(tlsout, "w"))
|
def refmac5_prep(xyzin, tlsin, xyzout, tlsout): """Use TLS model + Uiso for each atom. Output xyzout with the residual Uiso only. """ os.umask(022) ## load structure struct = LoadStructure(fil = xyzin) ## load and construct TLS groups tls_group_list = [] for tlsin in tlsin_list: tls_file = TLSFile() tls_file.set_file_format(TLSFileFormatTLSOUT()) tls_file.load(open(tlsin, "r")) for tls_desc in tls_file.tls_desc_list: tls_group = tls_desc.construct_tls_group_with_atoms(struct) tls_group.tls_desc = tls_desc tls_group_list.append(tls_group) ## set the extra Uiso for each atom for tls_group in tls_group_list: ## minimal/maximal amount of Uiso which has to be added ## to the group's atoms to to make Uiso == Uiso_tls min_Uiso = 0.0 max_Uiso = 0.0 n = 0 sum_diff2 = 0.0 for atm, Utls in tls_group.iter_atm_Utls(): for aatm in atm.iter_alt_loc(): tls_tf = trace(Utls)/3.0 ref_tf = trace(aatm.get_U())/3.0 n += 1 sum_diff2 += (tls_tf - ref_tf)**2 if ref_tf>tls_tf: max_Uiso = max(ref_tf - tls_tf, max_Uiso) else: min_Uiso = max(tls_tf - ref_tf, min_Uiso) msd = sum_diff2 / n rmsd = math.sqrt(msd) ## report the percentage of atoms with Uiso within the RMSD ntotal = 0 nrmsd = 0 for atm, Utls in tls_group.iter_atm_Utls(): for aatm in atm.iter_alt_loc(): tls_tf = trace(Utls)/3.0 ref_tf = trace(aatm.get_U())/3.0 ntotal += 1 deviation = math.sqrt((tls_tf - ref_tf)**2) if deviation<=rmsd: nrmsd += 1 ## reduce the TLS group T tensor by min_Uiso so that ## a PDB file can be written out where all atoms ## Uiso == Uiso_tls ## we must rotate the T tensor to its primary axes before ## subtracting min_Uiso magnitude from it (T_eval, TR) = eigenvectors(tls_group.T) T = matrixmultiply(TR, matrixmultiply(tls_group.T, transpose(TR))) assert allclose(T[0,1], 0.0) assert allclose(T[0,2], 0.0) assert allclose(T[1,2], 0.0) T[0,0] = T[0,0] - min_Uiso T[1,1] = T[1,1] - min_Uiso T[2,2] = T[2,2] - min_Uiso ## now take half of the smallest principal component of T and ## move it into the individual atomic temperature factors min_T = min(T[0,0], min(T[1,1], T[2,2])) sub_T = min_T * 0.80 add_Uiso = min_T - sub_T T[0,0] = T[0,0] - sub_T T[1,1] = T[1,1] - sub_T T[2,2] = T[2,2] - sub_T ## rotate T back to original orientation tls_group.T = matrixmultiply(transpose(TR), matrixmultiply(T, TR)) ## reset the TLS tensor values in the TLSDesc object so they can be ## saved tls_group.tls_desc.set_tls_group(tls_group) ## set atm.temp_factor for atm, Utls in tls_group.iter_atm_Utls(): for aatm in atm.iter_alt_loc(): tls_tf = trace(Utls)/3.0 ref_tf = trace(aatm.get_U())/3.0 if ref_tf>tls_tf: aatm.temp_factor = ((add_Uiso) + ref_tf - tls_tf)*U2B aatm.U = None else: aatm.temp_factor = (add_Uiso) * U2B aatm.U = None SaveStructure(fil=xyzout, struct=struct) tls_file.save(open(tlsout, "w"))
| 6,541
|
def refmac5_prep(xyzin, tlsin, xyzout, tlsout): """Use TLS model + Uiso for each atom. Output xyzout with the residual Uiso only. """ os.umask(022) ## load structure struct = LoadStructure(fil = xyzin) ## load and construct TLS groups tls_group_list = [] tls_file = TLSFile() tls_file.set_file_format(TLSFileFormatTLSOUT()) tls_file.load(open(tlsin, "r")) for tls_desc in tls_file.tls_desc_list: tls_group = tls_desc.construct_tls_group_with_atoms(struct) fit_tls_group(tls_group) tls_group.tls_desc = tls_desc tls_group_list.append(tls_group) ## set the extra Uiso for each atom for tls_group in tls_group_list: ## minimal/maximal amount of Uiso which has to be added ## to the group's atoms to to make Uiso == Uiso_tls min_Uiso = 0.0 max_Uiso = 0.0 n = 0 sum_diff2 = 0.0 for atm, Utls in tls_group.iter_atm_Utls(): for aatm in atm.iter_alt_loc(): tls_tf = trace(Utls)/3.0 ref_tf = trace(aatm.get_U())/3.0 n += 1 sum_diff2 += (tls_tf - ref_tf)**2 if ref_tf>tls_tf: max_Uiso = max(ref_tf - tls_tf, max_Uiso) else: min_Uiso = max(tls_tf - ref_tf, min_Uiso) msd = sum_diff2 / n rmsd = math.sqrt(msd) ## report the percentage of atoms with Uiso within the RMSD ntotal = 0 nrmsd = 0 for atm, Utls in tls_group.iter_atm_Utls(): for aatm in atm.iter_alt_loc(): tls_tf = trace(Utls)/3.0 ref_tf = trace(aatm.get_U())/3.0 ntotal += 1 deviation = math.sqrt((tls_tf - ref_tf)**2) if deviation<=rmsd: nrmsd += 1 ## reduce the TLS group T tensor by min_Uiso so that ## a PDB file can be written out where all atoms ## Uiso == Uiso_tls ## we must rotate the T tensor to its primary axes before ## subtracting min_Uiso magnitude from it (T_eval, TR) = eigenvectors(tls_group.T) T = matrixmultiply(TR, matrixmultiply(tls_group.T, transpose(TR))) assert allclose(T[0,1], 0.0) assert allclose(T[0,2], 0.0) assert allclose(T[1,2], 0.0) T[0,0] = T[0,0] - min_Uiso T[1,1] = T[1,1] - min_Uiso T[2,2] = T[2,2] - min_Uiso ## now take half of the smallest principal component of T and ## move it into the individual atomic temperature factors min_T = min(T[0,0], min(T[1,1], T[2,2])) sub_T = min_T * 0.80 add_Uiso = min_T - sub_T T[0,0] = T[0,0] - sub_T T[1,1] = T[1,1] - sub_T T[2,2] = T[2,2] - sub_T ## rotate T back to original orientation tls_group.T = matrixmultiply(transpose(TR), matrixmultiply(T, TR)) ## reset the TLS tensor values in the TLSDesc object so they can be ## saved tls_group.tls_desc.set_tls_group(tls_group) ## set atm.temp_factor for atm, Utls in tls_group.iter_atm_Utls(): for aatm in atm.iter_alt_loc(): tls_tf = trace(Utls)/3.0 ref_tf = trace(aatm.get_U())/3.0 if ref_tf>tls_tf: aatm.temp_factor = ((add_Uiso) + ref_tf - tls_tf)*U2B aatm.U = None else: aatm.temp_factor = (add_Uiso) * U2B aatm.U = None SaveStructure(fil=xyzout, struct=struct) tls_file.save(open(tlsout, "w"))
|
def refmac5_prep(xyzin, tlsin, xyzout, tlsout): """Use TLS model + Uiso for each atom. Output xyzout with the residual Uiso only. """ os.umask(022) ## load structure struct = LoadStructure(fil = xyzin) ## load and construct TLS groups tls_group_list = [] tls_file = TLSFile() tls_file.set_file_format(TLSFileFormatTLSOUT()) tls_file.load(open(tlsin, "r")) for tls_desc in tls_file.tls_desc_list: tls_group = tls_desc.construct_tls_group_with_atoms(struct) fit_tls_group(tls_group) tls_group.tls_desc = tls_desc tls_group_list.append(tls_group) ## set the extra Uiso for each atom for tls_group in tls_group_list: ## minimal/maximal amount of Uiso which has to be added ## to the group's atoms to to make Uiso == Uiso_tls min_Uiso = 0.0 max_Uiso = 0.0 n = 0 sum_diff2 = 0.0 for atm, Utls in tls_group.iter_atm_Utls(): for aatm in atm.iter_alt_loc(): tls_tf = trace(Utls)/3.0 ref_tf = trace(aatm.get_U())/3.0 n += 1 sum_diff2 += (tls_tf - ref_tf)**2 if ref_tf>tls_tf: max_Uiso = max(ref_tf - tls_tf, max_Uiso) else: min_Uiso = max(tls_tf - ref_tf, min_Uiso) msd = sum_diff2 / n rmsd = math.sqrt(msd) ## report the percentage of atoms with Uiso within the RMSD ntotal = 0 nrmsd = 0 for atm, Utls in tls_group.iter_atm_Utls(): for aatm in atm.iter_alt_loc(): tls_tf = trace(Utls)/3.0 ref_tf = trace(aatm.get_U())/3.0 ntotal += 1 deviation = math.sqrt((tls_tf - ref_tf)**2) if deviation<=rmsd: nrmsd += 1 ## reduce the TLS group T tensor by min_Uiso so that ## a PDB file can be written out where all atoms ## Uiso == Uiso_tls ## we must rotate the T tensor to its primary axes before ## subtracting min_Uiso magnitude from it (T_eval, TR) = eigenvectors(tls_group.T) T = matrixmultiply(TR, matrixmultiply(tls_group.T, transpose(TR))) assert allclose(T[0,1], 0.0) assert allclose(T[0,2], 0.0) assert allclose(T[1,2], 0.0) T[0,0] = T[0,0] - min_Uiso T[1,1] = T[1,1] - min_Uiso T[2,2] = T[2,2] - min_Uiso ## now take half of the smallest principal component of T and ## move it into the individual atomic temperature factors min_T = min(T[0,0], min(T[1,1], T[2,2])) sub_T = min_T * 0.80 add_Uiso = min_T - sub_T T[0,0] = T[0,0] - sub_T T[1,1] = T[1,1] - sub_T T[2,2] = T[2,2] - sub_T ## rotate T back to original orientation tls_group.T = matrixmultiply(transpose(TR), matrixmultiply(T, TR)) ## reset the TLS tensor values in the TLSDesc object so they can be ## saved tls_group.tls_desc.set_tls_group(tls_group) ## set atm.temp_factor for atm, Utls in tls_group.iter_atm_Utls(): for aatm in atm.iter_alt_loc(): tls_tf = trace(Utls)/3.0 ref_tf = trace(aatm.get_U())/3.0 if ref_tf>tls_tf: aatm.temp_factor = ((add_Uiso) + ref_tf - tls_tf)*U2B aatm.U = None else: aatm.temp_factor = (add_Uiso) * U2B aatm.U = None SaveStructure(fil=xyzout, struct=struct) tls_file.save(open(tlsout, "w"))
| 6,542
|
def atom_common(arec1, arec2): arec2["serial"] = arec1["serial"] arec2["chainID"] = arec1["chainID"] arec2["resName"] = arec1["resName"] arec2["resSeq"] = arec1["resSeq"] arec2["iCode"] = arec1["iCode"] arec2["name"] = arec1["name"] arec2["altLoc"] = arec1["altLoc"] arec2["element"] = arec1["element"] arec2["charge"] = arec1["charge"]
|
def atom_common(arec1, arec2): arec2["serial"] = arec1["serial"] arec2["chainID"] = arec1["chainID"] arec2["resName"] = arec1["resName"] arec2["resSeq"] = arec1["resSeq"] arec2["iCode"] = arec1["iCode"] arec2["name"] = arec1["name"] arec2["altLoc"] = arec1["altLoc"] arec2["element"] = arec1["element"] arec2["charge"] = arec1["charge"]
| 6,543
|
def atom_common(arec1, arec2): arec2["serial"] = arec1["serial"] arec2["chainID"] = arec1["chainID"] arec2["resName"] = arec1["resName"] arec2["resSeq"] = arec1["resSeq"] arec2["iCode"] = arec1["iCode"] arec2["name"] = arec1["name"] arec2["altLoc"] = arec1["altLoc"] arec2["element"] = arec1["element"] arec2["charge"] = arec1["charge"]
|
def atom_common(arec1, arec2): arec2["serial"] = arec1["serial"] arec2["chainID"] = arec1["chainID"] arec2["resName"] = arec1["resName"] arec2["resSeq"] = arec1["resSeq"] arec2["iCode"] = arec1["iCode"] arec2["name"] = arec1["name"] arec2["altLoc"] = arec1["altLoc"] arec2["element"] = arec1["element"] arec2["charge"] = arec1["charge"]
| 6,544
|
def atom_common(arec1, arec2): arec2["serial"] = arec1["serial"] arec2["chainID"] = arec1["chainID"] arec2["resName"] = arec1["resName"] arec2["resSeq"] = arec1["resSeq"] arec2["iCode"] = arec1["iCode"] arec2["name"] = arec1["name"] arec2["altLoc"] = arec1["altLoc"] arec2["element"] = arec1["element"] arec2["charge"] = arec1["charge"]
|
def atom_common(arec1, arec2): arec2["serial"] = arec1["serial"] arec2["chainID"] = arec1["chainID"] arec2["resName"] = arec1["resName"] arec2["resSeq"] = arec1["resSeq"] arec2["iCode"] = arec1["iCode"] arec2["name"] = arec1["name"] arec2["altLoc"] = arec1["altLoc"] arec2["element"] = arec1["element"] arec2["charge"] = arec1["charge"]
| 6,545
|
def __init__(self): ## bars are 15 pixels heigh self.pheight = ALIGN_HEIGHT ## spacing pixels between stacked bars self.spacing = ALIGN_SPACING ## background color self.bg_color = rgb_f2i((1.0, 1.0, 1.0)) self.frag_list = [] self.segmentations = []
|
def __init__(self): ## bars are 15 pixels heigh self.pheight = ALIGN_HEIGHT ## spacing pixels between stacked bars self.spacing = ALIGN_SPACING ## background color self.bg_color = rgb_f2i((1.0, 1.0, 1.0)) self.frag_list = [] self.segmentations = []
| 6,546
|
def add_tls_segmentation(self, chainopt, ntls): """Add a TLS optimization to the alignment plot. """ tlsopt = chainopt["tlsopt"][ntls] ## get the list of TLS segments for the specified number of ## segments (ntls) tls_seg_desc = {} self.segmentations.append(tls_seg_desc) tls_seg_desc["chainopt"] = chainopt tls_seg_desc["ntls"] = ntls tls_seg_desc["tlsopt"] = tlsopt ## update the master fragment_list self.__update_frag_list(chainopt["chain"], tlsopt)
|
def add_tls_segmentation(self, chainopt, ntls): """Add a TLS optimization to the alignment plot. """ tlsopt = chainopt["tlsopt"][ntls] ## get the list of TLS segments for the specified number of ## segments (ntls) tls_seg_desc = {} self.configurations.append(tls_seg_desc) tls_seg_desc["chainopt"] = chainopt tls_seg_desc["ntls"] = ntls tls_seg_desc["tlsopt"] = tlsopt ## update the master fragment_list self.__update_frag_list(chainopt["chain"], tlsopt)
| 6,547
|
def plot(self, path): """Plot and write the png plot image to the specified path. """ if len(self.frag_list)==0 or len(self.segmentations)==0: return False nfrag = len(self.frag_list) target_width = 500 fw = int(round(float(ALIGN_TARGET_WIDTH) / nfrag)) fwidth = max(1, fw)
|
def plot(self, path): """Plot and write the png plot image to the specified path. """ if len(self.frag_list)==0 or len(self.configurations)==0: return False nfrag = len(self.frag_list) target_width = 500 fw = int(round(float(ALIGN_TARGET_WIDTH) / nfrag)) fwidth = max(1, fw)
| 6,548
|
def plot(self, path): """Plot and write the png plot image to the specified path. """ if len(self.frag_list)==0 or len(self.segmentations)==0: return False nfrag = len(self.frag_list) target_width = 500 fw = int(round(float(ALIGN_TARGET_WIDTH) / nfrag)) fwidth = max(1, fw)
|
def plot(self, path): """Plot and write the png plot image to the specified path. """ if len(self.frag_list)==0 or len(self.segmentations)==0: return False nfrag = len(self.frag_list) target_width = 500 fw = int(round(float(ALIGN_TARGET_WIDTH) / nfrag)) fwidth = max(1, fw)
| 6,549
|
def plot(self, path): """Plot and write the png plot image to the specified path. """ if len(self.frag_list)==0 or len(self.segmentations)==0: return False nfrag = len(self.frag_list) target_width = 500 fw = int(round(float(ALIGN_TARGET_WIDTH) / nfrag)) fwidth = max(1, fw)
|
def plot(self, path): """Plot and write the png plot image to the specified path. """ if len(self.frag_list)==0 or len(self.segmentations)==0: return False nfrag = len(self.frag_list) target_width = 500 fw = int(round(float(ALIGN_TARGET_WIDTH) / nfrag)) fwidth = max(1, fw)
| 6,550
|
def calc_include_atom(atm, reject_messages = False): """Filter out atoms from the model which will cause problems or cont contribute to the TLS analysis. """ if atm.position == None: return False if atm.occupancy < 0.1: if reject_messages == True: console.stdoutln("calc_include_atom(%s): rejected because of low occupancy" % (atm)) return False if numpy.trace(atm.get_U()) <= const.TSMALL: if reject_messages == True: console.stdoutln("calc_include_atom(%s): rejected because of small Uiso magnitude " % (atm)) return False elif conf.globalconf.include_atoms == "MAINCHAIN": if const.MAINCHAIN_ATOM_DICT.has_key(atom.name) is False: if reject_messages == True: console.stdoutln("calc_include_atom(%s): rejected non-mainchain atom" % (atm)) return False return True
|
def calc_include_atom(atm, reject_messages = False): """Filter out atoms from the model which will cause problems or cont contribute to the TLS analysis. """ if atm.position == None: return False if atm.occupancy < 0.1: if reject_messages == True: console.stdoutln("calc_include_atom(%s): rejected because of low occupancy" % (atm)) return False if numpy.trace(atm.get_U()) <= const.TSMALL: if reject_messages == True: console.stdoutln("calc_include_atom(%s): rejected because of small Uiso magnitude " % (atm)) return False elif conf.globalconf.include_atoms == "MAINCHAIN": if const.MAINCHAIN_ATOM_DICT.has_key(atm.name) is False: if reject_messages == True: console.stdoutln("calc_include_atom(%s): rejected non-mainchain atom" % (atm)) return False return True
| 6,551
|
def __init__(self): self.visible = True self.width = 0 self.height = 0 self.zplane = 5000.0
|
def __init__(self): self.visible = True self.width = 0 self.height = 0 self.zplane = 5000.0
| 6,552
|
def lsq_fit_segment(self, frag_id1, frag_id2): """Performs a LSQ fit of TLS parameters for the protein segment starting with fragment index ifrag_start to (and including) the fragment ifrag_end. """ ## all return values here fit_info = {} ## calculate the start/end indexes of the start fragment ## and end fragment so the A matrix and b vector can be sliced ## in the correct placees
|
def lsq_fit_segment(self, frag_id1, frag_id2): """Performs a LSQ fit of TLS parameters for the protein segment starting with fragment index ifrag_start to (and including) the fragment ifrag_end. """ ## all return values here fit_info = {} ## calculate the start/end indexes of the start fragment ## and end fragment so the A matrix and b vector can be sliced ## in the correct placees
| 6,553
|
def load_atom(self, atm_map): """Called repeatedly by the implementation of read_atoms to load all the data for a single atom. The data is contained in the atm_map argument, and is not well documented at this point. Look at this function and you'll figure it out. """ ## XXX -- I presently do not support more than one NMR ## style MODEL; this is first on the list for the ## next version if atm_map.has_key("model_num") and atm_map["model_num"] > 1: debug("NMR-style multi-models not supported yet") return ## /XXX
|
def load_atom(self, atm_map): """Called repeatedly by the implementation of read_atoms to load all the data for a single atom. The data is contained in the atm_map argument, and is not well documented at this point. Look at this function and you'll figure it out. """ ## XXX -- I presently do not support more than one NMR ## style MODEL; this is first on the list for the ## next version if atm_map.has_key("model_num") and atm_map["model_num"] > 1: debug("NMR-style multi-models not supported yet") return ## /XXX
| 6,554
|
def load_atom(self, atm_map): """Called repeatedly by the implementation of read_atoms to load all the data for a single atom. The data is contained in the atm_map argument, and is not well documented at this point. Look at this function and you'll figure it out. """ ## XXX -- I presently do not support more than one NMR ## style MODEL; this is first on the list for the ## next version if atm_map.has_key("model_num") and atm_map["model_num"] > 1: debug("NMR-style multi-models not supported yet") return ## /XXX
|
defload_atom(self,atm_map):"""Calledrepeatedlybytheimplementationofread_atomstoloadallthedataforasingleatom.Thedataiscontainedintheatm_mapargument,andisnotwelldocumentedatthispoint.Lookatthisfunctionandyou'llfigureitout."""##XXX--IpresentlydonotsupportmorethanoneNMR##styleMODEL;thisisfirstonthelistforthe##nextversionifatm_map.has_key("model_num")andatm_map["model_num"]>1:debug("NMR-stylemulti-modelsnotsupportedyet")return##/XXX
| 6,555
|
def load_atom(self, atm_map): """Called repeatedly by the implementation of read_atoms to load all the data for a single atom. The data is contained in the atm_map argument, and is not well documented at this point. Look at this function and you'll figure it out. """ ## XXX -- I presently do not support more than one NMR ## style MODEL; this is first on the list for the ## next version if atm_map.has_key("model_num") and atm_map["model_num"] > 1: debug("NMR-style multi-models not supported yet") return ## /XXX
|
def load_atom(self, atm_map): """Called repeatedly by the implementation of read_atoms to load all the data for a single atom. The data is contained in the atm_map argument, and is not well documented at this point. Look at this function and you'll figure it out. """ ## XXX -- I presently do not support more than one NMR ## style MODEL; this is first on the list for the ## next version if atm_map.has_key("model_num") and atm_map["model_num"] > 1: debug("NMR-style multi-models not supported yet") return ## /XXX
| 6,556
|
def load_atom(self, atm_map): """Called repeatedly by the implementation of read_atoms to load all the data for a single atom. The data is contained in the atm_map argument, and is not well documented at this point. Look at this function and you'll figure it out. """ ## XXX -- I presently do not support more than one NMR ## style MODEL; this is first on the list for the ## next version if atm_map.has_key("model_num") and atm_map["model_num"] > 1: debug("NMR-style multi-models not supported yet") return ## /XXX
|
def atm_id = (name, alt_loc, fragment_id, chain_id) load_atom(self, atm_id = (name, alt_loc, fragment_id, chain_id) atm_map): atm_id = (name, alt_loc, fragment_id, chain_id) """Called atm_id = (name, alt_loc, fragment_id, chain_id) repeatedly atm_id = (name, alt_loc, fragment_id, chain_id) by atm_id = (name, alt_loc, fragment_id, chain_id) the atm_id = (name, alt_loc, fragment_id, chain_id) implementation atm_id = (name, alt_loc, fragment_id, chain_id) of atm_id = (name, alt_loc, fragment_id, chain_id) read_atoms atm_id = (name, alt_loc, fragment_id, chain_id) to atm_id = (name, alt_loc, fragment_id, chain_id) load atm_id = (name, alt_loc, fragment_id, chain_id) all atm_id = (name, alt_loc, fragment_id, chain_id) the atm_id = (name, alt_loc, fragment_id, chain_id) data atm_id = (name, alt_loc, fragment_id, chain_id) for atm_id = (name, alt_loc, fragment_id, chain_id) a atm_id = (name, alt_loc, fragment_id, chain_id) single atm_id = (name, alt_loc, fragment_id, chain_id) atom. atm_id = (name, alt_loc, fragment_id, chain_id) atm_id = (name, alt_loc, fragment_id, chain_id) The atm_id = (name, alt_loc, fragment_id, chain_id) data atm_id = (name, alt_loc, fragment_id, chain_id) is atm_id = (name, alt_loc, fragment_id, chain_id) contained atm_id = (name, alt_loc, fragment_id, chain_id) in atm_id = (name, alt_loc, fragment_id, chain_id) the atm_id = (name, alt_loc, fragment_id, chain_id) atm_map atm_id = (name, alt_loc, fragment_id, chain_id) argument, atm_id = (name, alt_loc, fragment_id, chain_id) and atm_id = (name, alt_loc, fragment_id, chain_id) is atm_id = (name, alt_loc, fragment_id, chain_id) not atm_id = (name, alt_loc, fragment_id, chain_id) well atm_id = (name, alt_loc, fragment_id, chain_id) documented atm_id = (name, alt_loc, fragment_id, chain_id) at atm_id = (name, alt_loc, fragment_id, chain_id) this atm_id = (name, alt_loc, fragment_id, chain_id) point. atm_id = (name, alt_loc, fragment_id, chain_id) atm_id = (name, alt_loc, fragment_id, chain_id) Look atm_id = (name, alt_loc, fragment_id, chain_id) at atm_id = (name, alt_loc, fragment_id, chain_id) this atm_id = (name, alt_loc, fragment_id, chain_id) function atm_id = (name, alt_loc, fragment_id, chain_id) and atm_id = (name, alt_loc, fragment_id, chain_id) you'll atm_id = (name, alt_loc, fragment_id, chain_id) figure atm_id = (name, alt_loc, fragment_id, chain_id) it atm_id = (name, alt_loc, fragment_id, chain_id) out. atm_id = (name, alt_loc, fragment_id, chain_id) """ atm_id = (name, alt_loc, fragment_id, chain_id) ## atm_id = (name, alt_loc, fragment_id, chain_id) XXX atm_id = (name, alt_loc, fragment_id, chain_id) -- atm_id = (name, alt_loc, fragment_id, chain_id) I atm_id = (name, alt_loc, fragment_id, chain_id) presently atm_id = (name, alt_loc, fragment_id, chain_id) do atm_id = (name, alt_loc, fragment_id, chain_id) not atm_id = (name, alt_loc, fragment_id, chain_id) support atm_id = (name, alt_loc, fragment_id, chain_id) more atm_id = (name, alt_loc, fragment_id, chain_id) than atm_id = (name, alt_loc, fragment_id, chain_id) one atm_id = (name, alt_loc, fragment_id, chain_id) NMR atm_id = (name, alt_loc, fragment_id, chain_id) ## atm_id = (name, alt_loc, fragment_id, chain_id) atm_id = (name, alt_loc, fragment_id, chain_id) atm_id = (name, alt_loc, fragment_id, chain_id) atm_id = (name, alt_loc, fragment_id, chain_id) atm_id = (name, alt_loc, fragment_id, chain_id) atm_id = (name, alt_loc, fragment_id, chain_id) atm_id = (name, alt_loc, fragment_id, chain_id) atm_id = (name, alt_loc, fragment_id, chain_id) style atm_id = (name, alt_loc, fragment_id, chain_id) MODEL; atm_id = (name, alt_loc, fragment_id, chain_id) this atm_id = (name, alt_loc, fragment_id, chain_id) is atm_id = (name, alt_loc, fragment_id, chain_id) first atm_id = (name, alt_loc, fragment_id, chain_id) on atm_id = (name, alt_loc, fragment_id, chain_id) the atm_id = (name, alt_loc, fragment_id, chain_id) list atm_id = (name, alt_loc, fragment_id, chain_id) for atm_id = (name, alt_loc, fragment_id, chain_id) the atm_id = (name, alt_loc, fragment_id, chain_id) ## atm_id = (name, alt_loc, fragment_id, chain_id) atm_id = (name, alt_loc, fragment_id, chain_id) atm_id = (name, alt_loc, fragment_id, chain_id) atm_id = (name, alt_loc, fragment_id, chain_id) atm_id = (name, alt_loc, fragment_id, chain_id) atm_id = (name, alt_loc, fragment_id, chain_id) atm_id = (name, alt_loc, fragment_id, chain_id) atm_id = (name, alt_loc, fragment_id, chain_id) next atm_id = (name, alt_loc, fragment_id, chain_id) version atm_id = (name, alt_loc, fragment_id, chain_id) if atm_id = (name, alt_loc, fragment_id, chain_id) atm_map.has_key("model_num") atm_id = (name, alt_loc, fragment_id, chain_id) and atm_id = (name, alt_loc, fragment_id, chain_id) atm_map["model_num"] atm_id = (name, alt_loc, fragment_id, chain_id) > atm_id = (name, alt_loc, fragment_id, chain_id) 1: atm_id = (name, alt_loc, fragment_id, chain_id) debug("NMR-style atm_id = (name, alt_loc, fragment_id, chain_id) multi-models atm_id = (name, alt_loc, fragment_id, chain_id) not atm_id = (name, alt_loc, fragment_id, chain_id) supported atm_id = (name, alt_loc, fragment_id, chain_id) yet") atm_id = (name, alt_loc, fragment_id, chain_id) return atm_id = (name, alt_loc, fragment_id, chain_id) ## atm_id = (name, alt_loc, fragment_id, chain_id) /XXX
| 6,557
|
def load_atom(self, atm_map): """Called repeatedly by the implementation of read_atoms to load all the data for a single atom. The data is contained in the atm_map argument, and is not well documented at this point. Look at this function and you'll figure it out. """ ## XXX -- I presently do not support more than one NMR ## style MODEL; this is first on the list for the ## next version if atm_map.has_key("model_num") and atm_map["model_num"] > 1: debug("NMR-style multi-models not supported yet") return ## /XXX
|
def load_atom(self, atm_map): """Called repeatedly by the implementation of read_atoms to load all the data for a single atom. The data is contained in the atm_map argument, and is not well documented at this point. Look at this function and you'll figure it out. """ ## XXX -- I presently do not support more than one NMR ## style MODEL; this is first on the list for the ## next version if atm_map.has_key("model_num") and atm_map["model_num"] > 1: debug("NMR-style multi-models not supported yet") return ## /XXX
| 6,558
|
def close(self): for fil in self.fils: fil.close()
|
def close(self): for fil in self.fils: fil.close()
| 6,559
|
def close(self): for fil in self.fils: fil.close()
|
def close(self): for fil in self.fils: fil.close()
| 6,560
|
def atom_test(atom, stats): """Tests the mmLib.Structure.Atom object. """ stats["atom_count"] += 1 stats["testing"] = atom len(atom) alt_loc = atom.get_structure().get_default_alt_loc() atom.get_fragment() atom.get_chain() atom.get_model() atom.get_structure() visited_atm_list = [] for atm in atom.iter_alt_loc(): assert isinstance(atm, Atom) assert atm in atom assert atm not in visited_atm_list visited_atm_list.append(atm) assert atm[atom.alt_loc] == atom assert atm.get_fragment() == atom.get_fragment() assert atm.get_chain() == atom.get_chain() assert atm.get_structure() == atom.get_structure() assert atm.name == atom.name assert atm.res_name == atom.res_name assert atm.fragment_id == atom.fragment_id assert atm.chain_id == atom.chain_id atom.calc_anisotropy() atom.calc_anisotropy3()
|
def atom_test(atom, stats): """Tests the mmLib.Structure.Atom object. """ stats["atom_count"] += 1 stats["testing"] = atom len(atom) alt_loc = atom.get_structure().get_default_alt_loc() atom.get_fragment() atom.get_chain() atom.get_model() atom.get_structure() visited_atm_list = [] for atm in atom.iter_alt_loc(): assert isinstance(atm, Atom) assert atm in atom assert atm not in visited_atm_list visited_atm_list.append(atm) assert atm[atom.alt_loc] == atom assert atm.get_fragment() == atom.get_fragment() assert atm.get_chain() == atom.get_chain() assert atm.get_structure() == atom.get_structure() assert atm.name == atom.name assert atm.res_name == atom.res_name assert atm.fragment_id == atom.fragment_id assert atm.chain_id == atom.chain_id try: atom.calc_anisotropy() except ZeroDivisionError: pass try: atom.calc_anisotropy3() except ZeroDivisionError: pass
| 6,561
|
def __str__(self): try: frag1 = self.segment[0] frag2 = self.segment[-1] except IndexError: return "AlphaHelix(%s %d)" % (self.helix_id, self.helix_class)
|
def __str__(self): try: frag1 = self.segment[0] frag2 = self.segment[-1] except IndexError: return "AlphaHelix(%s %d)" % (self.helix_id, self.helix_class)
| 6,562
|
def refmac5_prep(xyzin, tlsin_list, xyzout, tlsout): """Use TLS model + Uiso for each atom. Output xyzout with the residual Uiso only. """ os.umask(022) ## load structure struct = FileLoader.LoadStructure(fil = xyzin) ## load and construct TLS groups tls_group_list = [] tls_file = TLS.TLSFile() tls_file.set_file_format(TLS.TLSFileFormatTLSOUT()) tls_file_format = TLS.TLSFileFormatTLSOUT() for tlsin in tlsin_list: tls_desc_list = tls_file_format.load(open(tlsin, "r")) for tls_desc in tls_desc_list: tls_file.tls_desc_list.append(tls_desc) tls_group = tls_desc.construct_tls_group_with_atoms(struct) tls_group.tls_desc = tls_desc tls_group_list.append(tls_group) ## set the extra Uiso for each atom for tls_group in tls_group_list: ## minimal/maximal amount of Uiso which has to be added ## to the group's atoms to to make Uiso == Uiso_tls min_Uiso = 0.0 max_Uiso = 0.0 n = 0 sum_diff2 = 0.0 for atm, Utls in tls_group.iter_atm_Utls(): for aatm in atm.iter_alt_loc(): tls_tf = numpy.trace(Utls)/3.0 ref_tf = numpy.trace(aatm.get_U())/3.0 n += 1 sum_diff2 += (tls_tf - ref_tf)**2 if ref_tf>tls_tf: max_Uiso = max(ref_tf - tls_tf, max_Uiso) else: min_Uiso = max(tls_tf - ref_tf, min_Uiso) msd = sum_diff2 / n rmsd = math.sqrt(msd) ## report the percentage of atoms with Uiso within the RMSD ntotal = 0 nrmsd = 0 for atm, Utls in tls_group.iter_atm_Utls(): for aatm in atm.iter_alt_loc(): tls_tf = numpy.trace(Utls)/3.0 ref_tf = numpy.trace(aatm.get_U())/3.0 ntotal += 1 deviation = math.sqrt((tls_tf - ref_tf)**2) if deviation <= rmsd: nrmsd += 1 ## reduce the TLS group T tensor by min_Uiso so that ## a PDB file can be written out where all atoms ## Uiso == Uiso_tls ## we must rotate the T tensor to its primary axes before ## subtracting min_Uiso magnitude from it (T_eval, TR) = numpy.linalg.eigenvectors(tls_group.T) T = numpy.matrixmultiply(TR, numpy.matrixmultiply(tls_group.T, numpy.transpose(TR))) assert numpy.allclose(T[0,1], 0.0) assert numpy.allclose(T[0,2], 0.0) assert numpy.allclose(T[1,2], 0.0) T[0,0] = T[0,0] - min_Uiso T[1,1] = T[1,1] - min_Uiso T[2,2] = T[2,2] - min_Uiso ## now take half of the smallest principal component of T and ## move it into the individual atomic temperature factors min_T = min(T[0,0], min(T[1,1], T[2,2])) sub_T = min_T * 0.80 add_Uiso = min_T - sub_T T[0,0] = T[0,0] - sub_T T[1,1] = T[1,1] - sub_T T[2,2] = T[2,2] - sub_T ## rotate T back to original orientation tls_group.T = numpy.matrixmultiply(numpy.transpose(TR), numpy.matrixmultiply(T, TR)) ## reset the TLS tensor values in the TLSDesc object so they can be saved tls_group.tls_desc.set_tls_group(tls_group) ## set atm.temp_factor for atm, Utls in tls_group.iter_atm_Utls(): for aatm in atm.iter_alt_loc(): tls_tf = numpy.trace(Utls)/3.0 ref_tf = numpy.trace(aatm.get_U())/3.0 if ref_tf>tls_tf: aatm.temp_factor = ((add_Uiso) + ref_tf - tls_tf)*U2B aatm.U = None else: aatm.temp_factor = (add_Uiso) * U2B aatm.U = None FileLoader.SaveStructure(fil=xyzout, struct=struct) tls_file.save(open(tlsout, "w"))
|
def refmac5_prep(xyzin, tlsin_list, xyzout, tlsout): """Use TLS model + Uiso for each atom. Output xyzout with the residual Uiso only. """ os.umask(022) ## load structure struct = FileLoader.LoadStructure(fil = xyzin) ## load and construct TLS groups tls_group_list = [] tls_file = TLS.TLSFile() tls_file.set_file_format(TLS.TLSFileFormatTLSOUT()) tls_file_format = TLS.TLSFileFormatTLSOUT() for tlsin in tlsin_list: tls_desc_list = tls_file_format.load(open(tlsin, "r")) for tls_desc in tls_desc_list: tls_file.tls_desc_list.append(tls_desc) tls_group = tls_desc.construct_tls_group_with_atoms(struct) tls_group.tls_desc = tls_desc tls_group_list.append(tls_group) ## set the extra Uiso for each atom for tls_group in tls_group_list: ## minimal/maximal amount of Uiso which has to be added ## to the group's atoms to to make Uiso == Uiso_tls min_Uiso = 0.0 max_Uiso = 0.0 n = 0 sum_diff2 = 0.0 for atm, Utls in tls_group.iter_atm_Utls(): for aatm in atm.iter_alt_loc(): tls_tf = numpy.trace(Utls)/3.0 ref_tf = numpy.trace(aatm.get_U())/3.0 n += 1 sum_diff2 += (tls_tf - ref_tf)**2 if ref_tf>tls_tf: max_Uiso = max(ref_tf - tls_tf, max_Uiso) else: min_Uiso = max(tls_tf - ref_tf, min_Uiso) msd = sum_diff2 / n rmsd = math.sqrt(msd) ## report the percentage of atoms with Uiso within the RMSD ntotal = 0 nrmsd = 0 for atm, Utls in tls_group.iter_atm_Utls(): for aatm in atm.iter_alt_loc(): tls_tf = numpy.trace(Utls)/3.0 ref_tf = numpy.trace(aatm.get_U())/3.0 ntotal += 1 deviation = math.sqrt((tls_tf - ref_tf)**2) if deviation <= rmsd: nrmsd += 1 ## reduce the TLS group T tensor by min_Uiso so that ## a PDB file can be written out where all atoms ## Uiso == Uiso_tls ## we must rotate the T tensor to its primary axes before ## subtracting min_Uiso magnitude from it (T_eval, TR) = numpy.linalg.eigenvectors(tls_group.T) T = numpy.matrixmultiply(TR, numpy.matrixmultiply(tls_group.T, numpy.transpose(TR))) assert numpy.allclose(T[0,1], 0.0) assert numpy.allclose(T[0,2], 0.0) assert numpy.allclose(T[1,2], 0.0) T[0,0] = T[0,0] - min_Uiso T[1,1] = T[1,1] - min_Uiso T[2,2] = T[2,2] - min_Uiso ## now take half of the smallest principal component of T and ## move it into the individual atomic temperature factors min_T = min(T[0,0], min(T[1,1], T[2,2])) sub_T = min_T * 0.80 add_Uiso = min_T - sub_T T[0,0] = T[0,0] - sub_T T[1,1] = T[1,1] - sub_T T[2,2] = T[2,2] - sub_T ## rotate T back to original orientation tls_group.T = numpy.matrixmultiply(numpy.transpose(TR), numpy.matrixmultiply(T, TR)) ## reset the TLS tensor values in the TLSDesc object so they can be saved tls_group.tls_desc.set_tls_group(tls_group) ## set atm.temp_factor for atm, Utls in tls_group.iter_atm_Utls(): for aatm in atm.iter_alt_loc(): tls_tf = numpy.trace(Utls)/3.0 ref_tf = numpy.trace(aatm.get_U())/3.0 if ref_tf > tls_tf: aatm.temp_factor = ((add_Uiso) + ref_tf - tls_tf)*Constants.U2B aatm.U = None else: aatm.temp_factor = (add_Uiso) * U2B aatm.U = None FileLoader.SaveStructure(fil=xyzout, struct=struct) tls_file.save(open(tlsout, "w"))
| 6,563
|
def refmac5_prep(xyzin, tlsin_list, xyzout, tlsout): """Use TLS model + Uiso for each atom. Output xyzout with the residual Uiso only. """ os.umask(022) ## load structure struct = FileLoader.LoadStructure(fil = xyzin) ## load and construct TLS groups tls_group_list = [] tls_file = TLS.TLSFile() tls_file.set_file_format(TLS.TLSFileFormatTLSOUT()) tls_file_format = TLS.TLSFileFormatTLSOUT() for tlsin in tlsin_list: tls_desc_list = tls_file_format.load(open(tlsin, "r")) for tls_desc in tls_desc_list: tls_file.tls_desc_list.append(tls_desc) tls_group = tls_desc.construct_tls_group_with_atoms(struct) tls_group.tls_desc = tls_desc tls_group_list.append(tls_group) ## set the extra Uiso for each atom for tls_group in tls_group_list: ## minimal/maximal amount of Uiso which has to be added ## to the group's atoms to to make Uiso == Uiso_tls min_Uiso = 0.0 max_Uiso = 0.0 n = 0 sum_diff2 = 0.0 for atm, Utls in tls_group.iter_atm_Utls(): for aatm in atm.iter_alt_loc(): tls_tf = numpy.trace(Utls)/3.0 ref_tf = numpy.trace(aatm.get_U())/3.0 n += 1 sum_diff2 += (tls_tf - ref_tf)**2 if ref_tf>tls_tf: max_Uiso = max(ref_tf - tls_tf, max_Uiso) else: min_Uiso = max(tls_tf - ref_tf, min_Uiso) msd = sum_diff2 / n rmsd = math.sqrt(msd) ## report the percentage of atoms with Uiso within the RMSD ntotal = 0 nrmsd = 0 for atm, Utls in tls_group.iter_atm_Utls(): for aatm in atm.iter_alt_loc(): tls_tf = numpy.trace(Utls)/3.0 ref_tf = numpy.trace(aatm.get_U())/3.0 ntotal += 1 deviation = math.sqrt((tls_tf - ref_tf)**2) if deviation <= rmsd: nrmsd += 1 ## reduce the TLS group T tensor by min_Uiso so that ## a PDB file can be written out where all atoms ## Uiso == Uiso_tls ## we must rotate the T tensor to its primary axes before ## subtracting min_Uiso magnitude from it (T_eval, TR) = numpy.linalg.eigenvectors(tls_group.T) T = numpy.matrixmultiply(TR, numpy.matrixmultiply(tls_group.T, numpy.transpose(TR))) assert numpy.allclose(T[0,1], 0.0) assert numpy.allclose(T[0,2], 0.0) assert numpy.allclose(T[1,2], 0.0) T[0,0] = T[0,0] - min_Uiso T[1,1] = T[1,1] - min_Uiso T[2,2] = T[2,2] - min_Uiso ## now take half of the smallest principal component of T and ## move it into the individual atomic temperature factors min_T = min(T[0,0], min(T[1,1], T[2,2])) sub_T = min_T * 0.80 add_Uiso = min_T - sub_T T[0,0] = T[0,0] - sub_T T[1,1] = T[1,1] - sub_T T[2,2] = T[2,2] - sub_T ## rotate T back to original orientation tls_group.T = numpy.matrixmultiply(numpy.transpose(TR), numpy.matrixmultiply(T, TR)) ## reset the TLS tensor values in the TLSDesc object so they can be saved tls_group.tls_desc.set_tls_group(tls_group) ## set atm.temp_factor for atm, Utls in tls_group.iter_atm_Utls(): for aatm in atm.iter_alt_loc(): tls_tf = numpy.trace(Utls)/3.0 ref_tf = numpy.trace(aatm.get_U())/3.0 if ref_tf>tls_tf: aatm.temp_factor = ((add_Uiso) + ref_tf - tls_tf)*U2B aatm.U = None else: aatm.temp_factor = (add_Uiso) * U2B aatm.U = None FileLoader.SaveStructure(fil=xyzout, struct=struct) tls_file.save(open(tlsout, "w"))
|
def refmac5_prep(xyzin, tlsin_list, xyzout, tlsout): """Use TLS model + Uiso for each atom. Output xyzout with the residual Uiso only. """ os.umask(022) ## load structure struct = FileLoader.LoadStructure(fil = xyzin) ## load and construct TLS groups tls_group_list = [] tls_file = TLS.TLSFile() tls_file.set_file_format(TLS.TLSFileFormatTLSOUT()) tls_file_format = TLS.TLSFileFormatTLSOUT() for tlsin in tlsin_list: tls_desc_list = tls_file_format.load(open(tlsin, "r")) for tls_desc in tls_desc_list: tls_file.tls_desc_list.append(tls_desc) tls_group = tls_desc.construct_tls_group_with_atoms(struct) tls_group.tls_desc = tls_desc tls_group_list.append(tls_group) ## set the extra Uiso for each atom for tls_group in tls_group_list: ## minimal/maximal amount of Uiso which has to be added ## to the group's atoms to to make Uiso == Uiso_tls min_Uiso = 0.0 max_Uiso = 0.0 n = 0 sum_diff2 = 0.0 for atm, Utls in tls_group.iter_atm_Utls(): for aatm in atm.iter_alt_loc(): tls_tf = numpy.trace(Utls)/3.0 ref_tf = numpy.trace(aatm.get_U())/3.0 n += 1 sum_diff2 += (tls_tf - ref_tf)**2 if ref_tf>tls_tf: max_Uiso = max(ref_tf - tls_tf, max_Uiso) else: min_Uiso = max(tls_tf - ref_tf, min_Uiso) msd = sum_diff2 / n rmsd = math.sqrt(msd) ## report the percentage of atoms with Uiso within the RMSD ntotal = 0 nrmsd = 0 for atm, Utls in tls_group.iter_atm_Utls(): for aatm in atm.iter_alt_loc(): tls_tf = numpy.trace(Utls)/3.0 ref_tf = numpy.trace(aatm.get_U())/3.0 ntotal += 1 deviation = math.sqrt((tls_tf - ref_tf)**2) if deviation <= rmsd: nrmsd += 1 ## reduce the TLS group T tensor by min_Uiso so that ## a PDB file can be written out where all atoms ## Uiso == Uiso_tls ## we must rotate the T tensor to its primary axes before ## subtracting min_Uiso magnitude from it (T_eval, TR) = numpy.linalg.eigenvectors(tls_group.T) T = numpy.matrixmultiply(TR, numpy.matrixmultiply(tls_group.T, numpy.transpose(TR))) assert numpy.allclose(T[0,1], 0.0) assert numpy.allclose(T[0,2], 0.0) assert numpy.allclose(T[1,2], 0.0) T[0,0] = T[0,0] - min_Uiso T[1,1] = T[1,1] - min_Uiso T[2,2] = T[2,2] - min_Uiso ## now take half of the smallest principal component of T and ## move it into the individual atomic temperature factors min_T = min(T[0,0], min(T[1,1], T[2,2])) sub_T = min_T * 0.80 add_Uiso = min_T - sub_T T[0,0] = T[0,0] - sub_T T[1,1] = T[1,1] - sub_T T[2,2] = T[2,2] - sub_T ## rotate T back to original orientation tls_group.T = numpy.matrixmultiply(numpy.transpose(TR), numpy.matrixmultiply(T, TR)) ## reset the TLS tensor values in the TLSDesc object so they can be saved tls_group.tls_desc.set_tls_group(tls_group) ## set atm.temp_factor for atm, Utls in tls_group.iter_atm_Utls(): for aatm in atm.iter_alt_loc(): tls_tf = numpy.trace(Utls)/3.0 ref_tf = numpy.trace(aatm.get_U())/3.0 if ref_tf>tls_tf: aatm.temp_factor = ((add_Uiso) + ref_tf - tls_tf)*U2B aatm.U = None else: aatm.temp_factor = (add_Uiso) * Constants.U2B aatm.U = None FileLoader.SaveStructure(fil=xyzout, struct=struct) tls_file.save(open(tlsout, "w"))
| 6,564
|
def html_page(self): job_id = check_job_id(self.form) title = 'Input Files for Refmac5 TLS Refinement' x = '' x += self.html_head(title) x += self.html_title(title)
|
def html_page(self): job_id = check_job_id(self.form) title = 'Input Files for Refmac5 TLS Refinement' x = '' x += self.html_head(title) x += self.html_title(title)
| 6,565
|
def isatty(self): return 1
|
def isatty(self): return 1
| 6,566
|
def main(self, argv, noshell): cmd = None edit = 0 debug = 0 startup = 0 try: opts, args = getopt.getopt(argv, "c:deist:") except getopt.error, msg: sys.stderr.write("Error: %s\n" % str(msg)) sys.stderr.write(usage_msg) sys.exit(2) for o, a in opts: noshell = 0 if o == '-c': cmd = a if o == '-d': debug = 1 if o == '-e': edit = 1 if o == '-s': startup = 1 if o == '-t': PyShell.shell_title = a if noshell: edit=1 for i in range(len(sys.path)): sys.path[i] = os.path.abspath(sys.path[i]) pathx = [] if edit: for filename in args: pathx.append(os.path.dirname(filename)) elif args and args[0] != "-": pathx.append(os.path.dirname(args[0])) else: pathx.append(os.curdir) for dir in pathx: dir = os.path.abspath(dir) if not dir in sys.path: sys.path.insert(0, dir)
|
def main(self, argv, noshell): cmd = None edit = 0 debug = 0 startup = 0 try: opts, args = getopt.getopt(argv, "c:dir:st:") except getopt.error, msg: sys.stderr.write("Error: %s\n" % str(msg)) sys.stderr.write(usage_msg) sys.exit(2) for o, a in opts: noshell = 0 if o == '-c': cmd = a if o == '-d': debug = 1 if o == '-e': edit = 1 if o == '-s': startup = 1 if o == '-t': PyShell.shell_title = a if noshell: edit=1 for i in range(len(sys.path)): sys.path[i] = os.path.abspath(sys.path[i]) pathx = [] if edit: for filename in args: pathx.append(os.path.dirname(filename)) elif args and args[0] != "-": pathx.append(os.path.dirname(args[0])) else: pathx.append(os.curdir) for dir in pathx: dir = os.path.abspath(dir) if not dir in sys.path: sys.path.insert(0, dir)
| 6,567
|
def main(self, argv, noshell): cmd = None edit = 0 debug = 0 startup = 0 try: opts, args = getopt.getopt(argv, "c:deist:") except getopt.error, msg: sys.stderr.write("Error: %s\n" % str(msg)) sys.stderr.write(usage_msg) sys.exit(2) for o, a in opts: noshell = 0 if o == '-c': cmd = a if o == '-d': debug = 1 if o == '-e': edit = 1 if o == '-s': startup = 1 if o == '-t': PyShell.shell_title = a if noshell: edit=1 for i in range(len(sys.path)): sys.path[i] = os.path.abspath(sys.path[i]) pathx = [] if edit: for filename in args: pathx.append(os.path.dirname(filename)) elif args and args[0] != "-": pathx.append(os.path.dirname(args[0])) else: pathx.append(os.curdir) for dir in pathx: dir = os.path.abspath(dir) if not dir in sys.path: sys.path.insert(0, dir)
|
def main(self, argv, noshell): cmd = None edit = 0 debug = 0 startup = 0 try: opts, args = getopt.getopt(argv, "c:deist:") except getopt.error, msg: sys.stderr.write("Error: %s\n" % str(msg)) sys.stderr.write(usage_msg) sys.exit(2) for o, a in opts: noshell = 0 if o == '-c': cmd = a if o == '-d': debug = 1 if o == '-e': edit = 1 if o == '-s': startup = 1 if o == '-t': PyShell.shell_title = a if noshell: edit=1 for i in range(len(sys.path)): sys.path[i] = os.path.abspath(sys.path[i]) pathx = [] if edit: for filename in args: pathx.append(os.path.dirname(filename)) elif args and args[0] != "-": pathx.append(os.path.dirname(args[0])) else: pathx.append(os.curdir) for dir in pathx: dir = os.path.abspath(dir) if not dir in sys.path: sys.path.insert(0, dir)
| 6,568
|
def main(self, argv, noshell): cmd = None edit = 0 debug = 0 startup = 0 try: opts, args = getopt.getopt(argv, "c:deist:") except getopt.error, msg: sys.stderr.write("Error: %s\n" % str(msg)) sys.stderr.write(usage_msg) sys.exit(2) for o, a in opts: noshell = 0 if o == '-c': cmd = a if o == '-d': debug = 1 if o == '-e': edit = 1 if o == '-s': startup = 1 if o == '-t': PyShell.shell_title = a if noshell: edit=1 for i in range(len(sys.path)): sys.path[i] = os.path.abspath(sys.path[i]) pathx = [] if edit: for filename in args: pathx.append(os.path.dirname(filename)) elif args and args[0] != "-": pathx.append(os.path.dirname(args[0])) else: pathx.append(os.curdir) for dir in pathx: dir = os.path.abspath(dir) if not dir in sys.path: sys.path.insert(0, dir)
|
def main(self, argv, noshell): cmd = None edit = 0 debug = 0 startup = 0 try: opts, args = getopt.getopt(argv, "c:deist:") except getopt.error, msg: sys.stderr.write("Error: %s\n" % str(msg)) sys.stderr.write(usage_msg) sys.exit(2) for o, a in opts: noshell = 0 if o == '-c': cmd = a if o == '-d': debug = 1 if o == '-i': interactive = 1 if o == '-r': script = a if o == '-s': startup = 1 if o == '-t': PyShell.shell_title = a if noshell: edit=1 for i in range(len(sys.path)): sys.path[i] = os.path.abspath(sys.path[i]) pathx = [] if edit: for filename in args: pathx.append(os.path.dirname(filename)) elif args and args[0] != "-": pathx.append(os.path.dirname(args[0])) else: pathx.append(os.curdir) for dir in pathx: dir = os.path.abspath(dir) if not dir in sys.path: sys.path.insert(0, dir)
| 6,569
|
def main(self, argv, noshell): cmd = None edit = 0 debug = 0 startup = 0 try: opts, args = getopt.getopt(argv, "c:deist:") except getopt.error, msg: sys.stderr.write("Error: %s\n" % str(msg)) sys.stderr.write(usage_msg) sys.exit(2) for o, a in opts: noshell = 0 if o == '-c': cmd = a if o == '-d': debug = 1 if o == '-e': edit = 1 if o == '-s': startup = 1 if o == '-t': PyShell.shell_title = a if noshell: edit=1 for i in range(len(sys.path)): sys.path[i] = os.path.abspath(sys.path[i]) pathx = [] if edit: for filename in args: pathx.append(os.path.dirname(filename)) elif args and args[0] != "-": pathx.append(os.path.dirname(args[0])) else: pathx.append(os.curdir) for dir in pathx: dir = os.path.abspath(dir) if not dir in sys.path: sys.path.insert(0, dir)
|
def main(self, argv, noshell): cmd = None edit = 0 debug = 0 startup = 0 try: opts, args = getopt.getopt(argv, "c:deist:") except getopt.error, msg: sys.stderr.write("Error: %s\n" % str(msg)) sys.stderr.write(usage_msg) sys.exit(2) for o, a in opts: noshell = 0 if o == '-c': cmd = a if o == '-d': debug = 1 if o == '-e': edit = 1 if o == '-s': startup = 1 if o == '-t': PyShell.shell_title = a if noshell: edit=1 for i in range(len(sys.path)): sys.path[i] = os.path.abspath(sys.path[i]) pathx = [] if edit: for filename in args: pathx.append(os.path.dirname(filename)) elif args and args[0] != "-": pathx.append(os.path.dirname(args[0])) else: pathx.append(os.curdir) for dir in pathx: dir = os.path.abspath(dir) if not dir in sys.path: sys.path.insert(0, dir)
| 6,570
|
def testNtoH(self): for func in socket.htonl, socket.ntohl: for i in (0, 1, ~0xffff, 2L): self.assertEqual(i, func(func(i)))
|
def testNtoH(self): for func in socket.htonl, socket.ntohl: for i in (0, 1, ~0xffff, 2L): self.assertEqual(i, func(func(i)))
| 6,571
|
def _ascii_split(self, s, charset, firstline): # Attempt to split the line at the highest-level syntactic break # possible. Note that we don't have a lot of smarts about field # syntax; we just try to break on semi-colons, then whitespace. rtn = [] lines = s.splitlines() while lines: line = lines.pop(0) if firstline: maxlinelen = self._firstlinelen firstline = 0 else: line = line.lstrip() maxlinelen = self._maxlinelen # Short lines can remain unchanged if len(line.replace('\t', SPACE8)) <= maxlinelen: rtn.append(line) else: oldlen = len(line) # Try to break the line on semicolons, but if that doesn't # work, try to split on folding whitespace. while len(line) > maxlinelen: i = line.rfind(';', 0, maxlinelen) if i < 0: break rtn.append(line[:i] + ';') line = line[i+1:] # Is the remaining stuff still longer than maxlinelen? if len(line) <= maxlinelen: # Splitting on semis worked rtn.append(line) continue # Splitting on semis didn't finish the job. If it did any # work at all, stick the remaining junk on the front of the # `lines' sequence and let the next pass do its thing. if len(line) <> oldlen: lines.insert(0, line) continue # Otherwise, splitting on semis didn't help at all. parts = re.split(r'(\s+)', line) if len(parts) == 1 or (len(parts) == 3 and parts[0].endswith(':')): # This line can't be split on whitespace. There's now # little we can do to get this into maxlinelen. BAW: # We're still potentially breaking the RFC by possibly # allowing lines longer than the absolute maximum of 998 # characters. For now, let it slide. # # len(parts) will be 1 if this line has no `Field: ' # prefix, otherwise it will be len(3). rtn.append(line) continue # There is whitespace we can split on. first = parts.pop(0) sublines = [first] acc = len(first) while parts: len0 = len(parts[0]) len1 = len(parts[1]) if acc + len0 + len1 <= maxlinelen: sublines.append(parts.pop(0)) sublines.append(parts.pop(0)) acc += len0 + len1 else: # Split it here, but don't forget to ignore the # next whitespace-only part if first <> '': rtn.append(EMPTYSTRING.join(sublines)) del parts[0] first = parts.pop(0) sublines = [first] acc = len(first) rtn.append(EMPTYSTRING.join(sublines)) return [(chunk, charset) for chunk in rtn]
|
def _ascii_split(self, s, charset, firstline): # Attempt to split the line at the highest-level syntactic break # possible. Note that we don't have a lot of smarts about field # syntax; we just try to break on semi-colons, then whitespace. rtn = [] lines = s.splitlines() while lines: line = lines.pop(0) if firstline: maxlinelen = self._firstlinelen firstline = 0 else: maxlinelen = self._maxlinelen # Short lines can remain unchanged if len(line.replace('\t', SPACE8)) <= maxlinelen: rtn.append(line) else: oldlen = len(line) # Try to break the line on semicolons, but if that doesn't # work, try to split on folding whitespace. while len(line) > maxlinelen: i = line.rfind(';', 0, maxlinelen) if i < 0: break rtn.append(line[:i] + ';') line = line[i+1:] # Is the remaining stuff still longer than maxlinelen? if len(line) <= maxlinelen: # Splitting on semis worked rtn.append(line) continue # Splitting on semis didn't finish the job. If it did any # work at all, stick the remaining junk on the front of the # `lines' sequence and let the next pass do its thing. if len(line) <> oldlen: lines.insert(0, line) continue # Otherwise, splitting on semis didn't help at all. parts = re.split(r'(\s+)', line) if len(parts) == 1 or (len(parts) == 3 and parts[0].endswith(':')): # This line can't be split on whitespace. There's now # little we can do to get this into maxlinelen. BAW: # We're still potentially breaking the RFC by possibly # allowing lines longer than the absolute maximum of 998 # characters. For now, let it slide. # # len(parts) will be 1 if this line has no `Field: ' # prefix, otherwise it will be len(3). rtn.append(line) continue # There is whitespace we can split on. first = parts.pop(0) sublines = [first] acc = len(first) while parts: len0 = len(parts[0]) len1 = len(parts[1]) if acc + len0 + len1 <= maxlinelen: sublines.append(parts.pop(0)) sublines.append(parts.pop(0)) acc += len0 + len1 else: # Split it here, but don't forget to ignore the # next whitespace-only part if first <> '': rtn.append(EMPTYSTRING.join(sublines)) del parts[0] first = parts.pop(0) sublines = [first] acc = len(first) rtn.append(EMPTYSTRING.join(sublines)) return [(chunk, charset) for chunk in rtn]
| 6,572
|
def islower (c): return c in string.lowercase
|
def islower (c): return c in string.lowercase
| 6,573
|
def _fix_sentence_endings (self, chunks): """_fix_sentence_endings(chunks : [string])
|
def _fix_sentence_endings (self, chunks): """_fix_sentence_endings(chunks : [string])
| 6,574
|
def _fix_sentence_endings (self, chunks): """_fix_sentence_endings(chunks : [string])
|
def _fix_sentence_endings (self, chunks): """_fix_sentence_endings(chunks : [string])
| 6,575
|
def dumps(self, values): out = [] write = out.append dump = self.__dump if isinstance(values, Fault): # fault instance write("<fault>\n") dump(vars(values), write) write("</fault>\n") else: # parameter block # FIXME: the xml-rpc specification allows us to leave out # the entire <params> block if there are no parameters. # however, changing this may break older code (including # old versions of xmlrpclib.py), so this is better left as # is for now. See @XMLRPC3 for more information. /F write("<params>\n") for v in values: write("<param>\n") dump(v, write) write("</param>\n") write("</params>\n") result = string.join(out, "") return result
|
def dumps(self, values): out = [] write = out.append dump = self.__dump if isinstance(values, Fault): # fault instance write("<fault>\n") dump({'faultCode': values.faultCode, 'faultString': values.faultString}, write) write("</fault>\n") else: # parameter block # FIXME: the xml-rpc specification allows us to leave out # the entire <params> block if there are no parameters. # however, changing this may break older code (including # old versions of xmlrpclib.py), so this is better left as # is for now. See @XMLRPC3 for more information. /F write("<params>\n") for v in values: write("<param>\n") dump(v, write) write("</param>\n") write("</params>\n") result = string.join(out, "") return result
| 6,576
|
def run (self):
|
def run (self):
| 6,577
|
def do_key(self, event): (what, message, when, where, modifiers) = event c = chr(message & charCodeMask) if modifiers & cmdKey: if c == '.': raise self else: result = MenuKey(ord(c)) id = (result>>16) & 0xffff # Hi word item = result & 0xffff # Lo word if id: self.do_rawmenu(id, item, None, event)
|
def do_key(self, event): (what, message, when, where, modifiers) = event c = chr(message & charCodeMask) if modifiers & cmdKey: if c == '.': raise self else: result = MenuKey(ord(c)) id = (result>>16) & 0xffff # Hi word item = result & 0xffff # Lo word if id: self.do_rawmenu(id, item, None, event)
| 6,578
|
def put(self, data, to=None): args = (self.name, 'put', data) if to: args = args + to apply(self.tk.call, args)
|
def put(self, data, to=None): args = (self.name, 'put', data) if to: if to[0] == '-to': to = to[1:] args = args + ('-to',) + tuple(to) apply(self.tk.call, args)
| 6,579
|
def test_run_abort(self): # returncode handles signal termination p = subprocess.Popen([sys.executable, "-c", "import os; os.abort()"]) p.wait() self.assertEqual(-p.returncode, signal.SIGABRT)
|
def test_run_abort(self): # returncode handles signal termination old_limit = self._suppress_core_files() try: p = subprocess.Popen([sys.executable, "-c", "import os; os.abort()"]) finally: self._unsuppress_core_files(old_limit) p.wait() self.assertEqual(-p.returncode, signal.SIGABRT)
| 6,580
|
def trace_vdelete(self, mode, cbname): self._tk.call("trace", "vdelete", self._name, mode, cbname) self._tk.deletecommand(cbname)
|
def trace_vdelete(self, mode, cbname): self._tk.call("trace", "vdelete", self._name, mode, cbname) self._tk.deletecommand(cbname)
| 6,581
|
def try_cpp (self, body=None, headers=None, include_dirs=None, lang="c"): """Construct a source file from 'body' (a string containing lines of C/C++ code) and 'headers' (a list of header files to include) and run it through the preprocessor. Return true if the preprocessor succeeded, false if there were any errors. ('body' probably isn't of much use, but what the heck.) """ from distutils.ccompiler import CompileError self._check_compiler() ok = 1 try: self._preprocess(body, headers, lang) except CompileError: ok = 0
|
def try_cpp (self, body=None, headers=None, include_dirs=None, lang="c"): """Construct a source file from 'body' (a string containing lines of C/C++ code) and 'headers' (a list of header files to include) and run it through the preprocessor. Return true if the preprocessor succeeded, false if there were any errors. ('body' probably isn't of much use, but what the heck.) """ from distutils.ccompiler import CompileError self._check_compiler() ok = 1 try: self._preprocess(body, headers, include_dirs, lang) except CompileError: ok = 0
| 6,582
|
def search_cpp (self, pattern, body=None, headers=None, include_dirs=None, lang="c"): """Construct a source file (just like 'try_cpp()'), run it through the preprocessor, and return true if any line of the output matches 'pattern'. 'pattern' should either be a compiled regex object or a string containing a regex. If both 'body' and 'headers' are None, preprocesses an empty file -- which can be useful to determine the symbols the preprocessor and compiler set by default. """
|
def search_cpp (self, pattern, body=None, headers=None, include_dirs=None, lang="c"): """Construct a source file (just like 'try_cpp()'), run it through the preprocessor, and return true if any line of the output matches 'pattern'. 'pattern' should either be a compiled regex object or a string containing a regex. If both 'body' and 'headers' are None, preprocesses an empty file -- which can be useful to determine the symbols the preprocessor and compiler set by default. """
| 6,583
|
def search_cpp (self, pattern, body=None, headers=None, include_dirs=None, lang="c"): """Construct a source file (just like 'try_cpp()'), run it through the preprocessor, and return true if any line of the output matches 'pattern'. 'pattern' should either be a compiled regex object or a string containing a regex. If both 'body' and 'headers' are None, preprocesses an empty file -- which can be useful to determine the symbols the preprocessor and compiler set by default. """
|
def search_cpp (self, pattern, body=None, headers=None, include_dirs=None, lang="c"): """Construct a source file (just like 'try_cpp()'), run it through the preprocessor, and return true if any line of the output matches 'pattern'. 'pattern' should either be a compiled regex object or a string containing a regex. If both 'body' and 'headers' are None, preprocesses an empty file -- which can be useful to determine the symbols the preprocessor and compiler set by default. """
| 6,584
|
def try_compile (self, body, headers=None, include_dirs=None, lang="c"): """Try to compile a source file built from 'body' and 'headers'. Return true on success, false otherwise. """ from distutils.ccompiler import CompileError self._check_compiler() try: self._compile(body, headers, lang) ok = 1 except CompileError: ok = 0
|
def try_compile (self, body, headers=None, include_dirs=None, lang="c"): """Try to compile a source file built from 'body' and 'headers'. Return true on success, false otherwise. """ from distutils.ccompiler import CompileError self._check_compiler() try: self._compile(body, headers, include_dirs, lang) ok = 1 except CompileError: ok = 0
| 6,585
|
def detect_modules(self): # Ensure that /usr/local is always used add_dir_to_list(self.compiler.library_dirs, '/usr/local/lib') add_dir_to_list(self.compiler.include_dirs, '/usr/local/include')
|
def detect_modules(self): # Ensure that /usr/local is always used add_dir_to_list(self.compiler.library_dirs, '/usr/local/lib') add_dir_to_list(self.compiler.include_dirs, '/usr/local/include')
| 6,586
|
def testMultiply(self): self.assertEquals((0 * 10), 0) self.assertEquals((5 * 8), 40)
|
def testMultiply(self): self.assertEquals((0 * 10), 0) self.assertEquals((5 * 8), 40)
| 6,587
|
def failUnlessAlmostEqual(self, first, second, places=7, msg=None): """Fail if the two objects are unequal as determined by their difference rounded to the given number of decimal places (default 7) and comparing to zero.
|
def failUnlessAlmostEqual(self, first, second, places=7, msg=None): """Fail if the two objects are unequal as determined by their difference rounded to the given number of decimal places (default 7) and comparing to zero.
| 6,588
|
def loadTestsFromName(self, name, module=None): """Return a suite of all tests cases given a string specifier.
|
def loadTestsFromName(self, name, module=None): """Return a suite of all tests cases given a string specifier.
| 6,589
|
def loadTestsFromName(self, name, module=None): """Return a suite of all tests cases given a string specifier.
|
def loadTestsFromName(self, name, module=None): """Return a suite of all tests cases given a string specifier.
| 6,590
|
def loadTestsFromName(self, name, module=None): """Return a suite of all tests cases given a string specifier.
|
def loadTestsFromName(self, name, module=None): """Return a suite of all tests cases given a string specifier.
| 6,591
|
def loadTestsFromName(self, name, module=None): """Return a suite of all tests cases given a string specifier.
|
def loadTestsFromName(self, name, module=None): """Return a suite of all tests cases given a string specifier.
| 6,592
|
def run(self, test): "Run the given test case or test suite." result = self._makeResult() startTime = time.time() test(result) stopTime = time.time() timeTaken = float(stopTime - startTime) result.printErrors() self.stream.writeln(result.separator2) run = result.testsRun self.stream.writeln("Ran %d test%s in %.3fs" % (run, run != 1 and "s" or "", timeTaken)) self.stream.writeln() if not result.wasSuccessful(): self.stream.write("FAILED (") failed, errored = map(len, (result.failures, result.errors)) if failed: self.stream.write("failures=%d" % failed) if errored: if failed: self.stream.write(", ") self.stream.write("errors=%d" % errored) self.stream.writeln(")") else: self.stream.writeln("OK") return result
|
def run(self, test): "Run the given test case or test suite." result = self._makeResult() startTime = time.time() test(result) stopTime = time.time() timeTaken = stopTime - startTime result.printErrors() self.stream.writeln(result.separator2) run = result.testsRun self.stream.writeln("Ran %d test%s in %.3fs" % (run, run != 1 and "s" or "", timeTaken)) self.stream.writeln() if not result.wasSuccessful(): self.stream.write("FAILED (") failed, errored = map(len, (result.failures, result.errors)) if failed: self.stream.write("failures=%d" % failed) if errored: if failed: self.stream.write(", ") self.stream.write("errors=%d" % errored) self.stream.writeln(")") else: self.stream.writeln("OK") return result
| 6,593
|
def cmp(f1, f2, shallow=1, use_statcache=0): """Compare two files. Arguments: f1 -- First file name f2 -- Second file name shallow -- Just check stat signature (do not read the files). defaults to 1. use_statcache -- obsolete argument. Return value: True if the files are the same, False otherwise. This function uses a cache for past comparisons and the results, with a cache invalidation mechanism relying on stale signatures. """ s1 = _sig(os.stat(f1)) s2 = _sig(os.stat(f2)) if s1[0] != stat.S_IFREG or s2[0] != stat.S_IFREG: return False if shallow and s1 == s2: return True if s1[1] != s2[1]: return False result = _cache.get((f1, f2)) if result and (s1, s2) == result[:2]: return result[2] outcome = _do_cmp(f1, f2) _cache[f1, f2] = s1, s2, outcome return outcome
|
def cmp(f1, f2, shallow=1, use_statcache=None): """Compare two files. Arguments: f1 -- First file name f2 -- Second file name shallow -- Just check stat signature (do not read the files). defaults to 1. use_statcache -- obsolete argument. Return value: True if the files are the same, False otherwise. This function uses a cache for past comparisons and the results, with a cache invalidation mechanism relying on stale signatures. """ s1 = _sig(os.stat(f1)) s2 = _sig(os.stat(f2)) if s1[0] != stat.S_IFREG or s2[0] != stat.S_IFREG: return False if shallow and s1 == s2: return True if s1[1] != s2[1]: return False result = _cache.get((f1, f2)) if result and (s1, s2) == result[:2]: return result[2] outcome = _do_cmp(f1, f2) _cache[f1, f2] = s1, s2, outcome return outcome
| 6,594
|
def cmpfiles(a, b, common, shallow=1, use_statcache=0): """Compare common files in two directories. a, b -- directory names common -- list of file names found in both directories shallow -- if true, do comparison based solely on stat() information use_statcache -- obsolete argument Returns a tuple of three lists: files that compare equal files that are different filenames that aren't regular files. """ res = ([], [], []) for x in common: ax = os.path.join(a, x) bx = os.path.join(b, x) res[_cmp(ax, bx, shallow)].append(x) return res
|
def cmpfiles(a, b, common, shallow=1, use_statcache=None): """Compare common files in two directories. a, b -- directory names common -- list of file names found in both directories shallow -- if true, do comparison based solely on stat() information use_statcache -- obsolete argument Returns a tuple of three lists: files that compare equal files that are different filenames that aren't regular files. """ res = ([], [], []) for x in common: ax = os.path.join(a, x) bx = os.path.join(b, x) res[_cmp(ax, bx, shallow)].append(x) return res
| 6,595
|
def demo(): import sys import getopt options, args = getopt.getopt(sys.argv[1:], 'r') if len(args) != 2: raise getopt.error, 'need exactly two args' dd = dircmp(args[0], args[1]) if ('-r', '') in options: dd.report_full_closure() else: dd.report()
|
def demo(): import sys import getopt options, args = getopt.getopt(sys.argv[1:], 'r') if len(args) != 2: raise getopt.GetoptError('need exactly two args', None) dd = dircmp(args[0], args[1]) if ('-r', '') in options: dd.report_full_closure() else: dd.report()
| 6,596
|
def _bytecode_filenames (self, py_filenames): bytecode_files = [] for py_file in py_filenames: if self.compile: bytecode_files.append(py_file + "c") if self.optmize > 0: bytecode_files.append(py_file + "o")
|
def _bytecode_filenames (self, py_filenames): bytecode_files = [] for py_file in py_filenames: if self.compile: bytecode_files.append(py_file + "c") if self.optimize > 0: bytecode_files.append(py_file + "o")
| 6,597
|
def add(self, message): """Add message and return assigned key.""" tmp_file = self._create_tmp() try: self._dump_message(message, tmp_file) finally: tmp_file.close() if isinstance(message, MaildirMessage): subdir = message.get_subdir() suffix = self.colon + message.get_info() if suffix == self.colon: suffix = '' else: subdir = 'new' suffix = '' uniq = os.path.basename(tmp_file.name).split(self.colon)[0] dest = os.path.join(self._path, subdir, uniq + suffix) os.rename(tmp_file.name, dest) if isinstance(message, MaildirMessage): os.utime(dest, (os.path.getatime(dest), message.get_date())) return uniq
|
def add(self, message): """Add message and return assigned key.""" tmp_file = self._create_tmp() try: self._dump_message(message, tmp_file) finally: _sync_close(tmp_file) if isinstance(message, MaildirMessage): subdir = message.get_subdir() suffix = self.colon + message.get_info() if suffix == self.colon: suffix = '' else: subdir = 'new' suffix = '' uniq = os.path.basename(tmp_file.name).split(self.colon)[0] dest = os.path.join(self._path, subdir, uniq + suffix) os.rename(tmp_file.name, dest) if isinstance(message, MaildirMessage): os.utime(dest, (os.path.getatime(dest), message.get_date())) return uniq
| 6,598
|
def flush(self): """Write any pending changes to disk.""" if not self._pending: return self._lookup() new_file = _create_temporary(self._path) try: new_toc = {} self._pre_mailbox_hook(new_file) for key in sorted(self._toc.keys()): start, stop = self._toc[key] self._file.seek(start) self._pre_message_hook(new_file) new_start = new_file.tell() while True: buffer = self._file.read(min(4096, stop - self._file.tell())) if buffer == '': break new_file.write(buffer) new_toc[key] = (new_start, new_file.tell()) self._post_message_hook(new_file) except: new_file.close() os.remove(new_file.name) raise new_file.close() self._file.close() try: os.rename(new_file.name, self._path) except OSError, e: if e.errno == errno.EEXIST or \ (os.name == 'os2' and e.errno == errno.EACCES): os.remove(self._path) os.rename(new_file.name, self._path) else: raise self._file = open(self._path, 'rb+') self._toc = new_toc self._pending = False if self._locked: _lock_file(self._file, dotlock=False)
|
def flush(self): """Write any pending changes to disk.""" if not self._pending: return self._lookup() new_file = _create_temporary(self._path) try: new_toc = {} self._pre_mailbox_hook(new_file) for key in sorted(self._toc.keys()): start, stop = self._toc[key] self._file.seek(start) self._pre_message_hook(new_file) new_start = new_file.tell() while True: buffer = self._file.read(min(4096, stop - self._file.tell())) if buffer == '': break new_file.write(buffer) new_toc[key] = (new_start, new_file.tell()) self._post_message_hook(new_file) except: _sync_close(new_file) os.remove(new_file.name) raise _sync_close(new_file) self._file.close() try: os.rename(new_file.name, self._path) except OSError, e: if e.errno == errno.EEXIST or \ (os.name == 'os2' and e.errno == errno.EACCES): os.remove(self._path) os.rename(new_file.name, self._path) else: raise self._file = open(self._path, 'rb+') self._toc = new_toc self._pending = False if self._locked: _lock_file(self._file, dotlock=False)
| 6,599
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.