def get_rna_counts(rna_file, transcript_name):
<EOL>if not os.path.exists(rna_file):<EOL><INDENT>msg = '<STR_LIT>'.format(rna_file)<EOL>logging.error(msg)<EOL>raise OSError(msg)<EOL><DEDENT>rna_counts = {}<EOL>cov_file = tempfile.NamedTemporaryFile(delete=False)<EOL>try:<EOL><INDENT>subprocess.check_call(<EOL>['<STR_LIT>', '<STR_LIT>', '<STR_LIT>', rna_file,<EOL>'<STR_LIT>'], stdout=cov_file)<EOL><DEDENT>except subprocess.CalledProcessError as e:<EOL><INDENT>raise ribocore.RNACountsError('<STR_LIT>'.format(e))<EOL><DEDENT>for line in open(cov_file.name):<EOL><INDENT>line = line.split()<EOL>if line[<NUM_LIT:0>] == transcript_name:<EOL><INDENT>position, count = int(line[<NUM_LIT:1>]) + <NUM_LIT:1>, int(line[<NUM_LIT:3>])<EOL>rna_counts[position] = count<EOL><DEDENT><DEDENT>cov_file.close()<EOL>os.unlink(cov_file.name)<EOL>return rna_counts<EOL>
Get coverage for a given RNA BAM file, return read counts.