|
1 | 1 | import base64 |
2 | 2 | from collections import defaultdict |
3 | | -from datetime import datetime |
4 | 3 | import json |
5 | 4 | import os |
6 | 5 | import requests |
|
17 | 16 | from seqr.utils.search.add_data_utils import trigger_data_loading, get_missing_family_samples, get_loaded_individual_ids, trigger_delete_families_search |
18 | 17 | from seqr.utils.search.elasticsearch.es_utils import get_elasticsearch_status, delete_es_index |
19 | 18 | from seqr.utils.search.utils import clickhouse_only, es_only, InvalidSearchException |
20 | | -from seqr.utils.file_utils import file_iter |
21 | 19 | from seqr.utils.logging_utils import SeqrLogger |
22 | 20 | from seqr.utils.middleware import ErrorsWarningsException |
23 | 21 | from seqr.utils.vcf_utils import validate_vcf_and_get_samples, get_vcf_list |
24 | 22 |
|
25 | 23 | from seqr.views.utils.airtable_utils import AirtableSession, LOADABLE_PDO_STATUSES, AVAILABLE_PDO_STATUS |
26 | | -from seqr.views.utils.dataset_utils import load_rna_seq, load_phenotype_prioritization_data_file, RNA_DATA_TYPE_CONFIGS, \ |
27 | | - post_process_rna_data, convert_django_meta_to_http_headers |
28 | | -from seqr.views.utils.file_utils import get_temp_file_path, load_uploaded_file |
| 24 | +from seqr.views.utils.dataset_utils import load_rna_seq, load_phenotype_prioritization_data_file, convert_django_meta_to_http_headers |
| 25 | +from seqr.views.utils.file_utils import load_uploaded_file |
29 | 26 | from seqr.views.utils.json_utils import create_json_response |
30 | | -from seqr.views.utils.json_to_orm_utils import update_model_from_json |
31 | 27 | from seqr.views.utils.pedigree_info_utils import get_validated_related_individuals, JsonConstants |
32 | 28 | from seqr.views.utils.permissions_utils import data_manager_required, pm_or_data_manager_required, get_internal_projects |
33 | 29 | from seqr.views.utils.terra_api_utils import anvil_enabled |
34 | 30 |
|
35 | | -from seqr.models import Sample, RnaSample, Individual, Project, PhenotypePrioritization |
| 31 | +from seqr.models import Sample, Individual, Project, PhenotypePrioritization |
36 | 32 |
|
37 | 33 | from settings import KIBANA_SERVER, KIBANA_ELASTICSEARCH_PASSWORD, KIBANA_ELASTICSEARCH_USER, \ |
38 | 34 | LOADING_DATASETS_DIR, LUIGI_UI_SERVICE_HOSTNAME, LUIGI_UI_SERVICE_PORT |
@@ -92,33 +88,6 @@ def _get_sample_file_path(file_dir, sample_guid): |
92 | 88 | return os.path.join(file_dir, f'{sample_guid}.json.gz') |
93 | 89 |
|
94 | 90 |
|
95 | | -@pm_or_data_manager_required |
96 | | -def load_rna_seq_sample_data(request, sample_guid): |
97 | | - sample = RnaSample.objects.get(guid=sample_guid) |
98 | | - logger.info(f'Loading outlier data for {sample.individual.individual_id}', request.user) |
99 | | - |
100 | | - request_json = json.loads(request.body) |
101 | | - file_name = request_json['fileName'] |
102 | | - data_type = request_json['dataType'] |
103 | | - config = RNA_DATA_TYPE_CONFIGS[data_type] |
104 | | - |
105 | | - file_path = get_temp_file_path(f'{file_name}/{sample_guid}.json.gz') |
106 | | - try: |
107 | | - data_rows = [json.loads(line) for line in file_iter(file_path, user=request.user)] |
108 | | - data_rows, error = post_process_rna_data(sample_guid, data_rows, **config.get('post_process_kwargs', {})) |
109 | | - except FileNotFoundError: |
110 | | - logger.error(f'No saved temp data found for {sample_guid} with file prefix {file_name}', request.user) |
111 | | - error = 'Data for this sample was not properly parsed. Please re-upload the data' |
112 | | - if error: |
113 | | - return create_json_response({'error': error}, status=400) |
114 | | - |
115 | | - model_cls = config['model_class'] |
116 | | - model_cls.bulk_create(request.user, [model_cls(sample=sample, **data) for data in data_rows], batch_size=1000) |
117 | | - update_model_from_json(sample, {'is_active': True}, user=request.user) |
118 | | - |
119 | | - return create_json_response({'success': True}) |
120 | | - |
121 | | - |
122 | 91 | def _notify_phenotype_prioritization_loaded(project, tool, num_samples): |
123 | 92 | send_project_notification( |
124 | 93 | project, |
|
0 commit comments