Beispiel #1
0
def validate_barcoded_sample_info(sampleName, sampleId, nucleotideType, sampleReference, runType, applicationGroupName, displayedName='Barcoded Sample'):
    errors = []
    if not validation.is_valid_chars(sampleName):
        errors.append(validation.invalid_chars_error(displayedName))

    if not validation.is_valid_leading_chars(sampleName):
        errors.append(validation.invalid_chars_error(displayedName))

    if not validation.is_valid_length(sampleName, MAX_LENGTH_SAMPLE_NAME):
        errors.append(validation.invalid_length_error(displayedName, MAX_LENGTH_SAMPLE_NAME))

    sample_id_errors = validate_sample_id(sampleId)
    if sample_id_errors:
        errors.extend(sample_id_errors)

    nucleotideType_errors, sample_nucleotideType = validate_sample_nucleotideType(nucleotideType, runType, applicationGroupName)
    if (nucleotideType_errors):
        errors.extend(nucleotideType_errors)

    ref_displayedName = "Sample Reference" if nucleotideType != "RNA" else "RNA Sample Reference"
    ref_errors, ref_short_name = validate_reference(sampleReference, runType, applicationGroupName, displayedName=ref_displayedName)
    if (ref_errors):
        errors.extend(ref_errors)

    return errors, ref_short_name, sample_nucleotideType
Beispiel #2
0
def validate_barcoded_sample_info(sampleName, sampleId, nucleotideType, sampleReference, runType, applicationGroupName, displayedName='Barcoded Sample'):
    errors = []
    if not validation.is_valid_chars(sampleName):
        errors.append(validation.invalid_chars_error(displayedName))

    if not validation.is_valid_leading_chars(sampleName):
        errors.append(validation.invalid_chars_error(displayedName))

    if not validation.is_valid_length(sampleName, MAX_LENGTH_SAMPLE_NAME):
        errors.append(validation.invalid_length_error(displayedName, MAX_LENGTH_SAMPLE_NAME))

    sample_id_errors = validate_sample_id(sampleId)
    if sample_id_errors:
        errors.extend(sample_id_errors)

    nucleotideType_errors, sample_nucleotideType = validate_sample_nucleotideType(nucleotideType, runType, applicationGroupName)
    if (nucleotideType_errors):
        errors.extend(nucleotideType_errors)

    ref_displayedName = "Sample Reference" if nucleotideType != "RNA" else "RNA Sample Reference"
    ref_errors, ref_short_name = validate_reference(sampleReference, runType, applicationGroupName, displayedName=ref_displayedName)
    if (ref_errors):
        errors.extend(ref_errors)

    return errors, ref_short_name, sample_nucleotideType
Beispiel #3
0
def validate_barcoded_sample_info(
    sampleName, sampleId, nucleotideType, runTypeName, sampleReference, displayedName="Barcoded Sample"
):
    errors = []
    if not validation.is_valid_chars(sampleName):
        errors.append(validation.invalid_chars_error(displayedName))

    if not validation.is_valid_leading_chars(sampleName):
        errors.append(validation.invalid_chars_error(displayedName))

    if not validation.is_valid_length(sampleName, MAX_LENGTH_SAMPLE_NAME):
        errors.append(validation.invalid_length_error(displayedName, MAX_LENGTH_SAMPLE_NAME))

    sample_id_errors = validate_sample_id(sampleId)
    if sample_id_errors:
        errors.extend(sample_id_errors)

    sample_nucleotideType = ""

    nucleotideType_errors, sample_nucleotideType = validate_sample_nucleotideType(nucleotideType, runTypeName)
    if nucleotideType_errors:
        errors.extend(nucleotideType_errors)

    ref_errors, ref_short_name = validate_reference(sampleReference, displayedName="Sample Reference")
    ##logger.debug("plan_validator.validate_barcoded_sample_info() sampleReference=%s; ref_short_name=%s" %(sampleReference, ref_short_name))

    if ref_errors:
        errors.extend(ref_errors)

    ##logger.debug("plan_validator.validate_barcoded_sample_info() errors=%s" %(errors))

    return errors, ref_short_name, sample_nucleotideType
