// File: ncbi[P]amr/seq.cpp
// Function: Seq_sp::Dna::getPeptides(char, unsigned char, unsigned long) const
Vector<Peptide> Dna::getPeptides (Frame frame,
                                  Gencode gencode,
                                  size_t len_min) const
{
  ASSERT (isFrame (frame));
  ASSERT (len_min);
  
  Vector<Peptide> peps;  peps. reserve (seq. size () / 300 + 1);  // PAR
  
  string dnaSeq (seq);
  if (frame < 0)
    reverseDna (dnaSeq);
    
  size_t start = (size_t) abs (frame) - 1;
  size_t stop = 0;
  string pepSeq;
  
  const auto proc = [&] () 
    {
      if (pepSeq. size () < len_min)
        return;
      if (frame < 0)
      {
        const size_t start_ = start;
        start = seq. size () - stop;
        stop  = seq. size () - start_;
      }
      // ";partial=11" (Prodigal notation)
      peps << std::move (Peptide (getId () + ":" + to_string (start + 1) + ".." + to_string (stop), pepSeq, false));      
    };
  
  for (size_t i = start; i + 2 < dnaSeq. size (); i += 3)
  {
    const char aa = codon2aa (& dnaSeq [i], gencode, true);
    stop = i;
    if (aa == *terminator)
    {
    //pepSeq += string (1, *terminator);  // Like in GeneMark etc.  // PAR  
      proc ();
      pepSeq. clear ();
    }
    else if (! pepSeq. empty ())
      pepSeq += toUpper (aa);
    else if (Peptide::isStartAa (aa))
    {
      ASSERT (pepSeq. empty ());
      pepSeq = "M";
      start = i;
    }
  }
//proc ();  // Trunc3  // PAR
  
  return peps;
}

