// File: gcollet[P]MstatX/src/mvector.cpp
// Function: MVectStat::calculate(Msa&)
void
MVectStat :: calculate(Msa & msa)
{
	int L = msa.getNcol();
	int N = msa.getNseq();
	
	/* Get the scoring matrix */
	ScoringMatrix score_mat(Options::Get().matrix_fname);
	
	/* Remove the unknown symbol from msa (consider them as gaps)*/
	sm_alphabet = score_mat.getAlphabet();
	msa.fitToAlphabet(sm_alphabet);
	
	/* Calculate the mean vector for each column */
	int K = (int) sm_alphabet.size();
	means = vector<vector<float> >(L);
	
	for (int col(0); col < L; col++) {
		vector<float> mean_col(K, 0.0);
		for (int seq(0); seq < N; ++seq) {
			if (msa.getSymbol(seq,col) == '-'){
				continue;
			} else {
				for (int a(0); a < K; ++a) {
					mean_col[a] += score_mat.normScore(sm_alphabet[a],msa.getSymbol(seq,col));
				}
			}
		}
		for (int a(0); a < K; ++a) {
			mean_col[a] /= (float) N;
		}
		means[col] = mean_col;
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x190, %rsp            # imm = 0x190
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x138(%rbp)
movq -0x10(%rbp), %rdi
callq 0x4ae0
movl %eax, -0x14(%rbp)
movq -0x10(%rbp), %rdi
callq 0x4b00
movl %eax, -0x18(%rbp)
callq 0x5150
movq %rax, %rsi
addq $0x88, %rsi
leaq -0x80(%rbp), %rdi
movq %rdi, -0x130(%rbp)
callq 0x4140
movq -0x130(%rbp), %rsi
leaq -0x60(%rbp), %rdi
callq 0x169d0
jmp 0x14be7
leaq -0x80(%rbp), %rdi
callq 0x41e0
leaq -0xb0(%rbp), %rdi
leaq -0x60(%rbp), %rsi
callq 0x15440
jmp 0x14c02
movq -0x138(%rbp), %rdi
addq $0x8, %rdi
movq %rdi, -0x148(%rbp)
leaq -0xb0(%rbp), %rsi
movq %rsi, -0x150(%rbp)
callq 0x4420
movq -0x150(%rbp), %rdi
callq 0x41e0
movq -0x148(%rbp), %rsi
movq -0x10(%rbp), %rax
movq %rax, -0x140(%rbp)
leaq -0xd0(%rbp), %rdi
callq 0x4140
jmp 0x14c53
movq -0x140(%rbp), %rdi
leaq -0xd0(%rbp), %rsi
callq 0x12df0
jmp 0x14c68
leaq -0xd0(%rbp), %rdi
callq 0x41e0
movq -0x138(%rbp), %rdi
addq $0x8, %rdi
callq 0x4260
movl %eax, -0xd4(%rbp)
movslq -0x14(%rbp), %rax
movq %rax, -0x160(%rbp)
leaq -0xf1(%rbp), %rdi
movq %rdi, -0x158(%rbp)
callq 0x15470
movq -0x160(%rbp), %rsi
movq -0x158(%rbp), %rdx
leaq -0xf0(%rbp), %rdi
callq 0x15490
jmp 0x14cc4
movq -0x138(%rbp), %rdi
addq $0x28, %rdi
leaq -0xf0(%rbp), %rsi
callq 0x15500
leaq -0xf0(%rbp), %rdi
callq 0x15530
leaq -0xf1(%rbp), %rdi
callq 0x15590
movl $0x0, -0xf8(%rbp)
movl -0xf8(%rbp), %eax
cmpl -0x14(%rbp), %eax
jge 0x14ff7
movslq -0xd4(%rbp), %rax
movq %rax, -0x170(%rbp)
movl $0x0, -0x114(%rbp)
leaq -0x115(%rbp), %rdi
movq %rdi, -0x168(%rbp)
callq 0x7510
movq -0x170(%rbp), %rsi
movq -0x168(%rbp), %rcx
leaq -0x110(%rbp), %rdi
leaq -0x114(%rbp), %rdx
callq 0x13880
jmp 0x14d5a
leaq -0x115(%rbp), %rdi
callq 0x5120
movl $0x0, -0x11c(%rbp)
movl -0x11c(%rbp), %eax
cmpl -0x18(%rbp), %eax
jge 0x14f52
movq -0x10(%rbp), %rdi
movl -0x11c(%rbp), %esi
movl -0xf8(%rbp), %edx
callq 0x71a0
movb %al, -0x171(%rbp)
jmp 0x14d9c
movb -0x171(%rbp), %al
movsbl %al, %eax
cmpl $0x2d, %eax
jne 0x14e76
jmp 0x14f3e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x88(%rbp)
movl %eax, -0x8c(%rbp)
leaq -0x80(%rbp), %rdi
callq 0x41e0
jmp 0x15012
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x88(%rbp)
movl %eax, -0x8c(%rbp)
jmp 0x15009
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x88(%rbp)
movl %eax, -0x8c(%rbp)
leaq -0xd0(%rbp), %rdi
callq 0x41e0
jmp 0x15009
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x88(%rbp)
movl %eax, -0x8c(%rbp)
leaq -0xf1(%rbp), %rdi
callq 0x15590
jmp 0x15009
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x88(%rbp)
movl %eax, -0x8c(%rbp)
leaq -0x115(%rbp), %rdi
callq 0x5120
jmp 0x15009
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x88(%rbp)
movl %eax, -0x8c(%rbp)
leaq -0x110(%rbp), %rdi
callq 0x4ea0
jmp 0x15009
movl $0x0, -0x120(%rbp)
movl -0x120(%rbp), %eax
cmpl -0xd4(%rbp), %eax
jge 0x14f3a
movq -0x138(%rbp), %rdi
addq $0x8, %rdi
movslq -0x120(%rbp), %rsi
callq 0x46c0
movq %rax, -0x180(%rbp)
jmp 0x14eb2
movq -0x180(%rbp), %rax
movb (%rax), %al
movb %al, -0x182(%rbp)
movq -0x10(%rbp), %rdi
movl -0x11c(%rbp), %esi
movl -0xf8(%rbp), %edx
callq 0x71a0
movb %al, -0x181(%rbp)
jmp 0x14ede
movb -0x181(%rbp), %al
movb -0x182(%rbp), %cl
movsbl %cl, %esi
movsbl %al, %edx
leaq -0x60(%rbp), %rdi
callq 0x17650
movss %xmm0, -0x188(%rbp)
jmp 0x14f03
movslq -0x120(%rbp), %rsi
leaq -0x110(%rbp), %rdi
callq 0x5180
movss -0x188(%rbp), %xmm0
addss (%rax), %xmm0
movss %xmm0, (%rax)
movl -0x120(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x120(%rbp)
jmp 0x14e80
jmp 0x14f3c
jmp 0x14f3e
movl -0x11c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x11c(%rbp)
jmp 0x14d70
movl $0x0, -0x124(%rbp)
movl -0x124(%rbp), %eax
cmpl -0xd4(%rbp), %eax
jge 0x14faf
cvtsi2ssl -0x18(%rbp), %xmm0
movss %xmm0, -0x18c(%rbp)
movslq -0x124(%rbp), %rsi
leaq -0x110(%rbp), %rdi
callq 0x5180
movss -0x18c(%rbp), %xmm1
movss (%rax), %xmm0
divss %xmm1, %xmm0
movss %xmm0, (%rax)
movl -0x124(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x124(%rbp)
jmp 0x14f5c
movq -0x138(%rbp), %rdi
addq $0x28, %rdi
movslq -0xf8(%rbp), %rsi
callq 0x155b0
movq %rax, %rdi
leaq -0x110(%rbp), %rsi
callq 0x155d0
jmp 0x14fd7
leaq -0x110(%rbp), %rdi
callq 0x4ea0
movl -0xf8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xf8(%rbp)
jmp 0x14cfd
leaq -0x60(%rbp), %rdi
callq 0x174a0
addq $0x190, %rsp            # imm = 0x190
popq %rbp
retq
leaq -0x60(%rbp), %rdi
callq 0x174a0
movq -0x88(%rbp), %rdi
callq 0x45e0
nop