Esempio n. 1
0
def print_output(i,
                 j,
                 state0,
                 state1,
                 distribution_parameter0,
                 system='2D_muller'):
    """ Print the state information out to screen """
    if system == "2D_muller":
        print(
            "Position at iteration=%s and Cooling step=%s: X=%4.2f Y=%4.2f Energy=%4.2f/%4.2f Distribution Parameter=%4.5f"
            % (i, j, state0[0], state0[1], energy(state0, system),
               energy(state1, system), distribution_parameter0))
    if system == "RNA":
        # visualize structure
        label = "Fold at iteration=%s and Cooling step=%s: Energy=%4.2f/%4.2f Distribution Parameter=%4.5f" % (
            i, j, energy(state0, system), energy(
                state1, system), distribution_parameter0)
        matrix = stem2basepair_matrix(state0['sequence'],
                                      state0['assembled_stems'],
                                      state0['stems_s1'], state0['stems_s2'])
        visualize_structure(matrix, label)
Esempio n. 2
0
from PyRNA import SimRNAfile2bp, dot2bp, visualize_structure, basepair_matrix2CT
import pandas as pd
from sklearn.metrics import recall_score, precision_score, matthews_corrcoef

# Sensitivity, hit rate, recall, or true positive rate: TPR = TP/(TP+FN)
# Specificity or true negative rate: TNR = TN/(TN+FP)
# Precision or positive predictive value: PPV = TP/(TP+FP)
# Matthews correlation coefficient (MCC): https://scikit-learn.org/stable/modules/generated/sklearn.metrics.matthews_corrcoef.html#sklearn.metrics.matthews_corrcoef

bp_matrix_ref = SimRNAfile2bp("data/SimRNA/reference.ss")
bp_matrix_pre = SimRNAfile2bp("data/SimRNA/predicted.ss")

ref = pd.DataFrame.from_records(bp_matrix_ref).values.flatten()
pre = pd.DataFrame.from_records(bp_matrix_pre).values.flatten()
tpr, ppv, mcc = recall_score(y_true=ref, y_pred=pre), precision_score(
    y_true=ref, y_pred=pre), matthews_corrcoef(y_true=ref, y_pred=pre)
print(tpr, ppv, mcc)

ct = basepair_matrix2CT(bp_matrix_ref, filename="data/SimRNA/reference.ct")
ct = basepair_matrix2CT(bp_matrix_pre, filename="data/SimRNA/predicted.ct")

visualize_structure(bp_matrix_ref, label="FSW-reference")
visualize_structure(bp_matrix_pre, label="FSW-predicted")
Esempio n. 3
0
from geneticalgorithm.geneticalgorithm import geneticalgorithm as ga
import network_line_graph as nlg
from myga import run_genetic_algorithm
from PyRNA import initialize_RNA, CT2basepair_matrix, check_compatibility, ga2stems, state2basepair_matrix, visualize_structure
import numpy as np

# dictionary to store results
results = {}

results['TAR'] = {}
results['TAR']['bp'], results['TAR']['ct'] = CT2basepair_matrix("data/7JU1.ct")
results['TAR']['models'], results['TAR']['states'] = run_genetic_algorithm(
    sequence='GGCAGAUCUGAGCCUGGGAGCUCUCUGCC',
    N_stems=4,
    iterations=200,
    population_size=30)

from PyRNA import states2averaged_base_matrix
visualize_structure(states2averaged_base_matrix(results['TAR']['states']),
                    label="Average")
visualize_structure(results['TAR']['bp'], label="Acutal")

import joblib
filename = 'data/states_HIV_TAR.sav'
joblib.dump(results['TAR']['states'], filename)

from PyRNA import state2CT
state = results['TAR']['states'][195]
visualize_structure(state2basepair_matrix(state))
state2CT(state)