Exemplo n.º 1
0
def main():

    from hmm import load_hmm_model_from_files

    fasta_file_path = r'data/chrom17.fasta'
    emission_input_file = r'data/initial_emission.tsv'
    transition_input_file = r'data/initial_transition.tsv'

    hmm_model = load_hmm_model_from_files(emission_input_file, transition_input_file)
    observation = load_fasta_file(fasta_file_path)
    v, ptr = viterbi_algorithm(hmm_model, observation)
    np.savez_compressed('output/viterbi_algorithm_output.npz', v=v, ptr=ptr)
    path = restore_viterbi_path(v,ptr)
    np.savez_compressed('output/path.npz', path=path)
    q_3_1_c(path, observation)
Exemplo n.º 2
0
Arquivo: q_3_2.py Projeto: 8v/76558
                                                  size=len(observation),
                                                  replace=True))
    f = forward_algorithm(hmm_model, random_observation)
    print(f[1, -1])


def q_2_b_iii(hmm_model, observation):
    """
    calculating the log probability of observing chrom17.fasta given the model.
    :return:
    """
    repetitive_observation = 'A'*len(observation)
    f = forward_algorithm(hmm_model, repetitive_observation)
    print(f[1, -1])


if __name__ == '__main__':

    from hmm import load_hmm_model_from_files

    fasta_file_path = r'data/chrom17.fasta'
    observation = load_fasta_file(fasta_file_path)

    emission_input_file = r'data/initial_emission.tsv'
    transition_input_file = r'data/initial_transition.tsv'

    hmm_model = load_hmm_model_from_files(emission_input_file, transition_input_file)

    q_2_b_i(hmm_model, observation)
    #q_2_b_ii(hmm_model, observation)
    #q_2_b_iii(hmm_model, observation)