// File: 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:
subq $0x1bc8, %rsp           # imm = 0x1BC8
movb %r8b, %al
movq %rdi, 0x1bc0(%rsp)
movq %rsi, 0x1bb8(%rsp)
andb $0x1, %dl
movb %dl, 0x1bb7(%rsp)
andb $0x1, %cl
movb %cl, 0x1bb6(%rsp)
andb $0x1, %al
movb %al, 0x1bb5(%rsp)
movq 0x1bc0(%rsp), %rax
movq %rax, 0xe8(%rsp)
movb $0x1, 0x1bb4(%rsp)
movl $0x1400, 0x79c(%rsp) # imm = 0x1400
leaq 0x778(%rsp), %rdi
movq %rdi, 0xf0(%rsp)
callq 0x4450
leaq 0x758(%rsp), %rdi
callq 0x4450
movq 0xf0(%rsp), %rdi
movslq 0x79c(%rsp), %rsi
callq 0x4530
jmp 0xca93
movslq 0x79c(%rsp), %rsi
leaq 0x758(%rsp), %rdi
callq 0x4530
jmp 0xcaaa
leaq 0x4a8(%rsp), %rdi
callq 0xd8c0
jmp 0xcab9
leaq 0x208(%rsp), %rdi
callq 0xd8c0
jmp 0xcac8
movq 0xe8(%rsp), %rax
movl $0x0, 0x50(%rax)
movq 0x1bb8(%rsp), %rsi
leaq 0x208(%rsp), %rdi
movl $0x8, %edx
callq 0xd9d0
jmp 0xcaf3
movq 0x208(%rsp), %rax
movq -0x18(%rax), %rax
leaq 0x208(%rsp,%rax), %rdi
callq 0x45b0
movb %al, 0xe7(%rsp)
jmp 0xcb15
movb 0xe7(%rsp), %al
testb $0x1, %al
jne 0xcb25
jmp 0xd534
jmp 0xcb27
movq 0x208(%rsp), %rax
movq -0x18(%rax), %rax
leaq 0x208(%rsp,%rax), %rdi
callq 0x4660
movb %al, 0xe6(%rsp)
jmp 0xcb49
movb 0xe6(%rsp), %al
xorb $-0x1, %al
testb $0x1, %al
jne 0xcb5b
jmp 0xcd90
leaq 0x390(%rsp), %rdi
movslq 0x79c(%rsp), %rdx
leaq 0x7a0(%rsp), %rsi
callq 0x40f0
jmp 0xcb7a
movsbl 0x7a0(%rsp), %eax
cmpl $0x3e, %eax
jne 0xcd8b
leaq 0x1e7(%rsp), %rdi
movq %rdi, 0xd8(%rsp)
callq 0x4610
movq 0xd8(%rsp), %rdx
leaq 0x1e8(%rsp), %rdi
leaq 0x7a0(%rsp), %rsi
callq 0x6300
jmp 0xcbbf
leaq 0x1e7(%rsp), %rdi
callq 0x4380
leaq 0x1c0(%rsp), %rdi
leaq 0x1e8(%rsp), %rsi
movl $0x1, %edx
movq $-0x1, %rcx
callq 0x4350
jmp 0xcbef
leaq 0x1e8(%rsp), %rdi
leaq 0x1c0(%rsp), %rsi
callq 0x43d0
leaq 0x1c0(%rsp), %rdi
callq 0x4220
movb 0x1bb5(%rsp), %al
andb $0x1, %al
movzbl %al, %eax
cmpl $0x1, %eax
jne 0xcd39
xorl %eax, %eax
movl %eax, %edx
movq %rdx, 0xd0(%rsp)
leaq 0x1e8(%rsp), %rdi
movq %rdi, 0xc8(%rsp)
movl $0x20, %esi
callq 0x4410
movq 0xc8(%rsp), %rsi
movq 0xd0(%rsp), %rdx
movq %rax, 0x1b8(%rsp)
movq 0x1b8(%rsp), %rcx
leaq 0x198(%rsp), %rdi
callq 0x4350
jmp 0xcc7b
leaq 0x1e8(%rsp), %rdi
leaq 0x198(%rsp), %rsi
callq 0x43d0
leaq 0x198(%rsp), %rdi
callq 0x4220
jmp 0xcd39
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x750(%rsp)
movl %eax, 0x74c(%rsp)
jmp 0xd5e6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x750(%rsp)
movl %eax, 0x74c(%rsp)
jmp 0xd5d9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x750(%rsp)
movl %eax, 0x74c(%rsp)
jmp 0xd5cc
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x750(%rsp)
movl %eax, 0x74c(%rsp)
leaq 0x1e7(%rsp), %rdi
callq 0x4380
jmp 0xd5cc
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x750(%rsp)
movl %eax, 0x74c(%rsp)
leaq 0x1e8(%rsp), %rdi
callq 0x4220
jmp 0xd5cc
movq 0xa298(%rip), %rdi      # 0x16fd8
leaq 0x1e8(%rsp), %rsi
callq 0x42f0
movq %rax, 0xc0(%rsp)
jmp 0xcd57
movq 0xc0(%rsp), %rdi
movq 0xa262(%rip), %rsi      # 0x16fc8
callq 0x4360
jmp 0xcd6d
movq 0xe8(%rsp), %rax
movl 0x50(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x50(%rax)
leaq 0x1e8(%rsp), %rdi
callq 0x4220
jmp 0xcb27
movq 0xe8(%rsp), %rax
movq %rax, %rdi
addq $0x20, %rdi
movslq 0x50(%rax), %rsi
callq 0xd7c0
jmp 0xcdaa
movq 0xe8(%rsp), %rax
movq %rax, %rdi
addq $0x8, %rdi
movslq 0x50(%rax), %rsi
callq 0xd7c0
jmp 0xcdc4
movq 0xa20d(%rip), %rdi      # 0x16fd8
leaq 0x4378(%rip), %rsi      # 0x1114a
callq 0x4320
movq %rax, 0xb8(%rsp)
jmp 0xcde1
movq 0xb8(%rsp), %rdi
movq 0xe8(%rsp), %rax
movl 0x50(%rax), %esi
callq 0x45d0
movq %rax, 0xb0(%rsp)
jmp 0xce03
movq 0xb0(%rsp), %rdi
leaq 0x4a33(%rip), %rsi      # 0x11845
callq 0x4320
movq %rax, 0xa8(%rsp)
jmp 0xce21
movq 0xa8(%rsp), %rdi
movq 0xa198(%rip), %rsi      # 0x16fc8
callq 0x4360
jmp 0xce37
leaq 0x208(%rsp), %rdi
callq 0x10a60
jmp 0xce46
movq 0x1bb8(%rsp), %rsi
leaq 0x4a8(%rsp), %rdi
movl $0x8, %edx
callq 0xd9d0
jmp 0xce62
leaq 0x630(%rsp), %rdi
movslq 0x79c(%rsp), %rdx
leaq 0x7a0(%rsp), %rsi
callq 0x40f0
jmp 0xce81
leaq 0x778(%rsp), %rdi
leaq 0x7a0(%rsp), %rsi
callq 0x4430
jmp 0xce98
xorl %eax, %eax
movl %eax, %esi
leaq 0x778(%rsp), %rdi
callq 0x46b0
movq %rax, 0xa0(%rsp)
jmp 0xceb3
movq 0xa0(%rsp), %rax
movsbl (%rax), %eax
cmpl $0x3e, %eax
je 0xcefd
movq 0xa10e(%rip), %rdi      # 0x16fd8
leaq 0x497f(%rip), %rsi      # 0x11850
callq 0x4320
movq %rax, 0x98(%rsp)
jmp 0xcee0
movq 0x98(%rsp), %rdi
movq 0xa0d9(%rip), %rsi      # 0x16fc8
callq 0x4360
jmp 0xcef6
xorl %edi, %edi
callq 0x43c0
movq 0xe8(%rsp), %rdi
leaq 0x778(%rsp), %rsi
callq 0xbea0
jmp 0xcf14
movl $0x0, 0x1bac(%rsp)
movq 0x4a8(%rsp), %rax
movq -0x18(%rax), %rax
leaq 0x4a8(%rsp,%rax), %rdi
callq 0x4660
movb %al, 0x97(%rsp)
jmp 0xcf41
movb 0x97(%rsp), %al
xorb $-0x1, %al
testb $0x1, %al
jne 0xcf53
jmp 0xd493
xorl %eax, %eax
movl %eax, %esi
leaq 0x778(%rsp), %rdi
callq 0x46b0
movq %rax, 0x88(%rsp)
jmp 0xcf6e
movq 0x88(%rsp), %rax
movsbl (%rax), %eax
cmpl $0x3e, %eax
jne 0xd204
movb 0x1bb5(%rsp), %al
andb $0x1, %al
movzbl %al, %eax
cmpl $0x0, %eax
jne 0xd002
leaq 0x778(%rsp), %rdi
leaq 0x480e(%rip), %rsi      # 0x117b0
xorl %eax, %eax
movl %eax, %edx
callq 0x46a0
movl %eax, 0x194(%rsp)
cmpl $-0x1, 0x194(%rsp)
je 0xd000
movslq 0x194(%rsp), %rsi
leaq 0x48aa(%rip), %rcx      # 0x11875
leaq 0x778(%rsp), %rdi
movl $0x1, %edx
callq 0x4210
jmp 0xcfdf
leaq 0x778(%rsp), %rdi
leaq 0x47c2(%rip), %rsi      # 0x117b0
xorl %eax, %eax
movl %eax, %edx
callq 0x46a0
movl %eax, 0x194(%rsp)
jmp 0xcfb2
jmp 0xd073
xorl %eax, %eax
movl %eax, %edx
movq %rdx, 0x80(%rsp)
leaq 0x778(%rsp), %rdi
movq %rdi, 0x78(%rsp)
movl $0x20, %esi
callq 0x4410
movq 0x78(%rsp), %rsi
movq 0x80(%rsp), %rdx
movq %rax, 0x188(%rsp)
movq 0x188(%rsp), %rcx
leaq 0x168(%rsp), %rdi
callq 0x4350
jmp 0xd051
leaq 0x778(%rsp), %rdi
leaq 0x168(%rsp), %rsi
callq 0x43d0
leaq 0x168(%rsp), %rdi
callq 0x4220
movq 0xe8(%rsp), %rdi
addq $0x20, %rdi
movslq 0x1bac(%rsp), %rsi
callq 0x6460
movq %rax, 0x70(%rsp)
leaq 0x148(%rsp), %rdi
leaq 0x778(%rsp), %rsi
movl $0x1, %edx
movq $-0x1, %rcx
callq 0x4350
jmp 0xd0b4
movq 0x70(%rsp), %rdi
leaq 0x148(%rsp), %rsi
callq 0x4680
jmp 0xd0c8
leaq 0x148(%rsp), %rdi
callq 0x4220
movl 0x1bac(%rsp), %eax
incl %eax
movl %eax, 0x1bac(%rsp)
movl $0x0, 0x1bb0(%rsp)
leaq 0x630(%rsp), %rdi
movslq 0x79c(%rsp), %rdx
leaq 0x7a0(%rsp), %rsi
callq 0x40f0
jmp 0xd10f
leaq 0x778(%rsp), %rdi
leaq 0x7a0(%rsp), %rsi
callq 0x4430
jmp 0xd126
movq 0xe8(%rsp), %rdi
movzbl 0x1bb6(%rsp), %ecx
movzbl 0x1bb7(%rsp), %edx
andl $0x1, %edx
andl $0x1, %ecx
leaq 0x778(%rsp), %rsi
callq 0xc900
jmp 0xd153
leaq 0x778(%rsp), %rdi
movq %rdi, 0x60(%rsp)
callq 0x42c0
movq 0x60(%rsp), %rdi
movq %rax, 0x140(%rsp)
callq 0x41f0
movq 0x60(%rsp), %rdi
movq %rax, 0x138(%rsp)
callq 0x42c0
movq %rax, 0x130(%rsp)
movq 0x140(%rsp), %rdi
movq 0x138(%rsp), %rsi
movq 0x130(%rsp), %rdx
callq 0xd740
movq %rax, 0x68(%rsp)
jmp 0xd1b5
movq 0xe8(%rsp), %rdi
movq 0x68(%rsp), %rax
movq %rax, 0x120(%rsp)
leaq 0x778(%rsp), %rsi
callq 0xbea0
jmp 0xd1d9
jmp 0xd48e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x750(%rsp)
movl %eax, 0x74c(%rsp)
leaq 0x148(%rsp), %rdi
callq 0x4220
jmp 0xd5cc
leaq 0x3f40(%rip), %rsi      # 0x1114b
leaq 0x758(%rsp), %rdi
callq 0x4430
jmp 0xd21a
jmp 0xd21c
xorl %eax, %eax
movl %eax, %esi
leaq 0x778(%rsp), %rdi
callq 0x46b0
movq %rax, 0x58(%rsp)
jmp 0xd234
movq 0x58(%rsp), %rax
movsbl (%rax), %ecx
xorl %eax, %eax
cmpl $0x3e, %ecx
movb %al, 0x57(%rsp)
je 0xd270
movq 0x4a8(%rsp), %rax
movq -0x18(%rax), %rax
leaq 0x4a8(%rsp,%rax), %rdi
callq 0x4660
movb %al, 0x56(%rsp)
jmp 0xd266
movb 0x56(%rsp), %al
xorb $-0x1, %al
movb %al, 0x57(%rsp)
movb 0x57(%rsp), %al
testb $0x1, %al
jne 0xd27d
jmp 0xd45d
leaq 0x758(%rsp), %rdi
leaq 0x778(%rsp), %rsi
callq 0x4680
jmp 0xd294
leaq 0x630(%rsp), %rdi
movslq 0x79c(%rsp), %rdx
leaq 0x7a0(%rsp), %rsi
callq 0x40f0
jmp 0xd2b3
leaq 0x778(%rsp), %rdi
leaq 0x7a0(%rsp), %rsi
callq 0x4430
jmp 0xd2ca
movq 0xe8(%rsp), %rdi
leaq 0x778(%rsp), %rsi
callq 0xbea0
jmp 0xd2e1
xorl %eax, %eax
movl %eax, %esi
leaq 0x778(%rsp), %rdi
callq 0x46b0
movq %rax, 0x48(%rsp)
jmp 0xd2f9
movq 0x48(%rsp), %rax
movsbl (%rax), %eax
cmpl $0x3e, %eax
je 0xd458
movq 0xe8(%rsp), %rdi
movzbl 0x1bb6(%rsp), %ecx
movzbl 0x1bb7(%rsp), %edx
andl $0x1, %edx
andl $0x1, %ecx
leaq 0x778(%rsp), %rsi
callq 0xc900
jmp 0xd337
leaq 0x778(%rsp), %rdi
movq %rdi, 0x38(%rsp)
callq 0x42c0
movq 0x38(%rsp), %rdi
movq %rax, 0x118(%rsp)
callq 0x41f0
movq 0x38(%rsp), %rdi
movq %rax, 0x110(%rsp)
callq 0x42c0
movq %rax, 0x108(%rsp)
movq 0x118(%rsp), %rdi
movq 0x110(%rsp), %rsi
movq 0x108(%rsp), %rdx
callq 0xd740
movq %rax, 0x40(%rsp)
jmp 0xd399
movq 0x40(%rsp), %rax
movq %rax, 0xf8(%rsp)
movl $0x1, 0x798(%rsp)
cmpl $-0x1, 0x798(%rsp)
je 0xd456
leaq 0x778(%rsp), %rdi
leaq 0x44a9(%rip), %rsi      # 0x11877
xorl %eax, %eax
movl %eax, %edx
callq 0x41e0
movl %eax, 0x798(%rsp)
cmpl $-0x1, 0x798(%rsp)
je 0xd451
movq 0x9be9(%rip), %rdi      # 0x16fd8
leaq 0x448e(%rip), %rsi      # 0x11884
callq 0x4320
movq %rax, 0x30(%rsp)
jmp 0xd402
movq 0x30(%rsp), %rdi
movl 0x1bac(%rsp), %esi
callq 0x45d0
movq %rax, 0x28(%rsp)
jmp 0xd41a
movq 0x28(%rsp), %rdi
movq 0x9ba2(%rip), %rsi      # 0x16fc8
callq 0x4360
jmp 0xd42d
movslq 0x798(%rsp), %rsi
leaq 0x778(%rsp), %rdi
callq 0x46b0
movq %rax, 0x20(%rsp)
jmp 0xd449
movq 0x20(%rsp), %rax
movb $0x6e, (%rax)
jmp 0xd3b1
jmp 0xd458
jmp 0xd21c
movq 0xe8(%rsp), %rdi
addq $0x8, %rdi
movl 0x1bac(%rsp), %eax
decl %eax
movslq %eax, %rsi
callq 0x6460
movq %rax, %rdi
leaq 0x758(%rsp), %rsi
callq 0x4680
jmp 0xd48c
jmp 0xd48e
jmp 0xcf1f
leaq 0x4a8(%rsp), %rdi
callq 0x10a60
jmp 0xd4a2
movq 0xe8(%rsp), %rax
movq %rax, %rdi
addq $0x38, %rdi
movslq 0x50(%rax), %rsi
callq 0xdaa0
jmp 0xd4bc
movl $0x0, 0x1bac(%rsp)
movq 0xe8(%rsp), %rcx
movl 0x1bac(%rsp), %eax
cmpl 0x50(%rcx), %eax
jge 0xd532
movq 0xe8(%rsp), %rdi
addq $0x8, %rdi
movslq 0x1bac(%rsp), %rsi
callq 0x6460
movq %rax, %rdi
callq 0x4500
movq 0xe8(%rsp), %rdi
movl %eax, 0x1c(%rsp)
addq $0x38, %rdi
movslq 0x1bac(%rsp), %rsi
callq 0xdb40
movl 0x1c(%rsp), %ecx
movl %ecx, (%rax)
movl 0x1bac(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x1bac(%rsp)
jmp 0xd4c7
jmp 0xd57f
movq 0x9a9d(%rip), %rdi      # 0x16fd8
leaq 0x4368(%rip), %rsi      # 0x118aa
callq 0x4320
movq %rax, 0x10(%rsp)
jmp 0xd54e
movq 0x10(%rsp), %rdi
movq 0x1bb8(%rsp), %rsi
callq 0x4320
movq %rax, 0x8(%rsp)
jmp 0xd567
movq 0x8(%rsp), %rdi
movq 0x9a55(%rip), %rsi      # 0x16fc8
callq 0x4360
jmp 0xd57a
callq 0x41c0
movb 0x1bb4(%rsp), %al
movb %al, 0x7(%rsp)
leaq 0x208(%rsp), %rdi
callq 0xdb60
leaq 0x4a8(%rsp), %rdi
callq 0xdb60
leaq 0x758(%rsp), %rdi
callq 0x4220
leaq 0x778(%rsp), %rdi
callq 0x4220
movb 0x7(%rsp), %al
andb $0x1, %al
addq $0x1bc8, %rsp           # imm = 0x1BC8
retq
leaq 0x208(%rsp), %rdi
callq 0xdb60
leaq 0x4a8(%rsp), %rdi
callq 0xdb60
leaq 0x758(%rsp), %rdi
callq 0x4220
leaq 0x778(%rsp), %rdi
callq 0x4220
movq 0x750(%rsp), %rdi
callq 0x4600
nopl (%rax)