Skip to content

Commit

Permalink
Update run-ngs-pipeline
Browse files Browse the repository at this point in the history
* Update :command:`run-ngs-pipeline` command to check input files more 
vigorously.
  • Loading branch information
sbslee committed Nov 27, 2021
1 parent 658d17f commit ff6a5bf
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ Changelog
* Rename :meth:`sdk.utils.Archive.check` method to :meth:`sdk.utils.Archive.check_type`.
* Add new method :meth:`sdk.utils.Archive.check_metadata`.
* Add new error ``sdk.utils.IncorrectMetadataError``.
* Update :command:`run-ngs-pipeline` command to check input files more vigorously.

0.8.0 (2021-11-20)
------------------
Expand Down
7 changes: 4 additions & 3 deletions pypgx/api/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,8 @@ def run_ngs_pipeline(
depth_of_coverage = sdk.Archive.from_file(depth_of_coverage)

depth_of_coverage.check_type('CovFrame[DepthOfCoverage]')
depth_of_coverage.check_metadata('Platform', platform)
depth_of_coverage.check_metadata('Assembly', assembly)

if control_statistics is None:
raise ValueError('SV detection requires SampleTable[Statistcs]')
Expand All @@ -164,9 +166,8 @@ def run_ngs_pipeline(
control_statistics = sdk.Archive.from_file(control_statistics)

control_statistics.check_type('SampleTable[Statistics]')

if depth_of_coverage.metadata['Platform'] != control_statistics.metadata['Platform']:
raise ValueError('Different platforms detected')
control_statistics.check_metadata('Platform', platform)
control_statistics.check_metadata('Assembly', assembly)

read_depth = utils.import_read_depth(gene, depth_of_coverage)
read_depth.to_file(f'{output}/read-depth.zip')
Expand Down
12 changes: 7 additions & 5 deletions pypgx/sdk/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@
import pandas as pd
from fuc import pyvcf, pycov, common, pybam

class SemanticTypeNotFoundError(Exception):
"""Raised when specified semantic type is not supported."""
class IncorrectMetadataError(Exception):
"""Raised when specified metadata is incorrect."""

class IncorrectSemanticTypeError(Exception):
"""Raised when specified semantic type is incorrect."""

class IncorrectMetadataError(Exception):
"""Raised when specified metadata is incorrect."""
class SemanticTypeNotFoundError(Exception):
"""Raised when specified semantic type is not supported."""

class Archive:
"""
Expand Down Expand Up @@ -122,10 +122,12 @@ def check_metadata(self, key, value):
Raise IncorrectMetadataError if the archive does not have specified
pair of key and value.
"""
semantic_type = self.metadata['SemanticType']
actual_value = self.metadata[key]
if actual_value != value:
raise IncorrectMetadataError(
f"Expected '{key}={value}' but found '{key}={actual_value}'")
f"Expected '{key}={value}' but found '{key}={actual_value}' "
f"for semantic type '{semantic_type}'")

def zipdir(dir, output):
"""
Expand Down

0 comments on commit ff6a5bf

Please sign in to comment.