phc-ingestion 0.10.12__tar.gz → 0.10.13__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (64) hide show
  1. {phc-ingestion-0.10.12 → phc-ingestion-0.10.13}/PKG-INFO +1 -1
  2. {phc-ingestion-0.10.12 → phc-ingestion-0.10.13}/ingestion/nebula/manifest_assembler.py +42 -4
  3. {phc-ingestion-0.10.12 → phc-ingestion-0.10.13}/ingestion/nebula/process.py +3 -2
  4. {phc-ingestion-0.10.12 → phc-ingestion-0.10.13}/pyproject.toml +1 -1
  5. {phc-ingestion-0.10.12 → phc-ingestion-0.10.13}/PYPI.md +0 -0
  6. {phc-ingestion-0.10.12 → phc-ingestion-0.10.13}/ingestion/__init__.py +0 -0
  7. {phc-ingestion-0.10.12 → phc-ingestion-0.10.13}/ingestion/caris/__init__.py +0 -0
  8. {phc-ingestion-0.10.12 → phc-ingestion-0.10.13}/ingestion/caris/process.py +0 -0
  9. {phc-ingestion-0.10.12 → phc-ingestion-0.10.13}/ingestion/caris/util/__init__.py +0 -0
  10. {phc-ingestion-0.10.12 → phc-ingestion-0.10.13}/ingestion/caris/util/cnv.py +0 -0
  11. {phc-ingestion-0.10.12 → phc-ingestion-0.10.13}/ingestion/caris/util/detect_genome_ref.py +0 -0
  12. {phc-ingestion-0.10.12 → phc-ingestion-0.10.13}/ingestion/caris/util/hla.py +0 -0
  13. {phc-ingestion-0.10.12 → phc-ingestion-0.10.13}/ingestion/caris/util/ihc.py +0 -0
  14. {phc-ingestion-0.10.12 → phc-ingestion-0.10.13}/ingestion/caris/util/interpretation.py +0 -0
  15. {phc-ingestion-0.10.12 → phc-ingestion-0.10.13}/ingestion/caris/util/json.py +0 -0
  16. {phc-ingestion-0.10.12 → phc-ingestion-0.10.13}/ingestion/caris/util/metadata.py +0 -0
  17. {phc-ingestion-0.10.12 → phc-ingestion-0.10.13}/ingestion/caris/util/specimen_details.py +0 -0
  18. {phc-ingestion-0.10.12 → phc-ingestion-0.10.13}/ingestion/caris/util/structural.py +0 -0
  19. {phc-ingestion-0.10.12 → phc-ingestion-0.10.13}/ingestion/caris/util/tests.py +0 -0
  20. {phc-ingestion-0.10.12 → phc-ingestion-0.10.13}/ingestion/caris/util/tmb.py +0 -0
  21. {phc-ingestion-0.10.12 → phc-ingestion-0.10.13}/ingestion/caris/util/tsv.py +0 -0
  22. {phc-ingestion-0.10.12 → phc-ingestion-0.10.13}/ingestion/caris/util/vcf.py +0 -0
  23. {phc-ingestion-0.10.12 → phc-ingestion-0.10.13}/ingestion/foundation/__init__.py +0 -0
  24. {phc-ingestion-0.10.12 → phc-ingestion-0.10.13}/ingestion/foundation/process.py +0 -0
  25. {phc-ingestion-0.10.12 → phc-ingestion-0.10.13}/ingestion/foundation/util/__init__.py +0 -0
  26. {phc-ingestion-0.10.12 → phc-ingestion-0.10.13}/ingestion/foundation/util/cnv.py +0 -0
  27. {phc-ingestion-0.10.12 → phc-ingestion-0.10.13}/ingestion/foundation/util/fnv.py +0 -0
  28. {phc-ingestion-0.10.12 → phc-ingestion-0.10.13}/ingestion/foundation/util/ga4gh.py +0 -0
  29. {phc-ingestion-0.10.12 → phc-ingestion-0.10.13}/ingestion/foundation/util/interpretation.py +0 -0
  30. {phc-ingestion-0.10.12 → phc-ingestion-0.10.13}/ingestion/foundation/util/vcf_etl.py +0 -0
  31. {phc-ingestion-0.10.12 → phc-ingestion-0.10.13}/ingestion/generic/__init__.py +0 -0
  32. {phc-ingestion-0.10.12 → phc-ingestion-0.10.13}/ingestion/generic/process.py +0 -0
  33. {phc-ingestion-0.10.12 → phc-ingestion-0.10.13}/ingestion/generic/utils.py +0 -0
  34. {phc-ingestion-0.10.12 → phc-ingestion-0.10.13}/ingestion/nebula/__init__.py +0 -0
  35. {phc-ingestion-0.10.12 → phc-ingestion-0.10.13}/ingestion/nebula/constants.py +0 -0
  36. {phc-ingestion-0.10.12 → phc-ingestion-0.10.13}/ingestion/nextgen/__init__.py +0 -0
  37. {phc-ingestion-0.10.12 → phc-ingestion-0.10.13}/ingestion/nextgen/process.py +0 -0
  38. {phc-ingestion-0.10.12 → phc-ingestion-0.10.13}/ingestion/nextgen/util/alteration_table.py +0 -0
  39. {phc-ingestion-0.10.12 → phc-ingestion-0.10.13}/ingestion/nextgen/util/interpretation.py +0 -0
  40. {phc-ingestion-0.10.12 → phc-ingestion-0.10.13}/ingestion/nextgen/util/manifest_helpers.py +0 -0
  41. {phc-ingestion-0.10.12 → phc-ingestion-0.10.13}/ingestion/nextgen/util/nextgen_specific_genes.py +0 -0
  42. {phc-ingestion-0.10.12 → phc-ingestion-0.10.13}/ingestion/nextgen/util/pre_filter_somatic_vcf.py +0 -0
  43. {phc-ingestion-0.10.12 → phc-ingestion-0.10.13}/ingestion/nextgen/util/process_cnv.py +0 -0
  44. {phc-ingestion-0.10.12 → phc-ingestion-0.10.13}/ingestion/nextgen/util/process_manifest.py +0 -0
  45. {phc-ingestion-0.10.12 → phc-ingestion-0.10.13}/ingestion/nextgen/util/process_structural.py +0 -0
  46. {phc-ingestion-0.10.12 → phc-ingestion-0.10.13}/ingestion/nextgen/util/process_vcf.py +0 -0
  47. {phc-ingestion-0.10.12 → phc-ingestion-0.10.13}/ingestion/nextgen/util/types.py +0 -0
  48. {phc-ingestion-0.10.12 → phc-ingestion-0.10.13}/ingestion/resources/GRCh37_map.csv.gz +0 -0
  49. {phc-ingestion-0.10.12 → phc-ingestion-0.10.13}/ingestion/resources/GRCh38_map.csv.gz +0 -0
  50. {phc-ingestion-0.10.12 → phc-ingestion-0.10.13}/ingestion/shared_util/__init__.py +0 -0
  51. {phc-ingestion-0.10.12 → phc-ingestion-0.10.13}/ingestion/shared_util/coords_to_genes.py +0 -0
  52. {phc-ingestion-0.10.12 → phc-ingestion-0.10.13}/ingestion/shared_util/ga4gh.py +0 -0
  53. {phc-ingestion-0.10.12 → phc-ingestion-0.10.13}/ingestion/shared_util/gene_to_coords.py +0 -0
  54. {phc-ingestion-0.10.12 → phc-ingestion-0.10.13}/ingestion/shared_util/lambda_client.py +0 -0
  55. {phc-ingestion-0.10.12 → phc-ingestion-0.10.13}/ingestion/shared_util/open_maybe_gzipped.py +0 -0
  56. {phc-ingestion-0.10.12 → phc-ingestion-0.10.13}/ingestion/shared_util/tar.py +0 -0
  57. {phc-ingestion-0.10.12 → phc-ingestion-0.10.13}/ingestion/shared_util/types.py +0 -0
  58. {phc-ingestion-0.10.12 → phc-ingestion-0.10.13}/ingestion/vcf_standardization/Variant.py +0 -0
  59. {phc-ingestion-0.10.12 → phc-ingestion-0.10.13}/ingestion/vcf_standardization/__init__.py +0 -0
  60. {phc-ingestion-0.10.12 → phc-ingestion-0.10.13}/ingestion/vcf_standardization/standardize.py +0 -0
  61. {phc-ingestion-0.10.12 → phc-ingestion-0.10.13}/ingestion/vcf_standardization/util/__init__.py +0 -0
  62. {phc-ingestion-0.10.12 → phc-ingestion-0.10.13}/ingestion/vcf_standardization/util/af_helpers.py +0 -0
  63. {phc-ingestion-0.10.12 → phc-ingestion-0.10.13}/ingestion/vcf_standardization/util/dp_helpers.py +0 -0
  64. {phc-ingestion-0.10.12 → phc-ingestion-0.10.13}/ingestion/vcf_standardization/util/read_write.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: phc-ingestion
