def readoutresults(reslall, resnall, pickthese, DeltaOmegaParametersBoundaries,
                   savstatdir, namresults, conditions, k23max):
    """
    reads global fitting results from file.
    reslall: list of all residues possibly used for the results output, with a letter
        in front indicating whether this is referring to the folded (A), random
        coil (B) or dimer(C) peak.
    resnall: same list as reslall, without the letter
    pickthese: list pointing to the residues in reslall, resnall actually used
        for the output
    DeltaOmegaParametersBoundaries: boundaries for delta omegas, this is a dummy
        variable in most case. format: [residue1, residue2, ...]; residue1=
        [site A, site B, site C]; site A: [min, max boundary]
    namresults: name of results file. typically has an err_ suffix when referring
        to the error calculations based on a corresponding file without the suffix
        results files have the .dill file extension.
    DEL? conditions: list of fitting conditions, not important (dummy)
        format will me explained later. subject to removal 
    
    First, a collection of Property Axes is triggered. Containing informations
        about possible magnetic fields, temperatures, sites, concentrations,
        B1 fields, experiment types, TROSY type, residues
    Then a ParameterCollection object based on the params class, using the
        PropertyAxesColl object, is generated.
    All relaxation dispersion fitting data are loaded into a variety
        of variables.
    The resultcoll variable contains the actual results. costs are extracted.
    The resulting parameters are transferred to the ParameterCollection object.
    The ParameterCollection object is re-sorted in order of increasing fitting cost.
    Important variables including a list of fitting conditions saved in the
        results file are returned. Also resultcoll, cost list, the resorted
        Parameter Collection and Property Axes Collection.
    """

    PropAxesColl=mainfuncts.GeneratePropertyAxesCollection([x for y,x in \
        enumerate(reslall) if y in pickthese],[x for y,x in enumerate(resnall)\
                 if y in pickthese])
    ParameterColl=mainfuncts.parammake(PropAxesColl,0,[x for y,x in enumerate\
        (DeltaOmegaParametersBoundaries) if y in pickthese],1,10000,100,900,1,k23max,0.005,0.5) #2 or 900

    #DEL?#setparameters2=['combo10l.dat','C:\\Users\\Hans\\Desktop\\TRANSFER\\2020Feb\\',[[x for y,x in enumerate(reslall) if y in pickthese]],conditions,namresults]
    #DEL?#namresults=namresults+str(resnall[0])+'_'+str(nn)+'_'

    #A variety of pre-calculated data is loaded with this command. Not all of
    #them are in use, so no need to understand every sirngle variable here.
    poscoll,resnam,allsetcoll,resultcoll,relaxrat0,relaxrat,lookatratio,\
        results,relaxrat1,relaxrat2,relaxrat_1,relaxrat_2,intdiffcorr, intcorr,\
        intmin,ac,oc,rateconstpre,cond=hkio2.loadeverything(savstatdir,[namresults],0,decoupl=0)
    costcoll = [i.cost for i in resultcoll]
    #resultcoll=[resultcoll[np.argsort(costcoll)[0]]]
    ParameterColl2 = mainfuncts.resc2param(PropAxesColl, ParameterColl,
                                           resultcoll, 2)
    ParameterColl2 = [ParameterColl2[i] for i in np.argsort(costcoll)]
    costcoll = [costcoll[i] for i in np.argsort(costcoll)]
    return PropAxesColl, ParameterColl2, costcoll, resultcoll, cond
