Beispiel #1
0
    def fit_to_chain(self, chain):
        """Re-sets all derived information in the TLSSegment.
        """
        ## cut segment from chain using segment ranges
        segments = []
        for frag_id1, frag_id2 in self.segment_ranges:
            segments.append(chain[frag_id1:frag_id2])
        self.segments = segments

        ## put all atoms in the segment into a new TLSGroup instance
        tls_group = TLS.TLSGroup()
        for segment in self.segments:
            for atm in segment.iter_all_atoms():
                if atm.include is True:
                    tls_group.append(atm)
        self.tls_group = tls_group

        if len(self.tls_group) != self.num_atoms():
            console.stderrln(
                "fit_to_chain: EEK! (%s) len(self.tls_group)=%d != self.num_atoms()=%d" % (
                self, len(self.tls_group), self.num_atoms()))
            raise SystemExit

        ## fit the TLS group parameters
        try:
            self.fit_tls_parameters(chain)
        except:
            print console.formatExceptionInfo()

        ## helpful additions
        tls_info  = self.tls_group.calc_tls_info()
        itls_info = TLS.calc_itls_center_of_reaction(
            self.tls_group.itls_T,
            self.tls_group.itls_L,
            self.tls_group.itls_S,
            self.tls_group.origin)

        self.tls_info = tls_info
        self.itls_info = itls_info

        if conf.globalconf.tls_model in ["ISOT", "NLISOT"]:
            self.tls_group.model = "ISOT"
            self.model_tls_info = itls_info
        elif conf.globalconf.tls_model in ["ANISO", "NLANISO"]:
            self.tls_group.model = "ANISO"
            self.model_tls_info = tls_info

        try:
            self.rmsd_b = tls_calcs.calc_rmsd_tls_biso(self.tls_group)
        except:
            print console.formatExceptionInfo()
Beispiel #2
0
    def fit_to_chain(self, chain):
        """Re-sets all derived information in the TLSSegment.
        """
        ## cut segment from chain using segment ranges
        segments = []
        for frag_id1, frag_id2 in self.segment_ranges:
            segments.append(chain[frag_id1:frag_id2])
        self.segments = segments

        ## put all atoms in the segment into a new TLSGroup instance
        tls_group = TLS.TLSGroup()
        for segment in self.segments:
            for atm in segment.iter_all_atoms():
                if atm.include is True:
                    tls_group.append(atm)
        self.tls_group = tls_group

        if len(self.tls_group) != self.num_atoms():
            console.stderrln(
                "fit_to_chain: EEK! (%s) len(self.tls_group)=%d != self.num_atoms()=%d"
                % (self, len(self.tls_group), self.num_atoms()))
            raise SystemExit

        ## fit the TLS group parameters
        try:
            self.fit_tls_parameters(chain)
        except:
            print console.formatExceptionInfo()

        ## helpful additions
        tls_info = self.tls_group.calc_tls_info()
        itls_info = TLS.calc_itls_center_of_reaction(self.tls_group.itls_T,
                                                     self.tls_group.itls_L,
                                                     self.tls_group.itls_S,
                                                     self.tls_group.origin)

        self.tls_info = tls_info
        self.itls_info = itls_info

        if conf.globalconf.tls_model in ["ISOT", "NLISOT"]:
            self.tls_group.model = "ISOT"
            self.model_tls_info = itls_info
        elif conf.globalconf.tls_model in ["ANISO", "NLANISO"]:
            self.tls_group.model = "ANISO"
            self.model_tls_info = tls_info

        try:
            self.rmsd_b = tls_calcs.calc_rmsd_tls_biso(self.tls_group)
        except:
            print console.formatExceptionInfo()
Beispiel #3
0
def FitConstrainedTLSModel(analysis):
    """Calculates constrained TLS model for visualization.
    """
    console.endln()
    console.debug_stdoutln(">tlsmd_analysis->FitConstrainedTLSModel()")
    console.stdoutln("CALCULATING CONSTRAINED TLS MODEL FOR VISUALIZATION")

    ## EAM Feb 2008 User job was getting stuck in fit_to_chain()
    ## Obviously it would be nice to fix the actual error, but at least we would
    ## like to be able to give it a swift non-fatal kick by sending SIGUSR1
    signal.signal(signal.SIGUSR1, SIGUSR1_handler)

    ## Progress tracking 
    ##    - assume this portion of the run occupies 0.1 -> 0.5 of the total time
    progress = 0.1

    for chain in analysis.iter_chains():
        console.stdoutln("CHAIN %s" % (chain.chain_id))
        for cpartition in chain.partition_collection.iter_chain_partitions():
            ## cpartition.chain = "Segment(1:A, Res(MET,1,A)...Res(VAL,50,A))"

            console.stdoutln("TLS GROUPS: %d" % (cpartition.num_tls_segments()))

            for tls in cpartition.iter_tls_segments():
                try:
                    tls.fit_to_chain(cpartition.chain)

                    ## TODO: Write out data for residual plots.
                    #gp = gnuplots.LSQR_vs_TLS_Segments_Pre_Plot(cpartition.chain)
                    #console.stdoutln("FIT_TO_CHAIN_PATH: %s" % analysis.struct2_file_path)

                except (RuntimeError, numpy.linalg.linalg.LinAlgError), e:
                    msg  = "            Runtime error for [%s]: %s, " % (
                        tls, e)
                    msg += "trying to continue..."
                    console.stdoutln(msg)
                    print console.formatExceptionInfo()
                    pass

        ## Track progress
        progress += 0.4/analysis.num_chains()
        progress_report = open("progress","w+")
        print >> progress_report, progress
        ## progress_report.write(progress)
        progress_report.close()
Beispiel #4
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.
    """
    console.debug_stdoutln(">tlsmd_analysis->LoadStructure()")

    ## 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

    ## TODO: Is this the same load struct used during the sanity checks? 2009-05-28
    ## load struct
    struct = FileIO.LoadStructure(file = fobj, distance_bonds = True)
    job_dir = str(os.path.dirname(str(struct_source)))

    console.kvformat("HEADER", struct.header)
    console.kvformat("TITLE", struct.title)
    console.kvformat("EXPERIMENTAL METHOD", struct.experimental_method)
    console.kvformat("PATH", job_dir)

    ## 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:
            try:
                tls_group = tls_desc.construct_tls_group_with_atoms(struct)
            except:
                print console.formatExceptionInfo()

            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