本文整理汇总了Python中Bio.SeqFeature.SeqFeature.qualifiers方法的典型用法代码示例。如果您正苦于以下问题:Python SeqFeature.qualifiers方法的具体用法?Python SeqFeature.qualifiers怎么用?Python SeqFeature.qualifiers使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Bio.SeqFeature.SeqFeature
的用法示例。
在下文中一共展示了SeqFeature.qualifiers方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create_gene_feature
# 需要导入模块: from Bio.SeqFeature import SeqFeature [as 别名]
# 或者: from Bio.SeqFeature.SeqFeature import qualifiers [as 别名]
def create_gene_feature(gene_name, feature_location, feature_qualifiers):
"""Creates a minimal SeqFeature to represent a gene.
"""
gene_feature = SeqFeature(feature_location, type='gene')
gene_feature.qualifiers = {'gene': [gene_name]}
gene_feature.qualifiers = dict(gene_feature.qualifiers.items() +
feature_qualifiers.items())
return gene_feature
示例2: make_protein_feature
# 需要导入模块: from Bio.SeqFeature import SeqFeature [as 别名]
# 或者: from Bio.SeqFeature.SeqFeature import qualifiers [as 别名]
def make_protein_feature(feature_name, feature_start, feature_end, feature_type):
''' Returns sequence feature, using start, end, name and type as input
'''
feature = SeqFeature(FeatureLocation(int(feature_start), int(feature_end)), type=feature_type)
if feature_type == "Region":
feature.qualifiers = {'name': [feature_name]}
return feature
示例3: parse
# 需要导入模块: from Bio.SeqFeature import SeqFeature [as 别名]
# 或者: from Bio.SeqFeature.SeqFeature import qualifiers [as 别名]
def parse(self):
with open(self._file) as handle:
genbank = SeqRecord(Seq.UnknownSeq(0))
header_pattern = re.compile(r"ref\|(?P<id>.*?)\|:(?P<start>[0-9]+)-(?P<end>[0-9]+)\|(?P<description>.*?)\|\s*\[gene=(?P<gene>\S+)\]\s*\[locus_tag=(?P<locus_tag>\S+)\]\s*")
first = True
for record in SeqIO.parse(handle, "fasta"):
header = record.description
match = header_pattern.match(header)
if not match:
self.errors.append("Invalid header: >" + header)
continue
if first:
first = False
genbank.id = match.group("id")
genbank.name = match.group("id")
feature = SeqFeature(FeatureLocation(int(match.group("start")), int(match.group("end"))), type = "gene")
feature.qualifiers = {"locus_tag": match.group("locus_tag"),
"gene": match.group("gene"),
"note": match.group("description"),
"sequence": record.seq}
genbank.features.append(feature)
return genbank
return None
示例4: make_seq_feature
# 需要导入模块: from Bio.SeqFeature import SeqFeature [as 别名]
# 或者: from Bio.SeqFeature.SeqFeature import qualifiers [as 别名]
def make_seq_feature(start, end, ftype, quals={}):
'''
create a sequence feature from a start, end, and a type. additionally you
may include other fields, like note, label, evidence, citation, as a dict.
'''
seq_feature = SeqFeature(FeatureLocation(start, end), strand= +1, type=ftype)
seq_feature.qualifiers = quals
seq_feature.qualifiers['source'] = ['splicemod']
return seq_feature
示例5: attach_features
# 需要导入模块: from Bio.SeqFeature import SeqFeature [as 别名]
# 或者: from Bio.SeqFeature.SeqFeature import qualifiers [as 别名]
def attach_features(predictions, seqrecord):
for prediction in predictions[seqrecord.id]:
if prediction.raw_score >= 1.0:
qualifiers = {}
qualifiers['locus_tag'] = [prediction.cds_id]
feature = SeqFeature(
location=prediction.location,
type='CDS',
strand=prediction.strand,
qualifiers=qualifiers,
)
feature.qualifiers = qualifiers
seqrecord.features.append(feature)
示例6: _add_gff_line
# 需要导入模块: from Bio.SeqFeature import SeqFeature [as 别名]
# 或者: from Bio.SeqFeature.SeqFeature import qualifiers [as 别名]
def _add_gff_line(self, rec, gff_parts, parents, children):
"""Add details from a GFF line to the given SeqRecord.
"""
gff_parts = [(None if p == '.' else p) for p in gff_parts]
assert rec.id == gff_parts[0], "ID mismatch: %s %s" % (rec.id,
gff_parts[0])
# collect all of the base qualifiers for this item
quals = collections.defaultdict(list)
if gff_parts[1]:
quals["source"].append(gff_parts[1])
if gff_parts[5]:
quals["score"].append(gff_parts[5])
if gff_parts[7]:
quals["phase"].append(gff_parts[7])
for key, val in [a.split('=') for a in gff_parts[8].split(';')]:
quals[key].extend(val.split(','))
quals = dict(quals)
# if we are describing a location, then we are a feature
if gff_parts[3] and gff_parts[4]:
#if quals.has_key('ID') or quals.has_key('Parent'):
# print gff_parts[1:6], quals
location = FeatureLocation(int(gff_parts[3]) - 1, int(gff_parts[4]))
new_feature = SeqFeature(location, gff_parts[2],
id = quals.get('ID', [''])[0],
strand = self._strand_map[gff_parts[6]])
new_feature.qualifiers = quals
# Handle flat features
if not new_feature.id:
rec.features.append(new_feature)
# features that have parents need to link so we can pick up
# the relationship
elif new_feature.qualifiers.has_key('Parent'):
for parent in new_feature.qualifiers['Parent']:
children[parent].append(new_feature)
# top level features
else:
parents[rec.id].append(new_feature)
# otherwise, associate these annotations with the full record
else:
# add these as a list of annotations, checking not to overwrite
# current values
for key, vals in quals:
if rec.annotations.has_key(key):
try:
rec.annotations[key].extend(vals)
except AttributeError:
rec.annotations[key] = [rec.annotations[key]] + vals
else:
rec.annotations[key] = vals
return rec, parents, children
示例7: nrpsSmash
# 需要导入模块: from Bio.SeqFeature import SeqFeature [as 别名]
# 或者: from Bio.SeqFeature.SeqFeature import qualifiers [as 别名]
def nrpsSmash(dnaSeq):
options = Namespace()
options.outputfoldername = "/tmp/nrpspks_predictions_txt"
options.record_idx = "" # used in NRPSPredictor2.nrpscodepred, check later what to set it to
options.eukaryotic = 0
tstFeature = SeqFeature(FeatureLocation(0, len(dnaSeq)), type="CDS", strand=1)
tstFeature.qualifiers = {'gene':['gene']}
sequenceRecord = SeqRecord(Seq(dnaSeq, IUPAC.unambiguous_dna),
id = "seq_id",
name = "seq_name",
description = "seq_description")
sequenceRecord.features = [tstFeature]
analysis = specific_analysis(sequenceRecord, options)
shutil.rmtree(options.raw_predictions_outputfolder)
return analysis
示例8: parse_smart_domains
# 需要导入模块: from Bio.SeqFeature import SeqFeature [as 别名]
# 或者: from Bio.SeqFeature.SeqFeature import qualifiers [as 别名]
def parse_smart_domains(file_name):
in_handle = open(file_name, "rU")
lines = in_handle.readlines()
domains = []
domain_status = False
domain_type = False
is_domain = False
for line in lines:
line = line.rstrip()
if len(line) > 1:
pairs = line.split("=")
is_domain = True
if len(pairs) == 2:
if pairs[0] == "DOMAIN":
domain_name = pairs[1]
elif pairs[0] == "START":
domain_start = int(pairs[1])
elif pairs[0] == "END":
domain_end = int(pairs[1])
elif pairs[0] == "TYPE":
if pairs[1] != "PFAM":
domain_type = True
else:
domain_type = False
elif pairs[0] == "STATUS":
if pairs[1] == "visible|OK":
domain_status = True
#False
else: domain_status = True
else:
is_domain = False
else:
if is_domain & domain_type & domain_status:
d = SeqFeature(FeatureLocation(domain_start, domain_end), type="Region")
d.qualifiers = {'region_name': [domain_name]}
if domain_name != 'low_complexity_region':
domains.append(d)
is_domain = False
domain_type = False
domain_status = False
in_handle.close()
return domains
示例9: pred_coil
# 需要导入模块: from Bio.SeqFeature import SeqFeature [as 别名]
# 或者: from Bio.SeqFeature.SeqFeature import qualifiers [as 别名]
def pred_coil(seqr, params, fScore=None):
''' pred_coil(seq,seqLen,params,fScore) returns the coiled coil prediction of sequence seq'''
seqr = copy.deepcopy(seqr)
if fScore == None:
fScore = seqScore
seq = seqr.seq
seqLen = len(seqr.seq)
hept_pos=['a','b','c','d','e','f','g']
score=[0.0]*seqLen
hept_seq=['x']*seqLen
for i in range(seqLen-params.win+1):
this_score=1.0
actual_win=0.0
for j in range(min(params.win,seqLen-i)):
pos=j%7
actual_win+=params.pow[pos]
this_score*=math.pow( fScore(params.mat,seq,i+j,pos), params.pow[pos] )
if actual_win > 0:
this_score=math.pow(this_score,1/actual_win)
else:
this_score=0.0
for j in range(min(params.win,seqLen-i)):
pos=j%7
if this_score > score[i+j]:
score[i+j]=this_score
hept_seq[i+j]=hept_pos[pos]
for i in range(seqLen):
gg, gcc, prob = coilProb(score[i],params)
seqf = SeqFeature(location=FeatureLocation(i,i), type="pscoils")
seqf.qualifiers = {'gg':gg,
'gcc': gcc,
'prob': prob,
'score': score[i],
'hept_seq': hept_seq[i]}
seqr.features.append(seqf)
return seqr
示例10: SeqFeature
# 需要导入模块: from Bio.SeqFeature import SeqFeature [as 别名]
# 或者: from Bio.SeqFeature.SeqFeature import qualifiers [as 别名]
right_remains_end=currentsearch[2]
rightremains_list=[rightremainseq,right_remains_start,right_remains_end]
remainsearches.append([rightremainseq,right_remains_start,right_remains_end])
featureslist=[]
for feat in gbhitslist:
#print feat
mystrand=feat[3]["frame"][0]*feat[3]["frame"][1]
feature = SeqFeature(FeatureLocation(feat[0]-1,feat[1]), strand=mystrand,type=feat[2])
feature.qualifiers=feat[3]
featureslist.append(feature)
for f in featureslist:
gbfile.features.append(f)
outfilepath=contig_dir_path
#print(outfilepath)
tempfh=open(outfilepath,"w")
SeqIO.write([gbfile],tempfh,"genbank")
#print "treated "+str(contigcounter)+ " contigs"
print "treated "+str(genomerowcounter)+ "genome rows"
示例11: gene2features
# 需要导入模块: from Bio.SeqFeature import SeqFeature [as 别名]
# 或者: from Bio.SeqFeature.SeqFeature import qualifiers [as 别名]
def gene2features(r, gene, gene2position, gene2product, start, end, gcode, partialyes, verbose):
"""
"""
contig, CDSs, gffstrand, function, frames = gene2position[gene]
if gffstrand in ('1','+'):
strand = +1
else:
strand = -1
CDSs.reverse()
'''#add stop codon if not partial seq
if strand==1 and CDSs[-1][1]+3 <= len(r.seq):
CDSs[-1][1] += 3
elif strand==-1 and CDSs[0][0]-3 > 0:
CDSs[0][0] -= 3'''
cdsloc, mrnaloc = get_locations(CDSs, start, end, strand)
#add gene
geneid = gene #".".join(gene.split('.')[:-1])
#get product
product = "hypothetical protein"
if geneid in gene2product:
product = gene2product[geneid]
if gene.endswith('.t1'):
sf = SeqFeature(FeatureLocation(BeforePosition(start-1),AfterPosition(end)), strand=strand, type='gene', id=geneid)
sf.qualifiers={"locus_tag": geneid, "gene": geneid, "product": product}
r.features.append(sf)
#get mRNA sf
sf = SeqFeature(mrnaloc, type='mRNA', id=gene)
sf.qualifiers={"locus_tag": geneid, "gene": geneid, "product": product} #"protein_id": gene
r.features.append(sf)
#get CDS sf
sf = SeqFeature(cdsloc, type='CDS', id=gene)
#get translation
seq = sf.extract(r.seq)
aa = str(seq.translate(table=gcode))
#solve non-triplets issue
if len(seq) % 3:
if strand==1:
end -= len(seq) % 3
else:
start += len(seq) % 3
##check for partial sequence - no M as first or no * as last aa
partial = 0
#both ends partial
if aa[0]!="M" and aa[-1]!="*":
partial = 1
sf.location = FeatureLocation(BeforePosition(start-1),AfterPosition(end))
#left end partial
elif aa[0]!="M" and strand==1 or aa[-1]!="*" and strand==-1:
partial = 1
sf.location = FeatureLocation(BeforePosition(start-1),end)
#right end partial
elif aa[-1]!="*" and strand==1 or aa[0]!="M" and strand==-1:
partial = 1
sf.location = FeatureLocation(start-1,AfterPosition(end))
#strip stop codon
aa = aa.strip("*")
#replace internal stop codons by X
if "*" in aa:
if verbose:
sys.stderr.write("[Warning] Stop codon(s) in: %s. Skipped!\n" % gene)
return r
#aa = aa.replace("*","X")
sf.qualifiers = {'transl_table': gcode, "locus_tag": geneid, "gene": geneid, "product": product, "translation": aa} #"protein_id": gene,
if function:
sf.qualifiers['note'] = function
#inform about partial entries
if partial:
#skip if not partial are allowed
if not partialyes:
return r
if aa[0]!="M":
sf.qualifiers['codon_start'] = 1
sf.qualifiers['product'] += ", partial cds"
if verbose:
sys.stderr.write("[Warning] Partial sequence: %s\n" % (gene,))
#sys.stderr.write("[Warning] Partial sequence: %s %s\n" % (gene,sf))
#add to features
r.features.append(sf)
return r