当前位置: 首页>>代码示例>>Python>>正文


Python HSPFragment.aln_annotation[key]方法代码示例

本文整理汇总了Python中Bio.SearchIO._model.HSPFragment.aln_annotation[key]方法的典型用法代码示例。如果您正苦于以下问题:Python HSPFragment.aln_annotation[key]方法的具体用法?Python HSPFragment.aln_annotation[key]怎么用?Python HSPFragment.aln_annotation[key]使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Bio.SearchIO._model.HSPFragment的用法示例。


在下文中一共展示了HSPFragment.aln_annotation[key]方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _create_hsp

# 需要导入模块: from Bio.SearchIO._model import HSPFragment [as 别名]
# 或者: from Bio.SearchIO._model.HSPFragment import aln_annotation[key] [as 别名]
def _create_hsp(hid, qid, hspd):
    """Returns a list of HSP objects from the given parsed HSP values."""
    frags = []
    # we are iterating over query_ranges, but hit_ranges works just as well
    for idx, qcoords in enumerate(hspd["query_ranges"]):
        # get sequences, create object
        hseqlist = hspd.get("hit")
        hseq = "" if hseqlist is None else hseqlist[idx]
        qseqlist = hspd.get("query")
        qseq = "" if qseqlist is None else qseqlist[idx]
        frag = HSPFragment(hid, qid, hit=hseq, query=qseq)
        # coordinates
        frag.query_start = qcoords[0]
        frag.query_end = qcoords[1]
        frag.hit_start = hspd["hit_ranges"][idx][0]
        frag.hit_end = hspd["hit_ranges"][idx][1]
        # alignment annotation
        try:
            aln_annot = hspd.get("aln_annotation", {})
            for key, value in aln_annot.items():
                frag.aln_annotation[key] = value[idx]
        except IndexError:
            pass
        # strands
        frag.query_strand = hspd["query_strand"]
        frag.hit_strand = hspd["hit_strand"]
        # and append the hsp object to the list
        if frag.aln_annotation.get("similarity") is not None:
            if "#" in frag.aln_annotation["similarity"]:
                frags.extend(_split_fragment(frag))
                continue
        # try to set frame if there are translation in the alignment
        if (
            len(frag.aln_annotation) > 1
            or frag.query_strand == 0
            or ("vulgar_comp" in hspd and re.search(_RE_TRANS, hspd["vulgar_comp"]))
        ):
            _set_frame(frag)

        frags.append(frag)

    # if the query is protein, we need to change the hit and query sequences
    # from three-letter amino acid codes to one letter, and adjust their
    # coordinates accordingly
    if len(frags[0].aln_annotation) == 2:  # 2 annotations == protein query
        frags = _adjust_aa_seq(frags)

    hsp = HSP(frags)
    # set hsp-specific attributes
    for attr in ("score", "hit_split_codons", "query_split_codons", "model", "vulgar_comp", "cigar_comp", "alphabet"):
        if attr in hspd:
            setattr(hsp, attr, hspd[attr])

    return hsp
开发者ID:allista,项目名称:biopython,代码行数:56,代码来源:_base.py


注:本文中的Bio.SearchIO._model.HSPFragment.aln_annotation[key]方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。