From abcc94605d700ef3e854d658f75ead781905bb0c Mon Sep 17 00:00:00 2001
From: Martijn Vermaat <martijn@vermaat.name>
Date: Tue, 12 Apr 2011 13:20:00 +0000
Subject: [PATCH] Small fixes.

git-svn-id: https://humgenprojects.lumc.nl/svn/mutalyzer/branches/refactor-mutalyzer-branch@268 eb6bd6ab-9ccd-42b9-aceb-e2899b4a52f1
---
 extras/soap-tools/namecheck.py |  2 +-
 mutalyzer/File.py              |  7 +++----
 mutalyzer/GenRecord.py         | 20 ++++++++++++--------
 mutalyzer/variantchecker.py    | 23 ++++++++++++-----------
 4 files changed, 28 insertions(+), 24 deletions(-)

diff --git a/extras/soap-tools/namecheck.py b/extras/soap-tools/namecheck.py
index 6aa47f1e..c0f48524 100755
--- a/extras/soap-tools/namecheck.py
+++ b/extras/soap-tools/namecheck.py
@@ -15,7 +15,7 @@
 import sys
 from suds.client import Client  # https://fedorahosted.org/suds/
 
-VERBOSE = True
+VERBOSE = False
 
 URL = 'http://localhost/mutalyzer/services/?wsdl'
 
diff --git a/mutalyzer/File.py b/mutalyzer/File.py
index 7bfd479d..fd2e892b 100644
--- a/mutalyzer/File.py
+++ b/mutalyzer/File.py
@@ -378,10 +378,9 @@ class File() :
             #allow a 5 (default) percent threshold for errors in batchfiles
             self.__output.addMessage(__file__, 3, "EBPARSE",
                     "There were errors in your batch entry file, they are "
-                    "omitted and your batch is started.")
-            self.__output.addMessage(__file__, 3, "EBPARSE",
-                    "Please check the batch input file help at the top of "
-                    "this page for additional information.")
+                    "omitted and your batch is started. Please check the "
+                    "batch input file help at the top of this page for "
+                    "additional information.")
             return (ret, columns)
         else:
             return (None, columns)
diff --git a/mutalyzer/GenRecord.py b/mutalyzer/GenRecord.py
index d66c3194..fedf5d32 100644
--- a/mutalyzer/GenRecord.py
+++ b/mutalyzer/GenRecord.py
@@ -1,5 +1,3 @@
-#!/usr/bin/python
-
 """
 Module to convert a GenBank record to a nested dictionary consisting of
 a list of genes, which itself consists of a list of loci. This structure
@@ -89,6 +87,7 @@ class Locus(object) :
         """
 
         self.name = name
+        self.current = False
         self.mRNA = None
         self.CDS = None
         self.location = []
@@ -646,12 +645,22 @@ class GenRecord() :
                         orientedStop = reverseStop
                     #if
 
-                    # Check whether the variant hits CDS start.
+                    # Turn of translation to protein if we hit splice sites.
+                    # For the current transcript, this is handled with more
+                    # care in variantchecker.py.
+                    if not j.current and \
+                           util.over_splice_site(orientedStart, orientedStop,
+                                                 j.CM.RNA):
+                        j.translate = False
+
+                    # And check whether the variant hits CDS start.
                     if j.molType == 'c' and forwardStop >= j.CM.x2g(1, 0) \
                        and forwardStart <= j.CM.x2g(3, 0) :
                         self.__output.addMessage(__file__, 2, "WSTART",
                             "Mutation in start codon of gene %s transcript " \
                             "%s." % (i.name, j.name))
+                        if not j.current:
+                            j.translate = False
 
                     # FIXME Check whether the variant hits a splice site.
 
@@ -713,8 +722,3 @@ class GenRecord() :
         #if
     #checkIntron
 #GenRecord
-
-if __name__ == "__main__" :
-    R = GenRecord()
-    del R
-#if
diff --git a/mutalyzer/variantchecker.py b/mutalyzer/variantchecker.py
index 909906e0..52d1fd46 100644
--- a/mutalyzer/variantchecker.py
+++ b/mutalyzer/variantchecker.py
@@ -363,6 +363,8 @@ def apply_deletion_duplication(first, last, type, mutator, record, O):
             mutator.visualiseLargeString(str(mutator.orig[incorrect_first - 1:incorrect_stop])),
             util.format_range(incorrect_first, incorrect_stop)))
 
+    # Todo: I think we should use shifted first and last here...
+    # Likewise for other apply_* functions.
     if type == 'del':
         mutator.delM(first, last)
     else :
@@ -914,15 +916,11 @@ def process_raw_variant(mutator, variant, record, transcript, output):
     # If we hit a splice site, issue a warning. Later on we decide if we
     # can still process this variant in any way (e.g. if it deletes an
     # entire exon).
-    for gene in record.record.geneList:
-        for t in gene.transcriptList:
-            if t.CM and util.over_splice_site(first, last, t.CM.RNA):
-                if t == transcript:
-                    splice_abort = True
-                    output.addMessage(__file__, 2, 'WOVERSPLICE',
-                                      'Variant hits one or more splice sites.')
-                else:
-                    t.translate = False
+    if transcript and util.over_splice_site(first, last, transcript.CM.RNA):
+        splice_abort = True
+        output.addMessage(__file__, 2, 'WOVERSPLICE',
+                          'Variant hits one or more splice sites in ' \
+                          'selected transcript.')
 
     # If we have a deletion, and it covers exactly an even number of splice
     # sites, remove these splice sites.
@@ -954,8 +952,8 @@ def process_raw_variant(mutator, variant, record, transcript, output):
                 splice_abort = False
                 mutator.add_removed_sites(removed_sites)
                 output.addMessage(__file__, 1, 'IDELSPLICE',
-                                  'Removed %i splice sites from transcript.' \
-                                  % len(removed_sites))
+                                  'Removed %i splice sites from selected ' \
+                                  'transcript.' % len(removed_sites))
 
     # If splice_abort is set, this basically means WOVERSPLICE was called and
     # IDELSPLICE was not called.
@@ -1231,6 +1229,9 @@ def process_variant(mutator, description, record, output):
             # Todo: Shouldn't we add some message here?
             raise _VariantError()
 
+        # Mark this as the current transcript we work with.
+        transcript.current = True
+
     # Add static transcript-specific information.
     if transcript and record.record.geneList:
         _add_static_transcript_info(transcript, output)
-- 
GitLab