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.
        '''
        from quick.toolguide.controller.ToolGuide import ToolGuideController
        from quick.toolguide import ToolGuideConfig

        if not choices.histElement:
            return ToolGuideController.getHtml(cls.toolId,
                                               [ToolGuideConfig.GSUITE_INPUT],
                                               choices.isBasic)
        errorString = GeneralGuiTool._checkGSuiteFile(choices.histElement)
        if errorString:
            return errorString

        gSuite = getGSuiteFromGalaxyTN(choices.histElement)

        if choices.Analysis in (
                MultiTrackAnalysisTool.LBL_FACTORS_OBSERVED_VS_EXPECTED,
                MultiTrackAnalysisTool.LBL_HYPOTHESIS_TESTING_MULTI):
            errorString = GeneralGuiTool._checkGSuiteTrackListSize(gSuite,
                                                                   minSize=3,
                                                                   maxSize=3)
            if errorString:
                return errorString

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

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

#         regSpec, binSpec = UserBinSelector.getRegsAndBinsSpec(choices)
#         if regSpec.strip() is '' or binSpec.strip() is '':
#             return 'Region and bin must be specified'
#         ubSource = GalaxyInterface._getUserBinSource(regSpec, binSpec, gSuite.genome)
#
#         hasBins = False
#         for bin in ubSource:
#             hasBins = True
#             break
#
#         if not hasBins:
#             return 'Zero analysis bins specified. This may be caused by entering an incorrect filtering condition, e.g. a mistyped chromosome.'
#
        return None
Exemplo n.º 3
0
    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.gSuite:
            return ToolGuideController.getHtml(cls.toolId, [ToolGuideConfig.GSUITE_INPUT], True)
        
        if choices.normStrat not in [cls.NORM_STRAT_RPKM]:
            return 'Not implemented yet'
        
        return None
    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.histElement1 or not choices.histElement2:
            return ToolGuideController.getHtml(cls.toolId,
                                               [ToolGuideConfig.GSUITE_INPUT],
                                               choices.isBasic)

        gSuiteList = []
        for desc, histElement in [('first', choices.histElement1),
                                  ('second', choices.histElement2)]:
            errorString = cls._checkGSuiteFile(histElement)
            if errorString:
                return errorString

            gSuite = getGSuiteFromGalaxyTN(histElement)

            errorString = cls._checkGSuiteTrackListSize\
                (gSuite, minSize=cls.MIN_NUMBER_OF_TRACKS, maxSize=cls.MAX_NUMBER_OF_TRACKS)
            if errorString:
                return errorString

            errorString = cls._checkGSuiteRequirements \
                    (gSuite,
                     cls.GSUITE_ALLOWED_FILE_FORMATS,
                     cls.GSUITE_ALLOWED_LOCATIONS,
                     cls.GSUITE_ALLOWED_TRACK_TYPES,
                     cls.GSUITE_DISALLOWED_GENOMES)
            if errorString:
                return 'Error in the %s GSuite file: ' % desc + errorString

            gSuiteList.append(gSuite)

        errorString = cls._checkGenomeEquality(
            *[gSuite.genome for gSuite in gSuiteList])
        if errorString:
            return errorString

        for i, desc, divideChoice, numClustersChoice in \
                [(0, 'row', choices.divideRows, choices.numClustersRows),
                 (1, 'column', choices.divideCols, choices.numClustersCols)]:
            if divideChoice == 'Yes':
                try:
                    numClusters = int(numClustersChoice)
                except:
                    return numClustersChoice + ' is not an integer (number)'

                numTracks = gSuiteList[i].numTracks()
                if numClusters < 1 or numClusters > (numTracks / 2):
                    return 'The number of cluster for the %s tracks must be between 1 and %s' \
                        % (desc, numTracks / 2)

        errorString = cls.validateUserBins(choices)
        if errorString:
            return errorString
Exemplo n.º 5
0
    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 not choices.gSuite:
            from quick.toolguide.controller.ToolGuide import ToolGuideController
            from quick.toolguide import ToolGuideConfig
            return ToolGuideController.getHtml(cls.toolId,
                                               [ToolGuideConfig.GSUITE_INPUT],
                                               choices.isBasic)

        errorString = GeneralGuiTool._checkGSuiteFile(choices.gSuite)
        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

        if choices.similarityTech == cls.SIMILARITY_RELATIONS_TO_OTHER \
                or choices.similarityTech == cls.REGIONS_CLUSTERING:
            if not choices.gSuiteRef:
                from quick.toolguide.controller.ToolGuide import ToolGuideController
                from quick.toolguide import ToolGuideConfig
                return ToolGuideController.getHtml(
                    cls.toolId, [ToolGuideConfig.GSUITE_INPUT],
                    choices.isBasic)

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

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

        if choices.similarityTech in [
                cls.SIMILARITY_POSITIONAL, cls.SIMILARITY_RELATIONS_TO_OTHER
        ]:
            if not choices.featureSelection:
                return 'Feature for similarity calculation has not been selected. ' \
                       'If no features are available for selection, the track types ' \
                       'if the clustering and reference tracks are too inconsistent. ' \
                       'Please remove the inconsistent tracks from the GSuite.'

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

        errorString = cls.validateUserBins(choices)
        if errorString:
            return errorString
Exemplo n.º 6
0
    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.
        :param choices:  Dict holding all current selections
        """
        from quick.toolguide.controller.ToolGuide import ToolGuideController
        from quick.toolguide import ToolGuideConfig

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

        errorString = cls._checkGSuiteFile(choices.gsuite)
        if errorString:
            return errorString

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

        errorString = cls._checkTrack(choices, 'queryTrack', 'genome')
        if errorString:
            return errorString

        gsuite = getGSuiteFromGalaxyTN(choices.gsuite)

        errorString = cls._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 = cls._checkGSuiteTrackListSize(gsuite)
        if errorString:
            return errorString

        if choices.randStrat in [RAND_BY_UNIVERSE_TEXT]:
            errorString = cls._checkTrack(choices, 'intensityTrack', 'genome')
            if errorString:
                return errorString

            if choices.queryTrack and choices.intensityTrack:
                basicTFQuery = cls._getBasicTrackFormat(choices, 'queryTrack')[-1]
                basicTFIntensity = cls._getBasicTrackFormat(choices, 'intensityTrack')[-1]

                if not all(_ == 'points' for _ in [basicTFQuery, basicTFIntensity]):
                    core = HtmlCore()
                    core.paragraph('The selected randomization strategy requires the query and '
                                   'the universe track to both be of type "Points". One or both '
                                   'of these tracks have the incorrect track type.')
                    core.descriptionLine('Current track type of query track', basicTFQuery)
                    core.descriptionLine('Current track type of universe track', basicTFIntensity)
                    core.paragraph('The only file formats (Galaxy datatypes) that '
                                   'support the "Points" track type is "gtrack" and "bed.points". '
                                   'To fix your input track(s), do as follows:')
                    core.orderedList([
                        'If you currently have a segment track (with segment lengths > 1), '
                        'please convert it into points tracks by using the tool "Expand or '
                        'contract points/segments" under the "Customize tracks" submenu.',
                        'If you currently have a "bed" file where all segments have '
                        'length one, possibly as the result of step 1, you will need to '
                        'change the Galaxy datatype to "point.bed". To do this, click the '
                        '"pencil" icon of the history element, select the "Datatypes" tab '
                        'and select "point.bed".'])
                    return str(core)

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