From 93159a0ed2a9b4f2c4ed9d91af41cea5918b70ad Mon Sep 17 00:00:00 2001
From: Martijn Vermaat <martijn@vermaat.name>
Date: Thu, 9 Jul 2015 12:14:47 +0200
Subject: [PATCH] Convert DNA to uppercase when reading from plain text

---
 mutalyzer/util.py     |  5 +++--
 tests/test_website.py | 12 ++++++++++++
 2 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/mutalyzer/util.py b/mutalyzer/util.py
index 1ef1987f..ae709477 100644
--- a/mutalyzer/util.py
+++ b/mutalyzer/util.py
@@ -392,7 +392,8 @@ def read_dna(handle):
     Read the first record in an NGS data file.
 
     If the format is not recognised as FASTA or FASTQ, we assume that the input
-    is in plain text. In this case, all non-DNA characters are removed.
+    is in plain text. In this case, DNA is converted to uppercase and all
+    non-DNA characters are removed.
 
     :arg stream handle: Open readable handle to an NGS data file.
 
@@ -403,7 +404,7 @@ def read_dna(handle):
     if file_format != 'text':
         return unicode(SeqIO.parse(handle, file_format).next().seq)
 
-    return ''.join(x for x in unicode(handle.read()) if x in 'ATCG')
+    return ''.join(x for x in unicode(handle.read()).upper() if x in 'ATCG')
 
 
 def in_frame_description(s1, s2) :
diff --git a/tests/test_website.py b/tests/test_website.py
index 3392d1fa..faf336ba 100644
--- a/tests/test_website.py
+++ b/tests/test_website.py
@@ -207,6 +207,18 @@ class TestWebsite(MutalyzerTest):
         assert 'Input sequences are restricted to ' in r.data
         assert '1 Error, 0 Warnings.' in r.data
 
+    def test_description_extractor_lowercase(self):
+        """
+        Submit a sample sequence with a base in lowercase to the variant
+        description extractor.
+        """
+        r = self.app.post('/description-extractor', data={
+            'reference_method': 'raw_method',
+            'sample_method': 'raw_method',
+            'reference_sequence': 'TTT',
+            'sample_sequence': 'TaT'})
+        assert '<pre class="description">2T&gt;A</pre>' in r.data
+
     def test_checksyntax_valid(self):
         """
         Submit the check syntax form with a valid variant.
-- 
GitLab