Skip to content

Commit

Permalink
Merge pull request #170 from opentargets/do_docstring_fixes
Browse files Browse the repository at this point in the history
docs: several fixes in docstrings
  • Loading branch information
DSuveges authored Oct 16, 2023
2 parents cc1f636 + 84e8de5 commit dc5d2b6
Show file tree
Hide file tree
Showing 13 changed files with 59 additions and 61 deletions.
2 changes: 1 addition & 1 deletion config/step/my_v2g.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ liftover_chain_file_path: ${datasets.chain_37_38}
anderson_path: ${datasets.anderson}
javierre_path: ${datasets.javierre}
jung_path: ${datasets.jung}
thurnman_path: ${datasets.thurnman}
thurman_path: ${datasets.thurman}
v2g_path: ${datasets.v2g}
1 change: 1 addition & 0 deletions docs/components/datasource/intervals/thurman.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
::: otg.datasource.intervals.thurman.IntervalsThurman
1 change: 0 additions & 1 deletion docs/components/datasource/intervals/thurnman.md

This file was deleted.

4 changes: 2 additions & 2 deletions src/otg/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ class V2GStepConfig:
anderson_path (str): Anderson intervals path.
javierre_path (str): Javierre intervals path.
jung_path (str): Jung intervals path.
thurnman_path (str): Thurnman intervals path.
thurman_path (str): Thurman intervals path.
liftover_max_length_difference (int): Maximum length difference for liftover.
max_distance (int): Maximum distance to consider.
output_path (str): Output V2G path.
Expand All @@ -164,7 +164,7 @@ class V2GStepConfig:
anderson_path: str = MISSING
javierre_path: str = MISSING
jung_path: str = MISSING
thurnman_path: str = MISSING
thurman_path: str = MISSING
liftover_max_length_difference: int = 100
max_distance: int = 500_000
v2g_path: str = MISSING
Expand Down
4 changes: 2 additions & 2 deletions src/otg/datasource/finngen/study_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ def from_source(
Args:
finngen_studies (DataFrame): FinnGen raw study table
finngen_release_prefix (str): Release prefix pattern.
finngen_sumstat_url_prefix (str): URL prefix for summary statistics location.
finngen_sumstat_url_suffix (str): URL prefix suffix for summary statistics location.
finngen_summary_stats_url_prefix (str): URL prefix for summary statistics location.
finngen_summary_stats_url_suffix (str): URL prefix suffix for summary statistics location.
Returns:
FinnGenStudyIndex: Parsed and annotated FinnGen study table.
Expand Down
3 changes: 1 addition & 2 deletions src/otg/datasource/intervals/andersson.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,7 @@ def parse(
"""Parse Andersson et al. 2014 dataset.
Args:
session (Session): session
path (str): Path to dataset
raw_anderson_df (DataFrame): Raw Andersson et al. dataset
gene_index (GeneIndex): Gene index
lift (LiftOverSpark): LiftOverSpark instance
Expand Down
7 changes: 3 additions & 4 deletions src/otg/datasource/intervals/javierre.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ class IntervalsJavierre(Intervals):
"""Interval dataset from Javierre et al. 2016."""

@staticmethod
def read_javierre(spark: SparkSession, path: str):
def read_javierre(spark: SparkSession, path: str) -> DataFrame:
"""Read Javierre dataset.
Args:
spark (SparkSession): Spark session
path (str): Path to dataset
Returns:
DataFrame: DataFrame with raw Javierre data
DataFrame: Raw Javierre dataset
"""
return spark.read.parquet(path)

Expand All @@ -41,8 +41,7 @@ def parse(
"""Parse Javierre et al. 2016 dataset.
Args:
session (Session): session
path (str): Path to dataset
javierre_raw (DataFrame): Raw Javierre data
gene_index (GeneIndex): Gene index
lift (LiftOverSpark): LiftOverSpark instance
Expand Down
2 changes: 1 addition & 1 deletion src/otg/datasource/intervals/jung.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class IntervalsJung(Intervals):
"""Interval dataset from Jung et al. 2019."""

@staticmethod
def read_jung(spark: SparkSession, path: str):
def read_jung(spark: SparkSession, path: str) -> DataFrame:
"""Read jung dataset.
Args:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,19 @@
from otg.dataset.gene_index import GeneIndex


class IntervalsThurnman(Intervals):
class IntervalsThurman(Intervals):
"""Interval dataset from Thurman et al. 2012."""

@staticmethod
def read_thurnman(spark: SparkSession, path: str):
"""Read thurnman dataset.
def read_thurman(spark: SparkSession, path: str) -> DataFrame:
"""Read thurman dataset.
Args:
spark (SparkSession): Spark session
path (str): Path to dataset
Returns:
DataFrame: DataFrame with raw thurnman data
DataFrame: DataFrame with raw thurman data
"""
thurman_schema = t.StructType(
[
Expand All @@ -45,28 +45,28 @@ def read_thurnman(spark: SparkSession, path: str):

@classmethod
def parse(
cls: type[IntervalsThurnman],
thurnman_raw: DataFrame,
cls: type[IntervalsThurman],
thurman_raw: DataFrame,
gene_index: GeneIndex,
lift: LiftOverSpark,
) -> Intervals:
"""Parse the Thurman et al. 2012 dataset.
Args:
thurnman_raw (DataFrame): raw Thurman et al. 2019 dataset
thurman_raw (DataFrame): raw Thurman et al. 2019 dataset
gene_index (GeneIndex): gene index
lift (LiftOverSpark): LiftOverSpark instance
Returns:
Intervals: Interval dataset containing Thurnman et al. 2012 data
Intervals: Interval dataset containing Thurman et al. 2012 data
"""
dataset_name = "thurman2012"
experiment_type = "dhscor"
pmid = "22955617"

return cls(
_df=(
thurnman_raw.select(
thurman_raw.select(
f.regexp_replace(f.col("chrom"), "chr", "").alias("chrom"),
"start",
"end",
Expand Down
6 changes: 3 additions & 3 deletions src/otg/v2g.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from otg.datasource.intervals.andersson import IntervalsAndersson
from otg.datasource.intervals.javierre import IntervalsJavierre
from otg.datasource.intervals.jung import IntervalsJung
from otg.datasource.intervals.thurnman import IntervalsThurnman
from otg.datasource.intervals.thurman import IntervalsThurman


@dataclass
Expand Down Expand Up @@ -76,8 +76,8 @@ def run(self: V2GStep) -> None:
gene_index_filtered,
lift,
).v2g(vi),
IntervalsThurnman.parse(
IntervalsThurnman.read_thurnman(self.session, self.thurnman_path),
IntervalsThurman.parse(
IntervalsThurman.read_thurman(self.session, self.thurman_path),
gene_index_filtered,
lift,
).v2g(vi),
Expand Down
File renamed without changes.
36 changes: 36 additions & 0 deletions tests/datasource/intervals/test_thurman.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
"""Test Thurman."""
from __future__ import annotations

import pytest
from pyspark.sql import DataFrame, SparkSession

from otg.common.Liftover import LiftOverSpark
from otg.dataset.gene_index import GeneIndex
from otg.datasource.intervals.thurman import IntervalsThurman


@pytest.fixture(scope="module")
def sample_intervals_thurman(spark: SparkSession) -> DataFrame:
"""Sample Andersson intervals."""
return IntervalsThurman.read_thurman(
spark, "tests/data_samples/thurman_sample.bed8"
)


def test_read_thurman(sample_intervals_thurman: DataFrame) -> None:
"""Test read_jung."""
assert isinstance(sample_intervals_thurman, DataFrame)


def test_thurman_intervals_from_source(
sample_intervals_thurman: DataFrame,
mock_gene_index: GeneIndex,
liftover_chain_37_to_38: LiftOverSpark,
) -> None:
"""Test IntervalsThurman creation with mock data."""
assert isinstance(
IntervalsThurman.parse(
sample_intervals_thurman, mock_gene_index, liftover_chain_37_to_38
),
IntervalsThurman,
)
36 changes: 0 additions & 36 deletions tests/datasource/intervals/test_thurnman.py

This file was deleted.

0 comments on commit dc5d2b6

Please sign in to comment.