Beispiel #2
0
def readoutresults(namresultsx):
    reslall=['A29','A30','A31','A32','A33','A34','A52','A53','A54','A78','A81','A82','A83','A84','A86']
    resnall=[29,30,31,32,33,34,52,53,54,78,81,82,83,84,86]
    freevsfix='free' #'fix_0
    pickthis=1
    list1=[]
    for pickthis in np.arange(15):
        list2=[]
        for nn in np.arange(3):
            reslall=['A29','A30','A31','A32','A33','A34','A52','A53','A54','A78','A81','A82','A83','A84','A86']
            resnall=[29,30,31,32,33,34,52,53,54,78,81,82,83,84,86]
            reslall=[reslall[pickthis]]
            resnall=[resnall[pickthis]]
            pickthese=[0]
            
            praxs1=mainfuncts.praxismake([x for y,x in enumerate(reslall) if y in pickthese],[x for y,x in enumerate(resnall) if y in pickthese])
            parbdslistaxallf=[[[-1, 1], [-26000,26000], [-13000, 13000]],\
                       [[-1, 1], [-26000,26000], [-13000, 13000]],\
                       [[-1, 1], [-26000,26000], [-13000, 13000]],\
                       [[-1, 1], [-26000,26000], [-13000, 13000]],\
                       [[-1, 1], [-26000,26000], [-13000, 13000]],\
                       [[-1,-1,],[-26000,26000],[-13000, 13000]],\
                   #out    [[-1, 1], [-389.0, -5341], [-13000, 13000]],\
                       [[-1, 1], [-26000,26000], [-13000, 13000]],\
                       [[-1, 1], [-26000,26000], [-13000, 13000]],\
                       [[-1, 1], [-26000,26000], [-13000, 13000]],\
                       [[-1, 1], [-26000,26000], [-13000, 13000]],\
                       [[-1, 1], [-26000,26000], [-13000, 13000]],\
                       [[-1, 1], [-26000,26000], [-13000, 13000]],\
                       [[-1, 1], [-26000,26000], [-13000, 13000]],\
                       [[-1, 1], [-26000,26000], [-13000, 13000]],\
                       [[-1, 1], [-26000,26000], [-13000, 13000]]]
            parbdslistaxallf=[parbdslistaxallf[pickthis]]
            
            
            paramsxx=mainfuncts.parammake(praxs1,0,[x for y,x in enumerate(parbdslistaxallf) if y in pickthese],1,10000,100,900,1,10000)
            conditions=[0,[1,3,3,3,3]]
            #setparameters2=['combo10l.dat','C:\\Users\\Hans\\Desktop\\TRANSFER\\2020Feb\\',[[x for y,x in enumerate(reslall) if y in pickthese]],conditions,namresults]
            namresults=namresultsx+str(resnall[0])+'_'+str(nn)+'_'
            
            poscoll,resnam,allsetcoll,resultcoll,relaxrat0,relaxrat,lookatratio,results,relaxrat1,relaxrat2,relaxrat_1,relaxrat_2,intdiffcorr, intcorr, intmin,ac,oc,rateconstpre,cond=hkio.loadeverything([namresults],0,decoupl=0)
            costcoll=[i.cost for i in resultcoll]
            resultcoll=[resultcoll[np.argsort(costcoll)[0]]]
            paramsxy=mainfuncts.resc2param(praxs1,paramsxx,resultcoll,5)
            list2.append(costcoll[0])
        list1.append(list2)
    return list1
Beispiel #3
0
def produceindivplots(reslallx,resnallx,parbdslistaxallfx,namout,mode,k231,k232):
    for pickthis in np.arange(len(reslallx)):

        reslall=[reslallx[pickthis]]
        resnall=[resnallx[pickthis]]
        pickthese=[0]
        #global praxs1
        praxs1=mainfuncts.praxismake([x for y,x in enumerate(reslall) if y in pickthese],[x for y,x in enumerate(resnall) if y in pickthese])

        parbdslistaxallf=[parbdslistaxallfx[pickthis]]
    
    
        namresults='multix13_k13_ext_0'#######'multindiv_'+str(resnall[0])
        paramsxx=mainfuncts.parammake(praxs1,0,[x for y,x in enumerate(parbdslistaxallf) if y in pickthese],1,10000,100,900,k231,k232)
        conditions=[0,[1,3,3,3,3]]
        #setparameters2=['combo10l.dat','C:\\Users\\Hans\\Desktop\\TRANSFER\\2020Feb\\',[[x for y,x in enumerate(reslall) if y in pickthese]],conditions,namresults]
        poscoll,resnam,allsetcoll,resultcoll,relaxrat0,relaxrat,lookatratio,results,relaxrat1,relaxrat2,relaxrat_1,relaxrat_2,intdiffcorr, intcorr, intmin,ac,oc,rateconstpre,cond=hkio.loadeverything([namresults],0,decoupl=0)
        costcoll=[i.cost for i in resultcoll]
        resultcoll=[resultcoll[np.argsort(costcoll)[0]]]
        paramsxy=mainfuncts.resc2param(praxs1,paramsxx,resultcoll,mode)
        for nn in [0]:#np.arange(3):
            namresultsOUT=namout+str(resnall[0])+'_'+str(nn)+'_'
            setparameters3=['combo10l.dat','C:\\Users\\Hans\\Desktop\\TRANSFER\\2020Feb\\',[[x for y,x in enumerate(reslall) if y in pickthese]],conditions,namresultsOUT,0]
            hkfit2.parallelfit3(praxs1,setparameters3,0,paramsxy[nn])
