示例#1
0
def IsotropicADPDataSmoother(chain, num_smooth = 1):
    """Experimental data smoothing of temperature factors.
    """
    console.endln()
    console.stdoutln("SMOOTHING CHAIN %s ADPs" % (chain.chain_id))
    console.kvformat("SMOOTH WINDOW", 2 * num_smooth + 1)

    num_frags = len(chain)

    smooth_uiso = dict()
    ifrag_start = num_smooth
    ifrag_end = num_frags - num_smooth - 1

    for ifrag in xrange(ifrag_start, ifrag_end + 1):
        smooth_frag = chain[ifrag]
        frag1 = chain[ifrag - num_smooth]
        frag2 = chain[ifrag + num_smooth]

        IT, IL, IS, IOrigin = IsotropicFitSegmentOutlierRejection(
            chain, frag1.fragment_id, frag2.fragment_id)

        for atm, uiso in TLS.iter_itls_uiso(smooth_frag.iter_all_atoms(), 
                                            IT, IL, IS, IOrigin):
            smooth_uiso[atm] = uiso

        if ifrag == ifrag_start:
            for i in range(ifrag_start):
                smooth_frag = chain[i]
                for atm, uiso in TLS.iter_itls_uiso(smooth_frag.iter_all_atoms(),
                                                    IT, IL, IS, IOrigin):
                    smooth_uiso[atm] = uiso
        elif ifrag == ifrag_end:
            for i in range(ifrag_end + 1, num_frags):
                smooth_frag = chain[i]
                for atm, uiso in TLS.iter_itls_uiso(smooth_frag.iter_all_atoms(),
                                                    IT, IL, IS, IOrigin):
                    smooth_uiso[atm] = uiso

    for atm, uiso in smooth_uiso.iteritems():
        atm.temp_factor = Constants.U2B * uiso
        atm.U = numpy.identity(3, float) * uiso
示例#2
0
def IsotropicADPDataSmoother(chain, num_smooth=1):
    """Experimental data smoothing of temperature factors
    """
    console.endln()
    console.stdoutln("SMOOTHING CHAIN %s ADPs" % (chain.chain_id))
    conesole.kvformat("SMOOTH WINDOW", 2 * num_smooth + 1)

    num_frags = len(chain)

    smooth_uiso = dict()
    ifrag_start = num_smooth
    ifrag_end = num_frags - num_smooth - 1

    for ifrag in xrange(ifrag_start, ifrag_end + 1):
        smooth_frag = chain[ifrag]
        frag1 = chain[ifrag - num_smooth]
        frag2 = chain[ifrag + num_smooth]

        IT, IL, IS, IOrigin = IsotropicFitSegmentOutlierRejection(
            chain, frag1.fragment_id, frag2.fragment_id)

        for atm, uiso in TLS.iter_itls_uiso(smooth_frag.iter_all_atoms(), IT,
                                            IL, IS, IOrigin):
            smooth_uiso[atm] = uiso

        if ifrag == ifrag_start:
            for i in range(ifrag_start):
                smooth_frag = chain[i]
                for atm, uiso in TLS.iter_itls_uiso(
                        smooth_frag.iter_all_atoms(), IT, IL, IS, IOrigin):
                    smooth_uiso[atm] = uiso
        elif ifrag == ifrag_end:
            for i in range(ifrag_end + 1, num_frags):
                smooth_frag = chain[i]
                for atm, uiso in TLS.iter_itls_uiso(
                        smooth_frag.iter_all_atoms(), IT, IL, IS, IOrigin):
                    smooth_uiso[atm] = uiso

    for atm, uiso in smooth_uiso.iteritems():
        atm.temp_factor = Constants.U2B * uiso
        atm.U = numpy.identity(3, float) * uiso
示例#3
0
def ResidualInfo(chain, range, tlsdict):
    IT, IL, IS, IO = tls_calcs.isotlsdict2tensors(tlsdict)

    num_atoms = 0
    weight_sum = 0.0
    msd_sum = 0.0
    atomiter = iter_fragment_atoms(chain.iter_fragments(*range))
    for atm, uiso_tls in TLS.iter_itls_uiso(atomiter, IT, IL, IS, IO):
        num_atoms += 1
        delta = atm.temp_factor - (Constants.U2B * uiso_tls)
        msd_sum += atm.occupancy * delta**2
        weight_sum += atm.occupancy
    msd = msd_sum / weight_sum
    return msd
