You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

66 lines
2.6 KiB

#!/usr/bin/env python3
import marshmallow
from marshmallow import fields
class LociSchema(marshmallow.Schema):
D8S1179 =fields.List(marshmallow.fields.String(), required=True)
D21S11 = fields.List(fields.String(), required=True)
D7S820 = fields.List(fields.String(), required=True)
CSF1PO = fields.List(fields.String(), required=True)
D3S1358 = fields.List(fields.String(), required=True)
TH01 = fields.List(fields.String(), required=True)
D13S317 = fields.List(fields.String(), required=True)
D16S539 = fields.List(fields.String(), required=True)
D2S1338 = fields.List(fields.String(), required=True)
D19S433 = fields.List(fields.String(), required=True)
vWA = fields.List(fields.String(), required=True)
TPOX = fields.List(fields.String(), required=True)
D18S51 = fields.List(fields.String(), required=True)
D5S818 = fields.List(fields.String(), required=True)
FGA = fields.List(fields.String(), required=True)
class ComparisonSchema(LociSchema):
name = fields.String(
required=True
error_messages={'required': "Field 'name' is required."})
class EvidenceSchema(marshmallow.Schema):
class Meta:
strict = True
name = fields.String(
required=True
error_messages={'required': "Field 'name' is required."})
replicates = fields.List(
fields.Nested(LociSchema()),
required=True,
error_messages={'required': "Field 'replicates' is required."})
comparisons = fields.List(
fields.Nested(ComparisonSchema()),
required=True,
error_messages={'required': "Field 'comparisons' is required."})
known_pn = fields.List(
fields.Nested(LociSchema()))
contributors = fields.Integer(
required=True,
error_messages={'required': "Field 'contributors' is required."})
deducible = fields.Boolean(
required=True,
error_messages={'required': "Field 'deducible' is required."})
quantity = fields.Float(
required=True,
error_messages={'required': "Field 'quantity' is required."})
# NOTE: 0 contributors makes no sense
@marshmallow.validates('contributors')
def validate_contributors(self, value):
if value < 1:
raise marshmallow.ValidationError("Field 'contributors' must be greater than or equal to 1.")
# NOTE: a sample of anything less than or equal to 0 makes no sense
@marshmallow.validates('quantity')
def validate_quantity(self, value):
if value <= 0:
raise marshmallow.ValidationError("Field 'quantity' must be greater than 0.")