示例#1
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.queryGSuite and choices.refGSuite):
            return ToolGuideController.getHtml(cls.toolId, [ToolGuideConfig.GSUITE_INPUT], choices.isBasic)

        errorString = GeneralGuiTool._checkGSuiteFile(choices.queryGSuite)
        if errorString:
            return errorString
        errorString = GeneralGuiTool._checkGSuiteFile(choices.refGSuite)
        if errorString:
            return errorString

        qGSuite = getGSuiteFromGalaxyTN(choices.queryGSuite)

        errorString = GeneralGuiTool._checkGSuiteRequirements \
            (qGSuite,
             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(qGSuite)
        if errorString:
            return errorString

        refGSuite = getGSuiteFromGalaxyTN(choices.refGSuite)

        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._validateGenome(choices)
        if errorString:
            return errorString

        errorString = cls.validateUserBins(choices)
        if errorString:
            return errorString
示例#2
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.
        '''
        errorString = cls._checkGSuiteFile(choices.gsuite)
        if errorString:
            return errorString

        gSuite = getGSuiteFromGalaxyTN(choices.gsuite)

        errorString = cls._checkGSuiteRequirements(
            gSuite,
            allowedLocations=cls.GSUITE_ALLOWED_LOCATIONS,
            allowedFileFormats=cls.GSUITE_ALLOWED_FILE_FORMATS,
            allowedTrackTypes=cls.GSUITE_ALLOWED_TRACK_TYPES)

        if errorString:
            return errorString

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

        errorString = GeneralGuiTool._checkGSuiteTrackListSize(
            gSuite, minSize=cls.GSUITE_MIN_TRACK_COUNT)
        if errorString:
            return errorString
示例#3
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
示例#4
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.multitrack.MultiTrackCommon import getGSuiteFromGalaxyTN

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

        gSuite = getGSuiteFromGalaxyTN(choices.history)

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

        errorString = GeneralGuiTool._checkGSuiteRequirements(
            gSuite, allowedLocations=cls.GSUITE_ALLOWED_LOCATIONS)
        if errorString:
            return errorString

        errorString = GeneralGuiTool._checkGSuiteTrackListSize(gSuite,
                                                               minSize=1)
        if errorString:
            return errorString
    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
示例#6
0
 def getOptionsBoxTfTracks(cls, prevChoices):
     if prevChoices.sourceTfsDetails != cls.SELECT:
         genome = prevChoices.genome
         sourceTfs = prevChoices.sourceTfs
         sourceTfsDetails = prevChoices.sourceTfsDetails
         if sourceTfs == cls.SELECT:
             return
         elif sourceTfs == 'Hyperbrowser repository':
             tfSourceTN = TfTrackNameMappings.getTfTrackNameMappings(
                 prevChoices.genome)[sourceTfsDetails]
             subtypes = ProcTrackOptions.getSubtypes(
                 prevChoices.genome, tfSourceTN, True)
             falses = ['False'] * len(subtypes)
             return OrderedDict(zip(subtypes, falses))
         elif sourceTfs == cls.REGIONS_FROM_HISTORY:
             if isinstance(sourceTfsDetails, basestring):
                 galaxyTN = sourceTfsDetails.split(':')
                 if galaxyTN[
                         1] == "gsuite":  #ExternalTrackManager.extractFileSuffixFromGalaxyTN(prevChoices.sourceTfsDetails, allowUnsupportedSuffixes=True) == "gsuite"
                     errorString = GeneralGuiTool._checkGSuiteFile(
                         sourceTfsDetails)
                     if not errorString:
                         gSuite = getGSuiteFromGalaxyTN(sourceTfsDetails)
                         sizeErrorString = GeneralGuiTool._checkGSuiteTrackListSize(
                             gSuite, 1, 1000)
                         if not sizeErrorString:
                             reqErrorString = GeneralGuiTool._checkGSuiteRequirements \
                                 (gSuite,
                                  AllTfsOfRegions.GSUITE_ALLOWED_FILE_FORMATS,
                                  AllTfsOfRegions.GSUITE_ALLOWED_LOCATIONS,
                                  AllTfsOfRegions.GSUITE_ALLOWED_TRACK_TYPES,
                                  AllTfsOfRegions.GSUITE_DISALLOWED_GENOMES)
                             if not reqErrorString:
                                 validity = 'Valid'
                             else:
                                 return
                         else:
                             return
                     else:
                         return
                     if validity == 'Valid':
                         selectedTrackNames = []
                         gSuite = getGSuiteFromGalaxyTN(sourceTfsDetails)
                         for track in gSuite.allTracks():
                             selectedTrackNames.append(':'.join(
                                 track.trackName))
                         falses = ['False'] * len(selectedTrackNames)
                         return OrderedDict(zip(selectedTrackNames, falses))
                 else:
                     tfTrackName = ExternalTrackManager.getPreProcessedTrackFromGalaxyTN(
                         genome, galaxyTN)
                     return [':'.join(tfTrackName)]
             else:
                 return
         else:
             return
     else:
         return
    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
示例#8
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 choices[0] == 'From GSuite':
            if not choices[1]:
                return 'Please select a GSuite from history'

        if choices[0] == 'From GSuite':
            errorString = GeneralGuiTool._checkGSuiteFile(choices[1])
            if errorString:
                return errorString
            gSuite = getGSuiteFromGalaxyTN(choices[1])
            errorString = GeneralGuiTool._checkGSuiteTrackListSize(gSuite,
                                                                   minSize=2)
            if errorString:
                return errorString
            errorString = GeneralGuiTool._checkGSuiteRequirements \
                (gSuite,
                 CreateBpsVennDIagram.GSUITE_ALLOWED_FILE_FORMATS,
                 CreateBpsVennDIagram.GSUITE_ALLOWED_LOCATIONS,
                 CreateBpsVennDIagram.GSUITE_ALLOWED_TRACK_TYPES,
                 CreateBpsVennDIagram.GSUITE_DISALLOWED_GENOMES)
            if errorString:
                return errorString

        genome, trackNames = CreateBpsVennDIagram.getTrackNamesFromFormParameters(
            choices)
        ret = ''
        # ret += 'coiches='+str(choices) + '<br/>'
        # ret += 'genome='+genome+'<br/>'
        # ret += 'trackNames='+str(trackNames)+'<br/><br/>'

        if choices[3] != 'Several bed files' and choices[
                0] == 'From repository':
            if len(list(trackNames)) == 0:
                return ret + 'Need one category.bed file as input'
            if len(list(trackNames)) > 1:
                return ret + 'Need just one category.bed file as input'
            if len(list(trackNames)) > len(
                    CreateBpsVennDIagram.getPrimeList()):
                return ret + 'To many files for tool, max number of files is ' + len(
                    CreateBpsVennDIagram.getPrimeList())
        else:
            if len(list(trackNames)) < 2:
                return ret + 'Need at least two tracks (or bed files) as input'

#         if ret:
#             return ret
        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.
        '''
        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
    def validateGSuite(cls, choices):
        errorString = cls._checkGSuiteFile(choices.gSuite)
        if errorString:
            return errorString

        gSuite = getGSuiteFromGalaxyTN(choices.gSuite)
        errorString = GeneralGuiTool._checkGSuiteRequirements(
            gSuite,
            allowedLocations=CommonClusteringFunctions.GSUITE_ALLOWED_LOCATIONS,
            allowedFileFormats=CommonClusteringFunctions.GSUITE_ALLOWED_FILE_FORMATS,
            allowedTrackTypes=CommonClusteringFunctions.GSUITE_ALLOWED_TRACK_TYPES)
        if errorString:
            return errorString

        errorString = GeneralGuiTool._checkGSuiteTrackListSize(gSuite, 2)
        if errorString:
            return errorString
示例#11
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