@@ -73,7 +73,7 @@ def mapEnhancerToGene(annotFile,enhancerFile,transcribedFile='',uniqueGenes=True
73
73
geneToEnhancerTable = [['GENE_NAME' ,'REFSEQ_ID' ,'PROXIMAL_STITCHED_PEAKS' ]]
74
74
75
75
#have all information
76
- signalWithGenes = [['GENE_NAME' , 'REFSEQ_ID' ,'PROXIMAL_STITCHED_PEAKS' , 'SIGNAL' ]]
76
+ signalWithGenes = [['GENE_NAME' , 'REFSEQ_ID' , 'PROXIMAL_STITCHED_PEAKS' , 'SIGNAL' ]]
77
77
78
78
for line in enhancerTable [6 :]:
79
79
@@ -129,14 +129,6 @@ def mapEnhancerToGene(annotFile,enhancerFile,transcribedFile='',uniqueGenes=True
129
129
130
130
#get absolute distance to enhancer center
131
131
distList = [abs (enhancerCenter - startDict [geneID ]['start' ][0 ]) for geneID in allEnhancerGenes ]
132
- #get the ID and convert to name
133
- #print enhancerCenter - startDict[geneID]['start'][0]
134
- #print distList.index(min(distList))
135
- #print min(distList)
136
- #print len(distList)
137
- #print len(allEnhancerGenes[distList.index(min(distList))])
138
- #print line
139
- #print len(startDict[allEnhancerGenes[distList.index(min(distList))]])
140
132
closestGene = startDict [allEnhancerGenes [distList .index (min (distList ))]]['name' ]
141
133
142
134
#NOW WRITE THE ROW FOR THE ENHANCER TABLE
@@ -145,9 +137,6 @@ def mapEnhancerToGene(annotFile,enhancerFile,transcribedFile='',uniqueGenes=True
145
137
if byRefseq :
146
138
newEnhancerLine .append (',' .join (ROSE_utils .uniquify ([x for x in overlappingGenes ])))
147
139
newEnhancerLine .append (',' .join (ROSE_utils .uniquify ([x for x in proximalGenes ])))
148
- #print newEnhancerLine
149
- #print len(allEnhancerGenes)
150
- #print distList
151
140
closestGene = allEnhancerGenes [distList .index (min (distList ))]
152
141
newEnhancerLine .append (closestGene )
153
142
else :
@@ -157,20 +146,21 @@ def mapEnhancerToGene(annotFile,enhancerFile,transcribedFile='',uniqueGenes=True
157
146
newEnhancerLine .append (closestGene )
158
147
159
148
149
+ #WRITE GENE TABLE
150
+ signalWithGenes .append ([startDict [closestGene ]['name' ], closestGene , enhancerString , enhancerSignal ])
151
+
160
152
newEnhancerLine += line [- 2 :]
161
153
enhancerToGeneTable .append (newEnhancerLine )
162
154
#Now grab all overlapping and proximal genes for the gene ordered table
163
155
164
156
overallGeneList += overlappingGenes
165
157
for refID in overlappingGenes :
166
158
geneDict ['overlapping' ][refID ].append (enhancerString )
167
- geneDict ['enhancerString' ][enhancerString ].append (enhancerSignal )
168
-
159
+
169
160
170
161
overallGeneList += proximalGenes
171
162
for refID in proximalGenes :
172
163
geneDict ['proximal' ][refID ].append (enhancerString )
173
- geneDict ['enhancerString' ][enhancerString ].append (enhancerSignal )
174
164
175
165
176
166
#End loop through
@@ -197,8 +187,6 @@ def mapEnhancerToGene(annotFile,enhancerFile,transcribedFile='',uniqueGenes=True
197
187
newLine = [geneName ,refID ,',' .join (proxEnhancers )]
198
188
199
189
200
- for eachEnhancer in proxEnhancers :
201
- signalWithGenes .append ([geneName ,refID ,eachEnhancer ,ROSE_utils .uniquify (geneDict ['enhancerString' ][eachEnhancer ])[0 ]])
202
190
geneToEnhancerTable .append (newLine )
203
191
204
192
#re-sort enhancerToGeneTable
0 commit comments