Beispiel #4
0
def validate_barcoded_sample_info(sampleName,
                                  sampleId,
                                  nucleotideType,
                                  sampleReference,
                                  sampleRnaReference,
                                  runType,
                                  applicationGroupName,
                                  displayedName='Barcoded Sample'):
    errors = []
    if not validation.is_valid_chars(sampleName):
        errors.append(validation.invalid_chars_error(displayedName))

    if not validation.is_valid_leading_chars(sampleName):
        errors.append(validation.invalid_chars_error(displayedName))

    if not validation.is_valid_length(sampleName, MAX_LENGTH_SAMPLE_NAME):
        errors.append(
            validation.invalid_length_error(displayedName,
                                            MAX_LENGTH_SAMPLE_NAME))

    sample_id_errors = validate_sample_id(sampleId)
    if sample_id_errors:
        errors.extend(sample_id_errors)

    sample_nucleotideType = ""

    nucleotideType_errors, sample_nucleotideType = validate_sample_nucleotideType(
        nucleotideType, runType, applicationGroupName)

    if (nucleotideType_errors):
        errors.extend(nucleotideType_errors)

    if runType == "AMPS_DNA_RNA" and sample_nucleotideType.upper() == "RNA":
        rna_ref_errors, rna_ref_short_name = validate_reference(
            sampleRnaReference,
            runType,
            applicationGroupName,
            displayedName="RNA Sample Reference")
        logger.debug(
            "plan_validator.validate_barcoded_sample_info() sampleRnaReference=%s; rna_ref_short_name=%s"
            % (sampleRnaReference, rna_ref_short_name))

        if (rna_ref_errors):
            errors.extend(rna_ref_errors)

    else:
        rna_ref_errors = []
        rna_ref_short_name = ""

    ref_errors, ref_short_name = validate_reference(
        sampleReference,
        runType,
        applicationGroupName,
        displayedName="Sample Reference")
    ##logger.debug("plan_validator.validate_barcoded_sample_info() sampleReference=%s; ref_short_name=%s" %(sampleReference, ref_short_name))

    if (ref_errors):
        errors.extend(ref_errors)

    return errors, ref_short_name, rna_ref_short_name, sample_nucleotideType
Beispiel #5
0
def validate_sampleAttribute(attribute, value):
    """
    validate the sample attribute value for the attribute of interest
    return a boolean isValid and a text string for error message, None if input passes validation
    Note: Input length will not be validated since maxLength has been specified in the form.
    """    
        
    isValid = False
    if not attribute:
        return isValid, "Error, No sample attribute to validate."
    
    if not validation.has_value(value):
        if attribute.isMandatory:
            return isValid, "Error, "+ validation.required_error(attribute.displayedName)
    else:
        aValue = value.strip()
        if attribute.dataType.dataType == "Text" and not validation.is_valid_chars(aValue):
            return isValid, "Error, "+ validation.invalid_chars_error(attribute.displayedName)
        if attribute.dataType.dataType == "Integer" and not aValue.isdigit():
            return isValid, "Error, "+ attribute.displayedName + ERROR_MSG_INVALID_DATATYPE
        if not validation.is_valid_chars(aValue):
            return isValid, "Error, "+ validation.invalid_chars_error(attribute.displayedName)

        if not validation.is_valid_length(aValue, MAX_LENGTH_SAMPLE_ATTRIBUTE_VALUE):
            errorMessage = validation.invalid_length_error("Error, User-defined sample attribute value", MAX_LENGTH_SAMPLE_ATTRIBUTE_VALUE) + ". It is currently %s characters long." % str(len(aValue.strip()))
            return isValid, errorMessage
        
    isValid = True
    return isValid, None   
