예제 #1
0
def main():
    file_name = 'datasets/rosalind_orf.txt'
    seq_dict = parse_fasta(file_name)

    for key in seq_dict:
        dna = seq_dict[key]

    orfs = orf_translate(dna)

    print('\n'.join(orfs))

    with open('solutions/rosalind_orf.txt', 'w') as output_file:
        output_file.write('\n'.join(orfs))
예제 #2
0
def main():
    file_name = 'datasets/rosalind_lcsm.txt'
    seq_dict = parse_fasta(file_name)

    seq_list = []
    for key in seq_dict:
        seq_list.append(seq_dict[key])

    shared_motif = longest_shared_motif(seq_list)
    print(shared_motif)

    with open('solutions/rosalind_lcsm.txt', 'w') as output_file:
        output_file.write(shared_motif)
예제 #3
0
def main():
    file_name = 'datasets/rosalind_pmch.txt'
    seq_dict = parse_fasta(file_name)

    seq_list = []
    for key in seq_dict:
        seq_list.append(seq_dict[key])

    rna = seq_list[0]
    num_perfect_matching = perfect_matching(rna)

    print(str(num_perfect_matching))

    with open('solutions/rosalind_pmch.txt', 'w') as output_file:
        output_file.write(str(num_perfect_matching))
예제 #4
0
def main():
    
    file_name='datasets/rosalind_revp.txt'
    seq_dict = parse_fasta(file_name)
    
    for key in seq_dict:
        dna=seq_dict[key]
        
    restrict_sites, len_sites=restriction_sites(dna)
    
    for i in range(len(restrict_sites)):
         print(str(restrict_sites[i])+' '+str(len_sites[i]))
         
    with open('solutions/rosalind_revp.txt', 'w') as output_file:
        for i in range(len(restrict_sites)):
            output_file.write(str(restrict_sites[i])+' '+str(len_sites[i])+'\n')
예제 #5
0
def main():
    file_name = 'datasets/rosalind_kmer.txt'
    seq_dict = parse_fasta(file_name)

    seq_list = []
    for key in seq_dict:
        seq_list.append(seq_dict[key])

    dna = seq_list[0]

    kmer_count = k_mer_sequence(dna)

    print(' '.join(map(str, (kmer_count))))

    with open('solutions/rosalind_kmer.txt', 'w') as output_file:
        output_file.write(' '.join(map(str, (kmer_count))))
예제 #6
0
def main():

    file_name = 'datasets/rosalind_long.txt'
    seq_dict = parse_fasta(file_name)

    seq_list = []
    for key in seq_dict:
        seq_list.append(seq_dict[key])

    final_sequence = shortest_super_sequence(seq_list)

    print(final_sequence)
    print(len(final_sequence))

    with open('solutions/rosalind_long.txt', 'w') as output_file:
        output_file.write(final_sequence)
예제 #7
0
def main():
    file_name = 'datasets/rosalind_sseq.txt'
    seq_dict = parse_fasta(file_name)

    seq_list = []
    for key in seq_dict:
        seq_list.append(seq_dict[key])

    dna = seq_list[0]
    motif = seq_list[1]

    splice_pos = spliced_motif(dna, motif)

    print(' '.join(map(str, (splice_pos))))

    with open('solutions/rosalind_sseq.txt', 'w') as output_file:
        output_file.write(' '.join(map(str, (splice_pos))))
예제 #8
0
def main():
    file_name = 'datasets/rosalind_edit.txt'
    seq_dict = parse_fasta(file_name)

    seq_list = []
    for key in seq_dict:
        seq_list.append(seq_dict[key])

    seq1 = seq_list[0]
    seq2 = seq_list[1]

    edit_distance_value = edit_distance(seq1, seq2)

    print(str(edit_distance_value))

    with open('solutions/rosalind_edit.txt', 'w') as output_file:
        output_file.write(str(edit_distance_value))
