def validateAndReturnErrors(cls, choices):
        genome = choices.genome
        genomicRegionsSource = choices.genomicRegionsSource
        genomicRegions = choices.genomicRegions
        sourceTfs = choices.sourceTfs
        tfTracks = choices.tfTracks

        # Check genome
        if genome == cls.SELECT:
            return 'Please select a genome build.'

        # Check that all boxes have data:
        if genomicRegionsSource == AllTargetsOfTfs.SELECT:
            return 'Please select a genomic region source.'
        if not genomicRegions:
            return 'Please select a genomic region.'

        # Check tracks for Genomic Regions-History:
        if genomicRegionsSource == 'History (user-defined)':
            if len(genomicRegions.split(":")) > 1:
                if genomicRegions.split(":")[1] == "gsuite":
                    errorString = GeneralGuiTool._checkGSuiteFile(
                        genomicRegions)
                    if errorString:
                        return errorString
                    else:
                        gSuite = getGSuiteFromGalaxyTN(genomicRegions)
                        sizeErrorString = GeneralGuiTool._checkGSuiteTrackListSize(
                            gSuite, 1, 1000)
                        if sizeErrorString:
                            return sizeErrorString
                        else:
                            reqErrorString = GeneralGuiTool._checkGSuiteRequirements \
                                (gSuite,
                                 AllTargetsOfTfs.GSUITE_ALLOWED_FILE_FORMATS,
                                 AllTargetsOfTfs.GSUITE_ALLOWED_LOCATIONS,
                                 AllTargetsOfTfs.GSUITE_ALLOWED_TRACK_TYPES,
                                 AllTargetsOfTfs.GSUITE_DISALLOWED_GENOMES)
                            if reqErrorString:
                                return reqErrorString
                else:
                    errorString = GeneralGuiTool._checkTrack(
                        choices, 'genomicRegions', 'genome')
                    if errorString:
                        return errorString

        if sourceTfs == AllTargetsOfTfs.SELECT:
            return 'Please select a TF source.'
        if not tfTracks:
            return 'Please select a TF track.'

        # Check tracks for TFs-History:
        if sourceTfs == 'History (user-defined)':
            tfErrorString = GeneralGuiTool._checkTrack(choices, 'tfTracks',
                                                       'genome')
            if tfErrorString:
                return tfErrorString

        return None
