// File: /workspace/github_cpp_makefile_star2_O2/auton1[P]motiflocation/DNA.cpp
// Function: DNA::readFASTA(char const*, bool, bool, bool)
bool DNA::readFASTA(const char* filename, bool uppercase_only, bool lowercase_only, bool KG_ref=false)
{
	bool output = true;
	int count;
	int i;
	char buffer[5120];
	int bufsize = 5120;
	int nonstandard;
	string junk, junk2;
	junk.reserve(bufsize);
	junk2.reserve(bufsize);
	igzstream in, in2;

	NSeqs = 0;
	in2.open(filename, ios::in);
	if (in2.good())
	{
		while(!in2.eof())
		{
			in2.getline(buffer, bufsize);
			if (buffer[0] == '>')
			{
				string s = buffer;
				s = s.substr(1);
				if (KG_ref == true)
				{
					string::size_type pos=s.find(' ',0);
					s = s.substr(0,pos);
				}
				cout << s << endl;
				NSeqs++;
			}
		}
		header.resize(NSeqs);
		sequence.resize(NSeqs);
		cout << "\t" << NSeqs << " sequences" << endl;

		in2.close();

		in.open(filename, ios::in);
		in.getline(buffer, bufsize);
		junk = buffer;
		if (junk[0] != '>')
		{
			cout << "Error first line is not a headerline" << endl;
			exit(0);
		}
		Trim(junk);
		i=0;
		while(!in.eof())
		{
			if (junk[0] == '>')
			{
				if (KG_ref == false)
				{
					int pos = junk.find(" ");
					while (pos != -1)
					{
						junk.replace(pos,1,"_");
						pos = junk.find(" ");
					}
				}
				else
				{
					string::size_type pos=junk.find(' ',0);
					junk = junk.substr(0,pos);
				}
				header[i].append(junk.substr(1));
				i++;
				count = 0;
				in.getline(buffer, bufsize);
				junk = buffer;
				remove_upper_or_lowercase(junk, uppercase_only, lowercase_only);
				std::transform (junk.begin(), junk.end(), junk.begin(), ToLower());
				Trim(junk);
			}
			else
			{
				junk2 = "";
				while ((junk[0] != '>') && (!in.eof()))
				{
					junk2.append(junk);
					in.getline(buffer, bufsize);
					junk = buffer;
					Trim(junk);
					if (junk[0] != '>')
					{
						remove_upper_or_lowercase(junk, uppercase_only, lowercase_only);
						std::transform (junk.begin(), junk.end(), junk.begin(), ToLower());
						nonstandard = 1;
						while (nonstandard != -1)
						{
							nonstandard = (int)junk.find_first_not_of(" /t/nacgtn/0");
							if (nonstandard != -1)
							{
								cout << "Non-standard character found on line " << i << endl;
								junk[nonstandard] = 'n';
							}
						}
					}
				}
				sequence[i-1].append(junk2);
			}
		}
		in.close();

		SeqLength.resize(NSeqs);
		for (i=0; i < NSeqs; i++)
		{
			SeqLength[i] = (unsigned int)(sequence[i].length());
		}
	}
	else
	{
		cout << "Unable to open file: " << filename << endl;
		abort();
	}

	return output;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1a08, %rsp           # imm = 0x1A08
movl %r8d, 0x24(%rsp)
movl %ecx, %ebx
movl %edx, %ebp
movq %rsi, 0x18(%rsp)
movq %rdi, 0x10(%rsp)
leaq 0x40(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
xorl %ecx, %ecx
movb %cl, (%rax)
leaq 0x70(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb %cl, (%rax)
leaq 0x30(%rsp), %rdi
movl $0x1400, %esi           # imm = 0x1400
callq 0x33d0
leaq 0x60(%rsp), %rdi
movl $0x1400, %esi           # imm = 0x1400
callq 0x33d0
leaq 0xc0(%rsp), %rdi
callq 0x63be
leaq 0x360(%rsp), %rdi
callq 0x63be
movl %ebp, 0x28(%rsp)
movl %ebx, 0xc(%rsp)
movq 0x10(%rsp), %rax
andl $0x0, 0x50(%rax)
leaq 0x360(%rsp), %rdi
pushq $0x8
popq %rdx
movq 0x18(%rsp), %rsi
callq 0x7748
movq 0x360(%rsp), %rax
movq -0x18(%rax), %rax
cmpl $0x0, 0x380(%rsp,%rax)
jne 0x6226
leaq 0x4e8(%rsp), %r14
leaq 0x600(%rsp), %r15
leaq 0x80(%rsp), %r12
leaq 0xa0(%rsp), %r13
pushq $-0x1
popq %rbx
movq 0x626e(%rip), %rbp      # 0xbfd8
testb $0x2, 0x380(%rsp,%rax)
jne 0x5e33
movl $0x1400, %edx           # imm = 0x1400
movq %r14, %rdi
movq %r15, %rsi
callq 0x30a0
cmpb $0x3e, 0x600(%rsp)
jne 0x5e22
movq %r12, %rdi
movq %r15, %rsi
movq %r13, %rdx
callq 0x437a
movq %r13, %rdi
movq %r12, %rsi
pushq $0x1
popq %rdx
movq %rbx, %rcx
callq 0x3280
movq %r12, %rdi
movq %r13, %rsi
callq 0x32b0
movq %r13, %rdi
callq 0x3110
cmpb $0x0, 0x24(%rsp)
je 0x5dff
movq %r12, %rdi
pushq $0x20
popq %rsi
xorl %edx, %edx
callq 0x32e0
movq %r13, %rdi
movq %r12, %rsi
xorl %edx, %edx
movq %rax, %rcx
callq 0x3280
movq %r12, %rdi
movq %r13, %rsi
callq 0x32b0
movq %r13, %rdi
callq 0x3110
movq %rbp, %rdi
movq %r12, %rsi
callq 0x3220
movq %rax, %rdi
callq 0x3120
movq 0x10(%rsp), %rax
incl 0x50(%rax)
movq %r12, %rdi
callq 0x3110
movq 0x360(%rsp), %rax
movq -0x18(%rax), %rax
jmp 0x5d6a
movq 0x10(%rsp), %rax
leaq 0x20(%rax), %rdi
movslq 0x50(%rax), %rsi
movq %rdi, 0x58(%rsp)
callq 0x638e
movq 0x10(%rsp), %rax
leaq 0x8(%rax), %rdi
movslq 0x50(%rax), %rsi
movq %rdi, 0x50(%rsp)
callq 0x638e
movq 0x6170(%rip), %rdi      # 0xbfd8
leaq 0x22f1(%rip), %rsi      # 0x8160
callq 0x3250
movq 0x10(%rsp), %rcx
movl 0x50(%rcx), %esi
movq %rax, %rdi
callq 0x3440
leaq 0x27f0(%rip), %rsi      # 0x867b
movq %rax, %rdi
callq 0x3250
movq %rax, %rdi
callq 0x3120
leaq 0x360(%rsp), %rdi
callq 0x7888
leaq 0xc0(%rsp), %rdi
pushq $0x8
popq %rdx
movq 0x18(%rsp), %rsi
callq 0x7748
leaq 0x248(%rsp), %rdi
leaq 0x600(%rsp), %rsi
movl $0x1400, %edx           # imm = 0x1400
callq 0x30a0
leaq 0x30(%rsp), %rdi
leaq 0x600(%rsp), %rsi
callq 0x34c0
movq 0x30(%rsp), %rax
cmpb $0x3e, (%rax)
jne 0x6253
leaq 0x30(%rsp), %rsi
callq 0x56dc
xorl %r13d, %r13d
leaq 0x30(%rsp), %r15
leaq 0x80(%rsp), %rbp
movzbl 0x28(%rsp), %eax
movl %eax, 0x18(%rsp)
movzbl 0xc(%rsp), %eax
movl %eax, 0xc(%rsp)
leaq 0x2783(%rip), %r14      # 0x86ad
movq 0x60a7(%rip), %rbx      # 0xbfd8
leaq 0x2782(%rip), %r12      # 0x86ba
movl %r13d, %r13d
movq %r13, %rax
shlq $0x5, %rax
movq %rax, 0x28(%rsp)
movq 0xc0(%rsp), %rax
movq -0x18(%rax), %rax
testb $0x2, 0xe0(%rsp,%rax)
jne 0x6195
movq 0x30(%rsp), %rax
cmpb $0x3e, (%rax)
je 0x6091
leaq 0x60(%rsp), %rdi
leaq 0x21e6(%rip), %rsi      # 0x8161
callq 0x34c0
movq 0x30(%rsp), %rax
cmpb $0x3e, (%rax)
je 0x6065
movq 0xc0(%rsp), %rax
movq -0x18(%rax), %rax
testb $0x2, 0xe0(%rsp,%rax)
jne 0x6065
leaq 0x60(%rsp), %rdi
movq %r15, %rsi
callq 0x34d0
movl $0x1400, %edx           # imm = 0x1400
leaq 0x248(%rsp), %rdi
leaq 0x600(%rsp), %rsi
callq 0x30a0
movq %r15, %rdi
leaq 0x600(%rsp), %rsi
callq 0x34c0
movq %r15, %rsi
callq 0x56dc
movq 0x30(%rsp), %rax
cmpb $0x3e, (%rax)
je 0x5f80
movq %r15, %rsi
movl 0x18(%rsp), %edx
movl 0xc(%rsp), %ecx
callq 0x5be0
movq 0x30(%rsp), %rdi
movq 0x38(%rsp), %rsi
addq %rdi, %rsi
movq %rdi, %rdx
callq 0x635f
pushq $0x1
popq %rax
movl %eax, %ebp
cmpl $-0x1, %ebp
je 0x5f80
movq %r15, %rdi
movq %r14, %rsi
xorl %edx, %edx
callq 0x3190
movq %rax, %rbp
cmpl $-0x1, %ebp
je 0x601b
movq %rbx, %rdi
movq %r12, %rsi
callq 0x3250
movq %rax, %rdi
movl %r13d, %esi
callq 0x3440
movq %rax, %rdi
callq 0x3120
movslq %ebp, %rax
movq 0x30(%rsp), %rcx
movb $0x6e, (%rcx,%rax)
jmp 0x601b
movq 0x50(%rsp), %rax
movq (%rax), %rax
movq 0x28(%rsp), %rcx
leaq (%rax,%rcx), %rdi
addq $-0x20, %rdi
leaq 0x60(%rsp), %rsi
callq 0x34d0
leaq 0x80(%rsp), %rbp
jmp 0x5f47
cmpb $0x0, 0x24(%rsp)
je 0x6164
movq %r15, %rdi
pushq $0x20
popq %rsi
xorl %edx, %edx
callq 0x32e0
movq %rbp, %rdi
movq %r15, %rsi
xorl %edx, %edx
movq %rax, %rcx
callq 0x3280
movq %r15, %rdi
movq %rbp, %rsi
callq 0x32b0
movq %rbp, %rdi
callq 0x3110
movq 0x58(%rsp), %rax
movq %rbp, %rdi
movq (%rax), %rbp
movq %r15, %rsi
pushq $0x1
popq %rdx
pushq $-0x1
popq %rcx
callq 0x3280
addq 0x28(%rsp), %rbp
movq %rbp, %rdi
leaq 0x80(%rsp), %rbp
movq %rbp, %rsi
callq 0x34d0
movq %rbp, %rdi
callq 0x3110
movl $0x1400, %edx           # imm = 0x1400
leaq 0x248(%rsp), %rdi
leaq 0x600(%rsp), %rsi
callq 0x30a0
movq %r15, %rdi
leaq 0x600(%rsp), %rsi
callq 0x34c0
movq %r15, %rsi
movl 0x18(%rsp), %edx
movl 0xc(%rsp), %ecx
callq 0x5be0
movq 0x30(%rsp), %rdi
movq 0x38(%rsp), %rsi
addq %rdi, %rsi
movq %rdi, %rdx
callq 0x635f
incl %r13d
movq %r15, %rsi
callq 0x56dc
jmp 0x5f38
movq %r15, %rdi
leaq 0x247a(%rip), %rsi      # 0x85e8
xorl %edx, %edx
callq 0x34e0
cmpl $-0x1, %eax
je 0x60cc
movslq %eax, %rsi
movq %r15, %rdi
pushq $0x1
popq %rdx
leaq 0x251d(%rip), %rcx      # 0x86ab
callq 0x31a0
jmp 0x6164
leaq 0xc0(%rsp), %rdi
callq 0x7888
movq 0x10(%rsp), %rax
leaq 0x38(%rax), %rbx
movslq 0x50(%rax), %rsi
movq %rbx, %rdi
callq 0x6490
movq 0x50(%rsp), %rax
movq (%rax), %rax
movq (%rbx), %rcx
addq $0x8, %rax
xorl %edx, %edx
movq 0x10(%rsp), %rsi
movslq 0x50(%rsi), %rsi
cmpq %rsi, %rdx
jge 0x61e4
movl (%rax), %esi
movl %esi, (%rcx,%rdx,4)
incq %rdx
addq $0x20, %rax
jmp 0x61c8
leaq 0x360(%rsp), %rdi
callq 0x64c2
leaq 0xc0(%rsp), %rdi
callq 0x64c2
leaq 0x60(%rsp), %rdi
callq 0x3110
leaq 0x30(%rsp), %rdi
callq 0x3110
movb $0x1, %al
addq $0x1a08, %rsp           # imm = 0x1A08
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x5dab(%rip), %rdi      # 0xbfd8
leaq 0x24ac(%rip), %rsi      # 0x86e0
callq 0x3250
movq %rax, %rdi
movq 0x18(%rsp), %rsi
callq 0x3250
movq %rax, %rdi
callq 0x3120
callq 0x3170
movq 0x5d7e(%rip), %rdi      # 0xbfd8
leaq 0x2425(%rip), %rsi      # 0x8686
callq 0x3250
movq %rax, %rdi
callq 0x3120
xorl %edi, %edi
callq 0x32a0
jmp 0x62ab
jmp 0x6293
jmp 0x62ab
movq %rax, %rbx
jmp 0x62bb
jmp 0x6282
movq %rax, %rbx
jmp 0x62c8
jmp 0x62ab
jmp 0x6293
jmp 0x62ab
jmp 0x6293
jmp 0x62ab
jmp 0x62ab
movq %rax, %rbx
leaq 0x80(%rsp), %rdi
callq 0x3110
jmp 0x62ae
jmp 0x62ab
jmp 0x62ab
jmp 0x62ab
movq %rax, %rbx
leaq 0x360(%rsp), %rdi
callq 0x64c2
leaq 0xc0(%rsp), %rdi
callq 0x64c2
leaq 0x60(%rsp), %rdi
callq 0x3110
leaq 0x30(%rsp), %rdi
callq 0x3110
movq %rbx, %rdi
callq 0x3470