Beispiel #6
0
def validate_sampleAttribute_definition(attributeName, attributeDescription):
    """
    validate the sample attribute definition
    return a boolean isValid and a text string for error message, None if input passes validation
    Note: Input length will not be validated since maxLength has been specified in the form.
    """    
        
    isValid = False
    
    if not validation.has_value(attributeName):
        return isValid, validation.required_error("Error, Attribute name")
    if not validation.is_valid_chars(attributeName.strip()):
        return isValid, validation.invalid_chars_error("Error, Attribute name")
            
    if not validation.is_valid_length(attributeName.strip(), MAX_LENGTH_SAMPLE_ATTRIBUTE_DISPLAYED_NAME):
        errorMessage = validation.invalid_length_error("Error, User-defined sample attribute", MAX_LENGTH_SAMPLE_ATTRIBUTE_DISPLAYED_NAME) + ". It is currently %s characters long." % str(len((attributeName.strip())))
        return isValid, errorMessage
    
    if not validation.is_valid_chars(attributeDescription):
        return isValid, validation.invalid_chars_error("Error, Attribute description")

    if not validation.is_valid_length(attributeDescription.strip(), MAX_LENGTH_SAMPLE_ATTRIBUTE_DESCRIPTION):
        errorMessage = validation.invalid_length_error("Error, User-defined sample attribute description", MAX_LENGTH_SAMPLE_ATTRIBUTE_DESCRIPTION) + ". It is currently %s characters long." % str(len(attributeDescription.strip()))
        return isValid, errorMessage
    
    isValid = True
    return isValid, None 
Beispiel #7
0
def validate_sampleSet_values(sampleSetName, sampleSetDesc, isNew = False):
    """ 
    validate the sampleSet input. 
    returns a boolean isValid and a text string for error message, None if input passes validation
    Note: Input length willl not be validated since maxLength has been specified in the form.
    """
    
    isValid = False
    if not validation.has_value(sampleSetName):
        return isValid, validation.required_error("Error, Sample set name")
    else:        
        if not validation.is_valid_chars(sampleSetName):
            return isValid, validation.invalid_chars_error("Error, Sample set name")
        
        if not validation.is_valid_length(sampleSetName, MAX_LENGTH_SAMPLE_SET_DISPLAYED_NAME):
            errorMessage = validation.invalid_length_error("Error, Sample set name", MAX_LENGTH_SAMPLE_SET_DISPLAYED_NAME) + ". It is currently %s characters long." % str(len(sampleSetName.strip()))
            return isValid, errorMessage

        if isNew:
            #error if new sample set already exists
            existingSampleSets = SampleSet.objects.filter(displayedName = sampleSetName)
            if existingSampleSets:
                errorMessage = "Error, Sample set %s already exists." % (sampleSetName)           
                return isValid, errorMessage
    
    if validation.has_value(sampleSetDesc):
        if not validation.is_valid_chars(sampleSetDesc):
            return isValid, validation.invalid_chars_error("Error, Sample set description")
        
        if not validation.is_valid_length(sampleSetDesc, MAX_LENGTH_SAMPLE_SET_DESCRIPTION):
            errorMessage = validation.invalid_length_error("Error, Sample set description", MAX_LENGTH_SAMPLE_SET_DESCRIPTION) + ". It is currently %s characters long." % str(len(sampleSetDesc.strip()))
            return isValid, errorMessage

    isValid = True
    return isValid, None
Beispiel #8
0
def validate_sample_name(value,
                         displayedName='Sample Name',
                         isTemplate=None,
                         barcodeId=None):
    errors = []
    if not value:
        if not isTemplate:
            errors.append(validation.required_error(displayedName))
    else:
        if isTemplate:
            errors.append(
                "Invalid input. Sample information cannot be saved in the template"
            )
        if barcodeId:
            errors.append(
                "Invalid input. Barcode kit should not be provided (%s) for non barcoded plan"
                % barcodeId)
        if not validation.is_valid_chars(value):
            errors.append(validation.invalid_chars_error(displayedName))
        if not validation.is_valid_leading_chars(value):
            errors.append(validation.invalid_chars_error(displayedName))
        if not validation.is_valid_length(value, MAX_LENGTH_SAMPLE_NAME):
            errors.append(
                validation.invalid_length_error(displayedName,
                                                MAX_LENGTH_SAMPLE_NAME))

    return errors
Beispiel #9
0
def validate_sample_name(value, displayedName="Sample Name"):
    errors = []
    if not validation.is_valid_chars(value):
        errors.append(validation.invalid_chars_error(displayedName))

    if not validation.is_valid_leading_chars(value):
        errors.append(validation.invalid_chars_error(displayedName))

    if not validation.is_valid_length(value, MAX_LENGTH_SAMPLE_NAME):
        errors.append(validation.invalid_length_error(displayedName, MAX_LENGTH_SAMPLE_NAME))

    return errors
