Esempio n. 1
0
def validate_sample_nucleotideType(value, runType, applicationGroupName, displayedName='Sample Nucleotide Type'):
    """
    validate nucleotide type case-insensitively with leading/trailing blanks in the input ignored
    """
    errors = []
    nucleotideType = ""
    try:
        runTypeObj = RunType.objects.filter(runType=runType)[0]
        value_from_runType = runTypeObj.nucleotideType.upper() if runTypeObj.nucleotideType else ""
    except:
        value_from_runType = ""

    if value:
        nucleotideType = value.strip().upper()
        if nucleotideType == "FUSIONS": nucleotideType = "RNA"

        if value_from_runType:
            if value_from_runType == "DNA_RNA":
                valid_values = ["DNA", "RNA", "Fusions"]
            else:
                valid_values = [value_from_runType]
        else:
            valid_values = ["DNA", "RNA"]

        if not validation.is_valid_keyword(nucleotideType, valid_values):
            errors.append(validation.invalid_keyword_error(displayedName, valid_values))
    else:
        # fill in nucleotideType from selected runType or applicationGroup
        if value_from_runType and value_from_runType != "DNA_RNA":
            nucleotideType = value_from_runType
        elif applicationGroupName in ["DNA", "RNA"]:
            nucleotideType = applicationGroupName

    return errors, nucleotideType
Esempio n. 2
0
def validate_sample_nucleotideType(nucleotideType,
                                   runType,
                                   displayedName='Sample Nucleotide Type'):
    """
    validate nucleotide type case-insensitively with leading/trailing blanks in the input ignored
    """

    errors = []
    input = ""
    valid_values = VALID_NUCLEOTIDE_TYPES

    if nucleotideType:
        input = nucleotideType.strip().upper()

        if runType:
            runTypeObjs = RunType.objects.filter(runType=runType)
            if runTypeObjs:
                runTypeObj = runTypeObjs[0]

                if (runTypeObj.nucleotideType
                        and runTypeObj.nucleotideType.upper() != "DNA_RNA"):
                    valid_values = [str(runTypeObj.nucleotideType.upper())]

        if not validation.is_valid_keyword(input, valid_values):
            errors.append(
                validation.invalid_keyword_error(displayedName, valid_values))

    return errors, input
Esempio n. 3
0
def validate_sample_nucleotideType(nucleotideType, runType, applicationGroupName, displayedName='Sample Nucleotide Type'):
    """
    validate nucleotide type case-insensitively with leading/trailing blanks in the input ignored
    """        
    errors = []
    input = ""
    valid_values = VALID_NUCLEOTIDE_TYPES
                    
    if nucleotideType:
        input = nucleotideType.strip().upper()
        
        if runType:
            runTypeObjs = RunType.objects.filter(runType = runType)
            if runTypeObjs:
                runTypeObj = runTypeObjs[0]
 
                if (runTypeObj.nucleotideType and runTypeObj.nucleotideType.upper() != "DNA_RNA"):
                    valid_values = [str(runTypeObj.nucleotideType.upper())]
                   
        if not validation.is_valid_keyword(input, valid_values):
            errors.append(validation.invalid_keyword_error(displayedName, valid_values))
    else:
        if runType:
            runTypeObjs = RunType.objects.filter(runType = runType)
            if runTypeObjs:
                runTypeObj = runTypeObjs[0]
    
                if (runTypeObj.nucleotideType and runTypeObj.nucleotideType.upper() != "DNA_RNA"):  
                    return errors, runTypeObj.nucleotideType.upper()
                else:
                    #some runType can have more than one nucleotideType
                    if applicationGroupName in ["DNA", "RNA"]:
                        return errors, applicationGroupName
              
    return errors, input
