Changeset 2840


Ignore:
Timestamp:
May 27, 2017 11:20:45 AM (6 years ago)
Author:
vondreele
Message:

fix PDB importer & reimport atoms
rework RB GUI - now shows just one residue at a time & structure plot follows selection
also RB parameter changes show on structure drawing
add protein validator - not complete
remove commented out dead code from GSAIIgrid
fix bug if cancel of macro restraints selection

Location:
trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIddataGUI.py

    r2752 r2840  
    871871        useData.SetValue(UseList[G2frame.hist]['Use'])
    872872        useBox.Add(useData,0,WACV)
    873         if not generalData['doPawley']:
     873        if not generalData['doPawley'] and 'PWDR' in G2frame.hist[:4]:
    874874            lebail = wx.CheckBox(DData,wx.ID_ANY,label='Do LeBail extraction?')
    875875            lebail.Bind(wx.EVT_CHECKBOX, OnLeBail)
  • trunk/GSASIIgrid.py

    r2825 r2840  
    6868    wxID_RELOADDRAWATOMS,wxID_ATOMSDISAGL,wxID_ATOMMOVE,wxID_MAKEMOLECULE,
    6969    wxID_ASSIGNATMS2RB,wxID_ATOMSPDISAGL, wxID_ISODISP,wxID_ADDHATOM,wxID_UPDATEHATOM,
    70     wxID_WAVEVARY,wxID_ATOMSROTATE, wxID_ATOMSDENSITY,
     70    wxID_WAVEVARY,wxID_ATOMSROTATE, wxID_ATOMSDENSITY, wxID_VALIDPROTEIN,
    7171    wxID_ATOMSSETALL, wxID_ATOMSSETSEL,
    72 ] = [wx.NewId() for item in range(21)]
     72] = [wx.NewId() for item in range(22)]
    7373
    7474[ wxID_DRAWATOMSTYLE, wxID_DRAWATOMLABEL, wxID_DRAWATOMCOLOR, wxID_DRAWATOMRESETCOLOR,
     
    24432443        self.AtomCompute.Append(id=wxID_ATOMSPDISAGL, kind=wx.ITEM_NORMAL,text='Save Distances && Angles',
    24442444            help='Compute distances & angles for selected atoms')
    2445         self.AtomCompute.ISOcalc = self.AtomCompute.Append(
    2446             id=wxID_ISODISP, kind=wx.ITEM_NORMAL,
    2447             text='ISODISTORT mode values',
    2448             help='Compute values of ISODISTORT modes from atom parameters')
    24492445        self.AtomCompute.Append(id=wxID_ATOMSDENSITY, kind=wx.ITEM_NORMAL,
    2450             text='Density',
    2451             help='Compute density for current phase')
     2446            text='Density',help='Compute density for current phase')
     2447        self.AtomCompute.Append(id=wxID_VALIDPROTEIN, kind=wx.ITEM_NORMAL,
     2448            text='Protein quality',help='Protein quality analysis')
     2449        self.AtomCompute.ISOcalc = self.AtomCompute.Append(id=wxID_ISODISP, kind=wx.ITEM_NORMAL,
     2450            text='ISODISTORT mode values',help='Compute values of ISODISTORT modes from atom parameters')
     2451       
    24522452        self.PostfillDataMenu()
    24532453       
     
    28662866            wx.CallAfter(UpdateControls,G2frame,data)
    28672867           
    2868 #        def OnConvergence(event):
    2869 #            event.Skip()
    2870 #            try:
    2871 #                value = max(1.e-9,min(1.0,float(Cnvrg.GetValue())))
    2872 #            except ValueError:
    2873 #                value = 0.0001
    2874 #            data['min dM/M'] = value
    2875 #            Cnvrg.SetValue('%.2g'%(value))
    2876 #           
    28772868        def OnMaxCycles(event):
    28782869            data['max cyc'] = int(maxCyc.GetValue())
     
    28952886            data['F**2'] = fsqRef.GetValue()
    28962887           
    2897 #        def OnHatomFix(event):
    2898 #            data['HatomFix'] = Hfix.GetValue()
    2899        
    2900 #        def OnUsrRej(event):
    2901 #            event.Skip()
    2902 #            Obj = event.GetEventObject()
    2903 #            item,limits = Indx[Obj]
    2904 #            try:
    2905 #                value = min(max(float(Obj.GetValue()),limits[0]),limits[1])
    2906 #            except ValueError:
    2907 #                value = data['UsrReject'][item]
    2908 #            data['UsrReject'][item] = value
    2909 #            Obj.SetValue('%.2f'%(value))
    2910 #
    29112888        LSSizer = wx.FlexGridSizer(cols=4,vgap=5,hgap=5)
    29122889        LSSizer.Add(wx.StaticText(G2frame.dataDisplay,label=' Refinement derivatives: '),0,WACV)
    2913         Choice=['analytic Jacobian','numeric','analytic Hessian']
     2890        Choice=['analytic Jacobian','numeric','analytic Hessian']   #TODO +'SVD refine' - what flags will it need?
    29142891        derivSel = wx.ComboBox(parent=G2frame.dataDisplay,value=data['deriv type'],choices=Choice,
    29152892            style=wx.CB_READONLY|wx.CB_DROPDOWN)
     
    29202897        LSSizer.Add(wx.StaticText(G2frame.dataDisplay,label=' Min delta-M/M: '),0,WACV)
    29212898        Cnvrg = G2G.ValidatedTxtCtrl(G2frame.dataDisplay,data,'min dM/M',nDig=(10,2,'g'),min=1.e-9,max=1.,typeHint=float)
    2922 #        Cnvrg = wx.TextCtrl(G2frame.dataDisplay,-1,value='%.2g'%(data['min dM/M']),style=wx.TE_PROCESS_ENTER)
    2923 #        Cnvrg.Bind(wx.EVT_TEXT_ENTER,OnConvergence)
    2924 #        Cnvrg.Bind(wx.EVT_KILL_FOCUS,OnConvergence)
    29252899        LSSizer.Add(Cnvrg,0,WACV)
    2926 #        Indx = {}
    29272900        if 'Hessian' in data['deriv type']:
    29282901            LSSizer.Add(wx.StaticText(G2frame.dataDisplay,label=' Max cycles: '),0,WACV)
     
    29302903            maxCyc = wx.ComboBox(parent=G2frame.dataDisplay,value=str(data['max cyc']),choices=Choice,
    29312904                style=wx.CB_READONLY|wx.CB_DROPDOWN)
    2932 #            maxCyc.SetValue(str(data['max cyc']))
    29332905            maxCyc.Bind(wx.EVT_COMBOBOX, OnMaxCycles)
    29342906            LSSizer.Add(maxCyc,0,WACV)
     
    29392911            marqLam.Bind(wx.EVT_COMBOBOX,OnMarqLam)
    29402912            LSSizer.Add(marqLam,0,WACV)
    2941         else:
     2913        else:       #TODO what for SVD refine?
    29422914            LSSizer.Add(wx.StaticText(G2frame.dataDisplay,label=' Initial shift factor: '),0,WACV)
    29432915            Factr = G2G.ValidatedTxtCtrl(G2frame.dataDisplay,data,'shift factor',nDig=(10,5),min=1.e-5,max=100.,typeHint=float)
    2944 #            Factr = wx.TextCtrl(G2frame.dataDisplay,-1,value='%.5f'%(data['shift factor']),style=wx.TE_PROCESS_ENTER)
    2945 #            Factr.Bind(wx.EVT_TEXT_ENTER,OnFactor)
    2946 #            Factr.Bind(wx.EVT_KILL_FOCUS,OnFactor)
    29472916            LSSizer.Add(Factr,0,WACV)
    29482917        if G2frame.Sngl:
     
    29612930                usrrej = G2G.ValidatedTxtCtrl(G2frame.dataDisplay,userReject,item,nDig=(10,2),
    29622931                    min=usrRej[item][1][0],max=usrRej[item][1][1],typeHint=float)
    2963 #                usrrej = wx.TextCtrl(G2frame.dataDisplay,-1,value='%.2f'%(userReject[item]),style=wx.TE_PROCESS_ENTER)
    2964 #                Indx[usrrej] = [item,usrRej[item][1]]
    2965 #                usrrej.Bind(wx.EVT_TEXT_ENTER,OnUsrRej)
    2966 #                usrrej.Bind(wx.EVT_KILL_FOCUS,OnUsrRej)
    29672932                LSSizer.Add(usrrej,0,WACV)
    2968 #        Hfix = wx.CheckBox(G2frame.dataDisplay,-1,label='Regularize H atoms? ')
    2969 #        Hfix.SetValue(data['HatomFix'])
    2970 #        Hfix.Bind(wx.EVT_CHECKBOX,OnHatomFix)
    2971 #        LSSizer.Add(Hfix,0,WACV)   #for now
    29722933        return LSSizer
    29732934       
     
    45184479        mainSizer.Add(wx.StaticText(G2frame.dataDisplay,-1,
    45194480            ' Data residual wR: %.3f%% on %d observations'%(data[0]['wR'],data[0]['Nobs'])))
    4520         mainSizer.Add(wx.StaticText(G2frame.dataDisplay,-1,
    4521             ' Durbin-Watson statistic: %.3f'%(data[0].get('Durbin-Watson',0.))))
     4481        if kind == 'PWDR':
     4482            mainSizer.Add(wx.StaticText(G2frame.dataDisplay,-1,
     4483                ' Durbin-Watson statistic: %.3f'%(data[0].get('Durbin-Watson',0.))))
    45224484        for value in data[0]:
    45234485            if 'Nref' in value:
  • trunk/GSASIImath.py

    r2839 r2840  
    23942394        out += ("e{:d}").format(valoff) # add an exponent, when needed
    23952395    return out
     2396   
     2397###############################################################################
     2398##### Protein validation - "ERRATV2" analysis
     2399###############################################################################
     2400
     2401    def validProtein(Phase):
     2402        resNames = ['ALA','ARG','ASN','ASP','CYS','GLN','GLU','GLY','HIS','ILE',
     2403            'LEU','LYS','MET','PHE','PRO','SER','THR','TRP','TYR','VAL','MSE']
     2404        print 'Do VALIDPROTEIN analysis - TBD'
     2405        General = Phase['General']
     2406        Amat,Bmat = G2lat.cell2AB(General['Cell'][1:7])
     2407        cx,ct,cs,cia = General['AtomPtrs']
     2408        Atoms = Phase['Atoms']
     2409        cartAtoms = []
     2410        chains = []
     2411        for atom in Atoms:
     2412            if atom[2] in resNames:
     2413                cartAtoms.append(atom[:cx+3])
     2414                if atom[2] not in chains:
     2415                    chains.append(atom[2])
     2416                cartAtoms[-1][cx:cx+3] = np.inner(Amat,cartAtoms[-1][cx:cx+3])
     2417           
    23962418   
    23972419################################################################################
  • trunk/GSASIIphsGUI.py

    r2834 r2840  
    25122512        print(msg)
    25132513        G2G.G2MessageBox(G2frame.dataFrame,msg,'Density')
     2514       
     2515    def OnValidProtein(event):
     2516        G2mth.validProtein(data)
    25142517
    25152518    def OnSetAll(event):
     
    27682771            try:
    27692772                idx = atomNames.index(''.join(atom[:ct+1]).capitalize())  #eliminate spurious differences
    2770                 atId = atom[cia+8]
    2771                 atomData[idx][:-1] = atom[:-1]
    2772                 atomData[idx][cia+8] = atId
     2773                atId = atomData[idx][cia+8]                                 #save old Id
     2774                atomData[idx][:cia+8] = atom[:cia+8]+[atId,]
    27732775            except ValueError:
    27742776                if All:
     
    60096011                         
    60106012        def ResrbSizer(RBObj):
    6011             G2frame.dataFrame.SetStatusText('NB: Rotation vector is in crystallographic space')
    6012              
     6013           
    60136014            def OnTorsionRef(event):
    60146015                Obj = event.GetEventObject()
     
    61276128            return vecrbSizer               
    61286129       
     6130        def OnSelect(event):
     6131            rbId = select.GetSelection()
     6132            wx.CallLater(100,RepaintRBInfo,rbId)
     6133           
     6134        def RepaintRBInfo(rbId,Scroll=0):
     6135            oldFocus = wx.Window.FindFocus()
     6136            G2frame.bottomSizer.DeleteWindows()
     6137            Indx.clear()
     6138            rbObj = data['RBModels']['Residue'][rbId]
     6139            data['Drawing']['viewPoint'][0] = rbObj['Orig'][0]
     6140            G2frame.bottomSizer =  ResrbSizer(rbObj)
     6141            mainSizer.Add(G2frame.bottomSizer)
     6142            mainSizer.Layout()
     6143            G2frame.dataFrame.Refresh()
     6144            RigidBodies.SetVirtualSize(mainSizer.GetMinSize())
     6145            RigidBodies.Scroll(0,Scroll)
     6146            G2frame.dataFrame.SendSizeEvent()
     6147            wx.CallAfter(G2plt.PlotStructure,G2frame,data)
     6148            oldFocus.SetFocus()
     6149       
    61296150        # FillRigidBodyGrid executable code starts here
    61306151        if refresh:
     
    61506171            mainSizer.Add(wx.StaticText(RigidBodies,-1,'No rigid body models:'),0,WACV)
    61516172            mainSizer.Add((5,5),0)
    6152         if 'Residue' in data['RBModels']:
     6173        if 'Residue' in data['RBModels'] and len(data['RBModels']['Residue']):
    61536174            mainSizer.Add((5,5),0)
    61546175            mainSizer.Add(wx.StaticText(RigidBodies,-1,'Residue rigid bodies:'),0,WACV)
    61556176            mainSizer.Add((5,5),0)
     6177            RBnames = []
    61566178            for RBObj in data['RBModels']['Residue']:
    6157                 mainSizer.Add(ResrbSizer(RBObj))
    6158         if 'Vector' in data['RBModels']:
     6179                RBnames.append(RBObj['RBname'].split(':')[0]+RBObj['numChain'])
     6180            rbName = RBnames[0]
     6181            rbObj = data['RBModels']['Residue'][0]
     6182            data['Drawing']['viewPoint'][0] = rbObj['Orig'][0]
     6183            select = wx.ListBox(RigidBodies,choices=RBnames,style=wx.LB_SINGLE,size=(-1,120))
     6184            select.SetSelection(RBnames.index(rbName))
     6185            select.SetFirstItem(RBnames.index(rbName))
     6186            select.Bind(wx.EVT_LISTBOX,OnSelect)
     6187            mainSizer.Add(select,0,WACV)
     6188            G2frame.bottomSizer = wx.BoxSizer(wx.VERTICAL)
     6189            G2frame.bottomSizer.Add(ResrbSizer(rbObj))
     6190            mainSizer.Add(G2frame.bottomSizer)
     6191            G2frame.dataFrame.SetStatusText('NB: Rotation vector is in crystallographic space')
     6192            wx.CallAfter(G2plt.PlotStructure,G2frame,data)
     6193        if 'Vector' in data['RBModels'] and len(data['RBModels']['Vector']):
    61596194            mainSizer.Add((5,5),0)
    61606195            mainSizer.Add(wx.StaticText(RigidBodies,-1,'Vector rigid bodies:'),0,WACV)
     
    61936228                RBObjs[x].update(copy.copy(sourceRB))
    61946229        G2plt.PlotStructure(G2frame,data)
    6195         wx.CallAfter(FillRigidBodyGrid(True))
     6230        wx.CallAfter(FillRigidBodyGrid,True)
    61966231               
    61976232    def OnRBAssign(event):
     
    80718106        G2frame.dataFrame.Bind(wx.EVT_MENU, OnDistAngle, id=G2gd.wxID_ATOMSDISAGL)
    80728107        G2frame.dataFrame.Bind(wx.EVT_MENU, OnDistAnglePrt, id=G2gd.wxID_ATOMSPDISAGL)
     8108        G2frame.dataFrame.Bind(wx.EVT_MENU, OnDensity, id=G2gd.wxID_ATOMSDENSITY)
     8109        G2frame.dataFrame.Bind(wx.EVT_MENU, OnValidProtein, id=G2gd.wxID_VALIDPROTEIN)
    80738110        G2frame.dataFrame.Bind(wx.EVT_MENU, OnIsoDistortCalc, id=G2gd.wxID_ISODISP)
    8074         G2frame.dataFrame.Bind(wx.EVT_MENU, OnDensity, id=G2gd.wxID_ATOMSDENSITY)
    80758111        if 'HydIds' in data['General']:
    80768112            G2frame.dataFrame.AtomEdit.Enable(G2gd.wxID_UPDATEHATOM,True)
     
    82308266    G2frame.dataDisplay.AddPage(G2frame.PawleyRefl,'Pawley reflections')
    82318267    Pages.append('Pawley reflections')
    8232     G2frame.dataFrame.AtomCompute.ISOcalc.Enable('ISODISTORT' in data)
     8268    G2frame.dataFrame.AtomCompute.Enable(G2gd.wxID_ISODISP,'ISODISTORT' in data)
     8269    G2frame.dataFrame.AtomCompute.Enable(G2gd.wxID_VALIDPROTEIN,'macro' in data['General']['Type'])
    82338270    G2frame.dataDisplay.Bind(wx.aui.EVT_AUINOTEBOOK_PAGE_CHANGED, OnPageChanged)
    82348271    FillMenus()
  • trunk/GSASIIrestrGUI.py

    r2704 r2840  
    120120            style=wx.OPEN | wx.CHANGE_DIR)
    121121        try:
     122            macro = ''
    122123            if dlg.ShowModal() == wx.ID_OK:
    123124                macfile = dlg.GetPath()
     
    907908                for ibad in bad:
    908909                    del bondList[ibad]
    909             bondTable = G2G.Table(table,rowLabels=rowLabels,colLabels=colLabels,types=Types)
    910             Bonds = G2G.GSGrid(BondRestr)
    911             Bonds.SetTable(bondTable, True)
    912             Bonds.AutoSizeColumns(False)
    913             for r in range(len(bondList)):
    914                 for c in [0,1,4]:
    915                     Bonds.SetReadOnly(r,c,True)
    916                     Bonds.SetCellStyle(r,c,VERY_LIGHT_GREY,True)
    917             Bonds.Bind(wg.EVT_GRID_LABEL_LEFT_CLICK,OnRowSelect)
    918             Bonds.Bind(wg.EVT_GRID_CELL_CHANGE, OnCellChange)
    919             G2frame.dataFrame.Bind(wx.EVT_MENU, OnDeleteRestraint, id=G2gd.wxID_RESTDELETE)
    920             G2frame.dataFrame.Bind(wx.EVT_MENU, OnChangeValue, id=G2gd.wxID_RESRCHANGEVAL)
    921             G2frame.dataFrame.Bind(wx.EVT_MENU, OnChangeEsd, id=G2gd.wxID_RESTCHANGEESD)
    922             mainSizer.Add(wx.StaticText(BondRestr,-1,
    923                 'Bond restraints: sum(wt*(delt/sig)^2) =    %.2f, mean(wt*(delt/sig)^2) =    %.2f'    \
    924                 %(chisq,chisq/len(bondList))),0,wx.ALIGN_CENTER_VERTICAL)
    925             mainSizer.Add(Bonds,0,)
     910            if len(bondList):
     911                bondTable = G2G.Table(table,rowLabels=rowLabels,colLabels=colLabels,types=Types)
     912                Bonds = G2G.GSGrid(BondRestr)
     913                Bonds.SetTable(bondTable, True)
     914                Bonds.AutoSizeColumns(False)
     915                for r in range(len(bondList)):
     916                    for c in [0,1,4]:
     917                        Bonds.SetReadOnly(r,c,True)
     918                        Bonds.SetCellStyle(r,c,VERY_LIGHT_GREY,True)
     919                Bonds.Bind(wg.EVT_GRID_LABEL_LEFT_CLICK,OnRowSelect)
     920                Bonds.Bind(wg.EVT_GRID_CELL_CHANGE, OnCellChange)
     921                G2frame.dataFrame.Bind(wx.EVT_MENU, OnDeleteRestraint, id=G2gd.wxID_RESTDELETE)
     922                G2frame.dataFrame.Bind(wx.EVT_MENU, OnChangeValue, id=G2gd.wxID_RESRCHANGEVAL)
     923                G2frame.dataFrame.Bind(wx.EVT_MENU, OnChangeEsd, id=G2gd.wxID_RESTCHANGEESD)
     924                mainSizer.Add(wx.StaticText(BondRestr,-1,
     925                    'Bond restraints: sum(wt*(delt/sig)^2) =    %.2f, mean(wt*(delt/sig)^2) =    %.2f'    \
     926                    %(chisq,chisq/len(bondList))),0,wx.ALIGN_CENTER_VERTICAL)
     927                mainSizer.Add(Bonds,0,)
     928            else:
     929                mainSizer.Add(wx.StaticText(BondRestr,-1,'No bond distance restraints for this phase'),0,)
    926930        else:
    927931            mainSizer.Add(wx.StaticText(BondRestr,-1,'No bond distance restraints for this phase'),0,)
     
    10361040                for ibad in bad:
    10371041                    del angleList[ibad]
    1038             angleTable = G2G.Table(table,rowLabels=rowLabels,colLabels=colLabels,types=Types)
    1039             Angles = G2G.GSGrid(AngleRestr)
    1040             Angles.SetTable(angleTable, True)
    1041             Angles.AutoSizeColumns(False)
    1042             for r in range(len(angleList)):
    1043                 for c in [0,1,4]:
    1044                     Angles.SetReadOnly(r,c,True)
    1045                     Angles.SetCellStyle(r,c,VERY_LIGHT_GREY,True)
    1046             Angles.Bind(wg.EVT_GRID_LABEL_LEFT_CLICK,OnRowSelect)
    1047             Angles.Bind(wg.EVT_GRID_CELL_CHANGE, OnCellChange)
    1048             G2frame.dataFrame.Bind(wx.EVT_MENU, OnDeleteRestraint, id=G2gd.wxID_RESTDELETE)
    1049             G2frame.dataFrame.Bind(wx.EVT_MENU, OnChangeValue, id=G2gd.wxID_RESRCHANGEVAL)
    1050             G2frame.dataFrame.Bind(wx.EVT_MENU, OnChangeEsd, id=G2gd.wxID_RESTCHANGEESD)
    1051             mainSizer.Add(wx.StaticText(AngleRestr,-1,
    1052                 'Angle restraints: sum(wt*(delt/sig)^2) =    %.2f, mean(wt*(delt/sig)^2) =    %.2f'    \
    1053                 %(chisq,chisq/len(angleList))),0,wx.ALIGN_CENTER_VERTICAL)
    1054             mainSizer.Add(Angles,0,)
     1042            if len(angleList):
     1043                angleTable = G2G.Table(table,rowLabels=rowLabels,colLabels=colLabels,types=Types)
     1044                Angles = G2G.GSGrid(AngleRestr)
     1045                Angles.SetTable(angleTable, True)
     1046                Angles.AutoSizeColumns(False)
     1047                for r in range(len(angleList)):
     1048                    for c in [0,1,4]:
     1049                        Angles.SetReadOnly(r,c,True)
     1050                        Angles.SetCellStyle(r,c,VERY_LIGHT_GREY,True)
     1051                Angles.Bind(wg.EVT_GRID_LABEL_LEFT_CLICK,OnRowSelect)
     1052                Angles.Bind(wg.EVT_GRID_CELL_CHANGE, OnCellChange)
     1053                G2frame.dataFrame.Bind(wx.EVT_MENU, OnDeleteRestraint, id=G2gd.wxID_RESTDELETE)
     1054                G2frame.dataFrame.Bind(wx.EVT_MENU, OnChangeValue, id=G2gd.wxID_RESRCHANGEVAL)
     1055                G2frame.dataFrame.Bind(wx.EVT_MENU, OnChangeEsd, id=G2gd.wxID_RESTCHANGEESD)
     1056                mainSizer.Add(wx.StaticText(AngleRestr,-1,
     1057                    'Angle restraints: sum(wt*(delt/sig)^2) =    %.2f, mean(wt*(delt/sig)^2) =    %.2f'    \
     1058                    %(chisq,chisq/len(angleList))),0,wx.ALIGN_CENTER_VERTICAL)
     1059                mainSizer.Add(Angles,0,)
     1060            else:
     1061                mainSizer.Add(wx.StaticText(AngleRestr,-1,'No bond angle restraints for this phase'),0,)
    10551062        else:
    10561063            mainSizer.Add(wx.StaticText(AngleRestr,-1,'No bond angle restraints for this phase'),0,)
     
    11611168                for ibad in bad:
    11621169                    del planeList[ibad]
    1163             planeTable = G2G.Table(table,rowLabels=rowLabels,colLabels=colLabels,types=Types)
    1164             Planes = G2G.GSGrid(PlaneRestr)
    1165             Planes.SetTable(planeTable, True)
    1166             Planes.AutoSizeColumns(False)
    1167             Planes.AutoSizeRows(False)
    1168             for r in range(len(planeList)):
    1169                 for c in range(3):
    1170                     Planes.SetReadOnly(r,c,True)
    1171                     Planes.SetCellStyle(r,c,VERY_LIGHT_GREY,True)
    1172             Planes.Bind(wg.EVT_GRID_LABEL_LEFT_CLICK,OnRowSelect)
    1173             Planes.Bind(wg.EVT_GRID_CELL_CHANGE, OnCellChange)
    1174             G2frame.dataFrame.Bind(wx.EVT_MENU, OnDeleteRestraint, id=G2gd.wxID_RESTDELETE)
    1175             G2frame.dataFrame.Bind(wx.EVT_MENU, OnChangeEsd, id=G2gd.wxID_RESTCHANGEESD)
    1176             mainSizer.Add(wx.StaticText(PlaneRestr,-1,
    1177                 'Plane restraints: sum(wt*(delt/sig)^2) =    %.2f, mean(wt*(delt/sig)^2) =    %.2f'    \
    1178                 %(chisq,chisq/len(planeList))),0,wx.ALIGN_CENTER_VERTICAL)
    1179             mainSizer.Add(Planes,0,)
     1170            if len(planeList):
     1171                planeTable = G2G.Table(table,rowLabels=rowLabels,colLabels=colLabels,types=Types)
     1172                Planes = G2G.GSGrid(PlaneRestr)
     1173                Planes.SetTable(planeTable, True)
     1174                Planes.AutoSizeColumns(False)
     1175                Planes.AutoSizeRows(False)
     1176                for r in range(len(planeList)):
     1177                    for c in range(3):
     1178                        Planes.SetReadOnly(r,c,True)
     1179                        Planes.SetCellStyle(r,c,VERY_LIGHT_GREY,True)
     1180                Planes.Bind(wg.EVT_GRID_LABEL_LEFT_CLICK,OnRowSelect)
     1181                Planes.Bind(wg.EVT_GRID_CELL_CHANGE, OnCellChange)
     1182                G2frame.dataFrame.Bind(wx.EVT_MENU, OnDeleteRestraint, id=G2gd.wxID_RESTDELETE)
     1183                G2frame.dataFrame.Bind(wx.EVT_MENU, OnChangeEsd, id=G2gd.wxID_RESTCHANGEESD)
     1184                mainSizer.Add(wx.StaticText(PlaneRestr,-1,
     1185                    'Plane restraints: sum(wt*(delt/sig)^2) =    %.2f, mean(wt*(delt/sig)^2) =    %.2f'    \
     1186                    %(chisq,chisq/len(planeList))),0,wx.ALIGN_CENTER_VERTICAL)
     1187                mainSizer.Add(Planes,0,)
     1188            else:
     1189                mainSizer.Add(wx.StaticText(PlaneRestr,-1,'No plane restraints for this phase'),0,)
    11801190        else:
    11811191            mainSizer.Add(wx.StaticText(PlaneRestr,-1,'No plane restraints for this phase'),0,)
     
    12901300                for ibad in bad:
    12911301                    del volumeList[ibad]
    1292             volumeTable = G2G.Table(table,rowLabels=rowLabels,colLabels=colLabels,types=Types)
    1293             Volumes = G2G.GSGrid(ChiralRestr)
    1294             Volumes.SetTable(volumeTable, True)
    1295             Volumes.AutoSizeColumns(False)
    1296             for r in range(len(volumeList)):
    1297                 for c in [0,1,4]:
    1298                     Volumes.SetReadOnly(r,c,True)
    1299                     Volumes.SetCellStyle(r,c,VERY_LIGHT_GREY,True)
    1300             Volumes.Bind(wg.EVT_GRID_LABEL_LEFT_CLICK,OnRowSelect)
    1301             Volumes.Bind(wg.EVT_GRID_CELL_CHANGE, OnCellChange)
    1302             G2frame.dataFrame.Bind(wx.EVT_MENU, OnDeleteRestraint, id=G2gd.wxID_RESTDELETE)
    1303             G2frame.dataFrame.Bind(wx.EVT_MENU, OnChangeValue, id=G2gd.wxID_RESRCHANGEVAL)
    1304             G2frame.dataFrame.Bind(wx.EVT_MENU, OnChangeEsd, id=G2gd.wxID_RESTCHANGEESD)
    1305             mainSizer.Add(wx.StaticText(ChiralRestr,-1,
    1306                 'Chiral volume restraints: sum(wt*(delt/sig)^2) =    %.2f, mean(wt*(delt/sig)^2) =    %.2f'    \
    1307                 %(chisq,chisq/len(volumeList))),0,wx.ALIGN_CENTER_VERTICAL)
    1308             mainSizer.Add(Volumes,0,)
     1302            if len(volumeList):
     1303                volumeTable = G2G.Table(table,rowLabels=rowLabels,colLabels=colLabels,types=Types)
     1304                Volumes = G2G.GSGrid(ChiralRestr)
     1305                Volumes.SetTable(volumeTable, True)
     1306                Volumes.AutoSizeColumns(False)
     1307                for r in range(len(volumeList)):
     1308                    for c in [0,1,4]:
     1309                        Volumes.SetReadOnly(r,c,True)
     1310                        Volumes.SetCellStyle(r,c,VERY_LIGHT_GREY,True)
     1311                Volumes.Bind(wg.EVT_GRID_LABEL_LEFT_CLICK,OnRowSelect)
     1312                Volumes.Bind(wg.EVT_GRID_CELL_CHANGE, OnCellChange)
     1313                G2frame.dataFrame.Bind(wx.EVT_MENU, OnDeleteRestraint, id=G2gd.wxID_RESTDELETE)
     1314                G2frame.dataFrame.Bind(wx.EVT_MENU, OnChangeValue, id=G2gd.wxID_RESRCHANGEVAL)
     1315                G2frame.dataFrame.Bind(wx.EVT_MENU, OnChangeEsd, id=G2gd.wxID_RESTCHANGEESD)
     1316                mainSizer.Add(wx.StaticText(ChiralRestr,-1,
     1317                    'Chiral volume restraints: sum(wt*(delt/sig)^2) =    %.2f, mean(wt*(delt/sig)^2) =    %.2f'    \
     1318                    %(chisq,chisq/len(volumeList))),0,wx.ALIGN_CENTER_VERTICAL)
     1319                mainSizer.Add(Volumes,0,)
     1320            else:
     1321                mainSizer.Add(wx.StaticText(ChiralRestr,-1,'No chiral volume restraints for this phase'),0,)
    13091322        else:
    13101323            mainSizer.Add(wx.StaticText(ChiralRestr,-1,'No chiral volume restraints for this phase'),0,)
     
    13911404                for ibad in bad:
    13921405                    del torsionList[ibad]
    1393             torsionTable = G2G.Table(table,rowLabels=rowLabels,colLabels=colLabels,types=Types)
    1394             TorsionRestr.Torsions = G2G.GSGrid(TorsionRestr)
    1395             TorsionRestr.Torsions.SetTable(torsionTable, True)
    1396             TorsionRestr.Torsions.AutoSizeColumns(False)
    1397             for r in range(len(torsionList)):
    1398                 for c in range(5):
    1399                     TorsionRestr.Torsions.SetReadOnly(r,c,True)
    1400                     TorsionRestr.Torsions.SetCellStyle(r,c,VERY_LIGHT_GREY,True)
    1401             TorsionRestr.Torsions.Bind(wg.EVT_GRID_LABEL_LEFT_CLICK,OnRowSelect)
    1402             TorsionRestr.Torsions.Bind(wg.EVT_GRID_CELL_CHANGE, OnCellChange)
    1403             G2frame.dataFrame.Bind(wx.EVT_MENU, OnDeleteRestraint, id=G2gd.wxID_RESTDELETE)
    1404             G2frame.dataFrame.Bind(wx.EVT_MENU, OnChangeEsd, id=G2gd.wxID_RESTCHANGEESD)
    1405             mainSizer.Add(wx.StaticText(TorsionRestr,-1,
    1406                 'Torsion restraints: sum(wt*(delt/sig)^2) =    %.2f, mean(wt*(delt/sig)^2) =    %.2f'    \
    1407                 %(chisq,chisq/len(torsionList))),0,wx.ALIGN_CENTER_VERTICAL)
    1408             mainSizer.Add(TorsionRestr.Torsions,0,)
    1409            
    1410             mainSizer.Add((5,5))
    1411             mainSizer.Add(wx.StaticText(TorsionRestr,-1,'Torsion function coefficients:'),0,wx.ALIGN_CENTER_VERTICAL)
    1412             table = []
    1413             rowLabels = []
    1414             Types = 9*[wg.GRID_VALUE_FLOAT+':10,4',]
    1415             colLabels = ['Mag A','Pos A','Width A','Mag B','Pos B','Width B','Mag C','Pos C','Width C']
    1416             for item in coeffDict:
    1417                 rowLabels.append(item)
    1418                 table.append(coeffDict[item])
    1419             coeffTable = G2G.Table(table,rowLabels=rowLabels,colLabels=colLabels,types=Types)
    1420             Coeff = G2G.GSGrid(TorsionRestr)
    1421             Coeff.SetTable(coeffTable, True)
    1422             Coeff.AutoSizeColumns(False)
    1423             for r in range(len(coeffDict)):
    1424                 for c in range(9):
    1425                     Coeff.SetReadOnly(r,c,True)
    1426                     Coeff.SetCellStyle(r,c,VERY_LIGHT_GREY,True)
    1427             mainSizer.Add(Coeff,0,)
     1406            if len(torsionList):
     1407                torsionTable = G2G.Table(table,rowLabels=rowLabels,colLabels=colLabels,types=Types)
     1408                TorsionRestr.Torsions = G2G.GSGrid(TorsionRestr)
     1409                TorsionRestr.Torsions.SetTable(torsionTable, True)
     1410                TorsionRestr.Torsions.AutoSizeColumns(False)
     1411                for r in range(len(torsionList)):
     1412                    for c in range(5):
     1413                        TorsionRestr.Torsions.SetReadOnly(r,c,True)
     1414                        TorsionRestr.Torsions.SetCellStyle(r,c,VERY_LIGHT_GREY,True)
     1415                TorsionRestr.Torsions.Bind(wg.EVT_GRID_LABEL_LEFT_CLICK,OnRowSelect)
     1416                TorsionRestr.Torsions.Bind(wg.EVT_GRID_CELL_CHANGE, OnCellChange)
     1417                G2frame.dataFrame.Bind(wx.EVT_MENU, OnDeleteRestraint, id=G2gd.wxID_RESTDELETE)
     1418                G2frame.dataFrame.Bind(wx.EVT_MENU, OnChangeEsd, id=G2gd.wxID_RESTCHANGEESD)
     1419                mainSizer.Add(wx.StaticText(TorsionRestr,-1,
     1420                    'Torsion restraints: sum(wt*(delt/sig)^2) =    %.2f, mean(wt*(delt/sig)^2) =    %.2f'    \
     1421                    %(chisq,chisq/len(torsionList))),0,wx.ALIGN_CENTER_VERTICAL)
     1422                mainSizer.Add(TorsionRestr.Torsions,0,)
     1423               
     1424                mainSizer.Add((5,5))
     1425                mainSizer.Add(wx.StaticText(TorsionRestr,-1,'Torsion function coefficients:'),0,wx.ALIGN_CENTER_VERTICAL)
     1426                table = []
     1427                rowLabels = []
     1428                Types = 9*[wg.GRID_VALUE_FLOAT+':10,4',]
     1429                colLabels = ['Mag A','Pos A','Width A','Mag B','Pos B','Width B','Mag C','Pos C','Width C']
     1430                for item in coeffDict:
     1431                    rowLabels.append(item)
     1432                    table.append(coeffDict[item])
     1433                coeffTable = G2G.Table(table,rowLabels=rowLabels,colLabels=colLabels,types=Types)
     1434                Coeff = G2G.GSGrid(TorsionRestr)
     1435                Coeff.SetTable(coeffTable, True)
     1436                Coeff.AutoSizeColumns(False)
     1437                for r in range(len(coeffDict)):
     1438                    for c in range(9):
     1439                        Coeff.SetReadOnly(r,c,True)
     1440                        Coeff.SetCellStyle(r,c,VERY_LIGHT_GREY,True)
     1441                mainSizer.Add(Coeff,0,)
     1442            else:
     1443                mainSizer.Add(wx.StaticText(TorsionRestr,-1,'No torsion restraints for this phase'),0,)
    14281444        else:
    14291445            mainSizer.Add(wx.StaticText(TorsionRestr,-1,'No torsion restraints for this phase'),0,)
     
    15111527                for ibad in bad:
    15121528                    del ramaList[ibad]
    1513             ramaTable = G2G.Table(table,rowLabels=rowLabels,colLabels=colLabels,types=Types)
    1514             RamaRestr.Ramas = G2G.GSGrid(RamaRestr)
    1515             RamaRestr.Ramas.SetTable(ramaTable, True)
    1516             RamaRestr.Ramas.AutoSizeColumns(False)
    1517             for r in range(len(ramaList)):
    1518                 for c in range(6):
    1519                     RamaRestr.Ramas.SetReadOnly(r,c,True)
    1520                     RamaRestr.Ramas.SetCellStyle(r,c,VERY_LIGHT_GREY,True)
    1521             RamaRestr.Ramas.Bind(wg.EVT_GRID_LABEL_LEFT_CLICK,OnRowSelect)
    1522             RamaRestr.Ramas.Bind(wg.EVT_GRID_CELL_CHANGE, OnCellChange)
    1523             G2frame.dataFrame.Bind(wx.EVT_MENU, OnDeleteRestraint, id=G2gd.wxID_RESTDELETE)
    1524             G2frame.dataFrame.Bind(wx.EVT_MENU, OnChangeEsd, id=G2gd.wxID_RESTCHANGEESD)
    1525             mainSizer.Add(wx.StaticText(RamaRestr,-1,
    1526                 'Ramachandran restraints: sum(wt*(delt/sig)^2) =    %.2f, mean(wt*(delt/sig)^2) =    %.2f'    \
    1527                 %(chisq,chisq/len(ramaList))),0,wx.ALIGN_CENTER_VERTICAL)
    1528             mainSizer.Add(RamaRestr.Ramas,0,)
     1529            if len(ramaList):
     1530                ramaTable = G2G.Table(table,rowLabels=rowLabels,colLabels=colLabels,types=Types)
     1531                RamaRestr.Ramas = G2G.GSGrid(RamaRestr)
     1532                RamaRestr.Ramas.SetTable(ramaTable, True)
     1533                RamaRestr.Ramas.AutoSizeColumns(False)
     1534                for r in range(len(ramaList)):
     1535                    for c in range(6):
     1536                        RamaRestr.Ramas.SetReadOnly(r,c,True)
     1537                        RamaRestr.Ramas.SetCellStyle(r,c,VERY_LIGHT_GREY,True)
     1538                RamaRestr.Ramas.Bind(wg.EVT_GRID_LABEL_LEFT_CLICK,OnRowSelect)
     1539                RamaRestr.Ramas.Bind(wg.EVT_GRID_CELL_CHANGE, OnCellChange)
     1540                G2frame.dataFrame.Bind(wx.EVT_MENU, OnDeleteRestraint, id=G2gd.wxID_RESTDELETE)
     1541                G2frame.dataFrame.Bind(wx.EVT_MENU, OnChangeEsd, id=G2gd.wxID_RESTCHANGEESD)
     1542                mainSizer.Add(wx.StaticText(RamaRestr,-1,
     1543                    'Ramachandran restraints: sum(wt*(delt/sig)^2) =    %.2f, mean(wt*(delt/sig)^2) =    %.2f'    \
     1544                    %(chisq,chisq/len(ramaList))),0,wx.ALIGN_CENTER_VERTICAL)
     1545                mainSizer.Add(RamaRestr.Ramas,0,)
     1546            else:
     1547                mainSizer.Add(wx.StaticText(RamaRestr,-1,'No Ramachandran restraints for this phase'),0,)
    15291548        else:
    15301549            mainSizer.Add(wx.StaticText(RamaRestr,-1,'No Ramachandran restraints for this phase'),0,)
     
    16491668                for ibad in bad:
    16501669                    del chemcompList[ibad]
    1651             chemcompTable = G2G.Table(table,rowLabels=rowLabels,colLabels=colLabels,types=Types)
    1652             ChemComps = G2G.GSGrid(ChemCompRestr)
    1653             ChemComps.SetTable(chemcompTable, True)
    1654             ChemComps.AutoSizeColumns(False)
    1655             for r in range(chemcompTable.GetNumberRows()):
    1656                 for c in range(2):
    1657                     ChemComps.SetReadOnly(r,c,True)
    1658                     ChemComps.SetCellStyle(r,c,VERY_LIGHT_GREY,True)
    1659                 if 'Restr' in ChemComps.GetRowLabelValue(r):
    1660                     for c in range(4):
     1670            if len(chemcompList):
     1671                chemcompTable = G2G.Table(table,rowLabels=rowLabels,colLabels=colLabels,types=Types)
     1672                ChemComps = G2G.GSGrid(ChemCompRestr)
     1673                ChemComps.SetTable(chemcompTable, True)
     1674                ChemComps.AutoSizeColumns(False)
     1675                for r in range(chemcompTable.GetNumberRows()):
     1676                    for c in range(2):
    16611677                        ChemComps.SetReadOnly(r,c,True)
    16621678                        ChemComps.SetCellStyle(r,c,VERY_LIGHT_GREY,True)
    1663                     for c in [1,2]:
    1664                         ChemComps.SetCellTextColour(r,c,VERY_LIGHT_GREY)
    1665                 else:
    1666                     for c in [3,4,5]:
    1667                         ChemComps.SetReadOnly(r,c,True)
    1668                         ChemComps.SetCellStyle(r,c,VERY_LIGHT_GREY,True)
    1669                     for c in [4,5]:
    1670                         ChemComps.SetCellTextColour(r,c,VERY_LIGHT_GREY)
    1671                        
    1672             ChemComps.Bind(wg.EVT_GRID_LABEL_LEFT_CLICK,OnRowSelect)
    1673             ChemComps.Bind(wg.EVT_GRID_CELL_CHANGE, OnCellChange)
    1674             G2frame.dataFrame.Bind(wx.EVT_MENU, OnDeleteRestraint, id=G2gd.wxID_RESTDELETE)
    1675             G2frame.dataFrame.Bind(wx.EVT_MENU, OnChangeValue, id=G2gd.wxID_RESRCHANGEVAL)
    1676             mainSizer.Add(wx.StaticText(ChemCompRestr,-1,
    1677                 'Chemical composition restraints: sum(wt*(delt/sig)^2) =    %.2f, mean(wt*(delt/sig)^2) =    %.2f'    \
    1678                 %(chisq,chisq/len(chemcompList))),0,wx.ALIGN_CENTER_VERTICAL)
    1679             mainSizer.Add(ChemComps,0,)
     1679                    if 'Restr' in ChemComps.GetRowLabelValue(r):
     1680                        for c in range(4):
     1681                            ChemComps.SetReadOnly(r,c,True)
     1682                            ChemComps.SetCellStyle(r,c,VERY_LIGHT_GREY,True)
     1683                        for c in [1,2]:
     1684                            ChemComps.SetCellTextColour(r,c,VERY_LIGHT_GREY)
     1685                    else:
     1686                        for c in [3,4,5]:
     1687                            ChemComps.SetReadOnly(r,c,True)
     1688                            ChemComps.SetCellStyle(r,c,VERY_LIGHT_GREY,True)
     1689                        for c in [4,5]:
     1690                            ChemComps.SetCellTextColour(r,c,VERY_LIGHT_GREY)
     1691                           
     1692                ChemComps.Bind(wg.EVT_GRID_LABEL_LEFT_CLICK,OnRowSelect)
     1693                ChemComps.Bind(wg.EVT_GRID_CELL_CHANGE, OnCellChange)
     1694                G2frame.dataFrame.Bind(wx.EVT_MENU, OnDeleteRestraint, id=G2gd.wxID_RESTDELETE)
     1695                G2frame.dataFrame.Bind(wx.EVT_MENU, OnChangeValue, id=G2gd.wxID_RESRCHANGEVAL)
     1696                mainSizer.Add(wx.StaticText(ChemCompRestr,-1,
     1697                    'Chemical composition restraints: sum(wt*(delt/sig)^2) =    %.2f, mean(wt*(delt/sig)^2) =    %.2f'    \
     1698                    %(chisq,chisq/len(chemcompList))),0,wx.ALIGN_CENTER_VERTICAL)
     1699                mainSizer.Add(ChemComps,0,)
     1700            else:
     1701                mainSizer.Add(wx.StaticText(ChemCompRestr,-1,'No chemical composition restraints for this phase'),0,)
    16801702        else:
    16811703            mainSizer.Add(wx.StaticText(ChemCompRestr,-1,'No chemical composition restraints for this phase'),0,)
  • trunk/GSASIIstrIO.py

    r2770 r2840  
    14561456        for name,rest in names:
    14571457            itemRest = phaseRest[name]
    1458             if itemRest[rest] and itemRest['Use']:
     1458            if rest in itemRest and itemRest[rest] and itemRest['Use']:
    14591459                print >>pFile,'\n  %s %10.3f Use: %s'%(name+' restraint weight factor',itemRest['wtFactor'],str(itemRest['Use']))
    14601460                if name in ['Bond','Angle','Plane','Chiral']:
  • trunk/imports/G2phase.py

    r2817 r2840  
    130130                    S[12:17].strip(),Type.strip().capitalize(),'',XYZ[0],XYZ[1],XYZ[2],
    131131                    float(S[55:61]),SytSym,Mult,'I',Uiso,0,0,0,0,0,0]
    132                 S = file.readline()
    133                 line += 1
    134                 if 'ANISOU' in S[:6]:
    135                     Uij = S[30:72].split()
    136                     Uij = [float(Uij[0])/10000.,float(Uij[1])/10000.,float(Uij[2])/10000.,
    137                         float(Uij[3])/10000.,float(Uij[4])/10000.,float(Uij[5])/10000.]
    138                     Atom = Atom[:14]+Uij
    139                     Atom[12] = 'A'
    140132                Atom.append(ran.randint(0,sys.maxint))
    141133                Atoms.append(Atom)
     134            elif 'ANISOU' in S[:6]:
     135                Uij = S[30:72].split()
     136                Uij = [float(Uij[0])/10000.,float(Uij[1])/10000.,float(Uij[2])/10000.,
     137                    float(Uij[3])/10000.,float(Uij[4])/10000.,float(Uij[5])/10000.]
     138                Atoms[-1] = Atoms[-1][:14]+Uij
     139                Atoms[-1][12] = 'A'
     140                Atoms[-1].append(ran.randint(0,sys.maxint))
    142141            S = file.readline()
    143142            line += 1
Note: See TracChangeset for help on using the changeset viewer.