예제 #9
0
def main():
    file_name='datasets/rosalind_lcsq.txt'
    seq_dict = parse_fasta(file_name)
    
    seq_list=[]
    for key in seq_dict:
        seq_list.append(seq_dict[key])
    
    seq1 = seq_list[0]
    seq2 = seq_list[1]
            
   
    lcs = shared_spliced_motif(seq1, seq2)
    
    print(lcs)
    
    
    with open('solutions/rosalind_lcsq.txt', 'w') as output_file:
        output_file.write(lcs) 
예제 #10
0
def main():
    file_name = 'datasets/rosalind_glob.txt'
    seq_dict = parse_fasta(file_name)

    seq_list = []
    for key in seq_dict:
        seq_list.append(seq_dict[key])

    seq1 = seq_list[0]
    seq2 = seq_list[1]

    indel_penalty = 5
    scoring_matrix = BLOSUM62()
    max_score = global_alignment_score(seq1, seq2, scoring_matrix,
                                       indel_penalty)

    print(str(max_score))

    with open('solutions/rosalind_glob.txt', 'w') as output_file:
        output_file.write(str(max_score))
예제 #11
0
def main():
    file_name='datasets/rosalind_pdst.txt'
    seq_dict = parse_fasta(file_name)
    
    seq_list=[]
    for key in seq_dict:
        seq_list.append(seq_dict[key])
        
    distance_plot=distance_matrix(seq_list)
    
    for i in range(len(distance_plot[0])):
        for j in range(len(distance_plot[0])):
            print(str(distance_plot[i][j])+' ')
        print()
    
    with open('solutions/rosalind_pdst.txt', 'w') as output_file:
        for i in range(len(distance_plot[0])):
            for j in range(len(distance_plot[0])):
                output_file.write(str(distance_plot[i][j])+' ')
            output_file.write('\n')
예제 #12
0
def main():

    file_name = 'datasets/rosalind_oap.txt'
    seq_dict = parse_fasta(file_name)

    seq_list = []
    for key in seq_dict:
        seq_list.append(seq_dict[key])

    seq1 = seq_list[0]
    seq2 = seq_list[1]

    max_score, aligned_seq1, aligned_seq2 = overlap_alignment(seq1, seq2)

    print(str(max_score))
    print(aligned_seq1)
    print(aligned_seq2)

    with open('solutions/rosalind_oap.txt', 'w') as output_data:
        output_data.write(str(max_score) + '\n')
        output_data.write(aligned_seq1 + '\n')
        output_data.write(aligned_seq2)
예제 #13
0
def main():
    file_name = 'datasets/rosalind_cons.txt'

    seq_dict = parse_fasta(file_name)

    sequence_list = []
    for key in seq_dict:
        sequence_list.append(seq_dict[key])

    dict_cons, array_cons = consensus_profile(sequence_list)

    con_seq = consensus_sequence(array_cons)

    print(con_seq)
    for key in dict_cons:
        print(key + ': ' + ' '.join(map(str, (dict_cons[key]))))

    with open('solutions/rosalind_cons.txt', 'w') as output_file:
        output_file.write(con_seq + '\n')
        for key in dict_cons:
            output_file.write(key + ': ' +
                              ' '.join(map(str, (dict_cons[key]))) + '\n')
예제 #14
0
def main():
    
    file_name='datasets/rosalind_loca.txt'
    seq_dict = parse_fasta(file_name)
    
    seq_list=[]
    for key in seq_dict:
        seq_list.append(seq_dict[key])
    
    seq1 = seq_list[0]
    seq2 = seq_list[1]

    indel_penalty = 5
    scoring_matrix = PAM250()
    max_score, aligned_seq1, aligned_seq2 = local_alignment_subsequence(seq1, seq2, scoring_matrix, indel_penalty)

    print(str(max_score))
    print(aligned_seq1)
    print(aligned_seq2)
    
    with open('solutions/rosalind_loca.txt', 'w') as output_data:
        output_data.write(str(max_score)+'\n')
        output_data.write(aligned_seq1+'\n')
        output_data.write(aligned_seq2)