Skip to content

Commit 41db8d5

Browse files
Merge pull request #345 from mcveanlab/doc-improvements
Doc improvements
2 parents f369b7e + b6e94f4 commit 41db8d5

File tree

7 files changed

+140
-92
lines changed

7 files changed

+140
-92
lines changed

CHANGELOG.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
--------------------
2-
[0.0.0] - 2019-XX-XX
2+
[0.1.0] - 2019-12-18
33
--------------------
44

55
Initial release.

docs/_ext/speciescatalog.py

Lines changed: 36 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -45,86 +45,46 @@ def get_target(self, tid):
4545
self.state.document.note_explicit_target(target)
4646
return target
4747

48-
def species_summary_table(self, species):
49-
table = nodes.table()
50-
tgroup = nodes.tgroup(cols=2)
51-
colspec = nodes.colspec(colwidth=1)
52-
tgroup.append(colspec)
53-
colspec = nodes.colspec(colwidth=1)
54-
tgroup.append(colspec)
55-
colspec = nodes.colspec(colwidth=1)
56-
tgroup.append(colspec)
57-
58-
table += tgroup
59-
60-
data = [
61-
("id", species.id, ""),
62-
("name", species.name, ""),
63-
("generation_time", species.generation_time,
64-
"TODO: Notes for generation_time"),
65-
("population_size", species.population_size,
66-
"TODO: Notes for population_size"),
67-
]
68-
69-
rows = []
70-
for row_data in data:
71-
row = nodes.row()
72-
rows.append(row)
73-
for entry_data in row_data:
74-
entry = nodes.entry()
75-
entry += nodes.paragraph(text=entry_data)
76-
row += entry
48+
def make_field_list(self, data):
7749

78-
tbody = nodes.tbody()
79-
tbody.extend(rows)
80-
tgroup += tbody
50+
field_list = nodes.field_list()
51+
for name, text, citation in data:
52+
field = nodes.field()
53+
field_name = nodes.field_name(text=name)
54+
field_body = nodes.field_body()
55+
para = nodes.paragraph(text=text)
8156

82-
return table
57+
if citation is not None:
58+
text = f" ({citation.author}, {citation.year})"
59+
para += nodes.reference(
60+
internal=False, refuri=citation.doi, text=text)
8361

84-
def model_table(self, model):
85-
table = nodes.table()
86-
tgroup = nodes.tgroup(cols=2)
62+
field_body += para
63+
field += field_name
64+
field += field_body
65+
field_list += field
8766

88-
colspec = nodes.colspec(colwidth=1)
89-
tgroup.append(colspec)
90-
colspec = nodes.colspec(colwidth=1)
91-
tgroup.append(colspec)
67+
return field_list
9268

93-
table += tgroup
94-
95-
rows = []
96-
row = nodes.row()
97-
rows.append(row)
98-
entry = nodes.entry()
99-
entry += nodes.paragraph(text="ID")
100-
row += entry
101-
entry = nodes.entry()
102-
entry += nodes.paragraph(text=model.id)
103-
row += entry
104-
105-
row = nodes.row()
106-
rows.append(row)
107-
entry = nodes.entry()
108-
entry += nodes.paragraph(text="Description")
109-
row += entry
110-
entry = nodes.entry()
111-
entry += nodes.paragraph(text=model.description)
112-
row += entry
113-
114-
row = nodes.row()
115-
rows.append(row)
116-
entry = nodes.entry()
117-
entry += nodes.paragraph(text="Num populations")
118-
row += entry
119-
entry = nodes.entry()
120-
entry += nodes.paragraph(text=model.num_populations)
121-
row += entry
122-
123-
tbody = nodes.tbody()
124-
tbody.extend(rows)
125-
tgroup += tbody
69+
def species_summary(self, species):
70+
data = [
71+
("ID", species.id, None),
72+
("Name", species.name, None),
73+
("Common name", species.common_name, None),
74+
("Generation time", species.generation_time,
75+
species.generation_time_citations[0]),
76+
("Population size", species.population_size,
77+
species.population_size_citations[0]),
78+
]
79+
return self.make_field_list(data)
12680

127-
return table
81+
def model_summary(self, model):
82+
data = [
83+
("ID", model.id, None),
84+
("Description", model.description, None),
85+
("Num populations", model.num_populations, None),
86+
]
87+
return self.make_field_list(data)
12888

12989
def citation_list(self, citable):
13090
bullet_list = nodes.bullet_list()
@@ -411,7 +371,7 @@ def model_section(self, species, model):
411371
section += nodes.title(text=model.description)
412372
section += nodes.paragraph(text=model.long_description)
413373
section += nodes.rubric(text="Details")
414-
section += self.model_table(model)
374+
section += self.model_summary(model)
415375
section += nodes.rubric(text="Populations")
416376
section += self.population_table(model)
417377
section += nodes.rubric(text="Citations")
@@ -427,7 +387,7 @@ def run(self):
427387
species_target = self.get_target(sid)
428388
section = nodes.section(ids=[sid], names=[sid])
429389
section += nodes.title(text=species.name)
430-
section += self.species_summary_table(species)
390+
section += self.species_summary(species)
431391

