def safe_bed_file(infile):
 fix_pat = re.compile('^(track|browser)')
 (fd, fname) = tempfile.mkstemp()
 in_handle = open(infile)
 out_handle = open(fname, 'w')
 for line in in_handle:
  if fix_pat.match(line):
   line = ('#' + line)
  out_handle.write(line)
 in_handle.close()
 out_handle.close()
 return fname

def safe_bed_file ( infile ) : fix_pat = re . compile ( '^(track|browser)' ) ( fd , fname ) = tempfile . mkstemp ( ) in_handle = open ( infile ) out_handle = open ( fname , 'w' ) for line in in_handle : if fix_pat . match ( line ) : line = ( '#' + line ) out_handle . write ( line ) in_handle . close ( ) out_handle . close ( ) return fname
make a bed file with track and browser lines ready for liftover .