comparison CRAPomeQuery.py @ 14:b451afff1aad draft

Uploaded
author bornea
date Mon, 25 Apr 2016 11:40:37 -0400
parents eb51efc01e35
children 0c0abdfad3b7
comparison
equal deleted inserted replaced
13:eb51efc01e35 14:b451afff1aad
121 unique+=1 121 unique+=1
122 j[2] = i[0] # change to user input 122 j[2] = i[0] # change to user input
123 filt.append(j) 123 filt.append(j)
124 flag +=1 124 flag +=1
125 if flag == 0: # if protein is not present in CRAPome database then add it 125 if flag == 0: # if protein is not present in CRAPome database then add it
126 filt.append(["\t", "\t", i[0], "Invalid identifier / gene not available","\t","\t","\t"]) 126 filt.append(["\t", "\t", i[0], "Invalid identifier / gene not available"])
127 total = 0 # Experiment counter 127 total = 0 # Experiment counter
128 query = [] 128 query = []
129 for i in filt: # Create CRAPome file as list 129 for i in filt: # Create CRAPome file as list
130 temp=[] 130 temp=[]
131 if len(i) > 5: 131 if len(i) > 5:
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 print j
139 if j != '0': 138 if j != '0':
140 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
141 cnt+=1 140 cnt+=1
142 temp.append(str(cnt) + " / "+str(total)) # format ratio 141 temp.append(str(cnt) + " / "+str(total)) # format ratio
143 if ave != []: 142 if ave != []:
147 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
148 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
149 else: 148 else:
150 temp.append(i[2]) # append accession 149 temp.append(i[2]) # append accession
151 temp.append(i[3]) 150 temp.append(i[3])
151 temp.append("\t")
152 temp.append("\t")
153 temp.append("\t")
152 query.append(temp) # final query results 154 query.append(temp) # final query results
153 155
154 header = ["User Input","Mapped Gene Symbol","Num of Expt. (found/total)","Ave SC","Max SC"] 156 header = ["User Input","Mapped Gene Symbol","Num of Expt. (found/total)","Ave SC","Max SC"]
155 with open("Crappy Data.txt","wt") as x: # write file 157 with open("Crappy Data.txt","wt") as x: # write file
156 x.write("\t".join(header) + "\n") 158 x.write("\t".join(header) + "\n")