示例#2
0
    def validateAndReturnErrors(cls, choices):
            
        errorString = GeneralGuiTool._checkGSuiteFile(choices.gsuite)
        if errorString:
            return errorString

        errorString = cls._validateGenome(choices)
        if errorString:
            return errorString
        
        errorString = GeneralGuiTool._checkTrack(choices, 'targetTrack', 'genome')
        if errorString:
            return errorString


        gsuite = getGSuiteFromGalaxyTN(choices.gsuite)

        errorString = GeneralGuiTool._checkGSuiteRequirements \
            (gsuite,
             cls.GSUITE_ALLOWED_FILE_FORMATS,
             cls.GSUITE_ALLOWED_LOCATIONS,
             cls.GSUITE_ALLOWED_TRACK_TYPES,
             cls.GSUITE_DISALLOWED_GENOMES)
        
        if errorString:
            return errorString

        errorString = GeneralGuiTool._checkGSuiteTrackListSize(gsuite)
        if errorString:
            return errorString

        errorString = cls.validateUserBins(choices)
        if errorString:
            return errorString
    def validateAndReturnErrors(cls, choices):
        '''
        Should validate the selected input parameters. If the parameters are not
        valid, an error text explaining the problem should be returned. The GUI
        then shows this text to the user (if not empty) and greys out the
        execute button (even if the text is empty). If all parameters are valid,
        the method should return None, which enables the execute button.
        '''
        from quick.toolguide.controller.ToolGuide import ToolGuideController
        from quick.toolguide import ToolGuideConfig

        if not choices.targetTrack and not choices.refTrackCollection:
            return ToolGuideController.getHtml(
                cls.toolId,
                [ToolGuideConfig.TRACK_INPUT, ToolGuideConfig.GSUITE_INPUT],
                choices.isBasic)
        if not choices.targetTrack:
            return ToolGuideController.getHtml(cls.toolId,
                                               [ToolGuideConfig.TRACK_INPUT],
                                               choices.isBasic)
        if not choices.refTrackCollection:
            return ToolGuideController.getHtml(cls.toolId,
                                               [ToolGuideConfig.GSUITE_INPUT],
                                               choices.isBasic)

        errorString = GeneralGuiTool._checkGSuiteFile(
            choices.refTrackCollection)
        if errorString:
            return errorString

        errorString = cls._validateGenome(choices)
        if errorString:
            return errorString

        errorString = GeneralGuiTool._checkTrack(choices, 'targetTrack',
                                                 'genome')
        if errorString:
            return errorString

        refGSuite = getGSuiteFromGalaxyTN(choices.refTrackCollection)

        errorString = GeneralGuiTool._checkGSuiteRequirements \
            (refGSuite,
             cls.GSUITE_ALLOWED_FILE_FORMATS,
             cls.GSUITE_ALLOWED_LOCATIONS,
             cls.GSUITE_ALLOWED_TRACK_TYPES,
             cls.GSUITE_DISALLOWED_GENOMES)

        if errorString:
            return errorString

        errorString = GeneralGuiTool._checkGSuiteTrackListSize(refGSuite)
        if errorString:
            return errorString

        errorString = cls.validateUserBins(choices)
        if errorString:
            return errorString
    def validateAndReturnErrors(cls, choices):
        '''
        Should validate the selected input parameters. If the parameters are not
        valid, an error text explaining the problem should be returned. The GUI
        then shows this text to the user (if not empty) and greys out the
        execute button (even if the text is empty). If all parameters are valid,
        the method should return None, which enables the execute button.
        '''
        if cls.exception:
            return cls.exception

        #check track
        errorString = GeneralGuiTool._checkTrack(choices, 'targetTrack', 'targetTrackGenome')
        if errorString:
            return errorString

        genome, tn, tf = GeneralGuiTool._getBasicTrackFormat(choices, 'targetTrack', 'targetTrackGenome')
        errorString = ''
        from os import linesep
        if tf not in SegmentsOverlapVisualizationTool.TRACK_ALLOWED_TRACK_TYPES:
            errorString += '%s is not a supported track type for this tool. Supported track types are ' %tf
            errorString += str(SegmentsOverlapVisualizationTool.TRACK_ALLOWED_TRACK_TYPES) + linesep
            return errorString

        if choices.refTrackCollection is not None:

            targetTrackGenome = choices.targetTrackGenome
            errorString = GeneralGuiTool._checkGSuiteFile(choices.refTrackCollection)
            if errorString:
                return errorString

            refGSuite = getGSuiteFromGalaxyTN(choices.refTrackCollection)

            #check genome
            errorString = GeneralGuiTool._checkGenomeEquality(targetTrackGenome, refGSuite.genome)
            if errorString:
                return errorString

            errorString = GeneralGuiTool._checkGSuiteRequirements \
                (refGSuite,
                 SegmentsOverlapVisualizationTool.GSUITE_ALLOWED_FILE_FORMATS,
                 SegmentsOverlapVisualizationTool.GSUITE_ALLOWED_LOCATIONS,
                 SegmentsOverlapVisualizationTool.GSUITE_ALLOWED_TRACK_TYPES,
                 SegmentsOverlapVisualizationTool.GSUITE_DISALLOWED_GENOMES)
            if errorString:
                return errorString
            #number of tracks

            errorString = GeneralGuiTool._checkGSuiteTrackListSize(refGSuite, maxSize=10)
            if errorString:
                return errorString
        else:
            return None
