Skip to content

Commit

Permalink
ENCD-6102-change-regex-lot-id-product-id (#4069)
Browse files Browse the repository at this point in the history
  • Loading branch information
jenjou authored Aug 27, 2021
1 parent 9d9248a commit b17ca4d
Show file tree
Hide file tree
Showing 17 changed files with 88 additions and 12 deletions.
9 changes: 2 additions & 7 deletions src/encoded/schemas/antibody_lot.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
{ "$ref": "mixins.json#/submitted" },
{ "$ref": "mixins.json#/source" },
{ "$ref": "mixins.json#/url" },
{ "$ref": "mixins.json#/lot_id" },
{ "$ref": "mixins.json#/product_id" },
{ "$ref": "mixins.json#/notes" }

Expand All @@ -31,7 +32,7 @@
],
"properties": {
"schema_version": {
"default": "9"
"default": "10"
},
"accession": {
"accessionType": "AB"
Expand All @@ -52,12 +53,6 @@
"pattern": "^(ENCAB\\d{3}[A-Z]{3})$|^(TSTAB\\d{6})$"
}
},
"lot_id": {
"title": "Lot ID",
"description": "The lot identifier provided by the originating lab or vendor.",
"type": "string",
"pattern": "^(\\S+(\\s|\\S)*\\S+|\\S)$|^$"
},
"lot_id_alias": {
"title": "Lot ID aliases",
"description": "The lot identifiers for this lot deemed to be exactly the same by the vendor.",
Expand Down
2 changes: 1 addition & 1 deletion src/encoded/schemas/biosample.json
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@
},
"properties": {
"schema_version": {
"default": "25"
"default": "26"
},
"accession": {
"accessionType": "BS"
Expand Down
3 changes: 3 additions & 0 deletions src/encoded/schemas/changelogs/antibody_lot.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
## Changelog for antibody_lot.json

### Schema version 10
* Modified regex pattern for *lot_id* and *product_id* to disallow blank strings.

### Minor changes since schema version 9

* Added *single cell* to *biosample_type* enums
Expand Down
4 changes: 4 additions & 0 deletions src/encoded/schemas/changelogs/biosample.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
## Changelog for biosample.json

### Schema version 26

* Modified regex pattern for *lot_id* and *product_id* to disallow blank strings.

### Minor changes since schema version 25

* Added *simple_summary* truncated version of biosample_summary as calculated property
Expand Down
3 changes: 3 additions & 0 deletions src/encoded/schemas/changelogs/library.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
## Changelog for library.json

### Schema version 19
* Modified regex pattern for *lot_id* and *product_id* to disallow blank strings.

### Schema version 18
* The *nucleic_acid_starting_quantity* property must now be formatted as a number.

Expand Down
3 changes: 3 additions & 0 deletions src/encoded/schemas/changelogs/treatment.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
## Changelog for treatment.json

### Schema version 13
* Modified regex pattern for *product_id* to disallow blank strings.

### Schema version 12
* Moved *stimulation* from *treatment_type* to *purpose*

Expand Down
2 changes: 1 addition & 1 deletion src/encoded/schemas/library.json
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@
},
"properties": {
"schema_version": {
"default": "18"
"default": "19"
},
"accession": {
"accessionType": "LB"
Expand Down
4 changes: 2 additions & 2 deletions src/encoded/schemas/mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -315,15 +315,15 @@
"title": "Product ID",
"description": "The product identifier provided by the originating lab or vendor.",
"type": "string",
"pattern": "^(\\S+(\\s|\\S)*\\S+|\\S)$|^$"
"pattern": "^(\\S+(\\s|\\S)*\\S+|\\S)$"
}
},
"lot_id": {
"lot_id":{
"title": "Lot ID",
"description": "The lot identifier provided by the originating lab or vendor.",
"type": "string",
"pattern": "^(\\S+(\\s|\\S)*\\S+|\\S)$|^$"
"pattern": "^(\\S+(\\s|\\S)*\\S+|\\S)$"
}
},
"source": {
Expand Down
2 changes: 1 addition & 1 deletion src/encoded/schemas/treatment.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
},
"properties": {
"schema_version": {
"default": "12"
"default": "13"
},
"documents": {
"description": "Documents that describe the treatment protocol."
Expand Down
9 changes: 9 additions & 0 deletions src/encoded/tests/test_upgrade_antibody_lot.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,12 @@ def test_antibody_lot_unique_array(upgrader, antibody_lot_4):
value = upgrader.upgrade('antibody_lot', antibody_lot_4, current_version='4', target_version='5')
assert len(value['purifications']) == len(set(value['purifications']))
assert len(value['lot_id_alias']) == len(set(value['lot_id_alias']))


def test_antibody_lot_upgrade_9_10(upgrader, antibody_lot_base):
antibody_lot_base['lot_id'] = ''
antibody_lot_base['product_id'] = ''
value = upgrader.upgrade('antibody_lot', antibody_lot_base, current_version='9', target_version='10')
assert value['schema_version'] == '10'
assert value['lot_id'] == 'Placeholder'
assert value['product_id'] == 'Placeholder'
9 changes: 9 additions & 0 deletions src/encoded/tests/test_upgrade_biosample.py
Original file line number Diff line number Diff line change
Expand Up @@ -339,3 +339,12 @@ def test_upgrade_biosample_24_to_25(upgrader, biosample_with_disease):
assert value['schema_version'] == '25'
assert isinstance(value['disease_term_id'], list)
assert value['disease_term_id'] == ['DOID:0080600']


def test_upgrade_biosample_25_to_26(upgrader, biosample):
biosample['lot_id'] = ''
biosample['product_id'] = ''
value = upgrader.upgrade('biosample', biosample, current_version='25', target_version='26')
assert value['schema_version'] == '26'
assert 'lot_id' not in value
assert 'product_id' not in value
9 changes: 9 additions & 0 deletions src/encoded/tests/test_upgrade_library.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,3 +135,12 @@ def test_library_upgrade_17_to_18(upgrader, library_schema_17):
value = upgrader.upgrade('library', library_schema_17, target_version='18')
assert value['schema_version'] == '18'
assert value['nucleic_acid_starting_quantity'] == 9.2


def test_library_upgrade_18_to_19(upgrader, base_library):
base_library['lot_id'] = ''
base_library['product_id'] = ''
value = upgrader.upgrade('library', base_library, current_version='18', target_version='19')
assert value['schema_version'] == '19'
assert 'lot_id' not in value
assert 'product_id' not in value
7 changes: 7 additions & 0 deletions src/encoded/tests/test_upgrade_treatment.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,10 @@ def test_treatment_upgrade_11_12(upgrader, treatment_11):
value = upgrader.upgrade('treatment', treatment_11, current_version='11', target_version='12')
assert value['treatment_type'] == 'chemical'
assert value['purpose'] == 'stimulation'


def test_treatment_upgrade_12_13(upgrader, treatment_12):
treatment_12['product_id'] = ''
value = upgrader.upgrade('treatment', treatment_12, current_version='12', target_version='13')
assert value['schema_version'] == '13'
assert 'product_id' not in value
9 changes: 9 additions & 0 deletions src/encoded/upgrade/antibody_lot.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,3 +81,12 @@ def antibody_lot_7_8(value, system):
def antibody_lot_8_9(value, system):
# http://redmine.encodedcc.org/issues/5041
return


@upgrade_step('antibody_lot', '9', '10')
def antibody_lot_9_10(value, system):
# https://encodedcc.atlassian.net/browse/ENCD-6102
if 'lot_id' in value and value['lot_id'] == '':
value['lot_id'] = 'Placeholder'
if 'product_id' in value and value['product_id'] == '':
value['product_id'] = 'Placeholder'
9 changes: 9 additions & 0 deletions src/encoded/upgrade/biosample.py
Original file line number Diff line number Diff line change
Expand Up @@ -376,3 +376,12 @@ def biosample_24_25(value, system):
# https://encodedcc.atlassian.net/browse/ENCD-5466
if 'disease_term_id' in value:
value['disease_term_id'] = [value['disease_term_id']]


@upgrade_step('biosample', '25', '26')
def biosample_25_26(value, system):
# https://encodedcc.atlassian.net/browse/ENCD-6102
if 'lot_id' in value and value['lot_id'] == '':
value.pop('lot_id')
if 'product_id' in value and value['product_id'] == '':
value.pop('product_id')
9 changes: 9 additions & 0 deletions src/encoded/upgrade/library.py
Original file line number Diff line number Diff line change
Expand Up @@ -327,3 +327,12 @@ def library_17_18(value, system):
except ValueError:
value['nucleic_acid_starting_quantity'] = 0
value['notes'] = (notes + ' The nucleic_acid_starting_quantity of this library could not be upgraded: '+ quantity).strip()


@upgrade_step('library', '18', '19')
def library_18_19(value, system):
# https://encodedcc.atlassian.net/browse/ENCD-6102
if 'lot_id' in value and value['lot_id'] == '':
value.pop('lot_id')
if 'product_id' in value and value['product_id'] == '':
value.pop('product_id')
7 changes: 7 additions & 0 deletions src/encoded/upgrade/treatment.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,3 +105,10 @@ def treatment_11_12(value, system):
if value.get('treatment_type') == 'stimulation':
value['treatment_type'] = 'chemical'
value['purpose'] = 'stimulation'


@upgrade_step('treatment', '12', '13')
def treatment_12_13(value, system):
# https://encodedcc.atlassian.net/browse/ENCD-6102
if 'product_id' in value and value['product_id'] == '':
value.pop('product_id')

0 comments on commit b17ca4d

Please sign in to comment.