def _download_latest_clinvar_xml(self, dest_dir):
ftp = FTP('ftp.ncbi.nlm.nih.gov')
ftp.login()
ftp.cwd(CV_XML_DIR)
# sort just in case the ftp lists the files in random order
cv_xml_w_date = sorted(
[f for f in ftp.nlst() if re.match(CV_XML_REGEX, f)])
if len(cv_xml_w_date) == 0:
raise CommandError('ClinVar reporting zero XML matching' +
' regex: \'{0}\' in directory {1}'.format(
CV_XML_REGEX, CV_XML_DIR))
ftp_xml_filename = cv_xml_w_date[-1]
dest_filepath = os.path.join(dest_dir, ftp_xml_filename)
with open(dest_filepath, 'w') as fh:
ftp.retrbinary('RETR {0}'.format(ftp_xml_filename), fh.write)
return dest_filepath, ftp_xml_filename
评论列表
文章目录