Repository: popsim-consortium/stdpopsim (language: python)

Issue:
added stickleback genome
I initiated by running `python -m maintenance add-species Gasterosteus_aculeatus` and it created the `species.py` and `genome_data.py`. But it didn't pull the genome information on Ensembl, so I manually added it from NCBI.


Discussion / hints:
Are you using the same branch you have used for the QC of HelMel #1084?
I would suggest that you create a different branch for this pull request @vitorpavinato.
You can do it by typing: 
$ git fetch upstream
$ git checkout upstream/main
$ git checkout -b topic_branch_name

because it seems that the error in tests you are getting is related to the QC and not with adding the new species to the catalog.

Fix patch:
diff --git a/stdpopsim/catalog/GasAcu/__init__.py b/stdpopsim/catalog/GasAcu/__init__.py
new file mode 100644
index 000000000..1f78c9fbe
--- /dev/null
+++ b/stdpopsim/catalog/GasAcu/__init__.py
@@ -0,0 +1,4 @@
+"""
+Catalog definitions for GasAcu (Ensembl ID='9307941')
+"""
+from . import species  # noqa: F401
diff --git a/stdpopsim/catalog/GasAcu/genome_data.py b/stdpopsim/catalog/GasAcu/genome_data.py
new file mode 100644
index 000000000..a72b633e3
--- /dev/null
+++ b/stdpopsim/catalog/GasAcu/genome_data.py
@@ -0,0 +1,30 @@
+# File autogenerated from Ensembl REST API. Do not edit.
+data = {
+    "assembly_accession": "GCF_016920845.1",
+    "assembly_name": "GAculeatus_UGA_version5",
+    "chromosomes": {
+        "1": {"length": 29619991, "synonyms": []},
+        "2": {"length": 23686546, "synonyms": []},
+        "3": {"length": 17759012, "synonyms": []},
+        "4": {"length": 34181212, "synonyms": []},
+        "5": {"length": 15550311, "synonyms": []},
+        "6": {"length": 18825451, "synonyms": []},
+        "7": {"length": 30776923, "synonyms": []},
+        "8": {"length": 20553084, "synonyms": []},
+        "9": {"length": 20843631, "synonyms": []},
+        "10": {"length": 17985176, "synonyms": []},
+        "11": {"length": 17651971, "synonyms": []},
+        "12": {"length": 20694444, "synonyms": []},
+        "13": {"length": 20748428, "synonyms": []},
+        "14": {"length": 16147532, "synonyms": []},
+        "15": {"length": 17318724, "synonyms": []},
+        "16": {"length": 19507025, "synonyms": []},
+        "17": {"length": 20195758, "synonyms": []},
+        "18": {"length": 15939336, "synonyms": []},
+        "19": {"length": 20580295, "synonyms": []},
+        "20": {"length": 20445003, "synonyms": []},
+        "21": {"length": 17421465, "synonyms": []},
+        "Y": {"length": 15859692, "synonyms": []},
+        "MT": {"length": 16543, "synonyms": []},
+    },
+}
diff --git a/stdpopsim/catalog/GasAcu/species.py b/stdpopsim/catalog/GasAcu/species.py
new file mode 100644
index 000000000..1e657305f
--- /dev/null
+++ b/stdpopsim/catalog/GasAcu/species.py
@@ -0,0 +1,102 @@
+import stdpopsim
+
+from . import genome_data
+
+_recombination_rate = {
+    "1": 3.11e-08,
+    "2": 3.11e-08,
+    "3": 3.11e-08,
+    "4": 3.11e-08,
+    "5": 3.11e-08,
+    "6": 3.11e-08,
+    "7": 3.11e-08,
+    "8": 3.11e-08,
+    "9": 3.11e-08,
+    "10": 3.11e-08,
+    "11": 3.11e-08,
+    "12": 3.11e-08,
+    "13": 3.11e-08,
+    "14": 3.11e-08,
+    "15": 3.11e-08,
+    "16": 3.11e-08,
+    "17": 3.11e-08,
+    "18": 3.11e-08,
+    "19": 3.11e-08,
+    "20": 3.11e-08,
+    "21": 3.11e-08,
+    "Y": 0,
+    "MT": 0,
+}
+
+_overall_rate = 3.7e-8
+_mutation_rate = {
+    "1": _overall_rate,
+    "2": _overall_rate,
+    "3": _overall_rate,
+    "4": _overall_rate,
+    "5": _overall_rate,
+    "6": _overall_rate,
+    "7": _overall_rate,
+    "8": _overall_rate,
+    "9": _overall_rate,
+    "10": _overall_rate,
+    "11": _overall_rate,
+    "12": _overall_rate,
+    "13": _overall_rate,
+    "14": _overall_rate,
+    "15": _overall_rate,
+    "16": _overall_rate,
+    "17": _overall_rate,
+    "18": _overall_rate,
+    "19": _overall_rate,
+    "20": _overall_rate,
+    "21": _overall_rate,
+    "Y": _overall_rate,
+    "MT": _overall_rate,
+}
+
+_genome = stdpopsim.Genome.from_data(
+    genome_data.data,
+    recombination_rate=_recombination_rate,
+    mutation_rate=_mutation_rate,
+    citations=[
+        stdpopsim.Citation(
+            author="Peichel et al.",
+            year=2017,
+            doi="https://doi.org/10.1093/jhered/esx058",
+            reasons={stdpopsim.CiteReason.ASSEMBLY},
+        ),
+        stdpopsim.Citation(
+            author="Roesti et al.",
+            year=2013,
+            doi="https://10.1111/mec.12322",
+            reasons={stdpopsim.CiteReason.REC_RATE},
+        ),
+        stdpopsim.Citation(
+            author="Liu et al.",
+            year=2016,
+            doi="https://10.1111/mec.13827",
+            reasons={stdpopsim.CiteReason.MUT_RATE},
+        ),
+    ],
+)
+
+_species = stdpopsim.Species(
+    id="GasAcu",
+    ensembl_id="9307941",
+    name="Gasterosteus aculeatus",
+    common_name="Three-spined stickleback",
+    genome=_genome,
+    generation_time=1,
+    population_size=1e4,
+    citations=[
+        stdpopsim.Citation(
+            author="Liu et al.",
+            year=2016,
+            doi="https://10.1111/mec.13827",
+            reasons={stdpopsim.CiteReason.POP_SIZE, stdpopsim.CiteReason.GEN_TIME},
+        ),
+    ],
+)
+
+stdpopsim.register_species(_species)


