def sam_list_paired(sam):
list = []<EOL>pair = ['<STR_LIT:1>', '<STR_LIT:2>']<EOL>prev = '<STR_LIT>'<EOL>for file in sam:<EOL><INDENT>for line in file:<EOL><INDENT>if line.startswith('<STR_LIT:@>') is False:<EOL><INDENT>line = line.strip().split()<EOL>id, map = line[<NUM_LIT:0>], int(line[<NUM_LIT:1>])<EOL>if map != <NUM_LIT:4> and map != <NUM_LIT:8>:<EOL><INDENT>read = id.rsplit('<STR_LIT:/>')[<NUM_LIT:0>]<EOL>if read == prev:<EOL><INDENT>list.append(read)<EOL><DEDENT>prev = read<EOL><DEDENT><DEDENT><DEDENT><DEDENT>return set(list)<EOL>
get a list of mapped reads
require that both pairs are mapped in the sam file in order to remove the reads