Skip to content

Commit

Permalink
Add IntegerSum transformation function (#50)
Browse files Browse the repository at this point in the history
* Add IntegerSum transformation function

* Bump version

* Update README
  • Loading branch information
lkuchenb authored Sep 8, 2023
1 parent 8ac008c commit e1b4a43
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 4 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,21 +62,21 @@ We recommend using the provided Docker container.

A pre-build version is available at [docker hub](https://hub.docker.com/repository/docker/ghga/metldata):
```bash
docker pull ghga/metldata:0.4.3
docker pull ghga/metldata:0.4.4
```

Or you can build the container yourself from the [`./Dockerfile`](./Dockerfile):
```bash
# Execute in the repo's root dir:
docker build -t ghga/metldata:0.4.3 .
docker build -t ghga/metldata:0.4.4 .
```

For production-ready deployment, we recommend using Kubernetes, however,
for simple use cases, you could execute the service using docker
on a single server:
```bash
# The entrypoint is preconfigured:
docker run -p 8080:8080 ghga/metldata:0.4.3 --help
docker run -p 8080:8080 ghga/metldata:0.4.4 --help
```

If you prefer not to use containers, you may install the service from source:
Expand Down
2 changes: 1 addition & 1 deletion metldata/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@

"""Short description of package""" # Please adapt to package

__version__ = "0.4.3"
__version__ = "0.4.4"
14 changes: 14 additions & 0 deletions metldata/builtin_transformations/aggregate/func.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,20 @@ def func(cls, data: Iterable[Any]) -> int:
return sum(1 for _ in data)


@register_function
class IntegerSumAggregation(AggregationFunction):
"""Transformation that returns the sum for a given sequence of integer
values."""

result_range_name = "integer"
result_range_cls_def = None
result_multivalued = False

@classmethod
def func(cls, data: Iterable[int]) -> int:
return sum(data)


class ElementCountAggregation(AggregationFunction, ABC):
"""Aggregation that returns the counts of unique elements in the given data."""

Expand Down
7 changes: 7 additions & 0 deletions tests/fixtures/transformations/aggregate/default/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -99,3 +99,10 @@ aggregations:
- study_files.format
- analysis_process_output_files.format
function: StringElementCount
- output_path: file_summary.stats.total_size
input_paths:
- sequencing_process_files.size
- sample_files.size
- study_files.size
- analysis_process_output_files.size
function: IntegerSum
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ dataset_stats:
count: 4
- value: VCF
count: 3
total_size: 753721
accession: GHGAD03742971815534
- title: The B dataset
types:
Expand Down Expand Up @@ -71,4 +72,5 @@ dataset_stats:
count: 6
- value: VCF
count: 6
total_size: 1663486
accession: GHGAD97673713575489
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,9 @@ slots:
value:
name: value
from_schema: https://w3id.org/GHGA-Submission-Metadata-Schema
total_size:
name: total_size
from_schema: https://w3id.org/GHGA-Submission-Metadata-Schema
dataset_stats:
name: dataset_stats
from_schema: https://w3id.org/GHGA-Submission-Metadata-Schema
Expand Down Expand Up @@ -427,6 +430,7 @@ classes:
from_schema: https://w3id.org/GHGA-Submission-Metadata-Schema
slots:
- format
- total_size
slot_usage:
format:
name: format
Expand All @@ -436,6 +440,12 @@ classes:
range: StringValueCount
inlined: true
inlined_as_list: true
total_size:
name: total_size
multivalued: false
domain_of:
- AutoGeneratedClass3
range: integer
AutoGeneratedClass4:
name: AutoGeneratedClass4
from_schema: https://w3id.org/GHGA-Submission-Metadata-Schema
Expand Down

0 comments on commit e1b4a43

Please sign in to comment.