Create a CIGAR string from the alignment

    :returns: CIGAR string
    :rtype: string
961109
def construct_cigar(self,min_intron_size=68):
    

    # goes target query
    ar = self.alignment_ranges
    cig = ''
    if ar[0][1].start > 1: # soft clipped
      cig += str(ar[0][1].start-1)+'S'
    for i in range(len(ar)):
      exlen = ar[i][0].length
      cig += str(exlen)+'M'
      if i < len(ar)-1:
        # we can look at distances
        dt = ar[i+1][0].start-ar[i][0].end-1
        dq = ar[i+1][1].start-ar[i][1].end-1
        if dq > 0: cig += str(dq)+'I'
        if dt >= min_intron_size:
          cig += str(dt)+'N'
        elif dt > 0: cig += str(dt)+'D'
        elif dq <= 0:
          sys.stderr.write("ERROR cant form alignment\n")
          sys.exit()

    if ar[-1][1].end < self.query_sequence_length: # soft clipped
      cig += str(self.query_sequence_length-ar[-1][1].end)+'S'
    return cig
502657
def mask_right(self, n_seq_bases, mask="S"):
        
        return Cigar(Cigar(self._reverse_cigar()).mask_left(n_seq_bases, mask)._reverse_cigar())
760037
def to_string(self):
        
        return '%s   %s %s %s %s' % (
            self.trait, self.start_position, self.peak_start_position,
            self.peak_stop_position, self.stop_position)
1347306
def fromString(self, inStr):
        
        host, sPort = inStr.split(":")
        return (host, int(sPort))
1082428
def _make_style_str(styledict):
    
    s = ''
    for key in list(styledict.keys()):
        s += "%s:%s;" % (key, styledict[key])
    return s
588658
private String createString(String f)
    {
        return
            "srcXInBytes="+srcXInBytes+f+
            "srcY="+srcY+f+
            "srcMemoryType="+CUmemorytype.stringFor(srcMemoryType)+f+
            "srcHost ="+srcHost +f+
            "srcDevice ="+srcDevice +f+
            "srcArray ="+srcArray +f+
            "srcPitch="+srcPitch+f+
            "dstXInBytes="+dstXInBytes+f+
            "dstY="+dstY+f+
            "dstMemoryType="+CUmemorytype.stringFor(dstMemoryType)+f+
            "dstHost ="+dstHost +f+
            "dstDevice ="+dstDevice +f+
            "dstArray ="+dstArray +f+
            "dstPitch="+dstPitch+f+
            "WidthInBytes="+WidthInBytes+f+
            "Height="+Height;
    }
571778
def get_string(self, sigfigs=8):
        
        ctrl_dict = self.as_dict()
        lines = [] if "HEADER" not in ctrl_dict else \
            ["HEADER".ljust(10) + self.header]
        if "VERS" in ctrl_dict:
            lines.append("VERS".ljust(10) + self.version)

        lines.append("STRUC".ljust(10) +
                     "ALAT="+str(round(ctrl_dict["ALAT"], sigfigs)))
        for l, latt in enumerate(ctrl_dict["PLAT"]):
            if l == 0:
                line = "PLAT=".rjust(15)
            else:
                line = " ".ljust(15)
            line += " ".join([str(round(v, sigfigs)) for v in latt])
            lines.append(line)

        for cat in ["CLASS", "SITE"]:
            for a, atoms in enumerate(ctrl_dict[cat]):
                if a == 0:
                    line = [cat.ljust(9)]
                else:
                    line = [" ".ljust(9)]
                for token, val in sorted(atoms.items()):
                    if token == "POS":
                        line.append("POS=" +
                                    " ".join([str(round(p, sigfigs))
                                              for p in val]))
                    else:
                        line.append(token + "=" + str(val))
                line = " ".join(line)
                lines.append(line)

        return "\n".join(lines)+"\n"
628379
def _to_string(self):
        
        return u"{}+{}@{}".format(text_type(self.definition_id), self.BLOCK_TYPE_PREFIX, self.block_type)
141323
def uri_from_fields(prefix, *fields):
        """"""
        string = '_'.join(AlignmentHelper.alpha_numeric(f.strip().lower(), '') for f in fields)

        if len(string) == len(fields) - 1:
            return ''

        return prefix + string
453005
def from_string(cls, line, ignore_bad_cookies=False,
                    ignore_bad_attributes=True):
        ""
        cookie_dict = parse_one_response(
            line, ignore_bad_cookies=ignore_bad_cookies,
            ignore_bad_attributes=ignore_bad_attributes)
        if not cookie_dict:
            return None
        return cls.from_dict(
            cookie_dict, ignore_bad_attributes=ignore_bad_attributes)
