// File: 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
subq $0x5d0, %rsp            # imm = 0x5D0
movb %r8b, %al
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
andb $0x1, %cl
movb %cl, -0x15(%rbp)
andb $0x1, %al
movb %al, -0x16(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x588(%rbp)
movq -0x10(%rbp), %rsi
leaq -0x220(%rbp), %rdi
movl $0x8, %edx
callq 0x34a0
movq -0x220(%rbp), %rax
movq -0x18(%rax), %rax
leaq -0x220(%rbp,%rax), %rdi
callq 0x3160
movb %al, -0x579(%rbp)
jmp 0x57d4
movb -0x579(%rbp), %al
testb $0x1, %al
jne 0x57e0
jmp 0x584b
movq 0x18809(%rip), %rdi     # 0x1dff0
leaq 0xfd49(%rip), %rsi      # 0x15537
callq 0x3270
movq %rax, -0x590(%rbp)
jmp 0x57fc
movq -0x590(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x3270
movq %rax, -0x598(%rbp)
jmp 0x5815
movq -0x598(%rbp), %rdi
movq 0x1877d(%rip), %rsi     # 0x1dfa0
callq 0x32c0
jmp 0x582a
movl $0x1, %edi
callq 0x3320
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x228(%rbp)
movl %eax, -0x22c(%rbp)
jmp 0x5b69
leaq -0x260(%rbp), %rdi
callq 0x6dd0
leaq -0x280(%rbp), %rdi
callq 0x3380
movl -0x14(%rbp), %eax
movl %eax, %ecx
leaq 0x104ca(%rip), %rax     # 0x15d39
testb $0x1, (%rax,%rcx)
je 0x58a3
leaq -0x220(%rbp), %rdi
leaq -0x280(%rbp), %rsi
callq 0x3080
jmp 0x588a
jmp 0x58a3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x228(%rbp)
movl %eax, -0x22c(%rbp)
jmp 0x5b51
jmp 0x58a5
leaq -0x220(%rbp), %rdi
leaq -0x280(%rbp), %rsi
callq 0x3080
movq %rax, -0x5a0(%rbp)
jmp 0x58c1
movq -0x5a0(%rbp), %rdi
movq (%rdi), %rax
movq -0x18(%rax), %rax
addq %rax, %rdi
callq 0x3350
movb %al, -0x5a1(%rbp)
jmp 0x58df
movb -0x5a1(%rbp), %al
testb $0x1, %al
jne 0x58ee
jmp 0x5b16
leaq -0x3f0(%rbp), %rdi
leaq -0x280(%rbp), %rsi
callq 0x3130
jmp 0x5903
movq -0x588(%rbp), %r9
movl -0x14(%rbp), %edx
addq $0x18, %r9
movzbl -0x16(%rbp), %r8d
movzbl -0x15(%rbp), %ecx
andl $0x1, %ecx
andl $0x1, %r8d
leaq -0x3d0(%rbp), %rdi
leaq -0x3f0(%rbp), %rsi
callq 0xf3c0
jmp 0x5936
leaq -0x3f0(%rbp), %rdi
callq 0x3508
cmpl $0x5, -0x14(%rbp)
je 0x599c
movq -0x588(%rbp), %rdi
leaq -0x3d0(%rbp), %rsi
callq 0x6df0
jmp 0x595d
jmp 0x5af7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x228(%rbp)
movl %eax, -0x22c(%rbp)
leaq -0x3f0(%rbp), %rdi
callq 0x3508
jmp 0x5b51
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x228(%rbp)
movl %eax, -0x22c(%rbp)
jmp 0x5b08
leaq -0x260(%rbp), %rdi
leaq -0x3d0(%rbp), %rsi
callq 0x6e90
movq %rax, -0x5b0(%rbp)
jmp 0x59b8
movq -0x5b0(%rbp), %rax
movq %rax, -0x3f8(%rbp)
leaq -0x260(%rbp), %rdi
callq 0x6ec0
movq %rax, -0x400(%rbp)
leaq -0x3f8(%rbp), %rdi
leaq -0x400(%rbp), %rsi
callq 0x6e60
testb $0x1, %al
jne 0x59f5
jmp 0x5aa6
movq -0x588(%rbp), %rdi
leaq -0x3d0(%rbp), %rsi
callq 0x6df0
jmp 0x5a0a
movq -0x588(%rbp), %rdi
callq 0x6f70
decq %rax
movq %rax, -0x560(%rbp)
leaq -0x558(%rbp), %rdi
leaq -0x3d0(%rbp), %rsi
leaq -0x560(%rbp), %rdx
callq 0x6f30
jmp 0x5a3c
leaq -0x260(%rbp), %rdi
leaq -0x558(%rbp), %rsi
callq 0x6ef0
movb %dl, -0x5b9(%rbp)
movq %rax, -0x5b8(%rbp)
jmp 0x5a5e
movb -0x5b9(%rbp), %al
movq -0x5b8(%rbp), %rcx
movq %rcx, -0x570(%rbp)
movb %al, -0x568(%rbp)
leaq -0x558(%rbp), %rdi
callq 0x6fa0
jmp 0x5af5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x228(%rbp)
movl %eax, -0x22c(%rbp)
leaq -0x558(%rbp), %rdi
callq 0x6fa0
jmp 0x5b08
leaq -0x260(%rbp), %rdi
leaq -0x3d0(%rbp), %rsi
callq 0x6fc0
movq %rax, -0x5c8(%rbp)
jmp 0x5ac2
movq -0x588(%rbp), %rdi
movq -0x5c8(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x578(%rbp)
movq -0x578(%rbp), %rsi
callq 0x70a0
movl 0xa8(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0xa8(%rax)
jmp 0x5af7
leaq -0x3d0(%rbp), %rdi
callq 0x12280
jmp 0x58a5
leaq -0x3d0(%rbp), %rdi
callq 0x12280
jmp 0x5b51
leaq -0x220(%rbp), %rdi
callq 0x3090
jmp 0x5b24
leaq -0x280(%rbp), %rdi
callq 0x3508
leaq -0x260(%rbp), %rdi
callq 0x70c0
leaq -0x220(%rbp), %rdi
callq 0x30c0
addq $0x5d0, %rsp            # imm = 0x5D0
popq %rbp
retq
leaq -0x280(%rbp), %rdi
callq 0x3508
leaq -0x260(%rbp), %rdi
callq 0x70c0
leaq -0x220(%rbp), %rdi
callq 0x30c0
movq -0x228(%rbp), %rdi
callq 0x3470
nopw %cs:(%rax,%rax)