Esempio n. 4
0
def validate_sample_nucleotideType(value, runType, applicationGroupName, displayedName='Sample Nucleotide Type'):
    """
    validate nucleotide type case-insensitively with leading/trailing blanks in the input ignored
    """
    errors = []
    nucleotideType = ""
    try:
        runTypeObj = RunType.objects.filter(runType=runType)[0]
        value_from_runType = runTypeObj.nucleotideType.upper() if runTypeObj.nucleotideType else ""
    except:
        value_from_runType = ""

    if value:
        nucleotideType = value.strip().upper()
        if nucleotideType == "FUSIONS": nucleotideType = "RNA"

        if value_from_runType:
            if value_from_runType == "DNA_RNA":
                valid_values = ["DNA", "RNA", "Fusions"]
            else:
                valid_values = [value_from_runType]
        else:
            valid_values = ["DNA", "RNA"]

        if not validation.is_valid_keyword(nucleotideType, valid_values):
            errors.append(validation.invalid_keyword_error(displayedName, valid_values))
    else:
        # fill in nucleotideType from selected runType or applicationGroup
        if value_from_runType and value_from_runType != "DNA_RNA":
            nucleotideType = value_from_runType
        elif applicationGroupName in ["DNA", "RNA"]:
            nucleotideType = applicationGroupName

    return errors, nucleotideType
Esempio n. 5
0
def validate_templatingSize(value, displayedName='Templating Size'):    
    """
    validate templating size case-insensitively with leading/trailing blanks in the input ignored
    """        
    errors = []
    input = ""
    valid_values = VALID_TEMPLATING_SIZES
                    
    if value:
        input = value.strip().upper()
                           
        if not validation.is_valid_keyword(input, valid_values):
            errors.append(validation.invalid_keyword_error(displayedName, valid_values))        
    return errors
Esempio n. 6
0
def validate_nucleotideType(nucleotideType, displayedName='Sample Nucleotide Type'):
    """
    validate nucleotide type case-insensitively with leading/trailing blanks in the input ignored
    """
    isValid = True      
    errors = []
    input = ""
                    
    if nucleotideType:
        input = nucleotideType.strip().lower()
                           
        if not validation.is_valid_keyword(input, VALID_NUCLEOTIDE_TYPES):
            errors.append(validation.invalid_keyword_error(displayedName, VALID_NUCLEOTIDE_TYPES))
            isValid = False
             
    return isValid, errors, input
Esempio n. 7
0
def validate_pcrPlateRow(pcrPlateRow, displayedName='PCR Plate Position'):
    """
    validate PCR plate row case-insensitively with leading/trailing blanks in the input ignored
    """
    isValid = True      
    errors = []
    input = ""
                    
    if pcrPlateRow:
        input = pcrPlateRow.strip().upper()

        validValues = views_helper._get_pcrPlateRow_valid_values(None)
        if not validation.is_valid_keyword(input, validValues):
            errors.append(validation.invalid_keyword_error(displayedName, validValues))
            isValid = False
             
    return isValid, errors, input
Esempio n. 8
0
def validate_pcrPlateRow(pcrPlateRow, displayedName='PCR Plate Position'):
    """
    validate PCR plate row case-insensitively with leading/trailing blanks in the input ignored
    """
    isValid = True
    errors = []
    input = ""

    if pcrPlateRow:
        input = pcrPlateRow.strip().upper()

        validValues = views_helper._get_pcrPlateRow_valid_values(None)
        if not validation.is_valid_keyword(input, validValues):
            errors.append(
                validation.invalid_keyword_error(displayedName, validValues))
            isValid = False

    return isValid, errors, input
Esempio n. 9
0
def validate_pcrPlateCol(pcrPlateCol, displayedName='PCR Plate Position'):
    """
    validate PCR plate row case-insensitively with leading/trailing blanks in the input ignored
    """
    isValid = True
    errors = []
    input = ""

    if pcrPlateCol:
        valid_tuples = SampleSetItem.ALLOWED_AMPLISEQ_PCR_PLATE_COLUMNS_V1
        input = pcrPlateCol.strip().upper()

        validValues = views_helper._get_pcrPlateCol_valid_values(None)
        if not validation.is_valid_keyword(input, validValues):
            errors.append(validation.invalid_keyword_error(displayedName, validValues))
            isValid = False

    return isValid, errors, input
