def _bitstrs(tree):
    bitstrs = set()
    term_names = [term.name for term in tree.get_terminals()]
    term_names.sort()
    for clade in tree.get_nonterminals():
        clade_term_names = [term.name for term in clade.get_terminals()]
        boolvals = [name in clade_term_names for name in term_names]
        bitstr = _BitString(''.join(map(str, map(int, boolvals))))
        bitstrs.add(bitstr)
    return bitstrs
Esempio n. 2
0
def _bitstrs(tree):
    bitstrs = set()
    term_names = [term.name for term in tree.get_terminals()]
    term_names.sort()
    for clade in tree.get_nonterminals():
        clade_term_names = [term.name for term in clade.get_terminals()]
        boolvals = [name in clade_term_names for name in term_names]
        bitstr = _BitString("".join(map(str, map(int, boolvals))))
        bitstrs.add(bitstr)
    return bitstrs
def _bitstrs(tree, term_names):
    #function from http://biopython.org/wiki/Phylo
    # store and return all _BitStrings
    bitstrs = set()
    term_names.sort()
    for clade in tree.get_nonterminals():
        clade_term_names = [term.name for term in clade.get_terminals()]
        boolvals = [name in clade_term_names for name in term_names]
        bitstr = _BitString(''.join(map(str, map(int, boolvals))))
        bitstrs.add(bitstr)
    return bitstrs
def _bitstrs(tree,term_names):
    #function from http://biopython.org/wiki/Phylo
    # store and return all _BitStrings    
    bitstrs = set()
    term_names.sort()
    for clade in tree.get_nonterminals():
        clade_term_names = [term.name for term in clade.get_terminals()]
        boolvals = [name in clade_term_names for name in term_names]
        bitstr = _BitString(''.join(map(str, map(int, boolvals))))
        bitstrs.add(bitstr)
    return bitstrs
Esempio n. 5
0
 def test_count_clades(self):
     bitstr_counts = Consensus._count_clades(self.trees)
     self.assertEqual(len(bitstr_counts), 6)
     self.assertEqual(bitstr_counts[_BitString('11111')][0], 3)
     self.assertEqual(bitstr_counts[_BitString('11000')][0], 2)
     self.assertEqual(bitstr_counts[_BitString('00111')][0], 3)
     self.assertEqual(bitstr_counts[_BitString('00110')][0], 2)
     self.assertEqual(bitstr_counts[_BitString('00011')][0], 1)
     self.assertEqual(bitstr_counts[_BitString('01111')][0], 1)
 def test_count_clades(self):
     bitstr_counts = Consensus._count_clades(self.trees)
     self.assertEqual(len(bitstr_counts), 6)
     self.assertEqual(bitstr_counts[_BitString('11111')][0], 3)
     self.assertEqual(bitstr_counts[_BitString('11000')][0], 2)
     self.assertEqual(bitstr_counts[_BitString('00111')][0], 3)
     self.assertEqual(bitstr_counts[_BitString('00110')][0], 2)
     self.assertEqual(bitstr_counts[_BitString('00011')][0], 1)
     self.assertEqual(bitstr_counts[_BitString('01111')][0], 1)
Esempio n. 7
0
 def test_count_clades(self):
     bitstr_counts, len_trees = Consensus._count_clades(self.trees)
     self.assertEqual(len_trees, len(self.trees))
     self.assertEqual(len(bitstr_counts), 6)
     self.assertEqual(bitstr_counts[_BitString("11111")][0], 3)
     self.assertEqual(bitstr_counts[_BitString("11000")][0], 2)
     self.assertEqual(bitstr_counts[_BitString("00111")][0], 3)
     self.assertEqual(bitstr_counts[_BitString("00110")][0], 2)
     self.assertEqual(bitstr_counts[_BitString("00011")][0], 1)
     self.assertEqual(bitstr_counts[_BitString("01111")][0], 1)
Esempio n. 8
0
 def test_bitstring(self):
     bitstr1 = _BitString('0011')
     bitstr2 = _BitString('0101')
     bitstr3 = _BitString('0001')
     bitstr4 = _BitString('0010')
     self.assertRaises(TypeError, _BitString, '10O1')
     self.assertEqual(bitstr1 & bitstr2, _BitString('0001'))
     self.assertEqual(bitstr1 | bitstr2, _BitString('0111'))
     self.assertEqual(bitstr1 ^ bitstr2, _BitString('0110'))
     self.assertFalse(bitstr1.contains(bitstr2))
     self.assertTrue(bitstr1.contains(bitstr1))
     self.assertTrue(bitstr1.contains(bitstr3))
     self.assertTrue(bitstr1.contains(bitstr4))
     self.assertFalse(bitstr1.independent(bitstr2))
     self.assertFalse(bitstr1.independent(bitstr4))
     self.assertTrue(bitstr2.independent(bitstr4))
     self.assertTrue(bitstr3.independent(bitstr4))
     self.assertFalse(bitstr1.iscompatible(bitstr2))
     self.assertTrue(bitstr1.iscompatible(bitstr3))
     self.assertTrue(bitstr1.iscompatible(bitstr4))
     self.assertTrue(bitstr2.iscompatible(bitstr4))
     self.assertTrue(bitstr3.iscompatible(bitstr4))
 def test_bitstring(self):
     bitstr1 = _BitString('0011')
     bitstr2 = _BitString('0101')
     bitstr3 = _BitString('0001')
     bitstr4 = _BitString('0010')
     self.assertRaises(TypeError, _BitString, '10O1')
     self.assertEqual(bitstr1 & bitstr2, _BitString('0001'))
     self.assertEqual(bitstr1 | bitstr2, _BitString('0111'))
     self.assertEqual(bitstr1 ^ bitstr2, _BitString('0110'))
     self.assertFalse(bitstr1.contains(bitstr2))
     self.assertTrue(bitstr1.contains(bitstr1))
     self.assertTrue(bitstr1.contains(bitstr3))
     self.assertTrue(bitstr1.contains(bitstr4))
     self.assertFalse(bitstr1.independent(bitstr2))
     self.assertFalse(bitstr1.independent(bitstr4))
     self.assertTrue(bitstr2.independent(bitstr4))
     self.assertTrue(bitstr3.independent(bitstr4))
     self.assertFalse(bitstr1.iscompatible(bitstr2))
     self.assertTrue(bitstr1.iscompatible(bitstr3))
     self.assertTrue(bitstr1.iscompatible(bitstr4))
     self.assertTrue(bitstr2.iscompatible(bitstr4))
     self.assertTrue(bitstr3.iscompatible(bitstr4))