comparison data_manager/resource_building.py @ 41:fe21769281fa draft

"planemo upload commit ba867b8fa3352695fbda1ae764407f363ee79a50-dirty"
author proteore
date Wed, 08 Jan 2020 13:44:22 +0000
parents a7bcc9a0a456
children f6a6a70712c4
comparison
equal deleted inserted replaced
40:a7bcc9a0a456 41:fe21769281fa
148 tab_path = download_from_uniprot_ftp(selected_tab_file,target_directory) 148 tab_path = download_from_uniprot_ftp(selected_tab_file,target_directory)
149 with gzip.open(tab_path,"rt") as select : 149 with gzip.open(tab_path,"rt") as select :
150 tab_reader = csv.reader(select,delimiter="\t") 150 tab_reader = csv.reader(select,delimiter="\t")
151 for line in tab_reader : 151 for line in tab_reader :
152 tab.append([line[0]]+[line[i] for i in [0,1,2,3,4,5,6,11,13,14,18,19,20]]) 152 tab.append([line[0]]+[line[i] for i in [0,1,2,3,4,5,6,11,13,14,18,19,20]])
153 if os.path.exists(os.path.join(archive,tab_path[-1])) : os.remove(os.path.join(archive,tab_path[-1])) 153 if os.path.exists(os.path.join(archive,tab_path.split("/")[-1])) : os.remove(os.path.join(archive,tab_path.split("/")[-1]))
154 shutil.move(tab_path, archive) 154 shutil.move(tab_path, archive)
155 #print("selected_tab ok") 155 #print("selected_tab ok")
156 156
157 #get uniprot-AC reviewed 157 #get uniprot-AC reviewed
158 organism = species_dict[species].split("_")[1] 158 organism = species_dict[species].split("_")[1]
200 unidict[uniprotID][id_type]= ";".join([unidict[uniprotID][id_type],cor_id]) #if there is already a value in the dictionnary 200 unidict[uniprotID][id_type]= ";".join([unidict[uniprotID][id_type],cor_id]) #if there is already a value in the dictionnary
201 else : 201 else :
202 unidict[uniprotID].update({ id_type : cor_id }) 202 unidict[uniprotID].update({ id_type : cor_id })
203 elif id_type in ids : 203 elif id_type in ids :
204 unidict[uniprotID]={id_type : cor_id} 204 unidict[uniprotID]={id_type : cor_id}
205 if os.path.exists(os.path.join(archive,dat_path[-1])) : os.remove(os.path.join(archive,dat_path[-1])) 205 if os.path.exists(os.path.join(archive,dat_path.split("/")[-1])) : os.remove(os.path.join(archive,dat_path.split("/")[-1]))
206 shutil.move(dat_path, archive) 206 shutil.move(dat_path, archive)
207 207
208 #print("dat_file ok") 208 #print("dat_file ok")
209 209
210 #add ids from idmapping.dat to the final tab 210 #add ids from idmapping.dat to the final tab
231 if human : 231 if human :
232 #build next_dict 232 #build next_dict
233 nextprot_path = id_list_from_nextprot_ftp("nextprot_ac_list_all.txt",target_directory) 233 nextprot_path = id_list_from_nextprot_ftp("nextprot_ac_list_all.txt",target_directory)
234 with open(nextprot_path,'r') as nextprot_ids : 234 with open(nextprot_path,'r') as nextprot_ids :
235 nextprot_ids = nextprot_ids.read().splitlines() 235 nextprot_ids = nextprot_ids.read().splitlines()
236 if os.path.exists(os.path.join(archive,nextprot_path[-1])) : os.remove(os.path.join(archive,nextprot_path[-1])) 236 if os.path.exists(os.path.join(archive,nextprot_path.split("/")[-1])) : os.remove(os.path.join(archive,nextprot_path.split("/")[-1]))
237 shutil.move(nextprot_path,archive) 237 shutil.move(nextprot_path,archive)
238 next_dict = {} 238 next_dict = {}
239 for nextid in nextprot_ids : 239 for nextid in nextprot_ids :
240 next_dict[nextid.replace("NX_","")] = nextid 240 next_dict[nextid.replace("NX_","")] = nextid
241 os.remove(os.path.join(target_directory,"nextprot_ac_list_all.txt")) 241 os.remove(os.path.join(target_directory,"nextprot_ac_list_all.txt"))