Changeset 4400
- Timestamp:
- Apr 13, 2020 5:06:27 PM (4 years ago)
- Location:
- trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/GSASIIconstrGUI.py
r4399 r4400 41 41 import GSASIIpy3 as G2py3 42 42 VERY_LIGHT_GREY = wx.Colour(235,235,235) 43 WACV = wx.ALIGN_CENTER_VERTICAL 43 44 44 45 class ConstraintDialog(wx.Dialog): … … 1567 1568 G2frame.Bind(wx.EVT_MENU, AddResidueRB, id=G2G.wxID_RIGIDBODYADD) 1568 1569 G2frame.Bind(wx.EVT_MENU, OnImportRigidBody, id=G2G.wxID_RIGIDBODYIMPORT) 1570 G2frame.Bind(wx.EVT_MENU, OnSaveRigidBody, id=G2G.wxID_RIGIDBODYSAVE) 1569 1571 G2frame.Bind(wx.EVT_MENU, OnDefineTorsSeq, id=G2G.wxID_RESIDUETORSSEQ) #enable only if residue RBs exist? 1570 1572 G2frame.Page = [page,'rrb'] … … 1616 1618 elif 'Residue' in G2frame.rbBook.GetPageText(page): 1617 1619 ImportResidueRB() 1620 1621 def OnSaveRigidBody(event): 1622 page = G2frame.rbBook.GetSelection() 1623 if 'Vector' in G2frame.rbBook.GetPageText(page): 1624 pass 1625 elif 'Residue' in G2frame.rbBook.GetPageText(page): 1626 SaveResidueRB() 1618 1627 1619 1628 def AddVectorRB(event): … … 1704 1713 while 'ATOM' not in txtStr[:6] and 'HETATM' not in txtStr[:6]: 1705 1714 txtStr = text.readline() 1706 #print txtStr1707 1715 items = txtStr.split() 1716 nat = 1 1708 1717 while len(items): 1709 1718 if 'txt' in ext: … … 1714 1723 atType = items[0] 1715 1724 rbXYZ.append([float(items[i]) for i in [1,2,3]]) 1716 atName = atType+str(len(rbXYZ))1725 atName = '%s%d'%(atType,nat) 1717 1726 elif 'mol2' in ext: 1718 1727 atType = items[1] … … 1721 1730 elif 'pdb' in ext: 1722 1731 atType = items[-1] 1723 atName = items[2] 1732 if not items[2][-1].isnumeric(): 1733 atName = '%s%d'%(items[2],nat) 1734 else: 1735 atName = '5s'%items[2] 1724 1736 xyz = txtStr[30:55].split() 1725 1737 rbXYZ.append([float(x) for x in xyz]) … … 1735 1747 break 1736 1748 items = txtStr.split() 1749 nat += 1 1737 1750 if len(atNames) < 3: 1738 1751 G2G.G2MessageBox(G2frame,'Not enough atoms in rigid body; must be 3 or more') … … 1751 1764 text.close() 1752 1765 UpdateResidueRB() 1766 1767 def SaveResidueRB(): 1768 global rbId 1769 pth = G2G.GetExportPath(G2frame) 1770 dlg = wx.FileDialog(G2frame, 'Choose PDB file for Atom XYZ', pth, '', 1771 'PDB files (*.pdb)|*.pdb',wx.FD_SAVE|wx.FD_OVERWRITE_PROMPT) 1772 try: 1773 if dlg.ShowModal() == wx.ID_OK: 1774 filename = dlg.GetPath() 1775 # make sure extension is .pkslst 1776 filename = os.path.splitext(filename)[0]+'.pdb' 1777 File = open(filename,'w') 1778 rbData = data['Residue'][rbId] 1779 for iat,xyz in enumerate(rbData['rbXYZ']): 1780 File.write('ATOM %6d %-4s%3s 1 %8.3f%8.3f%8.3f 1.00 0.00 %2s\n'%( 1781 iat,rbData['atNames'][iat],rbData['RBname'][:3],xyz[0],xyz[1],xyz[2],rbData['rbTypes'][iat])) 1782 File.close() 1783 print ('Atom XYZ saved to: '+filename) 1784 finally: 1785 dlg.Destroy() 1786 1753 1787 1754 1788 def FindNeighbors(Orig,XYZ,atTypes,atNames,AtInfo): … … 2037 2071 def rbNameSizer(rbId,rbData): 2038 2072 2039 def OnRBName(event):2040 Obj = event.GetEventObject()2041 rbData['RBname'] = Obj.GetValue()2042 wx.CallAfter(UpdateResidueRB)2043 2044 2073 def OnDelRB(event): 2045 2074 Obj = event.GetEventObject() … … 2077 2106 nameSizer.Add(wx.StaticText(ResidueRBDisplay,-1,'Residue name: '), 2078 2107 0,wx.ALIGN_CENTER_VERTICAL) 2079 RBname = wx.TextCtrl(ResidueRBDisplay,-1,rbData['RBname']) 2080 Indx[RBname.GetId()] = rbId 2081 RBname.Bind(wx.EVT_TEXT_ENTER,OnRBName) 2082 RBname.Bind(wx.EVT_KILL_FOCUS,OnRBName) 2083 nameSizer.Add(RBname,0,wx.ALIGN_CENTER_VERTICAL) 2108 nameSizer.Add(G2G.ValidatedTxtCtrl(ResidueRBDisplay,rbData,'RBname'),0,WACV) 2084 2109 nameSizer.Add((5,0),) 2085 2110 plotRB = wx.CheckBox(ResidueRBDisplay,-1,'Plot?') -
trunk/GSASIIdataGUI.py
r4399 r4400 5323 5323 # Rigid bodies 5324 5324 G2G.Define_wxId('wxID_RIGIDBODYADD', 'wxID_DRAWDEFINERB', 'wxID_RIGIDBODYIMPORT', 'wxID_RESIDUETORSSEQ', 5325 'wxID_VECTORBODYADD' )5325 'wxID_VECTORBODYADD', 'wxID_RIGIDBODYSAVE',) 5326 5326 self.RigidBodyMenu = wx.MenuBar() 5327 5327 self.PrefillDataMenu(self.RigidBodyMenu) 5328 5328 self.ResidueRBMenu = wx.Menu(title='') 5329 5329 self.ResidueRBMenu.Append(G2G.wxID_RIGIDBODYIMPORT,'Import XYZ','Import rigid body XYZ from file') 5330 self.ResidueRBMenu.Append(G2G.wxID_RIGIDBODYSAVE,'Save PDB','Save rigid body to PDB file') 5330 5331 self.ResidueRBMenu.Append(G2G.wxID_RESIDUETORSSEQ,'Define sequence','Define torsion sequence') 5331 5332 self.ResidueRBMenu.Append(G2G.wxID_RIGIDBODYADD,'Import residues','Import residue rigid bodies from macro file') -
trunk/GSASIIphsGUI.py
r4399 r4400 89 89 if '2' in platform.python_version_tuple()[0]: 90 90 GkDelta = unichr(0x0394) 91 Angstr = unichr(0x00c5) 91 92 else: 92 93 GkDelta = chr(0x0394) 94 Angstr = chr(0x00c5) 93 95 ################################################################################ 94 96 #### phase class definitions … … 4431 4433 mainSizer.Add((5,5),0,WACV) 4432 4434 if G2frame.RMCchoice == 'fullrmc': 4433 #try:4434 # from fullrmc import Engine4435 #except ModuleNotFoundError:4436 #wx.MessageBox(''' fullrmc is not correctly installed for use in GSAS-II4437 #Install it in your python according to the instructions in4438 #https://bachiraoun.github.io/fullrmc/index.html. ''',4439 #caption='fullrmc not installed',style=wx.ICON_INFORMATION)4440 #return4435 try: 4436 import fullrmc 4437 except ModuleNotFoundError: 4438 wx.MessageBox(''' fullrmc is not correctly installed for use in GSAS-II 4439 Install it in your python according to the instructions in 4440 https://bachiraoun.github.io/fullrmc/index.html. ''', 4441 caption='fullrmc not installed',style=wx.ICON_INFORMATION) 4442 return 4441 4443 mainSizer.Add(wx.StaticText(G2frame.FRMC,label=''' "Fullrmc, a Rigid Body Reverse Monte Carlo Modeling Package Enabled with Machine Learning and Artificial Intelligence", 4442 4444 B. Aoun, Jour. Comp. Chem. 2016, 37, 1102-1111. doi: https://doi.org/10.1002/jcc.24304 … … 4462 4464 data['RMC']['fullrmc'] = {'ifBox':True,'SuperCell':[1,1,1],'Box':[10.,10.,10.],'aTypes':aTypes, 4463 4465 'atSeq':atSeq,'Pairs':Pairs,'files':files,'ReStart':[False,False],'Swaps':[],'useBVS':False, 4464 'AveCN':[],'FxCN':[], }4466 'AveCN':[],'FxCN':[],'moleculePdb':'Select','targetDensity':1.0,'maxRecursion':10000} 4465 4467 RMCPdict = data['RMC']['fullrmc'] 4466 4468 … … 4489 4491 def OnReStart(event): 4490 4492 RMCPdict['ReStart'][0] = not RMCPdict['ReStart'][0] 4493 4494 def OnPdbButton(event): 4495 dlg = wx.FileDialog(G2frame.FRMC, 'Choose molecule pdb file',G2frame.LastGPXdir, 4496 style=wx.FD_OPEN ,wildcard='PDB file(*.pdb)|*.pdb') 4497 if dlg.ShowModal() == wx.ID_OK: 4498 fpath,fName = os.path.split(dlg.GetPath()) 4499 RMCPdict['moleculePdb'] = fName 4500 pdbButton.SetLabel(fName) 4501 4502 def OnMakePDB(event): 4503 dlg = wx.MessageDialog(G2frame,''' 4504 Warning - this step can take more than an hour; do you want to proceed? 4505 It will be run as a separate process, and a result is required for fullrmc. 4506 Make sure your parameters are correctly set. 4507 ''','Make big box pdb file',wx.YES_NO|wx.ICON_QUESTION) 4508 try: 4509 result = dlg.ShowModal() 4510 if result in [wx.ID_YES,]: 4511 pdpy = G2pwd.MakePdparse(RMCPdict) 4512 import subprocess as sb 4513 batch = open('pdbparse.bat','w') 4514 batch.write('CALL '+sys.exec_prefix+'\\Scripts\\activate\n') 4515 batch.write(sys.exec_prefix+'\\python.exe %s\n'%pdpy) 4516 batch.write('pause') 4517 batch.close() 4518 sb.Popen('pdbparse.bat',creationflags=sb.CREATE_NEW_CONSOLE).pid 4519 else: 4520 print(' Make PDB file for fullrmc abandonded') 4521 finally: 4522 dlg.Destroy() 4523 4491 4524 #patches 4492 4525 if 'useBVS' not in RMCPdict: 4493 4526 RMCPdict['useBVS'] = False 4527 if 'moleculePdb' not in RMCPdict: 4528 RMCPdict.update({'moleculePdb':'Select','targetDensity':1.0,'maxRecursion':10000}) 4494 4529 #end patches 4495 4530 restart = wx.CheckBox(G2frame.FRMC,label=' Restart fullrmc Engine? (will clear old result!) ') … … 4500 4535 lineSizer = wx.BoxSizer(wx.HORIZONTAL) 4501 4536 if RMCPdict['ifBox']: 4502 lineSizer.Add(wx.StaticText(G2frame.FRMC,label=' Big box dimensions :'),0,WACV)4537 lineSizer.Add(wx.StaticText(G2frame.FRMC,label=' Big box dimensions, %s:'%Angstr),0,WACV) 4503 4538 lineSizer.Add(GetBoxSizer(),0,WACV) 4504 4539 boxBtn = wx.Button(G2frame.FRMC,label='Use super lattice') … … 4510 4545 lineSizer.Add(boxBtn,0,WACV) 4511 4546 mainSizer.Add(lineSizer,0,WACV) 4512 4547 if RMCPdict['ifBox']: 4548 molecSizer = wx.BoxSizer(wx.HORIZONTAL) 4549 molecSizer.Add(wx.StaticText(G2frame.FRMC,label=' Source molecule file '),0,WACV) 4550 pdbButton = wx.Button(G2frame.FRMC,label=RMCPdict['moleculePdb']) 4551 pdbButton.Bind(wx.EVT_BUTTON,OnPdbButton) 4552 molecSizer.Add(pdbButton,0,WACV) 4553 molecSizer.Add(wx.StaticText(G2frame.FRMC,label=' target density, gm/cc '),0,WACV) 4554 molecSizer.Add(G2G.ValidatedTxtCtrl(G2frame.FRMC,RMCPdict,'targetDensity',min=0.1,size=[60,25]),0,WACV) 4555 molecSizer.Add(wx.StaticText(G2frame.FRMC,label=' max tries '),0,WACV) 4556 molecSizer.Add(G2G.ValidatedTxtCtrl(G2frame.FRMC,RMCPdict,'maxRecursion',min=1000,max=1000000,size=[60,25]),0,WACV) 4557 makePDB = wx.Button(G2frame.FRMC,label='Make big box PDB (slow!)') 4558 makePDB.Bind(wx.EVT_BUTTON,OnMakePDB) 4559 molecSizer.Add(makePDB,0,WACV) 4560 mainSizer.Add(molecSizer,0,WACV) 4561 4513 4562 mainSizer.Add(GetAtmChoice(RMCPdict),0,WACV) 4514 4563 … … 5029 5078 else: 5030 5079 print(G2pwd.MakefullrmcPDB(pName,data,RMCPdict)+ ' written') 5031 #print(G2pwd.MakefullrmcRun(pName,data,RMCPdict)+ ' written')5032 5080 print('fullrmc file build completed') 5033 5081 else: -
trunk/GSASIIpwd.py
r4397 r4400 2539 2539 return fname 2540 2540 2541 def MakepdparserPDB(Name,Phase,RMCPdict): 2542 import pdbparser as pdp 2543 fname = Name+'.pdb' 2541 def MakePdparse(RMCPdict): 2542 fname = 'make_pdb.py' 2543 outName = RMCPdict['moleculePdb'].split('.') 2544 outName[0] += 'bb' 2545 outName = '.'.join(outName) 2544 2546 fl = open(fname,'w') 2545 fl.write('REMARK this file to be generated using pdbparser\n') 2546 fl.close() 2547 fl.write('from pdbparser.pdbparser import pdbparser\n') 2548 fl.write('from pdbparser.Utilities.Construct import AmorphousSystem\n') 2549 fl.write("pdb = pdbparser('%s')\n"%RMCPdict['moleculePdb']) 2550 boxstr= 'boxsize=%s'%str(RMCPdict['Box']) 2551 recstr = 'recursionLimit=%d'%RMCPdict['maxRecursion'] 2552 denstr = 'density=%.3f'%RMCPdict['targetDensity'] 2553 fl.write('pdb = AmorphousSystem(pdb,%s,%s,%s,\n'%(boxstr,recstr,denstr)) 2554 fl.write(' priorities={"boxSize":True, "insertionNumber":False, "density":True}).construct().get_pdb()\n') 2555 fl.write('pdb.export_pdb("%s")\n'%outName) 2556 fl.close 2547 2557 return fname 2548 2558
Note: See TracChangeset
for help on using the changeset viewer.