Beispiel #10
0
def validate_sample_name(value, displayedName='Sample Name'):
    errors = []    
    if not validation.is_valid_chars(value):
        errors.append(validation.invalid_chars_error(displayedName))
        
    if not validation.is_valid_leading_chars(value):
        errors.append(validation.invalid_chars_error(displayedName))
    
    if not validation.is_valid_length(value, MAX_LENGTH_SAMPLE_NAME):
        errors.append(validation.invalid_length_error(displayedName, MAX_LENGTH_SAMPLE_NAME))

    return errors
Beispiel #11
0
def _validate_textValue(value, displayedTerm):
    isValid = False
    if value and not validation.is_valid_chars(value):
        return isValid, "Error, " + validation.invalid_chars_error(
            displayedTerm)

    return True, None
Beispiel #12
0
def validate_projects(value, displayedName='Project Name', delim=','):
    """
    validate projects case-insensitively with leading/trailing blanks in the input ignored
    """

    errors = []
    trimmed_projects = ""
    if value:
        for project in value.split(delim):
            trimmed_project = project.strip()
            if trimmed_project:
                trimmed_projects = trimmed_projects + trimmed_project + delim

                if not validation.is_valid_chars(trimmed_project):
                    errors.append(
                        validation.invalid_chars_error(displayedName))
                if not validation.is_valid_length(trimmed_project,
                                                  PROJECT_NAME_LENGTH):
                    errors.append(
                        validation.invalid_length_error(
                            displayedName, PROJECT_NAME_LENGTH))
                if errors:
                    break

    return errors, trimmed_projects
Beispiel #13
0
def validate_sample_id(value, displayedName="Sample Id"):
    errors = []
    if not validation.is_valid_chars(value):
        errors.append(validation.invalid_chars_error(displayedName))

    if not validation.is_valid_length(value, MAX_LENGTH_SAMPLE_ID):
        errors.append(validation.invalid_length_error(displayedName, MAX_LENGTH_SAMPLE_ID))

    return errors
Beispiel #14
0
def validate_sample_name(value, displayedName='Sample Name', isTemplate=None, barcodeId=None):
    errors = []
    if not value:
        if not isTemplate:
            errors.append(validation.required_error(displayedName))
    else:
        if isTemplate:
            errors.append("Invalid input. Sample information cannot be saved in the template")
        if barcodeId:
            errors.append("Invalid input. Barcode kit should not be provided (%s) for non barcoded plan" % barcodeId)
        if not validation.is_valid_chars(value):
            errors.append(validation.invalid_chars_error(displayedName))
        if not validation.is_valid_leading_chars(value):
            errors.append(validation.invalid_chars_error(displayedName))
        if not validation.is_valid_length(value, MAX_LENGTH_SAMPLE_NAME):
            errors.append(validation.invalid_length_error(displayedName, MAX_LENGTH_SAMPLE_NAME))

    return errors
Beispiel #15
0
def validate_sample_id(value, displayedName='Sample Id'):
    errors = []    
    if not validation.is_valid_chars(value):
        errors.append(validation.invalid_chars_error(displayedName))
    
    if not validation.is_valid_length(value, MAX_LENGTH_SAMPLE_ID):
        errors.append(validation.invalid_length_error(displayedName, MAX_LENGTH_SAMPLE_ID))

    return errors
Beispiel #16
0
def validate_notes(value, displayedName='Notes'):
    errors = []
    if not validation.is_valid_chars(value):
        errors.append(validation.invalid_chars_error(displayedName))
    
    if not validation.is_valid_length(value, MAX_LENGTH_NOTES):
        errors.append(validation.invalid_length_error(displayedName, MAX_LENGTH_NOTES))
        
    return errors
Beispiel #17
0
def validate_notes(value, displayedName="Notes"):
    errors = []
    if not validation.is_valid_chars(value):
        errors.append(validation.invalid_chars_error(displayedName))

    if not validation.is_valid_length(value, MAX_LENGTH_NOTES):
        errors.append(validation.invalid_length_error(displayedName, MAX_LENGTH_NOTES))

    return errors
