Mercurial > repos > dchristiany > data_manager_proteore
comparison data_manager/resource_building.py @ 12:60cb0a5ae661 draft
planemo upload commit e5e768b479ddc6b36270a1b5b0443a4c80d693bc-dirty
author | dchristiany |
---|---|
date | Tue, 23 Oct 2018 08:18:32 -0400 |
parents | 2f153b41b6fe |
children | a1530507fee4 |
comparison
equal
deleted
inserted
replaced
11:4bb219eee10f | 12:60cb0a5ae661 |
---|---|
50 unzip(url, path) #download and save file | 50 unzip(url, path) #download and save file |
51 tissue_name = tissue_name + " " + time.strftime("%d/%m/%Y") | 51 tissue_name = tissue_name + " " + time.strftime("%d/%m/%Y") |
52 tissue_id = tissue_name.replace(" ","_").replace("/","-") | 52 tissue_id = tissue_name.replace(" ","_").replace("/","-") |
53 | 53 |
54 data_table_entry = dict(id=tissue_id, name = tissue_name, value = tissue, path = path) | 54 data_table_entry = dict(id=tissue_id, name = tissue_name, value = tissue, path = path) |
55 _add_data_table_entry(data_manager_dict, data_table_entry, "protein_atlas") | 55 _add_data_table_entry(data_manager_dict, data_table_entry, "proteore_protein_atlas") |
56 | 56 |
57 | 57 |
58 ####################################################################################################### | 58 ####################################################################################################### |
59 # 2. Peptide Atlas | 59 # 2. Peptide Atlas |
60 ####################################################################################################### | 60 ####################################################################################################### |
88 w = csv.writer(out,delimiter='\t') | 88 w = csv.writer(out,delimiter='\t') |
89 w.writerow(["Uniprot_AC","nb_obs"]) | 89 w.writerow(["Uniprot_AC","nb_obs"]) |
90 w.writerows(uni_dict.items()) | 90 w.writerows(uni_dict.items()) |
91 | 91 |
92 data_table_entry = dict(id=tissue_id, name=tissue_name, value = path, tissue = tissue) | 92 data_table_entry = dict(id=tissue_id, name=tissue_name, value = path, tissue = tissue) |
93 _add_data_table_entry(data_manager_dict, data_table_entry, "peptide_atlas") | 93 _add_data_table_entry(data_manager_dict, data_table_entry, "proteore_peptide_atlas") |
94 | 94 |
95 #function to count the number of observations by uniprot id | 95 #function to count the number of observations by uniprot id |
96 def build_dictionary (csv) : | 96 def build_dictionary (csv) : |
97 uni_dict = {} | 97 uni_dict = {} |
98 for line in csv : | 98 for line in csv : |
219 name_dict={"human" : "Homo sapiens", "mouse" : "Mus musculus", "rat" : "Rattus norvegicus"} | 219 name_dict={"human" : "Homo sapiens", "mouse" : "Mus musculus", "rat" : "Rattus norvegicus"} |
220 name = name_dict[species]+" "+time.strftime("%d/%m/%Y") | 220 name = name_dict[species]+" "+time.strftime("%d/%m/%Y") |
221 id = species+"_id_mapping_"+ time.strftime("%d-%m-%Y") | 221 id = species+"_id_mapping_"+ time.strftime("%d-%m-%Y") |
222 | 222 |
223 data_table_entry = dict(id=id, name = name, value = species, path = path) | 223 data_table_entry = dict(id=id, name = name, value = species, path = path) |
224 _add_data_table_entry(data_manager_dict, data_table_entry, "id_mapping") | 224 _add_data_table_entry(data_manager_dict, data_table_entry, "proteore_id_mapping") |
225 | 225 |
226 def download_from_uniprot_ftp(file,target_directory) : | 226 def download_from_uniprot_ftp(file,target_directory) : |
227 ftp_dir = "pub/databases/uniprot/current_release/knowledgebase/idmapping/by_organism/" | 227 ftp_dir = "pub/databases/uniprot/current_release/knowledgebase/idmapping/by_organism/" |
228 path = os.path.join(target_directory, file) | 228 path = os.path.join(target_directory, file) |
229 ftp = ftplib.FTP("ftp.uniprot.org") | 229 ftp = ftplib.FTP("ftp.uniprot.org") |