Esempio n. 10
0
def validate_pcrPlateCol(pcrPlateCol, displayedName='PCR Plate Position'):
    """
    validate PCR plate row case-insensitively with leading/trailing blanks in the input ignored
    """
    isValid = True
    errors = []
    input = ""

    if pcrPlateCol:
        valid_tuples = SampleSetItem.ALLOWED_AMPLISEQ_PCR_PLATE_COLUMNS_V1
        input = pcrPlateCol.strip().upper()

        validValues = views_helper._get_pcrPlateCol_valid_values(None)
        if not validation.is_valid_keyword(input, validValues):
            errors.append(
                validation.invalid_keyword_error(displayedName, validValues))
            isValid = False

    return isValid, errors, input
Esempio n. 11
0
def validate_nucleotideType(nucleotideType,
                            displayedName='Sample Nucleotide Type'):
    """
    validate nucleotide type case-insensitively with leading/trailing blanks in the input ignored
    """
    isValid = True
    errors = []
    input = ""

    if nucleotideType:
        input = nucleotideType.strip().lower()

        if not validation.is_valid_keyword(input, VALID_NUCLEOTIDE_TYPES):
            errors.append(
                validation.invalid_keyword_error(displayedName,
                                                 VALID_NUCLEOTIDE_TYPES))
            isValid = False

    return isValid, errors, input
Esempio n. 12
0
def validate_libPrepType(libPrepType, displayedTerm="Library Prep Type"):
    """
    validate libPrepType with leading/trailing blanks in the input ignored
    """
    isValid = True
    errors = []
    inputData = ""
    if libPrepType:
        inputData = libPrepType.strip()

        validValues = views_helper._get_libraryPrepType_choices(None)
        if not validation.is_valid_keyword(inputData, validValues):
            errors.append(validation.invalid_keyword_error(displayedTerm, validValues))
            errors = ''.join(errors).replace("are ,", ":")
            isValid = False
            return isValid, errors, libPrepType

    isValid = True
    return isValid, None, None
Esempio n. 13
0
def validate_samplesetStatus(samplesetStatus, displayedTerm="Status"):
    """
    validate samplesetStatus with leading/trailing blanks in the input ignored
    """
    isValid = True
    errors = []
    inputData = ""

    if samplesetStatus:
        inputData = samplesetStatus.strip().lower()
        validValues = views_helper._get_sampleset_choices(None)
        if not validation.is_valid_keyword(inputData, validValues):
            errors.append(validation.invalid_keyword_error(displayedTerm, validValues))
            errors = ''.join(errors).replace("are ,", ":")
            isValid = False
            return isValid, errors, samplesetStatus

    isValid = True
    return isValid, None, None
Esempio n. 14
0
def validate_libPrepType(libPrepType, displayedTerm="Library Prep Type"):
    """
    validate libPrepType with leading/trailing blanks in the input ignored
    """
    isValid = True
    errors = []
    inputData = ""
    if libPrepType:
        inputData = libPrepType.strip()

        validValues = views_helper._get_libraryPrepType_choices(None)
        if not validation.is_valid_keyword(inputData, validValues):
            errors.append(
                validation.invalid_keyword_error(displayedTerm, validValues))
            errors = ''.join(errors).replace("are ,", ":")
            isValid = False
            return isValid, errors, libPrepType

    isValid = True
    return isValid, None, None
Esempio n. 15
0
def validate_samplesetStatus(samplesetStatus, displayedTerm="Status"):
    """
    validate samplesetStatus with leading/trailing blanks in the input ignored
    """
    isValid = True
    errors = []
    inputData = ""

    if samplesetStatus:
        inputData = samplesetStatus.strip().lower()
        validValues = views_helper._get_sampleset_choices(None)
        if not validation.is_valid_keyword(inputData, validValues):
            errors.append(
                validation.invalid_keyword_error(displayedTerm, validValues))
            errors = ''.join(errors).replace("are ,", ":")
            isValid = False
            return isValid, errors, samplesetStatus

    isValid = True
    return isValid, None, None