Test patch:
diff --git a/tests/test_GasAcu.py b/tests/test_GasAcu.py
new file mode 100644
index 000000000..a9815f91a
--- /dev/null
+++ b/tests/test_GasAcu.py
@@ -0,0 +1,101 @@
+import pytest
+
+import stdpopsim
+from tests import test_species
+
+
+class TestSpeciesData(test_species.SpeciesTestBase):
+
+    species = stdpopsim.get_species("GasAcu")
+
+    def test_ensembl_id(self):
+        assert self.species.ensembl_id == "9307941"
+
+    def test_name(self):
+        assert self.species.name == "Gasterosteus aculeatus"
+
+    def test_common_name(self):
+        assert self.species.common_name == "Three-spined stickleback"
+
+    # QC Tests. These tests are performed by another contributor
+    # independently referring to the citations provided in the
+    # species definition, filling in the appropriate values
+    # and deleting the pytest "skip" annotations.
+    @pytest.mark.skip("Population size QC not done yet")
+    def test_qc_population_size(self):
+        assert self.species.population_size == -1
+
+    @pytest.mark.skip("Generation time QC not done yet")
+    def test_qc_generation_time(self):
+        assert self.species.generation_time == -1
+
+
+class TestGenomeData(test_species.GenomeTestBase):
+
+    genome = stdpopsim.get_species("GasAcu").genome
+
+    @pytest.mark.skip("Recombination rate QC not done yet")
+    @pytest.mark.parametrize(
+        ["name", "rate"],
+        {
+            "1": -1,
+            "2": -1,
+            "3": -1,
+            "4": -1,
+            "5": -1,
+            "6": -1,
+            "7": -1,
+            "8": -1,
+            "9": -1,
+            "10": -1,
+            "11": -1,
+            "12": -1,
+            "13": -1,
+            "14": -1,
+            "15": -1,
+            "16": -1,
+            "17": -1,
+            "18": -1,
+            "19": -1,
+            "20": -1,
+            "21": -1,
+            "Y": -1,
+            "MT": -1,
+        }.items(),
+    )
+    def test_recombination_rate(self, name, rate):
+        assert rate == pytest.approx(
+            self.genome.get_chromosome(name).recombination_rate
+        )
+
+    @pytest.mark.skip("Mutation rate QC not done yet")
+    @pytest.mark.parametrize(
+        ["name", "rate"],
+        {
+            "1": -1,
+            "2": -1,
+            "3": -1,
+            "4": -1,
+            "5": -1,
+            "6": -1,
+            "7": -1,
+            "8": -1,
+            "9": -1,
+            "10": -1,
+            "11": -1,
+            "12": -1,
+            "13": -1,
+            "14": -1,
+            "15": -1,
+            "16": -1,
+            "17": -1,
+            "18": -1,
+            "19": -1,
+            "20": -1,
+            "21": -1,
+            "Y": -1,
+            "MT": -1,
+        }.items(),
+    )
+    def test_mutation_rate(self, name, rate):
+        assert rate == pytest.approx(self.genome.get_chromosome(name).mutation_rate)