# HG changeset patch # User dchristiany # Date 1548681267 18000 # Node ID b8271b9a10498efe98b3e6d67eef994a2f0239cb # Parent 871a7347ca24baecb4a42558796aea7edf612878 planemo upload commit c89c5deac442c0c2aa52b24f2c5af4b290773fc0-dirty diff -r 871a7347ca24 -r b8271b9a1049 data_manager/resource_building.py --- a/data_manager/resource_building.py Mon Jan 28 05:16:55 2019 -0500 +++ b/data_manager/resource_building.py Mon Jan 28 08:14:27 2019 -0500 @@ -67,24 +67,29 @@ sample_category_id = tissue[0] name = tissue[1] output_file = name+"_"+time.strftime("%d-%m-%Y") + ".tsv" - query="https://db.systemsbiology.net/sbeams/cgi/PeptideAtlas/GetProteins?&atlas_build_id="+sample_category_id+ \ - "&display_options=ShowAbundances&organism_id="+organism_id+"&redundancy_constraint=4&presence_level_constraint=1%2C2"+ \ - "&gene_annotation_level_constraint=leaf&QUERY_NAME=AT_GetProteins&action=QUERY&output_mode=tsv&apply_action=QUERY" - download = requests.get(query) - decoded_content = download.content.decode('utf-8') - cr = csv.reader(decoded_content.splitlines(), delimiter='\t') + + query="https://db.systemsbiology.net/sbeams/cgi/PeptideAtlas/GetProteins?&atlas_build_id="+ \ + sample_category_id+"&display_options=ShowAbundances&organism_id="+organism_id+ \ + "&redundancy_constraint=4&presence_level_constraint=1%2C2&gene_annotation_level_constraint=leaf\ + &QUERY_NAME=AT_GetProteins&action=QUERY&output_mode=tsv&apply_action=QUERY" - #build dictionary by only keeping uniprot accession (not isoform) as key and sum of observations as value + print (query) + + with requests.Session() as s: + download = s.get(query) + decoded_content = download.content.decode('utf-8') + cr = csv.reader(decoded_content.splitlines(), delimiter='\t') + #cr = list(cr) + uni_dict = build_dictionary(cr) #columns of data table peptide_atlas date = time.strftime("%d-%m-%Y") - tissue = tissue.split("-")[1] - tissue_id = tissue+"_"+date + tissue_id = name+"_"+date tissue_name = tissue_id.replace("-","/").replace("_"," ") - path = os.path.join(target_directory,output_file) + path = os.path.join(output_file) - with open(path,"wb") as out : + with open(path,"w") as out : w = csv.writer(out,delimiter='\t') w.writerow(["Uniprot_AC","nb_obs"]) w.writerows(uni_dict.items()) @@ -96,11 +101,11 @@ def build_dictionary (csv) : uni_dict = {} for line in csv : - if "-" not in line[2] and check_uniprot_access(line[2]) : - if line[2] in uni_dict : - uni_dict[line[2]] += int(line[4]) + if "-" not in line[0] and check_uniprot_access(line[0]) : + if line[0] in uni_dict : + uni_dict[line[0]] += int(line[5]) else : - uni_dict[line[2]] = int(line[4]) + uni_dict[line[0]] = int(line[5]) return uni_dict @@ -112,8 +117,6 @@ else : return False - - ####################################################################################################### # 3. ID mapping file ####################################################################################################### diff -r 871a7347ca24 -r b8271b9a1049 data_manager/resource_building.xml --- a/data_manager/resource_building.xml Mon Jan 28 05:16:55 2019 -0500 +++ b/data_manager/resource_building.xml Mon Jan 28 08:14:27 2019 -0500 @@ -1,4 +1,4 @@ - + to create or update reference files for proteore tools