Skip to content

Commit

Permalink
Merge branch 'feature/save-annotations-unfilled' of github.com:PMBio/…
Browse files Browse the repository at this point in the history
…deeprvat into feature/save-annotations-unfilled
  • Loading branch information
Mück committed Dec 11, 2024
2 parents 99d0df6 + f22d20a commit 59b12e6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
8 changes: 6 additions & 2 deletions deeprvat/annotations/annotations.py
Original file line number Diff line number Diff line change
Expand Up @@ -2031,7 +2031,10 @@ def create_gene_id_file(gtf_filepath: str, out_file: str):
@click.argument("out_file", type=click.Path())
@click.option("--keep_unfilled", type=click.Path(), default=None)
def select_rename_fill_annotations(
annotation_columns_yaml_file: str, annotations_path: str, out_file: str, keep_unfilled: str
annotation_columns_yaml_file: str,
annotations_path: str,
out_file: str,
keep_unfilled: str,
):
"""
Select, rename, and fill missing values in annotation columns based on a YAML configuration file.
Expand All @@ -2054,7 +2057,8 @@ def select_rename_fill_annotations(
annotations_path, columns=list(set(prior_names + key_cols))
)
anno_df.rename(columns=column_name_mapping, inplace=True)
if (keep_unfilled is not None): anno_df.to_parquet(keep_unfilled)
if keep_unfilled is not None:
anno_df.to_parquet(keep_unfilled)
anno_df.fillna(fill_value_mapping, inplace=True)
anno_df.to_parquet(out_file)

Expand Down
8 changes: 5 additions & 3 deletions tests/annotations/test_annotations.py
Original file line number Diff line number Diff line change
Expand Up @@ -735,6 +735,7 @@ def test_select_rename_fill_annotations(
written_results, expected_results[written_results.columns], check_exact=False
)


@pytest.mark.parametrize(
"test_data_name_dir, yaml_file, annotations, expected, expected_unfilled",
[
Expand Down Expand Up @@ -766,8 +767,7 @@ def test_select_rename_fill_annotations_unfilled(
annotations_path.as_posix(),
output_path.as_posix(),
"--keep_unfilled",
unfilled_path

unfilled_path,
]
result = cli_runner.invoke(annotations_cli, cli_parameters, catch_exceptions=False)
assert result.exit_code == 0
Expand All @@ -780,7 +780,9 @@ def test_select_rename_fill_annotations_unfilled(
written_results, expected_results[written_results.columns], check_exact=False
)
assert written_unfilled.shape == expected_unfilled.shape
assert_frame_equal(written_unfilled, expected_unfilled[written_unfilled.columns],check_exact=False)
assert_frame_equal(
written_unfilled, expected_unfilled[written_unfilled.columns], check_exact=False
)


@pytest.mark.parametrize(
Expand Down

0 comments on commit 59b12e6

Please sign in to comment.