Skip to content

Commit 9ec59c7

Browse files
authored
Merge pull request #309 from BU-ISCIII/develop
Release v1.1.0
2 parents b110cfa + 0d175ca commit 9ec59c7

15 files changed

+802
-469
lines changed

.github/workflows/pypi_publish.yml

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
name: Publish package python distribution to Pypi
22

33
on:
4-
push:
5-
branches: "main"
4+
release:
5+
types: [published]
6+
workflow_dispatch:
67

78
jobs:
89
build:
@@ -23,14 +24,13 @@ jobs:
2324
- name: Build a binary wheel and a source tarball
2425
run: python3 -m build
2526
- name: Store the distribution packages
26-
uses: actions/upload-artifact@v3
27+
uses: actions/upload-artifact@v4
2728
with:
2829
name: python-package-distributions
2930
path: dist/
3031

3132
publish-to-pypi:
3233
name: Publish dist to PyPI
33-
if: startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes
3434
needs:
3535
- build
3636
runs-on: ubuntu-latest
@@ -41,7 +41,7 @@ jobs:
4141
id-token: write
4242
steps:
4343
- name: Download all the dists
44-
uses: actions/download-artifact@v3
44+
uses: actions/download-artifact@v4
4545
with:
4646
name: python-package-distributions
4747
path: dist/
@@ -58,7 +58,7 @@ jobs:
5858
id-token: write
5959
steps:
6060
- name: Download all the dists
61-
uses: actions/download-artifact@v3
61+
uses: actions/download-artifact@v4
6262
with:
6363
name: python-package-distributions
6464
path: dist/

.github/workflows/test_modules.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ jobs:
3434
env:
3535
OUTPUT_LOCATION: ${{ github.workspace }}/tests/
3636
- name: Upload output file
37-
uses: actions/upload-artifact@v2
37+
uses: actions/upload-artifact@v4
3838
with:
3939
name: test-output
4040
path: output.txt
@@ -73,7 +73,7 @@ jobs:
7373
env:
7474
OUTPUT_LOCATION: ${{ github.workspace }}/tests/
7575
- name: Upload output file
76-
uses: actions/upload-artifact@v2
76+
uses: actions/upload-artifact@v4
7777
with:
7878
name: test-output
7979
path: output.txt

.github/workflows/test_sftp_handle.yml

+10-1
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,18 @@ jobs:
2424
echo "Current permission level is ${{ steps.checkAccess.outputs.user-permission }}"
2525
echo "Job originally triggered by ${{ github.actor }}"
2626
exit 1
27+
28+
sleep_to_ensure_concurrency:
29+
needs: security_check
30+
runs-on: ubuntu-latest
31+
steps:
32+
- name:
33+
run: sleep 10s
34+
shell: bash
2735

2836
test_sftp_handle:
29-
needs: security_check
37+
needs: [security_check, sleep_to_ensure_concurrency]
38+
if: github.repository_owner == 'BU-ISCIII'
3039
concurrency:
3140
group: ${{ github.repository }}-test_sftp_handle
3241
cancel-in-progress: false

CHANGELOG.md

+37-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ All notable changes to this project will be documented in this file.
44

55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

7-
## [1.1.0dev] - 2024-0X-0X : https://github.com/BU-ISCIII/relecov-tools/releases/tag/1.1.X
7+
## [1.X.Xdev] - 2024-XX-XX : https://github.com/BU-ISCIII/relecov-tools/releases/tag/1.X.X
88

99
### Credits
1010

@@ -22,7 +22,42 @@ Code contributions to the hotfix:
2222

2323
### Requirements
2424

