@@ -17,9 +17,7 @@ def __init__(self,data_folder,trackData):
17
17
self .__featureNCList = trackData ['featureNCList' ]
18
18
self .__sublistIndex = trackData ['sublistIndex' ]
19
19
self .__lazyIndex = trackData ['lazyIndex' ]
20
- self .__subFeatureArray = trackData ['subfeatureArray' ]
21
20
self .__lazyFeatureFile = self .__data_folder + '/' + re .sub ('{chunk}' ,'%s' ,trackData ['lazyfeatureUrlTemplate' ])
22
- self .__subFeatureFile = self .__data_folder + '/' + self .__subFeatureArray ['urlTemplate' ].replace ('{chunk}' ,'%s' )
23
21
24
22
def getGenes (self ,start ,end ,getFeatures = True ):
25
23
genes = []
@@ -45,38 +43,13 @@ def _getGenesFromNCList(self,nclist,start,end,getFeatures = True,genes = []):
45
43
46
44
def _getGeneFeaturesForGene (self ,gene ,getFeatures = True ):
47
45
stripped_gene = gene [0 :4 ]
48
- stripped_gene . append ([])
49
- if gene [ 4 ] != None and getFeatures :
50
- for subFeature in gene [ 4 ] :
51
- stripped_gene [ 4 ] .append (self . _getGeneFeaturesFromPos ( subFeature , subFeature ) )
46
+ if gene [ self . __sublistIndex - 1 ] != None and getFeatures :
47
+ stripped_gene . append ( gene [ self . __sublistIndex - 1 ])
48
+ else :
49
+ stripped_gene .append ([] )
52
50
return stripped_gene
53
51
54
- def _getGeneFeaturesFromPos (self ,start ,end ):
55
- import math
56
- features = []
57
- start = max ([0 ,start ])
58
- end = min ([end ,self .__subFeatureArray ['length' ]])
59
- firstChunk = int (math .floor (start / self .__subFeatureArray ['chunkSize' ]))
60
- lastChunk = int (math .floor (end / self .__subFeatureArray ['chunkSize' ]))
61
-
62
- for chunk in range (firstChunk ,lastChunk + 1 ):
63
- if not chunk in self .__lazyArrayChunks :
64
- fp = open (self .__subFeatureFile % chunk )
65
- lazyFeatures = simplejson .load (fp )
66
- fp .close ()
67
- self .__lazyArrayChunks [chunk ] = lazyFeatures
68
- features += self ._getGeneFeaturesFromChunk (chunk ,start ,end )
69
- return features
70
-
71
- def _getGeneFeaturesFromChunk (self ,chunk ,start ,end ):
72
- features = []
73
- chunkSize = self .__subFeatureArray ['chunkSize' ]
74
- firstIndex = chunk * chunkSize
75
- chunkStart = max ([start - firstIndex ,0 ])
76
- chunkEnd = min ([end - firstIndex ,chunkSize - 1 ])
77
- for i in range (chunkStart ,chunkEnd + 1 ):
78
- features += self .__lazyArrayChunks [chunk ][i ]
79
- return features
52
+
80
53
81
54
@classmethod
82
55
def _binary_search (cls ,arr , item , low = - 1 , high = None ,index = 1 ):
@@ -118,10 +91,11 @@ def getGenes(self,chromosome,start,end,getFeatures=True):
118
91
119
92
120
93
def __initChromocomeSources (self ,fname ):
121
- fp = open (self .__getChromosomeTrackFolder (fname )+ 'trackData.json' )
94
+ track_folder = self .__getChromosomeTrackFolder (fname )
95
+ fp = open (track_folder + 'trackData.json' )
122
96
trackData = simplejson .load (fp )
123
97
fp .close ()
124
- self .__chromosomeSources [fname ] = ChromosomeData (self . __jbrowse_tracks_folder ,trackData )
98
+ self .__chromosomeSources [fname ] = ChromosomeData (track_folder ,trackData )
125
99
126
100
def __getChromosomeTrackFolder (self ,chromosome ):
127
101
return self .__jbrowse_tracks_folder + '/data/tracks/%s/%s/' % (chromosome ,self .__track_key )
0 commit comments