Repository: cogent3/cogent3
Pull request #1163 (2022-10-06 04:55:27)

ENH: updated genetic codes based latest NCBI versions
[CHANGED] note name of genetic code 1 has changed from
    "Standard Nuclear" to "Standard"


Patch:
diff --git a/requirements.txt b/requirements.txt
index c20707b79..6b7fd0943 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -1,6 +1,6 @@
 chardet==5.0.0
 pillow==9.2.0
-psutil==5.9.2
+psutil==5.9.1
 scipy==1.9.1
 nox==2022.8.7
 plotly==5.10.0
diff --git a/src/cogent3/app/sample.py b/src/cogent3/app/sample.py
index b2bc82069..7ce1c3b2a 100644
--- a/src/cogent3/app/sample.py
+++ b/src/cogent3/app/sample.py
@@ -191,7 +191,7 @@ class take_codon_positions:
         self,
         *positions,
         fourfold_degenerate=False,
-        gc="Standard Nuclear",
+        gc="Standard",
         moltype="dna",
     ):
         """selects the indicated codon positions from an alignment
diff --git a/src/cogent3/core/genetic_code.py b/src/cogent3/core/genetic_code.py
index fd2e65c99..bf6e92026 100644
--- a/src/cogent3/core/genetic_code.py
+++ b/src/cogent3/core/genetic_code.py
@@ -353,7 +353,7 @@ NcbiGeneticCodeData = [
         [
             "FFLLSSSSYY**CC*WLLLLPPPPHHQQRRRRIIIMTTTTNNKKSSRRVVVVAAAADDEEGGGG",
             1,
-            "Standard Nuclear",
+            "Standard",
             "---M---------------M---------------M----------------------------",
         ],
         [
@@ -366,12 +366,13 @@ NcbiGeneticCodeData = [
             "FFLLSSSSYY**CCWWTTTTPPPPHHQQRRRRIIMMTTTTNNKKSSRRVVVVAAAADDEEGGGG",
             3,
             "Yeast Mitochondrial",
-            "----------------------------------MM----------------------------",
+            "----------------------------------MM---------------M------------",
         ],
         [
             "FFLLSSSSYY**CCWWLLLLPPPPHHQQRRRRIIIMTTTTNNKKSSRRVVVVAAAADDEEGGGG",
             4,
-            "Mold, Protozoan, and Coelenterate Mitochondrial, and Mycoplasma/Spiroplasma Nuclear",
+            "Mold Mitochondrial; Protozoan Mitochondrial; Coelenterate "
+            "Mitochondrial; Mycoplasma; Spiroplasma",
             "--MM---------------M------------MMMM---------------M------------",
         ],
         [
@@ -383,13 +384,13 @@ NcbiGeneticCodeData = [
         [
             "FFLLSSSSYYQQCC*WLLLLPPPPHHQQRRRRIIIMTTTTNNKKSSRRVVVVAAAADDEEGGGG",
             6,
-            "Ciliate, Dasycladacean and Hexamita Nuclear",
+            "Ciliate Nuclear; Dasycladacean Nuclear; Hexamita Nuclear",
             "-----------------------------------M----------------------------",
         ],
         [
             "FFLLSSSSYY**CCWWLLLLPPPPHHQQRRRRIIIMTTTTNNNKSSSSVVVVAAAADDEEGGGG",
             9,
-            "Echinoderm and Flatworm Mitochondrial",
+            "Echinoderm Mitochondrial; Flatworm Mitochondrial",
             "-----------------------------------M---------------M------------",
         ],
         [
@@ -401,7 +402,7 @@ NcbiGeneticCodeData = [
         [
             "FFLLSSSSYY**CC*WLLLLPPPPHHQQRRRRIIIMTTTTNNKKSSRRVVVVAAAADDEEGGGG",
             11,
-            "Bacterial Nuclear and Plant Plastid",
+            "Bacterial, Archaeal and Plant Plastid",
             "---M---------------M------------MMMM---------------M------------",
         ],
         [
@@ -414,7 +415,7 @@ NcbiGeneticCodeData = [
             "FFLLSSSSYY**CCWWLLLLPPPPHHQQRRRRIIMMTTTTNNKKSSGGVVVVAAAADDEEGGGG",
             13,
             "Ascidian Mitochondrial",
-            "-----------------------------------M----------------------------",
+            "---M------------------------------MM---------------M------------",
         ],
         [
             "FFLLSSSSYYY*CCWWLLLLPPPPHHQQRRRRIIIMTTTTNNNKSSSSVVVVAAAADDEEGGGG",
@@ -425,7 +426,7 @@ NcbiGeneticCodeData = [
         [
             "FFLLSSSSYY*QCC*WLLLLPPPPHHQQRRRRIIIMTTTTNNKKSSRRVVVVAAAADDEEGGGG",
             15,
-            "Blepharisma Nuclear",
+            "Blepharisma Macronuclear",
             "-----------------------------------M----------------------------",
         ],
         [
@@ -436,7 +437,7 @@ NcbiGeneticCodeData = [
         ],
         [
             "FFLLSSSSYY**CCWWLLLLPPPPHHQQRRRRIIMMTTTTNNNKSSSSVVVVAAAADDEEGGGG",
-            20,
+            21,
             "Trematode Mitochondrial",
             "-----------------------------------M---------------M------------",
         ],
@@ -450,6 +451,67 @@ NcbiGeneticCodeData = [
             "FF*LSSSSYY**CC*WLLLLPPPPHHQQRRRRIIIMTTTTNNKKSSRRVVVVAAAADDEEGGGG",
             23,
             "Thraustochytrium Mitochondrial",
+            "--------------------------------M--M---------------M------------",
+        ],
+        [
+            "FFLLSSSSYY**CCWWLLLLPPPPHHQQRRRRIIIMTTTTNNKKSSSKVVVVAAAADDEEGGGG",
+            24,
+            "Rhabdopleuridae Mitochondrial",
+            "---M---------------M---------------M---------------M------------",
+        ],
+        [
+            "FFLLSSSSYY**CCGWLLLLPPPPHHQQRRRRIIIMTTTTNNKKSSRRVVVVAAAADDEEGGGG",
+            25,
+            "Candidate Division SR1 and Gracilibacteria",
+            "---M-------------------------------M---------------M------------",
+        ],
+        [
+            "FFLLSSSSYY**CC*WLLLAPPPPHHQQRRRRIIIMTTTTNNKKSSRRVVVVAAAADDEEGGGG",
+            26,
+            "Pachysolen tannophilus Nuclear",
+            "-------------------M---------------M----------------------------",
+        ],
+        [
+            "FFLLSSSSYYQQCCWWLLLLPPPPHHQQRRRRIIIMTTTTNNKKSSRRVVVVAAAADDEEGGGG",
+            27,
+            "Karyorelict Nuclear",
+            "-----------------------------------M----------------------------",
+        ],
+        [
+            "FFLLSSSSYYQQCCWWLLLLPPPPHHQQRRRRIIIMTTTTNNKKSSRRVVVVAAAADDEEGGGG",
+            28,
+            "Condylostoma Nuclear",
+            "-----------------------------------M----------------------------",
+        ],
+        [
+            "FFLLSSSSYYYYCC*WLLLLPPPPHHQQRRRRIIIMTTTTNNKKSSRRVVVVAAAADDEEGGGG",
+            29,
+            "Mesodinium Nuclear",
+            "-----------------------------------M----------------------------",
+        ],
+        [
+            "FFLLSSSSYYEECC*WLLLLPPPPHHQQRRRRIIIMTTTTNNKKSSRRVVVVAAAADDEEGGGG",
+            30,
+            "Peritrich Nuclear",
+            "-----------------------------------M----------------------------",
+        ],
+        [
+            "FFLLSSSSYYEECCWWLLLLPPPPHHQQRRRRIIIMTTTTNNKKSSRRVVVVAAAADDEEGGGG",
+            31,
+            "Blastocrithidia Nuclear",
+            "-----------------------------------M----------------------------",
+        ],
+        [
+            "FFLLSSSSYY*WCC*WLLLLPPPPHHQQRRRRIIIMTTTTNNKKSSRRVVVVAAAADDEEGGGG",
+            32,
+            "Balanophoraceae Plastid",
+            "---M---------------M------------MMMM---------------M------------",
+        ],
+        [
+            "FFLLSSSSYYY*CCWWLLLLPPPPHHQQRRRRIIIMTTTTNNKKSSSKVVVVAAAADDEEGGGG",
+            33,
+            "Cephalodiscidae Mitochondrial",
+            "---M---------------M---------------M---------------M------------",
         ],
     ]
 ]


Test patch:
diff --git a/tests/test_core/test_genetic_code.py b/tests/test_core/test_genetic_code.py
index 46d532830..65042f546 100644
--- a/tests/test_core/test_genetic_code.py
+++ b/tests/test_core/test_genetic_code.py
@@ -41,7 +41,7 @@ class GeneticCodeTests(TestCase):
         self.NcbiStandard = [
             "FFLLSSSSYY**CC*WLLLLPPPPHHQQRRRRIIIMTTTTNNKKSSRRVVVVAAAADDEEGGGG",
             1,
-            "Standard Nuclear",
+            "Standard",
             "---M---------------M---------------M----------------------------",
         ]
 
@@ -69,7 +69,7 @@ class GeneticCodeTests(TestCase):
         )
         self.assertEqual(sgc.start_codons, {"TTG": "M", "CTG": "M", "ATG": "M"})
         self.assertEqual(sgc.ID, 1)
-        self.assertEqual(sgc.name, "Standard Nuclear")
+        self.assertEqual(sgc.name, "Standard")
         self.assertEqual(sgc["UUU"], "F")
         self.assertEqual(sgc.is_start("ATG"), True)
         self.assertEqual(sgc.is_start("AAA"), False)
@@ -95,7 +95,7 @@ class GeneticCodeTests(TestCase):
             )
             self.assertEqual(sgc.start_codons, {"TTG": "M", "CTG": "M", "ATG": "M"})
             self.assertEqual(sgc.ID, 1)
-            self.assertEqual(sgc.name, "Standard Nuclear")
+            self.assertEqual(sgc.name, "Standard")
             self.assertEqual(sgc["TTT"], "F")
             self.assertEqual(sgc.is_start("ATG"), True)
             self.assertEqual(sgc.is_start("AAA"), False)
@@ -361,7 +361,7 @@ class GeneticCodeTests(TestCase):
 
     def test_get_code(self):
         """correctly return the genetic code"""
-        for code_id in [1, "1", "Standard Nuclear", DEFAULT]:
+        for code_id in [1, "1", "Standard", DEFAULT]:
             got = get_code(code_id)
             self.assertEqual(got, DEFAULT)
         got = get_code(2)
@@ -370,8 +370,8 @@ class GeneticCodeTests(TestCase):
     def test_available_codes(self):
         """avaialable_codes returns Table with correct shape"""
         codes = available_codes()
-        self.assertEqual(codes.shape, (17, 2))
-        self.assertEqual(codes[0, "Name"], "Standard Nuclear")
+        self.assertTrue(codes.shape[0] > 17)
+        self.assertEqual(codes[0, "Name"], "Standard")
 
     def test_to_table(self):
         """tests to_table method."""
@@ -411,7 +411,7 @@ class GeneticCodeTests(TestCase):
         )
         self.assertTrue("<table>" in got)
         self.assertTrue("</table>" in got)
-        self.assertIn("Standard Nuclear", got)
+        self.assertIn("Standard", got)
 
 
 # Run tests if called from command line
diff --git a/tests/test_core/test_moltype.py b/tests/test_core/test_moltype.py
index 470599204..274e35f87 100644
--- a/tests/test_core/test_moltype.py
+++ b/tests/test_core/test_moltype.py
@@ -1130,7 +1130,7 @@ class TestCodonAlphabet(_AlphabetTestCase):
     def test_constructing_from_func(self):
         """the CodonAlphabet function should support genetic code names as well"""
         alpha_int = CodonAlphabet(1)
-        alpha_name = CodonAlphabet("Standard Nuclear")
+        alpha_name = CodonAlphabet("Standard")
         self.assertEqual(alpha_int, alpha_name)
         alpha_int = CodonAlphabet(2)
         alpha_name = CodonAlphabet("Vertebrate Mitochondrial")