本文整理汇总了Python中Bio.SearchIO._model.HSPFragment.query_start方法的典型用法代码示例。如果您正苦于以下问题:Python HSPFragment.query_start方法的具体用法?Python HSPFragment.query_start怎么用?Python HSPFragment.query_start使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Bio.SearchIO._model.HSPFragment
的用法示例。
在下文中一共展示了HSPFragment.query_start方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: parse_hsps
# 需要导入模块: from Bio.SearchIO._model import HSPFragment [as 别名]
# 或者: from Bio.SearchIO._model.HSPFragment import query_start [as 别名]
def parse_hsps(self, hit_placeholders):
"""Parse a HMMER2 hsp block, beginning with the hsp table."""
# HSPs may occur in different order than the hits
# so store Hit objects separately first
unordered_hits = {}
while self.read_next():
if self.line.startswith('Alignments') or \
self.line.startswith('Histogram') or \
self.line == '//':
break
if self.line.startswith('Model') or \
self.line.startswith('Sequence') or \
self.line.startswith('--------'):
continue
id_, domain, seq_f, seq_t, seq_compl, hmm_f, hmm_t, hmm_compl, \
score, evalue = self.line.split()
frag = HSPFragment(id_, self.qresult.id)
frag.alphabet = generic_protein
if self._meta['program'] == 'hmmpfam':
frag.hit_start = int(hmm_f) - 1
frag.hit_end = int(hmm_t)
frag.query_start = int(seq_f) - 1
frag.query_end = int(seq_t)
elif self._meta['program'] == 'hmmsearch':
frag.query_start = int(hmm_f) - 1
frag.query_end = int(hmm_t)
frag.hit_start = int(seq_f) - 1
frag.hit_end = int(seq_t)
hsp = HSP([frag])
hsp.evalue = float(evalue)
hsp.bitscore = float(score)
hsp.domain_index = int(domain.split('/')[0])
if self._meta['program'] == 'hmmpfam':
hsp.hit_endtype = hmm_compl
hsp.query_endtype = seq_compl
elif self._meta['program'] == 'hmmsearch':
hsp.query_endtype = hmm_compl
hsp.hit_endtype = seq_compl
if id_ not in unordered_hits:
placeholder = [ p for p in hit_placeholders if p.id_ == id_][0]
hit = placeholder.createHit([hsp])
unordered_hits[id_] = hit
else:
hit = unordered_hits[id_]
hsp.hit_description = hit.description
hit.append(hsp)
# The placeholder list is in the correct order, so use that order for
# the Hit objects in the qresult
for p in hit_placeholders:
self.qresult.append(unordered_hits[p.id_])
示例2: _create_hsp
# 需要导入模块: from Bio.SearchIO._model import HSPFragment [as 别名]
# 或者: from Bio.SearchIO._model.HSPFragment import query_start [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