def toebinding(seq, T=GLOBAL_TEMPERATURE, material='dna'): n = len(seq) (toe5len, toe3len) = toeholds(seq, T=T, material=material) if toe5len < n: toe5seq = seq[:toe5len] if toe5len > 0 else '' toe3seq = seq[-toe3len:] if toe3len > 0 else '' base = seq[toe5len] fake_seq1 = toe5seq + base + 'GGGGTTTTCCCC' + WC(base) + toe3seq fake_struct1 = '.' * toe5len + '(((((....)))))' + '.' * toe3len fake_seq2 = WC(fake_seq1) fake_struct2 = '.' * toe3len + '(((((....)))))' + '.' * toe5len fake_struct_toe5 = '(' * toe5len + '(((((....)))))' + '.' * toe3len + '+' + '.' * toe3len + '(((((....)))))' + ')' * toe5len fake_struct_toe3 = '.' * toe5len + '(((((....)))))' + '(' * toe3len + '+' + ')' * toe3len + '(((((....)))))' + '.' * toe5len fake_struct_toes = '(' * toe5len + '(((((....)))))' + '(' * toe3len + '+' + ')' * toe3len + '(((((....)))))' + ')' * toe5len # print "Sequence %s: %s %s and %s %s" % (seq,fake_seq1,fake_struct1,fake_seq2,fake_struct2) dG1 = nupack.energy([fake_seq1], fake_struct1, T=T, material=material) dG2 = nupack.energy([fake_seq2], fake_struct2, T=T, material=material) if toe5len > 0: dG_toe5 = nupack.energy([fake_seq1, fake_seq2], fake_struct_toe5, T=T, material=material) - dG1 - dG2 else: dG_toe5 = 0 if toe3len > 0: dG_toe3 = nupack.energy([fake_seq1, fake_seq2], fake_struct_toe3, T=T, material=material) - dG1 - dG2 else: dG_toe3 = 0 if toe5len > 0 and toe3len > 0: dG_toes = nupack.energy([fake_seq1, fake_seq2], fake_struct_toes, T=T, material=material) - dG1 - dG2 else: dG_toes = 0 return max(-dG_toe5, -dG_toe3, -dG_toes) else: # print "Sequence %s: no structure!" % seq return -duplex_dG(seq, T=T, material=material)
def _get_eos(self, sequence, structure, temperature, ligand=None): #TODO nupack.energy can not handle unconnected cofold structures return nupack.energy([self._change_cuts(sequence)], self._change_cuts(structure), material='rna', pseudo=True, T=temperature)