Beispiel #18
0
def validate_barcoded_sample_info(applicationGroupName, runType, sampleName, sampleId, nucleotideType, runTypeName, sampleReference, sampleRnaReference, displayedName='Barcoded Sample'):
    errors = []
    if not validation.is_valid_chars(sampleName):
        errors.append(validation.invalid_chars_error(displayedName))
        
    if not validation.is_valid_leading_chars(sampleName):
        errors.append(validation.invalid_chars_error(displayedName))
    
    if not validation.is_valid_length(sampleName, MAX_LENGTH_SAMPLE_NAME):
        errors.append(validation.invalid_length_error(displayedName, MAX_LENGTH_SAMPLE_NAME))

    sample_id_errors = validate_sample_id(sampleId)
    if sample_id_errors:
        errors.extend(sample_id_errors)

    sample_nucleotideType = ""
    
    nucleotideType_errors, sample_nucleotideType = validate_sample_nucleotideType(nucleotideType, runTypeName, applicationGroupName)

    if (nucleotideType_errors):
        errors.extend(nucleotideType_errors)

    if runType == "AMPS_DNA_RNA" and sample_nucleotideType.upper() == "RNA":
        rna_ref_errors, rna_ref_short_name = validate_reference(sampleRnaReference, displayedName = "RNA Sample Reference")
        logger.debug("plan_validator.validate_barcoded_sample_info() sampleRnaReference=%s; rna_ref_short_name=%s" %(sampleRnaReference, rna_ref_short_name))
        
        if (rna_ref_errors):
            errors.extend(rna_ref_errors)

    else:
        rna_ref_errors = []
        rna_ref_short_name = ""

    ref_errors, ref_short_name = validate_reference(sampleReference, displayedName = "Sample Reference")
    ##logger.debug("plan_validator.validate_barcoded_sample_info() sampleReference=%s; ref_short_name=%s" %(sampleReference, ref_short_name))

    if (ref_errors):
        errors.extend(ref_errors)

    ##logger.debug("plan_validator.validate_barcoded_sample_info() errors=%s" %(errors))
    
    return errors, ref_short_name, rna_ref_short_name, sample_nucleotideType 
Beispiel #19
0
def validate_sample_id(value, field_label):
    errors = []
    if not validation.is_valid_chars(value):
        errors.append(validation.invalid_chars_error(field_label))

    if not validation.is_valid_length(value, MAX_LENGTH_SAMPLE_ID):
        errors.append(
            validation.invalid_length_error(field_label, MAX_LENGTH_SAMPLE_ID,
                                            value))

    return errors
Beispiel #20
0
def validate_sample_tube_label(value, displayedName='Sample Tube Label'):    
    errors = []
    
    if value:
        if not validation.is_valid_chars(value):
            errors.append(validation.invalid_chars_error(displayedName))
            
        if not validation.is_valid_length(value, MAX_LENGTH_SAMPLE_TUBE_LABEL):
            errors.append(validation.invalid_length_error(displayedName, MAX_LENGTH_SAMPLE_TUBE_LABEL))

    return errors
Beispiel #21
0
def validate_sample_tube_label(value, displayedName="Sample Tube Label"):
    errors = []

    if value:
        if not validation.is_valid_chars(value):
            errors.append(validation.invalid_chars_error(displayedName))

        if not validation.is_valid_length(value, MAX_LENGTH_SAMPLE_TUBE_LABEL):
            errors.append(validation.invalid_length_error(displayedName, MAX_LENGTH_SAMPLE_TUBE_LABEL))

    return errors
Beispiel #22
0
def validate_plan_name(value, displayedName="Plan Name"):
    errors = []
    if not validation.has_value(value):
        errors.append(validation.required_error(displayedName))

    if not validation.is_valid_chars(value):
        errors.append(validation.invalid_chars_error(displayedName))

    if not validation.is_valid_length(value, MAX_LENGTH_PLAN_NAME):
        errors.append(validation.invalid_length_error(displayedName, MAX_LENGTH_PLAN_NAME))

    return errors
