Exemplo n.º 1
0
def LoadStructure(struct_source):
    """Loads Structure, chooses a unique struct_id string.
    Also, search the REMARK records for TLS group records.  If they
    are found, then add the TLS group ADP magnitude to the B facors of
    the ATOM records.
    """
    ## determine the argument type
    if isinstance(struct_source, str):
        file_path = struct_source
        console.kvformat("LOADING STRUCTURE", file_path)
        fobj = open(file_path, "r")
    elif hasattr(struct_source, "__iter__") and hasattr(struct_source, "seek"):
        console.kvformat("LOADING STRUCTURE", str(struct_source))
        fobj = struct_source
    else:
        raise ValueError

    ## load struct
    struct = FileIO.LoadStructure(file = fobj, distance_bonds = True)

    console.kvformat("HEADER", struct.header)
    console.kvformat("TITLE", struct.title)
    console.kvformat("EXPERIMENTAL METHOD", struct.experimental_method)
    
    ## set the structure ID
    if conf.globalconf.struct_id is not None:
        struct_id = conf.globalconf.struct_id
    else:
        struct_id = struct.structure_id
        conf.globalconf.struct_id = struct_id
    struct.structure_id = struct_id

    console.endln()

    ## if there are REFMAC5 TLS groups in the REMARK records of
    ## the PDB file, then add those in
    tls_file = TLS.TLSFile()
    tls_file.set_file_format(TLS.TLSFileFormatPDB())

    ## return to the beginning of the file and read the REMARK/TLS records
    fobj.seek(0)
    tls_file.load(fobj)

    if len(tls_file.tls_desc_list) > 0:
        console.stdoutln("ADDING TLS GROUP Bequiv TO ATOM TEMPERATURE FACTORS")
        console.stdoutln("    NUM TLS GROUPS: %d" % (len(tls_file.tls_desc_list)))

        ## assume REFMAC5 groups where Utotal = Utls + Biso(temp_factor)
        for tls_desc in tls_file.tls_desc_list:
            tls_group = tls_desc.construct_tls_group_with_atoms(struct)
            console.stdoutln("    TLS GROUP: %s" % (tls_group.name))
            for atm, Utls in tls_group.iter_atm_Utls():
                bresi = atm.temp_factor
                atm.temp_factor = bresi + (Constants.U2B * numpy.trace(Utls) / 3.0)
                atm.U = (Constants.B2U * bresi * numpy.identity(3, float)) + Utls

        console.endln()

    return struct
Exemplo n.º 2
0
    def prnt_settings(self):
        chain_ids = []
        for chain in self.chains:
            chain_ids.append(chain.chain_id)
        cids = ",".join(chain_ids)

        console.kvformat("STRUCTURE ID", self.struct_id)
        console.kvformat("CHAIN IDs SELECTED FOR ANALYSIS", cids)
        console.endln()
Exemplo n.º 3
0
    def prnt_settings(self):
        chain_ids = []
        for chain in self.chains:
            chain_ids.append(chain.chain_id)
        cids = ",".join(chain_ids)

        console.debug_stdoutln(">tlsmd_analysis->TLSMDAnalysis()")
        console.kvformat("STRUCTURE ID", self.struct_id)
        console.kvformat("CHAIN IDs SELECTED FOR ANALYSIS", cids)
        console.endln()
Exemplo n.º 4
0
    def select_chains(self):
        """Selects chains for analysis.
        """
        ## select viable chains for TLS analysis
        segments = []

        for chain in self.struct.iter_chains():
            ## if self.sel_chain_ids is set, then only use those
            ## selected chain ids
            if self.sel_chain_ids is not None:
                if chain.chain_id not in self.sel_chain_ids:
                    continue

            ## count the number of amino acid and/or nucleic acid residues in
            ## the chain and skip those that are too small
            ## also, warn the user if a chain contains non-standard residue
            ## types
            naa = chain.count_amino_acids()
            nna = chain.count_nucleic_acids()
            non = chain.count_non_standard_residues()

            if nna == 0 and (naa > 0 and naa < conf.MIN_AMINO_PER_CHAIN):
                console.kvformat("SKIPPING SMALL AMINO ACID CHAIN", 
                    chain.chain_id)
                continue

            if naa == 0 and (nna > 0 and nna < conf.MIN_NUCLEIC_PER_CHAIN):
                console.kvformat("SKIPPING SMALL NUCLEIC ACID CHAIN", 
                    chain.chain_id)
                continue

            if naa > nna and nna > 0:
                console.kvformat("CHAIN WITH DIFFERENT RESIDUE TYPES",
                    chain.chain_id)

            if non > 0:
                console.kvformat("CHAIN WITH NON-STANDARD RESIDUE TYPES",
                    chain.chain_id)

            num_frags = max(naa, nna)

            segment = ConstructSegmentForAnalysis(chain)
            if segment == "":
                console.kvformat("SKIPPING CHAIN WITH NO AA/NA RESIDUES",
                    chain.chain_id)
                continue

            segments.append(segment)
            segment.struct = self.struct

        self.chains = segments
Exemplo n.º 5
0
 def prnt(self):
     console.stdoutln("TLS Motion Determination (TLSMD) Version %s" % (const.VERSION))
     console.endln()
     console.kvformat("TLS PARAMETER FIT ENGINE", self.tls_model)
     console.kvformat("MIN_SUBSEGMENT_SIZE", self.min_subsegment_size)
     console.kvformat("ATOM B-FACTOR WEIGHT_MODEL", self.weight_model)
     console.kvformat("PROTEIN ATOMS CONSIDERED", self.include_atoms)
     console.endln()
Exemplo n.º 6
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
Exemplo n.º 7
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
Exemplo n.º 8
0
def SumperimposeHomologousStructure(analysis):
    """
    """
    import structcmp

    target_struct = FileIO.LoadStructure(fil = analysis.struct2_file_path)
    target_chain = target_struct.get_chain(analysis.struct2_chain_id)

    if target_chain is None:
        console.stderrln(
            "UNABLE TO LOAD TARGET STRUCTURE/CHAIN: %s:%s" % (
            target_struct, target_chain))
        return

    analysis.target_chain = target_chain

    for chain in analysis.iter_chains():
        console.endln()
        console.kvformat("Superimposing Chain", chain.chain_id)
        hyp = structcmp.TLSConformationPredctionHypothosis(chain, target_chain)
        for ntls, cpartition in chain.partition_collection.iter_ntls_chain_partitions():
            console.endln()
            console.stdoutln("Number of TLS Segments........: %d" % (ntls))
            hyp.add_conformation_prediction_to_chain_partition(cpartition)