Skip to content

Commit

Permalink
Merge pull request #25 from TheJacksonLaboratory/GW-160-geneset-metad…
Browse files Browse the repository at this point in the history
…ata-w-pub-info

Gw 160 geneset metadata with publication info
  • Loading branch information
francastell authored Feb 6, 2024
2 parents 6b5cd2b + 6f8b69d commit 840a0f9
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 5 deletions.
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 = "geneweaver-api"
version = "0.2.0a2"
version = "0.2.0a3"
description = "description"
authors = ["Jax Computational Sciences <cssc@jax.org>"]
packages = [
Expand Down
5 changes: 4 additions & 1 deletion src/geneweaver/api/controller/genesets.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,12 @@ def get_geneset_metadata(
],
user: UserInternal = Security(deps.full_user),
cursor: Optional[deps.Cursor] = Depends(deps.cursor),
include_pub_info: Optional[bool] = False,
) -> dict:
"""Get a geneset metadata by geneset id."""
response = genset_service.get_geneset_metadata(cursor, geneset_id, user)
response = genset_service.get_geneset_metadata(
cursor, geneset_id, user, include_pub_info
)

if "error" in response:
if response.get("message") == api_message.ACCESS_FORBIDDEN:
Expand Down
7 changes: 5 additions & 2 deletions src/geneweaver/api/services/geneset.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,22 @@
from psycopg import Cursor


def get_geneset_metadata(cursor: Cursor, geneset_id: int, user: User) -> dict:
def get_geneset_metadata(
cursor: Cursor, geneset_id: int, user: User, include_pub_info: bool = False
) -> dict:
"""Get a geneset metadata by geneset id.
@param cursor: DB cursor
@param geneset_id: geneset identifier
@param user: GW user
@param include_pub_info: bool (Optional with publication information)
@return: dictionary response (geneset).
"""
try:
if not is_geneset_readable_by_user(cursor, geneset_id, user):
return {"error": True, "message": message.ACCESS_FORBIDDEN}

geneset = db_geneset.by_id(cursor, geneset_id)
geneset = db_geneset.by_id(cursor, geneset_id, include_pub_info)
return {"geneset": geneset}

except Exception as err:
Expand Down
3 changes: 3 additions & 0 deletions tests/data/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@
test_geneset_data = {
"geneset_by_id_resp": json.loads(geneset_response_json),
"geneset_w_gene_id_type_resp": json.loads(geneset_w_gene_id_type_json),
"geneset_metadata_w_pub_info": json.loads(geneset_response_json).get(
"geneset_with_publication_info"
),
}

# Gene test data
Expand Down
34 changes: 33 additions & 1 deletion tests/data/response_geneset_1234.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,5 +74,37 @@
"gsv_date": "2020-05-05",
"ode_ref_id": "Hs.541341"
}
]
],
"geneset_with_publication_info": {
"geneset": {
"id": 1234,
"user_id": 51,
"file_id": 1715,
"curation_id": 3,
"species_id": 2,
"name": "Differential expression in heroin and cocaine abusers-Down-regulated Cocaine, Up-regulated Heroin",
"abbreviation": "UpRegHeroinDwnRegCocaine",
"pub_id": 6,
"description": "From the initial set of differentially expressed genes in post mortum nucleus accumbens of chronic heroin and cocaine abusers, this set contains genes upregulated in cocaine abusers but downregulated in heroin abusers.",
"count": 3,
"threshold_type": 3,
"threshold": "0.5",
"groups": "0",
"status": "normal",
"gene_id_type": -7,
"attribution": null,
"created": "2008-04-22",
"updated": "2020-05-06T09:19:44.883323",
"publication_id": 6,
"publication_authors": "Albertson DN, Schmidt CJ, Kapatos G, Bannon MJ",
"publication_title": "Distinctive profiles of gene expression in the human nucleus accumbens associated with cocaine and heroin abuse.",
"publication_abstract": "Drug abuse is thought to induce long-term cellular and behavioral adaptations as a result of alterations in gene expression. Understanding the molecular consequences of addiction may contribute to the development of better treatment strategies. This study utilized high-throughput Affymetrix microarrays to identify gene expression changes in the post-mortem nucleus accumbens of chronic heroin abusers. These data were analyzed independently and in relation to our previously reported data involving human cocaine abusers, in order to determine which expression changes were drug specific and which may be common to the phenomenon of addiction. A significant decrease in the expression of numerous genes encoding proteins involved in presynaptic release of neurotransmitter was seen in heroin abusers, a finding not seen in the cocaine-abusing cohort. Conversely, the striking decrease in myelin-related genes observed in cocaine abusers was not evident in our cohort of heroin subjects. Overall, little overlap in gene expression profiles was seen between the two drug-abusing cohorts: out of the approximately 39,000 transcripts investigated, the abundance of only 25 was significantly changed in both cocaine and heroin abusers, with nearly one-half of these being altered in opposite directions. These data suggest that the profiles of nucleus accumbens gene expression associated with chronic heroin or cocaine abuse are largely unique, despite what are thought to be common effects of these drugs on dopamine neurotransmission in this brain region. A re-examination of our current assumptions about the commonality of molecular mechanisms associated with substance abuse seems warranted.",
"publication_journal": "Neuropsychopharmacology : official publication of the American College of Neuropsychopharmacology",
"publication_volume": "31",
"publication_pages": "2304-12",
"publication_month": "Oct",
"publication_year": "2006",
"publication_pubmed_id": "16710320"
}
}
}
12 changes: 12 additions & 0 deletions tests/services/test_genset.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

geneset_by_id_resp = test_geneset_data.get("geneset_by_id_resp")
geneset_w_gene_id_type_resp = test_geneset_data.get("geneset_w_gene_id_type_resp")
geneset_metadata_w_pub_info = test_geneset_data.get("geneset_metadata_w_pub_info")


@patch("geneweaver.api.services.geneset.db_geneset")
Expand Down Expand Up @@ -107,3 +108,14 @@ def test_get_geneset_metadata(mock_genset_readable_func, mock_db_geneset):
response = geneset.get_geneset_metadata(None, 1234, None)

assert response.get("geneset") == geneset_by_id_resp["geneset"]


@patch("geneweaver.api.services.geneset.db_geneset")
@patch("geneweaver.api.services.geneset.is_geneset_readable_by_user")
def test_get_geneset_metadata_w_pub_info(mock_genset_readable_func, mock_db_geneset):
"""Test get geneset metadata by geneset id with publication info."""
mock_genset_readable_func.return_value = True
mock_db_geneset.by_id.return_value = geneset_metadata_w_pub_info
response = geneset.get_geneset_metadata(None, 1234, None, True)

assert response.get("geneset") == geneset_metadata_w_pub_info

0 comments on commit 840a0f9

Please sign in to comment.