Ejemplo n.º 1
0
    def remove_tumor_and_rename_decomposed(
            self, tumor2seqs_with_decompose, seqs_with_ancestor, tumor_seqs,
            REP, clone_frequency_for_seqs_with_ancestor):
        Align = MegaAlignment()
        SeqOrderIni, IniMeg2Seq = Align.name2seq(seqs_with_ancestor)
        TuLs, TuMeg2Seq = Align.name2seq(tumor_seqs)
        SNVNum = len(TuMeg2Seq[TuLs[0]])
        IdenLs = Align.identify_similar_seq(tumor_seqs, 0)
        Tu2IdenTu = Align.make_similar_seq_dic(IdenLs)
        outAllSeq = ['MEGA', '!Title SNVs;', '!Format datatype=dna;', ' ']
        RmCloLs = []
        for Tu in tumor2seqs_with_decompose:
            DeComCloLs = tumor2seqs_with_decompose[Tu]
            if DeComCloLs != []:
                IdenTu = Tu2IdenTu['T-' + Tu]
                RmCloLs += IdenTu
        RmCloLs = list(set(RmCloLs))
        Done = []
        for Tu in tumor2seqs_with_decompose:
            DeComCloLs = tumor2seqs_with_decompose[Tu]
            if RmCloLs.count(Tu) == 0:
                if Done.count('#' + Tu) == 0:
                    outAllSeq += ['#' + Tu, TuMeg2Seq['#' + Tu]]
                    Done.append('#' + Tu)
            if DeComCloLs != []:
                DecomCloOrder, Clu2Seq = Align.name2seq(DeComCloLs)
                for Clu in Clu2Seq:
                    Seq = Clu2Seq[Clu]
                    TuClu = Clu[1:].split('Clu')[0]
                    Code = TuClu in RmCloLs
                    if Code != True and Clu.find('#Node') == -1:
                        if Clu.find('#Clu') != -1:
                            Clu = '#' + Tu + Clu[1:] + 'REP' + str(REP)
                        if Done.count(Clu) == 0:
                            outAllSeq += [Clu, Seq]
                            Done.append(Clu)
            else:

                HitCloLs = clone_frequency_for_seqs_with_ancestor['T-' + Tu]
                for Clo in HitCloLs:
                    if HitCloLs[Clo] > 0:
                        TuClo = Clo.split('Clu')[0]
                        Code = TuClo in RmCloLs
                        if Code != True and Clo[:4] != 'Node':
                            if Done.count('#' + Clo) == 0:
                                outAllSeq += ['#' + Clo, IniMeg2Seq['#' + Clo]]
                                Done.append('#' + Clo)

        outAllSeq_without_redindant = Align.RmRedunSeq(outAllSeq)
        outAllSeq_without_redindant += ['#hg19', ('A' * SNVNum)]
        return outAllSeq_without_redindant
    def __init__(self, cluster_information, original_seq, tumor_seq, tsp_list,
                 clone_frequency_cutoff, CNV_info, ReadCountTable):
        self.Tu2Cluster = cluster_information
        self.CNV_info = CNV_info
        self.ReadCountTable = ReadCountTable
        Align = MegaAlignment()
        self.OriAncOrder, self.OriAnc2Seq0 = Align.name2seq(original_seq)
        self.TOrder, self.T2Seq = Align.name2seq(tumor_seq)
        self.SharePosi = Align.GetSharePosi1(self.OriAnc2Seq0, 'T')
        self.all_tsp = tsp_information(tsp_list)
        self.CloFreCutOff = clone_frequency_cutoff
        self.v_obs = self.all_tsp.tumor2alt_frequency()
        identical_seq_list = Align.identify_similar_seq(tumor_seq, 0)
        self.identical_seq = Align.make_similar_seq_dic(identical_seq_list)

        self.freq_cutoff = self.CloFreCutOff