Esempio n. 1
0
    def test_combinations(self):
        comb52 = list(collider.combinations( range(5), 2 ) )
        self.assertEqual(comb52, [
            (0, 1),
            (0, 2),
            (0, 3),
            (0, 4),
            (1, 2),
            (1, 3),
            (1, 4),
            (2, 3),
            (2, 4),
            (3, 4)
        ])
        comb53 = list(collider.combinations( range(5), 3 ) )
        self.assertEqual( comb53, [
            (0, 1, 2),
            (0, 1, 3),
            (0, 1, 4),
            (0, 2, 3), 
            (0, 2, 4),
            (0, 3, 4),
            (1, 2, 3),
            (1, 2, 4),
            (1, 3, 4),
            (2, 3, 4)
        ])

        # now also test the before 2.6 version

        comb52 = list(collider.combinations( range(5), 2, True ) )
        self.assertEqual(comb52, [
            (0, 1),
            (0, 2),
            (0, 3),
            (0, 4),
            (1, 2),
            (1, 3),
            (1, 4),
            (2, 3),
            (2, 4),
            (3, 4)
        ])
        comb53 = list(collider.combinations( range(5), 3, True ) )
        self.assertEqual( comb53, [
            (0, 1, 2),
            (0, 1, 3),
            (0, 1, 4),
            (0, 2, 3), 
            (0, 2, 4),
            (0, 3, 4),
            (1, 2, 3),
            (1, 2, 4),
            (1, 3, 4),
            (2, 3, 4)
        ])
Esempio n. 2
0
def get_all_modifications(this_sequence, to_modify, replace_with, max_nr_modifications):
    import re
    positions = [m.start() for m in re.finditer(to_modify, this_sequence)]
    for i in range(1,min(max_nr_modifications,1+len(positions))):
        to_replace = list(collider.combinations( positions, i))
        for new_peptide in to_replace:
            it = 0
            curr_seq = ''
            for pos in new_peptide:
                curr_seq += this_sequence[it:pos] + replace_with
                it = pos+1
            curr_seq += this_sequence[it:]
            pep = DDB.Peptide()
            pep.set_sequence(curr_seq)
            pep.modifications = i
            yield pep