Changeset 3003


Ignore:
Timestamp:
Aug 12, 2017 4:23:31 PM (6 years ago)
Author:
vondreele
Message:

more development of protein validation - still not correct
substitute old "paired" & "Paired-r" continuous colors for the installed one (16 discrete colors in mpl 2.0.X
trap use of tick_label in barh (not in mpl <2.0)

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIImath.py

    r3000 r3003  
    25742574    resNames = ['ALA','ARG','ASN','ASP','CYS','GLN','GLU','GLY','HIS','ILE',
    25752575        'LEU','LYS','MET','PHE','PRO','SER','THR','TRP','TYR','VAL','MSE']
     2576    old = True          #use errat version 1 math
     2577# data from errat.f
     2578    b1_old = np.array([
     2579        [1154.343,  600.213, 1051.018, 1132.885,  960.738],
     2580        [600.213, 1286.818, 1282.042,  957.156,  612.789],
     2581        [1051.018, 1282.042, 3519.471,  991.974, 1226.491],
     2582        [1132.885,  957.156,  991.974, 1798.672,  820.355],
     2583        [960.738,  612.789, 1226.491,  820.355, 2428.966]
     2584        ])
     2585    avg_old = np.array([ 0.225, 0.281, 0.071, 0.237, 0.044])    #Table 1 3.5A Obsd. Fr. p 1513
    25762586# data taken from erratv2.ccp
    2577     b1 = np.array([     [0,0,0,0,0,0],
    2578           [0,   5040.279078850848200,   3408.805141583649400,   4152.904423767300600,   4236.200004171890200,   5054.781210204625500], 
    2579           [0,   3408.805141583648900,   8491.906094010220800,   5958.881777877950300,   1521.387352718486200,   4304.078200827221700], 
    2580           [0,   4152.904423767301500,   5958.881777877952100,   7637.167089335050100,   6620.715738223072500,   5287.691183798410700], 
    2581           [0,   4236.200004171890200,   1521.387352718486200,   6620.715738223072500,   18368.343774298410000,  4050.797811118806700], 
    2582           [0,   5054.781210204625500,   4304.078200827220800,   5287.691183798409800,   4050.797811118806700,   6666.856740479164700]])
    2583     avg = np.array([0.,0.192765509919262, 0.195575208778518, 0.275322406824210, 0.059102357035642, 0.233154192767480])
     2587    b1 = np.array([
     2588          [5040.279078850848200,        3408.805141583649400,   4152.904423767300600,   4236.200004171890200,   5054.781210204625500], 
     2589          [3408.805141583648900,        8491.906094010220800,   5958.881777877950300,   1521.387352718486200,   4304.078200827221700], 
     2590          [4152.904423767301500,        5958.881777877952100,   7637.167089335050100,   6620.715738223072500,   5287.691183798410700], 
     2591          [4236.200004171890200,        1521.387352718486200,   6620.715738223072500,   18368.343774298410000,  4050.797811118806700], 
     2592          [5054.781210204625500,        4304.078200827220800,   5287.691183798409800,   4050.797811118806700,   6666.856740479164700]])
     2593    avg = np.array([0.192765509919262, 0.195575208778518, 0.275322406824210, 0.059102357035642, 0.233154192767480])
    25842594    General = Phase['General']
    25852595    Amat,Bmat = G2lat.cell2AB(General['Cell'][1:7])
     
    25942604            if atom[4].strip() in ['S','Se']:
    25952605                atom[4] = 'O'
    2596             if atom[3].strip() in ['C','N']:    #skip main chain C & N atoms
    2597                 continue
     2606#            if atom[3].strip() in ['C','N']:    #skip main chain C & N atoms
     2607#                continue
    25982608            cartAtoms.append(atom[:cx+3])
    25992609            cartAtoms[-1][cx:cx+3] = np.inner(Amat,cartAtoms[-1][cx:cx+3])
     
    26072617        Boxes[box[0],box[1],box[2],0] += 1
    26082618        Boxes[box[0],box[1],box[2],Boxes[box[0],box[1],box[2],0]] = ib
     2619    #Box content checks with errat.f ibox1 array
    26092620    indices = (-1,0,1)
    26102621    Units = np.array([[h,k,l] for h in indices for k in indices for l in indices])
    26112622    dsmax = 3.75**2
     2623    if old:
     2624        dsmax = 3.5**2
    26122625    chains = []
    26132626    resIntAct = []
     
    26312644                newChain = True
    26322645        if atom[0] not in res:  #new residue, get residue no.
     2646            if len(res): print res[-1],resname[-1],intact
    26332647            res.append(atom[0])
    26342648            resname.append('%s-%s%s'%(atom[2],atom[0],atom[1]))
     
    26452659        tgts = list(set(tgts))
    26462660        tgts = [tgt for tgt in tgts if atom[1:3] != cartAtoms[tgt][1:3]]    #exclude same residue
    2647         tgts = [tgt for tgt in tgts if cartAtoms[tgt][3].strip() not in ['C','N']]  #exclude main chain
     2661        if atom[3].strip() in ['C',]:
     2662            tgts = [tgt for tgt in tgts if cartAtoms[tgt][3].strip() not in ['N',]]  #exclude main chain C-N
     2663        if atom[3].strip() in ['N',]:
     2664            tgts = [tgt for tgt in tgts if cartAtoms[tgt][3].strip() not in ['C',]]  #exclude main chain N-C
    26482665        tgts = [tgt for tgt in tgts if np.sum((XYZ[ia]-XYZ[tgt])**2) <= dsmax]
    26492666        for tgt in tgts:
    26502667            dsqt = np.sqrt(np.sum((XYZ[ia]-XYZ[tgt])**2))
    26512668            mult = 1.0
    2652             if dsqt > 3.25:
     2669            if dsqt > 3.25 and not old:
    26532670                mult = 2.*(3.75-dsqt)
    26542671            intype = atom[4].strip()+cartAtoms[tgt][4].strip()
     
    26632680        Probs = [0.,0.,0.,0.]
    26642681        for i in range(4,nRes-4):
    2665             mtrx = np.zeros(6)
     2682            print i,IntAct[i]
     2683            mtrx = np.zeros(5)
    26662684            summ = 0.
    2667             for j in range(i-4,i+4):
     2685            for j in range(i-4,i+5):
    26682686                summ += np.sum(np.array(IntAct[j].values()))
    2669                 print 'CC',IntAct[j]['CC'],'CN',IntAct[j]['CN'],'CO',IntAct[j]['CO']
    2670                 print 'NN',IntAct[j]['NN'],'NO',IntAct[j]['NO'],'OO',IntAct[j]['OO']
    2671                 mtrx[1] += IntAct[j]['CC']
    2672                 mtrx[2] += IntAct[j]['CN']
    2673                 mtrx[3] += IntAct[j]['CO']
    2674                 mtrx[4] += IntAct[j]['NN']
    2675                 mtrx[5] += IntAct[j]['NO']
     2687                if old:
     2688                    mtrx[0] += IntAct[j]['CC']
     2689                    mtrx[1] += IntAct[j]['CO']
     2690                    mtrx[2] += IntAct[j]['NN']
     2691                    mtrx[3] += IntAct[j]['NO']
     2692                    mtrx[4] += IntAct[j]['OO']
     2693                else:
     2694                    mtrx[0] += IntAct[j]['CC']
     2695                    mtrx[1] += IntAct[j]['CN']
     2696                    mtrx[2] += IntAct[j]['CO']
     2697                    mtrx[3] += IntAct[j]['NN']
     2698                    mtrx[4] += IntAct[j]['NO']
     2699            print mtrx,np.sum(mtrx)
     2700            print summ
    26762701            mtrx /= summ
    2677             mtrx -= avg
    2678             prob = np.inner(np.inner(mtrx,b1),mtrx)/36.
     2702            if old:
     2703                mtrx -= avg_old
     2704                prob = np.inner(np.inner(mtrx,b1_old),mtrx)
     2705            else:
     2706                mtrx -= avg
     2707                prob = np.inner(np.inner(mtrx,b1),mtrx)
    26792708            print i, mtrx
    26802709            Probs.append(prob)
  • trunk/GSASIIplot.py

    r3000 r3003  
    7070#    GSASIIpath.IPyBreak()
    7171plotDebug = False
    72    
     72#matplotlib 2.0.x dumbed down Paired to 16 colors -
     73#   this restores the pre 2.0 Paired color map found in matplotlib._cm.py
     74_Old_Paired_data = {'blue': [(0.0, 0.89019608497619629,
     750.89019608497619629), (0.090909090909090912, 0.70588237047195435,
     760.70588237047195435), (0.18181818181818182, 0.54117649793624878,
     770.54117649793624878), (0.27272727272727271, 0.17254902422428131,
     780.17254902422428131), (0.36363636363636365, 0.60000002384185791,
     790.60000002384185791), (0.45454545454545453, 0.10980392247438431,
     800.10980392247438431), (0.54545454545454541, 0.43529412150382996,
     810.43529412150382996), (0.63636363636363635, 0.0, 0.0),
     82(0.72727272727272729, 0.83921569585800171, 0.83921569585800171),
     83(0.81818181818181823, 0.60392159223556519, 0.60392159223556519),
     84(0.90909090909090906, 0.60000002384185791, 0.60000002384185791), (1.0,
     850.15686275064945221, 0.15686275064945221)],
     86
     87    'green': [(0.0, 0.80784314870834351, 0.80784314870834351),
     88    (0.090909090909090912, 0.47058823704719543, 0.47058823704719543),
     89    (0.18181818181818182, 0.87450981140136719, 0.87450981140136719),
     90    (0.27272727272727271, 0.62745100259780884, 0.62745100259780884),
     91    (0.36363636363636365, 0.60392159223556519, 0.60392159223556519),
     92    (0.45454545454545453, 0.10196078568696976, 0.10196078568696976),
     93    (0.54545454545454541, 0.74901962280273438, 0.74901962280273438),
     94    (0.63636363636363635, 0.49803921580314636, 0.49803921580314636),
     95    (0.72727272727272729, 0.69803923368453979, 0.69803923368453979),
     96    (0.81818181818181823, 0.23921568691730499, 0.23921568691730499),
     97    (0.90909090909090906, 1.0, 1.0), (1.0, 0.3490196168422699,
     98    0.3490196168422699)],
     99
     100    'red': [(0.0, 0.65098041296005249, 0.65098041296005249),
     101    (0.090909090909090912, 0.12156862765550613, 0.12156862765550613),
     102    (0.18181818181818182, 0.69803923368453979, 0.69803923368453979),
     103    (0.27272727272727271, 0.20000000298023224, 0.20000000298023224),
     104    (0.36363636363636365, 0.9843137264251709, 0.9843137264251709),
     105    (0.45454545454545453, 0.89019608497619629, 0.89019608497619629),
     106    (0.54545454545454541, 0.99215686321258545, 0.99215686321258545),
     107    (0.63636363636363635, 1.0, 1.0), (0.72727272727272729,
     108    0.7921568751335144, 0.7921568751335144), (0.81818181818181823,
     109    0.41568627953529358, 0.41568627953529358), (0.90909090909090906,
     110    1.0, 1.0), (1.0, 0.69411766529083252, 0.69411766529083252)]}
     111mpl.cm.register_cmap('Paired',data=_Old_Paired_data,lut=128)
     112mpl.cm.register_cmap('Paired_r',data=mpl.cm._reverse_cmap_spec(_Old_Paired_data),lut=128)
     113#This can be done on request for other colors
     114
    73115class _tabPlotWin(wx.Panel):   
    74116    'Creates a basic tabbed plot window for GSAS-II graphics'
     
    31113153        Plot.set_xlabel(r'Error score',fontsize=14)
    31123154        Plot.set_ylabel(r'Residue',fontsize=14)
    3113         colors=['b','r','g','c','m','k']
    3114         Plot.barh(np.arange(len(resNames)),Probs,tick_label=resNames,)
     3155        try:
     3156            Plot.barh(np.arange(len(resNames)),Probs,tick_label=resNames,)
     3157        except AttributeError:  #tick_label not in mpl 1.4
     3158            Plot.barh(np.arange(len(resNames)),Probs)
    31153159        if thresh is not None:
    31163160            for item in thresh:
     
    31263170        else:
    31273171            Page.canvas.draw()
    3128            
    31293172   
    31303173    new,plotNum,Page,Plot,lim = G2frame.G2plotNB.FindPlotTab(Title,'mpl')
Note: See TracChangeset for help on using the changeset viewer.