Mercurial > repos > bornea > saint_protein_interactions
comparison ProteinInteractions.py @ 9:dd0b4c901d0a draft
Uploaded
author | bornea |
---|---|
date | Wed, 23 Mar 2016 11:15:44 -0400 |
parents | 355ad1ce474b |
children |
comparison
equal
deleted
inserted
replaced
8:355ad1ce474b | 9:dd0b4c901d0a |
---|---|
79 return ReturnValue2(data, proteins, header) | 79 return ReturnValue2(data, proteins, header) |
80 | 80 |
81 | 81 |
82 def get_info(uniprot_accession_in): | 82 def get_info(uniprot_accession_in): |
83 # Get aa lengths and gene name. | 83 # Get aa lengths and gene name. |
84 print uniprot_accession_in | |
84 error = open('error proteins.txt', 'a+') | 85 error = open('error proteins.txt', 'a+') |
85 i = 0 | 86 i = 0 |
86 while i == 0: | 87 while i == 0: |
87 try: | 88 try: |
88 data = urllib2.urlopen("http://www.uniprot.org/uniprot/" + uniprot_accession_in | 89 data = urllib2.urlopen("http://www.uniprot.org/uniprot/" + uniprot_accession_in |
131 def dd_network(listfile, SAINTscore, CPDB_filter): | 132 def dd_network(listfile, SAINTscore, CPDB_filter): |
132 # Filter by SS and CPDB. | 133 # Filter by SS and CPDB. |
133 data = read_listfile(listfile).data | 134 data = read_listfile(listfile).data |
134 # Change to filtered list. | 135 # Change to filtered list. |
135 SS = (read_listfile(listfile).header).index("SaintScore") | 136 SS = (read_listfile(listfile).header).index("SaintScore") |
137 uni_ids = (read_listfile(listfile).header).index("PreyGene") - 1 | |
136 filt_data = [] | 138 filt_data = [] |
137 for i in data: | 139 for i in data: |
138 if i[SS] >= SAINTscore: | 140 if i[SS] >= SAINTscore: |
139 filt_data.append(i) | 141 filt_data.append(i) |
140 accessions = [] | 142 accessions = [] |
141 for i in filt_data: | 143 for i in filt_data: |
142 accessions.append(get_info(i[1]).sp) | 144 accessions.append(get_info(i[uni_ids]).sp) |
143 GO = [] | 145 GO = [] |
144 for i in CPDB[2:]: | 146 for i in CPDB[2:]: |
145 if i[3] >= CPDB_filter: | 147 if i[3] >= CPDB_filter: |
146 # Filter interaction confidence. | 148 # Filter interaction confidence. |
147 GO.append(i[2]) | 149 GO.append(i[2]) |
178 | 180 |
179 def cytoscape(dd_network, listfile, SAINTscore): | 181 def cytoscape(dd_network, listfile, SAINTscore): |
180 with open('network.sif', 'wt') as y: | 182 with open('network.sif', 'wt') as y: |
181 data = read_listfile(listfile).data | 183 data = read_listfile(listfile).data |
182 SS = (read_listfile(listfile).header).index("SaintScore") | 184 SS = (read_listfile(listfile).header).index("SaintScore") |
185 uni_ids = (read_listfile(listfile).header).index("PreyGene") - 1 | |
183 filt_data = [] | 186 filt_data = [] |
184 for i in data: | 187 for i in data: |
185 if i[SS] >= SAINTscore: | 188 if i[SS] >= SAINTscore: |
186 filt_data.append(get_info(i[1]).sp) | 189 filt_data.append(get_info(i[uni_ids]).sp) |
187 for i in filt_data: | 190 for i in filt_data: |
188 if dd_network[i] != []: | 191 if dd_network[i] != []: |
189 lst = [] | 192 lst = [] |
190 for j in dd_network[i]: | 193 for j in dd_network[i]: |
191 lst.append(j) | 194 lst.append(j) |