def __init__(self, full_length_lineage, min_rel_abundance,
              min_abs_abundance):
     self.full_length_lineage = full_length_lineage
     self.min_rel_abundance = min_rel_abundance  # float number from 0 to 1
     self.min_abs_abundance = min_abs_abundance
     self.aa_dict = amino_acid_utils.AminoAcidDict()
     self.aa_dict.AddLineage(full_length_lineage)
 def _InitEdges(self):
     self.aa_dict = amino_acid_utils.AminoAcidDict()
     self.aa_dict.AddClonalTree(self.clonal_tree)
     self.used_aa = []
     self.aa_edges = dict()
     self.vertex_indices = set()
     self.num_edges = 0
     for v in self.clonal_tree.VertexIter():
         v_id = self.clonal_tree.GetSequenceByVertex(v).id
         v_aa = self.aa_dict.GetAAById(v_id)
         v_index = self.aa_dict.GetIndexByAA(v_aa)
         self.vertex_indices.add(v_index)
     for e in self.clonal_tree.EdgeIter():
         self.num_edges += 1
         src_id = self.clonal_tree.GetSequenceByVertex(e[0]).id
         dst_id = self.clonal_tree.GetSequenceByVertex(e[1]).id
         src_aa = self.aa_dict.GetAAById(src_id)
         dst_aa = self.aa_dict.GetAAById(dst_id)
         src_index = self.aa_dict.GetIndexByAA(src_aa)
         dst_index = self.aa_dict.GetIndexByAA(dst_aa)
         #            self.vertex_indices.add(src_index)
         #            self.vertex_indices.add(dst_index)
         if src_aa == dst_aa:
             continue
         aa_edge = (src_index, dst_index)
         if aa_edge not in self.aa_edges:
             self.aa_edges[aa_edge] = 0
         self.aa_edges[aa_edge] += 1
     print "# amino acid vertices: " + str(len(self.vertex_indices))
    def __init__(self, full_length_lineage, min_rel_abundance, min_abs_abundance):
        self.full_length_lineage = full_length_lineage
        self.min_rel_abundance = min_rel_abundance # float number from 0 to 1
        self.min_abs_abundance = min_abs_abundance
        self.aa_dict = amino_acid_utils.AminoAcidDict()
        self.aa_dict.AddLineage(full_length_lineage)
        abundant_aa_seqs = []
        for aa in self.aa_dict:
            if float(self.aa_dict.GetAAMultiplicity(aa)) / len(full_length_lineage) < self.min_rel_abundance or self.aa_dict.GetAAMultiplicity(aa) < min_abs_abundance:
                continue
#            print 'adding aa with multiplicity ' + str(self.aa_dict.GetAAMultiplicity(aa))
            seq_ids = self.aa_dict.GetIdsByAA(aa)
            seqs = [self.full_length_lineage.GetFullLengthSequenceByName(seq_id) for seq_id in seq_ids]
            abundant_aa_seqs.extend(seqs)
        self.seqs = []
        self.seqs.append(abundant_aa_seqs)