Changeset 2858 for trunk/GSASIImath.py


Ignore:
Timestamp:
Jun 5, 2017 9:12:03 PM (6 years ago)
Author:
vondreele
Message:

fix Pawley restraint problem
force skip of disordered residues in pdb reader - can't handle them in G2
small cleanup in SVD stuff

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIImath.py

    r2854 r2858  
    101101    s = np.where(s>cutoff,1./s,0.)
    102102    nzero = s.shape[0]-np.count_nonzero(s)
    103     res = np.dot(np.transpose(vt), np.multiply(s[:, np.newaxis], np.transpose(u)))
     103#    res = np.dot(np.transpose(vt), np.multiply(s[:, np.newaxis], np.transpose(u)))
     104    res = np.dot(vt.T,s[:,nxs]*u.T)
    104105    return res,nzero
    105106
     
    224225    try:
    225226        Bmat,Nzero = pinv(Amatlam,xtol)    #Moore-Penrose inversion (via SVD) & count of zeros
    226         print 'Found %d SVD zeros'%(Nzero)
     227        if Print:
     228            print 'Found %d SVD zeros'%(Nzero)
    227229#        Bmat = nl.inv(Amatlam); Nzeros = 0
    228230        Bmat = Bmat/Anorm
     
    25702572###############################################################################
    25712573
    2572     def validProtein(Phase):
    2573         resNames = ['ALA','ARG','ASN','ASP','CYS','GLN','GLU','GLY','HIS','ILE',
    2574             'LEU','LYS','MET','PHE','PRO','SER','THR','TRP','TYR','VAL','MSE']
    2575         print 'Do VALIDPROTEIN analysis - TBD'
    2576         General = Phase['General']
    2577         Amat,Bmat = G2lat.cell2AB(General['Cell'][1:7])
    2578         cx,ct,cs,cia = General['AtomPtrs']
    2579         Atoms = Phase['Atoms']
    2580         cartAtoms = []
    2581         chains = []
    2582         for atom in Atoms:
    2583             if atom[2] in resNames:
    2584                 cartAtoms.append(atom[:cx+3])
    2585                 if atom[2] not in chains:
    2586                     chains.append(atom[2])
    2587                 cartAtoms[-1][cx:cx+3] = np.inner(Amat,cartAtoms[-1][cx:cx+3])
     2574def validProtein(Phase):
     2575    resNames = ['ALA','ARG','ASN','ASP','CYS','GLN','GLU','GLY','HIS','ILE',
     2576        'LEU','LYS','MET','PHE','PRO','SER','THR','TRP','TYR','VAL','MSE']
     2577# data taken from erratv2.ccp
     2578    lmt = np.array([17.190823041860433,11.526684477428809])
     2579    b1 = np.array([     [0,0,0,0,0,0],
     2580          [0,   5040.279078850848200,   3408.805141583649400,   4152.904423767300600,   4236.200004171890200,   5054.781210204625500], 
     2581          [0,   3408.805141583648900,   8491.906094010220800,   5958.881777877950300,   1521.387352718486200,   4304.078200827221700], 
     2582          [0,   4152.904423767301500,   5958.881777877952100,   7637.167089335050100,   6620.715738223072500,   5287.691183798410700], 
     2583          [0,   4236.200004171890200,   1521.387352718486200,   6620.715738223072500,   18368.343774298410000,  4050.797811118806700], 
     2584          [0,   5054.781210204625500,   4304.078200827220800,   5287.691183798409800,   4050.797811118806700,   6666.856740479164700]])
     2585    avg = np.array([0.192765509919262, 0.195575208778518, 0.275322406824210, 0.059102357035642, 0.233154192767480])
     2586    General = Phase['General']
     2587    Amat,Bmat = G2lat.cell2AB(General['Cell'][1:7])
     2588    cx,ct,cs,cia = General['AtomPtrs']
     2589    Atoms = Phase['Atoms']
     2590    cartAtoms = []
     2591    chains = []
     2592    chainBeg = []
     2593    xyzmin = 999.*np.ones(3)
     2594    xyzmax = -999.*np.ones(3)
     2595    for atom in Atoms:
     2596        if atom[1] in resNames:
     2597            cartAtoms.append(atom[:cx+3])
     2598            if atom[2] not in chains:
     2599                chains.append(atom[2])
     2600                chainBeg.append(len(cartAtoms)-1)
     2601            cartAtoms[-1][cx:cx+3] = np.inner(Amat,cartAtoms[-1][cx:cx+3])
     2602    XYZ = np.array([atom[cx:cx+3] for atom in cartAtoms])
     2603    xyzmin = np.array([np.min(XYZ.T[i]) for i in [0,1,2]])
     2604    xyzmax = np.array([np.max(XYZ.T[i]) for i in [0,1,2]])
     2605    nbox = list(np.array(np.ceil((xyzmax-xyzmin)/4.),dtype=int))+[15,]
     2606    Boxes = np.zeros(nbox,dtype=int)
     2607    iBox = np.array([np.trunc((XYZ.T[i]-xyzmin[i])/4.) for i in [0,1,2]],dtype=int).T
     2608    for ib,box in enumerate(iBox):  #put in a try for too many atoms in box (IndexError)?
     2609        Boxes[box[0],box[1],box[2],0] += 1
     2610        Boxes[box[0],box[1],box[2],Boxes[box[0],box[1],box[2],0]] = ib
     2611    pstat = 0.
     2612    stat = 0.
     2613    mtrxstat = 0.
     2614    for ia,atom in cartAtoms:
     2615        if not i:   #skip 1st atom
     2616            continue
     2617        if atom[0] != cartAtom[ia-1][0]:    #new residue - start analysis
     2618            c = np.zeros((3,3))
     2619            s = 1
     2620   
     2621    print 'Do VALIDPROTEIN analysis - TBD'
    25882622           
    25892623   
Note: See TracChangeset for help on using the changeset viewer.