25-
## [1.0.0] - 2024-0X-0X : https://github.com/BU-ISCIII/relecov-tools/releases/tag/1.0.0
25+
## [1.1.0] - 2024-09-13 : https://github.com/BU-ISCIII/relecov-tools/releases/tag/1.1.0
26+
27+
### Credits
28+
29+
Code contributions to the hotfix:
30+
31+
- [Pablo Mata](https://github.com/Shettland)
32+
- [Sara Monzón](https://github.com/saramonzon)
33+
34+
### Modules
35+
36+
- New logs-to-excel function to create an excel file given a list of log-summary.json files [#300](https://github.com/BU-ISCIII/relecov-tools/pull/300)
37+
38+
#### Added enhancements
39+
40+
- Included a way to extract pango-designation version in read-bioinfo-metadata [#299](https://github.com/BU-ISCIII/relecov-tools/pull/299)
41+
- Now log_summary.py also creates an excel file with the process logs [#300](https://github.com/BU-ISCIII/relecov-tools/pull/300)
42+
- Read-bioinfo-metadata splits files and data by batch of samples [#306](https://github.com/BU-ISCIII/relecov-tools/pull/306)
43+
- Included a sleep time in test_sftp-handle to avoid concurrency check failure [#308](https://github.com/BU-ISCIII/relecov-tools/pull/308)
44+
45+
#### Fixes
46+
47+
- Fixes in launch_pipeline including creation of samples_id.txt and joined validated json [#303](https://github.com/BU-ISCIII/relecov-tools/pull/303)
48+
- Fixed failing module_tests.yml workflow due to deprecated upload-artifact version [#308](https://github.com/BU-ISCIII/relecov-tools/pull/308)
49+
50+
#### Changed
51+
52+
- Changed pypi_publish action to publish on every release, no need to push tags [#308](https://github.com/BU-ISCIII/relecov-tools/pull/308)
53+
54+
#### Removed
55+
56+
- Removed only_samples argument in log_summary.py as it was not used in any module. [#300](https://github.com/BU-ISCIII/relecov-tools/pull/300)
57+
58+
### Requirements
59+
60+
## [1.0.0] - 2024-09-02 : https://github.com/BU-ISCIII/relecov-tools/releases/tag/1.0.0
2661

2762
### Credits
2863

README.md

+33-19
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,10 @@ relecov-tools is a set of helper tools for the assembly of the different element
2424
- [upload-to-ena](#upload-to-ena)
2525
- [upload-to-gisaid](#upload-to-gisaid)
2626
- [update-db](#update-db)
27+
- [launch-pipeline](#launch-pipeline)
28+
- [logs-to-excel](#logs-to-excel)
2729
- [build-schema](#build-schema)
2830
- [Mandatory Fields](#mandatory-fields)
29-
- [launch-pipeline](#launch-pipeline)
3031
- [custom logs](#custom-logs)
3132
- [Python package mode](#python-package-mode)
3233
- [Acknowledgements](#acknowledgements)
@@ -62,7 +63,7 @@ $ relecov-tools --help
6263
\ \ / |__ / |__ | |___ | | | \ /
6364
/ / \ | \ | | | | | | \ /
6465
/ |--| | \ |___ |___ |___ |___ |___| \/
65-
RELECOV-tools version 1.0.0
66+
RELECOV-tools version 1.1.0
6667
Usage: relecov-tools [OPTIONS] COMMAND [ARGS]...
6768
6869
Options:
@@ -160,7 +161,7 @@ Usage: relecov-tools read-bioinfo-metadata [OPTIONS]
160161
- Note: Software-specific configurations are available in [bioinfo_config.json](./relecov_tools/conf/bioinfo_config.json).
161162

162163
#### validate
163-
`validate` commands validate the data in json format outputted by `read-metadata` command against a json schema, in this case the relecov [schema specification](./relecov_tools/schema/relecov_schema.json).
164+
`validate` commands validate the data in json format outputted by `read-metadata` command against a json schema, in this case the relecov [schema specification](./relecov_tools/schema/relecov_schema.json). It also creates a summary of the errors and warnings found in excel format as a report to the users.
164165

165166
```
166167
$ relecov-tools validate --help
@@ -246,6 +247,35 @@ Usage: relecov-tools upload-to-gisaid [OPTIONS]
246247
-t, --type Select the type of information to upload to database [sample,bioinfodata,variantdata]
247248
-d, --databaseServer Name of the database server receiving the data [iskylims,relecov]
248249

250+
#### launch-pipeline
251+
Create the folder structure to execute the given pipeline for the latest sample batches after executing download, read-lab-metadata and validate modules. This module will create symbolic links for each sample and generate the necessary files for pipeline execution using the information from validated_BATCH-NAME_DATE.json.
252+
```
253+
Usage: relecov-tools launch-pipeline [OPTIONS]
254+
255+
Create the symbolic links for the samples which are validated to prepare for
256+
bioinformatics pipeline execution.
257+
258+
Options:
259+
-i, --input PATH Path to the input folder where sample files are located
260+
-t, --template PATH Path to the pipeline template folder to be copied in the output folder
261+
-c, --config PATH Path to the the template config file
262+
-o, --out_dir PATH Path to output folder
263+
--help Show this message and exit.
264+
```
265+
266+
#### logs-to-excel
267+
Creates an xlsx file with all the entries found for a specified laboratory in a given set of log_summary.json files (from log-summary module). The laboratory name must match the name of one of the keys in the provided logs to work.
268+
```
269+
Usage: relecov-tools logs-to-excel [OPTIONS]
270+
271+
Creates a merged xlsx report from all the log summary jsons given as input
272+
273+
Options:
274+
-l, --lab_name Name for target laboratory in log-summary.json files
275+
-o, --output_folder Path to output folder where xlsx file is saved
276+
-f, --files Paths to log_summary.json files to merge into xlsx file, called once per file
277+
```
278+
249279
### build-schema
250280
The `build-schema` module provides functionality to generate and manage JSON Schema files based on database definitions from Excel spreadsheets. It automates the creation of JSON Schemas, including validation, drafting, and comparison with existing schemas.
251281

@@ -289,22 +319,6 @@ required (Y/N): Indicates if the property is required (Y) or optional (N).
289319
complex_field (Y/N): Indicates if the property is a complex (nested) field (Y) or a standard field (N).
290320
```
291321

292-
#### launch-pipeline
293-
Create the folder structure to execute the given pipeline for the latest sample batches after executing download, read-lab-metadata and validate modules. This module will create symbolic links for each sample and generate the necessary files for pipeline execution using the information from validated_BATCH-NAME_DATE.json.
294-
```
295-
Usage: relecov-tools launch-pipeline [OPTIONS]
296-
297-
Create the symbolic links for the samples which are validated to prepare for
298-
bioinformatics pipeline execution.
299-
300-
Options:
301-
-i, --input PATH Path to the input folder where sample files are located
302-
-t, --template PATH Path to the pipeline template folder to be copied in the output folder
303-
-c, --config PATH Path to the the template config file
304-
-o, --out_dir PATH Path to output folder
305-
--help Show this message and exit.
306-
```
307-
308322
#### custom logs
309323
After executing each of these modules, you may find a custom log report in json format named "DATE_EXECUTED-MODULE_log_summary.json. These custom log summaries can be useful to detect errors in metadata in order to fix them and/or notify the users.
310324

relecov_tools/__main__.py

+72-4
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
#!/usr/bin/env python
22
import logging
3-
4-
# import re
3+
import os
4+
import json
55

66
# from rich.prompt import Confirm
77
import click
88
import relecov_tools.download_manager
9+
import relecov_tools.log_summary
910
import rich.console
1011
import rich.logging
1112
import rich.traceback
@@ -60,7 +61,7 @@ def run_relecov_tools():
6061
)
6162

6263
# stderr.print("[green] `._,._,'\n", highlight=False)
63-
__version__ = "1.0.0"
64+
__version__ = "1.1.0"
6465
stderr.print(
6566
"\n" "[grey39] RELECOV-tools version {}".format(__version__), highlight=False
6667
)
@@ -487,7 +488,7 @@ def launch_pipeline(input, template, output, config):
487488

488489

489490
# schema builder
490-
@relecov_tools_cli.command(help_priority=13)
491+
@relecov_tools_cli.command(help_priority=14)
491492
@click.option(
492493
"-i",
493494
"--input_file",
@@ -523,5 +524,72 @@ def build_schema(input_file, schema_base, draft_version, diff, out_dir):
523524
schema_update.handle_build_schema()
524525

525526

527+
@relecov_tools_cli.command(help_priority=15)
528+
@click.option(
529+
"-l",
530+
"--lab_code",
531+
type=click.Path(),
532+
help="Name for target laboratory in log-summary.json files",
533+
required=True,
534+
)
535+
@click.option(
536+
"-o",
537+
"--output_folder",
538+
type=click.Path(),
539+
help="Path to output folder where xlsx file is saved",
540+
required=False,
541+
)
542+
@click.option(
543+
"-f",
544+
"--files",
545+
help="Paths to log_summary.json files to merge into xlsx file, called once per file",
546+
required=True,
547+
multiple=True,
548+
)
549+
def logs_to_excel(lab_code, output_folder, files):
550+
"""Creates a merged xlsx report from all the log summary jsons given as input"""
551+
all_logs = []
552+
full_paths = [os.path.realpath(f) for f in files]
553+
for file in full_paths:
554+
if not os.path.exists(file):
555+
stderr.print(f"[red]File {file} does not exist")
556+
continue
557+
try:
558+
with open(file, "r") as f:
559+
all_logs.append(json.load(f)[lab_code])
560+
except Exception as e:
561+
stderr.print(f"[red]Could extract data from {file}: {e}")
562+
if not all_logs:
563+
stderr.print("All provided files were empty.")
564+
exit(1)
565+
logsum = relecov_tools.log_summary.LogSum(output_location=output_folder)
566+
merged_logs = logsum.merge_logs(key_name=lab_code, logs_list=all_logs)
567+
final_logs = logsum.prepare_final_logs(logs=merged_logs)
568+
logsum.create_logs_excel(logs=final_logs)
569+
570+
571+
@relecov_tools_cli.command(help_priority=16)
572+
@click.option(
573+
"-c",
574+
"--config_file",
575+
type=click.Path(),
576+
help="Path to config file in yaml format",
577+
required=True,
578+
)
579+
@click.option(
580+
"-o",
581+
"--output_folder",
582+
type=click.Path(),
583+
help="Path to the base schema file. This file is used as a reference to compare it with the schema generated using this module. (Default: installed schema in 'relecov-tools/relecov_tools/schema/relecov_schema.json')",
584+
required=False,
585+
)
586+
def wrapper(config_file, output_folder):
587+
"""Executes the modules in config file sequentially"""
588+
process_wrapper = relecov_tools.dataprocess_wrapper.ProcessWrapper(
589+
config_file=config_file, output_folder=output_folder
590+
)
591+
process_wrapper.run_wrapper()
592+
593+
526594
if __name__ == "__main__":
527595
run_relecov_tools()

0 commit comments

Comments
 (0)