Beispiel #4
0
               [[-1, 1], [-26000,26000], [-13000, 13000]],\
               [[-1, 1], [-26000,26000], [-13000, 13000]],\
               [[-1, 1], [-26000,26000], [-13000, 13000]],\
               [[-1, 1], [-26000,26000], [-13000, 13000]],\
               [[-1, 1], [-26000,26000], [-13000, 13000]],\
               [[-1, 1], [-26000,26000], [-13000, 13000]]]
    parbdslistaxallf=[parbdslistaxallf[pickthis]]
    paramsxx=mainfuncts.parammake(praxs1,0,[x for y,x in enumerate(parbdslistaxallf) if y in pickthese],1,10000,100,900,1,10000)
    resultcollx=[]
    costcollx=[]
    for nn in np.arange(3):
        namresults='indiv_fix_0_'+str(resnall[0])+'_'+str(nn)+'_'
        
        poscoll,resnam,allsetcoll,resultcoll,relaxrat0,relaxrat,lookatratio,results,relaxrat1,relaxrat2,relaxrat_1,relaxrat_2,intdiffcorr, intcorr, intmin,ac,oc,rateconstpre,cond=hkio.loadeverything([namresults],0,decoupl=0)
        costcoll=[i.cost for i in resultcoll]
        resultcollx.append(resultcoll[np.argsort(costcoll)[0]])
        costcollx.append(resultcoll[np.argsort(costcoll)[0]].cost)
    resultcoll=[resultcollx[np.argsort(costcoll)[0]]]
    paramsxy=mainfuncts.resc2param(praxs1,paramsxx,resultcoll,2)
    dwblist.append(paramsxy[0]['dw'][1]['par'][0])
    dwclist.append(paramsxy[0]['dw'][2]['par'][0])
reslall=['A29','A30','A31','A32','A33','A34','A52','A53','A54','A78','A81','A82','A83','A84','A86']
for j,i in enumerate(reslall):
    print i, int(np.round(dwblist[j],0)), int(np.round(dwclist[j],0))

