63f3d24bed00019a85b9afb305fcc4d0d3e9b898
mmaddren
  Fri Oct 14 11:50:35 2011 -0700
added additional filtering support for ra files, and a readme in track.py
diff --git python/lib/ucscgenomics/ra.py python/lib/ucscgenomics/ra.py
index 1bcb7c9..6b049cd 100644
--- python/lib/ucscgenomics/ra.py
+++ python/lib/ucscgenomics/ra.py
@@ -171,30 +171,49 @@
 		select: the data to return. Takes in stanza, should return whatever to be added to the list for that stanza.
 		
 		For each stanza, if where(stanza) holds, it will add select(stanza) to the list of returned entities.
 		Also forces silent failure of key errors, so you don't have to check that a value is or is not in the stanza.
 		"""
 		
 		ret = list()
 		for stanza in self.itervalues():
 			try:
 				if where(stanza):
 					ret.append(select(stanza))
 			except KeyError:
 				continue
 		return ret
 				
+	def filter2(self, where):
+                """
+                select useful data from matching criteria
+
+                where: the conditional function that must be met. Where takes one argument, the stanza and should return true or false
+                select: the data to return. Takes in stanza, should return whatever to be added to the list for that stanza.
+
+                For each stanza, if where(stanza) holds, it will add select(stanza) to the list of returned entities.
+                Also forces silent failure of key errors, so you don't have to check that a value is or is not in the stanza.
+                """
+
+                ret = RaFile()
+                for stanza in self.itervalues():
+                        try:
+                                if where(stanza):
+                                        ret[stanza.name] = stanza
+                        except KeyError:
+                                continue
+                return ret			
 				
 	def __str__(self):
 		str = ''
 		for item in self.iteritems():
 			if len(item) == 1:
 				str += item[0].__str__() + '\n'
 			else:
 				str += item[1].__str__() + '\n'
 		return str
 
 
 class RaStanza(OrderedDict):
 	"""
 	Holds an individual entry in the RaFile.
 	"""