def saveelts( part, filename): env.history.message( "save main part element symbols -- no, atomic numbers -- to file: " + filename ) def doit(): atoms = atom_array_of_part(part) ## elts = [atm.element.symbol for atm in atoms] elts = [atm.element.eltnum for atm in atoms] env.history.message( "%d element nums, first few are %r" % (len(elts), elts[:5] ) ) thing = array(elts) save_obj(thing, filename) call_func_with_timing_histmsg( doit) return
def savebtypes( part, filename): env.history.message( "save main part bond type v6 ints to file: " + filename ) def doit(): atoms = atom_array_of_part(part) res = [] for atm in atoms: for b in atm.bonds: # don't worry for now about hitting each bond twice... well, do, and see if this makes it slower, as i guess. if b.atom1 is atm: res.append(b.v6) # a small int env.history.message( "%d btype ints, first few are %r" % (len(res), res[:5] ) ) thing = array(res, UnsignedInt8) # tell it to use a smaller type; see numpy.pdf page 14 on typecodes. # update, bruce 070612: we still use Numeric Python (not numarray or numpy). I am not sure what URL # is referred to by "numpy.pdf" above, but it is probably (and should be) about Numeric Python. save_obj(thing, filename) call_func_with_timing_histmsg( doit) return
def count_bonds_cmd( target): win = target.topLevelWidget() assy = win.assy part = assy.tree.part mols = part.molecules env.history.message( "count bonds (twice each) in %d mols:" % len(mols) ) def doit(): return nbonds(mols) nb = call_func_with_timing_histmsg( doit) env.history.message("count was %d, half that is %d" % (nb, nb/2) ) return
def count_bonds_cmd( target): win = target.topLevelWidget() assy = win.assy part = assy.tree.part mols = part.molecules env.history.message( "count bonds (twice each) in %d mols:" % len(mols) ) def doit(): return nbonds(mols) nb = call_func_with_timing_histmsg( doit) env.history.message("count was %d, half that is %d" % (nb, nb/2) ) return
def blerg_cmd( target): win = target.topLevelWidget() assy = win.assy part = assy.tree.part mols = part.molecules env.history.message( "blorg in %d mols:" % len(mols) ) def doit(): return blerg(mols) na, nb = call_func_with_timing_histmsg( doit) env.history.message("count was %d, %d" % (na,nb,) ) return
def loadposns( part, filename): # doesn't move atoms (just a file-reading speed test, for now) env.history.message( "load atom posns from file (discards them, doesn't move atoms): " + filename ) def doit(): return load_obj(filename) posns = call_func_with_timing_histmsg( doit) return
def saveposns(part, filename): env.history.message( "save main part atom posns to file: " + filename ) def doit(): save_atpos_list(part, filename) call_func_with_timing_histmsg( doit)