<jupyter_start><jupyter_text>Consensus sequence matrix<jupyter_code>import re
file = open("/Users/anilkumar/projectEEG/rosalind_cons (3).txt")
seqs = file.read()
seqs = seqs.replace("\n", "")
ids = re.findall(r'>Rosalind_\d{4}', seqs)
seqs = re.split(r'>Rosalind_\d{4}', seqs)[1:]
prof_mat = {'A': [], 'C': [], 'G':[], 'T': []}
num_seqs = len(seqs)
len_seqs = len(seqs[0])
for i in range(len_seqs):
    countA = 0
    countT = 0
    countG = 0
    countC = 0
    for j in range(num_seqs):
        if seqs[j][i] == 'A':
            countA += 1
        elif seqs[j][i] == 'T':
            countT += 1
        elif seqs[j][i] == 'G':
            countG += 1
        elif seqs[j][i] == 'C':
            countC += 1
    prof_mat['A'].append(countA)
    prof_mat['C'].append(countC)
    prof_mat['G'].append(countG)
    prof_mat['T'].append(countT)
def consensus(prof_mat):
    cons = []
    mat = np.array(list(prof_mat.values()))
    for i in range(len_seqs):
        max_res = np.argmax(np.array(list(prof_mat.values()))[:,i])
        cons.append(list(prof_mat.keys())[max_res])
    return "".join(cons)
print(consensus(prof_mat))
for k in ['A', 'C', 'G', 'T']:
      print(k + ": " + " ".join(str(x) for x in prof_mat[k]))<jupyter_output>TAGAATTAAAACGCGCGATTCCAATAACGGTGGAAGGGGGATACGGTTAGGGAGTTTGACCATTGCGACTATATAACCCGGAGGCTCAGCATGAGACAGCGTACTCGACCATGAGCACGAAAAATGAACAGTACCCGGGCCCACCGAGACTAGCAACACGTCATATCAAGCCCCACGGGATCCTGAACATAACTACCTAACCGGCAAACGGGATTAGGAGCTCCAACAATCACACTTCAAGTGCCACGACAGAGCGGTAAAATTTCTTCCACATTCATAGGCCAGTATAAGTCCGGCAGAAATAGGAACACTCACACATAATCAAATAACAACACCCATCCGTATCAAATACTGAGCACTACGGGTATTGCCTGCGCCTAAAATTTCGGTTTTACATGACCCCAAGTCTCATGCAAATCCGGTGATCAGTGAACAGGGCGAACAATCAAATCATTAACAGAGGGACCCAGCGTTCTGTAACTTAAGCAGGTGAACTTTGACCGCACAGACGTAAACCTACGCAAGTAACGGTACAATAAATCTGATCCATTAGACCAATACCAGCATCGTAATAACCTCAGAACAGACTGACAAATACCATTGCTAAGACGAGAGCTCTTAATCGAGCATCAGGAGAACCGGTCAACGAAAACTCAGATGAGGCTTATATAAATACCGATCTTTGGCATTTACCCGGGCCAGAAGAAGTCTAGAGCCCGGGATAACCTACCTGGCAAACACCCAGCGCGCAGATCCAACGTCAATGTAAACTGCTTAATTACCTGAGCAACTTGGTCAAGAAGGCTGTTCCTAGGCATTCGAGTGAGGTACGTGAAAGCTCCGTACAATAAAAGCAAACAACAACTCCAGAAGAACGTGCCAGAGTAAAGCCCAAAGCTCATGGCTGTGCCATAGATCGGTTAGTACGGCATAAAAGGCCTCACAAAT
A: 1 3 2 4 4 3 2 4 3 4 4 2 1 2 2 2 2 3 3 0 2 2 3 4 [...]
{'fraction_non_alphanumeric': 0.11780455153949129, 'fraction_numerical': 0.01651048639000446, 'mean_word_length': 5.692537313432836, 'pattern_counts': {'":': 1, '<': 4, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 3, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '6083', 'license': 'MIT', 'n_tokens_mistral': 1080, 'n_tokens_neox': 959, 'n_words': 119, 'path': 'CONS.ipynb', 'repo_name': 'anilk991/rosalindsolutions', 'size': '2241'}