Skip to content
This repository has been archived by the owner on Nov 25, 2023. It is now read-only.

Commit

Permalink
Release 0.2.4
Browse files Browse the repository at this point in the history
* Bugfix: ribocount now returns correct read counts if an offset is
* provided.
* Bugfix: Don't include read counts in the longest ORF start or stop
* positions
  i.e., only include reads upstream or downstream of the start or stop
positions.
  • Loading branch information
vimalkvn committed Nov 25, 2015
1 parent 60d24d6 commit 774a1b5
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 16 deletions.
6 changes: 6 additions & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@
History
=======
0.2.4 (2015-11-25)
------------------
* Bugfix: ribocount now returns correct read counts if an offset is provided.
* Bugfix: Don't include read counts in the longest ORF start or stop positions
i.e., only include reads upstream or downstream of the start or stop positions.

0.2.3 (2015-11-24)
------------------
* Bugfix: Recalculate read frame positions after applying offset.
Expand Down
2 changes: 1 addition & 1 deletion riboplot/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

__author__ = 'Vimalkumar Velayudhan'
__email__ = '[email protected]'
__version__ = '0.2.3'
__version__ = '0.2.4'
4 changes: 2 additions & 2 deletions riboplot/ribocore.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,12 +244,12 @@ def filter_ribo_counts(counts, orf_start=None, orf_stop=None):
filtered_counts.pop(position)
elif orf_start:
# check if current position is upstream of ORF start. if not, remove
if position > orf_start:
if position >= orf_start:
filtered_counts.pop(position)
elif orf_stop:
# check if current position is downstream of ORF stop. If not,
# remove
if position < orf_stop:
if position <= orf_stop:
filtered_counts.pop(position)

# calculate total reads for this transcript
Expand Down
17 changes: 10 additions & 7 deletions riboplot/ribocount.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,12 @@ def main(args):

log.info('Get RiboSeq read counts for all transcripts in FASTA')
for transcript in f.references:
ribo_counts, ribo_reads = ribocore.get_ribo_counts(b, transcript, read_length)
ribo_counts, ribo_reads = ribocore.get_ribo_counts(ribo_fileobj=b, transcript_name=transcript,
read_length=read_length, read_offset=read_offset)
if not ribo_reads: # no reads for this transcript. skip.
continue

transcript_sequence = f[transcript]
# By default, all counts will be written (ribo_counts)
# If 5' or 3' counts requested, filter and use
# those counts for printing instead
Expand All @@ -113,7 +115,7 @@ def main(args):
if count_five or count_three:
# use default start and stop codons and find ORFs in all 3
# frames (+)
orfs = ribocore.get_three_frame_orfs(sequence=f[transcript])
orfs = ribocore.get_three_frame_orfs(sequence=transcript_sequence)
if not len(orfs):
log.debug('No ORFs for transcript {0}'.format(transcript))
continue
Expand All @@ -136,13 +138,14 @@ def main(args):
count += 1
csv_file = 'RiboCounts{}.csv'.format(count)
with open(os.path.join(csv_dir, csv_file), 'w') as cw:
cw.write('"Position","Frame 1","Frame 2","Frame 3"\n')
for pos in range(1, len(f[transcript]) + 1):
cw.write('"Position","Nucleotide","Frame 1","Frame 2","Frame 3"\n')
for pos in range(1, len(transcript_sequence) + 1):
nucleotide = transcript_sequence[pos - 1]
if pos in write_counts:
cw.write('{0},{1},{2},{3}\n'.format(
pos, write_counts[pos][1], write_counts[pos][2], write_counts[pos][3]))
cw.write('{0},{1},{2},{3},{4}\n'.format(
pos, nucleotide, write_counts[pos][1], write_counts[pos][2], write_counts[pos][3]))
else:
cw.write('{0},{1},{2},{3}\n'.format(pos, 0, 0, 0))
cw.write('{0},{1},{2},{3},{4}\n'.format(pos, nucleotide, 0, 0, 0))
# HTML table
table_body += '<tr><td>{0}</td><td>{1}</td>'.format(transcript, ribo_reads)
if count_five:
Expand Down
6 changes: 1 addition & 5 deletions riboplot/riboplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,6 @@ def plot_profile(ribo_counts, transcript_name, transcript_length,
edgecolor=colors['rna'], label='RNA')
ax_rna.set_zorder(1)

# import pudb;pudb.set_trace();
frame_counts = {1: {}, 2: {}, 3: {}}
for k, v in ribo_counts.iteritems():
for fr in (1, 2, 3):
Expand All @@ -191,9 +190,6 @@ def plot_profile(ribo_counts, transcript_name, transcript_length,

for frame in (1, 2, 3):
color = colors['frames'][frame - 1]
# if read_offset:
# x_vals = [pos + read_offset for pos in frame_counts[frame].keys()]
# else:
x_vals = frame_counts[frame].keys()
ax2.bar(x_vals, frame_counts[frame].values(), color=color, facecolor=color, edgecolor=color)

Expand Down Expand Up @@ -383,7 +379,7 @@ def main(args):

log.info('Writing RiboSeq read counts for {}'.format(transcript_name))
with open(os.path.join(output_path, 'RiboCounts.csv'), 'w') as f:
f.write('"Position","Sequence","Frame 1","Frame 2","Frame 3"\n')
f.write('"Position","Nucleotide","Frame 1","Frame 2","Frame 3"\n')

for pos in range(1, transcript_length + 1):
if pos in ribo_counts:
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

setup(
name='riboplot',
version='0.2.3',
version='0.2.4',
description="Plot read counts of RiboSeq data from BAM format alignment files",
long_description=readme + '\n\n' + history,
author="Vimalkumar Velayudhan",
Expand Down

0 comments on commit 774a1b5

Please sign in to comment.