comparison data_manager/resource_building.py @ 53:bb552aa4b9ac draft

"planemo upload commit 59b014e9f6e2d668cbd7c4844b10db3d59baefd8-dirty"
author proteore
date Fri, 05 Jun 2020 13:49:53 +0000
parents 55b12ec24a9f
children 109fc5236204
comparison
equal deleted inserted replaced
52:93bb1170280d 53:bb552aa4b9ac
279 ftp.retrbinary("RETR " + file, open(path, 'wb').write) 279 ftp.retrbinary("RETR " + file, open(path, 'wb').write)
280 ftp.quit() 280 ftp.quit()
281 return (path) 281 return (path)
282 282
283 def id_list_from_nextprot_ftp(file,target_directory) : 283 def id_list_from_nextprot_ftp(file,target_directory) :
284 ftp_dir = "pub/current_release/ac_lists/"
284 path = os.path.join(target_directory, file) 285 path = os.path.join(target_directory, file)
285 ftp = ftplib.FTP("ftp.nextprot.org") 286 ftp = ftplib.FTP("ftp.nextprot.org")
286 ftp.login("anonymous", "anonymous") 287 ftp.login("anonymous", "anonymous")
287 ftp.cwd("pub/current_release/ac_lists/") 288 ftp.cwd(ftp_dir)
288 r = StringIO() 289 ftp.retrbinary("RETR " + file, open(path, 'wb').write)
289 ftp.retrlines("RETR " + file, lambda line: r.write(line + '\n'))
290 ftp.quit() 290 ftp.quit()
291 r.seek(0) 291 with open(path,'r') as nextprot_ids :
292 ids = r.readlines() 292 nextprot_ids = nextprot_ids.read().splitlines()
293 ids = [id.strip('\n') for id in ids if id != ''] 293 return (nextprot_ids)
294 return (ids)
295 294
296 #return '' if there's no value in a dictionary, avoid error 295 #return '' if there's no value in a dictionary, avoid error
297 def access_dictionary (dico,key1,key2) : 296 def access_dictionary (dico,key1,key2) :
298 if key1 in dico : 297 if key1 in dico :
299 if key2 in dico[key1] : 298 if key2 in dico[key1] :