Skip to content

Commit

Permalink
update to unittests; in-work effort
Browse files Browse the repository at this point in the history
  • Loading branch information
n8sean committed Sep 7, 2023
1 parent b6dc5f1 commit e5be9b0
Show file tree
Hide file tree
Showing 10 changed files with 68 additions and 166 deletions.
195 changes: 48 additions & 147 deletions poetry.lock

Large diffs are not rendered by default.

5 changes: 0 additions & 5 deletions poetrybuild.out

This file was deleted.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ pandas = "^2.0.3"
snakemake = "^7.32.3"
pysam = "^0.21.0"
ryd = "^0.7.1"
pydantic = "^2.0.0"
pydantic = "^1.10.12"
networkx = "^3.1"
Jinja2 = "^3.1.2"
more-itertools = "^10.1.0"
Expand Down
2 changes: 1 addition & 1 deletion src/cgr_gwas_qc/cli/pre_flight.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ def main(
def check_config(filename: Path) -> Config:
try:
data = yaml.load(filename)
config = Config.model_validate(data)
config = Config.parse_obj(data)
except Exception as err:
if isinstance(err, OSError):
msg = err.args[1]
Expand Down
4 changes: 2 additions & 2 deletions src/cgr_gwas_qc/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def __init__(self, root: Path, user_config: Path, sample_sheet_file: Path):
self.sample_sheet_file: Path = sample_sheet_file

data = yaml.load(self.user_config)
self._config = Config.model_validate(data)
self._config = Config.parse_obj(data)
self._sample_sheet: pd.DataFrame = sample_sheet.read(self.sample_sheet_file)
self._cluster_groups = sorted(self.ss.cluster_group.unique())

Expand Down Expand Up @@ -244,4 +244,4 @@ def serialize(data):
cleaned[k] = v
return cleaned

yaml.write(serialize(cfg.model_dump(exclude_none=exclude_none, **kwargs)), Path(yaml_file))
yaml.write(serialize(cfg.dict(exclude_none=exclude_none, **kwargs)), Path(yaml_file))
4 changes: 2 additions & 2 deletions src/cgr_gwas_qc/models/config/user_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def validate_gtc_pattern(cls, v):

return v

@root_validator(skip_on_failure=True)
@root_validator
def check_ped_map(cls, values):
ped, map_ = values.get("ped"), values.get("map")
if ped is not None and map_ is None:
Expand All @@ -116,7 +116,7 @@ def check_ped_map(cls, values):

return values

@root_validator(skip_on_failure=True)
@root_validator
def check_bed_bim_fam(cls, values):
bed, bim, fam = values.get("bed"), values.get("bim"), values.get("fam")

Expand Down
4 changes: 2 additions & 2 deletions src/cgr_gwas_qc/testing/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ def make_cgr_sample_sheet(self, **kwargs) -> U:
Raises:
ValueError: You must have provided a working directory when
instantiating the object.
instantiating the object.
Returns:
Creates a file ``working_dir/cgr_sample_sheet.csv`` and returns
Expand Down Expand Up @@ -169,7 +169,7 @@ def add_user_files(self, entry_point: str = "bed", copy: bool = True) -> U:
Args:
entry_point: Which entry point to use ("gtc", "ped", or "bed").
Defaults to "bed".
Defaults to "bed".
"""
if self.working_dir and copy:
Expand Down
6 changes: 3 additions & 3 deletions tests/cli/test_pre_flight.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def test_check_reference_files_bpm_error(fake_cfg: ConfigMgr, capsys):
# GIVEN: a working directory
with chdir(fake_cfg.root):
# WHEN: Run `cgr pre-flight`
reference_files = fake_cfg.config.reference_files.model_copy()
reference_files = fake_cfg.config.reference_files.copy()
reference_files.illumina_manifest_file = "missing.bpm"
pre_flight.check_reference_files(reference_files)
# THEN: No errors and `cgr_sample_sheet.csv` exists
Expand All @@ -100,7 +100,7 @@ def test_check_reference_files_vcf_error(fake_cfg: ConfigMgr, capsys):
# GIVEN: a working directory
with chdir(fake_cfg.root):
# WHEN: Run `cgr pre-flight`
reference_files = fake_cfg.config.reference_files.model_copy()
reference_files = fake_cfg.config.reference_files.copy()
reference_files.thousand_genome_vcf = "missing.vfc"
pre_flight.check_reference_files(reference_files)
# THEN: No errors and `cgr_sample_sheet.csv` exists
Expand All @@ -112,7 +112,7 @@ def test_check_reference_files_tbi_error(fake_cfg: ConfigMgr, capsys):
# GIVEN: a working directory
with chdir(fake_cfg.root):
# WHEN: Run `cgr pre-flight`
reference_files = fake_cfg.config.reference_files.model_copy()
reference_files = fake_cfg.config.reference_files.copy()
reference_files.thousand_genome_tbi = "missing.vfc.tbi"
pre_flight.check_reference_files(reference_files)
# THEN: No errors and `cgr_sample_sheet.csv` exists
Expand Down
4 changes: 4 additions & 0 deletions tests/cluster_profiles/test_cgems.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
os.environ.get("GITHUB_ACTIONS", "false") == "true", reason="Broken on GitHub Actions"
)
def test_cgems_submission_end_to_end(tmp_path, qsub):
# tmp_path = "src/cgr_gwas_qc/testing"
print("!!!!!!!!!")
print(tmp_path)
print("!!!!!!!!!")
with pytest.raises(SystemExit) as exc:
args = [
"-j",
Expand Down
8 changes: 5 additions & 3 deletions tests/workflow/scripts/test_sample_concordance.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,14 @@ def test_add_expected_replicate_missing_pair(fake_cfg, concordance):
# GIVEN: That I have an expected replicate that is not in the concordance table
ss = fake_cfg.ss.copy()
ss.loc[0, "replicate_ids"] = "SP00001|SP10000" # Add an expected replicate
ss = ss.append(
pd.Series({"Sample_ID": "SP10000", "replicate_ids": "SP00001|SP10000"}), ignore_index=True
)
pseudo_data = pd.DataFrame({"Sample_ID": ["SP10000"], "replicate_ids": ["SP00001|SP10000"]})
ss = pd.concat([ss, pseudo_data], ignore_index=True)

# THEN: I should add that pair and flag them as an expected_replicate
df = concordance.pipe(sample_concordance._add_expected_replicates, ss)
print("!!!!!!!!")
print(df["is_expected_replicate"].values)
print("!!!!!!!!")
assert 2 == df.is_expected_replicate.sum()


Expand Down

0 comments on commit e5be9b0

Please sign in to comment.