示例#1
0
    def write_tlsout_file(self, chain, cpartition):
        """Writes the TLSOUT file for the segmentation.
        """
        basename = "%s_CHAIN%s_NTLS%d" % (self.struct_id, chain.chain_id,
                                          cpartition.num_tls_segments())
        tlsout_path = "%s.tlsout" % (basename)

        struct_id = self.struct_id
        chain_id = chain.chain_id

        tls_file = TLS.TLSFile()
        tls_file.set_file_format(TLS.TLSFileFormatTLSOUT())

        for tls in cpartition.iter_tls_segments():
            ## don't write out bypass edges
            if tls.method != "TLS":
                continue

            tls_desc = TLS.TLSGroupDesc()
            tls_file.tls_desc_list.append(tls_desc)
            tls_desc.set_tls_group(tls.tls_group)
            for frag_id1, frag_id2 in tls.iter_segment_ranges():
                tls_desc.add_range(chain_id, frag_id1, chain_id, frag_id2,
                                   "ALL")

        tls_file.save(open(tlsout_path, "w"))

        return tlsout_path
示例#2
0
def main(path, opt_dict):
    struct = FileIO.LoadStructure(file=path)

    tls_group_list = []

    ## make the TLS groups
    if opt_dict.has_key("-t"):

        try:
            fil = open(opt_dict["-t"], "r")
        except IOError:
            print "[ERROR]: TLSIN File not found %s" % (opt_dict["-t"])
            sys.exit(-1)

        tls_file = TLS.TLSFile()
        tls_file.set_file_format(TLS.TLSFileFormatTLSOUT())
        tls_file.load(fil)

        for tls_desc in tls_file.tls_desc_list:
            tls = tls_desc.construct_tls_group_with_atoms(struct)
            tls.tls_desc = tls_desc
            tls_group_list.append(tls)

    else:
        ## create one TLS group per chain by default
        for chain in struct.iter_chains():
            if chain.count_amino_acids() < 10:
                continue

            try:
                chain_id1 = chain.chain_id
                frag_id1 = chain[0].fragment_id
                frag_id2 = chain[-1].fragment_id
            except IndexError:
                continue

            tls_desc = TLS.TLSGroupDesc()
            tls_desc.add_range(chain_id1, frag_id1, chain_id1, frag_id2, "ALL")
            tls = tls_desc.construct_tls_group_with_atoms(struct)
            tls_group_list.append(tls)
            tls.tls_desc = tls_desc

            print "Creating TLS Group: %s" % (tls.name)

    ## fit TLS groups and write output
    tls_file = TLS.TLSFile()
    tls_file.set_file_format(TLS.TLSFileFormatTLSOUT())

    ## preform a LSQ fit if necessary
    for tls in tls_group_list:

        print "[TLS GROUP  %s]" % (tls.name)

        ## if the TLS group is null, then perform a LSQ-TLS fit
        if tls.is_null():
            print "Null Group: Running TLS-LSQ"

            if len(tls) < 20:
                print "ERROR: Not Enough Atoms in TLS Group."
                continue

            tls.origin = tls.calc_centroid()
            lsq_residual = tls.calc_TLS_least_squares_fit()
            tls.shift_COR()

        tls.tls_desc.set_tls_group(tls)
        tls_file.tls_desc_list.append(tls.tls_desc)

    if opt_dict.has_key("-o"):
        print "Saving TLSIN: %s" % (opt_dict["-o"])
        tls_file.save(open(opt_dict["-o"], "w"))

    ## write out a PDB file with 0.0 tempature factors for all
    ## atoms in TLS groups
    if opt_dict.has_key("-p"):

        for tls in tls_group_list:
            for atm, Utls in tls.iter_atm_Utls():
                if opt_dict.has_key("-s"):
                    atm.temp_factor = 0.0
                    atm.U = None
                else:
                    atm.temp_factor = Constants.U2B * numpy.trace(Utls) / 3.0
                    atm.U = Utls

        ## save the struct
        print "Saving XYZIN: %s" % (opt_dict["-p"])
        FileIO.SaveStructure(file=opt_dict["-p"], struct=struct)
示例#3
0
def main(path, opt_dict):
    struct = FileIO.LoadStructure(file = path)

    tls_group_list = []

    ## make the TLS groups
    if opt_dict.has_key("-t"):

        try:
            fil = open(opt_dict["-t"], "r")
        except IOError:
            print "ERROR: TLSIN File not found %s" % (opt_dict["-t"])
            sys.exit(-1)
        
        tls_file = TLS.TLSFile()
        tls_file.set_file_format(TLS.TLSFileFormatTLSOUT())
        tls_file.load(fil)
        
        for tls_desc in tls_file.tls_desc_list:
            #tls = tls_desc.generate_tls_group(struct) ## old def
            tls = tls_desc.construct_tls_group_with_atoms(struct)
            tls.tls_desc = tls_desc
            tls_group_list.append(tls)
            print tls.name

    else:
        tls_desc = TLS.TLSGroupDesc()
        tls_desc.add_range("A", "1", "A", "25", "ALL")
        tls_group = tls_desc.construct_tls_group_with_atoms(struct)
        tls_group_list.append(tls_group)
        tls_group.tls_desc = tls_desc

        tls_group.origin = tls_group.calc_centroid()
        tls_group.T = rt_random(T1)
        tls_group.L, tls_group.S = rt_random2(L1, S1)

        tls_desc = TLS.TLSGroupDesc()
        tls_desc.add_range("A", "26", "A", "35", "ALL")
        tls_group = tls_desc.construct_tls_group_with_atoms(struct)
        tls_group_list.append(tls_group)
        tls_group.tls_desc = tls_desc

        tls_group.origin = tls_group.calc_centroid()
        tls_group.T = rt_random(T2)
        tls_group.L, tls_group.S = rt_random2(L2, S1)
        
        tls_desc = TLS.TLSGroupDesc()
        tls_desc.add_range("A", "36", "A", "52", "ALL")
        tls_group = tls_desc.construct_tls_group_with_atoms(struct)
        tls_group_list.append(tls_group)
        tls_group.tls_desc = tls_desc

        tls_group.origin = tls_group.calc_centroid()
        tls_group.T = rt_random(T3)
        tls_group.L, tls_group.S = rt_random2(L3, S1)

    for atm in struct.iter_all_atoms():
        atm.U = None

    ## write out ideal TLS ANISOU records
    if opt_dict.has_key("-p"):
        for tls_group in tls_group_list:
            for atm, Utls in tls_group.iter_atm_Utls():
                atm.temp_factor = Constants.U2B * (numpy.trace(Utls) / 3.0)
                atm.U = Utls
                
        ## save the struct
        FileIO.SaveStructure(file = opt_dict["-p"], struct = struct)