rem stringlengths 0 322k | add stringlengths 0 2.05M | context stringlengths 8 228k |
|---|---|---|
self.line_color = pack.getAttribute( 'line_color') or self.line_color | for attr in ("line_color",): if pack.getAttributeNode( attr): setattr( self, attr, pack.getAttribute( 'area_color')) | def read_package( self, pack): """reads the dom element pack and sets internal state according to it""" self.points = [] for p in pack.getElementsByTagName( 'point'): self.points.append( classes.point( self.paper, arrow=self, package=p)) |
x1, y1, x2, y2, x3, y3 = map( self.paper.px_to_cm, self.paper.coords( i)) point_array = [(x1,y1), (x2,y2), (x3,y3)] | x1, y1, x2, y2, x3, y3, x4, y4 = map( self.paper.px_to_cm, self.paper.coords( i)) point_array = [(x1,y1), (x2,y2), (x3,y3), (x4, y4)] | def add_bond( self, b, page): """adds bond item to page""" s = graphics_style( stroke_color=self.paper.any_color_to_rgb_string( b.line_color), stroke_width=self.paper.px_to_cm( b.line_width)) style_name = self.get_appropriate_style_name( s) l_group = page # items to export if b.type == 'h': items = b.items else: if b.c... |
print type if type == 'normal': type = 1 else: type = data.bond_types.index( type) return type | return order | def __mode_to_bond_type( self): """maps bond type submode to bond_type number""" order = self.submode[1]+1 type = self.submodes[2][ self.submode[2]][0] type = "%s%d" % (type, order) print type if type == 'normal': type = 1 else: type = data.bond_types.index( type) return type |
movex = -scale*(maxx+minx)/2 movey = -scale*(maxy+miny)/2 | movex = (maxx+minx)/2 movey = (maxy+miny)/2 | def oasa_mol_to_bkchem_mol( mol, paper): m = molecule.molecule( paper) if None in reduce( operator.add, [[a.x, a.y] for a in mol.atoms], []): calc_position = 0 else: calc_position = 1 minx = None maxx = None miny = None maxy = None # atoms for a in mol.vertices: a2 = oasa_atom_to_bkchem_atom( a, paper, m) m.insert_ato... |
self.type = 1 | self.type = 'n' | def read_package( self, package): b = ['no', 'yes'] type = package.getAttribute( 'type') if type: self.type = type[0] self.order = int( type[1]) else: self.type = 1 self.order = 1 # implied if package.getAttribute( 'distance'): self.bond_width = float( package.getAttribute( 'distance')) * self.paper.real_to_screen_rati... |
if self.order != 1: | if self.order != 1 or self.type in 'wha': | def get_package( self, doc): b = ['no', 'yes'] bnd = doc.createElement('bond') dom_extensions.setAttributes( bnd, (('type', "%s%d" % (self.type, self.order)), ('width', str( self.line_width)), ('start', self.atom1.get_cdml_id()), ('end', self.atom2.get_cdml_id()), ('double_ratio', str( self.double_length_ratio)))) if s... |
return oasa_mol_to_bkchem_mol( mol, paper) | m = oasa_mol_to_bkchem_mol( mol, paper) return m | def read_inchi( text, paper): mol = oasa.inchi.text_to_mol( text, calc_coords=1, include_hydrogens=False) #oasa.coords_generator.calculate_coords( mol, bond_length=1.0, force=1) return oasa_mol_to_bkchem_mol( mol, paper) |
exit_code = os.spawnv( os.P_WAIT, program, (program, name, in_name, "-AUXNONE")) | if os.name == 'nt': options = "/AUXNONE" else: options = "-AUXNONE" exit_code = os.spawnv( os.P_WAIT, program, (program, name, in_name, options)) | def gen_inchi( self): program = self.pm.get_preference( "inchi_program_path") import tempfile if not oasa_bridge.oasa_available: return u, i = self.paper.selected_to_unique_top_levels() sms = [] if not interactors.check_validity( self, u): return for m in u: if m.object_type == 'molecule': plugin = plugins.molfile exp... |
self.body = Tkinter.Frame( self.dialog.interior(), bd=2, relief="groove") self.body.pack( padx=10, pady=10, anchor="n" ) | def __init__( self, parent, paper): self.parent = parent self.paper = paper self.dialog = Pmw.Dialog( parent, buttons=(_('OK'), _('Cancel')), defaultbutton=_('OK'), title=_('File properties'), command=self.done, master='parent') self.body = Tkinter.Frame( self.dialog.interior(), bd=2, relief="groove") self.body.pack( p... | |
self.paper_type_chooser = Pmw.OptionMenu( self.body, | self.paper_type_chooser = Pmw.OptionMenu( paper_frame, | def draw( self): # paper type if self.paper._paper_properties['type'] == 'custom': t = _('Custom') else: t = self.paper._paper_properties['type'] self.paper_type_chooser = Pmw.OptionMenu( self.body, items=data.paper_types.keys(), #+[_('Custom')], initialitem = t, labelpos = 'w', label_text = _('Paper size')+':', menubu... |
self.paper_type_chooser.pack( anchor='n', padx=10, pady=10) | self.paper_type_chooser.pack( anchor='w', padx=5, pady=5) | def draw( self): # paper type if self.paper._paper_properties['type'] == 'custom': t = _('Custom') else: t = self.paper._paper_properties['type'] self.paper_type_chooser = Pmw.OptionMenu( self.body, items=data.paper_types.keys(), #+[_('Custom')], initialitem = t, labelpos = 'w', label_text = _('Paper size')+':', menubu... |
self.paper_orientation_chooser = Pmw.RadioSelect( self.body, | self.paper_orientation_chooser = Pmw.RadioSelect( paper_frame, | def draw( self): # paper type if self.paper._paper_properties['type'] == 'custom': t = _('Custom') else: t = self.paper._paper_properties['type'] self.paper_type_chooser = Pmw.OptionMenu( self.body, items=data.paper_types.keys(), #+[_('Custom')], initialitem = t, labelpos = 'w', label_text = _('Paper size')+':', menubu... |
self.paper_orientation_chooser.pack( anchor='w', padx=10, pady=10) | self.paper_orientation_chooser.pack( anchor='w', padx=5, pady=5) | def draw( self): # paper type if self.paper._paper_properties['type'] == 'custom': t = _('Custom') else: t = self.paper._paper_properties['type'] self.paper_type_chooser = Pmw.OptionMenu( self.body, items=data.paper_types.keys(), #+[_('Custom')], initialitem = t, labelpos = 'w', label_text = _('Paper size')+':', menubu... |
crop = Tkinter.Checkbutton( self.dialog.interior(), | crop = Tkinter.Checkbutton( crop_frame, | def draw( self): # paper type if self.paper._paper_properties['type'] == 'custom': t = _('Custom') else: t = self.paper._paper_properties['type'] self.paper_type_chooser = Pmw.OptionMenu( self.body, items=data.paper_types.keys(), #+[_('Custom')], initialitem = t, labelpos = 'w', label_text = _('Paper size')+':', menubu... |
crop.pack( anchor='w', padx=10, pady=10) | crop.pack( anchor='w', padx=5, pady=5) | def draw( self): # paper type if self.paper._paper_properties['type'] == 'custom': t = _('Custom') else: t = self.paper._paper_properties['type'] self.paper_type_chooser = Pmw.OptionMenu( self.body, items=data.paper_types.keys(), #+[_('Custom')], initialitem = t, labelpos = 'w', label_text = _('Paper size')+':', menubu... |
self.margin_entry = Pmw.Counter( self.dialog.interior(), | self.margin_entry = Pmw.Counter( crop_frame, | def draw( self): # paper type if self.paper._paper_properties['type'] == 'custom': t = _('Custom') else: t = self.paper._paper_properties['type'] self.paper_type_chooser = Pmw.OptionMenu( self.body, items=data.paper_types.keys(), #+[_('Custom')], initialitem = t, labelpos = 'w', label_text = _('Paper size')+':', menubu... |
self.margin_entry.pack( anchor='n', padx=10, pady=10) | self.margin_entry.pack( anchor='n', padx=5, pady=5) | def draw( self): # paper type if self.paper._paper_properties['type'] == 'custom': t = _('Custom') else: t = self.paper._paper_properties['type'] self.paper_type_chooser = Pmw.OptionMenu( self.body, items=data.paper_types.keys(), #+[_('Custom')], initialitem = t, labelpos = 'w', label_text = _('Paper size')+':', menubu... |
f1 = Tkinter.Frame( self.dialog.interior()) f1.pack( anchor='w', padx=10, pady=10) | minus_frame = Tkinter.Frame( self.dialog.interior(), bd=2, relief="groove") minus_frame.pack( padx=10, pady=10, anchor="n", fill="x") | def draw( self): # paper type if self.paper._paper_properties['type'] == 'custom': t = _('Custom') else: t = self.paper._paper_properties['type'] self.paper_type_chooser = Pmw.OptionMenu( self.body, items=data.paper_types.keys(), #+[_('Custom')], initialitem = t, labelpos = 'w', label_text = _('Paper size')+':', menubu... |
use_real_minus_button = Tkinter.Checkbutton( f1, | use_real_minus_button = Tkinter.Checkbutton( minus_frame, | def draw( self): # paper type if self.paper._paper_properties['type'] == 'custom': t = _('Custom') else: t = self.paper._paper_properties['type'] self.paper_type_chooser = Pmw.OptionMenu( self.body, items=data.paper_types.keys(), #+[_('Custom')], initialitem = t, labelpos = 'w', label_text = _('Paper size')+':', menubu... |
use_real_minus_button.pack( anchor='w', padx=0, pady=0) | use_real_minus_button.pack( anchor='w', padx=5, pady=5) | def draw( self): # paper type if self.paper._paper_properties['type'] == 'custom': t = _('Custom') else: t = self.paper._paper_properties['type'] self.paper_type_chooser = Pmw.OptionMenu( self.body, items=data.paper_types.keys(), #+[_('Custom')], initialitem = t, labelpos = 'w', label_text = _('Paper size')+':', menubu... |
replace_minus_button = Tkinter.Checkbutton( f1, | replace_minus_button = Tkinter.Checkbutton( minus_frame, | def draw( self): # paper type if self.paper._paper_properties['type'] == 'custom': t = _('Custom') else: t = self.paper._paper_properties['type'] self.paper_type_chooser = Pmw.OptionMenu( self.body, items=data.paper_types.keys(), #+[_('Custom')], initialitem = t, labelpos = 'w', label_text = _('Paper size')+':', menubu... |
replace_minus_button.pack( anchor='w', padx=0, pady=0) | replace_minus_button.pack( anchor='w', padx=5, pady=5) | def draw( self): # paper type if self.paper._paper_properties['type'] == 'custom': t = _('Custom') else: t = self.paper._paper_properties['type'] self.paper_type_chooser = Pmw.OptionMenu( self.body, items=data.paper_types.keys(), #+[_('Custom')], initialitem = t, labelpos = 'w', label_text = _('Paper size')+':', menubu... |
self.bind( "<MouseWheel>", lambda e: self.yview( "scroll", -misc.signum( e.delta), "units")) | def set_bindings( self): if not Store.app.in_batch_mode: self.bind( "<B1-Motion>", self._drag1) self.bind( "<ButtonRelease-1>", self._release1) self.bind( "<Shift-B1-Motion>", self._drag1) self.bind( "<Button-1>", lambda e: self._pressed1( e, mod=[])) self.bind( "<Shift-Button-1>", lambda e: self._pressed1( e, mod=['sh... | |
_("The standard was successfully saved as personal standard to %s") % a) | _("The standard was successfully saved as personal standard to %s\n\nIt is not automatically applied to the current drawing and will be activated after you restart BKChem.\nYou can still apply the changes to the current drawing from the dialog window.") % a) | def done( self, button): if button == _('Save'): a = self.parent.paper.save_personal_standard( self.get_the_standard()) if a: tkMessageBox.showinfo( _("Standard saved"), _("The standard was successfully saved as personal standard to %s") % a) else: tkMessageBox.showerror( _("Standard not saved"), _("""For some reason t... |
self.focused.focus() | else: self.focused.focus() | def mouse_click( self, event): if not self.focused: #print "it should not get here!!!" mol = Store.app.paper.new_molecule() a = mol.create_new_atom( event.x, event.y) Store.app.paper.add_bindings() b = bond( standard = Store.app.paper.standard, type=self.__mode_to_bond_type(), order=self.__mode_to_bond_order(), simple_... |
'mark_size': set_mark_size} | 'mark_size': set_mark_size, 'pos': set_symbol_pos} | def set_mark_size( o, value): for mark in o.marks: mark.size = value o.redraw() |
map( lambda a: a.draw(), self) | [a.draw() for a in self] | def draw( self): map( lambda a: a.draw(), self) |
self.atom2 = self.molecule.get_atom_with_cdml_id( package.getAttribute( 'end')) | self.atom2 = self.molecule.get_atom_with_cdml_id( package.getAttribute( 'end')) def post_read_analysis( self): """this method is called by molecule after the *whole* molecule is read to perform a post-load analysis of double bond positioning""" sign, center = self._compute_sing_and_center() if self.bond_width and sel... | def read_package( self, package): b = ['no', 'yes'] type = package.getAttribute( 'type') if type: if type == 'forth': self.type = 4 else: for type_set in ('bond_types', 'alternative_bond_types', 'numbered_bond_types'): if type in data.__dict__[type_set]: self.type = data.__dict__[type_set].index( type) else: self.type ... |
atms = self.molecule.atoms_bound_to( self.atom1) + self.molecule.atoms_bound_to( self.atom2) atms = misc.difference( atms, [self.atom1, self.atom2]) coords = [a.get_xy() for a in atms] | def _decide_distance_and_center( self): """according to molecular geometry decide what bond.center and bond.bond_width should be""" atms = self.molecule.atoms_bound_to( self.atom1) + self.molecule.atoms_bound_to( self.atom2) atms = misc.difference( atms, [self.atom1, self.atom2]) coords = [a.get_xy() for a in atms] lin... | |
self.center = 1 | return (1 ,1) | def get_circles_for_side( side): res = 0 side1, side2 = side while len( side1): a1 = side1.pop(0) for a2 in side2: atoms = copy.copy( self.molecule.atoms_map) atoms.remove( self.atom1) atoms.remove( self.atom2) if accessible( a1, a2, atoms): res += 1 return res |
self.center = 0 self.bond_width = -abs( self.bond_width) | return (-1, 0) | def get_circles_for_side( side): res = 0 side1, side2 = side while len( side1): a1 = side1.pop(0) for a2 in side2: atoms = copy.copy( self.molecule.atoms_map) atoms.remove( self.atom1) atoms.remove( self.atom2) if accessible( a1, a2, atoms): res += 1 return res |
self.center = 0 self.bond_width = abs( self.bond_width) | return (1, 0) | def get_circles_for_side( side): res = 0 side1, side2 = side while len( side1): a1 = side1.pop(0) for a2 in side2: atoms = copy.copy( self.molecule.atoms_map) atoms.remove( self.atom1) atoms.remove( self.atom2) if accessible( a1, a2, atoms): res += 1 return res |
if y2 < y1: d = -d | def find_parallel( x1, y1, x2, y2, d): "returns tuple of coordinates for parallel abscissa in distance d" # following is here to ensure that signum of "d" clearly determines # the side of line on whitch the parallel is drawn if y2 < y1: d = -d if round( y2, 3) -round( y1, 3) != 0: k = -(x2-x1)/(y2-y1) x = ( d + sqrt( k... | |
items = [self.item] + self.second + self.third + self.items + [self.selector] | items = [self.item] + self.second + self.third + self.items if self.selector: items.append( self.selector) | def move( self, dx, dy): """moves object with his selector (when present)""" items = [self.item] + self.second + self.third + self.items + [self.selector] [self.paper.move( o, dx, dy) for o in items] |
pass | for i in range( 5): path = Store.pm.get_preference( "recent-file%d" % (i+1)) if path: self._recent_files.insert( 0, path) self.menu.addmenuitem( _("Recent files"), 'command', label=path, command=misc.lazy_apply( self.load_CDML, (path,))) | def init_preferences( self): # save_dir must be set after the preference manager is initiated #self.save_dir = Store.pm.get_preference( "default-dir") pass |
dom_extensions.elementUnder( self.group, 'rect', (( 'x', str( x)), ( 'y', str( y)), ( 'width', str( x2-x)), ( 'height', str( y2-y)), ( 'fill', t.area_color), ( 'stroke', t.area_color))) | if t.area_color: dom_extensions.elementUnder( self.group, 'rect', (( 'x', str( x)), ( 'y', str( y)), ( 'width', str( x2-x)), ( 'height', str( y2-y)), ( 'fill', t.area_color), ( 'stroke', t.area_color))) | def add_text( self, t): """adds text item to SVG document""" item = t.item x1, y1 = t.get_xy() x, y, x2, y2 = self.paper.bbox( item) dom_extensions.elementUnder( self.group, 'rect', (( 'x', str( x)), ( 'y', str( y)), ( 'width', str( x2-x)), ( 'height', str( y2-y)), ( 'fill', t.area_color), ( 'stroke', t.area_color))) y... |
dom_extensions.elementUnder( self.group, 'rect', (( 'x', str( x)), ( 'y', str( y)), ( 'width', str( x2-x)), ( 'height', str( y2-y)), ( 'fill', p.area_color), ( 'stroke', p.area_color))) | if p.area_color: dom_extensions.elementUnder( self.group, 'rect', (( 'x', str( x)), ( 'y', str( y)), ( 'width', str( x2-x)), ( 'height', str( y2-y)), ( 'fill', p.area_color), ( 'stroke', p.area_color))) | def add_plus( self, p): """adds plus item to SVG document""" item = p.item x1, y1 = p.get_xy() x, y, x2, y2 = self.paper.bbox( item) dom_extensions.elementUnder( self.group, 'rect', (( 'x', str( x)), ( 'y', str( y)), ( 'width', str( x2-x)), ( 'height', str( y2-y)), ( 'fill', p.area_color), ( 'stroke', p.area_color))) y... |
dom_extensions.elementUnder( self.group, 'rect', (( 'x', str( x1)), ( 'y', str( y1)), ( 'width', str( x2-x1)), ( 'height', str( y2-y1)), ( 'fill', o.area_color), ( 'stroke', o.line_color), ( 'stroke-width', str( o.line_width)))) | el = dom_extensions.elementUnder( self.group, 'rect', (( 'x', str( x1)), ( 'y', str( y1)), ( 'width', str( x2-x1)), ( 'height', str( y2-y1)), ( 'stroke-width', str( o.line_width)))) if o.area_color: el.setAttribute( 'fill', o.area_color) if o.line_color: el.setAttribute( 'stroke', o.line_color) | def add_rect( self, o): x1, y1, x2, y2 = o.coords dom_extensions.elementUnder( self.group, 'rect', (( 'x', str( x1)), ( 'y', str( y1)), ( 'width', str( x2-x1)), ( 'height', str( y2-y1)), ( 'fill', o.area_color), ( 'stroke', o.line_color), ( 'stroke-width', str( o.line_width)))) |
dom_extensions.elementUnder( self.group, 'ellipse', (( 'cx', str( (x2+x1)/2)), ( 'cy', str( (y2+y1)/2)), ( 'rx', str( (x2-x1)/2)), ( 'ry', str( (y2-y1)/2)), ( 'fill', o.area_color), ( 'stroke', o.line_color), ( 'stroke-width', str( o.line_width)))) | el = dom_extensions.elementUnder( self.group, 'ellipse', (( 'cx', str( (x2+x1)/2)), ( 'cy', str( (y2+y1)/2)), ( 'rx', str( (x2-x1)/2)), ( 'ry', str( (y2-y1)/2)), ( 'stroke-width', str( o.line_width)))) if o.area_color: el.setAttribute( 'fill', o.area_color) if o.line_color: el.setAttribute( 'stroke', o.line_color) | def add_oval( self, o): x1, y1, x2, y2 = o.coords dom_extensions.elementUnder( self.group, 'ellipse', (( 'cx', str( (x2+x1)/2)), ( 'cy', str( (y2+y1)/2)), ( 'rx', str( (x2-x1)/2)), ( 'ry', str( (y2-y1)/2)), ( 'fill', o.area_color), ( 'stroke', o.line_color), ( 'stroke-width', str( o.line_width)))) |
( 'fill', o.area_color), ( 'stroke', o.line_color), | def add_polygon( self, o): ps = '' for (x,y) in [p.get_xy() for p in o.points]: ps += '%d,%d ' % (x,y) poly = dom_extensions.elementUnder( self.group, 'polygon', (( 'points', ps), ( 'stroke-width', str( o.line_width)), ( 'fill', o.area_color), ( 'stroke', o.line_color), ( 'fill-rule', 'evenodd'))) | |
( 'fill', 'none'), ( 'stroke', o.line_color))) | ( 'fill', 'none'))) if o.line_color: el.setAttribute( 'stroke', o.line_color) | def add_polyline( self, o): ps = '' for (x,y) in [p.get_xy() for p in o.points]: ps += '%d,%d ' % (x,y) poly = dom_extensions.elementUnder( self.group, 'polyline', (( 'points', ps), ( 'stroke-width', str( o.line_width)), ( 'fill', 'none'), ( 'stroke', o.line_color))) |
self._one_atom_is_enough_for_this_submode = [0,0] | def __init__( self, paper): edit_mode.__init__( self, paper) self.name = _('bond align') self._rotated_mol = None self.first_atom_selected = None self.submodes = [['tohoriz','tovert']] self.submodes_names = [[_('horizontal align'),_('vertical align')]] self.submode = [0] | |
self._centerx = ( x1 + x2) / 2 self._centery = ( y1 + y2) / 2 angle0 = geometry.clockwise_angle_from_east( x2 - x1, y2 - y1) if angle0 >= math.pi : angle0 = angle0 - math.pi if self.submode[0] == 0: if (angle0 > -0.005) and (angle0 < .005) : angle = math.pi elif angle0 <= math.pi/2: angle = -angle0 else: angle = math... | tr = self.__class__.__dict__['_transform_'+self.get_submode(0)]( self, x1, y1, x2, y2) | def mouse_down( self, event, modifiers = []): if not self.focused: return if self.focused.object_type not in ['atom', 'bond']: return # edit_mode.mouse_down( self, event, modifiers = modifiers) self._block_leave_event = 0 if not self.first_atom_selected: self.paper.unselect_all() if self.focused.object_type == 'bond': ... |
app.logbuffer.insert_with_tags_by_name(app.iter, "\rERROR: Cannot open file: ", e.filename, "red_foreground") | app.logbuffer.insert_with_tags_by_name(app.iter, "\rERROR: Cannot open file: "+str(e.filename), "red_foreground") | def run(self): from bencode import bencode, bdecode from sha import sha import os try: f = open(self.filename, "r") except IOError, e: app.logbuffer.insert_with_tags_by_name(app.iter, "\rFATAL ERROR: Cannot open file: ", e.filename , "red_foreground") app.haltplant() sys.exit() file = f.read() f.close() try: bdata = bd... |
app.logbuffer.insert_with_tags_by_name(app.iter, "\rError: Tracker cannot be accessed. Please Try Again"+e, "blue_foreground") | app.logbuffer.insert_with_tags_by_name(app.iter, "\rError: Tracker cannot be accessed. Please Try Again"+str(e), "blue_foreground") | def run(self): from bencode import bencode, bdecode from sha import sha import os try: f = open(self.filename, "r") except IOError, e: app.logbuffer.insert_with_tags_by_name(app.iter, "\rFATAL ERROR: Cannot open file: ", e.filename , "red_foreground") app.haltplant() sys.exit() file = f.read() f.close() try: bdata = bd... |
app.logbuffer.insert_with_tags_by_name(app.iter, "\rError: Tracker cannot be accessed. Please Try Again - "+e , "red_foreground") | app.logbuffer.insert_with_tags_by_name(app.iter, "\rError: Tracker cannot be accessed. Please Try Again - "+str(e) , "red_foreground") | def run(self): from bencode import bencode, bdecode from sha import sha import os try: f = open(self.filename, "r") except IOError, e: app.logbuffer.insert_with_tags_by_name(app.iter, "\rFATAL ERROR: Cannot open file: ", e.filename , "red_foreground") app.haltplant() sys.exit() file = f.read() f.close() try: bdata = bd... |
app.logbuffer.insert_with_tags_by_name(app.iter, "\rERROR: Cannot write to file: "+e.filename, "green_foreground") | app.logbuffer.insert_with_tags_by_name(app.iter, "\rERROR: Cannot write to file: "+str(e.filename), "green_foreground") | def run(self): from bencode import bencode, bdecode from sha import sha import os try: f = open(self.filename, "r") except IOError, e: app.logbuffer.insert_with_tags_by_name(app.iter, "\rFATAL ERROR: Cannot open file: ", e.filename , "red_foreground") app.haltplant() sys.exit() file = f.read() f.close() try: bdata = bd... |
f = open(self.filename, "r") | f = open(self.filename, "rb") | def run(self): from bencode import bencode, bdecode from sha import sha import os import time try: f = open(self.filename, "r") except IOError, e: app.logbuffer.insert_with_tags_by_name(app.iter, "\rFATAL ERROR: Cannot open file: ", e.filename , "red_foreground") app.haltplant() sys.exit() file = f.read() f.close() try... |
f = open(self.filename, "w") | f = open(self.filename, "wb") | def run(self): from bencode import bencode, bdecode from sha import sha import os import time try: f = open(self.filename, "r") except IOError, e: app.logbuffer.insert_with_tags_by_name(app.iter, "\rFATAL ERROR: Cannot open file: ", e.filename , "red_foreground") app.haltplant() sys.exit() file = f.read() f.close() try... |
assert test.run( local=1 ) == test.expected_result() | assert test.run( local=0 ) == test.expected_result() | def expected_result( self ): """ Precalculated result to check for consistent performance. |
for k in l[0].keys(): x = l.valuesOf( k, None ) | keyList = l[0].keys() keyList.sort() for k in keyList: x = __valuesOf( l, k ) | def check( l ): print '%-20s %6s' % ('infokey', 'invalid') print 30*'-' for k in l[0].keys(): x = l.valuesOf( k, None ) try: print '%-20s: %6i' % (k, sum( equal( x, None ) ) ) except: print lastError() print '%-20s: %6s' % (k, '?') pass |
@param rgbColor: HEX-color e.g. 'FF00FF' @type rgbColor : str | @param hexColor: HEX-color e.g. 'FF00FF' @type hexColor: str | def hex2rgb( hexColor, str=0 ): """ convert 8 bit hex rgb color into rgb color :: 'FF00FF' -> [ 1.0, 0.0, 1.0, ] @param rgbColor: HEX-color e.g. 'FF00FF' @type rgbColor : str @param str: return rgb colors as a tring (i.e for PyMol) @type str: 1|0 @return: rgb colors @rtype: [float] """ rgb = [] if hexColor[:2] == ... |
return add.accumulate( a ) / N.sum( a ) | return N.add.accumulate( a ) / N.sum( a ) | def accumulate( a ): """ cumulative sum of C{ a[0], a[0]+a[1], a[0]+a[1]+[a2], ... } normalized by C{ N.sum( a ) } @param a: array('f') or float @type a: array @return: float @rtype: float """ return add.accumulate( a ) / N.sum( a ) |
@return: xyz-coordinates, N.array( 3 x N_atoms, 'f' ) | @return: xyz-coordinates, N.array( 3 x N_atoms, N.Float ) | def getXyz( self, mask=None ): """ Get coordinates, fetch from source PDB or pickled PDBModel, if necessary. |
return N.array( [], 'f' ) | return N.array( [], N.Float ) | def getXyz( self, mask=None ): """ Get coordinates, fetch from source PDB or pickled PDBModel, if necessary. |
self.xyz = self.xyz.astype('f') | self.xyz = self.xyz.astype(N.Float) | def slim( self ): """ Remove xyz array and list of atoms if they haven't been changed and could hence be loaded from the source file (only if there is a source file...). Remove any unchanged profiles. B{AUTOMATICALLY CALLED BEFORE PICKLING} """ ## remove atoms/coordinates if they are unchanged from an existing ## sourc... |
mask = mask or N.ones( self.lenAtoms(), 'i' ) | mask = mask or N.ones( self.lenAtoms(), N.Int ) | def sequence(self, mask=None, xtable=molUtils.xxDic ): """ Amino acid sequence in one letter code. |
@return: Numpy N.array( [0,1,1,0,0,0,1,0,..], 'i') or list | @return: Numpy N.array( [0,1,1,0,0,0,1,0,..], N.Int) or list | def maskF(self, atomFunction, numpy=1 ): """ Create list whith result of atomFunction( atom ) for each atom. |
return N.array( [what], 'i' ) | return N.array( [what], N.Int ) | def indices( self, what ): """ Get atom indices conforming condition |
r = N.zeros( self.lenAtoms(),'i' ) | r = N.zeros( self.lenAtoms(),N.Int ) | def mask( self, what, numpy=1 ): """ Get atom mask. |
result = N.zeros( self.lenResidues(), 'i' ) | result = N.zeros( self.lenResidues(), N.Int ) | def atom2resMask( self, atomMask ): """ Mask (0) residues for which all atoms are masked (0) in atomMask. |
result = N.zeros( self.lenAtoms(), 'i') | result = N.zeros( self.lenAtoms(), N.Int) | def res2atomMask( self, resMask ): """ convert residue mask to atom mask. |
mask = mask or N.ones( len(self.getAtoms() ) , 'i' ) | mask = mask or N.ones( len(self.getAtoms() ) , N.Int ) | def resMapOriginal(self, mask=None): """ Generate list to map from any atom to its ORIGINAL(!) PDB residue number. |
return N.compress( mask, N.array(result, 'i') ) | return N.compress( mask, N.array(result, N.Int) ) | def resMapOriginal(self, mask=None): """ Generate list to map from any atom to its ORIGINAL(!) PDB residue number. |
return N.array(result, 'i') | return N.array(result, N.Int) | def __calcResMap( self, mask=None ): """ Create a map of residue residue for atoms in model. |
return N.array( result, 'i' ) | return N.array( result, N.Int ) | @param breaks: split chains at chain breaks (def 0) |
@return: array('f') | @return: array(N.Float) | def centerOfMass( self ): """ Center of mass of PDBModel. |
return N.array( result, 'f' ) | return N.array( result, N.Float ) | def residusMaximus( self, atomValues, mask=None ): """ Take list of value per atom, return list where all atoms of any residue are set to the highest value of any atom in that residue. (after applying mask) |
When done, write resuĺt to disc. | When done, write result to disc. | def finish( self ): """ When done, write resuĺt to disc. """ self.rec = PCRModel( self.com.rec_model.getPsfFile(), self.rec_out ) self.lig = PCRModel( self.com.lig_model.getPsfFile(), self.lig_out ) |
@raise raise ProfileError: if length of prof != N_residues | @raise ProfileError: if length of prof != N_residues | def setProfile( self, name, prof, mask=None, default=None, asarray=1, comment=None, **moreInfo ): """ Add/override profile. @param name: profile name @type name: str @param prof: list of values @type prof: [any] @param mask: list 1 x N_items of 0|1, if there are less values than items, provide mask for missing valu... |
@raise raise ProfileError: if no profile is found with |name| | @raise ProfileError: if no profile is found with |name| | def profile( self, name, default=None ): """ Get the values of a profile:: get( name ) -> list of values @param name: profile name @type name: str @param default: default result if no profile is found @type default: any @raise raise ProfileError: if no profile is found with |name| """ return self.profiles.get( name... |
@raise raise ProfileError: if no profile is found with |name| | @raise ProfileError: if no profile is found with |name| | def profileInfo( self, name ): """ GEt information associated with a profile:: profileInfo( name ) -> dict with infos about profile Guaranteed infos: 'version'->str, 'comment'->str, 'changed'->1|0 |
@raise raise ProfileError: if no profile is found with |name| | @raise ProfileError: if no profile is found with |name| | def setProfileInfo( self, name, **args ): """ Add/Override infos about a given profile:: e.g. setInfo('relASA', comment='new', params={'bin':'whatif'}) |
@raise TrajError if result length <> N_residues: | @raise TrajError: if result length <> N_residues: | def getResFluct( self, atomFluctList=None ): """ Convert list of atomic fluctuations to list of residue fluctuation. @param atomFluctList: array 1 x N_atoms of float @type atomFluctList: [float] @return: array 1 x N_residues of float @rtype: [float] |
import os, time | import time | def pcMovie( self, ev, steps, factor=1., ref=0, morph=1 ): """ Morph between the two extreme values of a single principal component. @param ev: EigenVector to visualize @type ev: int @param steps: number of intermediate frames @type steps: int @param factor: exageration factor (default: 1 = No exageration) @type fa... |
traj = T.Load(T.testRoot() + '/lig_pc2_00/traj.dat') | traj = T.Load(T.testRoot() + '/lig_pcr_00/traj.dat') | def pcMovie( self, ev, steps, factor=1., ref=0, morph=1 ): """ Morph between the two extreme values of a single principal component. @param ev: EigenVector to visualize @type ev: int @param steps: number of intermediate frames @type steps: int @param factor: exageration factor (default: 1 = No exageration) @type fa... |
@return: n_cluster : lst of lst of int, frame indices | @return: n_cluster, lst of lst of int, frame indices | def memberFrames( self, threshold=0. ): """ Get indices of all frames belonging to each cluster. Each frame is guaranteed to belong, at least, to the cluster for which it has its maximum membership. If threshold > 0, it can additionally pop up in other clusters. @param threshold: minimal cluster membership or 0 to con... |
from Biskit.EnsembleTraj import * | import Biskit.EnsembleTraj as ET | def avgRmsd2Ref( self, cluster, ref, avg=1 ): """ Claculate the rmsd (or average rmsd) of all frames belonging to a cluster to a reference structure (in Angstrom). @param cluster: cluster number @type cluster: int @param ref: reference structure @type ref: model @param avg: return the average rmsd (1) OR a list with... |
traj = traj2ensemble( traj ) | traj = ET.traj2ensemble( traj ) | def avgRmsd2Ref( self, cluster, ref, avg=1 ): """ Claculate the rmsd (or average rmsd) of all frames belonging to a cluster to a reference structure (in Angstrom). @param cluster: cluster number @type cluster: int @param ref: reference structure @type ref: model @param avg: return the average rmsd (1) OR a list with... |
def __init__( self, path=None, checkEnv=1, minLen=3, **vars ): | def __init__( self, path=None, checkEnv=1, minLen=3, maxSub=1, absolute=1, resolveLinks=0, **vars ): | def __init__( self, path=None, checkEnv=1, minLen=3, **vars ): """ Create a new environment-dependent path from either a list of fragments and their substitution variable names or from a path or from a formatted string (not implemented). A path will be analyzed to substitute as big chunks as possible by environment var... |
@param vars: alternative envVar=value pairs, to be used instead of environment variables @type vars: envVar=value | @param absolute: normalize file name [1] @type absolute: 1|0 @param resolveLinks: resolve symbolic links [0] @type resolveLinks: 1|0 @param maxSub: maximal number of substitutions [1] @type maxSub: int @param vars: additional param=value pairs with suggested substitutors @type vars: param=value | def __init__( self, path=None, checkEnv=1, minLen=3, **vars ): """ Create a new environment-dependent path from either a list of fragments and their substitution variable names or from a path or from a formatted string (not implemented). A path will be analyzed to substitute as big chunks as possible by environment var... |
self.set( path, checkEnv=checkEnv, minLen=minLen, **vars ) | self.set( path, checkEnv=checkEnv, minLen=minLen, absolute=absolute, resolveLinks=resolveLinks, maxSub=maxSub, **vars ) | def __init__( self, path=None, checkEnv=1, minLen=3, **vars ): """ Create a new environment-dependent path from either a list of fragments and their substitution variable names or from a path or from a formatted string (not implemented). A path will be analyzed to substitute as big chunks as possible by environment var... |
result = t.absfile( result ) | result = T.absfile( result ) | def get_local( self, existing=0 ): """ Return a valid, absolute path. Either the existing original or with all substitutions for which environment variables exist. This function is time consuming (absfile - os.realpath is the culprit). @param existing: don't return a non-existing path @type existing: 0|1 @return: va... |
def set( self, v, checkEnv=1, minLen=3, **vars ): """ Assign a new file name | def set( self, v, checkEnv=1, minLen=3, maxSub=1, absolute=1, resolveLinks=0, **vars ): """ Assign a new file name. checkEnv, minLen, resolve*, maxSub are only considered for path name input. | def set( self, v, checkEnv=1, minLen=3, **vars ): """ Assign a new file name @param v: fragment tuples or path or custom-formatted string @type v: [ (str,str) ] OR str @param checkEnv: look for possible substitutions in environment [1] (ignored if v is already formatted like '{/x/y|$xy}/z.txt' ) @type checkEnv: 0|1 ... |
(ignored if v is already formatted like '{/x/y|$xy}/z.txt' ) | (iggnored if v is already formatted like '{/x/y|$xy}/z.txt' ) | def set( self, v, checkEnv=1, minLen=3, **vars ): """ Assign a new file name @param v: fragment tuples or path or custom-formatted string @type v: [ (str,str) ] OR str @param checkEnv: look for possible substitutions in environment [1] (ignored if v is already formatted like '{/x/y|$xy}/z.txt' ) @type checkEnv: 0|1 ... |
(ignored if v is already formatted like '{/x/y|$xy}/z.txt' ) | def set( self, v, checkEnv=1, minLen=3, **vars ): """ Assign a new file name @param v: fragment tuples or path or custom-formatted string @type v: [ (str,str) ] OR str @param checkEnv: look for possible substitutions in environment [1] (ignored if v is already formatted like '{/x/y|$xy}/z.txt' ) @type checkEnv: 0|1 ... | |
return self.set_path( v, minLen=minLen, **vars ) | return self.set_path( v, minLen=minLen, absolute=absolute, maxSub=maxSub, resolveLinks=resolveLinks, **vars ) | def set( self, v, checkEnv=1, minLen=3, **vars ): """ Assign a new file name @param v: fragment tuples or path or custom-formatted string @type v: [ (str,str) ] OR str @param checkEnv: look for possible substitutions in environment [1] (ignored if v is already formatted like '{/x/y|$xy}/z.txt' ) @type checkEnv: 0|1 ... |
def set_path( self, fname, minLen=3, **vars ): """ Set a new path and try to identify environment variables that could substitute parts of it. If vars is given, env. variables are ignored. | def absfile( self, fname, resolveLinks=0 ): return T.absfile( fname, resolveLinks=resolveLinks ) def set_path( self, fname, minLen=3, absolute=1, resolveLinks=0, maxSub=1, **vars ): """ Set a new path and try to identify settings/environment variables that could substitute parts of it. | def set_path( self, fname, minLen=3, **vars ): """ Set a new path and try to identify environment variables that could substitute parts of it. If vars is given, env. variables are ignored. @param fname: relative or absolute file name @type fname: str @param vars: alternative param=value pairs with suggested substitut... |
@param vars: alternative param=value pairs with suggested substitutors | @param minLen: minimal length of string o to be counted as path @type minLen: int @param absolute: normalize file name [1] @type absolute: 1|0 @param resolveLinks: resolve symbolic links [0] @type resolveLinks: 1|0 @param maxSub: maximal number of substitutions [1] @type maxSub: int @param vars: additional param=va... | def set_path( self, fname, minLen=3, **vars ): """ Set a new path and try to identify environment variables that could substitute parts of it. If vars is given, env. variables are ignored. @param fname: relative or absolute file name @type fname: str @param vars: alternative param=value pairs with suggested substitut... |
return t.Load( self.local( existing=1 ) ) | return T.Load( self.local( existing=1 ) ) | def load( self ): """ Try to unpickle an object from the currently valid path. @return: unpickled object @rtype: any @raise IOError: if file can not be found """ try: return t.Load( self.local( existing=1 ) ) except LocalPathError, why: raise IOError, "Cannot find file %s (constructed from %s)" %\ self.local(), str( ... |
t.Dump( f, o ) | T.Dump( f, o ) | def dump( self, o ): """ Try to pickle an object to the currently valid path. @return: the absolute path to which o was pickled @rtype: str """ try: f = self.local() t.Dump( f, o ) return f except: t.errWriteln("Couldn't dump to %s (constructed from %s)" %\ self.formatted(), self.local() ) raise |
t.errWriteln("Couldn't dump to %s (constructed from %s)" %\ | T.errWriteln("Couldn't dump to %s (constructed from %s)" %\ | def dump( self, o ): """ Try to pickle an object to the currently valid path. @return: the absolute path to which o was pickled @rtype: str """ try: f = self.local() t.Dump( f, o ) return f except: t.errWriteln("Couldn't dump to %s (constructed from %s)" %\ self.formatted(), self.local() ) raise |
v = t.absfile( value ) a = t.absfile( abs ) pos = a.find( v ) | pos = self.__find_subpath( abs, value ) | def __substitute( self, fragments, name, value ): """ Look in all not yet substituted fragments for parts that can be substituted by value and, if successful, create a new fragment @param fragments: fragment tuples @type fragments: [ (str, str) ] @param name: substitution variable name @type name: str @param value: ... |
end = pos + len( v ) f1, f2, f3 = a[0:pos], a[pos:end], a[end:] | end = pos + len( value ) f1, f2, f3 = abs[0:pos], abs[pos:end], abs[end:] | def __substitute( self, fragments, name, value ): """ Look in all not yet substituted fragments for parts that can be substituted by value and, if successful, create a new fragment @param fragments: fragment tuples @type fragments: [ (str, str) ] @param name: substitution variable name @type name: str @param value: ... |
s = t.absfile( o ) | s = T.absfile( o ) | def __is_path( self, o, minLen=3 ): """ Check whether an object is a path string (existing or not). @param minLen: minimal length of string o to be counted as path @type minLen: int @return: 1|0 @rtype: int """ r = ( type( o ) == str and o.find('/') != -1 and len(o) >= minLen\ and o.find(':') == -1 ) if r: try: s = ... |
items = vars.items() or S.__dict__.items() exclude = exclude + self.exclude_vars items = [ (k,v) for (k,v) in items if self.__is_path(v) ] pairs = [ (len(v[1]), v) for v in items if not v[0] in self.exclude_vars ] pairs.sort() return [ x[1] for x in pairs ] | return self.__path_vars( S.__dict__, minLen=minLen, vars=vars, exclude=(exclude + self.exclude_vars ) ) | def __paths_in_settings( self, minLen=3, vars={}, exclude=[]): """ Get all setting variables looking like a path, sorted by length |
items = vars.items() or os.environ.items() exclude = exclude + self.exclude_vars pairs = [ (len(v[1]), v) for v in items if self.__is_path(v[1]) and not v[0] in exclude ] pairs.sort() pairs.reverse() return [ x[1] for x in pairs ] | return self.__path_vars( os.environ, minLen=minLen, vars=vars, exclude=(exclude + self.exclude_vars ) ) | def __paths_in_env( self, minLen=3, vars={}, exclude=[] ): """ Get all environment variables with at least one '/' sorted by length. |
@param vars: alternative param=value pairs to consider instead of environment | @param vars: additional param=value pairs to consider | def get_substitution_pairs( self, minLen=3, vars={}, exclude=[] ): """ Get all variable/value pairs that are available for path substitutions. |
l.set_path( '/home/Bis/raik/data/tb/interfaces/c11/com_wet/ref.com' ) | l.set_path( '/home/xyz/data/tb/interfaces/c11/com_wet/ref.com' ) | def run( self, local=0 ): """ run function test |
l.set_path( t.projectRoot() + '/test/com' ) | l.set_path( T.projectRoot() + '/test/com' ) | def run( self, local=0 ): """ run function test |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.