Beispiel #23
0
def validate_notes(value, field_label=_Experiment.notes.verbose_name):
    errors = []
    if value:
        if not validation.is_valid_chars(value):
            errors.append(validation.invalid_chars_error(field_label))

        if not validation.is_valid_length(value, MAX_LENGTH_NOTES):
            errors.append(
                validation.invalid_length_error(field_label, MAX_LENGTH_NOTES,
                                                value))

    return errors
Beispiel #24
0
def validate_plan_name(value, displayedName='Plan Name'):
    errors = []
    if not validation.has_value(value):
        errors.append(validation.required_error(displayedName))
        
    if not validation.is_valid_chars(value):
        errors.append(validation.invalid_chars_error(displayedName))
    
    if not validation.is_valid_length(value, MAX_LENGTH_PLAN_NAME):
        errors.append(validation.invalid_length_error(displayedName, MAX_LENGTH_PLAN_NAME))
    
    return errors
Beispiel #25
0
def validate_barcoded_sample_info(sampleName,
                                  sampleId,
                                  nucleotideType,
                                  runTypeName,
                                  sampleReference,
                                  displayedName='Barcoded Sample'):
    errors = []
    if not validation.is_valid_chars(sampleName):
        errors.append(validation.invalid_chars_error(displayedName))

    if not validation.is_valid_leading_chars(sampleName):
        errors.append(validation.invalid_chars_error(displayedName))

    if not validation.is_valid_length(sampleName, MAX_LENGTH_SAMPLE_NAME):
        errors.append(
            validation.invalid_length_error(displayedName,
                                            MAX_LENGTH_SAMPLE_NAME))

    sample_id_errors = validate_sample_id(sampleId)
    if sample_id_errors:
        errors.extend(sample_id_errors)

    sample_nucleotideType = ""

    nucleotideType_errors, sample_nucleotideType = validate_sample_nucleotideType(
        nucleotideType, runTypeName)
    if (nucleotideType_errors):
        errors.extend(nucleotideType_errors)

    ref_errors, ref_short_name = validate_reference(
        sampleReference, displayedName="Sample Reference")
    ##logger.debug("plan_validator.validate_barcoded_sample_info() sampleReference=%s; ref_short_name=%s" %(sampleReference, ref_short_name))

    if (ref_errors):
        errors.extend(ref_errors)

    ##logger.debug("plan_validator.validate_barcoded_sample_info() errors=%s" %(errors))

    return errors, ref_short_name, sample_nucleotideType
Beispiel #26
0
def validate_plan_name(value, field_label):
    errors = []
    if not validation.has_value(value):
        errors.append(validation.required_error(field_label))

    if not validation.is_valid_chars(value):
        errors.append(validation.invalid_chars_error(field_label))

    if not validation.is_valid_length(value, MAX_LENGTH_PLAN_NAME):
        errors.append(
            validation.invalid_length_error(field_label, MAX_LENGTH_PLAN_NAME,
                                            value))

    return errors
Beispiel #27
0
def validate_sample_tube_label(value, field_label):
    errors = []

    if value:
        if not validation.is_valid_chars(value):
            errors.append(validation.invalid_chars_error(field_label))

        if not validation.is_valid_length(value, MAX_LENGTH_SAMPLE_TUBE_LABEL):
            errors.append(
                validation.invalid_length_error(field_label,
                                                MAX_LENGTH_SAMPLE_TUBE_LABEL,
                                                value))

    return errors
