本文整理汇总了Python中Bio.Entrez.email方法的典型用法代码示例。如果您正苦于以下问题:Python Entrez.email方法的具体用法?Python Entrez.email怎么用?Python Entrez.email使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Bio.Entrez
的用法示例。
在下文中一共展示了Entrez.email方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_ncbi_seq
# 需要导入模块: from Bio import Entrez [as 别名]
# 或者: from Bio.Entrez import email [as 别名]
def get_ncbi_seq(email, db, rettype, accession):
# fetch
print("Fetching accession %s from GenBank\n" % (accession))
Entrez.email = email
try:
handle = Entrez.efetch(
db=db,
rettype=rettype,
retmode="text",
id=accession
)
res = handle.read()
# for testing only
# pickle_item(res, accession)
return res
except Exception:
sys.stderr.write("Error! Cannot fetch: %s \n" % accession)
示例2: main
# 需要导入模块: from Bio import Entrez [as 别名]
# 或者: from Bio.Entrez import email [as 别名]
def main():
parser = argparse.ArgumentParser(
description='Populate the phageParser database with data from NCBI'
)
parser.add_argument(
'email',
nargs=1,
help=('your email address (does not need to be registered, '
'just used to identify you)')
)
args = parser.parse_args()
Entrez.email = args.email
print("Starting organism population")
populate_organism()
print("Starting LSR population")
populate_lsrpair()
print("Starting AntiCRISPR population")
populate_anticrispr()
示例3: fetch_chrom_name
# 需要导入模块: from Bio import Entrez [as 别名]
# 或者: from Bio.Entrez import email [as 别名]
def fetch_chrom_name(id):
try:
if not id.startswith("NC_"):
return id
Entrez.email = "vcf-kit@vcf-kit.com"
chrom = Entrez.read(Entrez.efetch(db="nuccore", id=id, rettype="gb", retmode="xml"))
gb_feature_quals = chrom[0]["GBSeq_feature-table"][0]["GBFeature_quals"]
features = dict([x.values() for x in gb_feature_quals])
if "organelle" in features:
if features["organelle"] == "mitochondrion":
return "MtDNA"
else:
chrom_name = features["chromosome"]
return chrom_name
except:
return id
示例4: __init__
# 需要导入模块: from Bio import Entrez [as 别名]
# 或者: from Bio.Entrez import email [as 别名]
def __init__(self, prefix, datasource, outdb, options=None, ohost=None,
email=None):
'''
prefix - prefix used to recognise which annotation is being performed
datasource - link used for API
outdb - output database
options - optional string to be parsed by the APIAnnotation subclass
ohost - original species of interest used by some subclasses
email - entrez requires an email address to use its API
'''
self.prefix = prefix
self.datasource = datasource
self.outdb = outdb
self.options = options
self.ohost = ohost
self.email = email
self.resultsz = dict()
self.resultspd = dict()
示例5: get_species_from_taxid
# 需要导入模块: from Bio import Entrez [as 别名]
# 或者: from Bio.Entrez import email [as 别名]
def get_species_from_taxid(self, taxid):
#if it is an integer (a taxid), try to get the species name
species = taxid
if taxid.isdigit():
Entrez.email = EMBL.PREVIOUS_VALUES["email"]
# fetch the classification sufing the taxid
logging.debug("Fetch The Lineage using Entrez.efetch")
try:
search = Entrez.efetch(id=taxid, db="taxonomy", retmode="xml")
data = Entrez.read(search)
species = data[0]['ScientificName']
except IOError as e:
logging.error("Could not get species from taxid: %s" % e)
return "%s%s" % (species[0].upper(), species[1:].lower())
#if species is a taxid we change by the species name
示例6: get_taxid_from_species
# 需要导入模块: from Bio import Entrez [as 别名]
# 或者: from Bio.Entrez import email [as 别名]
def get_taxid_from_species(self, species):
#if it is a species name try to get the taxid
taxid = species
if not species.isdigit():
Entrez.email = EMBL.PREVIOUS_VALUES["email"]
#fetch taxid from ncbi taxomomy
logging.debug("Fetch the taxid from species name using Entrez.esearch")
species = species.replace(" ", "+").strip()
try:
search = Entrez.esearch(term=species, db="taxonomy", retmode="xml")
record = Entrez.read(search)
if not record['IdList']: #no taxid found
logging.warning("Please verify the species name. '%s' species is unknown into the NCBI taxonomy databse. Impossible to check the taxonomic classification. We will use the default value 'Life' to populate the OC line.",self.species)
taxid=None
else:
taxid = record['IdList'][0]
except IOError as e:
logging.error("Could not get taxid from species: %s" % e)
return taxid
示例7: parse
# 需要导入模块: from Bio import Entrez [as 别名]
# 或者: from Bio.Entrez import email [as 别名]
def parse(self, path, fname, ftype, email, **kwargs):
if self.accessions is not None:
accessions = [acc.strip() for acc in self.accessions.split(",")]
self.entrez_email(email)
gi = self.get_GIs(accessions)
viruses, sequences = self.get_entrez_viruses(gi, **kwargs)
elif ftype is not None and fname is not None:
if ftype == 'genbank':
viruses, sequences = self.parse_gb_file(path + fname, **kwargs)
elif ftype == 'accession':
accessions = self.parse_accession_file(path + fname, **kwargs)
self.entrez_email(email)
gi = self.get_GIs(accessions)
viruses, sequences = self.get_entrez_viruses(gi, **kwargs)
elif ftype == 'fasta':
viruses, sequences = self.parse_fasta_file(path + fname, **kwargs)
elif ftype == 'tsv':
viruses, sequences = self.parse_tsv_file(path + fname, **kwargs)
print("Parsed " + str(len(viruses)) + " viruses and " + str(len(sequences)) + " sequences from file " + path+fname)
else:
raise Exception("No input file name and type defined or accessions given")
return (viruses, sequences)
示例8: get_args
# 需要导入模块: from Bio import Entrez [as 别名]
# 或者: from Bio.Entrez import email [as 别名]
def get_args():
"""get command-line arguments"""
parser = argparse.ArgumentParser(
description='Filter FASTA by taxons',
formatter_class=argparse.ArgumentDefaultsHelpFormatter)
parser.add_argument('file', metavar='str', help='Input file')
parser.add_argument('-t',
'--taxa',
help='Taxa ids/file',
metavar='str',
type=str,
required=True)
parser.add_argument('-e',
'--email',
help='Email address for Entrez query',
metavar='str',
type=str,
default='kyclark@email.arizona.edu')
parser.add_argument('-o',
'--outfile',
help='Output file',
metavar='str',
type=str,
default='seqs.fa')
parser.add_argument('-d', '--debug', help='Debug', action='store_true')
return parser.parse_args()
# --------------------------------------------------
示例9: fetch_from_entrez
# 需要导入模块: from Bio import Entrez [as 别名]
# 或者: from Bio.Entrez import email [as 别名]
def fetch_from_entrez(index, cache_dir=False):
logger = logging.getLogger('build')
# slugify the index for the cache filename (some indices have symbols not allowed in file names (e.g. /))
index_slug= slugify(index)
cache_file_path = '{}/{}'.format('/'.join(cache_dir), index_slug)
# try fetching from cache
if cache_dir:
d = fetch_from_cache(cache_dir, index_slug)
if d:
logger.info('Fetched {} from cache'.format(cache_file_path))
return d
# if nothing is found in the cache, use the web API
logger.info('Fetching {} from Entrez'.format(index))
tries = 0
max_tries = 5
while tries < max_tries:
if tries > 0:
logger.warning('Failed fetching pubmed {}, retrying'.format(str(index)))
try:
Entrez.email = 'info@gpcrdb.org'
handle = Entrez.efetch(
db="pubmed",
id=str(index),
rettype="medline",
retmode="text"
)
except:
tries += 1
time.sleep(2)
else:
d = Medline.read(handle)
# save to cache
save_to_cache(cache_dir, index_slug, d)
logger.info('Saved entry for {} in cache'.format(cache_file_path))
return d
示例10: last_exception
# 需要导入模块: from Bio import Entrez [as 别名]
# 或者: from Bio.Entrez import email [as 别名]
def last_exception():
"""Return last exception as a string, or use in logging."""
exc_type, exc_value, exc_traceback = sys.exc_info()
return "".join(traceback.format_exception(exc_type, exc_value, exc_traceback))
# Set contact email for NCBI
示例11: set_ncbi_email
# 需要导入模块: from Bio import Entrez [as 别名]
# 或者: from Bio.Entrez import email [as 别名]
def set_ncbi_email(args: Namespace) -> None:
"""Set contact email for NCBI.
:param args: Namespace, command-line arguments
"""
logger = logging.getLogger(__name__)
Entrez.email = args.email
logger.info("Set NCBI contact email to %s", args.email)
Entrez.tool = "genbank_get_genomes_by_taxon.py"
# Create output directory if it doesn't exist
示例12: get_tax_id
# 需要导入模块: from Bio import Entrez [as 别名]
# 或者: from Bio.Entrez import email [as 别名]
def get_tax_id(self, query_name):
"""to get data from ncbi taxomomy, we need to have the taxid. we can
get that by passing the species name to esearch, which will return
the tax id"""
query_name = query_name.replace(' ', "+").strip()
Entrez.email = 'A.N.Other@example.com'
search = Entrez.esearch(term=query_name, db="taxonomy", retmode="xml")
record = Entrez.read(search)
return record['IdList'][0] if record['IdList'] else None
示例13: get_tax_data
# 需要导入模块: from Bio import Entrez [as 别名]
# 或者: from Bio.Entrez import email [as 别名]
def get_tax_data(self, taxid):
"""once we have the taxid, we can fetch the record"""
Entrez.email = 'A.N.Other@example.com'
search = Entrez.efetch(id=taxid, db="taxonomy", retmode="xml")
return Entrez.read(search)
示例14: fetSeqFromNCBI
# 需要导入模块: from Bio import Entrez [as 别名]
# 或者: from Bio.Entrez import email [as 别名]
def fetSeqFromNCBI(self, id_array):
batch_size = 20
count = len(id_array)
download_contents = ""
for start in range(0, count, batch_size):
if self.interrupt:
return
end = min(count, start + batch_size)
print("Going to download record %i to %i" % (start + 1, end))
if (start + batch_size) > count:
batch_size = count - start
Entrez.email = self.email if self.email else "A.N.Other@example.com"
fetch_handle = Entrez.efetch(db="nucleotide", rettype=self.rettype, retmode="text",
retstart=start, retmax=batch_size, id=id_array)
download_contents += fetch_handle.read()
self.progressDiologSig.emit(end * 100 / count)
if self.rettype == "gb":
self.inputContentSig.emit(
download_contents, self.outputPath)
else:
with open(self.outputPath + os.sep + self.fasta_file_name, "w", encoding="utf-8") as f:
f.write(download_contents)
self.fastaDownloadFinishedSig.emit(self.outputPath)
# result_handle = Entrez.efetch(
# db="nucleotide", rettype="gb", id=id_array, retmode="text")
# # with open(self.exportPath + os.sep + "new.gb", "w", encoding="utf-8") as f2:
# # f2.write(result_handle.read())
# self.inputContentSig.emit(
# result_handle.read(), [])
示例15: on_toolButton_clicked
# 需要导入模块: from Bio import Entrez [as 别名]
# 或者: from Bio.Entrez import email [as 别名]
def on_toolButton_clicked(self):
info = '''To make use of NCBI's E-utilities, NCBI requires you to specify your email address with each request.<br>
In case of excessive usage of the E-utilities, NCBI will attempt to contact a user at the email address provided before blocking access to the E-utilities.'''
QMessageBox.information(
self,
"Information",
"<p style='line-height:25px; height:25px'>%s</p>"%info)