Mercurial > repos > bornea > query_crapome
comparison CRAPomeQuery.py @ 16:a5444c834e72 draft
Uploaded
author | bornea |
---|---|
date | Fri, 29 Apr 2016 15:42:11 -0400 |
parents | 0c0abdfad3b7 |
children | 378fc3676c78 |
comparison
equal
deleted
inserted
replaced
15:0c0abdfad3b7 | 16:a5444c834e72 |
---|---|
2 """ | 2 """ |
3 Created on Thu Apr 14 16:58:05 2016 | 3 Created on Thu Apr 14 16:58:05 2016 |
4 | 4 |
5 @author: brentkuenzi | 5 @author: brentkuenzi |
6 """ | 6 """ |
7 ################################################################################ | |
8 ## Dependencies ## | |
9 import urllib2 | |
10 import sys | |
11 import numpy | |
12 import os | |
13 ################################################################################ | 7 ################################################################################ |
14 # This program will read in a SAINT formatted 'prey.txt' file or a file | 8 # This program will read in a SAINT formatted 'prey.txt' file or a file |
15 # containing a single column list of uniprot accessions (e.g. "P00533" or | 9 # containing a single column list of uniprot accessions (e.g. "P00533" or |
16 # "EGFR_HUMAN")query the CRAPome database (v1.1), and return a file specifying | 10 # "EGFR_HUMAN")query the CRAPome database (v1.1), and return a file specifying |
17 # the prevalence of each protein in the CRAPome. | 11 # the prevalence of each protein in the CRAPome. |
22 # or any later version published by the Free Software Foundation; | 16 # or any later version published by the Free Software Foundation; |
23 # with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. | 17 # with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. |
24 # A copy of the license is included in the section entitled "GNU | 18 # A copy of the license is included in the section entitled "GNU |
25 # Free Documentation License". | 19 # Free Documentation License". |
26 ################################################################################ | 20 ################################################################################ |
21 ## Dependencies ## | |
22 import urllib2 | |
23 import sys | |
24 import numpy | |
25 import os | |
26 ################################################################################ | |
27 ## REQUIRED INPUT ## | 27 ## REQUIRED INPUT ## |
28 # 1) crappyData: Prey.txt or single column list of Uniprot accessions | 28 # 1) crappyData: Prey.txt or single column list of Uniprot accessions |
29 crappyData = sys.argv[1] # Prey file or File with single column of accessions | 29 crappyData = sys.argv[1] # Prey file or File with single column of accessions |
30 # 2) Species: HUMAN or YEAST | 30 # 2) Species: HUMAN or YEAST |
31 species = sys.argv[2] # HUMAN or YEAST | 31 species = sys.argv[2] # HUMAN or YEAST |
32 db_path = sys.argv[4] | 32 db_path = sys.argv[4] |
33 ################################################################################ | 33 ################################################################################ |
34 ## Global Variables ## | 34 ## Global Variables ## |
35 if species == "HUMAN": | 35 if species == "HUMAN": |
36 database = str(db_path) + "Human_CRAPome_v1-1.txt" | 36 database = "Human_CRAPome_v1-1.txt" |
37 if species == "YEAST": | 37 if species == "YEAST": |
38 database = str(db_path) + "Yeast_CRAPome_v1-1.txt" | 38 database = "Yeast_CRAPome_v1-1.txt" |
39 ################################################################################ | 39 ################################################################################ |
40 ## CRAPomeQuery ## | 40 ## CRAPomeQuery ## |
41 class ReturnValue1(object): | 41 class ReturnValue1(object): |
42 def __init__(self, uniprot_acc, gene, swissprot): | 42 def __init__(self, uniprot_acc, gene, swissprot): |
43 self.up = uniprot_acc | 43 self.up = uniprot_acc |
132 cnt=0 | 132 cnt=0 |
133 temp.append(i[2]) # append accession | 133 temp.append(i[2]) # append accession |
134 temp.append(i[0]) # append gene name | 134 temp.append(i[0]) # append gene name |
135 ave = [] | 135 ave = [] |
136 total = len(i[3:]) # calculate total experiments | 136 total = len(i[3:]) # calculate total experiments |
137 for j in i[3:]: | 137 for j in i[3:]: |
138 if j != '0': | 138 if j != '0': |
139 ave.append(int(j)) # calculate Ave.SC on only experiments with ID | 139 ave.append(int(j)) # calculate Ave.SC on only experiments with ID |
140 cnt+=1 | 140 cnt+=1 |
141 temp.append(str(cnt) + " / "+str(total)) # format ratio | 141 temp.append(str(cnt) + " / "+str(total)) # format ratio |
142 if ave != []: | 142 if ave != []: |
146 temp.append(0) # add 0 if has not been ID'd in CRAPome | 146 temp.append(0) # add 0 if has not been ID'd in CRAPome |
147 temp.append(0) # add 0 if has not been ID'd in CRAPome | 147 temp.append(0) # add 0 if has not been ID'd in CRAPome |
148 else: | 148 else: |
149 temp.append(i[2]) # append accession | 149 temp.append(i[2]) # append accession |
150 temp.append(i[3]) | 150 temp.append(i[3]) |
151 temp.append("NA") | |
152 temp.append("NA") | |
153 temp.append("NA") | |
154 query.append(temp) # final query results | 151 query.append(temp) # final query results |
155 | 152 |
156 header = ["User Input","Mapped Gene Symbol","Num of Expt. (found/total)","Ave SC","Max SC"] | 153 header = ["User Input","Mapped Gene Symbol","Num of Expt. (found/total)","Ave SC","Max SC"] |
157 with open("Crappy Data.txt","wt") as x: # write file | 154 with open("Crappy Data.txt","wt") as x: # write file |
158 x.write("\t".join(header) + "\n") | 155 x.write("\t".join(header) + "\n") |