コード例 #1
0
ファイル: TestLeaderboard.py プロジェクト: philipcraig/silly2
 def test_expand(self):
     leaderboard = {(0,)}
     result = leaderboard_cyclopeptide_sequencing.expand(leaderboard, set(genome.readUniqueWeights()))
     self.assertIn((0, 129), result)
     self.assertIn((0, 103), result)
     self.assertEqual(18, len(result))
     leaderboard = {(0, 129)}
     result = leaderboard_cyclopeptide_sequencing.expand(leaderboard, set(genome.readUniqueWeights()))
     self.assertIn((0, 129, 129), result)
     self.assertIn((0, 129, 103), result)
     self.assertEqual(18, len(result))
コード例 #2
0
    temp=[]
    for p in leaderboard:
        temp.append((score(p, spectrum), p))
    sorted(temp, key=itemgetter(0))
    result=[]
    for i, x in enumerate(temp):
        if i < N:
            result.append(x[1])
            finalScore = x[0]
        elif finalScore == x[0]:
            result.append(x[1])



if __name__ == "__main__":
    weights = set(genome.readUniqueWeights())

    spectrum = [0, 71, 113, 129, 147, 200, 218, 260, 313, 331, 347, 389, 460]
    N = 10

    inpFile = open('C:/temp/leaderboard_data.txt', 'r')
    inpFile.readline()
    # spectrum = map(int, inpFile.readline().split())

    zero_tuple = 0,
    leaderboard = set()
    leaderboard.add(zero_tuple)
    leaderpeptide = zero_tuple
    while leaderboard:
        leaderboard = expand(leaderboard, weights)
        newLeaderboard = set()