示例#5
0
    def validateAndReturnErrors(choices):
        '''
        Should validate the selected input parameters. If the parameters are not valid,
        an error text explaining the problem should be returned. The GUI then shows this text
        to the user (if not empty) and greys out the execute button (even if the text is empty).
        If all parameters are valid, the method should return None, which enables the execute button.
        '''
        if ' ' in choices[0]:
            return 'Genome short name should not contain spaces.'

        basePath = GenomeImporter.getBasePathSequence(choices[0])
        if os.path.exists(basePath):
            return "Genome sequence path already exists: %s. Rename genome or delete directory to proceed." \
                % basePath

        if any(c.strip() == '' for c in choices[0:2]):
            return "Genome abbreviation and name boxes must be filled."

        if choices[2] == 'URL':
            if choices[3].strip() == '':
                return "Sequence URL box must be filled."
        else:
            error = GeneralGuiTool._checkTrack(choices, trackChoiceIndex=4, genomeChoiceIndex=None, \
                                               filetype='FASTA', validateFirstLine=True)
            if error:
                return error

        # test if the URLs are alive
        if choices[2] == 'URL':
            urls = choices[3].strip().split()
            urlError = validateURLs(urls)
            if urlError:
                return urlError

        taxonomyUrl = choices[8].strip()
        if taxonomyUrl != '':
            urlError = validateURL(taxonomyUrl)
            if urlError:
                return urlError
        import re
        emails = [v for v in re.split('[ ,\n\t\r]+', choices[10])]
        for email in emails:
            if not ('@' in email and '.' in email):
                #pass
                #if len([v for v in choices[8].replace(os.linesep, ' ').replace(',', ' ').split(' ') if not v =='' and v.find('@')<0])>0:
                return 'There is an invalid format (%s) inside the E-mail address field' % email

        ucscError = validateUcscValues([choices[x] for x in [13, 14, 15]])
        if ucscError:
            return ucscError

        if choices[16] == 'from URL':
            if choices[17].strip() == '':
                return "Genome annotation URL box must be filled."
        elif choices[16] == 'from history':
            error = GeneralGuiTool._checkTrack(choices, trackChoiceIndex=18, genomeChoiceIndex=None, \
                                               filetype='FASTA', validateFirstLine=True)
            if error:
                return error

        # test if the URLs are alive
        if choices[16] == 'from URL':
            urls = choices[17].strip().split()
            urlError = validateURLs(urls)
            if urlError:
                return urlError
示例#6
0
    def validateAndReturnErrors(cls, choices):
        genome = choices.genome
        genomicRegions = choices.genomicRegions
        genomicRegionsTracks = choices.genomicRegionsTracks
        sourceTfs = choices.sourceTfs
        sourceTfsDetails = choices.sourceTfsDetails
        tfTracks = choices.tfTracks

        # Check genome
        if genome == cls.SELECT:
            return 'Please select a genome build.'

        # Check that all region boxes have data:
        if genomicRegions == AllTfsOfRegions.SELECT:
            return 'Please select a genomic region.'
        if genomicRegionsTracks == AllTfsOfRegions.SELECT:
            return 'Please select a genomic region track.'

        # Check tracks for Genomic Regions-History:
        if genomicRegions == AllTfsOfRegions.REGIONS_FROM_HISTORY:
            errorString = GeneralGuiTool._checkTrack(choices,
                                                     'genomicRegionsTracks',
                                                     'genome')
            if errorString:
                return errorString

        # Check that TF box has data:
        if sourceTfs == AllTfsOfRegions.SELECT:
            return 'Please select a TF source.'

        # Check tracks for TFs-History:
        if sourceTfs == AllTfsOfRegions.REGIONS_FROM_HISTORY:
            if sourceTfsDetails == AllTfsOfRegions.SELECT:
                return 'Please select a TF track.'
            else:
                if isinstance(sourceTfsDetails, basestring):
                    trackType = sourceTfsDetails.split(':')[1]
                    if trackType == "gsuite":
                        errorString = GeneralGuiTool._checkGSuiteFile(
                            sourceTfsDetails)
                        if errorString:
                            return errorString
                        gSuite = getGSuiteFromGalaxyTN(sourceTfsDetails)
                        sizeErrorString = GeneralGuiTool._checkGSuiteTrackListSize(
                            gSuite, 1, 1000)
                        if sizeErrorString:
                            return sizeErrorString
                        reqErrorString = GeneralGuiTool._checkGSuiteRequirements \
                            (gSuite,
                             AllTfsOfRegions.GSUITE_ALLOWED_FILE_FORMATS,
                             AllTfsOfRegions.GSUITE_ALLOWED_LOCATIONS,
                             AllTfsOfRegions.GSUITE_ALLOWED_TRACK_TYPES,
                             AllTfsOfRegions.GSUITE_DISALLOWED_GENOMES)

                        if reqErrorString:
                            return reqErrorString
                    else:
                        errorString = GeneralGuiTool._checkTrack(
                            choices, 'sourceTfsDetails', 'genome')
                        if errorString:
                            return errorString

        return None