Example #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()
Example #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()
Example #3
0
    def run_gnuplot(self, script):
        """Execute GNUPlot with the given script.
        """
        try:
            pobj = subprocess.Popen([self.gnuplot_path],
                                    stdin = subprocess.PIPE,
                                    stdout = subprocess.PIPE,
                                    stderr = subprocess.STDOUT,
                                    close_fds = True,
                                    bufsize = 8192)
        except OSError:
            console.stderrln("gnuplot failed to execute from path: %s" % (self.gnuplot_path))
            return
            
        pobj.stdin.write(script)
        pobj.stdin.close()
	pobj.stdout.read()
        pobj.stdout.close()
        pobj.wait()
Example #4
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)
Example #5
0
    def run_minimization(self):
        """Run the HCSSSP minimization on the self.V, self.E graph, resulting
        in the creation of the self.D, self.P, and self.T arrays which
        contain 
        """
        chain = self.chain
        chain_id = self.chain.chain_id
        min_subsegment_len = self.min_subsegment_len
        num_vertex = len(chain) + 1

        ## choose the TLS Model to fit for the chain
        fit_method = self.get_fit_method(chain)

        ## build the vertex labels to reflect the protein structure
        ## the graph spans
        vertices = []
        for i in xrange(num_vertex):
            ## add the vertex label for i at Vi
            if i == 0 :
                vertex_label = "N-TERM"
            elif i == num_vertex - 1:
                vertex_label = "C-TERM"
            else:
                vertex_label = "%s{%s:%s}" % (
                    chain_id, chain[i-1].fragment_id, chain[i].fragment_id)
            vertex_label = "V%d[%s]" % (i, vertex_label)
            vertices.append(vertex_label)

        ## fit chain segments with TLS model and build residual graph to 
        ## minimize
        total_num_subsegments = calc_num_subsegments(chain.count_fragments(), 
                                                     min_subsegment_len)
        num_subsegments = 0
        pcomplete = 0
        pcomplete_old = 0
        edges = []
        console.stdoutln("=" * 80)
        console.stdoutln("BUILDING RESIDUAL GRAPH TO MINIMIZE: chain_id=%s" % chain_id)
        for frag_id1, frag_id2, i, j in iter_chain_subsegment_descs(chain, min_subsegment_len):
            tlsdict = fit_method(frag_id1, frag_id2)

            num_subsegments += 1
            pcomplete = round(100.0 * num_subsegments / total_num_subsegments)
            if pcomplete != pcomplete_old:
                console.stdoutln("(%10d/%10d) %2d%% Complete" % (
                    num_subsegments, total_num_subsegments, pcomplete))
                pcomplete_old = pcomplete

            if tlsdict == None:
                console.stderrln("no TLS group %s{%s..%s}" % (
                    chain_id, frag_id1, frag_id2))
                raise SystemExit

            if tlsdict.has_key("error") is True:
                continue

            if not tlsdict.has_key("residual"):
                console.stderrln("no residual! %s{%s..%s}" % (
                    chain_id, frag_id1, frag_id2))
                raise SystemExit

            residual = tlsdict["residual"]
            num_atoms = tlsdict["num_atoms"]
            num_residues = tlsdict["num_residues"]

            if residual < 0.0:
                console.stdoutln("ERROR: Residual is negative!")
                continue

            msd = residual / num_residues
            rmsd = math.sqrt(msd)
            rmsd_b = rmsd * Constants.U2B
            chi2 = msd * num_atoms

            ## XXX: Why is this set to 40? 2010-08-20
            if num_atoms < 40:
                continue

            cost = residual

            frag_range = (frag_id1, frag_id2)
            edge = (i, j, cost, frag_range, tlsdict)
            edges.append(edge)

        console.cpu_time_stdoutln("->ResidualGraphMinimized chain_id=%s: %s" % (
            chain_id, time.clock()))

        ## perform the minimization
        if len(edges) > 0:
            console.stdoutln("HCSSSP Minimizing: chain_id=%s" % (chain_id))

            D, P, T = self.HCSSSP_minimize(vertices, edges, self.nparts)

            self.minimized = True
            self.V = vertices
            self.D = D
            self.P = P
            self.T = T
        else:
            console.stdoutln("HCSSSP Minimizing: Unable to minimize chain_id=%s" % (
                chain_id))
            self.minimized = False
            raise SystemExit

        ## free memory taken up from edges
        edges = None
        gc.collect()