Skip to content

Commit a7e04dd

Browse files
committed
adjusted audit
1 parent c6871ce commit a7e04dd

File tree

3 files changed

+69
-9
lines changed

3 files changed

+69
-9
lines changed

src/igvfd/audit/construct_library_set.py

+27-5
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,19 @@
99
)
1010

1111

12+
def get_assay_terms(value, system):
13+
assay_terms = set()
14+
for sample in value.get('applied_to_samples', []):
15+
sample_object = system.get('request').embed(
16+
sample + '@@object_with_select_calculated_properties?field=file_sets')
17+
file_sets = sample_object.get('file_sets', [])
18+
for file_set in file_sets:
19+
if file_set.startswith('/measurement-sets/'):
20+
input_file_set_object = system.get('request').embed(input_file_set + '@@object?skip_calculated=true')
21+
assay_terms.add(input_file_set_object.get('assay_term'))
22+
return list(assay_terms)
23+
24+
1225
@audit_checker('ConstructLibrarySet', frame='object')
1326
def audit_construct_library_set_associated_phenotypes(value, system):
1427
'''
@@ -97,26 +110,35 @@ def audit_integrated_content_files(value, system):
97110
'''
98111
[
99112
{
100-
"audit_description": "Guide libraries are expected to link to an integrated content file of guide RNA sequences.",
113+
"audit_description": "Guide libraries used in CRISPR assays are expected to link to an integrated content file of guide RNA sequences.",
101114
"audit_category": "missing guide RNA sequences",
102115
"audit_level": "NOT_COMPLIANT"
103116
},
104117
{
105-
"audit_description": "Reporter libraries are expected to link to an integrated content file of MPRA sequence designs.",
118+
"audit_description": "Reporter libraries used in MPRA assays are expected to link to an integrated content file of MPRA sequence designs.",
106119
"audit_category": "missing MPRA sequence designs",
107120
"audit_level": "NOT_COMPLIANT"
108121
}
109122
]
110123
'''
111124
audit_message_guide = get_audit_message(audit_integrated_content_files, index=0)
112125
audit_message_reporter = get_audit_message(audit_integrated_content_files, index=1)
126+
assay_terms = get_assay_terms(value, system)
127+
CRISPR_assays = [
128+
'/assay-terms/OBI_0003659/' # in vitro CRISPR screen assay
129+
'/assay-terms/OBI_0003660/' # in vitro CRISPR screen using single-cell RNA-seq
130+
'/assay-terms/OBI_0003661/' # in vitro CRISPR screen using flow cytometry
131+
]
132+
MPRA_assays = [
133+
'/assay-terms/OBI_0002675/' # massively parallel reporter assay
134+
]
113135
library_expectation = {
114-
'guide library': ('guide RNA sequences', audit_message_guide),
115-
'reporter library': ('MPRA sequence designs', audit_message_reporter),
136+
'guide library': ('guide RNA sequences', audit_message_guide, CRISPR_assays),
137+
'reporter library': ('MPRA sequence designs', audit_message_reporter, MPRA_assays),
116138
}
117139
integrated_content_files = value.get('integrated_content_files', '')
118140
library_type = value.get('file_set_type', '')
119-
if library_type in library_expectation:
141+
if library_type in library_expectation and any(assay_term in library_expectation[library_type][2] for assay_term in assay_terms):
120142
file_expectation = library_expectation[library_type][0]
121143
audit_message = library_expectation[library_type][1]
122144
if integrated_content_files:

src/igvfd/mappings/construct_library_set.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
2-
"hash": "c2f24a479121ea32c2e8fd5687fff44d",
3-
"index_name": "construct_library_set_c2f24a47",
2+
"hash": "53b59edfed6d4f2d5101620baad2df0f",
3+
"index_name": "construct_library_set_53b59edf",
44
"item_type": "construct_library_set",
55
"mapping": {
66
"dynamic_templates": [

src/igvfd/tests/test_audit_construct_library_set.py

+40-2
Original file line numberDiff line numberDiff line change
@@ -184,8 +184,20 @@ def test_audit_construct_library_set_with_invalid_chroms(
184184
def test_audit_construct_library_set_guide_library_guide_rna_sequences(
185185
testapp,
186186
construct_library_set_genome_wide,
187-
tabular_file
187+
tabular_file,
188+
assay_term_crispr,
189+
measurement_set,
190+
tissue
188191
):
192+
testapp.patch_json(
193+
measurement_set['@id'],
194+
{'assay_term': assay_term_crispr['@id'],
195+
'samples': tissue['@id']}
196+
)
197+
testapp.patch_json(
198+
tissue['@id'],
199+
{'construct_library_sets': construct_library_set_genome_wide['@id']}
200+
)
189201
res = testapp.get(construct_library_set_genome_wide['@id'] + '@@audit')
190202
assert any(
191203
error['category'] == 'missing guide RNA sequences'
@@ -213,8 +225,21 @@ def test_audit_construct_library_set_guide_library_guide_rna_sequences(
213225
def test_audit_construct_library_set_mpra_sequence_designs(
214226
testapp,
215227
construct_library_set_reporter,
216-
tabular_file
228+
tabular_file,
229+
assay_term_mpra,
230+
measurement_set,
231+
tissue,
232+
assay_term_starr
217233
):
234+
testapp.patch_json(
235+
measurement_set['@id'],
236+
{'assay_term': assay_term_mpra['@id'],
237+
'samples': tissue['@id']}
238+
)
239+
testapp.patch_json(
240+
tissue['@id'],
241+
{'construct_library_sets': construct_library_set_reporter['@id']}
242+
)
218243
res = testapp.get(construct_library_set_reporter['@id'] + '@@audit')
219244
assert any(
220245
error['category'] == 'missing MPRA sequence designs'
@@ -229,6 +254,19 @@ def test_audit_construct_library_set_mpra_sequence_designs(
229254
error['category'] == 'missing MPRA sequence designs'
230255
for error in res.json['audit'].get('NOT_COMPLIANT', [])
231256
)
257+
testapp.patch_json(
258+
measurement_set['@id'],
259+
{'assay_term': assay_term_starr['@id']}
260+
)
261+
res = testapp.get(construct_library_set_reporter['@id'] + '@@audit')
262+
assert all(
263+
error['category'] != 'missing MPRA sequence designs'
264+
for error in res.json['audit'].get('NOT_COMPLIANT', [])
265+
)
266+
testapp.patch_json(
267+
measurement_set['@id'],
268+
{'assay_term': assay_term_mpra['@id']}
269+
)
232270
testapp.patch_json(
233271
tabular_file['@id'],
234272
{'content_type': 'MPRA sequence designs'}

0 commit comments

Comments
 (0)