3
- Version: 0.10.12
3
+ Version: 0.10.13
4
4
  Summary: Functions for LifeOmic PHC genomic ingestions
5
5
  License: MIT
6
6
  Author-email: LifeOmic Development <development@lifeomic.com>
@@ -1,6 +1,10 @@
1
- from typing import Optional, TypedDict, Any
2
- from datetime import datetime
1
+ import re
2
+ import gzip
3
+ from typing import Optional, TypedDict, Any, Callable
4
+ from datetime import datetime, timezone
5
+ from dateutil import parser
3
6
  from ingestion.shared_util.lambda_client import LambdaClient
7
+ from ingestion.vcf_standardization.util.read_write import read_headers
4
8
  from ingestion.nebula.constants import (
5
9
  DATASET_SYSTEM,
6
10
  NEBULA_KIT_ID_SYSTEM,
@@ -9,7 +13,6 @@ from ingestion.nebula.constants import (
9
13
  NEBULA_BODY_SITE,
10
14
  NEBULA_INDICATION,
11
15
  )
12
- import re
13
16
 
14
17
 
15
18
  class HumanName(TypedDict):
@@ -49,11 +52,14 @@ class Practitioner(Resource):
49
52
 
50
53
 
51
54
  class ManifestAssembler:
52
- def __init__(self, ingestion_id: str, account_id: str, project_id: str, kit_id: str):
55
+ def __init__(
56
+ self, ingestion_id: str, account_id: str, project_id: str, kit_id: str, vcf_file_path: str
57
+ ):
53
58
  self.ingestion_id = ingestion_id
54
59
  self.account_id = account_id
55
60
  self.project_id = project_id
56
61
  self.kit_id = kit_id
62
+ self.vcf_file_path = vcf_file_path
57
63
  self.client = LambdaClient(
58
64
  "patient-service",
59
65
  {
@@ -142,6 +148,37 @@ class ManifestAssembler:
142
148
  "fullName": f"{first_name} {last_name}",
143
149
  }
144
150
 
151
+ def _safe(self, lambda_func: Callable[[], Any]) -> Any:
152
+ try:
153
+ return lambda_func()
154
+ except Exception as e:
155
+ return None
156
+
157
+ def __extract_report_date(self) -> dict[str, str]:
158
+ in_file = self.vcf_file_path
159
+ with gzip.open(in_file, "rt") if in_file.endswith(".gz") else open(in_file, "r") as f:
160
+ headers = read_headers(f)
161
+ for header in headers:
162
+ epoch_parts = re.search(r"Epoch=(\d+)", header)
163
+ epoch_time_raw = epoch_parts.group(1) if epoch_parts else None
164
+ epoch_time = self._safe(
165
+ lambda: datetime.fromtimestamp(int(epoch_time_raw) / 1000.0, tz=timezone.utc)
166
+ )
167
+ date_parts = re.search(r"Date=\"(.*)\"", header)
168
+ date_string_raw = date_parts.group(1) if date_parts else None
169
+ date_string = self._safe(
170
+ lambda: parser.parse(date_string_raw, tzinfos={"GST": "UTC+4"})
171
+ )
172
+
173
+ report_date = epoch_time or date_string
174
+ if report_date:
175
+ return {
176
+ "reportDate": report_date.astimezone(tz=timezone.utc)
177
+ .isoformat(timespec="milliseconds")
178
+ .replace("+00:00", "Z")
179
+ }
180
+ return {}
181
+
145
182
  def create_manifest(self) -> dict[str, Any]:
146
183
  patient = self.__fetch_patient_by_kit_id()
147
184
 
@@ -167,6 +204,7 @@ class ManifestAssembler:
167
204
  return {
168
205
  "name": "Nebula",
169
206
  "indexedDate": datetime.now().strftime("%Y-%m-%d"),
207
+ **self.__extract_report_date(),
170
208
  "reference": "GRCh38",
171
209
  "patientId": patient.get("id"),
172
210
  "mrn": self.__extract_elation_mrn(patient),
@@ -15,8 +15,9 @@ def process(vcf_file, out_path, file_name, source_file_id, ingestion_id, account
15
15
  )
16
16
 
17
17
  case_id = file_name
18
- manifest_assembler = ManifestAssembler(ingestion_id, account_id, project_id, case_id)
19
- manifest = manifest_assembler.create_manifest()
18
+ manifest = ManifestAssembler(
19
+ ingestion_id, account_id, project_id, case_id, vcf_file
20
+ ).create_manifest()
20
21
  base_vcf_file = os.path.basename(vcf_file)
21
22
  vcf_out = base_vcf_file.replace(".vcf", ".modified.vcf")
22
23
  vcf_final = base_vcf_file.replace(".vcf", ".modified.nrm.filtered.vcf")
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "phc-ingestion"
3
- version = "0.10.12"
3
+ version = "0.10.13"
4
4
  description = "Functions for LifeOmic PHC genomic ingestions"
5
5
  authors = [
6
6
  { name = "LifeOmic Development", email = "development@lifeomic.com" },
File without changes