432392
genome_section = nodes.section(ids=[f"sec_catalog_{species.id}_genome"])
433393
genome_section += nodes.title(text="Genome")

docs/catalog.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ and saves the output to a file called ``test.trees``:
2929

3030
.. code-block:: console
3131
32-
$ stdpopsim HomSap -c chr22 -o test.trees -g HapmapII_GRCh37 --model ooa_3 2 2 2
32+
$ stdpopsim HomSap -c chr22 -o test.trees -g HapMapII_GRCh37 --model OutOfAfrica_3G09 2 2 2
3333
3434
(To learn more about using ``stdpopsim`` via the command-line, read our :ref:`sec_tutorial`
3535
about it.)

docs/docutils.conf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# This is used to make sure that we don't split lines when field names
2+
# are long in the speciescatalog extension. See
3+
# https://stackoverflow.com/questions/13029207/overriding-the-default-field-name-limit-in-sphinx-docutils
4+
[html4css1 writer]
5+
field_name_limit: 40

docs/installation.rst

Lines changed: 84 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,89 @@
44
Installation
55
============
66

7+
There are two basic options for installing ``stdpopsim`` and its dependencies: either
8+
using :ref:`sec_installation_conda` or :ref:`sec_installation_pip`.
9+
We recommend conda for most users (particularly those using OSX or Windows),
10+
although pip can be more convenient in certain cases.
11+
12+
.. _sec_installation_requirements:
13+
14+
************
15+
Requirements
16+
************
17+
18+
Library requirements for stdpopsim should be installed automatically when using
19+
either conda or pip.
20+
21+
Stdpopsim requires Python 3.5 or later.
22+
23+
24+
.. _sec_installation_conda:
25+
26+
*****
27+
Conda
28+
*****
29+
30+
.. todo:: The conda package for stdpopsim is currently under development and will
31+
be available shortly. Please use pip for now.
32+
33+
34+
.. _sec_installation_pip:
35+
36+
***
37+
Pip
38+
***
39+
40+
Installing using pip is usually as simple as::
41+
42+
$ python -m pip install stdpopsim --user
43+
44+
This will install ``stdpopsim`` into your local user Python packages
45+
(on some systems you will need to use ``python3`` rather than
46+
``python``). Please see the Python `package installation
47+
<https://packaging.python.org/tutorials/installing-packages/>`_
48+
tutorial for more details on the various installation options. In particular,
49+
we recommend using a `virtual environment
50+
<https://packaging.python.org/tutorials/installing-packages/#creating-virtual-environments>`_
51+
to improve reproducibility.
52+
53+
It may also be necessary to update your PATH to run the command
54+
line interface. See `here
55+
<https://packaging.python.org/tutorials/installing-packages/#installing-to-the-user-site>`_
56+
for details on what this means and how to do it.
57+
58+
We use `msprime <https://msprime.readthedocs.io/>`_ as the
59+
default simulation engine, which has some system level dependencies
60+
and requires a functioning compiler. Please see the msprime
61+
`installation documentation
62+
<https://msprime.readthedocs.io/en/stable/installation.html>`_ for
63+
instructions if you encounter errors during installation.
64+
65+
.. _sec_installation_running_cli:
66+
67+
***************
68+
Running the CLI
69+
***************
70+
71+
After installation is complete it should be possible to run the
72+
:ref:`command line interface <sec_cli_args>`. This can be done in one
73+
of two ways:
74+
75+
1. The most reliable way is to use ::
76+
77+
$ python -m stdpopsim
78+
79+
Once the ``python`` executable is the same one as was used when installing
80+
``conda`` or ``pip``, this is guaranteed to work.
81+
82+
2. It is also possible to run ``stdpopsim`` like a regular Unix program
83+
using::
84+
85+
$ stdpopsim
86+
87+
However, this requires that your `PATH <https://en.wikipedia.org/wiki/PATH_(variable)>`_
88+
environment variable contains the directory where conda or pip installed the
89+
executable. Please see the specific documentation on these methods above for
90+
details on how to do this.
791

8-
.. todo:: Add installation docs. Should be as simple as ``pip install stdpopsim``.
992

