code: def parse(self, filename, gziped = False, stream = False) :
  		
  		self.stream = stream
  		
  		if gziped :
  			self.f = gzip.open(filename)
  		else :
  			self.f = open(filename)
  		
  		self.filename = filename
  		self.gziped = gziped
  		
  		lineId = 0
  		inLegend = True
  		while inLegend :
  			ll = self.f.readline()
  			l = ll.replace('\r', '\n').replace('\n', '')
  			if l[:2] == '##' :
  				eqPos = l.find('=')
  				key = l[2:eqPos]
  				values = l[eqPos+1:].strip()
  				
  				if l[eqPos+1] != '<' :
  					self.meta[key] = values
  				else :
  					if key not in self.meta :
  						self.meta[key] = {}
  					svalues = l[eqPos+2:-1].split(',') #remove the < and > that surounf the string 
  					idKey = svalues[0].split('=')[1]
  					self.meta[key][idKey] = {} 
  					i = 1
  					for v in svalues[1:] :
  						sv = v.split("=")
  						field = sv[0]
  						value = sv[1]
  						if field.lower() == 'description' :
  							self.meta[key][idKey][field] = ','.join(svalues[i:])[len(field)+2:-1]
  							break
  						self.meta[key][idKey][field] = value
  						i += 1
  			elif l[:6] == '#CHROM': #we are in legend
  				sl = l.split('\t')
  				for i in range(len(sl)) :
  					self.legend[sl[i]] = i
  					self.dnegel[i] = sl[i]
  				break
  			
  			lineId += 1
  		
  		if not stream :
  			self.lines = self.f.readlines()
  			self.f.close()
docs: opens a file