// File: /workspace/github_cpp_makefile_star2_O2/millanek[P]evo/process_vcf_coding_sequences.cpp
// Function: printPerGeneSummaries(std::basic_ofstream<char, std::char_traits<char>>*&, Annotation&)
void printPerGeneSummaries(std::ofstream*& stopsPerGeneSummaryFile, Annotation& wgAnnotation) {
    std::string previousGene = "";
    int numTranscripsWithStopsThisGene = 0;
    double stopAlleleFrequencySum = 0;
    std::vector<double> stopPosPctVec;
    for (std::vector<string>::size_type i = 0; i != stopsTranscriptRecord.size(); i++) {
         std::cerr << "previousGene: " << previousGene << std::endl;
        std::vector<string> oneTransctipt = split(stopsTranscriptRecord[i], '\t');
        if (geneFromTranscript(oneTransctipt[0]) == previousGene) {
            numTranscripsWithStopsThisGene++;
            stopAlleleFrequencySum += convertToDouble(oneTransctipt[3]);
            double stopPosPct = convertToDouble(oneTransctipt[1]) / convertToDouble(oneTransctipt[2]);
            stopPosPctVec.push_back(stopPosPct);
        } else {
            if (previousGene != "")
                *stopsPerGeneSummaryFile << previousGene << "\t" << numTranscripsWithStopsThisGene << "\t" << wgAnnotation.getTranscriptCount(previousGene) << "\t" << stopAlleleFrequencySum/numTranscripsWithStopsThisGene << "\t" << vector_average(stopPosPctVec) << std::endl;
            previousGene = geneFromTranscript(oneTransctipt[0]);
            numTranscripsWithStopsThisGene = 1; stopAlleleFrequencySum = convertToDouble(oneTransctipt[3]); stopPosPctVec.clear();
            double stopPosPct = convertToDouble(oneTransctipt[1]) / convertToDouble(oneTransctipt[2]);
            stopPosPctVec.push_back(stopPosPct);
        }
        
        // print the final gene
        if (i == (stopsTranscriptRecord.size() - 1)) {
            *stopsPerGeneSummaryFile << geneFromTranscript(oneTransctipt[0]) << "\t" << numTranscripsWithStopsThisGene << "\t" << wgAnnotation.getTranscriptCount(previousGene) << "\t" << stopAlleleFrequencySum/numTranscripsWithStopsThisGene << "\t" << vector_average(stopPosPctVec) << std::endl;
        }
        
        //oneTransctipt[0]
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xd8, %rsp
movq %rsi, 0x50(%rsp)
movq %rdi, 0x58(%rsp)
leaq 0x446a9(%rip), %rsi     # 0x99e1f
leaq 0xb8(%rsp), %r12
leaq 0x98(%rsp), %r13
movq %r12, %rdi
movq %r13, %rdx
callq 0x21904
xorpd %xmm0, %xmm0
leaq 0x30(%rsp), %rax
movapd %xmm0, (%rax)
andq $0x0, 0x10(%rax)
xorpd %xmm0, %xmm0
movsd %xmm0, 0x8(%rsp)
xorl %r15d, %r15d
xorl %r14d, %r14d
xorl %ebx, %ebx
movq 0x88de4(%rip), %rax     # 0xde5a0
subq 0x88dd5(%rip), %rax     # 0xde598
sarq $0x5, %rax
cmpq %rax, %rbx
je 0x55b17
movq 0x87811(%rip), %rdi     # 0xdcfe8
leaq 0x4eade(%rip), %rsi     # 0xa42bc
callq 0x8480
movq %rax, %rdi
movq %r12, %rsi
callq 0x8430
movq %rax, %rdi
callq 0x8230
movq 0x88d9b(%rip), %rsi     # 0xde598
addq %r15, %rsi
leaq 0x18(%rsp), %rdi
pushq $0x9
popq %rdx
callq 0x40349
movq 0x18(%rsp), %rsi
movq %r13, %rdi
callq 0x3293a
movq %r13, %rdi
movq %r12, %rsi
callq 0x26b06
movl %eax, %ebp
movq %r13, %rdi
callq 0x8978
testb %bpl, %bpl
je 0x558a4
movq 0x18(%rsp), %rdi
addq $0x60, %rdi
callq 0x5a2ff
movsd %xmm0, 0x60(%rsp)
movq 0x18(%rsp), %rdi
addq $0x20, %rdi
callq 0x5a2ff
movsd %xmm0, 0x10(%rsp)
movq 0x18(%rsp), %rdi
addq $0x40, %rdi
callq 0x5a2ff
movsd 0x10(%rsp), %xmm1
divsd %xmm0, %xmm1
movsd %xmm1, 0x98(%rsp)
leaq 0x30(%rsp), %rdi
movq %r13, %rsi
callq 0x5a406
incl %r14d
movsd 0x8(%rsp), %xmm0
addsd 0x60(%rsp), %xmm0
movsd %xmm0, 0x8(%rsp)
jmp 0x55a0d
movq %r12, %rdi
leaq 0x44571(%rip), %rsi     # 0x99e1f
callq 0x2ea9b
testb %al, %al
je 0x55982
movq 0x58(%rsp), %rax
movq (%rax), %rdi
movq %r12, %rsi
callq 0x8430
movq %rax, %rdi
leaq 0x44549(%rip), %rsi     # 0x99e1e
callq 0x8480
movq %rax, %rdi
movl %r14d, %esi
callq 0x8840
movq %rax, %rdi
leaq 0x4452f(%rip), %rsi     # 0x99e1e
callq 0x8480
movq %rax, %rbp
movq 0x50(%rsp), %rdi
movq %r12, %rsi
callq 0x5a428
movq %rbp, %rdi
movl %eax, %esi
callq 0x8840
movq %rax, %rdi
leaq 0x44506(%rip), %rsi     # 0x99e1e
callq 0x8480
cvtsi2sd %r14d, %xmm1
movsd 0x8(%rsp), %xmm0
divsd %xmm1, %xmm0
movq %rax, %rdi
callq 0x8750
movq %rax, %rdi
leaq 0x444e0(%rip), %rsi     # 0x99e1e
callq 0x8480
movq %rax, %r14
leaq 0x80(%rsp), %rdi
leaq 0x30(%rsp), %rsi
callq 0x2f816
leaq 0x80(%rsp), %rdi
callq 0x2f7e9
movq %r14, %rdi
callq 0x8750
movq %rax, %rdi
callq 0x8230
leaq 0x80(%rsp), %rdi
callq 0x2b43c
movq 0x18(%rsp), %rsi
movq %r13, %rdi
callq 0x3293a
movq %r12, %rdi
movq %r13, %rsi
callq 0x8550
movq %r13, %rdi
callq 0x8978
movq 0x18(%rsp), %rdi
addq $0x60, %rdi
callq 0x5a2ff
movsd %xmm0, 0x8(%rsp)
movq 0x30(%rsp), %rax
cmpq %rax, 0x38(%rsp)
je 0x559c7
movq %rax, 0x38(%rsp)
movq 0x18(%rsp), %rdi
addq $0x20, %rdi
callq 0x5a2ff
movsd %xmm0, 0x10(%rsp)
movq 0x18(%rsp), %rdi
addq $0x40, %rdi
callq 0x5a2ff
movsd 0x10(%rsp), %xmm1
divsd %xmm0, %xmm1
movsd %xmm1, 0x98(%rsp)
leaq 0x30(%rsp), %rdi
movq %r13, %rsi
callq 0x5a406
pushq $0x1
popq %r14
movq 0x88b8c(%rip), %rax     # 0xde5a0
subq 0x88b7d(%rip), %rax     # 0xde598
sarq $0x5, %rax
decq %rax
cmpq %rax, %rbx
jne 0x55b01
movq 0x58(%rsp), %rax
movq (%rax), %rbp
movq 0x18(%rsp), %rsi
movq %r13, %rdi
callq 0x3293a
movq %rbp, %rdi
movq %r13, %rsi
callq 0x8430
movq %rax, %rdi
leaq 0x443c9(%rip), %rsi     # 0x99e1e
callq 0x8480
movq %rax, %rdi
movl %r14d, %esi
callq 0x8840
movq %rax, %rdi
leaq 0x443af(%rip), %rsi     # 0x99e1e
callq 0x8480
movq %rax, %rbp
movq 0x50(%rsp), %rdi
movq %r12, %rsi
callq 0x5a428
movq %rbp, %rdi
movl %eax, %esi
callq 0x8840
movq %rax, %rdi
leaq 0x44386(%rip), %rsi     # 0x99e1e
callq 0x8480
cvtsi2sd %r14d, %xmm1
movsd 0x8(%rsp), %xmm0
divsd %xmm1, %xmm0
movq %rax, %rdi
callq 0x8750
movq %rax, %rdi
leaq 0x44360(%rip), %rsi     # 0x99e1e
callq 0x8480
movq %rax, %rbp
leaq 0x68(%rsp), %rdi
leaq 0x30(%rsp), %rsi
callq 0x2f816
leaq 0x68(%rsp), %rdi
callq 0x2f7e9
movq %rbp, %rdi
callq 0x8750
movq %rax, %rdi
callq 0x8230
leaq 0x68(%rsp), %rdi
callq 0x2b43c
movq %r13, %rdi
callq 0x8978
leaq 0x18(%rsp), %rdi
callq 0x28a08
incq %rbx
addq $0x20, %r15
jmp 0x557b5
leaq 0x30(%rsp), %rdi
callq 0x2b43c
leaq 0xb8(%rsp), %rdi
callq 0x8978
addq $0xd8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x55b72
jmp 0x55b72
movq %rax, %rbx
leaq 0x80(%rsp), %rdi
callq 0x2b43c
jmp 0x55b87
movq %rax, %rbx
leaq 0x68(%rsp), %rdi
callq 0x2b43c
jmp 0x55b7a
jmp 0x55b6d
jmp 0x55b72
jmp 0x55b72
jmp 0x55b72
movq %rax, %rbx
jmp 0x55b91
movq %rax, %rbx
jmp 0x55b87
movq %rax, %rbx
leaq 0x98(%rsp), %rdi
callq 0x8978
leaq 0x18(%rsp), %rdi
callq 0x28a08
leaq 0x30(%rsp), %rdi
callq 0x2b43c
leaq 0xb8(%rsp), %rdi
callq 0x8978
movq %rbx, %rdi
callq 0x8870