docs/tutorial.rst

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ This gives all of the possible demographic models we could simulate. We choose
7070
the two population out-of-Africa :ref:`model <sec_catalog_homsap_models_outofafrica_2t12>`
7171
from `Tennesen et al. (2012) <https://doi.org/10.1126/science.1219240>`_ .
7272
By looking at the model help we
73-
find that the name for this model is ``ooa_2`` and that we can specify it using
73+
find that the name for this model is ``OutOfAfrica_2T12`` and that we can specify it using
7474
the ``--model`` option. We choose to draw two samples from the African
7575
population and three samples from the European population. To increase
7676
simulation speed we can also chose to simulate a sequence a fraction of the
@@ -81,7 +81,7 @@ uniform recombination map. The command now looks like this:
8181

8282
.. code-block:: console
8383
84-
$ stdpopsim HomSap -c chr22 -l 0.05 -o foo.ts --model ooa_2 2 3
84+
$ stdpopsim HomSap -c chr22 -l 0.05 -o foo.ts --model OutOfAfrica_2T12 2 3
8585
8686
Note that there are now two numbers after the model option. This is because the
8787
model simulates two populations so we have to specify a number of samples to
@@ -98,14 +98,14 @@ the ``-l`` option. (NOTE: this may a minute or so to run).
9898

9999
.. code-block:: console
100100
101-
$ stdpopsim HomSap -g HapmapII_GRCh37 -c chr22 -o foo.ts --model ooa_2 2 3
101+
$ stdpopsim HomSap -g HapMapII_GRCh37 -c chr22 -o foo.ts --model OutOfAfrica_2T12 2 3
102102
103103
For reproducibility we can also choose set seed for the simulator using the
104104
``-s`` flag.
105105

106106
.. code-block:: console
107107
108-
$ stdpopsim HomSap -s 1046 -g HapmapII_GRCh37 -c chr22 -o foo.ts --model ooa_2 2 3
108+
$ stdpopsim HomSap -s 1046 -g HapMapII_GRCh37 -c chr22 -o foo.ts --model OutOfAfrica_2T12 2 3
109109
110110
Lastly, the CLI also outputs the relevant citations for both the simulator used
111111
and the resources used for simulation scenario.
@@ -262,8 +262,8 @@ This prints detailed information about all of the available models to
262262
the terminal.
263263
In this tutorial, we will use the model of African-American admixture from
264264
`2011 Browning et al <http://dx.doi.org/10.1371/journal.pgen.1007385>`_.
265-
From the help output (or the :ref:`Catalog <sec_catalog>`),
266-
we can see that this model has id ``america``,
265+
From the help output (or the :ref:`Catalog <sec_catalog_homsap_models_americanadmixture_4b11>`),
266+
we can see that this model has id ``AmericanAdmixture_4B11``,
267267
and allows samples to be drawn from 4 contemporary populations representing African,
268268
European, Asian and African-American groups.
269269

@@ -272,7 +272,7 @@ are available:
272272

273273
.. command-output:: stdpopsim HomSap --help-genetic-maps
274274

275-
Let's go with ``HapmapII_GRCh37``.
275+
Let's go with ``HapMapII_GRCh37``.
276276
The next command simulates 4 samples of chromosome 1 from each of the four
277277
populations, and saves the output to a file called ``afr-america-chr1.trees``.
278278
For the purposes of this tutorial, we'll also specify a random seed using the
@@ -281,8 +281,8 @@ For the purposes of this tutorial, we'll also specify a random seed using the
281281

282282
.. code-block:: console
283283
284-
$ stdpopsim HomSap -c chr1 -o afr-america-chr1.trees -s 13 -g HapmapII_GRCh37\
285-
--model america 4 4 4 4
284+
$ stdpopsim HomSap -c chr1 -o afr-america-chr1.trees -s 13 -g HapMapII_GRCh37\
285+
--model AmericanAdmixture_4B11 4 4 4 4
286286
287287
--------------------------
288288
2. Calculating divergences

setup.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
setup(
1010
name='stdpopsim',
11-
description='Standard simulation models for msprime',
11+
description='A library of population genetic simulation models',
1212
long_description=long_description,
1313
author='PopSim Consortium',
1414
# TODO probably should have a different email address?
@@ -33,10 +33,10 @@
3333
},
3434
# NOTE: make sure this is the 'attrs' package, not 'attr'!
3535
install_requires=["msprime", "attrs", "appdirs", "humanize"],
36-
url='https://github.com/popgensims/stdpopsim',
36+
url='https://github.com/popsim-consortium/stdpopsim',
3737
project_urls={
38-
'Bug Reports': 'https://github.com/popgensims/stdpopsim/issues',
39-
'Source': 'https://github.com/tsckit-dev/stdpopsim',
38+
'Bug Reports': 'https://github.com/popsim-consortium/stdpopsim/issues',
39+
'Source': 'https://github.com/popsim-consortium/stdpopsim',
4040
},
4141
license="GNU GPLv3+",
4242
platforms=["POSIX", "MacOS X", "Windows"],

0 commit comments

Comments
 (0)