35c0685ff195fd0332ba86828c6230a34eaaaacb
mmaddren
  Thu Apr 19 16:44:47 2012 -0700
added track viewing tools for GEO so that venkat can use it
diff --git python/lib/ucscgenomics/track.py python/lib/ucscgenomics/track.py
index bc45749..d4ca776 100644
--- python/lib/ucscgenomics/track.py
+++ python/lib/ucscgenomics/track.py
@@ -67,40 +67,56 @@
     
 class Release(object):
     '''
     Keeps track of a single release, stored within the track.
     '''
     
     @property
     def index(self):
         '''Which release, represented as an int starting with 1'''
         return self._index
         
     # @property
     # def status(self):
         # '''A string representing the status of this release: alpha, beta, or public'''
         # return self._status
+    @property
+    def onAlpha(self):
+        return self._alpha
+    
+    @property
+    def onBeta(self):
+        return self._beta
+        
+    @property
+    def onPublic(self):
+        return self._public
     
     @property
     def files(self):
-        '''A dictionary of TrackFiles where the filename is the key'''
+        '''A dictionary of TrackFiles belonging to this release where the filename is the key'''
         return self._files
     
     def __init__(self, index, status, files):
         self._files = files
         self._index = index
-        self._status = status.split()
+        if (status.strip() == ''):
+            self._alpha = self._beta = self._public = 1
+        else:
+            self._alpha = 'alpha' in status.split(',')
+            self._beta = 'beta' in status.split(',')
+            self._public = 'public' in status.split(',')
     
 class CompositeTrack(object):
     '''
     Stores an entire track, consisting mainly of its metadata and files.
     
     To make a CompositeTrack, you must specify database and name of the track:
         sometrack = CompositeTrack('hg19', 'wgEncodeCshlLongRnaSeq')
         
     You can also specify a trackDb path in the event that yours is different
     from the default, '~/kent/src/hg/makeDb/trackDb/':
         sometrack = CompositeTrack('hg19', 'wgEncode...', '/weird/path')
         
     It's important to know that the CompositeTrack does NOT load all of its
     information up front. Therefore, there's no performance hit for using a
     CompositeTrack instead of just specifying a RaFile. In fact, it's
@@ -194,76 +210,79 @@
         if os.path.exists(qaDir) and os.path.isdir(qaDir):
             pass
         else:
             os.makedirs(qaDir)
         self._qaDir = qaDir
         return qaDir
 
     @property
     def releaseObjects(self):
         '''A set of release objects describing each release'''
         
         try:
             return self._releaseObjects
         except AttributeError:
             self._releaseObjects = list()
-            count = 1
             
             omit = ['README.txt', 'md5sum.txt', 'md5sum.history', 'files.txt']
             
             maxcomposite = 0
             statuses = dict()
-            for line in open(self._trackDbDir):
+            for line in open(self._trackDbDir + 'trackDb.wgEncode.ra'):
+                if line.startswith('#') or line.strip() == '':
+                    continue
                 parts = line.split()
                 composite = parts[1]
                 places = ''
                 if len(parts) > 2:
                     places = parts[2]
                 if composite.startswith(self.name):
                     compositeparts = composite.split('.')
                     if len(compositeparts) >= 2 and compositeparts[1].startswith('release'):
                         index = int(compositeparts[1].replace('release', ''))
                         statuses[index] = places
                         maxcomposite = max(maxcomposite, index)
                     else:                       # THINK MORE ABOUT THIS REGION RE: PATCHES
                         statuses[1] = places
                         maxcomposite = max(maxcomposite, 1)
             
             lastplace = statuses[maxcomposite]
             for i in range(maxcomposite, 0, -1):
                 if i not in statuses:
                     statuses[i] = lastplace
                 else:
                     lastplace = statuses[i]
                     
-            while(1):
-                releasepath = self.downloadsDirectory + ('release%d' % count) + '/'
+            # while(1):
+                # releasepath = self.downloadsDirectory + ('release%d' % count) + '/'
                 
-                if not os.path.exists(releasepath):
-                    break
+                # if not os.path.exists(releasepath):
+                    # break
                     
-                md5s = encode.readMd5sums(releasepath + 'md5sum.txt')
-                releasefiles = dict()
+                # md5s = encode.readMd5sums(releasepath + 'md5sum.txt')
+                # releasefiles = dict()
                 
-                for file in os.listdir(releasepath):
-                    if os.path.isfile(releasepath + file) and file not in omit:
-                        if md5s != None and file in md5s:
-                            releasefiles[file] = TrackFile(releasepath + file, md5s[file])
-                        else:
-                            releasefiles[file] = TrackFile(releasepath + file, None)
+                # for file in os.listdir(releasepath):
+                    # if os.path.isfile(releasepath + file) and file not in omit:
+                        # if md5s != None and file in md5s:
+                            # releasefiles[file] = TrackFile(releasepath + file, md5s[file])
+                        # else:
+                            # releasefiles[file] = TrackFile(releasepath + file, None)
+            for i in range(1, maxcomposite + 1):    
+                self._releaseObjects.append(Release(i, statuses[i], None))
                 
-                self._releaseObjects.append(Release(count, statuses[count], releasefiles))
+            return self._releaseObjects
     @property 
     def releases(self):
         '''A list of all files in the release directory of this composite'''
         try:
             return self._releaseFiles
         except AttributeError:
             self._releaseFiles = list()
             count = 1
             
             while os.path.exists(self.downloadsDirectory + 'release' + str(count)):
                 releasepath = self.downloadsDirectory + 'release' + str(count) + '/'
                 md5s = encode.readMd5sums(releasepath + 'md5sum.txt')
                 releasefiles = dict()
                 
                 for file in os.listdir(releasepath):