Пример #1
0
def hamiltonian(config):
    """Given a configuration describing the left-endpoints of tfs, compute
    associated energy"""
    poses = positions(config)
    total_site_energy = sum(score_seq(energy_matrix,genome[pos:pos+w])
                            for pos in poses)
    total_interaction_energy = interaction_energy * len([(i,j) for (i,j) in pairs(poses) if j - i == w])
    total_exclusion_energy = exclusion_energy * len([(i,j) for (i,j) in pairs(poses) if j - i < w])
    return total_site_energy + total_interaction_energy + total_exclusion_energy
Пример #2
0
G = len(genome)
beta = 1
energy_matrix = [[-2,0,0,0],
                 [-0,-2,0,0],
                 [-0,0,-2,0],
                 [-0,0,0,-2],
                 [-0,0,0,-2],
                 [-0,0,-2,0],
                 [-0,-2,0,0],
                 [-2,0,0,0]]

w = len(energy_matrix)
config_len = G-w
interaction_energy = -8 # TFs in contact get -2 added to configuration energy
exclusion_energy = 1000000
eps =[score_seq(energy_matrix,genome[i:i+w]) for i in range(G-w+1)]
ks = [exp(-ep) for ep in eps]
    
def positions(config):
    return [i for i,x in enumerate(config) if x > 0]

def from_positions(poses):
    return [int(i in poses) for i in range(config_len)]
    
def hamiltonian(config):
    """Given a configuration describing the left-endpoints of tfs, compute
    associated energy"""
    poses = positions(config)
    total_site_energy = sum(score_seq(energy_matrix,genome[pos:pos+w])
                            for pos in poses)
    total_interaction_energy = interaction_energy * len([(i,j) for (i,j) in pairs(poses) if j - i == w])