#%%
from matplotlib import pyplot as plt
reslall=['A29','A30','A31','A32','A33','A34','A52','A53','A54','A78','A81','A82','A83','A84','A86']
fullnamlist=['Ser','Gly', 'Trp', 'Val', 'Trp', 'Asn', 'Gln', 'Phe', 'Phe', 'Val', 'Ile', 'Glu', 'Glu', 'Tyr', 'Thr', 'Gly', 'Pro', 'Asp', 'Pro', 'Val', 'Leu', 'Val', 'Gly', 'Arg', 'Leu', 'His', 'Ser', 'Asp', 'Ile', 'Asp', 'Ser', 'Gly', 'Asp', 'Gly', 'Asn', 'Ile', 'Lys', 'Tyr', 'Ile', 'Leu', 'Ser', 'Gly', 'Glu', 'Gly', 'Ala', 'Gly', 'Thr', 'Ile', 'Phe', 'Val', 'Ile', 'Asp', 'Asp', 'Lys', 'Ser', 'Gly', 'Asn', 'Ile', 'His', 'Ala', 'Thr', 'Lys', 'Thr', 'Leu', 'Asp', 'Arg', 'Glu', 'Glu', 'Arg', 'Ala', 'Gln', 'Tyr', 'Thr', 'Leu', 'Met', 'Ala', 'Gln', 'Ala', 'Val', 'Asp', 'Arg', 'Asp', 'Thr', 'Asn', 'Arg', 'Pro', 'Leu', 'Glu', 'Pro', 'Pro', 'Ser', 'Glu', 'Phe', 'Ile', 'Val', 'Lys', 'Val', 'Gln', 'Asp']
plt.rcParams.update({'font.size': 18})
lab=[];y1=[];y2=[];y3=[];y4=[]
Beispiel #5
0
                              inclfilt=[['residues', 'name', rbc[0]],
                                        ['sites', 'name', 'B']])[0])[0]
        if dnwn == 4 or dnwn == 8 or dnwn == 95:
            print dwb
        if (rbc[1] < 0 and dwb > 0) or (rbc[1] > 0 and dwb < 0):
            #print 'fail', dwb
            dnw += 1
        #else:
        #    print 'pass', dwb
    if dnw == 0:
        print 'all pass', dnwn
    else:
        print 'fail ', dnw, dnwn
        costcoll[dnwn] = costcoll[dnwn] + dnw

ParameterColl2 = [ParameterColl2[i] for i in np.argsort(costcoll)]
costcoll2 = [costcoll[i] for i in np.argsort(costcoll)]

#costcoll=[costcoll[i] for i in np.argsort(costcoll)]

