# 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
            ('cdr2_aa', self.antibody.v.regions.aa_seqs['CDR2']),
            ('cdr3_nt', self.antibody.junction.cdr3_nt),
            ('cdr3_aa', self.antibody.junction.cdr3_aa),
            ('v_start', str(self.antibody.v.germline_start)),
            ('vdj_nt', self.antibody.vdj_nt),
            ('vdj_aa', self.antibody.vdj_aa),
            ('var_muts_nt', '|'.join([m.abstar_formatted for m in self.antibody.v.nt_mutations])),
            ('var_muts_aa', '|'.join([m.abstar_formatted for m in self.antibody.v.aa_mutations])),
            ('var_identity_nt', str(self.antibody.v.nt_identity)),
            ('var_identity_aa', str(self.antibody.v.aa_identity)),
            ('var_mut_count_nt', str(self.antibody.v.nt_mutations.count)),
            ('var_mut_count_aa', str(self.antibody.v.aa_mutations.count)),
            ('var_ins', '|'.join([i.abstar_formatted for i in self.antibody.v.insertions])),
            ('var_del', '|'.join([d.abstar_formatted for d in self.antibody.v.deletions])),
            ('isotype', isotype),
            ('species', self.antibody.species),
            ('raw_input', self.antibody.raw_input.sequence),
        ])
        return ','.join(output.values())


    def _build_airr_output(self):
        # format specification: https://docs.airr-community.org/en/latest/datarep/rearrangements.html
        try:
            c_call = self.antibody.isotype.isotype
        except AttributeError:
            c_call = ''
        if self.antibody.d:
            d_call = self.antibody.d.full
            d_gene = self.antibody.d.gene

# 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

            ('cdr2_aa', self.antibody.v.regions.aa_seqs['CDR2']),
            ('cdr3_nt', self.antibody.junction.cdr3_nt),
            ('cdr3_aa', self.antibody.junction.cdr3_aa),
            ('v_start', str(self.antibody.v.germline_start)),
            ('vdj_nt', self.antibody.vdj_nt),
            ('vdj_aa', self.antibody.vdj_aa),
            ('var_muts_nt', '|'.join([m.abstar_formatted for m in self.antibody.v.nt_mutations])),
            ('var_muts_aa', '|'.join([m.abstar_formatted for m in self.antibody.v.aa_mutations])),
            ('var_identity_nt', str(self.antibody.v.nt_identity)),
            ('var_identity_aa', str(self.antibody.v.aa_identity)),
            ('var_mut_count_nt', str(self.antibody.v.nt_mutations.count)),
            ('var_mut_count_aa', str(self.antibody.v.aa_mutations.count)),
            ('var_ins', '|'.join([i.abstar_formatted for i in self.antibody.v.insertions])),
            ('var_del', '|'.join([d.abstar_formatted for d in self.antibody.v.deletions])),
            ('isotype', isotype),
            ('species', self.antibody.species),
            ('raw_input', self.antibody.raw_input.sequence),
        ])
        return ','.join(output.values())


    def _build_airr_output(self):
        # format specification: https://docs.airr-community.org/en/latest/datarep/rearrangements.html
        try:
            c_call = self.antibody.isotype.isotype
        except AttributeError:
            c_call = ''
        if self.antibody.d:
            d_call = self.antibody.d.full
            d_gene = self.antibody.d.gene

            d_cigar = make_cigar(self.antibody.d)