コード例 #1
0
def tree_twoway_counts(tree, alphabet=DnaPairs, average=True, attr='Sequence'):
    """From tree, return dict of Count objects.

    Note: if average is True, only has counts in m[i,j] or m[j,i], not both.
    """
    leaves = list(tree.traverse())
    result = {}
    if average:
        #return symmetric matrix
        for first, second in two_item_combos(leaves):
            seq_1 = getattr(first, attr)
            seq_2 = getattr(second, attr)
            result[(first.Id, second.Id)] = \
                Counts.fromPair(seq_1, seq_2, alphabet)
    else:
        for first, second in two_item_combos(leaves):
            seq_1 = getattr(first, attr)
            seq_2 = getattr(second, attr)
            result[(first.Id, second.Id)] = \
                Counts.fromPair(seq_1, seq_2, alphabet,False)
            result[(second.Id, first.Id)] = \
                Counts.fromPair(seq_2, seq_1, alphabet,False)
    return result
コード例 #2
0
ファイル: analysis.py プロジェクト: chungtseng/pycogent
def tree_twoway_counts(tree, alphabet=DnaPairs, average=True, attr='Sequence'):
    """From tree, return dict of Count objects.

    Note: if average is True, only has counts in m[i,j] or m[j,i], not both.
    """
    leaves = list(tree.traverse())
    result = {}
    if average:
        #return symmetric matrix
        for first, second in two_item_combos(leaves):
            seq_1 = getattr(first, attr)
            seq_2 = getattr(second, attr)
            result[(first.Id, second.Id)] = \
                Counts.fromPair(seq_1, seq_2, alphabet)
    else:
        for first, second in two_item_combos(leaves):
            seq_1 = getattr(first, attr)
            seq_2 = getattr(second, attr)
            result[(first.Id, second.Id)] = \
                Counts.fromPair(seq_1, seq_2, alphabet,False)
            result[(second.Id, first.Id)] = \
                Counts.fromPair(seq_2, seq_1, alphabet,False)
    return result
コード例 #3
0
ファイル: test_svd.py プロジェクト: blankenberg/pycogent
 def test_two_item_combos(self):
     """two_item_combos should return items in correct order"""
     items = list(two_item_combos("abcd"))
     self.assertEqual(items, map(tuple, ["ab", "ac", "ad", "bc", "bd", "cd"]))
コード例 #4
0
ファイル: test_svd.py プロジェクト: mikerobeson/pycogent
 def test_two_item_combos(self):
     """two_item_combos should return items in correct order"""
     items = list(two_item_combos('abcd'))
     self.assertEqual(items, map(tuple,
                                 ['ab', 'ac', 'ad', 'bc', 'bd', 'cd']))
コード例 #5
0
ファイル: test_svd.py プロジェクト: miklou/pycogent
 def test_two_item_combos(self):
     """two_item_combos should return items in correct order"""
     items = list(two_item_combos('abcd'))
     self.assertEqual(items, map(tuple, ['ab','ac','ad','bc','bd','cd']))