original_docstring:  Filter reads that fail score check out of a position comparison file
          Return number of reads filtered 
docstring: Filter reads that fail score check out of a position comparison file
  Return number of reads filtered
docstring_tokens: Filter reads that fail score check out of a position comparison file Return number of reads filtered
code: def _filter_position_file(self, position_file, out_file):
          """ Filter reads that fail score check out of a position comparison file
          Return number of reads filtered """
  
          # check if a read has been filtered by looking in the primary score comparison output
          reads_map = dict()
          def is_filtered(read, method):
              if method not in reads_map:
                  reads_map[method] = set()
                  try:
                      # -se not currently in filenames. ugh. 
                      name = method[0:-3] if method.endswith('-se') else method
                      score_path = os.path.join(os.path.dirname(position_file),
                                                '{}.compare.primary.scores'.format(name))
                      with io.open(score_path, 'r', encoding='utf8') as score_file:
                          for line in score_file:
                              toks = line.split(", ")
                              if int(toks[1]) < 0:
                                  reads_map[method].add(toks[0])
                  except:
                      pass
              return read in reads_map[method]
  
          # scan postions, filtering all reads in our set
          filter_count = 0
          with io.open(position_file, 'r', encoding='utf8') as pf, io.open(out_file, 'w', encoding='utf8') as of:
              for i, line in enumerate(pf):
                  toks = line.rstrip().split()
                  if i == 0:
                      ridx = toks.index('read')
                      aidx = toks.index('aligner')                
                  if i == 0 or not is_filtered(toks[ridx], toks[aidx].strip('"')):
                      of.write(line)
                  else:
                      filter_count += 1
          return filter_count
code_tokens: def _filter_position_file ( self , position_file , out_file ) : reads_map = dict ( ) def is_filtered ( read , method ) : if method not in reads_map : reads_map [ method ] = set ( ) try : name = method [ 0 : - 3 ] if method . endswith ( '-se' ) else method score_path = os . path . join ( os . path . dirname ( position_file ) , '{}.compare.primary.scores' . format ( name ) ) with io . open ( score_path , 'r' , encoding = 'utf8' ) as score_file : for line in score_file : toks = line . split ( ", " ) if int ( toks [ 1 ] ) < 0 : reads_map [ method ] . add ( toks [ 0 ] ) except : pass return read in reads_map [ method ] filter_count = 0 with io . open ( position_file , 'r' , encoding = 'utf8' ) as pf , io . open ( out_file , 'w' , encoding = 'utf8' ) as of : for i , line in enumerate ( pf ) : toks = line . rstrip ( ) . split ( ) if i == 0 : ridx = toks . index ( 'read' ) aidx = toks . index ( 'aligner' ) if i == 0 or not is_filtered ( toks [ ridx ] , toks [ aidx ] . strip ( '"' ) ) : of . write ( line ) else : filter_count += 1 return filter_count
short_docstring: Filter reads that fail score check out of a position comparison file
  Return number of reads filtered
short_docstring_tokens: Filter reads that fail score check out of a position comparison file Return number of reads filtered
comment: """ Filter reads that fail score check out of a position comparison file
          Return number of reads filtered """$SEP$# check if a read has been filtered by looking in the primary score comparison output$SEP$# -se not currently in filenames. ugh. $SEP$# scan postions, filtering all reads in our set