// File: /workspace/github_cpp_makefile_star2_O2/soccin[P]BIC-RNAseq/tools/MergeFusion/Merger.cpp
// Function: Merger::loadFusionFile(char const*, CALLER_TYPE, bool, bool)
void Merger::loadFusionFile(const char* filename, CALLER_TYPE caller_id, bool normalize_chrom, bool normalize_gene)
{
#ifdef _DEBUG
    cout << "[DEBUG]: Loading " << CALLER_TYPE_STRING[caller_id] << " file: " << filename << endl;
#endif
    
    ifstream input_fs(filename);
    if(!input_fs)
    {
        cerr << "Error: fail to open input file: " << filename << endl;
        exit(1);
    }
    map<StandardFusion, size_t> collapse_star;
    string line;
    if(CALLER_HEADER[caller_id])
    {
        getline(input_fs, line);
#ifdef _DEBUG
        cout << "[DEBUG]: Header line: " << line << endl;
#endif
    }
    while(getline(input_fs, line))
    {
#ifdef _DEBUG
        cout << "[DEBUG]: Data line: " << line << endl;
#endif
        StandardFusion new_fusion_entry(line, caller_id, normalize_chrom, normalize_gene, hugo_map);
        if(caller_id != STAR)   // caller other than star
            fusion_vec.push_back(new_fusion_entry);
        else                    // collapse star entries for each fusion junction
        {
            if(collapse_star.find(new_fusion_entry) == collapse_star.end())
            {
                fusion_vec.push_back(new_fusion_entry);
                collapse_star.insert(make_pair(new_fusion_entry, fusion_vec.size() - 1));
            }
            else
            {
                size_t entry_index = collapse_star[new_fusion_entry];
                fusion_vec[entry_index].breakpoint_coverage ++;
            }
        }
    }
    input_fs.close();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x538, %rsp            # imm = 0x538
movl %r8d, %r14d
movl %ecx, %r13d
movl %edx, %ebx
movq %rsi, %r12
movq %rdi, -0x38(%rbp)
leaq -0x408(%rbp), %r15
pushq $0x8
popq %rdx
movq %r15, %rdi
callq 0x2320
movq (%r15), %rax
movq -0x18(%rax), %rax
testb $0x5, -0x3e8(%rbp,%rax)
jne 0x334e
leaq -0x88(%rbp), %rax
andl $0x0, (%rax)
andq $0x0, 0x8(%rax)
movq %rax, 0x10(%rax)
movq %rax, 0x18(%rax)
andq $0x0, 0x20(%rax)
leaq -0x50(%rbp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb $0x0, (%rax)
movl %ebx, %eax
leaq 0x6bcc(%rip), %rcx      # 0x9d6f
cmpb $0x1, (%rcx,%rax)
jne 0x31b9
leaq -0x408(%rbp), %rdi
leaq -0x60(%rbp), %rsi
callq 0x2060
movq -0x38(%rbp), %rax
leaq 0x18(%rax), %rcx
movq %rcx, -0x40(%rbp)
movzbl %r13b, %ecx
movl %ecx, -0x30(%rbp)
movq %rax, %r13
movzbl %r14b, %eax
movl %eax, -0x2c(%rbp)
movq %r15, %rdi
leaq -0x60(%rbp), %rsi
callq 0x2060
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x330f
leaq -0xb0(%rbp), %r14
movq %r14, %rdi
leaq -0x60(%rbp), %rsi
callq 0x2240
leaq -0x200(%rbp), %rdi
movq %r14, %rsi
movl %ebx, %edx
movl -0x30(%rbp), %ecx
movl -0x2c(%rbp), %r8d
movq -0x40(%rbp), %r9
callq 0x63a0
movq %r14, %rdi
callq 0x2388
cmpl $0x5, %ebx
jne 0x3279
leaq -0x90(%rbp), %rdi
leaq -0x200(%rbp), %rsi
callq 0x48ee
leaq -0x88(%rbp), %rcx
cmpq %rcx, %rax
je 0x328d
leaq -0x90(%rbp), %rdi
leaq -0x200(%rbp), %rsi
callq 0x3d76
imulq $0x150, (%rax), %rax    # imm = 0x150
movq (%r13), %rcx
incl 0xa8(%rcx,%rax)
jmp 0x32fb
movq %r13, %rdi
leaq -0x200(%rbp), %r14
movq %r14, %rsi
callq 0x3d38
jmp 0x3302
movq %r13, %rdi
leaq -0x200(%rbp), %r12
movq %r12, %rsi
callq 0x3d38
movl %ebx, %r15d
movq (%r13), %r14
movq 0x8(%r13), %r13
leaq -0x560(%rbp), %rbx
movq %rbx, %rdi
movq %r12, %rsi
callq 0x4036
subq %r14, %r13
movq %r13, %rax
cqto
movl $0x150, %ecx            # imm = 0x150
idivq %rcx
decq %rax
movq %rax, -0x410(%rbp)
leaq -0x90(%rbp), %rdi
movq %rbx, %rsi
callq 0x4978
movq %rbx, %rdi
callq 0x7b1c
movq -0x38(%rbp), %r13
movl %r15d, %ebx
leaq -0x408(%rbp), %r15
leaq -0x200(%rbp), %r14
movq %r14, %rdi
callq 0x7b1c
jmp 0x31d6
leaq -0x408(%rbp), %rdi
callq 0x2070
leaq -0x60(%rbp), %rdi
callq 0x2388
leaq -0x90(%rbp), %rdi
callq 0x41b8
leaq -0x408(%rbp), %rdi
callq 0x2090
addq $0x538, %rsp            # imm = 0x538
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0xac9b(%rip), %rdi      # 0xdff0
leaq 0x6224(%rip), %rsi      # 0x9580
callq 0x21b0
movq %rax, %rdi
movq %r12, %rsi
callq 0x21b0
movq %rax, %rdi
callq 0x2100
pushq $0x1
popq %rdi
callq 0x2210
movq %rax, %rbx
jmp 0x33d6
jmp 0x33be
movq %rax, %rbx
leaq -0x560(%rbp), %rdi
callq 0x7b1c
jmp 0x339d
jmp 0x339a
jmp 0x339a
jmp 0x339a
movq %rax, %rbx
leaq -0x200(%rbp), %rdi
callq 0x7b1c
jmp 0x33c1
movq %rax, %rbx
leaq -0xb0(%rbp), %rdi
callq 0x2388
jmp 0x33c1
jmp 0x33be
movq %rax, %rbx
leaq -0x60(%rbp), %rdi
callq 0x2388
leaq -0x90(%rbp), %rdi
callq 0x41b8
leaq -0x408(%rbp), %rdi
callq 0x2090
movq %rbx, %rdi
callq 0x2300