#ParameterColl2[2]['dw'][19]['par']=[-10258.957]
#%%
import plotRD as procall2
import globalfitfunctions as hkfit2
#selnam=[reslalmall[0],reslalmall[1]] #7 symbolic
selnam = ['A30', 'A32', 'A37']  #reslalmall[0],reslalmall[1]] #7 symbolic
selnam = ['A38', 'A45', 'A38']
selnam = [
    'A30', 'A32', 'A37', 'A38', 'A45', 'A50', 'A53', 'A54', 'A73', 'A77',
    'A78', 'A86'
]
def produceindivplots(path2020, savstatdir, datafile, namresults, reslallx,
                      resnallx, parbdslistaxallfx, namout, mode, k121, k122,
                      k131, k132, k231, k232, errruns):
    #print 'a'
    for pickthis in np.arange(len(reslallx)):
        #   print 'b'
        reslall = [reslallx[pickthis]]
        resnall = [resnallx[pickthis]]
        pickthese = [0]
        #  print 'c'
        PropAxesColl = mainfuncts.GeneratePropertyAxesCollection(
            [x for y, x in enumerate(reslall) if y in pickthese],
            [x for y, x in enumerate(resnall) if y in pickthese])
        parbdslistaxallf = [parbdslistaxallfx[pickthis]]
        #paramsxx=mainfuncts.parammake(PropAxesColl,0,[x for y,x in enumerate(parbdslistaxallf) if y in pickthese],1,8000,100,900,k231,k232,0.005,0.1)
        #paramsxx=mainfuncts.parammake(PropAxesColl,0,[x for y,x in enumerate(parbdslistaxallf) if y in pickthese],3000,4000,600,700,k231,k232,0.01,0.02)
        paramsxx = mainfuncts.parammake(
            PropAxesColl, 0,
            [x for y, x in enumerate(parbdslistaxallf) if y in pickthese],
            k121, k122, k131, k132, k231, k232, 0.01, 0.02)
        ##conditions=[0,[1,0,0,5,5]] #individual nitrogen fits
        conditions = [0, [1, 0, 0, 10, 5]]  #individualproton fits
        #setparameters2=['combo10l.dat','C:\\Users\\Hans\\Desktop\\TRANSFER\\2020Feb\\',[[x for y,x in enumerate(reslall) if y in pickthese]],conditions,namresults]
        if namresults == []:
            ParameterColl6 = paramsxx
        else:
            poscoll, resnam, allsetcoll, resultcoll, relaxrat0, relaxrat, lookatratio, results, relaxrat1, relaxrat2, relaxrat_1, relaxrat_2, intdiffcorr, intcorr, intmin, ac, oc, rateconstpre, cond = hkio2.loadeverything(
                savstatdir, [namresults], 0, decoupl=0)
            costcoll = [i.cost for i in resultcoll]
            resultcoll = [resultcoll[np.argsort(costcoll)[0]]]

            ParameterColl6 = mainfuncts.resc2param(PropAxesColl, paramsxx,
                                                   resultcoll, mode)
        for nn in [0]:  #np.arange(3):
            namresultsOUT = namout + str(nn) + '_'
            setparameters3 = [
                datafile, path2020,
                [[x for y, x in enumerate(reslall) if y in pickthese]],
                conditions, namresultsOUT, 0
            ]
            hkfit2.parallelfit3(path2020, savstatdir, setparameters3, 0,
                                ParameterColl6[nn], PropAxesColl)
            dataname = datafile

            setparameters2 = [
                dataname, path2020,
                [x for y, x in enumerate(reslall) if y in pickthese],
                conditions, namresultsOUT
            ]  #,'A34' #'/home/hanskoss/data/Cadherin/nmrCad/procandcoll/TSnewsort/2020Feb/
            selset = 0
            ss = hkfit2.evaluaterdfit(path2020, savstatdir, PropAxesColl,
                                      setparameters2, 1,
                                      ParameterColl6[selset], 0)
            hkio2.savss(savstatdir, ss, namresultsOUT)

            for errc in np.arange(errruns):
                setparameters3 = [
                    datafile, path2020,
                    [[x for y, x in enumerate(reslall) if y in pickthese]],
                    conditions, namresultsOUT + 'err_' + str(errc) + '_',
                    namresultsOUT
                ]
                hkfit2.parallelfit3(path2020, savstatdir, setparameters3, 0,
                                    ParameterColl6[nn], PropAxesColl)
        setparameters3 = [
            'combo10l.dat', path2020,
            [[x for y, x in enumerate(reslall) if y in pickthese]], conditions,
            'FINAL_stage4_23_', 'FINAL_stage3_23x_' + str(runnum)
        ]
        p = multiprocessing.Process(target=hkfit2.parallelfit3,
                                    args=(path2020, savstatdir, setparameters3,
                                          outnum * numrep + runnum,
                                          ParameterColl6[runnum],
                                          PropAxesColl))
    results,relaxrat1,relaxrat2,relaxrat_1,relaxrat_2,intdiffcorr, intcorr,\
    intmin,ac,oc,rateconstpre,cond=hkio2.loadeverything(savstatdir,[namresultsprev],0,decoupl=0)
"""
from the 90 runs, the results of the last step from each of the three 
precalculation attempts is collected. The best 90 (lowest cost) of the 270
collected results are then selected to continue the fit (stage 3b), with 10
documented steps of 5 undocumented fitting substeps.
"""

resultcoll = []
allcostcoll = []
for i in allsetcoll:
    allcostcoll.append([i[j].cost for j in [2, 5, 8]])

allcostcoll = flatten(allcostcoll)
sortedcosts = np.argsort(allcostcoll)

for sel in np.arange(90):
    pos2 = sortedcosts[sel] % 3 * 3 + 2
    pos1 = int(np.floor(sortedcosts[sel] / 3))
    resultcoll.append(allsetcoll[pos1][pos2])
namresults = 'FINAL_stage2b'

ParameterColl2 = mainfuncts.resc2param(PropAxesColl, ParameterColl, resultcoll,
                                       2)
conditions = [0, [1, 0, 0, 10, 5]]
setparameters3 = [
    'combo10l.dat', path2020,
    [[x for y, x in enumerate(reslall) if y in pickthese]], conditions,
    namresults, 0
]