-
Notifications
You must be signed in to change notification settings - Fork 77
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
DOC: Add Python example equivalent to RNAfold -p --MEA
- Loading branch information
Showing
3 changed files
with
45 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#!/usr/bin/python | ||
# | ||
|
||
import RNA | ||
|
||
seq = "AUUUCCACUAGAGAAGGUCUAGAGUGUUUGUCGUUUGUCAGAAGUCCCUAUUCCAGGUACGAACACGGUGGAUAUGUUCGACGACAGGAUCGGCGCACUA" | ||
|
||
# create fold_compound data structure (required for all subsequently applied algorithms) | ||
fc = RNA.fold_compound(seq) | ||
|
||
# compute MFE and MFE structure | ||
(mfe_struct, mfe) = fc.mfe() | ||
|
||
# rescale Boltzmann factors for partition function computation | ||
fc.exp_params_rescale(mfe) | ||
|
||
# compute partition function | ||
(pp, pf) = fc.pf() | ||
|
||
# compute centroid structure | ||
(centroid_struct, dist) = fc.centroid() | ||
|
||
# compute free energy of centroid structure | ||
centroid_en = fc.eval_structure(centroid_struct) | ||
|
||
# compute MEA structure | ||
(MEA_struct, MEA) = fc.MEA() | ||
|
||
# compute free energy of MEA structure | ||
MEA_en = fc.eval_structure(MEA_struct) | ||
|
||
# print everything like RNAfold -p --MEA | ||
print("%s\n%s (%6.2f)" % (seq, mfe_struct, mfe)) | ||
print("%s [%6.2f]" % (pp, pf)) | ||
print("%s {%6.2f d=%.2f}" % (centroid_struct, centroid_en, dist)) | ||
print("%s {%6.2f MEA=%.2f}" % (MEA_struct, MEA_en, MEA)) | ||
print(" frequency of mfe structure in ensemble %g; ensemble diversity %-6.2f" % (fc.pr_structure(mfe_struct), fc.mean_bp_distance())) |