Skip to content

Sn DSA Sample Information #286

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ smaht-portal
Change Log
----------

0.109.1
=======
`PR 286 Sn DSA Sample Information <https://github.com/smaht-dac/smaht-portal/pull/286>`_
* Modify calculated properties for Supplementary File to show up in File Overview Page: `sample_summary` and `data_generation_summary` to pull from `DonorSpecificAssembly.derived_from.file_sets`

0.109.0
=======
`PR 280 SN Assay info <https://github.com/smaht-dac/smaht-portal/pull/280>`_
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "encoded"
version = "0.109.0"
version = "0.109.1"
description = "SMaHT Data Analysis Portal"
authors = ["4DN-DCIC Team <[email protected]>"]
license = "MIT"
Expand Down
7 changes: 6 additions & 1 deletion src/encoded/item_utils/file.py
Original file line number Diff line number Diff line change
Expand Up @@ -420,4 +420,9 @@ def get_associated_files_status(
request_handler,
get_file_sets(file),
partial(file_set.get_associated_files_status, request_handler, at_id)
)
)


def get_override_group_coverage(file: Dict[str, Any]) -> str:
"""Get override group coverage from properties."""
return file.get("override_group_coverage","")
202 changes: 200 additions & 2 deletions src/encoded/item_utils/supplementary_file.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,19 @@
from typing import Any, Dict, Union, Optional, List
from functools import partial

from .utils import RequestHandler, get_property_value_from_identifier, get_property_values_from_identifiers
from . import (
donor_specific_assembly as dsa_utils,
file as file_utils,
item as item_utils
item as item_utils,
file_set as file_set_utils,
library as library_utils,
sample as sample_utils,
tissue as tissue_utils,
cell_culture as cell_culture_utils,
cell_culture_mixture as cell_culture_mixture_utils,
cell_line as cell_line_utils,
sequencing as sequencing_utils
)

