Consensus and Profile Matrix

Intermediate Multiple Sequences Consensus Position Weight Matrix
Significance:
The profile matrix (also called a Position Weight Matrix, or PWM) is the statistical backbone of motif representation in bioinformatics — it's how tools like MEME and JASPAR represent transcription factor binding sites, and how you'd build a simple sequence classifier. The consensus string is the "most likely" sequence a PWM represents.
Statement

Given a collection of DNA strings, all of the **same length**, construct:
1. The **profile matrix**: for each of the 4 nucleotides (in row order A, C, G, T) and each column position, the count of that nucleotide across all input sequences at that position.
2. The **consensus string**: at each position, the nucleotide with the highest count in that column (if there's a tie, any of the tied nucleotides may be output).

Sample Input
ATCCAGCT
GGGCAACT
ATGGATCT
AAGCAACC
TTGGAACT
ATGCCATT
ATGGCACT
Sample Output
Consensus: ATGCAACT
A: 5 1 0 0 5 5 0 0
C: 0 0 1 4 2 0 6 1
G: 1 1 6 3 0 1 0 0
T: 1 5 0 0 0 1 1 6
Constraints

- `1 ≤ number of sequences ≤ 10`
- `1 ≤ length(each sequence) ≤ 100` (all equal length)


My Notes
Log in to save personal notes.
Console output will appear here when you click Run Code or Submit...
Enter DNA / RNA / Protein test string
Next Problem
Overlap Graphs