// File: /workspace/github_cpp_makefile_star2_O2/ChnMasterOG[P]KmerGO2/kmergo/kmer_filtering.cpp
// Function: continuous_feature_filtering(unsigned short, 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>>>>, KmerGO_parameters)
void continuous_feature_filtering(uint16_t Nprocess, std::vector<std::string> files_vec, KmerGO_parameters p)
{
	std::string line, kmer;
	std::string input_file_name = files_vec[Nprocess];
	std::string onput_file_name_l = joinPath(p.features_path, "continuous_l_" + std::to_string(Nprocess) + ".txt");
	std::string onput_file_name_n = joinPath(p.features_path, "continuous_n_" + std::to_string(Nprocess) + ".txt");
	std::ifstream input_file(input_file_name);
	std::ofstream output_file_l(onput_file_name_l);
	std::ofstream output_file_n(onput_file_name_n);
	std::vector<std::string> head_value;
	std::vector<bool> sample_valid;
	std::string::size_type position;

	/* read head text and set labels */
	std::getline(input_file, line);
	mtx.lock();
	progress += line.size() + 1;	// update progress
	mtx.unlock();
	output_file_l << line << "\tP\n";	// write logical file head text
	output_file_n << line << "\tP\tCorr\n";	// write numerical file head text
	position = line.find("\t");
	line = line.substr(position + 1);	// remove string "k-mer"
	position = line.find("\t");
	while (position != line.npos)
	{
		std::string sample_name = line.substr(0, position);
		head_value.push_back(sample_name);
		if (p.trait_information_map.find(sample_name) != p.trait_information_map.end()) sample_valid.push_back(true);
		else sample_valid.push_back(false);
		line = line.substr(position + 1);
		position = line.find("\t");
	}
	head_value.push_back(line);
	if (p.trait_information_map.find(line) != p.trait_information_map.end()) sample_valid.push_back(true);
	else sample_valid.push_back(false);

	/* filtering */
	while (std::getline(input_file, line))
	{
		std::string src_line(line);
		position = line.find("\t");
		line = line.substr(position + 1);	// remove first k-mer
		position = line.find("\t");
		std::vector<float> group1, group2, kmer_fre;
		int cnt = 0;
		while (position != line.npos)
		{
			std::string value_str = line.substr(0, position);
			float value_float = std::stof(value_str);
			/* logical filtering */
			if (sample_valid[cnt] == true)		// existence
			{
				kmer_fre.push_back(value_float);
				if (value_float == 0) group1.push_back(std::stof(p.trait_information_map[head_value[cnt]]));
				else group2.push_back(std::stof(p.trait_information_map[head_value[cnt]]));
			}
			line = line.substr(position + 1);
			position = line.find("\t");
			++cnt;
		}
		/* calculation */
		float pValue = ranksums(group1, group2);
		if (pValue < p.p_value)
		{
			output_file_l << src_line << '\t' << std::to_string(pValue) << '\n';
		}
		else
		{
			std::vector<float> group;
			group.insert(group.end(), group1.begin(), group1.end());
			group.insert(group.end(), group2.begin(), group2.end());
			float corr = spearman_correlation_coefficient(kmer_fre, group);	// calculate spearman correlation
			if (corr >= p.corr_vaule)
			{
				output_file_n << src_line << '\t' << std::to_string(pValue) << '\t' << std::to_string(corr) << '\n';
			}
		}
		mtx.lock();
		progress += src_line.size() + 1;	// update progress
		mtx.unlock();
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x898, %rsp            # imm = 0x898
movq %rdx, %rbx
movl %edi, %ebp
leaq 0x50(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
xorl %ecx, %ecx
movb %cl, (%rax)
leaq 0x268(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb %cl, (%rax)
movl %edi, %eax
shll $0x5, %eax
addq (%rsi), %rax
leaq 0x238(%rsp), %rdi
movq %rax, %rsi
callq 0x486820
movq %rbx, 0x18(%rsp)
addq $0x80, %rbx
leaq 0x1f8(%rsp), %rdi
movq %rbx, %rsi
callq 0x486820
movzwl %bp, %ebp
leaq 0x290(%rsp), %rdi
movl %ebp, %esi
callq 0x4060ae
leaq 0x19198c(%rip), %rsi    # 0x59c522
leaq 0x490(%rsp), %rdi
leaq 0x290(%rsp), %rdx
callq 0x406146
leaq 0x1916fa(%rip), %rdx    # 0x59c2ac
leaq 0x1d8(%rsp), %rdi
leaq 0x490(%rsp), %rsi
callq 0x405f45
leaq 0x218(%rsp), %rdi
leaq 0x1f8(%rsp), %rsi
leaq 0x1d8(%rsp), %rdx
callq 0x405fcb
leaq 0x1d8(%rsp), %rdi
callq 0x484210
leaq 0x490(%rsp), %rdi
callq 0x484210
leaq 0x290(%rsp), %rdi
callq 0x484210
leaq 0x1f8(%rsp), %rdi
callq 0x484210
leaq 0x198(%rsp), %rdi
movq %rbx, %rsi
callq 0x486820
leaq 0x290(%rsp), %rdi
movl %ebp, %esi
callq 0x4060ae
leaq 0x1918f2(%rip), %rsi    # 0x59c530
leaq 0x490(%rsp), %rdi
leaq 0x290(%rsp), %rdx
callq 0x406146
leaq 0x191652(%rip), %rdx    # 0x59c2ac
leaq 0x178(%rsp), %rdi
leaq 0x490(%rsp), %rsi
callq 0x405f45
leaq 0x1b8(%rsp), %rdi
leaq 0x198(%rsp), %rsi
leaq 0x178(%rsp), %rdx
callq 0x405fcb
leaq 0x178(%rsp), %rdi
callq 0x484210
leaq 0x490(%rsp), %rdi
callq 0x484210
leaq 0x290(%rsp), %rdi
callq 0x484210
leaq 0x198(%rsp), %rdi
callq 0x484210
leaq 0x490(%rsp), %rdi
leaq 0x238(%rsp), %rsi
pushq $0x8
popq %rdx
callq 0x45a300
leaq 0x290(%rsp), %rdi
leaq 0x218(%rsp), %rsi
pushq $0x10
popq %rdx
callq 0x45a470
leaq 0x698(%rsp), %rdi
leaq 0x1b8(%rsp), %rsi
pushq $0x10
popq %rdx
callq 0x45a470
andq $0x0, 0xb0(%rsp)
andq $0x0, 0xf8(%rsp)
andl $0x0, 0x100(%rsp)
andq $0x0, 0x108(%rsp)
xorps %xmm0, %xmm0
andl $0x0, 0x110(%rsp)
movaps %xmm0, 0xa0(%rsp)
andq $0x0, 0x118(%rsp)
leaq 0x490(%rsp), %rdi
leaq 0x40(%rsp), %rsi
callq 0x486ad0
leaq 0x20b9c8(%rip), %rdi    # 0x616728
callq 0x407f5e
leaq 0x40(%rsp), %rbx
movq 0x8(%rbx), %rax
movq 0x20b9a3(%rip), %rcx    # 0x616718
addq %rcx, %rax
incq %rax
movq %rax, 0x20b996(%rip)    # 0x616718
leaq 0x20b99f(%rip), %rdi    # 0x616728
callq 0x4f57b0
leaq 0x290(%rsp), %rdi
movq %rbx, %rsi
callq 0x486ac0
leaq 0x191799(%rip), %rsi    # 0x59c53e
movq %rax, %rdi
callq 0x47de40
leaq 0x698(%rsp), %rdi
leaq 0x40(%rsp), %rsi
callq 0x486ac0
leaq 0x19177c(%rip), %rsi    # 0x59c542
movq %rax, %rdi
callq 0x47de40
leaq 0x19174b(%rip), %rsi    # 0x59c520
leaq 0x40(%rsp), %rbx
movq %rbx, %rdi
xorl %edx, %edx
callq 0x485d70
leaq 0x1(%rax), %rdx
leaq 0xc0(%rsp), %rdi
pushq $-0x1
popq %rcx
movq %rbx, %rsi
callq 0x486a40
leaq 0x40(%rsp), %rbx
leaq 0xc0(%rsp), %r15
movq %rbx, %rdi
movq %r15, %rsi
callq 0x484260
movq %r15, %rdi
callq 0x484210
leaq 0x1916fe(%rip), %rsi    # 0x59c520
movq %rbx, %rdi
xorl %edx, %edx
callq 0x485d70
movq %rax, %rbp
movq 0x18(%rsp), %rax
leaq 0x158(%rax), %rcx
movq %rcx, 0x10(%rsp)
leaq 0x160(%rax), %r14
leaq 0x120(%rsp), %r12
pushq $-0x1
popq %r13
cmpq $-0x1, %rbp
je 0x40aee8
movq %r15, %rdi
movq %rbx, %rsi
xorl %edx, %edx
movq %rbp, %rcx
callq 0x486a40
leaq 0xa0(%rsp), %rdi
movq %r15, %rsi
callq 0x408300
movq 0x10(%rsp), %rdi
movq %r15, %rsi
callq 0x40bd98
xorl %esi, %esi
cmpq %r14, %rax
setne %sil
leaq 0xf8(%rsp), %rdi
callq 0x40b9be
incq %rbp
movq %r12, %rdi
movq %rbx, %rsi
movq %rbp, %rdx
movq %r13, %rcx
callq 0x486a40
movq %rbx, %rdi
movq %r12, %rsi
callq 0x484260
movq %r12, %rdi
callq 0x484210
movq %rbx, %rdi
leaq 0x19164f(%rip), %rsi    # 0x59c520
xorl %edx, %edx
callq 0x485d70
movq %rax, %rbp
movq %r15, %rdi
callq 0x484210
jmp 0x40ae53
leaq 0xa0(%rsp), %rdi
leaq 0x40(%rsp), %rsi
callq 0x408300
leaq 0x40(%rsp), %rsi
movq 0x10(%rsp), %rdi
callq 0x40bd98
xorl %esi, %esi
cmpq %r14, %rax
setne %sil
leaq 0xf8(%rsp), %rdi
callq 0x40b9be
leaq 0x40(%rsp), %r12
leaq 0x120(%rsp), %r15
leaq 0x158(%rsp), %r13
leaq 0x490(%rsp), %rdi
movq %r12, %rsi
callq 0x486ad0
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x40b31f
leaq 0xc0(%rsp), %rdi
movq %r12, %rsi
callq 0x486820
movq %r12, %rdi
leaq 0x1915b0(%rip), %rbx    # 0x59c520
movq %rbx, %rsi
xorl %edx, %edx
callq 0x485d70
leaq 0x1(%rax), %rdx
movq %r15, %rdi
movq %r12, %rsi
pushq $-0x1
popq %rcx
callq 0x486a40
movq %r12, %rdi
movq %r15, %rsi
callq 0x484260
movq %r15, %rdi
callq 0x484210
movq %r12, %rdi
movq %rbx, %rsi
xorl %edx, %edx
callq 0x485d70
andq $0x0, 0x90(%rsp)
movq %rax, %rbp
andq $0x0, 0x70(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x80(%rsp)
andq $0x0, 0xf0(%rsp)
movaps %xmm0, 0x60(%rsp)
movaps %xmm0, 0xe0(%rsp)
xorl %r14d, %r14d
xorl %ebx, %ebx
cmpq $-0x1, %rbp
je 0x40b108
movq %r15, %rdi
movq %r12, %rsi
xorl %edx, %edx
movq %rbp, %rcx
callq 0x486a40
movq %r15, %rdi
xorl %esi, %esi
callq 0x40b89a
movss %xmm0, 0x20(%rsp)
leaq 0xf8(%rsp), %rdi
movq %rbx, %rsi
callq 0x40b9fc
testq %rdx, (%rax)
je 0x40b0b9
leaq 0xe0(%rsp), %rdi
leaq 0x20(%rsp), %rsi
callq 0x40b8b4
movss 0x20(%rsp), %xmm0
ucomiss 0x191482(%rip), %xmm0   # 0x59c4c8
jne 0x40b084
jp 0x40b084
movq 0xa0(%rsp), %rsi
addq %r14, %rsi
movq 0x10(%rsp), %rdi
callq 0x4081f6
movq %rax, %rdi
xorl %esi, %esi
callq 0x40b89a
movss %xmm0, 0x158(%rsp)
leaq 0x80(%rsp), %rdi
movq %r13, %rsi
callq 0x408fa8
jmp 0x40b0b9
movq 0xa0(%rsp), %rsi
addq %r14, %rsi
movq 0x10(%rsp), %rdi
callq 0x4081f6
movq %rax, %rdi
xorl %esi, %esi
callq 0x40b89a
movss %xmm0, 0x158(%rsp)
leaq 0x60(%rsp), %rdi
movq %r13, %rsi
callq 0x408fa8
incq %rbp
movq %r13, %rdi
movq %r12, %rsi
movq %rbp, %rdx
pushq $-0x1
popq %rcx
callq 0x486a40
movq %r12, %rdi
movq %r13, %rsi
callq 0x484260
movq %r13, %rdi
callq 0x484210
movq %r12, %rdi
leaq 0x191436(%rip), %rsi    # 0x59c520
xorl %edx, %edx
callq 0x485d70
movq %rax, %rbp
incq %rbx
movq %r15, %rdi
callq 0x484210
addq $0x20, %r14
jmp 0x40afe4
leaq 0x80(%rsp), %rdi
leaq 0x60(%rsp), %rsi
callq 0x412f40
movss %xmm0, 0x8(%rsp)
movq 0x18(%rsp), %rax
movss 0x14(%rax), %xmm0
ucomiss 0x8(%rsp), %xmm0
jbe 0x40b185
leaq 0x290(%rsp), %rdi
leaq 0xc0(%rsp), %rsi
callq 0x486ac0
movq %rax, %rdi
pushq $0x9
popq %rsi
callq 0x47dd70
movq %rax, %rbx
movq %r15, %rdi
movss 0x8(%rsp), %xmm0
callq 0x40b8d6
movq %rbx, %rdi
movq %r15, %rsi
callq 0x486ac0
movq %rax, %rdi
pushq $0xa
popq %rsi
callq 0x47dd70
movq %r15, %rdi
callq 0x484210
jmp 0x40b2b5
andq $0x0, 0x30(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x20(%rsp)
movq 0x80(%rsp), %rdx
movq 0x88(%rsp), %rcx
leaq 0x20(%rsp), %rbx
movq %rbx, %rdi
xorl %esi, %esi
callq 0x40ba1a
movq 0x28(%rsp), %rsi
movq 0x60(%rsp), %rdx
movq 0x68(%rsp), %rcx
movq %rbx, %rdi
callq 0x40ba1a
leaq 0x140(%rsp), %rdi
leaq 0xe0(%rsp), %rsi
callq 0x409324
leaq 0x278(%rsp), %r14
movq %r14, %rdi
leaq 0x20(%rsp), %rsi
callq 0x409324
leaq 0x140(%rsp), %rbx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x4130e7
movss %xmm0, 0xc(%rsp)
movq %r14, %rdi
callq 0x408710
movq %rbx, %rdi
callq 0x408710
movq 0x18(%rsp), %rax
movss 0xc(%rsp), %xmm0
ucomiss 0x1c(%rax), %xmm0
jb 0x40b2ab
leaq 0x698(%rsp), %rdi
leaq 0xc0(%rsp), %rsi
callq 0x486ac0
movq %rax, %rdi
pushq $0x9
popq %rsi
callq 0x47dd70
movq %rax, %rbx
movq %r15, %rdi
movss 0x8(%rsp), %xmm0
callq 0x40b8d6
movq %rbx, %rdi
movq %r15, %rsi
callq 0x486ac0
movq %rax, %rdi
pushq $0x9
popq %rsi
callq 0x47dd70
movq %rax, %rbx
movq %r13, %rdi
movss 0xc(%rsp), %xmm0
callq 0x40b8d6
movq %rbx, %rdi
movq %r13, %rsi
callq 0x486ac0
movq %rax, %rdi
pushq $0xa
popq %rsi
callq 0x47dd70
movq %r13, %rdi
callq 0x484210
movq %r15, %rdi
callq 0x484210
leaq 0x20(%rsp), %rdi
callq 0x408710
leaq 0x20b46c(%rip), %rdi    # 0x616728
callq 0x407f5e
movq 0xc8(%rsp), %rax
movq 0x20b448(%rip), %rcx    # 0x616718
addq %rcx, %rax
incq %rax
movq %rax, 0x20b43b(%rip)    # 0x616718
leaq 0x20b444(%rip), %rdi    # 0x616728
callq 0x4f57b0
leaq 0xe0(%rsp), %rdi
callq 0x408710
leaq 0x60(%rsp), %rdi
callq 0x408710
leaq 0x80(%rsp), %rdi
callq 0x408710
leaq 0xc0(%rsp), %rdi
callq 0x484210
jmp 0x40af34
leaq 0xf8(%rsp), %rdi
callq 0x40ba3a
leaq 0xa0(%rsp), %rdi
callq 0x40616a
leaq 0x698(%rsp), %rdi
callq 0x45aef0
leaq 0x290(%rsp), %rdi
callq 0x45aef0
leaq 0x490(%rsp), %rdi
callq 0x45b030
leaq 0x1b8(%rsp), %rdi
callq 0x484210
leaq 0x218(%rsp), %rdi
callq 0x484210
leaq 0x238(%rsp), %rdi
callq 0x484210
leaq 0x258(%rsp), %rdi
callq 0x484210
leaq 0x40(%rsp), %rdi
callq 0x484210
addq $0x898, %rsp            # imm = 0x898
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x40b4e5
jmp 0x40b4e5
movq %rax, %rbx
jmp 0x40b566
movq %rax, %rbx
jmp 0x40b573
movq %rax, %rbx
jmp 0x40b580
movq %rax, %rbx
leaq 0x178(%rsp), %rdi
callq 0x484210
jmp 0x40b3e7
movq %rax, %rbx
leaq 0x490(%rsp), %rdi
callq 0x484210
jmp 0x40b3f9
movq %rax, %rbx
leaq 0x290(%rsp), %rdi
callq 0x484210
jmp 0x40b40b
movq %rax, %rbx
leaq 0x198(%rsp), %rdi
jmp 0x40b588
movq %rax, %rbx
jmp 0x40b58d
movq %rax, %rbx
leaq 0x1d8(%rsp), %rdi
callq 0x484210
jmp 0x40b435
movq %rax, %rbx
leaq 0x490(%rsp), %rdi
callq 0x484210
jmp 0x40b447
movq %rax, %rbx
leaq 0x290(%rsp), %rdi
callq 0x484210
jmp 0x40b459
movq %rax, %rbx
leaq 0x1f8(%rsp), %rdi
jmp 0x40b595
movq %rax, %rbx
jmp 0x40b59a
movq %rax, %rbx
jmp 0x40b5a7
jmp 0x40b4ca
jmp 0x40b4a2
jmp 0x40b4e5
movq %rax, %rbx
leaq 0x278(%rsp), %rdi
callq 0x408710
jmp 0x40b4b7
jmp 0x40b4ca
movq %rax, %rbx
leaq 0x158(%rsp), %rdi
callq 0x484210
jmp 0x40b4a5
movq %rax, %rbx
leaq 0x120(%rsp), %rdi
callq 0x484210
jmp 0x40b4cd
movq %rax, %rbx
leaq 0x140(%rsp), %rdi
callq 0x408710
jmp 0x40b4cd
jmp 0x40b4ca
jmp 0x40b4f5
movq %rax, %rbx
leaq 0x20(%rsp), %rdi
callq 0x408710
jmp 0x40b50e
jmp 0x40b4fe
jmp 0x40b4e5
jmp 0x40b4ea
jmp 0x40b4ea
jmp 0x40b4ea
jmp 0x40b4e5
movq %rax, %rbx
jmp 0x40b53f
movq %rax, %rbx
jmp 0x40b532
jmp 0x40b4f5
jmp 0x40b4fe
jmp 0x40b4fe
movq %rax, %rbx
jmp 0x40b50e
jmp 0x40b4fe
jmp 0x40b4fe
movq %rax, %rbx
leaq 0x120(%rsp), %rdi
callq 0x484210
leaq 0xe0(%rsp), %rdi
callq 0x408710
leaq 0x60(%rsp), %rdi
callq 0x408710
leaq 0x80(%rsp), %rdi
callq 0x408710
leaq 0xc0(%rsp), %rdi
callq 0x484210
leaq 0xf8(%rsp), %rdi
callq 0x40ba3a
leaq 0xa0(%rsp), %rdi
callq 0x40616a
leaq 0x698(%rsp), %rdi
callq 0x45aef0
leaq 0x290(%rsp), %rdi
callq 0x45aef0
leaq 0x490(%rsp), %rdi
callq 0x45b030
leaq 0x1b8(%rsp), %rdi
callq 0x484210
leaq 0x218(%rsp), %rdi
callq 0x484210
leaq 0x238(%rsp), %rdi
callq 0x484210
leaq 0x258(%rsp), %rdi
callq 0x484210
leaq 0x40(%rsp), %rdi
callq 0x484210
movq %rbx, %rdi
callq 0x4b8e10