Beispiel #28
0
def validate_barcoded_sample_info(
    sampleName,
    sampleName_label,
    sampleExternalId,
    sampleExternalId_label,
    nucleotideType,
    nucleotideType_label,
    sampleReference,
    sampleReference_label,
    runType,
    applicationGroupName,
):
    errors = []
    if not validation.is_valid_chars(sampleName):
        errors.append(validation.invalid_chars_error(sampleName_label))

    if not validation.is_valid_leading_chars(sampleName):
        errors.append(validation.invalid_leading_chars(sampleName_label))

    if not validation.is_valid_length(sampleName, MAX_LENGTH_SAMPLE_NAME):
        errors.append(
            validation.invalid_length_error(sampleName_label,
                                            MAX_LENGTH_SAMPLE_NAME,
                                            sampleName))

    sample_id_errors = validate_sample_id(sampleExternalId,
                                          field_label=sampleExternalId_label)
    if sample_id_errors:
        errors.extend(sample_id_errors)

    nucleotideType_errors, sample_nucleotideType = validate_sample_nucleotideType(
        nucleotideType,
        runType,
        applicationGroupName,
        field_label=nucleotideType_label)
    if nucleotideType_errors:
        errors.extend(nucleotideType_errors)

    ref_errors, ref_short_name = validate_reference(
        sampleReference,
        field_label=sampleReference_label,
        runType=runType,
        applicationGroupName=applicationGroupName,
        application_label=ScientificApplication.verbose_name,
    )
    if ref_errors:
        errors.extend(ref_errors)

    return errors, ref_short_name, sample_nucleotideType
Beispiel #29
0
def validate_plupload(request, pub_name, file_name, labelsContent):
    file_name = os.path.basename(file_name).strip().replace(" ", "_")

    if pub_name == "BED":
        # validate bed file name is unique
        if models.Content.objects.filter(file__endswith="/" +
                                         file_name).count() > 0:
            raise Exception(
                validation.invalid_entity_field_unique_value(
                    labelsContent.verbose_name,
                    labelsContent.pickfile.verbose_name,
                    file_name,
                ))

        # validate file name
        if not validation.is_valid_chars(file_name):
            raise Exception(validation.invalid_chars_error("BED file name"))

    return file_name
Beispiel #30
0
def validate_sample_name(
    value,
    field_label,
    isTemplate=None,
    isTemplate_label=PlanTemplate.verbose_name,
    barcodeId=None,
    barcodeId_label=ugettext_lazy("workflow.step.kits.fields.barcodeId.label"),
):  # TODO: i18n
    errors = []
    if not value:
        if not isTemplate:
            errors.append(validation.required_error(field_label))
    else:
        if isTemplate:
            errors.append(
                validation.format(
                    ugettext_lazy(
                        "template.messages.validation.invalidsamples"),
                    {"name": isTemplate_label},
                )
            )  # "Invalid input. Sample information cannot be saved in the %(name)s"
        if barcodeId:
            errors.append(
                validation.format(
                    ugettext_lazy(
                        "plannedexperiment.messages.validation.nonbarcoded.barcodesetnotrequired"
                    ),
                    {
                        "barcodeSetName": barcodeId_label,
                        "barcodeSetValue": barcodeId
                    },
                )
            )  # "Invalid input. %(barcodeSetName)s (%(barcodeSetValue)s) should not be provided for non barcoded plan"
        if not validation.is_valid_chars(value):
            errors.append(validation.invalid_chars_error(field_label))
        if not validation.is_valid_leading_chars(value):
            errors.append(validation.invalid_leading_chars(field_label))
        if not validation.is_valid_length(value, MAX_LENGTH_SAMPLE_NAME):
            errors.append(
                validation.invalid_length_error(field_label,
                                                MAX_LENGTH_SAMPLE_NAME, value))

    return errors
Beispiel #31
0
def validate_projects(value, displayedName="Project Name", delim=","):
    """
    validate projects case-insensitively with leading/trailing blanks in the input ignored
    """

    errors = []
    trimmed_projects = ""
    if value:
        for project in value.split(delim):
            trimmed_project = project.strip()
            if trimmed_project:
                trimmed_projects = trimmed_projects + trimmed_project + delim

                if not validation.is_valid_chars(trimmed_project):
                    errors.append(validation.invalid_chars_error(displayedName))
                if not validation.is_valid_length(trimmed_project, PROJECT_NAME_LENGTH):
                    errors.append(validation.invalid_length_error(displayedName, PROJECT_NAME_LENGTH))
                if errors:
                    break

    return errors, trimmed_projects
Beispiel #32
0
def _validate_textValue(value, displayedTerm):
    isValid = False
    if value and not validation.is_valid_chars(value):
        return isValid, "Error, " + validation.invalid_chars_error(displayedTerm)
        
    return True, None