575844
def variant_context_w_alignment(am, var, margin=20, tx_ac=None):
    """"""
    from uta_align.align.algorithms import align, cigar_alignment

    fh = full_house(am, var, tx_ac=tx_ac)
    tm = am._fetch_AlignmentMapper(fh['n'].ac, fh['g'].ac, am.alt_aln_method)
    strand = tm.strand
    span_g = _ival_to_span(fh['g'].posedit.pos)
    span_g = (span_g[0] - margin, span_g[1] + margin)
    ival_g = Interval(SimplePosition(span_g[0]), SimplePosition(span_g[1]))
    ival_n = tm.g_to_n(ival_g)
    assert ival_n.start.offset == 0 and ival_n.end.offset == 0, "limited to coding variants"
    span_n = _ival_to_span(ival_n)
    ival_c = tm.g_to_c(ival_g)
    span_c = _ival_to_span(ival_c)
    seq_gt = am.hdp.get_seq(fh['g'].ac, span_g[0] - 1, span_g[1])
    seq_gb = complement(seq_gt)
    seq_n = am.hdp.get_seq(fh['n'].ac, span_n[0] - 1, span_n[1])
    if strand == 1:
        a = align(bytes(seq_gt), bytes(seq_n), b'global', extended_cigar=True)
    else:
        seq_n = ''.join(reversed(seq_n))
        a = align(bytes(seq_gb), bytes(seq_n), b'global', extended_cigar=True)

    aseq_gt, _ = cigar_alignment(seq_gt, a.query, a.cigar, hide_match=False)
    aseq_gb, aseq_n = cigar_alignment(seq_gb, a.query, a.cigar, hide_match=False)
    aln_str = _reformat_aln_str(cigar_alignment(a.ref, a.query, a.cigar, hide_match=True)[1])
    s_dir = '>' if strand == 1 else '<'

    lines = [
        [
            1,
            0,
            seq_line_fmt(
                var=fh['c'],
                span=span_c if strand == 1 else list(reversed(span_c)),
                content='',
                dir=s_dir),
        ],
        [
            2,
            0,
            seq_line_fmt(
                var=fh['n'],
                span=span_n if strand == 1 else list(reversed(span_n)),
                content=aseq_n,
                dir=s_dir),
        ],
        [
            3,
            0,
            _line_fmt.format(pre='', content=aln_str, post=a.cigar.to_string(), comment=''),
        ],
        [
            4,
            1,
            seq_line_fmt(var=fh['g'], span=span_g, content=aseq_gt, dir='>'),
        ],
        [
            4,
            2,
            seq_line_fmt(var=fh['g'], span=span_g, content=aseq_gb, dir='<'),
        ],
        [
            5,
            0,
            pointer_line(var=fh['g'], span=span_g),
        ],
    ]
    if strand == -1:
        lines.sort(key=lambda e: (-e[0], e[1]))
    return '\n'.join(r[2] for r in lines)
663175
def _make_c_string(string):
    """"""
    if isinstance(string, bytes):
        try:
            _utf_8_decode(string, None, True)
            return string + b"\x00"
        except UnicodeError:
            raise InvalidStringData("strings in documents must be valid "
                                    "UTF-8: %r" % string)
    else:
        return _utf_8_encode(string)[0] + b"\x00"
255387
def tostring(self, inject):
        """"""
        return inject(self, '\n'.join(document.tostring(inject) for document in self.documents))
1329854
def tostr(self, object, indent=-2):
        
        history = []
        return self.process(object, history, indent)
595458
def to_str(self):
        ''''''
        pairs = []
        for name, value in self.get_all():
            if value and self._wrap_width:
                pairs.append('{0}:{1}'.format(
                    name,
                    '\r\n'.join(textwrap.wrap(
                        value, width=self._wrap_width,
                        drop_whitespace=False, initial_indent=' ',
                        subsequent_indent=' '
                    ))
                ))
            elif value:
                pairs.append('{0}: {1}'.format(name, value))
            else:
                pairs.append('{0}:'.format(name))

        pairs.append('')
        return '\r\n'.join(pairs)
207641
def ustring(self,
                indent,
                color,
                msg,
                prefix='',
                suffix='',
                endc=None):
        ''''''
        if endc is None:
            endc = self.ENDC  # pylint: disable=no-member

        indent *= ' '
        fmt = u'{0}{1}{2}{3}{4}{5}'

        try:
            return fmt.format(indent, color, prefix, msg, endc, suffix)
        except UnicodeDecodeError:
            return fmt.format(indent, color, prefix, salt.utils.data.decode(msg), endc, suffix)
1099314
def stringize(
        self,
        rnf_profile,
    ):
        

        coor_width = max(rnf_profile.coor_width, len(str(self.left)), len(str(self.right)))
        return "({},{},{},{},{})".format(
            str(self.genome_id).zfill(rnf_profile.genome_id_width),
            str(self.chr_id).zfill(rnf_profile.chr_id_width), self.direction,
            str(self.left).zfill(coor_width),
            str(self.right).zfill(coor_width)
        )