Skip to content

Commit

Permalink
Merge pull request #1059 from izabelcavassim/doc_dfe
Browse files Browse the repository at this point in the history
added DFE description to the catalog docs
  • Loading branch information
grahamgower committed Oct 25, 2021
2 parents 6516731 + bfe4655 commit 8805578
Showing 1 changed file with 81 additions and 2 deletions.
83 changes: 81 additions & 2 deletions docs/_ext/speciescatalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ def get_genetic_map_id(self, species, genetic_map):
def get_annotation_id(self, species, annotation):
return f"sec_catalog_{species.id}_annotations_{annotation.id}".lower()

def get_dfe_id(self, species, dfe):
return f"sec_catalog_{species.id}_dfes_{dfe.id}".lower()

def get_target(self, tid):
"""
Returns a target node for the specified ID.
Expand Down Expand Up @@ -493,27 +496,94 @@ def annotation_table(self, species):

return table

def dfe_section(self, species, dfe):
dfe_id = self.get_dfe_id(species, dfe)
target = self.get_target(dfe_id)
section = nodes.section(ids=[dfe_id])
section += nodes.title(text=dfe.id)
section += nodes.paragraph(text=dfe.description)
section += nodes.rubric(text="Citations")
section += self.citation_list(dfe)
return [target, section]

def dfes_table(self, species):
table = nodes.table()
tgroup = nodes.tgroup(cols=3)
colspec = nodes.colspec(colwidth=1)
tgroup.append(colspec)
colspec = nodes.colspec(colwidth=1)
tgroup.append(colspec)
colspec = nodes.colspec(colwidth=1)
tgroup.append(colspec)

table += tgroup

thead = nodes.thead()
tgroup += thead
row = nodes.row()
entry = nodes.entry()
entry += nodes.paragraph(text="ID")
row += entry
entry = nodes.entry()
entry += nodes.paragraph(text="Year")
row += entry
entry = nodes.entry()
entry += nodes.paragraph(text="Description")
row += entry

thead.append(row)

rows = []

for dfe in species.dfes:
row = nodes.row()
rows.append(row)

dfe_id = self.get_dfe_id(species, dfe)
entry = nodes.entry()
para = nodes.paragraph()
entry += para
para += nodes.reference(internal=True, refid=dfe_id, text=dfe.id)
row += entry

entry = nodes.entry()
entry += nodes.paragraph(text=dfe.citations[0].year)
row += entry

entry = nodes.entry()
para = nodes.paragraph()
entry += nodes.paragraph(text=dfe.description)
row += entry

tbody = nodes.tbody()
tbody.extend(rows)
tgroup += tbody

return table

def run(self):
# species:
species = stdpopsim.get_species(self.arguments[0])
sid = f"sec_catalog_{species.id}"
species_target = self.get_target(sid)
section = nodes.section(ids=[sid], names=[sid])
section += nodes.title(text=species.name)
section += self.species_summary(species)

# genomes:
genome_section = nodes.section(ids=[f"sec_catalog_{species.id}_genome"])
genome_section += nodes.title(text="Genome")
genome_section += self.chromosomes_table(species)
section += genome_section
section += nodes.transition()

# genetic maps:
maps_section = nodes.section(ids=[f"sec_catalog_{species.id}_genetic_maps"])
maps_section += nodes.title(text="Genetic Maps")
maps_section += self.genetic_maps_table(species)
for gmap in species.genetic_maps:
maps_section += self.genetic_map_section(species, gmap)
section += maps_section
section += nodes.transition()
# demographic models:
models_section = nodes.section(ids=[f"sec_catalog_{species.id}_models"])
models_section += nodes.title(text="Demographic Models")
models_section += self.models_table(species)
Expand All @@ -523,13 +593,22 @@ def run(self):
if i < len(species.demographic_models) - 1:
models_section += nodes.transition()
section += models_section
# annotation:
annot_section = nodes.section(ids=[f"sec_catalog_{species.id}_annotations"])
annot_section += nodes.title(text="Annotations")
annot_section += self.annotation_table(species)
for an in species.annotations:
annot_section += self.annotation_section(species, an)
section += annot_section
section += nodes.transition()
# DFE:
dfes_section = nodes.section(ids=[f"sec_catalog_{species.id}_dfe"])
dfes_section += nodes.title(text="Distribution of Fitness Effects (DFEs)")
dfes_section += self.dfes_table(species)
for i, dfe in enumerate(species.dfes):
dfes_section += self.dfe_section(species, dfe)
section += dfes_section
section += nodes.transition()
return [species_target, section]


Expand Down

0 comments on commit 8805578

Please sign in to comment.