Mercurial > repos > dchristiany > frogs_data_manager
comparison data_manager/FROGS_data_manager.py @ 7:99b2dfb1fa1c draft
planemo upload commit c3ff1475af0e964a0c61458b66e2744c903d8d3d-dirty
author | dchristiany |
---|---|
date | Fri, 04 Oct 2019 08:57:45 -0400 |
parents | d11bc4a8f596 |
children | 0d9cb5c5aa35 |
comparison
equal
deleted
inserted
replaced
6:d11bc4a8f596 | 7:99b2dfb1fa1c |
---|---|
23 with requests.Session() as s: | 23 with requests.Session() as s: |
24 download = s.get(frogs_db_index_link) | 24 download = s.get(frogs_db_index_link) |
25 decoded_content = download.content.decode('utf-8') | 25 decoded_content = download.content.decode('utf-8') |
26 db_index = download.content.splitlines() | 26 db_index = download.content.splitlines() |
27 db_index = [line.split("\t") for line in db_index[1:]] | 27 db_index = [line.split("\t") for line in db_index[1:]] |
28 db_index = [line[:4]+[line[1]+"_"+line[2]+"_"+line[1]]+[line[4]] for line in db_index] #add column name | 28 db_index = [line[:4]+[line[1]+"_"+line[2]+"_"+line[3]]+[line[4]] for line in db_index] #add column name |
29 | 29 |
30 #get frogs dbs | 30 #get frogs dbs |
31 os.chdir(target_directory) | |
31 dir_name="frogs_db_"+time.strftime("%Y%m%d") | 32 dir_name="frogs_db_"+time.strftime("%Y%m%d") |
32 os.mkdir(dir_name) | 33 os.mkdir(dir_name) |
33 dbs=set([]) | 34 dbs=set([]) |
34 for line in db_index[:2]: | 35 for line in db_index: |
35 value=line[4] | 36 value=line[4] |
36 name=value.replace("_"," ") | 37 name=value.replace("_"," ") |
37 link=line[5] | 38 link=line[5] |
38 | 39 |
39 #download frogs db | 40 #download frogs db |
82 HVL_sources(args.resource) | 83 HVL_sources(args.resource) |
83 elif args.database=="phiX_db_data": | 84 elif args.database=="phiX_db_data": |
84 phiX_sources(args.resource) | 85 phiX_sources(args.resource) |
85 | 86 |
86 #save info to json file | 87 #save info to json file |
87 filename = args.output | |
88 open(filename, 'wb').write(to_json_string(data_manager_dict)) | 88 open(filename, 'wb').write(to_json_string(data_manager_dict)) |
89 | 89 |
90 if __name__ == "__main__": | 90 if __name__ == "__main__": |
91 main() | 91 main() |