comparison data_manager/resource_building.py @ 34:0c0586ac3e29 draft

planemo upload commit c89c5deac442c0c2aa52b24f2c5af4b290773fc0-dirty
author dchristiany
date Mon, 28 Jan 2019 09:21:28 -0500
parents cdeffb3670c3
children b312ea6438a2
comparison
equal deleted inserted replaced
33:cdeffb3670c3 34:0c0586ac3e29
61 ####################################################################################################### 61 #######################################################################################################
62 def peptide_atlas_sources(data_manager_dict, tissue, target_directory): 62 def peptide_atlas_sources(data_manager_dict, tissue, target_directory):
63 # Define organism_id (here Human) - to be upraded when other organism added to the project 63 # Define organism_id (here Human) - to be upraded when other organism added to the project
64 organism_id = "2" 64 organism_id = "2"
65 # Extract sample_category_id and output filename 65 # Extract sample_category_id and output filename
66 tissue=tissue.split("-") 66 tissue=tissue.split(".")
67 sample_category_id = tissue[0] 67 sample_category_id = tissue[0]
68 name = tissue[1] 68 tissue_name = tissue[1]
69 output_file = name+"_"+time.strftime("%d-%m-%Y") + ".tsv" 69 output_file = tissue_name+"_"+time.strftime("%d-%m-%Y") + ".tsv"
70 70
71 query="https://db.systemsbiology.net/sbeams/cgi/PeptideAtlas/GetProteins?&atlas_build_id="+ \ 71 query="https://db.systemsbiology.net/sbeams/cgi/PeptideAtlas/GetProteins?&atlas_build_id="+ \
72 sample_category_id+"&display_options=ShowAbundances&organism_id="+organism_id+ \ 72 sample_category_id+"&display_options=ShowAbundances&organism_id="+organism_id+ \
73 "&redundancy_constraint=4&presence_level_constraint=1%2C2&gene_annotation_level_constraint=leaf\ 73 "&redundancy_constraint=4&presence_level_constraint=1%2C2&gene_annotation_level_constraint=leaf\
74 &QUERY_NAME=AT_GetProteins&action=QUERY&output_mode=tsv&apply_action=QUERY" 74 &QUERY_NAME=AT_GetProteins&action=QUERY&output_mode=tsv&apply_action=QUERY"
82 82
83 uni_dict = build_dictionary(cr) 83 uni_dict = build_dictionary(cr)
84 84
85 #columns of data table peptide_atlas 85 #columns of data table peptide_atlas
86 date = time.strftime("%d-%m-%Y") 86 date = time.strftime("%d-%m-%Y")
87 tissue_id = name+"_"+date 87 tissue_id = tissue_name+"_"+date
88 tissue_name = tissue_id.replace("-","/").replace("_"," ") 88 name = tissue_id.replace("-","/").replace("_"," ")
89 path = os.path.join(output_file) 89 path = os.path.join(output_file)
90 90
91 with open(path,"w") as out : 91 with open(path,"w") as out :
92 w = csv.writer(out,delimiter='\t') 92 w = csv.writer(out,delimiter='\t')
93 w.writerow(["Uniprot_AC","nb_obs"]) 93 w.writerow(["Uniprot_AC","nb_obs"])
94 w.writerows(uni_dict.items()) 94 w.writerows(uni_dict.items())
95 95
96 data_table_entry = dict(id=tissue_id, name=tissue_name, value = path, tissue = tissue) 96 data_table_entry = dict(id=tissue_id, name=name, value = path, tissue = tissue_name)
97 _add_data_table_entry(data_manager_dict, data_table_entry, "proteore_peptide_atlas") 97 _add_data_table_entry(data_manager_dict, data_table_entry, "proteore_peptide_atlas")
98 98
99 #function to count the number of observations by uniprot id 99 #function to count the number of observations by uniprot id
100 def build_dictionary (csv) : 100 def build_dictionary (csv) :
101 uni_dict = {} 101 uni_dict = {}