// Assembly:
subq $0x458, %rsp            # imm = 0x458
movq %rdi, 0x48(%rsp)
movb %cl, %al
movb %dl, %cl
movq %rdi, %rdx
movq %rdx, 0x50(%rsp)
movq %rdi, 0x450(%rsp)
movq %rsi, 0x448(%rsp)
movb %cl, 0x447(%rsp)
movb %al, 0x446(%rsp)
movq %r8, 0x438(%rsp)
movq 0x448(%rsp), %rax
movq %rax, 0x58(%rsp)
callq 0xd0a0
movl $0x0, (%rax)
movsbl 0x447(%rsp), %edi
callq 0xd8140
testb $0x1, %al
jne 0xb2482
callq 0xd8c0
cmpl $0x0, %eax
jne 0xb2478
leaq 0x397(%rsp), %rdi
movq %rdi, 0x40(%rsp)
callq 0xdd50
movq 0x40(%rsp), %rdx
leaq 0x3621f(%rip), %rsi     # 0xe8446
leaq 0x398(%rsp), %rdi
callq 0xfae0
jmp 0xb2236
leaq 0x360(%rsp), %rdi
movl $0x830, %esi            # imm = 0x830
callq 0x11600
jmp 0xb224a
leaq 0x3b8(%rsp), %rdi
leaq 0x398(%rsp), %rsi
leaq 0x360(%rsp), %rdx
callq 0x11510
jmp 0xb2269
leaq 0x30f61(%rip), %rdx     # 0xe31d1
leaq 0x3d8(%rsp), %rdi
leaq 0x3b8(%rsp), %rsi
callq 0x114c0
jmp 0xb2287
leaq 0x31f(%rsp), %rdi
movq %rdi, 0x38(%rsp)
callq 0xdd50
movq 0x38(%rsp), %rdx
leaq 0x36804(%rip), %rsi     # 0xe8aa9
leaq 0x320(%rsp), %rdi
callq 0xfae0
jmp 0xb22b4
leaq 0x316e9(%rip), %rdx     # 0xe39a4
leaq 0x340(%rsp), %rdi
leaq 0x320(%rsp), %rsi
callq 0x114c0
jmp 0xb22d2
leaq 0x3f8(%rsp), %rdi
leaq 0x3d8(%rsp), %rsi
leaq 0x340(%rsp), %rdx
callq 0x11510
jmp 0xb22f1
leaq 0x36630(%rip), %rdx     # 0xe8928
leaq 0x418(%rsp), %rdi
leaq 0x3f8(%rsp), %rsi
callq 0x114c0
jmp 0xb230f
leaq 0x418(%rsp), %rdi
callq 0x173d0
jmp 0xb231e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x388(%rsp)
movl %eax, 0x384(%rsp)
jmp 0xb2466
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x388(%rsp)
movl %eax, 0x384(%rsp)
jmp 0xb2459
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x388(%rsp)
movl %eax, 0x384(%rsp)
jmp 0xb244c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x388(%rsp)
movl %eax, 0x384(%rsp)
jmp 0xb243f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x388(%rsp)
movl %eax, 0x384(%rsp)
jmp 0xb2425
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x388(%rsp)
movl %eax, 0x384(%rsp)
jmp 0xb2418
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x388(%rsp)
movl %eax, 0x384(%rsp)
jmp 0xb240b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x388(%rsp)
movl %eax, 0x384(%rsp)
jmp 0xb23fe
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x388(%rsp)
movl %eax, 0x384(%rsp)
leaq 0x418(%rsp), %rdi
callq 0xdf08
leaq 0x3f8(%rsp), %rdi
callq 0xdf08
leaq 0x340(%rsp), %rdi
callq 0xdf08
leaq 0x320(%rsp), %rdi
callq 0xdf08
leaq 0x31f(%rsp), %rdi
callq 0xd7a0
leaq 0x3d8(%rsp), %rdi
callq 0xdf08
leaq 0x3b8(%rsp), %rdi
callq 0xdf08
leaq 0x360(%rsp), %rdi
callq 0xdf08
leaq 0x398(%rsp), %rdi
callq 0xdf08
leaq 0x397(%rsp), %rdi
callq 0xd7a0
jmp 0xb2cf3
movl $0x1, %edi
callq 0xd8e0
callq 0xd0a0
movl $0x0, (%rax)
cmpq $0x0, 0x438(%rsp)
jne 0xb2723
callq 0xd8c0
cmpl $0x0, %eax
jne 0xb2719
leaq 0x277(%rsp), %rdi
movq %rdi, 0x30(%rsp)
callq 0xdd50
movq 0x30(%rsp), %rdx
leaq 0x35f7e(%rip), %rsi     # 0xe8446
leaq 0x278(%rsp), %rdi
callq 0xfae0
jmp 0xb24d7
leaq 0x250(%rsp), %rdi
movl $0x831, %esi            # imm = 0x831
callq 0x11600
jmp 0xb24eb
leaq 0x298(%rsp), %rdi
leaq 0x278(%rsp), %rsi
leaq 0x250(%rsp), %rdx
callq 0x11510
jmp 0xb250a
leaq 0x30cc0(%rip), %rdx     # 0xe31d1
leaq 0x2b8(%rsp), %rdi
leaq 0x298(%rsp), %rsi
callq 0x114c0
jmp 0xb2528
leaq 0x20f(%rsp), %rdi
movq %rdi, 0x28(%rsp)
callq 0xdd50
movq 0x28(%rsp), %rdx
leaq 0x36563(%rip), %rsi     # 0xe8aa9
leaq 0x210(%rsp), %rdi
callq 0xfae0
jmp 0xb2555
leaq 0x31448(%rip), %rdx     # 0xe39a4
leaq 0x230(%rsp), %rdi
leaq 0x210(%rsp), %rsi
callq 0x114c0
jmp 0xb2573
leaq 0x2d8(%rsp), %rdi
leaq 0x2b8(%rsp), %rsi
leaq 0x230(%rsp), %rdx
callq 0x11510
jmp 0xb2592
leaq 0x36557(%rip), %rdx     # 0xe8af0
leaq 0x2f8(%rsp), %rdi
leaq 0x2d8(%rsp), %rsi
callq 0x114c0
jmp 0xb25b0
leaq 0x2f8(%rsp), %rdi
callq 0x173d0
jmp 0xb25bf
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x388(%rsp)
movl %eax, 0x384(%rsp)
jmp 0xb2707
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x388(%rsp)
movl %eax, 0x384(%rsp)
jmp 0xb26fa
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x388(%rsp)
movl %eax, 0x384(%rsp)
jmp 0xb26ed
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x388(%rsp)
movl %eax, 0x384(%rsp)
jmp 0xb26e0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x388(%rsp)
movl %eax, 0x384(%rsp)
jmp 0xb26c6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x388(%rsp)
movl %eax, 0x384(%rsp)
jmp 0xb26b9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x388(%rsp)
movl %eax, 0x384(%rsp)
jmp 0xb26ac
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x388(%rsp)
movl %eax, 0x384(%rsp)
jmp 0xb269f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x388(%rsp)
movl %eax, 0x384(%rsp)
leaq 0x2f8(%rsp), %rdi
callq 0xdf08
leaq 0x2d8(%rsp), %rdi
callq 0xdf08
leaq 0x230(%rsp), %rdi
callq 0xdf08
leaq 0x210(%rsp), %rdi
callq 0xdf08
leaq 0x20f(%rsp), %rdi
callq 0xd7a0
leaq 0x2b8(%rsp), %rdi
callq 0xdf08
leaq 0x298(%rsp), %rdi
callq 0xdf08
leaq 0x250(%rsp), %rdi
callq 0xdf08
leaq 0x278(%rsp), %rdi
callq 0xdf08
leaq 0x277(%rsp), %rdi
callq 0xd7a0
jmp 0xb2cf3
movl $0x1, %edi
callq 0xd8e0
movq 0x48(%rsp), %rdi
movb $0x0, 0x20e(%rsp)
callq 0xd8290
movq 0x58(%rsp), %rdi
addq $0x28, %rdi
callq 0xd520
movq 0x48(%rsp), %rdi
movabsq $0x6d3a06d3a06d3a07, %rcx # imm = 0x6D3A06D3A06D3A07
mulq %rcx
movq %rdx, %rsi
shrq $0x7, %rsi
incq %rsi
callq 0xd82c0
jmp 0xb2766
movq 0x58(%rsp), %rsi
addq $0x28, %rsi
leaq 0x1e8(%rsp), %rdi
callq 0xd330
jmp 0xb277e
movsbl 0x447(%rsp), %eax
cmpl $0x0, %eax
jge 0xb27ce
leaq 0x1e8(%rsp), %rdi
callq 0xad290
jmp 0xb279a
jmp 0xb27ce
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x388(%rsp)
movl %eax, 0x384(%rsp)
jmp 0xb2ce9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x388(%rsp)
movl %eax, 0x384(%rsp)
jmp 0xb2cc3
movsbl 0x447(%rsp), %eax
movl %eax, %ecx
negl %ecx
cmovnsl %ecx, %eax
cltq
subq $0x1, %rax
movq %rax, 0x1e0(%rsp)
movq $0x0, 0x1d8(%rsp)
leaq 0x1b8(%rsp), %rdi
callq 0xda50
movq 0x58(%rsp), %rcx
movq 0x48(%rsp), %rax
leaq 0x1b8(%rsp), %rdx
movq %rdx, 0x180(%rsp)
leaq 0x438(%rsp), %rdx
movq %rdx, 0x188(%rsp)
leaq 0x447(%rsp), %rdx
movq %rdx, 0x190(%rsp)
leaq 0x1e0(%rsp), %rdx
movq %rdx, 0x198(%rsp)
movq %rcx, 0x1a0(%rsp)
leaq 0x1d8(%rsp), %rcx
movq %rcx, 0x1a8(%rsp)
movq %rax, 0x1b0(%rsp)
movq 0x1e0(%rsp), %rax
movq %rax, 0x178(%rsp)
movq 0x178(%rsp), %rax
addq $0x2, %rax
movq %rax, 0x20(%rsp)
leaq 0x1e8(%rsp), %rdi
callq 0xd520
movq %rax, %rcx
movq 0x20(%rsp), %rax
cmpq %rcx, %rax
jae 0xb2c88
movq 0x178(%rsp), %rsi
leaq 0x1e8(%rsp), %rdi
callq 0xdec0
movq %rax, 0x18(%rsp)
jmp 0xb28c9
movq 0x18(%rsp), %rdi
movzbl 0x446(%rsp), %esi
movl $0x1, %edx
callq 0xad450
movb %al, 0x17(%rsp)
jmp 0xb28e6
movb 0x17(%rsp), %al
movb %al, 0x177(%rsp)
movq 0x178(%rsp), %rax
movq %rax, 0x1d8(%rsp)
movsbl 0x177(%rsp), %eax
movq 0x6e490(%rip), %rcx     # 0x120da0
movsbl (%rcx), %ecx
cmpl %ecx, %eax
jne 0xb2951
leaq 0x180(%rsp), %rdi
callq 0xb2d00
jmp 0xb2926
leaq 0x1b8(%rsp), %rdi
callq 0xd9c0
jmp 0xb2c6d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x388(%rsp)
movl %eax, 0x384(%rsp)
jmp 0xb2cb6
leaq 0x1b8(%rsp), %rdi
callq 0xdc60
testb $0x1, %al
jne 0xb2990
movsbl 0x177(%rsp), %edi
callq 0x4cae0
movb %al, 0x16(%rsp)
jmp 0xb2975
movb 0x16(%rsp), %al
movsbl %al, %esi
leaq 0x1b8(%rsp), %rdi
callq 0xd4b0
jmp 0xb298b
jmp 0xb2c6b
movsbl 0x177(%rsp), %edi
callq 0xd83d0
movb %al, 0x15(%rsp)
jmp 0xb29a3
movb 0x15(%rsp), %al
testb $0x1, %al
jne 0xb29b0
jmp 0xb2c69
callq 0xd0a0
movl $0x0, (%rax)
leaq 0x1b8(%rsp), %rdi
callq 0xdc60
testb $0x1, %al
jne 0xb2c43
callq 0xd8c0
cmpl $0x0, %eax
jne 0xb2c39
leaq 0xcf(%rsp), %rdi
movq %rdi, 0x8(%rsp)
callq 0xdd50
movq 0x8(%rsp), %rdx
leaq 0x35a4a(%rip), %rsi     # 0xe8446
leaq 0xd0(%rsp), %rdi
callq 0xfae0
jmp 0xb2a0b
leaq 0xa8(%rsp), %rdi
movl $0x859, %esi            # imm = 0x859
callq 0x11600
jmp 0xb2a1f
leaq 0xf0(%rsp), %rdi
leaq 0xd0(%rsp), %rsi
leaq 0xa8(%rsp), %rdx
callq 0x11510
jmp 0xb2a3e
leaq 0x3078c(%rip), %rdx     # 0xe31d1
leaq 0x110(%rsp), %rdi
leaq 0xf0(%rsp), %rsi
callq 0x114c0
jmp 0xb2a5c
leaq 0x67(%rsp), %rdi
movq %rdi, (%rsp)
callq 0xdd50
movq (%rsp), %rdx
leaq 0x36034(%rip), %rsi     # 0xe8aa9
leaq 0x68(%rsp), %rdi
callq 0xfae0
jmp 0xb2a81
leaq 0x30f1c(%rip), %rdx     # 0xe39a4
leaq 0x88(%rsp), %rdi
leaq 0x68(%rsp), %rsi
callq 0x114c0
jmp 0xb2a9c
leaq 0x130(%rsp), %rdi
leaq 0x110(%rsp), %rsi
leaq 0x88(%rsp), %rdx
callq 0x11510
jmp 0xb2abb
leaq 0x36036(%rip), %rdx     # 0xe8af8
leaq 0x150(%rsp), %rdi
leaq 0x130(%rsp), %rsi
callq 0x114c0
jmp 0xb2ad9
leaq 0x150(%rsp), %rdi
callq 0x173d0
jmp 0xb2ae8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x388(%rsp)
movl %eax, 0x384(%rsp)
jmp 0xb2c2a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x388(%rsp)
movl %eax, 0x384(%rsp)
jmp 0xb2c1d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x388(%rsp)
movl %eax, 0x384(%rsp)
jmp 0xb2c10
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x388(%rsp)
movl %eax, 0x384(%rsp)
jmp 0xb2c03
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x388(%rsp)
movl %eax, 0x384(%rsp)
jmp 0xb2bec
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x388(%rsp)
movl %eax, 0x384(%rsp)
jmp 0xb2be2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x388(%rsp)
movl %eax, 0x384(%rsp)
jmp 0xb2bd5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x388(%rsp)
movl %eax, 0x384(%rsp)
jmp 0xb2bc8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x388(%rsp)
movl %eax, 0x384(%rsp)
leaq 0x150(%rsp), %rdi
callq 0xdf08
leaq 0x130(%rsp), %rdi
callq 0xdf08
leaq 0x88(%rsp), %rdi
callq 0xdf08
leaq 0x68(%rsp), %rdi
callq 0xdf08
leaq 0x67(%rsp), %rdi
callq 0xd7a0
leaq 0x110(%rsp), %rdi
callq 0xdf08
leaq 0xf0(%rsp), %rdi
callq 0xdf08
leaq 0xa8(%rsp), %rdi
callq 0xdf08
leaq 0xd0(%rsp), %rdi
callq 0xdf08
leaq 0xcf(%rsp), %rdi
callq 0xd7a0
jmp 0xb2cb6
movl $0x1, %edi
callq 0xd8e0
leaq 0x33a01(%rip), %rsi     # 0xe664b
leaq 0x1b8(%rsp), %rdi
callq 0xda20
jmp 0xb2c59
movq 0x178(%rsp), %rax
movq %rax, 0x1e0(%rsp)
jmp 0xb2c6b
jmp 0xb2c6d
jmp 0xb2c6f
movq 0x178(%rsp), %rax
addq $0x3, %rax
movq %rax, 0x178(%rsp)
jmp 0xb287e
movb $0x1, 0x20e(%rsp)
leaq 0x1b8(%rsp), %rdi
callq 0xdf08
leaq 0x1e8(%rsp), %rdi
callq 0xdf08
testb $0x1, 0x20e(%rsp)
jne 0xb2cdc
jmp 0xb2cd2
leaq 0x1b8(%rsp), %rdi
callq 0xdf08
leaq 0x1e8(%rsp), %rdi
callq 0xdf08
jmp 0xb2ce9
movq 0x48(%rsp), %rdi
callq 0xd8400
movq 0x50(%rsp), %rax
addq $0x458, %rsp            # imm = 0x458
retq
movq 0x48(%rsp), %rdi
callq 0xd8400
movq 0x388(%rsp), %rdi
callq 0xdd40