本文整理汇总了Python中Bio.SwissProt.read方法的典型用法代码示例。如果您正苦于以下问题:Python SwissProt.read方法的具体用法?Python SwissProt.read怎么用?Python SwissProt.read使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Bio.SwissProt
的用法示例。
在下文中一共展示了SwissProt.read方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_SwissProt
# 需要导入模块: from Bio import SwissProt [as 别名]
# 或者: from Bio.SwissProt import read [as 别名]
def get_SwissProt(dict,accession):
try:
handle = ExPASy.get_sprot_raw(accession)
record = SwissProt.read(handle)
dict[accession] = record
except urllib2.HTTPError, error:
print accession + ": protein not found on UniProt . "
示例2: gen_uniprot_features_for_pdb
# 需要导入模块: from Bio import SwissProt [as 别名]
# 或者: from Bio.SwissProt import read [as 别名]
def gen_uniprot_features_for_pdb(infile):
for line in open(infile,'r'):
(pdb_dom, count, uniprot_ids) = line.replace('\n','').split('\t')
uniprot_ids = uniprot_ids.split('|')
for uniprot_id in uniprot_ids:
data = SwissProt.read(ExPASy.get_sprot_raw(uniprot_id)).__dict__
keep = False
go = []; interpro = ''; evo_trace = ''
for xref in data['cross_references']:
if xref[0] == 'GO':
go.append(xref[1])
if xref[0] == 'InterPro':
interpro = xref[1]
if xref[0] == 'EvolutionaryTrace':
evo_trace = xref[1]
if xref[0] == 'PDB' and xref[1].lower() == pdb_dom.lower():
keep = True
if keep == False:
continue
organism = data['organism']
loc = ''
for comment in data['comments']:
if comment.startswith('SUBCELLULAR LOCATION'):
loc = comment
print '%s\t%s\t%s\t%s\t%s\t%s\t%s' %(pdb_dom,uniprot_id,'|'.join(go),interpro,evo_trace,organism,loc)
示例3: main
# 需要导入模块: from Bio import SwissProt [as 别名]
# 或者: from Bio.SwissProt import read [as 别名]
def main(argv):
# input() reads stdin
handle = ExPASy.get_sprot_raw(input().strip()) #you can give several IDs separated by commas
record = SwissProt.read(handle) # use SwissProt.parse for multiple proteins
# there ought to be a better way to pull GO information from the record! maybe there is...
for p in filter(lambda x:x[0]=='GO' and x[2].startswith('P:'),record.cross_references):
print(p[2][2:])
示例4: main
# 需要导入模块: from Bio import SwissProt [as 别名]
# 或者: from Bio.SwissProt import read [as 别名]
def main():
with open("dbpr") as f:
handle = ExPASy.get_sprot_raw(f.readline().strip())
record = SwissProt.read(handle)
record = [x[2] for x in record.cross_references if x[0] == 'GO']
record = [x[2:] for x in record if x[0] == 'P']
sys.stdout = open("dbpr.out","w")
print "\n".join(record)
示例5: acession
# 需要导入模块: from Bio import SwissProt [as 别名]
# 或者: from Bio.SwissProt import read [as 别名]
def acession(self):
self.rec=[]
for ide in self.ids:
if ide!='ND':
results=ExPASy.get_sprot_raw(ide)
rec=SwissProt.read(results)
self.rec.append(rec)
else:
self.rec.append('ND')
return self.rec
示例6: BiologicalProcesses
# 需要导入模块: from Bio import SwissProt [as 别名]
# 或者: from Bio.SwissProt import read [as 别名]
def BiologicalProcesses(UniProtID):
Handle = ExPASy.get_sprot_raw(UniProtID)
Record = SwissProt.read(Handle)
Processes = []
for i in Record.cross_references:
if "GO" in i:
for j in i:
if re.match("P:.*", j):
Processes.append(j[j.rfind(':')+1:])
return "\n".join(Processes)
示例7: get_keywords
# 需要导入模块: from Bio import SwissProt [as 别名]
# 或者: from Bio.SwissProt import read [as 别名]
def get_keywords(lookup):
try:
handle = ExPASy.get_sprot_raw(lookup)
except:
print("Error in ExPASy")
sys.exit(1)
try:
record = SwissProt.read(handle)
except ValueError, error:
print(error)
sys.exit(1)
示例8: fetch
# 需要导入模块: from Bio import SwissProt [as 别名]
# 或者: from Bio.SwissProt import read [as 别名]
def fetch(acc) :
'''Downloads data from UniProt.
Input:
acc: accession code of the record
database: database name
Return: the Entrez record
'''
base_url = 'http://www.uniprot.org/uniprot/'
handle = urllib.request.urlopen(base_url + acc + '.txt')
record = SwissProt.read(handle)
return record
示例9: main
# 需要导入模块: from Bio import SwissProt [as 别名]
# 或者: from Bio.SwissProt import read [as 别名]
def main(protein_id):
handle = ExPASy.get_sprot_raw(protein_id) #you can give several IDs separated by commas
record = SwissProt.read(handle) # use SwissProt.parse for multiple proteins
answer = ""
for r in record.cross_references:
print r
if r[0] == "GO":
if r[2].split(":")[0] == 'P':
answer += r[2].split(":")[1] + "\n"
return answer.strip()
示例10: download_entry
# 需要导入模块: from Bio import SwissProt [as 别名]
# 或者: from Bio.SwissProt import read [as 别名]
def download_entry(self, accession):
try:
handle = ExPASy.get_sprot_raw(accession)
record = SwissProt.read(handle)
except:
raise KeyError('{}'.format(accession))
record_org = record.organism.strip().lower()
if self.organism not in record_org:
print('{} ortholog of {} not found.'.format(self.organism, accession))
raise KeyError('{} ortholog of {} not found.'.format(self.organism, accession))
else:
self.records[accession] = record
return record
示例11: main
# 需要导入模块: from Bio import SwissProt [as 别名]
# 或者: from Bio.SwissProt import read [as 别名]
def main():
#Grab our input id value
uniprot_id = get_uniprot_id_from_file(arguments['<input>'])
#Get a handle on the data for the uniprot id
handle = ExPASy.get_sprot_raw(uniprot_id)
#Parse our data
record = SwissProt.read(handle)
handle.close()
#Process out the stuff of interest, GO values in this case
go_refs = [ref[1:] for ref in record.cross_references if ref[0] == 'GO']
for go_entry in go_refs:
pre, val = go_entry[1].split(':')
if pre == 'P':
print(val)
示例12: main
# 需要导入模块: from Bio import SwissProt [as 别名]
# 或者: from Bio.SwissProt import read [as 别名]
def main(fichier):
"""
navigate into protein database
"""
f = open(fichier,'r')
fline = f.readline().strip()
from Bio import ExPASy
from Bio import SwissProt
handle = ExPASy.get_sprot_raw(fline)
record = SwissProt.read(handle)
go = []
for i in record.cross_references:
if i[0] == 'GO' and i[2][0]=='P':
go.append(i[2].lstrip('P:'))
print '\n'.join(go)
示例13: main
# 需要导入模块: from Bio import SwissProt [as 别名]
# 或者: from Bio.SwissProt import read [as 别名]
def main():
# Read the UniProt ID for a txt file.
with open('problem_datasets/rosalind_dbpr.txt', 'r') as infile:
uni_id = infile.read().strip()
# Retrieve the data from UniProt (separated IDs by commas).
raw_data = ExPASy.get_sprot_raw(uni_id)
record = SwissProt.read(raw_data) # use SwissProt.parse for multiple proteins
# Collect the relevant information.
go = []
for i in record.cross_references:
if i[2].startswith('P:'):
go.append(i[2][2:])
# Output answer.
with open('output/rosalind_dbpr_out.txt', 'w') as outfile:
outfile.write('\n'.join(go))
# Optional: Print answer and gene ID/name
name = record.gene_name.split(' ')[0][5:]
print('Gene:\n', name, ' (UniProt ID = ', uni_id,
')\n\nBiological Processes:\n', '\n'.join(go), sep='')
示例14: snp_uniprot
# 需要导入模块: from Bio import SwissProt [as 别名]
# 或者: from Bio.SwissProt import read [as 别名]
def snp_uniprot(uniprotname, selection='(all)', label=1, name='', quiet=0):
'''
DESCRIPTION
Selects all UniProt annotated nsSNPs (natural variants) in given
structure. Does a sequence alignment of UniProt sequence and PDB
sequence.
USAGE
snp_uniprot uniprotname [, selection [, label [, name [, quiet]]]]
ARGUMENTS
uniprotname = string: UniProt reference (like HBB_HUMAN or P68871)
selection = string: atom selection
label = 0 or 1: Label CA atoms of nsSNPs with mutation {default: 1}
name = string: name of new selection {default: nsSNPs}
EXAMPLE
fetch 3HBT
snp_uniprot ACTG_HUMAN, chain A
SEE ALSO
snp_ncbi
'''
from Bio import ExPASy
from Bio import SwissProt
handle = ExPASy.get_sprot_raw(uniprotname)
record = SwissProt.read(handle)
snp_common(record, selection, label, name, quiet)
示例15: SWAT
# 需要导入模块: from Bio import SwissProt [as 别名]
# 或者: from Bio.SwissProt import read [as 别名]
def SWAT(id):
handle = ExPASy.get_sprot_raw(id) # several IDs can be separated by commas
record = SwissProt.read(handle) # use SwissProt.parse for multiple proteins
return record.sequence