# Path: abstar/utils/cigar.py
# def make_cigar(germline_segment):
#     cigar = ''
#     if germline_segment.query_start > 0:
#         cigar += '{}S'.format(germline_segment.query_start)
#     if germline_segment.germline_start > 0:
#         cigar += '{}N'.format(germline_segment.germline_start)
#     cigar += make_alignment_cigar(germline_segment.realignment.aligned_query,
#                                   germline_segment.realignment.aligned_target)
#     return cigar


import collections
import json
import os
import traceback
import uuid
from abutils.utils import log
from .cigar import make_cigar
            ('d_gene', d_gene),
            ('d_score', d_score),
            # ('d_identity', d_identity),
            ('j_call', self.antibody.j.full),
            ('j_gene', self.antibody.j.gene),
            ('j_score', str(self.antibody.j.assigner_score)),
            ('j_identity', str(self.antibody.j.nt_identity / 100.)),
            ('j_identity_aa', str(self.antibody.j.aa_identity / 100.)),
            ('c_call', c_call),
            ('cdr3_length', str(len(self.antibody.junction.cdr3_aa))),
            ('fwr1_aa', self.antibody.v.regions.aa_seqs['FR1']),
            ('fwr2_aa', self.antibody.v.regions.aa_seqs['FR2']),
            ('fwr3_aa', self.antibody.v.regions.aa_seqs['FR3']),
            ('fwr4_aa', self.antibody.j.regions.aa_seqs['FR4']),
            ('cdr1_aa', self.antibody.v.regions.aa_seqs['CDR1']),
            ('cdr2_aa', self.antibody.v.regions.aa_seqs['CDR2']),
            ('cdr3_aa', self.antibody.junction.cdr3_aa),
            ('sequence_alignment', self.antibody.gapped_vdj_nt),
            ('germline_alignment', self.antibody.gapped_vdj_germ_nt),
            ('v_mutations', '|'.join([m.abstar_formatted for m in self.antibody.v.nt_mutations])),
            ('v_mutations_aa', '|'.join([m.abstar_formatted for m in self.antibody.v.aa_mutations])),
            ('v_mutation_count', str(self.antibody.v.nt_mutations.count)),
            ('v_mutation_count_aa', str(self.antibody.v.aa_mutations.count)),
            ('v_insertions', '|'.join([i.abstar_formatted for i in self.antibody.v.insertions]) if self.antibody.v.insertions else ''),
            ('v_deletions', '|'.join([i.abstar_formatted for i in self.antibody.v.deletions]) if self.antibody.v.deletions else ''),
            ('junction', self.antibody.junction.junction_nt),
            ('junction_aa', self.antibody.junction.junction_aa),
            ('junction_in_frame', 'True' if self.antibody.junction.in_frame else 'False'),
            ('isotype', c_call),
            ('locus', self.antibody.v.gene[:3].upper()),

# Path: abstar/utils/cigar.py
# def make_cigar(germline_segment):
#     cigar = ''
#     if germline_segment.query_start > 0:
#         cigar += '{}S'.format(germline_segment.query_start)
#     if germline_segment.germline_start > 0:
#         cigar += '{}N'.format(germline_segment.germline_start)
#     cigar += make_alignment_cigar(germline_segment.realignment.aligned_query,
#                                   germline_segment.realignment.aligned_target)
#     return cigar


# Path: abstar/utils/output.py
import collections
import json
import os
import traceback
import uuid
from abutils.utils import log
from .cigar import make_cigar

            ('d_gene', d_gene),
            ('d_score', d_score),
            # ('d_identity', d_identity),
            ('j_call', self.antibody.j.full),
            ('j_gene', self.antibody.j.gene),
            ('j_score', str(self.antibody.j.assigner_score)),
            ('j_identity', str(self.antibody.j.nt_identity / 100.)),
            ('j_identity_aa', str(self.antibody.j.aa_identity / 100.)),
            ('c_call', c_call),
            ('cdr3_length', str(len(self.antibody.junction.cdr3_aa))),
            ('fwr1_aa', self.antibody.v.regions.aa_seqs['FR1']),
            ('fwr2_aa', self.antibody.v.regions.aa_seqs['FR2']),
            ('fwr3_aa', self.antibody.v.regions.aa_seqs['FR3']),
            ('fwr4_aa', self.antibody.j.regions.aa_seqs['FR4']),
            ('cdr1_aa', self.antibody.v.regions.aa_seqs['CDR1']),
            ('cdr2_aa', self.antibody.v.regions.aa_seqs['CDR2']),
            ('cdr3_aa', self.antibody.junction.cdr3_aa),
            ('sequence_alignment', self.antibody.gapped_vdj_nt),
            ('germline_alignment', self.antibody.gapped_vdj_germ_nt),
            ('v_mutations', '|'.join([m.abstar_formatted for m in self.antibody.v.nt_mutations])),
            ('v_mutations_aa', '|'.join([m.abstar_formatted for m in self.antibody.v.aa_mutations])),
            ('v_mutation_count', str(self.antibody.v.nt_mutations.count)),
            ('v_mutation_count_aa', str(self.antibody.v.aa_mutations.count)),
            ('v_insertions', '|'.join([i.abstar_formatted for i in self.antibody.v.insertions]) if self.antibody.v.insertions else ''),
            ('v_deletions', '|'.join([i.abstar_formatted for i in self.antibody.v.deletions]) if self.antibody.v.deletions else ''),
            ('junction', self.antibody.junction.junction_nt),
            ('junction_aa', self.antibody.junction.junction_aa),
            ('junction_in_frame', 'True' if self.antibody.junction.in_frame else 'False'),
            ('isotype', c_call),
            ('locus', self.antibody.v.gene[:3].upper()),

            ('v_cigar', make_cigar(self.antibody.v)),