Repository: acorg/dark-matter

Issue:
Extract-ORFs.py mistranslates lowercase letters
In a sequence with mixed uppercase and lowercase letters, extract-ORFs.py output has incorrect translations only for the sites of lowercase letters. (Even though the `translations` function of `dark/reads.py` translate a sequence with mixed upper and lower case letters correctly)

Discussion:

Patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index fa389b6..e329501 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,10 @@
+## 3.0.60 Dec 13, 2018
+
+In `reads.py`, changed the `_makeComplementTable` function so that 
+uppercase and lowercase bases are correctly reverse complemented into their
+respective uppercase and lowercase complementary letters. Added a test to 
+`test/reads.py` to confirm that `reverseComplement` does this.
+
 ## 3.0.59 Dec 11, 2018
 
 Added `--sampleName` option to `proteins-to-pathogens`.
diff --git a/dark/__init__.py b/dark/__init__.py
index 278f52a..ffb465c 100644
--- a/dark/__init__.py
+++ b/dark/__init__.py
@@ -8,4 +8,4 @@ if sys.version_info < (2, 7):
 #
 # Remember to update ../CHANGELOG.md describing what's new in each version.
 
-__version__ = '3.0.59'
+__version__ = '3.0.60'
diff --git a/dark/reads.py b/dark/reads.py
index 18171d0..df381e0 100644
--- a/dark/reads.py
+++ b/dark/reads.py
@@ -27,7 +27,8 @@ def _makeComplementTable(complementData):
     """
     table = list(range(256))
     for _from, to in complementData.items():
-        table[ord(_from[0])] = ord(to[0])
+        table[ord(_from[0].lower())] = ord(to[0].lower())
+        table[ord(_from[0].upper())] = ord(to[0].upper())
     return ''.join(map(chr, table))
 
 


Test patch:
diff --git a/test/test_reads.py b/test/test_reads.py
index d586ab1..4663234 100644
--- a/test/test_reads.py
+++ b/test/test_reads.py
@@ -652,6 +652,16 @@ class TestDNARead(TestCase):
         read = DNARead('id', 'ATCGMRWSVHXN')
         self.assertEqual('NXDBSWYKCGAT', read.reverseComplement().sequence)
 
+    def testReverseComplementLowercaseLetters(self):
+        """
+        The reverseComplement function must correctly reverse complement
+        lowercase letters. The issue is described here:
+        https://github.com/acorg/dark-matter/issues/662
+        """
+        read = DNARead('id', 'CAGCAGctgcagcaccagcaccagcagcttcCACAT')
+        expected = ('ATGTGgaagctgctggtgctggtgctgcagCTGCTG')
+        self.assertEqual(expected, read.reverseComplement().sequence)
+
     def testTranslationsOfEmptySequence(self):
         """
         The translations function must correctly return all six (empty)