diff riboseqr/ribosome_profile.py @ 5:423ad61697c4

Bugfix 1: [triplet] Lengths (frameCounting) if given should be a range (not zero). readingFrame function fails with subscript out of bounds. Bugfix 2: [triplet] Check if transcript name in SAM matches the name in FASTA. Produce an error message if it's not. This fixes the problem where an empty plot is produced (no bars). [ribosome_profile] - A proper error message is now produced if an invalid transcript name is provided. Updated test data
author Vimalkumar Velayudhan <vimalkumarvelayudhan@gmail.com>
date Tue, 27 Oct 2015 12:21:50 +0000
parents c34c364ce75d
children
line wrap: on
line diff
--- a/riboseqr/ribosome_profile.py	Tue Jul 21 15:40:22 2015 +0100
+++ b/riboseqr/ribosome_profile.py	Tue Oct 27 12:21:50 2015 +0000
@@ -11,6 +11,10 @@
 R = robjects.r
 
 
+class RibosomeProfileError(Exception):
+    pass
+
+
 def run_rscript(command=None):
     """Run R command, log it, append to rscript"""
     global rscript
@@ -45,6 +49,13 @@
     """
     html += '<h2>Plot ribosome profile - results</h2>\n<hr>\n'
     if len(transcript_name):
+        # get a list of all transcript names as in SAM
+        refseqs = R('levels(riboDat@riboGR$`RiboSeq file 1`@seqnames)')
+        refseqs = tuple(refseqs)
+        if transcript_name not in refseqs:
+            raise RibosomeProfileError('Transcript "{}" does not exist in SAM alignment. '
+                                       'Please provide the transcript name exactly as in the SAM '
+                                       'alignment.'.format(transcript_name))
         cmd_args = (
             '"{transcript_name}", main="{transcript_name}",'
             'coordinates=ffCs@CDS, riboData=riboDat,'