Ejemplo n.º 1
0
def ConstructSegmentForAnalysis(raw_chain):
    """Returns a list of Segment instance from the
    Chain instance which is properly modified for use in
    the this application.
    """
    ## Sets that atm.include attribute for each atom in the chains
    ## being analyzed by tlsmd
    for atm in raw_chain.iter_all_atoms():
        atm.include = atom_selection.calc_include_atom(atm)

    ## ok, use the chain but use a segment and cut off
    ## any leading and trailing non-amino acid residues
    ## do not include a fragment with no included atoms
    naa = raw_chain.count_amino_acids()
    nna = raw_chain.count_nucleic_acids()

    if naa > nna:
        iter_residues = raw_chain.iter_amino_acids()
    elif nna > naa:
        iter_residues = raw_chain.iter_nucleic_acids()
        
    segment = Structure.Segment(chain_id = raw_chain.chain_id)
    for frag in iter_residues:
        for atm in frag.iter_all_atoms():
            if atm.include:
                segment.add_fragment(frag)
                break

    ## apply data smooth if desired
    if conf.globalconf.adp_smoothing > 0:
        adp_smoothing.IsotropicADPDataSmoother(segment, conf.globalconf.adp_smoothing)

    ## this is useful: for each fragment in the minimization
    ## set a attribute for its index position
    for i, frag in enumerate(segment.iter_fragments()):
        frag.ifrag = i

    ## create a TLSModelAnalyzer instance for the chain, and
    ## attach the instance to the chain for use by the rest of the
    ## program
    segment.tls_analyzer = tlsmdmodule.TLSModelAnalyzer()
    xlist = atom_selection.chain_to_xmlrpc_list(segment.iter_all_atoms())
    segment.tls_analyzer.set_xmlrpc_chain(xlist)

    return segment
Ejemplo n.º 2
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
Ejemplo n.º 3
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
Ejemplo n.º 4
0
def ConstructSegmentForAnalysis(raw_chain):
    """Returns a list of Segment instance from the Chain instance which is 
    properly modified for use in the this application.
    """
    console.debug_stdoutln(">tlsmd_analysis->ConstructSegmentForAnalysis(chain %s)" % (
        raw_chain.chain_id))

    ## NOTE: raw_chain = "Chain(1:A, Res(MET,1,A)...Res(VAL,50,A))"
    ## Sets that atm.include attribute for each atom in the chains
    ## being analyzed by tlsmd
    for atm in raw_chain.iter_all_atoms():
        #atm.include = atom_selection.calc_include_atom(atm)
        atm.include = atom_selection.calc_include_atom(atm, reject_messages = True)

    ## ok, use the chain but use a segment and cut off
    ## any leading and trailing non-amino acid residues
    ## do not include a fragment with no included atoms
    naa = nna = ota = 0
    naa = raw_chain.count_amino_acids()
    nna = raw_chain.count_nucleic_acids()
    ota = raw_chain.count_fragments()

    if naa > nna:
        ## Probably a protein with (possibly) some nucleic acids.
        iter_residues = raw_chain.iter_amino_acids()
    elif nna > naa:
        ## Probably a nucleic acid with (possibly) some amino acids.
        iter_residues = raw_chain.iter_nucleic_acids()

    if naa == 0 and nna == 0 and ota > 0:
        ## This chain does not have any amino or nucleic acids, so skip.
        return ""

    segment = Structure.Segment(chain_id = raw_chain.chain_id)

    for frag in iter_residues:
        for atm in frag.iter_all_atoms():
            if atm.include:
                segment.add_fragment(frag)
                break

    ## apply data smooth if desired (default is "0")
    if conf.globalconf.adp_smoothing > 0:
        adp_smoothing.IsotropicADPDataSmoother(segment, 
                                               conf.globalconf.adp_smoothing)

    ## this is useful: for each fragment in the minimization
    ## set an attribute for its index position
    for i, frag in enumerate(segment.iter_fragments()):
        ## NOTE (by Christoph):
        ## Example output:
        ## 0 : Res(MET,1,A)
        ## 1 : Res(ILE,2,A)
        ## ...
        frag.ifrag = i

    ## create a TLSModelAnalyzer instance for the chain, and attach the
    ## instance to the chain for use by the rest of the program
    segment.tls_analyzer = tlsmdmodule.TLSModelAnalyzer()
    xlist = atom_selection.chain_to_xmlrpc_list(segment.iter_all_atoms())
    segment.tls_analyzer.set_xmlrpc_chain(xlist)

    ## INPUT : raw_chain = "Chain(1:A, Res(MET,1,A)...Res(VAL,50,A))"
    ## OUTPUT: segment   = "Segment(1:A, Res(MET,1,A)...Res(VAL,50,A))"
    return segment