-
Notifications
You must be signed in to change notification settings - Fork 17
Update AssessmentValue global API #955
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
Merged
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
6e7e6be
Epi export rewrite (#911)
rabstejnek ce11ca0
rewrite riskofbias exports (#921)
shapiromatron bf9afe9
Epimeta export rewrite (#922)
rabstejnek 4133cf5
Merge branch 'main' into export-rewrites
shapiromatron 3276f32
Merge branch 'main' into export-rewrites
shapiromatron c6003ad
started simple assessment value exports
dannypeterson dd47a5c
added more assessment fields
dannypeterson 513bc52
add helper method to filter querysets in custom api viewset actions
shapiromatron b26b388
added assessment fields, and year filter
dannypeterson fb9689a
added order_by and pagination fields to filterset
dannypeterson fa07b77
changed format_time to accomodate pandas update
dannypeterson f8c87e6
fixed filtering for df with empty values
dannypeterson 3be36ec
Merge branch 'main' into export-rewrites
shapiromatron 00e2dc7
add a few more options
shapiromatron File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,41 +1,108 @@ | ||
| import pandas as pd | ||
| from django.conf import settings | ||
| from ..common.exports import Exporter, ModelExport | ||
| from ..common.models import sql_display, str_m2m | ||
| from ..study.exports import StudyExport | ||
| from . import constants | ||
|
|
||
| from ..common.exports import ModelExport | ||
| from ..common.helper import FlatFileExporter | ||
| from ..common.models import sql_format | ||
| from .models import AssessmentValue | ||
|
|
||
| class AssessmentValueExport(ModelExport): | ||
| def get_value_map(self) -> dict: | ||
| return { | ||
| "evaluation_type": "evaluation_type_display", | ||
| "system": "system", | ||
| "value_type": "value_type_display", | ||
| "value": "value", | ||
| "value_unit": "value_unit", | ||
| "adaf": "adaf", | ||
| "confidence": "confidence", | ||
| "duration": "duration", | ||
| "basis": "basis", | ||
| "pod_type": "pod_type", | ||
| "pod_value": "pod_value", | ||
| "pod_unit": "pod_unit", | ||
| "uncertainty": "uncertainty_display", | ||
| "species_studied": "species_studied", | ||
| "evidence": "evidence", | ||
| "tumor_type": "tumor_type", | ||
| "extrapolation_method": "extrapolation_method", | ||
| "comments": "comments", | ||
| "extra": "extra", | ||
| "created": "created", | ||
| "last_updated": "last_updated", | ||
| } | ||
|
|
||
| class DSSToxExport(ModelExport): | ||
| def get_value_map(self): | ||
| def get_annotation_map(self, query_prefix: str) -> dict: | ||
| return { | ||
| "dtxsid": "dtxsid", | ||
| "dashboard_url": "dashboard_url", | ||
| "img_url": "img_url", | ||
| "content": "content", | ||
| "evaluation_type_display": sql_display( | ||
| query_prefix + "evaluation_type", constants.EvaluationType | ||
| ), | ||
| "value_type_display": sql_display(query_prefix + "value_type", constants.ValueType), | ||
| "uncertainty_display": sql_display( | ||
| query_prefix + "uncertainty", constants.UncertaintyChoices | ||
| ), | ||
| } | ||
|
|
||
| def prepare_df(self, df): | ||
| return self.format_time(df) | ||
|
|
||
|
|
||
| class AssessmentExport(ModelExport): | ||
| def get_value_map(self) -> dict: | ||
| return { | ||
| "id": "id", | ||
| "name": "name", | ||
| "cas": "cas", | ||
| "dtxsids": "dtxsids__name", | ||
| "year": "year", | ||
| "created": "created", | ||
| "last_updated": "last_updated", | ||
| } | ||
|
|
||
| def get_annotation_map(self, query_prefix): | ||
| img_url_str = ( | ||
| f"https://api-ccte.epa.gov/chemical/file/image/search/by-dtxsid/{{}}?x-api-key={settings.CCTE_API_KEY}" | ||
| if settings.CCTE_API_KEY | ||
| else "https://comptox.epa.gov/dashboard-api/ccdapp1/chemical-files/image/by-dtxsid/{}" | ||
| ) | ||
| return { | ||
| "dashboard_url": sql_format( | ||
| "https://comptox.epa.gov/dashboard/dsstoxdb/results?search={}", | ||
| query_prefix + "dtxsid", | ||
| ), | ||
| "img_url": sql_format(img_url_str, query_prefix + "dtxsid"), | ||
| "dtxsids__name": str_m2m(query_prefix + "dtxsids__dtxsid"), | ||
| } | ||
|
|
||
| def prepare_df(self, df): | ||
| return self.format_time(df) | ||
|
|
||
|
|
||
| class ValuesListExport(FlatFileExporter): | ||
| def build_df(self) -> pd.DataFrame: | ||
| return AssessmentValue.objects.get_df() | ||
| class AssessmentDetailExport(ModelExport): | ||
| def get_value_map(self) -> dict: | ||
| return { | ||
| "project_type": "project_type", | ||
| "project_status": "project_status_display", | ||
| "project_url": "project_url", | ||
| "peer_review_status": "peer_review_status_display", | ||
| "qa_id": "qa_id", | ||
| "qa_url": "qa_url", | ||
| "report_id": "report_id", | ||
| "report_url": "report_url", | ||
| "extra": "extra", | ||
| "created": "created", | ||
| "last_updated": "last_updated", | ||
| } | ||
|
|
||
| def prepare_df(self, df): | ||
| return self.format_time(df) | ||
|
|
||
| def get_annotation_map(self, query_prefix: str) -> dict: | ||
| return { | ||
| "project_status_display": sql_display( | ||
| query_prefix + "project_status", constants.Status | ||
| ), | ||
| "peer_review_status_display": sql_display( | ||
| query_prefix + "peer_review_status", constants.PeerReviewType | ||
| ), | ||
| } | ||
|
|
||
|
|
||
| class AssessmentExporter(Exporter): | ||
| def build_modules(self) -> list[ModelExport]: | ||
| return [ | ||
| AssessmentExport("assessment", "assessment"), | ||
| AssessmentDetailExport("assessment_detail", "assessment__details"), | ||
| AssessmentValueExport("assessment_value", ""), | ||
| StudyExport( | ||
| "study", "study", include=("id", "short_citation", "hero_id", "pubmed_id", "doi") | ||
| ), | ||
| ] | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.