def is_supplementary_file(properties: Dict[str, Any]) -> bool:
Expand Down Expand Up @@ -66,6 +76,68 @@ def get_derived_from_file_sets(
return properties.get("file_sets", [])


def get_sequencings(
properties: Dict[str, Any], request_handler: Optional[RequestHandler] = None
) -> List[Union[str, Dict[str, Any]]]:
"""Get sequencings associated with file."""
if request_handler:
return get_property_values_from_identifiers(
request_handler,
get_derived_from_file_sets(properties, request_handler),
file_set_utils.get_sequencing
)
return properties.get("sequencing", [])


def get_sequencers(
properties: Dict[str, Any], request_handler: RequestHandler
) -> List[str]:
"""Get sequencers associated with file."""
sequencings = get_sequencings(properties, request_handler)
return get_property_values_from_identifiers(
request_handler, sequencings, sequencing_utils.get_sequencer
)


def get_libraries(
properties: Dict[str, Any], request_handler: Optional[RequestHandler] = None
) -> List[Union[str, Dict[str, Any]]]:
"""Get libraries associated with file from derived_from files."""
if request_handler:
return get_property_values_from_identifiers(
request_handler,
get_derived_from_file_sets(properties,request_handler),
file_set_utils.get_libraries
)
return properties.get("libraries", [])


def get_analytes(
properties: Dict[str, Any], request_handler: Optional[RequestHandler] = None
) -> List[Union[str, Dict[str, Any]]]:
"""Get analytes associated with file from derived_from files."""
if request_handler:
return get_property_values_from_identifiers(
request_handler,
get_libraries(properties, request_handler),
library_utils.get_analytes,
)
return properties.get("analytes", [])


def get_assays(
properties: Dict[str, Any], request_handler: Optional[RequestHandler] = None
) -> List[Union[str, Dict[str, Any]]]:
"""Get assays associated with file."""
if request_handler:
return get_property_values_from_identifiers(
request_handler,
get_libraries(properties, request_handler),
library_utils.get_assay,
)
return properties.get("assays", [])


def get_dsa_software(
properties: Dict[str, Any], request_handler: Optional[RequestHandler] = None
) -> List[Union[str, Dict[str, Any]]]:
Expand All @@ -76,4 +148,130 @@ def get_dsa_software(
get_donor_specific_assembly(properties),
dsa_utils.get_software,
)
return []
return []


def get_samples(
properties: Dict[str, Any], request_handler: Optional[RequestHandler] = None
) -> List[Union[str, Dict[str, Any]]]:
"""Get samples associated with file."""
if request_handler:
return get_property_values_from_identifiers(
request_handler,
get_derived_from_file_sets(properties, request_handler),
partial(file_set_utils.get_samples, request_handler=request_handler),
)
return properties.get("samples", [])


def get_sample_sources(
properties: Dict[str, Any], request_handler: Optional[RequestHandler] = None
) -> List[Union[str, Dict[str, Any]]]:
"""Get sample sources associated with file."""
if request_handler:
return get_property_values_from_identifiers(
request_handler,
get_samples(properties, request_handler),
sample_utils.get_sample_sources,
)
return properties.get("sample_sources", [])


def get_tissues(
properties: Dict[str, Any], request_handler: Optional[RequestHandler] = None
) -> List[Union[str, Dict[str, Any]]]:
"""Get tissues associated with file."""
sample_sources = get_sample_sources(properties, request_handler=request_handler)
if request_handler:
return [
sample_source
for sample_source in sample_sources
if tissue_utils.is_tissue(request_handler.get_item(sample_source))
]
return [
sample_source
for sample_source in sample_sources
if isinstance(sample_source, dict) and tissue_utils.is_tissue(sample_source)
]


def get_cell_culture_mixtures(
properties: Dict[str, Any], request_handler: Optional[RequestHandler] = None
) -> List[Union[str, Dict[str, Any]]]:
"""Get cell culture mixtures associated with file."""
sample_sources = get_sample_sources(properties, request_handler=request_handler)
if request_handler:
return [
sample_source
for sample_source in sample_sources
if cell_culture_mixture_utils.is_cell_culture_mixture(
request_handler.get_item(sample_source)
)
]
return [
sample_source
for sample_source in sample_sources
if isinstance(sample_source, dict)
and cell_culture_mixture_utils.is_cell_culture_mixture(sample_source)
]


def get_cell_cultures(
properties: Dict[str, Any], request_handler: RequestHandler
) -> List[str]:
"""Get cell cultures associated with file."""
sample_sources = get_sample_sources(properties, request_handler=request_handler)
cell_culture_mixtures = get_cell_culture_mixtures(
properties, request_handler=request_handler
)
cell_cultures_from_mixtures = get_property_values_from_identifiers(
request_handler, cell_culture_mixtures, cell_culture_mixture_utils.get_cell_cultures
)
direct_cell_cultures = [
sample_source
for sample_source in sample_sources
if cell_culture_utils.is_cell_culture(request_handler.get_item(sample_source))
]
return list(set(cell_cultures_from_mixtures + direct_cell_cultures))


def get_cell_lines(
properties: Dict[str, Any], request_handler: RequestHandler
) -> List[Union[str, Dict[str, Any]]]:
"""Get cell lines associated with file."""
cell_cultures = get_cell_cultures(properties, request_handler)
cell_culture_mixtures = get_cell_culture_mixtures(
properties, request_handler=request_handler
)
return list(
set(
get_property_values_from_identifiers(
request_handler, cell_cultures, cell_culture_utils.get_cell_line
)
+ get_property_values_from_identifiers(
request_handler,
cell_culture_mixtures,
partial(cell_culture_mixture_utils.get_cell_lines, request_handler),
)
)
)


def get_donors(
properties: Dict[str, Any], request_handler: Optional[RequestHandler] = None
) -> List[Union[str, Dict[str, Any]]]:
"""Get donors associated with file."""
if request_handler:
tissues = get_tissues(properties, request_handler)
cell_lines = get_cell_lines(properties, request_handler)
return list(
set(
get_property_values_from_identifiers(
request_handler, tissues, tissue_utils.get_donor
)
+ get_property_values_from_identifiers(
request_handler, cell_lines, partial(cell_line_utils.get_source_donor, request_handler)
)
)
)
return properties.get("donors", [])
6 changes: 6 additions & 0 deletions src/encoded/schemas/donor_specific_assembly.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
{
"$ref": "mixins.json#/attribution"
},
{
"$ref": "mixins.json#/code"
},
{
"$ref": "mixins.json#/description"
},
Expand Down Expand Up @@ -64,6 +67,9 @@
"version": {
"description": "Version of the assembly"
},
"code": {
"pattern": "^[A-Za-z0-9]{3,}$"
},
"submitted_id": {
"pattern": "^[A-Z0-9]{3,}_DONOR-SPECIFIC-ASSEMBLY_[A-Z0-9-_.]{4,}$"
},
Expand Down
Loading
Loading