本文整理汇总了Python中resources.Resources.download_missing_go_data方法的典型用法代码示例。如果您正苦于以下问题:Python Resources.download_missing_go_data方法的具体用法?Python Resources.download_missing_go_data怎么用?Python Resources.download_missing_go_data使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类resources.Resources
的用法示例。
在下文中一共展示了Resources.download_missing_go_data方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from resources import Resources [as 别名]
# 或者: from resources.Resources import download_missing_go_data [as 别名]
def main(resource_directory=None, cron=False, no_download=False):
""" Overview:
Collect resources
Display info on missing ones
Ask - Download missing ones
Ask - Insert new GO editions
Ask - Insert new GOA editions
Ask - Update sec_ac
Ask - preprocess
"""
# Connect to database
gotrack = gtdb.GOTrack(cursorclass=MySQLdb.cursors.SSCursor, **CREDS)
LOG.info("Connected to host: %s, db: %s, user: %s", CREDS['host'], CREDS['db'], CREDS['user'])
# Collect current state of resources
if resource_directory is None:
resource_directory = tempfile.mkdtemp()
LOG.warn("No resource directory specified. Creating temporary folder at %s", resource_directory)
check_ftp = not no_download and (cron or query_yes_no("Check FTP sites for new data?"))
res = Resources(resource_directory, gotrack.fetch_current_state(), check_ftp)
# Display current state of resource directory, database, and ftp site
LOG.info(res)
# if cron, force download of accession history file
res.sec_ac = None if cron else res.sec_ac
# Deal with missing data
if res.ftp_checked and res.is_missing_data():
missing_cnt = len(res.missing_go)
if missing_cnt:
LOG.warn("Missing %s GO Versions from FTP", missing_cnt)
if cron or query_yes_no("Download missing GO Versions?"):
res.download_missing_go_data()
missing_cnt = sum([len(goa_sp) for goa_sp in res.missing_goa.values()])
if missing_cnt:
LOG.warn("Missing %s GOA Editions from FTP", missing_cnt)
if cron or query_yes_no("Download missing GOA Editions?"):
res.download_missing_goa_data()
if not res.sec_ac:
LOG.warn("Missing secondary accession file (sec_ac.txt)")
if cron or query_yes_no("Download missing secondary accession file?"):
res.download_accession_history(skip_if_exists=not cron)
LOG.info("Re-checking state of resource directory")
res.populate_existing_files()
res.populate_missing_data()
LOG.info(res)
if res.is_missing_data() or not (cron or query_yes_no("Continue with updates?")):
return
# Insert new GO data
new_go = res.get_new_go()
if new_go:
LOG.info("New GO Versions ready to update: %s", len(new_go))
if cron or query_yes_no("Update GO tables? (Affected tables: '{go_edition}', '{go_term}', "
"'{go_adjacency}', '{go_alternate}')".format(**gotrack.tables)):
for go_date in sorted(new_go.keys()):
go_file = new_go[go_date]
LOG.info("Begin: %s", go_date.strftime('%Y-%m-%d'))
ont = Ontology.from_file_data(go_date, go_file)
gotrack.update_go_tables(ont)
newest_go_date = max(new_go)
LOG.info("Newest ontology available for GO definitions: %s", newest_go_date.strftime('%Y-%m-%d'))
if cron or query_yes_no("Update GO definitions with this ontology? (Affected tables: '{go_definition}'"
.format(**gotrack.tables)):
ont = Ontology.from_file_data(newest_go_date, new_go[newest_go_date])
gotrack.update_current_go_definitions(ont)
else:
LOG.info("There are no new GO Versions available to update")
# Insert new GOA data
new_goa = res.get_new_goa()
new_goa_cnt = sum([len(goa_sp) for goa_sp in new_goa.values()])
if new_goa_cnt:
LOG.info("New GOA Editions ready to update: %s", new_goa_cnt)
if cron or query_yes_no("Update GOA tables? (Affected tables: '{edition}', "
"'{accession}', '{annotation}', '{synonyms}')".format(**gotrack.tables)):
goa_skipped = []
for species, goa_eds in new_goa.iteritems():
LOG.info("Begin Species: %s", species)
sp_id = res.sp_map[species]
for edition in sorted(goa_eds.keys()):
LOG.info("Edition: %s", edition)
gpa_file, gpi_file = goa_eds[edition]
meta = parsers.check_goa_gpa(gpa_file)
if meta is None:
LOG.warn('Skipping edition %s for species %s', edition, species)
goa_skipped.append((edition,species))
continue
#.........这里部分代码省略.........