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

Issue:
C. elegans
- **Name:** _Caenorhabditis elegans_  ~



- **Description:** _C. elegans_ is a free-living nematode from _Rhabditida_. One of the model species, here's an amazing online [Wormbook](http://www.wormbook.org) on the biology and study of _C. elegans_.



- **Chromosome structure:**

The _C. elegans_ genome is the first sequenced one, it's pretty compact (100 Mb [the N2 genome](https://science.sciencemag.org/content/282/5396/2012), 102 Mb [the VC1020 genome](https://genome.cshlp.org/content/29/6/1009.full.html)), contains ~20,000 protein-coding genes located on 6 chromosomes, and a circular mitochondrial DNA. 

The chromosomes have a domain-like organization with a central region occupying about half of each chromosome with high gene density, low repeat density, and low recombination rate, and the peripheral parts ("arms") that have high recombination rate and a lot of repeats.

- [ ] chromosome sizes (PRJNA13758 from WornBase WS245, bp; C. elegans Sequencing Consortium 1998):
I  15072434
II  15279421
III  13783801
IV  17493829
V  20924180
X  17718942
MtDNA  13794



- **Recombination rates:**

Several genetic maps for _C. elegans_ are available, one of the most widely used is from [Rockman et al. 2009](https://journals.plos.org/plosgenetics/article?id=10.1371/journal.pgen.1000419). The recombination in the central domains suppressed, _C. elegans_ has control of recombination so that it should be at least one crossover per meiosis on each chromosome, but sometimes it may be two if the crossovers are far enough from each other (interference), see the corresponding [chapter in Wormbook](http://www.wormbook.org/chapters/www_meiosis/meiosis.html) and [a review](http://symposium.cshlp.org/content/82/223.full) about crossover distributions in _C. elegans_. Also, there are no recombination hotspots.

- [ ] genetic map of recombination rates (Rockman et al. 2009)



- **Mutation rate:**

In addition to the non-constant recombination rate, _C. elegans_ has a non-uniform mutation rate with 1.22 - 1.56 times more point mutation on the "arms" ([Konrad et al. 2019](https://www.genetics.org/content/212/3/837 )), and the observations are likely related. The genome-wide rate is 1.84 (95% C.I. ± 0.14) × 10−9/site/generation (Konrad et al 2019), however, it's much better to use the mutation map: the mutation rate on the tips and arms is 2.18e-9 changes/site/generation, on the centers 1.58e-9, MtDNA 1.05e−7 ([Konrad et al. 2017](https://doi.org/10.1093/molbev/msx051))

- [ ] mutation landscape (Konrad et al. 2017, 2019)



- **Demographic information:**

_C. elegans_ lives on various rotting materials and eats bacteria and fungi. This species found worldwide. [The C. elegans Natural Diversity Resource resources (CeNDR)](https://www.elegansvariation.org) contains whole-genome data for hundreds of wild isolates.

The default population size is 10,000 (Ne from 2e+02 to 4.4e+04 [Sivasundar & Hey 2002](https://www.genetics.org/content/genetics/163/1/147.full.pdf); 2e+02 - 9.5e+03 [Barrière & Félix 2005](https://pubmed.ncbi.nlm.nih.gov/16005289/), ∼ 8e+04 [Cutter 2006](https://www.genetics.org/content/172/1/171)) 

In the lab, there are about 150 generations per year, likely it's less in the wild ([Frézal & Félix 2015](https://elifesciences.org/articles/05849)).

- [ ] generation time in years >1/150 (Frézal & Félix 2015)
- [ ] "default" population size is 10,000 (Sivasundar & Hey 2002, Barrière & Félix 2005, Cutter 2006)



- **Demographic model:**

- [ ] population sizes, PSMC ([Thomas et al. 2015](https://genome.cshlp.org/content/25/5/667.full.html)) 



- **Other information:**

One of the chromosomes (X) determines the sex, _XX_ individuals are hermaphrodites and _X0_ are males ([Brenner 1974](https://www.ncbi.nlm.nih.gov/pmc/articles/PMC1213120/)). _C. elegans_ has an androdioecious mating system, hermaphrodites reproduce by selfing and rare mating with males. However, even after the selfing, these worms can produce males due to disjunction of the X chromosome in ~0.02% of meioses. The outcrossing rate in _C. elegans_ populations vary, but the average estimate is 99.9% ([Barrière & Félix 2005](https://pubmed.ncbi.nlm.nih.gov/16005289/), [2007](https://www.ncbi.nlm.nih.gov/pmc/articles/PMC1894625/), [Félix & Duveau 2012](https://bmcbiol.biomedcentral.com/articles/10.1186/1741-7007-10-59)).

- [ ] sex determination system XX/XO (Brenner 1974)
- [ ] ploidy - 2n



- **Challenges:**
1) genetic map
2) mutation landscape
3) 99.9% of selfing
4) XX/X0 sex-determination system


Discussion / hints:

Fix patch:
diff --git a/stdpopsim/catalog/CaeEle/__init__.py b/stdpopsim/catalog/CaeEle/__init__.py
new file mode 100644
index 000000000..5c1913f53
--- /dev/null
+++ b/stdpopsim/catalog/CaeEle/__init__.py
@@ -0,0 +1,6 @@
+"""
+Catalog data for Caenorhabditis elegans
+"""
+from . import species  # noqa: F401
+
+# from . import genetic_maps  # noqa: F401
diff --git a/stdpopsim/catalog/CaeEle/genome_data.py b/stdpopsim/catalog/CaeEle/genome_data.py
new file mode 100644
index 000000000..93437cdca
--- /dev/null
+++ b/stdpopsim/catalog/CaeEle/genome_data.py
@@ -0,0 +1,14 @@
+# File autogenerated from Ensembl REST API. Do not edit.
+data = {
+    "assembly_accession": "GCA_000002985.3",
+    "assembly_name": "ce11",
+    "chromosomes": {
+        "I": {"length": 15072434, "synonyms": []},
+        "II": {"length": 15279421, "synonyms": []},
+        "III": {"length": 13783801, "synonyms": []},
+        "IV": {"length": 17493829, "synonyms": []},
+        "V": {"length": 20924180, "synonyms": []},
+        "X": {"length": 17718942, "synonyms": []},
+        "MtDNA": {"length": 13794, "synonyms": []},
+    },
+}
diff --git a/stdpopsim/catalog/CaeEle/species.py b/stdpopsim/catalog/CaeEle/species.py
new file mode 100644
index 000000000..1dfbc7ddc
--- /dev/null
+++ b/stdpopsim/catalog/CaeEle/species.py
@@ -0,0 +1,115 @@
+import stdpopsim
+from . import genome_data
+
+
+_FrezalAndFelix2015 = stdpopsim.Citation(
+    author="Frézal & Félix",
+    year=2015,
+    doi="https://doi.org/10.7554/eLife.05849",
+    reasons={stdpopsim.CiteReason.GEN_TIME},
+)
+
+
+_genome1998 = stdpopsim.Citation(
+    doi="https://doi.org/10.1126/science.282.5396.2012",
+    year=1998,
+    author="The C. elegans Sequencing Consortium*",
+    reasons={stdpopsim.CiteReason.ASSEMBLY},
+)
+
+
+_Rockman2009 = stdpopsim.Citation(
+    doi="https://doi.org/10.1371/journal.pgen.1000419",
+    year=2009,
+    author="Rockman & Kruglyak",
+    reasons={stdpopsim.CiteReason.REC_RATE},
+)
+
+_KonradEtAl2019 = stdpopsim.Citation(
+    doi="https://doi.org/10.1534/genetics.119.302054",
+    year=2019,
+    author="Konrad et al.",
+    reasons={stdpopsim.CiteReason.MUT_RATE},
+)
+
+_KonradEtAl2017 = stdpopsim.Citation(
+    author="Konrad et al.",
+    doi="https://doi.org/10.1093/molbev/msx051",
+    year=2017,
+    reasons={stdpopsim.CiteReason.MUT_RATE},
+)
+
+
+_BarriereAndFelix2005 = stdpopsim.Citation(
+    doi="https://doi.org/10.1016/j.cub.2005.06.022",
+    year=2005,
+    author="Barrière & Félix",
+    reasons={stdpopsim.CiteReason.POP_SIZE},
+)
+
+
+_Cutter2006 = stdpopsim.Citation(
+    doi="https://doi.org/10.1534/genetics.105.048207",
+    year=2006,
+    author="Cutter",
+    reasons={stdpopsim.CiteReason.POP_SIZE},
+)
+
+# Mean chromosomal rates, calculated from the Rockman and Kruglyak 2009 map.
+# !!! The recombination rate is multiplied by 0.001 because the outcrosssing rate is 0.1%
+_recombination_rate_data = {
+    "I": 3.330038e-11,
+    "II": 3.999342e-11,
+    "III": 4.484974e-11,
+    "IV": 2.417689e-11,
+    "V": 2.722476e-11,
+    "X": 3.447911e-11,
+    "MtDNA": 0,
+}
+
+
+_chromosomes = []
+for name, data in genome_data.data["chromosomes"].items():
+    _chromosomes.append(
+        stdpopsim.Chromosome(
+            id=name,
+            length=data["length"],
+            synonyms=data["synonyms"],
+            mutation_rate=1.84e-9,  # _Konrad et al. de-nove mutation rate,
+            # it's not uniform and it's much better to use a mutation map.
+            # mutation_rate=_mutation_rate_data[name],
+            recombination_rate=_recombination_rate_data[name],
+        )
+    )
+
+
+_genome = stdpopsim.Genome(
+    chromosomes=_chromosomes,
+    assembly_name=genome_data.data["assembly_name"],
+    assembly_accession=genome_data.data["assembly_accession"],
+    citations=[
+        _genome1998,
+        _KonradEtAl2019.because(stdpopsim.CiteReason.MUT_RATE),
+        _KonradEtAl2017.because(stdpopsim.CiteReason.MUT_RATE),
+        _Rockman2009.because(stdpopsim.CiteReason.REC_RATE),
+    ],
+)
+
+_species = stdpopsim.Species(
+    id="CaeEle",
+    ensembl_id="",
+    name="Caenorhabditis elegans",
+    common_name="C. elegans",
+    genome=_genome,
+    generation_time=0.01,  # the generation time in the lab ~150
+    # generation per year (0.00666), it should be less in the wild
+    population_size=10000,
+    #    selfing_rate,=0.999,
+    citations=[
+        _FrezalAndFelix2015.because(stdpopsim.CiteReason.GEN_TIME),
+        _BarriereAndFelix2005.because(stdpopsim.CiteReason.POP_SIZE),
+        _Cutter2006.because(stdpopsim.CiteReason.POP_SIZE),
+    ],
+)
+
+stdpopsim.register_species(_species)


Test patch:
diff --git a/tests/test_CaeEle.py b/tests/test_CaeEle.py
new file mode 100644
index 000000000..e6dfa97fd
--- /dev/null
+++ b/tests/test_CaeEle.py
@@ -0,0 +1,51 @@
+import pytest
+
+import stdpopsim
+from tests import test_species
+
+
+class TestSpeciesData(test_species.SpeciesTestBase):
+
+    species = stdpopsim.get_species("CaeEle")
+
+    #   def test_ensembl_id(self):
+    #        assert self.species.ensembl_id == ""
+
+    def test_name(self):
+        assert self.species.name == "Caenorhabditis elegans"
+
+    def test_common_name(self):
+        assert self.species.common_name == "C. elegans"
+
+    # 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("CaeEle").genome
+
+    @pytest.mark.skip("Recombination rate QC not done yet")
+    @pytest.mark.parametrize(
+        ["name", "rate"],
+        {"I": -1, "II": -1, "III": -1, "IV": -1, "V": -1, "X": -1, "MtDNA": -1}.items(),
+    )
+    def test_recombination_rate(self, name, rate):
+        assert pytest.approx(rate, self.genome.get_chromosome(name).recombination_rate)
+
+    @pytest.mark.skip("Mutation rate QC not done yet")
+    @pytest.mark.parametrize(
+        ["name", "rate"],
+        {"I": -1, "II": -1, "III": -1, "IV": -1, "V": -1, "X": -1, "MtDNA": -1}.items(),
+    )
+    def test_mutation_rate(self, name, rate):
+        assert pytest.approx(rate, self.genome.get_chromosome(name).mutation_rate)