// File: /workspace/github_cpp_makefile_star2_O2/simonrharris[P]SKA/src/sk_align.cpp
// Function: printAlignment(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, std::unordered_map<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::hash<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>, std::equal_to<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>, std::allocator<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>>> const&, std::vector<int, std::allocator<int>>&, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>>, bool)
void printAlignment(const std::string & outputfilename, const std::unordered_map < std::string, std::string > & myKmerMap,std::vector < int > & constantBaseVector, const std::vector < std::string > sampleNames, const bool variantOnly){
	
	std::cout << "Printing alignment of "<< myKmerMap.size() << " sites" << std::endl;
	
	std::ofstream alignfile(outputfilename);

	for (int i=0; i<sampleNames.size(); ++i){
		float nonns=0.0;
		std::string mysequence (myKmerMap.size(), '-');
		int j=0;
		for (std::unordered_map < std::string, std::string >::const_iterator kmit=myKmerMap.begin(); kmit!=myKmerMap.end(); ++kmit, ++j){
			mysequence[j] = kmit->second[i];
			if(base_score[kmit->second[i]]<4){
				nonns++;
			}
		}
		alignfile << ">" << sampleNames[i] << std::endl << mysequence << std::endl;
		if ((nonns/myKmerMap.size())<0.5){
			std::cerr << "Warning: " << sampleNames[i] << " only matches " << nonns/myKmerMap.size()*100 << "% of kmers in the alignment" << std::endl;
		}
	}
	alignfile.close();

	if (variantOnly){//if the variant only option was selected, print the constant site counts
		std::cout << "Constant sites matching filters (a c g t):" << std::endl;
		std::cout << constantBaseVector[0] << " " << constantBaseVector[1]  << " " << constantBaseVector[2]  << " " << constantBaseVector[3]  << std::endl;
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x238, %rsp            # imm = 0x238
movl %r8d, 0x4(%rsp)
movq %rcx, %r14
movq %rdx, 0x8(%rsp)
movq %rsi, %r15
movq %rdi, %rbx
movq 0x2ae40(%rip), %rdi     # 0x35fb8
leaq 0x1a511(%rip), %rsi     # 0x25690
callq 0x53f0
movq 0x18(%r15), %rsi
movq %rax, %rdi
callq 0x5280
leaq 0x1b209(%rip), %rsi     # 0x263a0
movq %rax, %rdi
callq 0x53f0
movq %rax, %rdi
callq 0x51c0
leaq 0x38(%rsp), %rdi
pushq $0x10
popq %rdx
movq %rbx, %rsi
callq 0x5740
leaq 0x10(%r15), %rax
movq %rax, 0x10(%rsp)
xorl %r12d, %r12d
leaq 0x18(%rsp), %r13
leaq 0x2b281(%rip), %rbp     # 0x36450
movq 0x8(%r14), %rax
subq (%r14), %rax
sarq $0x5, %rax
cmpq %r12, %rax
jbe 0xb365
movq 0x18(%r15), %rsi
leaq 0x28(%rsp), %rax
movq %rax, 0x18(%rsp)
movq %r13, %rdi
pushq $0x2d
popq %rdx
callq 0x5470
xorps %xmm0, %xmm0
movss %xmm0, (%rsp)
xorl %eax, %eax
movq 0x10(%rsp), %rcx
movq (%rcx), %rcx
testq %rcx, %rcx
je 0xb250
movq 0x28(%rcx), %rdx
movb (%rdx,%r12), %dl
movq 0x18(%rsp), %rsi
movb %dl, (%rsi,%rax)
movq 0x28(%rcx), %rdx
movsbq (%rdx,%r12), %rdx
cmpb $0x4, (%rbp,%rdx)
movss (%rsp), %xmm1
movaps %xmm1, %xmm0
addss 0x19dc3(%rip), %xmm0    # 0x25004
jl 0xb246
movaps %xmm1, %xmm0
incq %rax
movss %xmm0, (%rsp)
jmp 0xb20b
leaq 0x38(%rsp), %rdi
leaq 0x1ae3b(%rip), %rsi     # 0x26097
callq 0x53f0
movq %r12, %rbx
shlq $0x5, %rbx
movq (%r14), %rsi
addq %rbx, %rsi
movq %rax, %rdi
callq 0x53a0
movq %rax, %rdi
callq 0x51c0
movq %rax, %rdi
movq %r13, %rsi
callq 0x53a0
movq %rax, %rdi
callq 0x51c0
movq 0x18(%r15), %rax
testq %rax, %rax
js 0xb2a1
cvtsi2ss %rax, %xmm0
jmp 0xb2b6
movq %rax, %rcx
shrq %rcx
andl $0x1, %eax
orq %rcx, %rax
cvtsi2ss %rax, %xmm0
addss %xmm0, %xmm0
movss (%rsp), %xmm1
divss %xmm0, %xmm1
movss 0x1a3a1(%rip), %xmm0    # 0x25668
ucomiss %xmm1, %xmm0
jbe 0xb355
movq 0x2ad19(%rip), %rdi     # 0x35ff0
leaq 0x1a3c9(%rip), %rsi     # 0x256a7
callq 0x53f0
addq (%r14), %rbx
movq %rax, %rdi
movq %rbx, %rsi
callq 0x53a0
movq %rax, %rdi
leaq 0x1a3b6(%rip), %rsi     # 0x256b1
callq 0x53f0
movq 0x18(%r15), %rcx
testq %rcx, %rcx
js 0xb310
cvtsi2ss %rcx, %xmm1
jmp 0xb325
movq %rcx, %rdx
shrq %rdx
andl $0x1, %ecx
orq %rdx, %rcx
cvtsi2ss %rcx, %xmm1
addss %xmm1, %xmm1
movss (%rsp), %xmm0
divss %xmm1, %xmm0
mulss 0x1a336(%rip), %xmm0    # 0x2566c
movq %rax, %rdi
callq 0x5300
movq %rax, %rdi
leaq 0x1a378(%rip), %rsi     # 0x256c0
callq 0x53f0
movq %rax, %rdi
callq 0x51c0
movq %r13, %rdi
callq 0x5778
incq %r12
jmp 0xb1cf
leaq 0x38(%rsp), %rdi
callq 0x5560
movq 0x8(%rsp), %rbx
cmpb $0x0, 0x4(%rsp)
je 0xb40a
movq 0x2ac32(%rip), %rdi     # 0x35fb8
leaq 0x1a34f(%rip), %rsi     # 0x256dc
callq 0x53f0
movq %rax, %rdi
callq 0x51c0
movq (%rbx), %rax
movl (%rax), %esi
movq 0x2ac12(%rip), %rdi     # 0x35fb8
callq 0x56a0
leaq 0x1afab(%rip), %rsi     # 0x2635d
movq %rax, %rdi
callq 0x53f0
movq (%rbx), %rcx
movl 0x4(%rcx), %esi
movq %rax, %rdi
callq 0x56a0
leaq 0x1af8e(%rip), %rsi     # 0x2635d
movq %rax, %rdi
callq 0x53f0
movq (%rbx), %rcx
movl 0x8(%rcx), %esi
movq %rax, %rdi
callq 0x56a0
leaq 0x1af71(%rip), %rsi     # 0x2635d
movq %rax, %rdi
callq 0x53f0
movq (%rbx), %rcx
movl 0xc(%rcx), %esi
movq %rax, %rdi
callq 0x56a0
movq %rax, %rdi
callq 0x51c0
leaq 0x38(%rsp), %rdi
callq 0x55c0
addq $0x238, %rsp            # imm = 0x238
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0xb428
movq %rax, %rbx
jmp 0xb43a
movq %rax, %rbx
leaq 0x18(%rsp), %rdi
callq 0x5778
leaq 0x38(%rsp), %rdi
callq 0x55c0
movq %rbx, %rdi
callq 0x56c0