示例#4
0
def ResidualInfo(chain, range, tlsdict):
    IT, IL, IS, IO = tls_calcs.isotlsdict2tensors(tlsdict)

    num_atoms = 0
    weight_sum = 0.0
    msd_sum = 0.0
    atomiter = iter_fragment_atoms(chain.iter_fragments(*range))
    for atm, uiso_tls in TLS.iter_itls_uiso(atomiter, IT, IL, IS, IO):
        num_atoms += 1
        delta = atm.temp_factor - (Constants.U2B * uiso_tls)
        msd_sum += atm.occupancy * delta**2
        weight_sum += atm.occupancy
    msd = msd_sum / weight_sum
    return msd
示例#5
0
def calc_rmsd_tls_biso(tls_group):
    """Calculate the RMSD of the tls_group using the isotropic TLS model.
    """
    T = tls_group.itls_T
    L = tls_group.itls_L
    S = tls_group.itls_S
    O = tls_group.origin

    msd_sum = 0.0
    
    for atm, uiso_tls in TLS.iter_itls_uiso(iter(tls_group), T, L, S, O):
        msd_sum += (Constants.U2B*uiso_tls - atm.temp_factor)**2
        
    if len(tls_group)>0:
        msd = msd_sum / len(tls_group)
        rmsd = math.sqrt(msd)
    else:
        rmsd = 0.0

    return rmsd
示例#6
0
def IsotropicFitSegmentOutlierRejection(chain, frag_id1, frag_id2):
    segment = chain[frag_id1:frag_id2]
    atoms = list(segment.iter_all_atoms())

    orig_num_atoms = len(atoms)
    rejected = 0

    while True:
        tls_analyzer = tlsmdmodule.TLSModelAnalyzer()
        xlist = atom_selection.chain_to_xmlrpc_list(iter(atoms))
        tls_analyzer.set_xmlrpc_chain(xlist)

        tlsdict = tls_analyzer.isotropic_fit_segment(frag_id1, frag_id2)
        IT, IL, IS, IOrigin = tls_calcs.isotlsdict2tensors(tlsdict)

        num_atoms = 0
        msd_sum = 0.0
        atm_deltab = []

        for atm, uiso in TLS.iter_itls_uiso(iter(atoms), IT, IL, IS, IOrigin):
            num_atoms += 1
            deltab = atm.temp_factor - (Constants.U2B * uiso)
            msd_sum += deltab**2
            atm_deltab.append((deltab, atm))

        sigma = math.sqrt((msd_sum / num_atoms))
        sigma2 = 2.0 * sigma

        outliers = 0
        for deltab, atm in atm_deltab:
            if abs(deltab) > sigma2:
                atoms.remove(atm)
                outliers += 1

        rejected += outliers

        if outliers == 0 or (num_atoms - outliers) < 10:
            console.stdoutln("SEGMENT %s-%s %d->%d" %
                             (frag_id1, frag_id2, orig_num_atoms,
                              orig_num_atoms - rejected))
            return IT, IL, IS, IOrigin
示例#7
0
def IsotropicFitSegmentOutlierRejection(chain, frag_id1, frag_id2):
    segment = chain[frag_id1:frag_id2]
    atoms = list(segment.iter_all_atoms())

    orig_num_atoms = len(atoms)
    rejected = 0

    while True:
        tls_analyzer = tlsmdmodule.TLSModelAnalyzer()
        xlist = atom_selection.chain_to_xmlrpc_list(iter(atoms))
        tls_analyzer.set_xmlrpc_chain(xlist)

        tlsdict = tls_analyzer.isotropic_fit_segment(frag_id1, frag_id2)
        IT, IL, IS, IOrigin = tls_calcs.isotlsdict2tensors(tlsdict)

        num_atoms = 0
        msd_sum = 0.0
        atm_deltab = []

        for atm, uiso in TLS.iter_itls_uiso(iter(atoms), IT, IL, IS, IOrigin):
            num_atoms += 1;
            deltab = atm.temp_factor - (Constants.U2B * uiso)
            msd_sum += deltab**2
            atm_deltab.append((deltab, atm))

        sigma = math.sqrt((msd_sum / num_atoms))
        sigma2 = 2.0 * sigma

        outliers = 0
        for deltab, atm in atm_deltab:
            if abs(deltab) > sigma2:
                atoms.remove(atm)
                outliers += 1

        rejected += outliers

        if outliers == 0 or (num_atoms - outliers) < 10:
            console.stdoutln("SEGMENT %s-%s %d->%d" % (
                frag_id1, frag_id2, orig_num_atoms, orig_num_atoms - rejected))
            return IT, IL, IS, IOrigin