Skip to content

Commit 44d95f2

Browse files
authored
Merge pull request #5107 from broadinstitute/dev
Dev
2 parents 78ecee1 + bcf2f0e commit 44d95f2

File tree

9 files changed

+328
-254
lines changed

9 files changed

+328
-254
lines changed

panelapp/pa_locus_list_api_tests.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ def test_import_all_panels(self):
7171

7272
responses.add(responses.GET, au_panels_p1_url, json=au_panels_p1_json, status=200)
7373
responses.add(responses.GET, au_panels_p2_url, json=au_panels_p2_json, status=200)
74+
responses.add(responses.GET, au_genes_url, status=429)
7475
responses.add(responses.GET, au_genes_url, json=au_genes_json, status=200)
7576
responses.add(responses.GET, uk_panels_p1_url, json=uk_panels_p1_json, status=200)
7677
responses.add(responses.GET, uk_genes_url, json=uk_genes_json, status=200)

panelapp/panelapp_utils.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from django.db import transaction
55
from django.utils import timezone
66
from tenacity import retry, wait_exponential, stop_after_attempt, retry_if_exception_type
7+
from time import sleep
78
from urllib3.exceptions import MaxRetryError
89

910
from panelapp.models import PaLocusList, PaLocusListGene
@@ -17,6 +18,8 @@
1718

1819
REQUEST_TIMEOUT_S = 300
1920

21+
class TooManyRequestsError(Exception):
22+
pass
2023

2124
def import_all_panels(user, panel_app_api_url, label=None):
2225
def _extract_ensembl_id_from_json(raw_gene_json):
@@ -118,12 +121,15 @@ def _get_all_panels(panels_url, all_results):
118121

119122
def _get_all_genes(genes_url: str, results_by_panel_id: dict):
120123
@retry(
121-
retry=retry_if_exception_type(MaxRetryError),
124+
retry=retry_if_exception_type((MaxRetryError, TooManyRequestsError)),
122125
wait=wait_exponential(multiplier=1, min=4, max=10),
123126
stop=stop_after_attempt(5),
124127
)
125128
def _get(url):
126129
resp = requests.get(url, timeout=REQUEST_TIMEOUT_S)
130+
if resp.status_code == 429:
131+
sleep(10)
132+
raise TooManyRequestsError()
127133
return resp.json()
128134

129135
resp_json = _get(genes_url)

seqr/management/commands/reload_clinvar_all_variants.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,9 @@ def parse_pathogenicity_and_assertions(classified_record_node: xml.etree.Element
123123
).replace(
124124
', low penetrance',
125125
'; low penetrance'
126+
).replace(
127+
'Likely pathogenic/Likely pathogenic',
128+
'Likely pathogenic'
126129
)
127130

128131
pathogenicity = pathogenicity_string.split(';')[0].strip()

seqr/views/apis/individual_api_tests.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,20 @@ def test_edit_individuals(self, mock_pm_group):
245245
self.assertEqual(response_json['individualsByGuid'][ID_UPDATE_GUID]['individualId'], UPDATED_ID)
246246
self.assertEqual(response_json['individualsByGuid'][ID_UPDATE_GUID]['maternalId'], 'NA19679')
247247

248+
response = self.client.post(edit_individuals_url, content_type='application/json', data=json.dumps({
249+
'individuals': [{
250+
'individualGuid': INDIVIDUAL_GUID,
251+
'familyId': '1',
252+
'individualId': 'NA19675_1',
253+
'paternalId': '',
254+
}]
255+
}))
256+
self.assertEqual(response.status_code, 200)
257+
response_json = response.json()
258+
self.assertSetEqual({INDIVIDUAL_GUID}, set(response_json['individualsByGuid']))
259+
self.assertIsNone(response_json['individualsByGuid'][INDIVIDUAL_GUID]['paternalId'])
260+
self.assertEqual(response_json['individualsByGuid'][INDIVIDUAL_GUID]['maternalId'], 'NA19679')
261+
248262
# Test PM permission
249263
pm_required_edit_individuals_url = reverse(edit_individuals_handler, args=[PM_REQUIRED_PROJECT_GUID])
250264
response = self.client.post(pm_required_edit_individuals_url, content_type='application/json', data=json.dumps({

seqr/views/utils/individual_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ def _update_from_record(record, user, families_by_id, individual_lookup, updated
143143
'mother': record.pop('mother', None),
144144
'father': record.pop('father', None),
145145
})
146-
elif record.get('maternalId') or record.get('paternalId'):
146+
elif record.get('maternalId') is not None or record.get('paternalId') is not None:
147147
parent_updates.append({
148148
'individual': individual,
149149
'maternalId': record.pop('maternalId', None),

seqr/views/utils/json_to_orm_utils.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,14 @@ def update_individual_parents(individual, json, user):
5555

5656
def _parse_parent_field(update_json, all_json, individual, parent_key, parent_id_key):
5757
updated_parent = all_json.get(parent_id_key) if parent_id_key else all_json.get(parent_key)
58+
if updated_parent is None:
59+
return
5860
parent = getattr(individual, parent_key, None)
5961
if parent_id_key:
6062
parent = parent.individual_id if parent else None
61-
if updated_parent != parent:
63+
if parent and not updated_parent:
64+
update_json[parent_key] = None
65+
elif updated_parent != parent:
6266
if parent_id_key:
6367
updated_parent = Individual.objects.get(individual_id=updated_parent, family=individual.family) if updated_parent else None
6468
update_json[parent_key] = updated_parent

0 commit comments

Comments
 (0)