// File: gcollet[P]MstatX/src/kabat.cpp
// Function: KabatStat::calculate(Msa&)
void
KabatStat :: calculate(Msa & msa)
{
	int k;                    // number of amino acid types in a given column
	int n1;                   // number of occurences of the most represented residue in a column
	int N = msa.getNseq();    // number of sequences in the msa
	int ncol = msa.getNcol(); // number of columns in the multiple alignment
	vector<int> naa;

	for (int x(0); x < ncol; ++x){
		k = msa.getNtype(x);
  	/* Find the most represented amino acid type (n1) */
		string aa_type = msa.getTypeList(x);
		vector<int> nb_aa(aa_type.size(), 0);
		for (int s(0); s < N; ++s){
			nb_aa[aa_type.find(msa.getSymbol(s, x))]++;
		}
		n1 = 0;
		for (int i(0); i < (int) nb_aa.size(); ++i)
			if (nb_aa[i] > n1)
				n1 = nb_aa[i];
		/* Calculate conservation from Wu & Kabat formula */
		col_stat.push_back((float)k / (float) n1);
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xd0, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0xa8(%rbp)
movq -0x10(%rbp), %rdi
callq 0x4b00
movl %eax, -0x1c(%rbp)
movq -0x10(%rbp), %rdi
callq 0x4ae0
movl %eax, -0x20(%rbp)
leaq -0x38(%rbp), %rdi
callq 0x9020
movl $0x0, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
cmpl -0x20(%rbp), %eax
jge 0x8ff0
movq -0x10(%rbp), %rdi
movl -0x3c(%rbp), %esi
callq 0x7170
movl %eax, -0xac(%rbp)
jmp 0x8de6
movl -0xac(%rbp), %eax
movl %eax, -0x14(%rbp)
movq -0x10(%rbp), %rsi
movl -0x3c(%rbp), %edx
leaq -0x70(%rbp), %rdi
callq 0x9040
jmp 0x8e01
leaq -0x70(%rbp), %rdi
callq 0x4260
movq %rax, -0xc0(%rbp)
movl $0x0, -0x8c(%rbp)
leaq -0x8d(%rbp), %rdi
movq %rdi, -0xb8(%rbp)
callq 0x9090
movq -0xc0(%rbp), %rsi
movq -0xb8(%rbp), %rcx
leaq -0x88(%rbp), %rdi
leaq -0x8c(%rbp), %rdx
callq 0x90b0
jmp 0x8e51
leaq -0x8d(%rbp), %rdi
callq 0x9130
movl $0x0, -0x94(%rbp)
movl -0x94(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jge 0x8f18
movq -0x10(%rbp), %rdi
movl -0x94(%rbp), %esi
movl -0x3c(%rbp), %edx
callq 0x71a0
movb %al, -0xc1(%rbp)
jmp 0x8e90
movb -0xc1(%rbp), %al
leaq -0x70(%rbp), %rdi
xorl %ecx, %ecx
movl %ecx, %edx
movsbl %al, %esi
callq 0x4480
movq %rax, %rsi
leaq -0x88(%rbp), %rdi
callq 0x7480
movl (%rax), %ecx
addl $0x1, %ecx
movl %ecx, (%rax)
movl -0x94(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x94(%rbp)
jmp 0x8e67
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x9002
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x8d(%rbp), %rdi
callq 0x9130
jmp 0x8fe5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x88(%rbp), %rdi
callq 0x9170
jmp 0x8fe5
movl $0x0, -0x18(%rbp)
movl $0x0, -0x98(%rbp)
movl -0x98(%rbp), %eax
movl %eax, -0xc8(%rbp)
leaq -0x88(%rbp), %rdi
callq 0x9150
movq %rax, %rcx
movl -0xc8(%rbp), %eax
cmpl %ecx, %eax
jge 0x8f93
movslq -0x98(%rbp), %rsi
leaq -0x88(%rbp), %rdi
callq 0x7480
movl (%rax), %eax
cmpl -0x18(%rbp), %eax
jle 0x8f80
movslq -0x98(%rbp), %rsi
leaq -0x88(%rbp), %rdi
callq 0x7480
movl (%rax), %eax
movl %eax, -0x18(%rbp)
jmp 0x8f82
movl -0x98(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x98(%rbp)
jmp 0x8f29
movq -0xa8(%rbp), %rdi
addq $0x8, %rdi
cvtsi2ssl -0x14(%rbp), %xmm0
cvtsi2ssl -0x18(%rbp), %xmm1
divss %xmm1, %xmm0
movss %xmm0, -0x9c(%rbp)
leaq -0x9c(%rbp), %rsi
callq 0x4b20
jmp 0x8fc2
leaq -0x88(%rbp), %rdi
callq 0x9170
leaq -0x70(%rbp), %rdi
callq 0x41e0
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x8dc6
leaq -0x70(%rbp), %rdi
callq 0x41e0
jmp 0x9002
leaq -0x38(%rbp), %rdi
callq 0x9170
addq $0xd0, %rsp
popq %rbp
retq
leaq -0x38(%rbp), %rdi
callq 0x9170
movq -0x48(%rbp), %rdi
callq 0x45e0
nopw %cs:(%rax,%rax)
nop