def uc_test3(): uc = UnitCell() at1 = Atom(symbol='Fe', mass=57) at2 = Atom(symbol='Al') at3 = Atom(symbol="Zr") site1 = Site((0, 0, 0), at1) site2 = Site((0.5, 0.5, 0.5), at2) site3 = Site((0.5, 0.5, 0.0), at3) site4 = Site((0.5, 0.0, 0.5), at3) site5 = Site((0.0, 0.5, 0.5), at3) uc.addSite(site1, "Fe1") uc.addSite(site2, "Al1") uc.addSite(site3, "") uc.addSite(site4, "") uc.addSite(site5, "") print "\n Original unit cell with 3 equivalent Zr atoms:\n" for key in uc._siteIds.keys(): print key, uc._siteIds[key] uc.getSiteFromId("Id0").getAtom().magneticMoment = 1.2 print "\n Modified unit cell with changed Zr magnetic moment:\n" for key in uc._siteIds.keys(): print key, uc._siteIds[key] return
def test(): from UnitCell import UnitCell, Site from Atom import Atom uc = UnitCell() at0 = Atom(symbol="Al") at1 = Atom(symbol="Fe") site0 = Site([0.0, 0.0, 0.0], at0) site1 = Site([0.5, 0.5, 0.5], at1) uc.addSite(site0, "") uc.addSite(site1, "") print uc print from python.parsing.parse_phon_results import parse phonlist = parse("phon.out_dos_noIBZ") wvectors = [[qx, 0.0, 0.0] for qx in range(30)] dwc = DebyeWallerCalculator(uc, phonlist, phonlist) dwlist = [ dwc.getDWFactorForAtom(0, wavevector, 300) for wavevector in wvectors ] #print dwlist return dwlist
def gen_atom(n): rad = np.random.randint(1, 5) atomy = [ Atom(v=Vec2(np.random.randint(75), np.random.randint(75)), pos=Vec2(np.random.randint(5, 40), np.random.randint(5, 40)), r=rad, m=rad * 10) ] i = 0 while len(atomy) < n: x = np.random.randint(5, 40) y = np.random.randint(5, 40) p = Vec2(x, y) rad = np.random.randint(1, 5) flaga = 0 for atom in atomy: odl = dc(atom.pos) - p if odl.length() < atom.r + rad: flaga += 1 if flaga == 0: mass = rad * 10 atomy.append( Atom(v=Vec2(np.random.randint(75), np.random.randint(75)), pos=p, r=rad, m=mass)) return atomy
def make_trial_state(state, timestep): """ Creates a trial state by generating trial walkers from driven diffusion. Arguments: state {Atom} -- An atom state from the previous iteration. timestep {double} -- Size of the time step of each iteration. Returns: Atom -- A trial state with updated walker positions from diffusion. """ new_walkers = [] for walker in state.walkers: # Calculate new position based on former walker new_walker = make_trial_walker(walker, timestep) # Add new walker to set new_walkers.append(new_walker) # Create new trial state to compare with previous trial_state = Atom(alpha = state.alpha, walkers = new_walkers, element = state.element, dims = state.dims) # Update the id of the newest walker, for plotting purposes trial_state.max_walker_id = state.max_walker_id return trial_state
def __init__(self, item, group): self.testMng = group.testMng Atom.__init__(self, item, group) self.LoadSubInfo(item) self.initUeInfo() self.initEnbInfo() self.sqlList = [] self.group = group
def uc_test2(): print "\n*** test2 ***" cellvectors = [(1, 0, 0), (0, 1, 0), (0, 0, 1)] uc = create_unitcell( cellvectors, [Atom(symbol='Fe'), Atom(symbol='Al')], [(0, 0, 0), (0.5, 0.5, 0.5)]) print uc return
def test(): from Atom import Atom from Molecule import Molecule from IO_MOLPRO import InputMOLPRO at1 = Atom(symbol='H', position=[2,0,0]) at2 = Atom(symbol='H', position=[0,0,0]) mol = Molecule([at1,at2]) inp = InputMOLPRO() pot = Potential_QM(mol,inp) pot.calc()
def read_atoms(self, f): for line in f: if line.isspace(): break if line[0] == ';': continue line = line.split() atom = Atom(line[0], line[1], line[2], line[3], line[4], line[5], line[6], line[7]) if len(line) > 8: if line[8] == "AR": atom.set_aromatic() self.atom_list.append(atom)
def test(): a = InputMOLPRO('test.com') at1 = Atom(symbol='O', position=[0.0, 0.0, 0.0]) at2 = Atom(symbol='H', position=[2.0, 0.0, 0.0]) at3 = Atom(symbol='H', position=[0.0, 2.0, 0.0]) a.set_option('symmetry,nosym\n') a.set_method('hf\nforces\n') a.set_coordinate([at1,at2,at3]) a.make_input() a.write()
def test3(): from Atom import Atom from Molecule import Molecule from VelocityVerlet import VelocityVerlet from Constants import fs2tau at1 = Atom(symbol='Ar', position=[5,0,0]) at2 = Atom(symbol='Ar', position=[0,0,0]) at3 = Atom(symbol='Ar', position=[0,5,0]) mol = Molecule([at1,at2,at3]) pot = Potential_MM(mol) md = VelocityVerlet(mol,pot,deltat=0.5*fs2tau ,nstep=200) md.run()
def write(self, atomdict): """ Write an atom to the file. Args: atom (dict): a dictionary describing the atom. """ from Atom import Atom at = Atom(atomdict) self._handle.write(at.sym + " ") pos = at.get_position(self.units) self._handle.write(" ".join([str(x) for x in pos])) self._handle.write("\n")
def __init__(self, score): "Initialises resources and start level" self.atoms = pygame.sprite.Group() self.ntype = 2 #number of atom classes self.level = 2 for i in range(10): self.atoms.add(Atom((random(), random()), "green", 1.0, self)) for i in range(10): self.atoms.add(Atom((random(), random()), "blue", 1.0, self)) Level.__init__(self, score, 75)
def read_pmd(self, fname='pmd0000'): f = open(fname, 'r') # 1st: lattice constant self.alc = float(f.readline().split()[0]) # 2nd-4th: cell vectors for i in range(3): data = f.readline().split() self.a1[i] = float(data[0]) self.a2[i] = float(data[1]) self.a3[i] = float(data[2]) # self.a1= np.array([float(x) for x in f.readline().split()]) # self.a2= np.array([float(x) for x in f.readline().split()]) # self.a3= np.array([float(x) for x in f.readline().split()]) # 5th-7th: velocity of cell vectors tmp = f.readline().split() tmp = f.readline().split() tmp = f.readline().split() # 8st: num of atoms natm = int(f.readline().split()[0]) # 9th-: atom positions self.atoms = [] for i in range(natm): data = [float(x) for x in f.readline().split()] ai = Atom() ai.decode_tag(data[0]) ai.set_pos(data[1], data[2], data[3]) ai.set_vel(data[4], data[5], data[6]) self.atoms.append(ai) f.close()
def expand(self,n1,n2,n3): #...expand unit vectors self.a1= self.a1*n1 self.a2= self.a2*n2 self.a3= self.a3*n3 n123= n1*n2*n3 nsid= 0 for ai in self.atoms: nsid= max(nsid,ai.sid) natm_per_spcs= np.zeros((nsid,),dtype=int) for ai in self.atoms: sid= ai.sid -1 natm_per_spcs[sid] += 1 natm0= self.num_atoms() atoms0= copy.copy(self.atoms) self.atoms= [] aid= 0 for ai0 in atoms0: ai0.pos[0] /= n1 ai0.pos[1] /= n2 ai0.pos[2] /= n3 for i1 in range(n1): for i2 in range(n2): for i3 in range(n3): aid += 1 ai= Atom() ai.sid= ai0.sid x= ai0.pos[0]+1.0/n1*i1 y= ai0.pos[1]+1.0/n2*i2 z= ai0.pos[2]+1.0/n3*i3 ai.set_pos(x,y,z) ai.set_auxd(ai0.auxd) ai.set_id(aid) self.atoms.append(ai)
def isTypeOG304(self, mol, atm_index): atom = mol.atoms[atm_index] atom_linked_1 = Atom() atom_linked_2 = Atom() if atom.num_linkages == 2: atom_linked_1 = mol.atoms[atom.linkage[0]] atom_linked_2 = mol.atoms[atom.linkage[1]] if (atom_linked_1.element.lower() == "P".lower() or atom_linked_1.element.lower() == "S".lower()) and atom_linked_1.numOxygenAtoms == 4: if (atom_linked_2.element.lower() == "P".lower() or atom_linked_2.element.lower() == "S".lower()) and atom_linked_2.numOxygenAtoms == 4: return True return False
def parse_atom_line(self, line): # parses an atom line, returns an atom object record_name = line[:6] serial_number = line[6:11] atom_name = line[11:17] alt_loc = line[16:17] residue_name = line[17:20] chain_id = line[20:22] residue_number = line[22:26] icode = line[26:30] x_coord = line[30:38] y_coord = line[38:46] z_coord = line[46:54] occupancy = line[54:60] bfactor = line[60:66] element = line[66:78] charge = line[78:] #troubleshooting #print(record_name+","+serial_number+","+atom_name+","+alt_loc+","+res_name+","+chain_id+","+res_seq+","+icode+","+xcoord+","+ycoord+","+zcoord+","+occupancy+","+bfactor+","+element+","+charge+",") atom = Atom(record_name, serial_number, atom_name, alt_loc, residue_name, chain_id, residue_number, icode, x_coord, y_coord, z_coord, occupancy, bfactor, element, charge) #print(record_name,serial_number,atom_name,alt_loc,residue_name,chain_id,residue_number,icode,x_coord,y_coord,z_coord,occupancy,bfactor,element,charge) return atom
def parse(tokens): syntax_tree = list() #if we have no tokens at start, there is an error if len(tokens) is 0: raise SyntaxError("Expected tokens") #get current token and take it off tokens list cur_token = tokens.pop(0) #if we get a ) token, then there is an error # ) shouldnt come before ( if cur_token is ")": raise SyntaxError("Expected (") #if we get a ( then recursivley call parse, adding the output to our parse tokens list elif cur_token is "(": #loop until we get a ), ending the list while tokens[0] is not ")": syntax_tree.append(parse(tokens)) #once we get a ), remove it from the tokens list and return the syntax tree tokens.pop(0) return syntax_tree #if none of the above, token is an atom #create an atom and return it else: atom = Atom(cur_token) return atom
def initializeAtomData(self): """ Return dictionary of atomData based on all symbols in SMILES code. Atom objects are created based on the symbol and index position of that atom Handles charges and finds valid alcohol indices """ atomData = {} atomIndex = -1 # 0 based indexing of atoms for pos, symbol in enumerate(self.SMILES): if symbol in self.ATOMS: # Exclusively analyze atoms atomIndex += 1 atomSymbol = symbol if self.SMILES[ pos - 1] == '[': # If atom charged, collect its bracketed group atomSymbol = self.getChargedGroup( pos - 1) # Use opening bracket for charge group atom = Atom(atomIndex, atomSymbol) # Create new atom objects atomData[atomIndex] = atom # Atom index to atom object pairing if symbol == 'O': # Alochols stem from oxygens self.determineAlcoholGroup(pos, atomIndex) return atomData
def test2(self): uc = UnitCell() uc.addAtom(Atom('H', (0,0,0.1))) self.assert_(uc.hasAtom(Atom('H', (0,0,0.10000001)))) self.assert_(uc.hasAtom(Atom('H', (0,0,0.09999999)))) self.assert_(not uc.hasAtom(Atom('H', (0,0,0.11)))) self.assert_(not uc.hasAtom(Atom('H', (0,0,0.09)))) self.assert_(uc.hasAtom(Atom('H', (0,0,1.10000001)))) self.assert_(uc.hasAtom(Atom('H', (0,0,1.09999999)))) self.assert_(not uc.hasAtom(Atom('H', (0,0,1.11)))) self.assert_(not uc.hasAtom(Atom('H', (0,0,1.09)))) self.assert_(not uc.hasAtom(Atom('H', (0,0,1.09999)))) return
def read_pdbqt(self, filename): with open(filename, 'r') as p_file: branch_stack = [] current_branch = None # Like atom ID, branch ID starts from 1. branch_id = 1 for line in p_file: # HETATM if line.startswith("HETATM"): data = line.split() atom_id = int(data[1]) tcoord = Axis3(float(data[6]), \ float(data[7]), \ float(data[8])) current_branch = branch_stack[-1] atom = Atom(atom_id, data[12], tcoord, float(data[11]), \ current_branch) self.ori_atoms.append(atom) # Update atom id into current active branches # Note: First branch is root but when collecting atoms, it # is treated as a branch) for branch in branch_stack: if atom_id != branch.link_id: branch.all_atom_ids.append(atom_id) if atom_id != branch_stack[-1].link_id: branch_stack[-1].atom_ids.append(atom_id) # ROOT elif line.startswith("ROOT"): # Ligand has only one root. Always set the ID to 1. self.root = Branch(branch_id, None, None, [], [], None, []) branch_id += 1 # Push root into branch_stack branch_stack.append(self.root) # ENDROOT elif line.startswith("ENDROOT"): branch_stack.pop() # BRANCH elif line.startswith("BRANCH"): anchor_id, link_id = [int(x) for x in line.split()[1:]] # Get parent branch from the stack (which is the last one). # If it empty, it means this branch directly linked to the # root. if not branch_stack: parent_branch = self.root else: parent_branch = branch_stack[-1] branch = Branch(branch_id, anchor_id, link_id, [], \ [], parent_branch, []) # Now the parent branch has this branch as the child parent_branch.children.append(branch) self.branches.append(branch) # Push active branch into branch_stack branch_stack.append(branch) branch_id += 1 # ENDBRANCH elif line.startswith("ENDBRANCH"): # Pop inactive branch from branch_stack branch_stack.pop() self.reset_atoms()
def __init__(self, atomname, estimate_num, dens): self.atomname = atomname self.n = estimate_num mass = Atom(symbol=self.atomname).GetMass() self.numdens = dens / 9.10939e-4 / mass / ang2bohr**3 self.vlength = (self.n / self.numdens)**(1.0 / 3.0) self.make_lattice()
def read_atoms(self,f): for line in f: if line.isspace(): break if line[0] == ';': continue line = line.split() atom = Atom(line[0],line[1],line[2],line[3],line[4],line[5],line[6],line[7]) self.atom_list.append(atom)
def branch_state(state, merits): # New walkers branch_walkers = [] for i in range(state.nbr_of_walkers): # Make m-1 copies of each walker nbr_of_copies = merits[i] # Append all copies of these walkers for _ in range(nbr_of_copies): branch_walkers.append(state.walkers[i]) # Re-number all walkers for walker, i in zip(branch_walkers, range(len(branch_walkers))): walker.id = i # Create new state new_state = Atom(alpha = state.alpha, walkers = branch_walkers, element = state.element, dims = state.dims) return new_state
def __init__(self, score): "Initialises resources and start level" self.atoms = pygame.sprite.Group() self.ntype = 2 #number of atom classes self.level = 1 for i in range(4): self.atoms.add(Atom((random(), random()), "green", 1.0, self)) for i in range(4): self.atoms.add(Atom((random(), random()), "blue", 1.0, self)) Level.__init__(self, score, 35) pygame.mixer.music.load("music/menu.ogg") pygame.mixer.music.play(-1)
def uc_test1(): print "\n*** test1 ***" uc = UnitCell() at1 = Atom(symbol='Fe', mass=57) pos1 = (0.0, 0.0, 0.0) at2 = Atom(symbol='Al') pos2 = (0.5, 0.5, 0.5) site1 = Site(pos1, at1) site2 = Site(pos2, at2) uc.addAtom(at1, pos1, "Fe1") uc.addAtom(at2, pos2, "Al1") for site in uc: print "\n position %s \n %s" % (site.getPosition(), site.getAtom()) continue return
def __copy__(self): new = UnitCell() new._lattice = self._lattice for siteId in self._siteIds.keys(): newsite = Site(self._siteIds[siteId].getPosition(), Atom(Z=self._siteIds[siteId].getAtom().Z)) new.addSite(newsite, siteId=siteId) return new
def read_akr(self,fname='akr0000'): f=open(fname,'r') # 1st: lattice constant self.alc= float(f.readline().split()[0]) # 2nd-4th: cell vectors self.a1= np.array([float(x) for x in f.readline().split()]) self.a2= np.array([float(x) for x in f.readline().split()]) self.a3= np.array([float(x) for x in f.readline().split()]) # 5th: num of atoms buff= f.readline().split()[0] natm= int(buff[0]) nauxd= int(buff[1]) if nauxd < 3: print '[Error] read_akr(): nauxd < 3 !!!' sys.exit() # 9th-: atom positions self.atoms= [] for i in range(natm): data= [float(x) for x in f.readline().split()] ai= Atom() ai.set_sid(data[0]) ai.set_pos(data[1],data[2],data[3]) # if there are less than 3 auxiliary data, there is not velocity ai.set_vel(data[4],data[5],data[6]) self.atoms.append(ai) f.close()
def __init__(self, atomnames = [], atomnumbers = [], positions = None, velocities = None,\ forces = None, ndims = 3): assert atomnames != [] or atomnumbers != [], "define atomic symbols or atomic numbers" self.atomnames, self.atomnumbers = [], [] self.masses = [] self.ndims = ndims if atomnames != []: self.atomnames = [atom.lower().capitalize() for atom in atomnames] for atom in self.atomnames: self.masses.append(Atom(symbol=atom).GetMass()) self.atomnumbers.append(Atom(symbol=atom).GetAtomicNumber()) if atomnumbers != []: self.atomnumbers = atomnumbers for natom in self.atomnumbers: self.masses.append(Atom(Z=natom).GetMass()) self.atomnames.append(Atom(Z=natom).GetChemicalSymbol()) self.atomnames = np.array(self.atomnames) self.atomnumbers = np.array(self.atomnumbers) self.masses = np.array(self.masses) self.natoms = len(self.atomnames) if positions == None: self.positions = np.zeros((self.natoms, self.ndims)) else: assert np.shape(positions) == ( self.natoms, self.ndims), "Molecule class size error" self.positions = np.array(positions) if velocities == None: self.velocities = np.zeros((self.natoms, self.ndims)) else: assert np.shape(velocities) == ( self.natoms, self.ndims), "Molecule class size error" self.velocities = np.array(velocities) if forces == None: self.forces = np.zeros((self.natoms, self.ndims)) else: assert np.shape(forces) == ( self.natoms, self.ndims), "Molecule class size error" self.forces = np.array(forces)
def read_pmd(self,fname='pmd0000'): f=open(fname,'r') # 1st: lattice constant self.alc= float(f.readline().split()[0]) # 2nd-4th: cell vectors self.a1= np.array([float(x) for x in f.readline().split()]) self.a2= np.array([float(x) for x in f.readline().split()]) self.a3= np.array([float(x) for x in f.readline().split()]) # 5th-7th: velocity of cell vectors tmp= f.readline().split() tmp= f.readline().split() tmp= f.readline().split() # 8st: num of atoms buff= f.readline().split() natm= int(buff[0]) nauxd= 9 # 9th-: atom positions self.atoms= [] for i in range(natm): data= [float(x) for x in f.readline().split()] ai= Atom() ai.decode_tag(data[0]) ai.set_pos(data[1],data[2],data[3]) ai.set_auxd(data[4:4+nauxd]) self.atoms.append(ai) f.close()
def addNewAtom(self, *args, **kwargs): """Add new Atom instance to the end of this Structure. All arguments are forwarded to Atom constructor. """ kwargs['lattice'] = self.lattice a = Atom(*args, **kwargs) list.append(self, a) self._uncache('labels')
def FromAtomPaths(selfClass, atomPaths, atoms=None): """Create a sequence from a list of atom paths.""" # . Argument check. if (atoms is not None) and (len(atoms) != len(atomPaths)): raise ValueError( "The \"atomPaths\" and \"atoms\" arguments are incompatible.") createAtoms = (atoms is None) # . Initialization. self = selfClass() # . Process the paths. duplicateAtoms = 0 index = 0 for atomPath in atomPaths: (entityLabel, componentLabel, atomLabel) = self.ParsePath(atomPath, labels=3) (entity, component, atom) = self.GetDescendantsFromLabels(entityLabel, componentLabel, atomLabel) if entity is None: entity = SequenceEntity(label=entityLabel) self.AddChild(entity) if component is None: genericLabel = self.ParseLabel(componentLabel, fields=1)[0] component = SequenceComponent(genericLabel=genericLabel, label=componentLabel) entity.AddChild(component) if atom is None: if createAtoms: atom = Atom(index=index, label=atomLabel) else: atom = atoms[index] atom.index = index atom.label = atomLabel index += 1 component.AddChild(atom) else: duplicateAtoms += 1 if duplicateAtoms > 0: raise ValueError( "There were {:d} duplicate atom paths in the sequence.".format( duplicateAtoms)) # . Finish up. return self
def insert_quote(syntax_tree): #loop through all expressions in the tree for index, expr in enumerate(syntax_tree): #if the expression is a list, recursivley call insert_quote on the list if isinstance(expr, list): insert_quote(expr) #if the expression is the ' atom, replace it with (quote symbol) elif expr.data is "'": syntax_tree[index] = [Atom("quote"), syntax_tree[index + 1]] syntax_tree.pop(index + 1)
def isTypeNG3N1(self, mol, atm_index): atom = mol.atoms[atm_index] atom_linked = Atom() if atom.num_linkages == 3: index = self.getIndexElement(mol, atm_index, "N") if index != -1: atom_linked = mol.atoms[index] if atom_linked.numHydrogenAtoms == 2 or atom_linked.numHydrogenAtoms == 1: return True return False
def miss_res_atoms(res_list): miss_res_atoms=[] all_aa_lib=AllAminoAcidLib() sequence=res_list.sequence() for i,aa in enumerate(sequence): if aa=='-': continue for atom_name in all_aa_lib.aa_lib(aa).iter_atoms(): atom=Atom(atom_name,i+1) if atom.elem() not in 'CNH': continue try: res=res_list.by_atom(atom) except KeyError: try: pn=BmrbAtomNames.get_combine(aa,atom_name)[0] if pn==None: miss_res_atoms.append(atom) continue res=res_list.by_atom(Atom(pn,i+1)) except KeyError: miss_res_atoms.append(atom) return miss_res_atoms
def read_POSCAR(self,fname='POSCAR'): f=open(fname,'r') # 1st: comment self.c1= f.readline() # 2nd: multiplying factor self.alc= float(f.readline().split()[0]) # 3-5: lattice vectors self.a1= np.array([float(x) for x in f.readline().split()]) self.a2= np.array([float(x) for x in f.readline().split()]) self.a3= np.array([float(x) for x in f.readline().split()]) # 6th: num of atoms par species data= f.readline().split() if( data[0].isdigit() ): natm_per_spcs= np.array([int(d) for d in data]) else: # skip one line and read next line data= f.readline().split() natm_per_spcs= np.array([int(d) for d in data]) # 7th: comment (in some cases, 8th line too) self.c7= f.readline() if self.c7[0] in ('s','S'): self.c8= f.readline() # hereafter: atom positions sid= 0 self.atoms=[] for ni in natm_per_spcs: sid += 1 for j in range(ni): line= f.readline().split() data= [ float(line[i]) for i in range(3)] ai= Atom() ai.set_sid(sid) ai.set_pos(data[0],data[1],data[2]) ai.set_auxd(line[3:]) ai.pbc() self.atoms.append(ai) f.close()
class Frontend(): def __init__(self,x,y,b): self.x=str(x) #1600 self.y=str(y) #900 self.pressed=0 self.b=10 self.c=30 self.grapher=0 self.graph=[0,0,0,0] self.root=b def startwindow(self): # self.root=Tk() a=str(self.x+'x'+self.y) self.root.title('Wahrscheinlichkeinten & Simulation') self.root.geometry(a) self.g=Label(self.root,bg='white') self.g.place(x=0,y=0,width=self.x,height=self.y) # self.g.bind('<1>',self.optioncanged) self.lst1 = ['Marriage','Atom','BubbleGum','House_of_Cards','Lotto','SecretSanta','Coins'] self.var1 = StringVar(self.root) self.var1.set('Marriage') self.drop = OptionMenu(self.root,self.var1,*self.lst1) self.drop.config(font=('Arial',(30)),bg='white') self.drop['menu'].config(font=('calibri',(20)),bg='white') self.drop.pack(side=TOP) self.photo = PhotoImage(file='z1.gif') self.label = Label(image=self.photo,borderwidth=0) self.label.image = self.photo self.label.bind('<1>',self.MouseOneDown) self.label.place(y=0,x=int(self.x)-200) self.startbutton=Button(self.root,text='Start',font=('Arial',40),bg='#B4045F',borderwidth=5,command=self.startpressed) self.startbutton.place(x=0,y=int(self.y)-100,width=int(self.y)-200,height=100) self.csvbutton=Button(self.root,text='Export CSV',font=('Arial',40),bg='green',borderwidth=5,command=self.csvpressed) self.csvbutton.place(x=int(self.x)/2+50,y=int(self.y)-100,width=int(self.y)-230,height=100) def startpressed(self): if self.grapher==1: for x in range(len(self.graph)): if self.graph[x]!=0: self.graph[x].destroy() self.grapher=0 self.root.update() a=self.var1.get() if self.pressed==1: try: self.b=int(self.changer0.get('1.0','end-1c')) except (AttributeError,TclError,ValueError): self.b=10 try: self.c=self.changer2.get('1.0','end-1c') except (AttributeError,TclError,ValueError): self.c=1 if a=='Marriage': self.run0=Marriage(self.b) self.run0.DEBUG=False self.run0.sim() elif a=='Atom': self.c=float(self.c) self.run1=Atom(self.c,self.b) self.run1.DEBUG=False self.run1.sim() elif a=='BubbleGum': self.run2=BubbleGum(self.b) self.run2.DEBUG=False self.run2.sim() self.grapher=1 self.graph=[0,0] g=str(round(self.run2.getrel()[0],4)) h=str(round(self.run2.getrel()[1],4)) self.graph[0]=Label(self.root,bg='white',text='Durchschnitt Karten zu viel: '+g,font=('calibri',19)) self.graph[0].place(x=10,y=450) self.graph[1]=Label(self.root,bg='white',text='Durchschnitt dass es passiert: '+h,font=('calibri',19)) self.graph[1].place(x=10,y=500) elif a=='House_of_Cards': if self.c=='': self.c=0 else: self.c=int(self.c) self.run3=House_of_Cards(self.b,self.c) self.run3.DEBUG=False self.run3.sim() self.grapher=1 self.graph=[0] self.graph[0]=Label(self.root,bg='white',text=('Durchschnitt: '+str(round(self.run3.getrel(),4))),font=('calibri',19)) self.graph[0].place(x=10,y=450) elif a=='Lotto': self.run4=Lotto(self.b) self.run4.DEBUG=False self.run4.sim() x=4 y=1 count=0 self.graph=[0,0,0,0] self.grapher=1 self.graph[0]=Label(self.root,bg='black') self.graph[0].place(x=10,width=10+(int(self.x)*0.8),height=1,y=int(self.y)-int(self.y)/4*0.5-350) self.graph[1]=Label(self.root,text='50%',bg='white',font=('calibri',10)) self.graph[1].place(x=60+(int(self.x)*0.8),width=50,height=50,y=int(self.y)-int(self.y)/4*0.5-375) self.graph[2]=Label(self.root,bg='black') self.graph[2].place(x=10,width=20,height=1,y=int(self.y)-350) self.graph[3]=Label(self.root,bg='black') self.graph[3].place(x=10,width=20,height=1,y=int(self.y)-int(self.y)/4-350) for draw in self.run4.turns: if draw.count(0) == 0: count += 1 elif draw.count(1) == 0: count += 1 elif draw.count(2) == 0: count += 1 elif draw.count(3) == 0: count += 1 elif draw.count(4) == 0: count += 1 elif draw.count(5) == 0: count += 1 self.graph+=[0] self.graph[x]=Label(self.root,bg='red') if str(self.c)=='1': self.graph[x].place(x=int(10+(int(self.x)*0.8)*((y-1)/self.b)),width=int(1250/self.b),height=int(self.y)-350-(int(int(self.y)-int(self.y)/4*(count/y)-350)),y=int(int(self.y)-int(self.y)/4*(count/y)-350)) else: self.graph[x].place(x=int(10+(int(self.x)*0.8)*(y/self.b)),width=3,height=3,y=int(int(self.y)-int(self.y)/4*(count/y)-350)) x+=1 y+=1 self.root.update() elif a=='SecretSanta': if self.c=='': self.c=1 else: self.c=int(self.c) self.run5=SecretSanta(self.b,self.c) self.run5.DEBUG=False self.run5.sim() self.grapher=1 self.graph=[0] self.graph[0]=Label(self.root,bg='white',text=('Durchschnitt: '+str(round(self.run5.getrel(),4))),font=('calibri',19)) self.graph[0].place(x=10,y=450) elif a=='Coins': self.run6=Coins(self.b) self.run6.sim() self.grapher=1 self.graph=[0,0] v=self.run6.geterg() vv=self.run6.getrel() self.graph[0]=Label(self.root,bg='white',text=('Statistik für www: '+str(v[0])+' '+str(vv[0])),font=('calibri',19)) self.graph[0].place(x=10,y=450) self.graph[1]=Label(self.root,bg='white',text=('Statistik für zwz: '+str(v[1])+' '+str(vv[1])),font=('calibri',19)) self.graph[1].place(x=10,y=500) def csvpressed(self): a=self.var1.get() if a=='Marriage': self.run0.exportcsv('Marriage_Simulation.csv') elif a=='Atom': self.run1.exportCSV('Atom_Simulation.csv') elif a=='Lotto': self.run4.exportCSV('Lotto_Simulation.csv') # def optioncanged(self,event): # a=self.var1.get() # if a=='Marriage': # self.csvbutton.destroy() # self.csvbutton=Button(self.root,text='Export CSV',font=('Arial',40),bg='green',borderwidth=5,command=self.csvpressed) # self.csvbutton.place(x=int(self.x)/2+50,y=int(self.y)-100,width=int(self.y)-230,height=100) # elif a=='Atom': # self.csvbutton.destroy() # self.csvbutton=Button(self.root,text='Export CSV',font=('Arial',40),bg='green',borderwidth=5,command=self.csvpressed) # self.csvbutton.place(x=int(self.x)/2+50,y=int(self.y)-100,width=int(self.y)-230,height=100) # elif a=='BubbleGum': # self.csvbutton.destroy() # self.csvbutton=Button(self.root,text='Export CSV',font=('Arial',40),bg='gray',borderwidth=5) # self.csvbutton.place(x=int(self.x)/2+50,y=int(self.y)-100,width=int(self.y)-230,height=100) # elif a=='House_of_Cards': # self.csvbutton.destroy() # self.csvbutton=Button(self.root,text='Export CSV',font=('Arial',40),bg='gray',borderwidth=5) # self.csvbutton.place(x=int(self.x)/2+50,y=int(self.y)-100,width=int(self.y)-230,height=100) # elif a=='Lotto': # self.csvbutton.destroy() # self.csvbutton=Button(self.root,text='Export CSV',font=('Arial',40),bg='green',borderwidth=5,command=self.csvpressed) # self.csvbutton.place(x=int(self.x)/2+50,y=int(self.y)-100,width=int(self.y)-230,height=100) #elif a=='SecretSanta': # self.csvbutton.destroy() # self.csvbutton=Button(self.root,text='Export CSV',font=('Arial',40),bg='gray',borderwidth=5) # self.csvbutton.place(x=int(self.x)/2+50,y=int(self.y)-100,width=int(self.y)-230,height=100) def MouseOneDown(self,event): if self.pressed==0: a=self.var1.get() if a=='Marriage': self.changer0=Text(self.root,bg='white',font=('Arial',30),borderwidth=1) self.changer0.place(y=100,x=int(self.x)-150,width=100,height=50) self.changer1=Label(self.root,text='Versuche:',bg='white',font=('Arial',30),borderwidth=1) self.changer1.place(y=100,x=int(self.x)-400,width=250,height=50) self.csvbutton.destroy() self.csvbutton=Button(self.root,text='Export CSV',font=('Arial',40),bg='green',borderwidth=5,command=self.csvpressed) self.csvbutton.place(x=int(self.x)/2+50,y=int(self.y)-100,width=int(self.y)-230,height=100) elif a=='Atom': self.changer0=Text(self.root,bg='white',font=('Arial',30),borderwidth=1) self.changer0.place(y=100,x=int(self.x)-150,width=100,height=50) self.changer1=Label(self.root,text='Anzahl der Atome:',bg='white',font=('Arial',30),borderwidth=1) self.changer1.place(y=100,x=int(self.x)-600,width=450,height=50) self.changer2=Text(self.root,bg='white',font=('Arial',30),borderwidth=1) self.changer2.place(y=200,x=int(self.x)-150,width=100,height=50) self.changer3=Label(self.root,text='Zerfallswahrscheinlichkeit:',bg='white',font=('Arial',30),borderwidth=1) self.changer3.place(y=200,x=int(self.x)-650,width=500,height=50) self.csvbutton.destroy() self.csvbutton=Button(self.root,text='Export CSV',font=('Arial',40),bg='green',borderwidth=5,command=self.csvpressed) self.csvbutton.place(x=int(self.x)/2+50,y=int(self.y)-100,width=int(self.y)-230,height=100) elif a=='BubbleGum': self.changer0=Text(self.root,bg='white',font=('Arial',30),borderwidth=1) self.changer0.place(y=100,x=int(self.x)-150,width=100,height=50) self.changer1=Label(self.root,text='Versuche:',bg='white',font=('Arial',30),borderwidth=1) self.changer1.place(y=100,x=int(self.x)-400,width=250,height=50) self.csvbutton.destroy() self.csvbutton=Button(self.root,text='Export CSV',font=('Arial',40),bg='gray',borderwidth=5) self.csvbutton.place(x=int(self.x)/2+50,y=int(self.y)-100,width=int(self.y)-230,height=100) elif a=='House_of_Cards': self.changer0=Text(self.root,bg='white',font=('Arial',30),borderwidth=1) self.changer0.place(y=100,x=int(self.x)-150,width=100,height=50) self.changer1=Label(self.root,text='Versuche:',bg='white',font=('Arial',30),borderwidth=1) self.changer1.place(y=100,x=int(self.x)-400,width=250,height=50) self.changer2=Text(self.root,bg='white',font=('Arial',30),borderwidth=1) self.changer2.place(y=200,x=int(self.x)-150,width=100,height=50) self.changer3=Label(self.root,text='Kartenanzahl(32,55):',bg='white',font=('Arial',30),borderwidth=1) self.changer3.place(y=200,x=int(self.x)-620,width=450,height=50) self.csvbutton.destroy() self.csvbutton=Button(self.root,text='Export CSV',font=('Arial',40),bg='gray',borderwidth=5) self.csvbutton.place(x=int(self.x)/2+50,y=int(self.y)-100,width=int(self.y)-230,height=100) elif a=='Lotto': self.changer0=Text(self.root,bg='white',font=('Arial',30),borderwidth=1) self.changer0.place(y=100,x=int(self.x)-150,width=100,height=50) self.changer1=Label(self.root,text='Versuche:',bg='white',font=('Arial',30),borderwidth=1) self.changer1.place(y=100,x=int(self.x)-400,width=250,height=50) self.changer2=Text(self.root,bg='white',font=('Arial',30),borderwidth=1) self.changer2.place(y=200,x=int(self.x)-150,width=100,height=50) self.changer3=Label(self.root,text='Version:',bg='white',font=('Arial',30),borderwidth=1) self.changer3.place(y=200,x=int(self.x)-400,width=250,height=50) self.csvbutton.destroy() self.csvbutton=Button(self.root,text='Export CSV',font=('Arial',40),bg='green',borderwidth=5,command=self.csvpressed) self.csvbutton.place(x=int(self.x)/2+50,y=int(self.y)-100,width=int(self.y)-230,height=100) elif a=='SecretSanta': self.changer0=Text(self.root,bg='white',font=('Arial',30),borderwidth=1) self.changer0.place(y=100,x=int(self.x)-150,width=100,height=50) self.changer1=Label(self.root,text='Versuche:',bg='white',font=('Arial',30),borderwidth=1) self.changer1.place(y=100,x=int(self.x)-400,width=250,height=50) self.changer2=Text(self.root,bg='white',font=('Arial',30),borderwidth=1) self.changer2.place(y=200,x=int(self.x)-150,width=100,height=50) self.changer3=Label(self.root,text='Anzahl der Schüler:',bg='white',font=('Arial',30),borderwidth=1) self.changer3.place(y=200,x=int(self.x)-550,width=400,height=50) self.csvbutton.destroy() self.csvbutton=Button(self.root,text='Export CSV',font=('Arial',40),bg='gray',borderwidth=5) self.csvbutton.place(x=int(self.x)/2+50,y=int(self.y)-100,width=int(self.y)-230,height=100) elif a=='Coins': self.changer0=Text(self.root,bg='white',font=('Arial',30),borderwidth=1) self.changer0.place(y=100,x=int(self.x)-150,width=100,height=50) self.changer1=Label(self.root,text='Versuche:',bg='white',font=('Arial',30),borderwidth=1) self.changer1.place(y=100,x=int(self.x)-400,width=250,height=50) self.csvbutton.destroy() self.csvbutton=Button(self.root,text='Export CSV',font=('Arial',40),bg='gray',borderwidth=5) self.csvbutton.place(x=int(self.x)/2+50,y=int(self.y)-100,width=int(self.y)-230,height=100) self.pressed=1 else: try: self.c=self.changer2.get('1.0','end-1c') self.changer3.destroy() self.changer2.destroy() except (AttributeError,TclError): z=0 try: self.b=self.changer0.get('1.0','end-1c') self.changer1.destroy() self.changer0.destroy() except (AttributeError,TclError): z=0 if self.b=='': self.b=1 else: self.b=int(self.b) if self.c=='': self.c=1 else: self.c=int(float(self.c)) self.pressed=0
def alignPDB(self, skipBlanks = True, modellerCompatibilityMode=False): # Sort the alignments by similarity alignments = self.alignments alignments.sort(key = lambda a: a.score,reverse=True) target = None template = None alignment = None # Get the highest scoring alignment with similarity below 90% for a in alignments: if a.similarity > 90: continue else: alignment = a target = a.target template = a.template pdb = self.pdbs[a.id] break if self.debug: print("Selected Template",alignment.id) # We now have the alignment and the pdb # Convert the pdb to a residue sequence # DO NOT CHANGE THESE seq = [] curres = '---' res = [] first = True atomnum = 5 resnum = 0 for line in pdb.lines: # Decode from byte array line = line.decode() # Grab only ATOM lines if line[:6] == 'ATOM ': # Get the atomname (N,CA,C,O) atomname = line[12:16] # First make sure you're only storing N, CA, C and O if atomname not in (' N ',' CA ',' C ',' O ') or line[16] not in (' ','A'): continue # Check to see if residue changed if line[17:20] != curres or atomnum > 4: if self.debug: print("%8s%8s%8s%8s" % ('CURRES','NEWRES','RESNUM','ATONUM')) print("%8s%8s%8d%8d" % (curres,line[17:20],resnum,atomnum)) print(line) # Check to make sure the last residue was complete if atomnum < 5: # Add on the missing atoms to the end of the residue if atomnum == 1: atom = Atom(atomName=' N ',resName=curres,elemSym=' N',missing=True) res.append(atom) atomnum += 1 if atomnum == 2: atom = Atom(atomName=' CA ',resName=curres,elemSym=' C',missing=True) res.append(atom) atomnum += 1 if atomnum == 3: atom = Atom(atomName=' C ',resName=curres,elemSym=' C',missing=True) res.append(atom) atomnum += 1 if atomnum == 4: atom = Atom(atomName=' O ',resName=curres,elemSym=' O',missing=True) res.append(atom) atomnum += 1 # Append the residue to the sequence if res: seq.append((amino3to1[curres],res)) # If this is the first atom fill in the blanks from the PDB if first: first = False if self.debug: print("Starting resnum:",int(line[22:26])) # Residue number of first residue in PDB for k in range(1,int(line[22:26])): resname = '---' res = [] res.append(Atom(atomName=' N ',resName=resname,elemSym=' N',missing=True)) res.append(Atom(atomName=' CA ',resName=resname,elemSym=' C',missing=True)) res.append(Atom(atomName=' C ',resName=resname,elemSym=' C',missing=True)) res.append(Atom(atomName=' O ',resName=resname,elemSym=' O',missing=True)) seq.append((amino3to1[resname],res)) # Decrement resnum by one to mimic the last res not in the PDB resnum = int(line[22:26])-1 # Check for resnum increment so we don't miss residues resinc = int(line[22:26])-resnum if resinc != 1: if self.debug: print("Resiude skip:",resnum,"->",int(line[22:26])) for k in range(1,resinc): resname = '---' res = [] res.append(Atom(atomName=' N ',resName=resname,elemSym=' N',missing=True)) res.append(Atom(atomName=' CA ',resName=resname,elemSym=' C',missing=True)) res.append(Atom(atomName=' C ',resName=resname,elemSym=' C',missing=True)) res.append(Atom(atomName=' O ',resName=resname,elemSym=' O',missing=True)) seq.append((amino3to1[resname],res)) # Reset the residue res = [] # Store residue numbers resnum = int(line[22:26]) # Store the atom number atomnum = 1 # Make sure current residue name is set curres = line[17:20] ''' if self.debug: print("Line:",line) ''' # Check to make sure the right atom is being stored if atomnum == 1: if atomname != ' N ': atom = Atom(atomName=' N ',resName=curres,elemSym=' N',missing=True) res.append(atom) atomnum += 1 if atomnum == 2: if atomname != ' CA ': atom = Atom(atomName=' CA ',resName=curres,elemSym=' C',missing=True) res.append(atom) atomnum += 1 if atomnum == 3: if atomname != ' C ': atom = Atom(atomName=' C ',resName=curres,elemSym=' C',missing=True) res.append(atom) atomnum += 1 if atomnum == 4: if atomname != ' O ': atom = Atom(atomName=' O ',resName=curres,elemSym=' O',missing=True) res.append(atom) atomnum += 1 continue if atomnum > 4: continue # Store off the atom information if valid atom = Atom( atomName=atomname, altLoc=line[16], resName=line[17:20], chainId=line[21], codeForInsertion=line[26], xcoord=float(line[30:38]), ycoord=float(line[38:46]), zcoord=float(line[46:54]), occ=float(line[54:60]), temp=float(line[60:66]), elemSym=line[76:78], charge=line[78:80] ) # And add it to the residue (in the proper order) res.append(atom) atomnum += 1 # Add the final residue to the sequence seq.append((amino3to1[curres],res)) # Sequence has been pulled out if self.debug: output = [] for s in seq: output.append(s[0]) print(''.join(output)) i = 0 # template j = 0 # seq targetseq = [] # final sequence if self.debug: print("%4s%4s%10s%10s%10s" % ("i","j","TARGET","TEMPLATE","PDB")) while i < len(template) and j < len(seq): if self.debug: print("%4d%4d%10s%10s%10s" % (i,j,target[i],template[i],seq[j][0])) # Template has a blank # Fill in blank data for that residue if '-' == template[i]: resname = amino1to3[target[i]] res = [] res.append(Atom(atomName=' N ',resName=resname,elemSym=' N',missing=True)) res.append(Atom(atomName=' CA ',resName=resname,elemSym=' C',missing=True)) res.append(Atom(atomName=' C ',resName=resname,elemSym=' C',missing=True)) res.append(Atom(atomName=' O ',resName=resname,elemSym=' O',missing=True)) targetseq.append(res) i += 1 if '-' == seq[j][0]: j += 1 continue # Target has a blank # Skip that line if '-' == target[i]: i += 1 j += 1 continue # PDB doesn't match template sequence ERROR if seq[j][0] != '-' and template[i] != seq[j][0]: print("Template doesn't match PDB: (%04d)%c - (%04d)%c" % (i,template[i],j,seq[j][0])) # Everything lines up! # Copy over the data resname = amino1to3[target[i]] res = [] # Take the atoms from the residue and swap residue names for atom in seq[j][1]: if not atom.missing: a = copy.copy(atom) a.resName = resname res.append(a) # Append it to the list and increment counters targetseq.append(res) i += 1 j += 1 # Time to make the PDB lines = [] lines.append("REMARK Template for target %s\n" % (self.pid)) residues_needed_for_loop_modelling = [] residues_needed_for_loop_modelling.append("Loops needed for target %s\n" % (self.pid)) i_atom = 0 i_residue = 0 last_residue_for_loop_modelling = 0 for res in targetseq: i_residue += 1 for atom in res: i_atom += 1 if atom.missing: if (last_residue_for_loop_modelling!=i_residue): residues_needed_for_loop_modelling.append("%i, " % i_residue) last_residue_for_loop_modelling = i_residue # we need to not have chain id's/have non-zero locations so modeller can do loop modelling if (modellerCompatibilityMode): atom.xcoord=(i_atom%4)*2.0 # If skipBlanks is True then only print atoms that aren't missing # Otherwise print all atoms if not skipBlanks or not atom.missing: lines.append('ATOM %5d %4s%c%3s %c%4d%c %8.3f%8.3f%8.3f%6.2f%6.2f %2s%2s\n' % ( i_atom,atom.atomName,atom.altLoc,atom.resName,' ',i_residue,atom.codeForInsertion, atom.xcoord,atom.ycoord,atom.zcoord,atom.occ,atom.temp,atom.elemSym,atom.charge )) '''blank character replaces atom.chainId'''
def unit_test(): import Atom Atom.unit_test() import PeakAssignment PeakAssignment.unit_test() import CrossPeak CrossPeak.unit_test() import CrossPeakList CrossPeakList.unit_test() import CrossPeakInfo CrossPeakInfo.unit_test() import Resonance Resonance.unit_test() import ResonanceList ResonanceList.unit_test() import DistanceRestraint DistanceRestraint.unit_test() import NoeStrip NoeStrip.unit_test() s=''' # Number of dimensions 3 #FILENAME resort_c-ali #FORMAT xeasy3D #INAME 1 c #INAME 2 H #INAME 3 h #CYANAFORMAT cHh #TOLERANCE 0.3 0.04 0.03 1 40.932 4.805 0.522 1 U 2.114E+05 0.000E+00 e 0 5 45.226 6.787 2.695 1 U 1.161E+05 0.000E+00 e 0 6 40.719 1.831 1.764 1 U 1.355E+06 0.000E+00 e 0 7 40.847 0.934 1.743 1 U 1.674E+05 0.000E+00 e 0 ''' r=''' 1 1.794 0.040 HA 4 MET M 2 1.75 0.040 HB2 4 MET M 3 1.79 0.040 HB3 4 MET M 4 1.919 0.040 QE 4 MET M 7 0.525 0.040 QG 4 MET M 9 175.642 0.400 C 5 MET M 10 54.943 0.400 CA 5 MET M 11 40.407 0.400 CB 4 MET M 12 16.931 0.400 CE 4 MET M 13 40.943 0.400 CG 4 MET M 14 4.8 0.4 H 12 LEU L ''' from StringIO import StringIO rl=ResonanceList.ResonanceList.read_from_stream(StringIO(r)) cl=CrossPeakList.CrossPeakList.read_from_stream(StringIO(s)) cl.assign_resonances( rl ) print cl for c in cl._peaks: print c print rl
def startpressed(self): if self.grapher==1: for x in range(len(self.graph)): if self.graph[x]!=0: self.graph[x].destroy() self.grapher=0 self.root.update() a=self.var1.get() if self.pressed==1: try: self.b=int(self.changer0.get('1.0','end-1c')) except (AttributeError,TclError,ValueError): self.b=10 try: self.c=self.changer2.get('1.0','end-1c') except (AttributeError,TclError,ValueError): self.c=1 if a=='Marriage': self.run0=Marriage(self.b) self.run0.DEBUG=False self.run0.sim() elif a=='Atom': self.c=float(self.c) self.run1=Atom(self.c,self.b) self.run1.DEBUG=False self.run1.sim() elif a=='BubbleGum': self.run2=BubbleGum(self.b) self.run2.DEBUG=False self.run2.sim() self.grapher=1 self.graph=[0,0] g=str(round(self.run2.getrel()[0],4)) h=str(round(self.run2.getrel()[1],4)) self.graph[0]=Label(self.root,bg='white',text='Durchschnitt Karten zu viel: '+g,font=('calibri',19)) self.graph[0].place(x=10,y=450) self.graph[1]=Label(self.root,bg='white',text='Durchschnitt dass es passiert: '+h,font=('calibri',19)) self.graph[1].place(x=10,y=500) elif a=='House_of_Cards': if self.c=='': self.c=0 else: self.c=int(self.c) self.run3=House_of_Cards(self.b,self.c) self.run3.DEBUG=False self.run3.sim() self.grapher=1 self.graph=[0] self.graph[0]=Label(self.root,bg='white',text=('Durchschnitt: '+str(round(self.run3.getrel(),4))),font=('calibri',19)) self.graph[0].place(x=10,y=450) elif a=='Lotto': self.run4=Lotto(self.b) self.run4.DEBUG=False self.run4.sim() x=4 y=1 count=0 self.graph=[0,0,0,0] self.grapher=1 self.graph[0]=Label(self.root,bg='black') self.graph[0].place(x=10,width=10+(int(self.x)*0.8),height=1,y=int(self.y)-int(self.y)/4*0.5-350) self.graph[1]=Label(self.root,text='50%',bg='white',font=('calibri',10)) self.graph[1].place(x=60+(int(self.x)*0.8),width=50,height=50,y=int(self.y)-int(self.y)/4*0.5-375) self.graph[2]=Label(self.root,bg='black') self.graph[2].place(x=10,width=20,height=1,y=int(self.y)-350) self.graph[3]=Label(self.root,bg='black') self.graph[3].place(x=10,width=20,height=1,y=int(self.y)-int(self.y)/4-350) for draw in self.run4.turns: if draw.count(0) == 0: count += 1 elif draw.count(1) == 0: count += 1 elif draw.count(2) == 0: count += 1 elif draw.count(3) == 0: count += 1 elif draw.count(4) == 0: count += 1 elif draw.count(5) == 0: count += 1 self.graph+=[0] self.graph[x]=Label(self.root,bg='red') if str(self.c)=='1': self.graph[x].place(x=int(10+(int(self.x)*0.8)*((y-1)/self.b)),width=int(1250/self.b),height=int(self.y)-350-(int(int(self.y)-int(self.y)/4*(count/y)-350)),y=int(int(self.y)-int(self.y)/4*(count/y)-350)) else: self.graph[x].place(x=int(10+(int(self.x)*0.8)*(y/self.b)),width=3,height=3,y=int(int(self.y)-int(self.y)/4*(count/y)-350)) x+=1 y+=1 self.root.update() elif a=='SecretSanta': if self.c=='': self.c=1 else: self.c=int(self.c) self.run5=SecretSanta(self.b,self.c) self.run5.DEBUG=False self.run5.sim() self.grapher=1 self.graph=[0] self.graph[0]=Label(self.root,bg='white',text=('Durchschnitt: '+str(round(self.run5.getrel(),4))),font=('calibri',19)) self.graph[0].place(x=10,y=450) elif a=='Coins': self.run6=Coins(self.b) self.run6.sim() self.grapher=1 self.graph=[0,0] v=self.run6.geterg() vv=self.run6.getrel() self.graph[0]=Label(self.root,bg='white',text=('Statistik für www: '+str(v[0])+' '+str(vv[0])),font=('calibri',19)) self.graph[0].place(x=10,y=450) self.graph[1]=Label(self.root,bg='white',text=('Statistik für zwz: '+str(v[1])+' '+str(vv[1])),font=('calibri',19)) self.graph[1].place(x=10,y=500)