Exemple #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
Exemple #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.

        '''
        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
Exemple #3
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.
        '''
        genome = choices[1] if choices[0] == 'Yes' else None
        if genome == '':
            return 'Please select a genome build.'

        errorStr = GeneralGuiTool._checkHistoryTrack(choices, 2, genome,
                                                     'first GTrack')
        if errorStr:
            return errorStr
        errorStr = GeneralGuiTool._checkHistoryTrack(choices, 3, genome,
                                                     'second GTrack')
        if errorStr:
            return errorStr

        if choices[2] == choices[3]:
            return 'Please select two different GTrack files.'

        if len(choices[4]) == 0:
            return 'Error: the GTrack files do not contain common intersecting factors (positional information or "id" column).'
    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.
        '''
        genome = choices[1] if choices[0] == 'Yes' else None
        if genome == '':
            return 'Please select a genome build.'
        
        from gold.origdata.GtrackGenomeElementSource import GtrackGenomeElementSource

        errorStr = GeneralGuiTool._checkHistoryTrack(choices, 2, GtrackGenomeElementSource, genome, 'first GTrack')
        if errorStr:
            return errorStr
        errorStr = GeneralGuiTool._checkHistoryTrack(choices, 3, GtrackGenomeElementSource, genome, 'second GTrack')
        if errorStr:
            return errorStr
            
        if choices[2] == choices[3]:
            return 'Please select two different GTrack files.'
        
        if len(choices[4]) == 0:
            return 'Error: the GTrack files do not contain common intersecting factors (positional information or "id" column).'
Exemple #5
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
Exemple #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.
        '''

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

        gSuite = getGSuiteFromGalaxyTN(choices.gsuite)

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

        if errorString:
            return errorString

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

        return None
    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
Exemple #8
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
Exemple #10
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 validateAndReturnErrors(cls, choices):
        errorString = GeneralGuiTool._checkGSuiteFile(choices.gsuite)
        if errorString:
            return errorString

        gSuite = getGSuiteFromGalaxyTN(choices.gsuite)

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

        if errorString:
            return errorString
Exemple #13
0
    def validateAndReturnErrors(choices):
        errorStr = GeneralGuiTool._checkGenome(choices.genome)
        if errorStr:
            return errorStr

        if not choices.seqs:
            return 'Please enter at least one sequence'
    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.
        '''

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

        from quick.multitrack.MultiTrackCommon import getGSuiteFromGalaxyTN
        gSuite = getGSuiteFromGalaxyTN(choices.history)

        if gSuite.location == GSuiteConstants.REMOTE:
            return 'All tracks in GSuite file are remote. ' \
                   'Please download the tracks of the GSuite file before preprocessing.'

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

        errorStr = cls._checkGSuiteRequirements(
            gSuite,
            allowedFileFormats=cls.GSUITE_ALLOWED_FILE_FORMATS,
            allowedLocations=cls.GSUITE_ALLOWED_LOCATIONS)

        if errorStr:
            return errorStr
    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.
        '''

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

        gSuite = getGSuiteFromGalaxyTN(choices.history)
        if gSuite.numTracks() == 0:
            return 'Please select a GSuite file with at least one track'

        errorStr = cls._checkGSuiteRequirements(
            gSuite,
            allowedFileFormats = cls.GSUITE_ALLOWED_FILE_FORMATS,
            allowedLocations = cls.GSUITE_ALLOWED_LOCATIONS)
        if errorStr:
            return errorStr

        if choices.operation:
            if choices.operation == cls.NO_OPERATION_TEXT:
                return 'Please select an operation to perform on the input tracks'
            else:
                try:
                    cls._runOperationOnExampleDataAndReturnOutput(choices)
                except Exception as e:
                    return 'An error occured testing operation "%s": ' % choices.operation + str(e)

            if choices.changeSuffix == 'Yes' and choices.suffix.strip() == '':
                return 'Please select a file suffix'
    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.
        '''
        from gold.gsuite.GSuiteConstants import UNKNOWN, MULTIPLE

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

        from quick.multitrack.MultiTrackCommon import getGSuiteFromGalaxyTN
        gSuite = getGSuiteFromGalaxyTN(choices.history)
        if gSuite.numTracks() == 0:
            return 'Please select a GSuite file with at least one track'

        if not gSuite.isPreprocessed():
            return 'Selected GSuite file is not preprocess. Please preprocess ' \
                   'the GSuite file before continuing the analysis.'

        if gSuite.trackType in [UNKNOWN]:
            return 'The track type of the GSuite file is not known. The track type ' \
                   'is needed for doing analysis.'

        if gSuite.trackType in [MULTIPLE]:
            return 'All tracks in the GSuite file needs to be of the same track ' \
                   'type. Multiple track types are not supported.'
    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 = GeneralGuiTool._checkGSuiteFile(choices.gsuite)
        if errorString:
            return errorString

        gSuite = getGSuiteFromGalaxyTN(choices.gsuite)

        errorString = GeneralGuiTool._checkGSuiteRequirements \
            (gSuite,
             allowedLocations=GSuiteExportToHistoryTool.GSUITE_ALLOWED_LOCATIONS,
             allowedFileFormats=GSuiteExportToHistoryTool.GSUITE_ALLOWED_FILE_FORMATS,
             allowedTrackTypes=GSuiteExportToHistoryTool.GSUITE_ALLOWED_TRACK_TYPES)

        if errorString:
            return errorString

        if choices.changeFormat == cls.OUTPUT_FORMAT_CONVERT and choices.outputFormat is None:
            return 'There are no common supported file formats that all selected tracks can be converted to.'
    def _validateGenome(cls, choices, validateBinaryTracksIfPresent=True):
        from quick.multitrack.MultiTrackCommon import getGSuiteFromGalaxyTN
        from quick.application.ProcTrackOptions import ProcTrackOptions

        allGSuiteGalaxyTNs = [
            getattr(choices, key) for key in cls.GSUITE_FILE_OPTIONS_BOX_KEYS
        ]
        if all(allGSuiteGalaxyTNs):
            if (not cls._allowGenomeOverride(choices)
                ) and cls._getNumUniquelySpecifiedGenomes(choices) > 1:
                return cls.ERROR_GENOME_BUILD_MISMATCH + ', '.join(
                    cls._getGsuiteGenomes(choices))

            errorStr = GeneralGuiTool._checkGenome(choices.genome)
            if errorStr:
                return errorStr

            if not cls._allowMultipleGenomes(
                    choices) and choices.genome == GSuiteConstants.MULTIPLE:
                return cls.ERROR_MULTIPLE_GENOMES_NOT_ALLOWED

            if validateBinaryTracksIfPresent:
                for galaxyTN in allGSuiteGalaxyTNs:
                    gSuite = getGSuiteFromGalaxyTN(galaxyTN)
                    if gSuite.fileFormat == GSuiteConstants.PREPROCESSED and gSuite.location == GSuiteConstants.LOCAL:
                        for gSuiteTrack in gSuite.allTracks():
                            if not ProcTrackOptions.isValidTrack(
                                    choices.genome, gSuiteTrack.trackName,
                                    True):
                                return cls.ERROR_PREPROCESSED_TRACK_INVALID % gSuiteTrack.title
Exemple #19
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.
        '''

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

        gSuite = getGSuiteFromGalaxyTN(choices.history)
        if choices.rowIndices:
            try:
                selectedIndices = CommonFunctionsForTools.processIndicesString(
                    choices.rowIndices)
                maxIndex = max(selectedIndices)
                if maxIndex > (gSuite.numTracks()):
                    return 'Selected row index %i is too high. GSuite contains %i tracks.' % (
                        maxIndex, gSuite.numTracks())
            except:
                return 'Please enter valid indices string (e.g. 1-10, 12, 14)'

        if gSuite.numTracks() == 0:
            return 'GSuite file contains no tracks'
    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
Exemple #21
0
    def validateAndReturnErrors(choices):
        if choices.source == 'Tabular file from history':
            if choices.history in [None, '']:
                return 'Error: Please select a tabular file from your history. You may need to change the format of your history items to "tabular" or other tabular formats.'
        else:
            if choices.input == '':
                return 'Please type or paste the contents of a tabular file into the input box.'

        if choices.numSkipLines is not None:
            try:
                int(choices.numSkipLines.strip())
            except:
                return 'Error: please type a correct number of lines to skip ("%s")' % choices.numSkipLines.strip()

        fileContentsInfo = TabularToGtrackTool._getFileContentsInfo(choices)
        if fileContentsInfo and fileContentsInfo.error is not None:
            return fileContentsInfo.error

        if choices.selectGenome == 'Yes':
            genome = choices.genome
            if genome in [None, '']:
                return 'Please select a genome build.'
        else:
            genome = None

        if choices.handleSeqId == 'Yes, auto-correct to the best match in the genome build':
            if choices.selectGenome != 'Yes':
                return 'To auto-correct the sequence ids, you need to specify a genome build.'

        if choices.cropCrossingSegments == 'Yes':
            if choices.selectGenome != 'Yes':
                return 'To crop segments crossing sequence ends, you need to specify a genome build.'

        if choices.columnSelection == 'Base columns on existing GTrack file':
            return GeneralGuiTool._checkHistoryTrack(choices, 'colSpecFile', genome, 'GTrack')

        headers = TabularToGtrackTool._getHeaders(choices)
        if not 'seqid' in headers:
            return "Error: the 'seqid' column is mandatory but is missing."

        if 'edges' in headers and not 'id' in choices:
            return "Error: the 'id' column is missing, but is mandatory since the 'edges' column has been selected."

        if choices.createDense == 'Yes' and not 'start' in headers:
            return 'The start column must be defined in order to create dense track types.'

        if choices.trackType is None:
            return 'Error: the columns selected do not define a GTrack track type. Please refer to the GTrack specification for more information.'
        elif any(x in choices.trackType.lower() for x in ['function', 'partition', 'base pairs']) and choices.createDense == 'No':
            denseTracksBasis = {'Function (F)': 'Valued Points (VP)', 'Step Function (SF)': 'Valued Segments (VS)',
                                'Genome Partition (GP)': 'Segments (S)', 'Linked Base Pairs (LBP)': 'Points (P)'}
            trackType, trackTypeBasis = choices.trackType, denseTracksBasis[choices.trackType]
            return 'Error: to create track type "%s", you must use select columns corresponing to track type "%s" and ' % (trackType, trackTypeBasis) + \
                    'select "Yes" for "Create dense track type". For linked track types, select the appropriate "linked" or "edges" columns.'

        return None
Exemple #22
0
    def getOptionsBoxQueryTrack(prevChoices):
        """
        Defines the type and contents of the input box. User selections are
        returned to the tools in the prevChoices and choices attributes to other
        methods. These are lists of results, one for each input box (in the
        order specified by getInputBoxOrder()).

        The input box is defined according to the following syntax:

        Selection box:          ['choice1','choice2']
        - Returns: string

        Text area:              'textbox' | ('textbox',1) | ('textbox',1,False)
        - Tuple syntax: (contents, height (#lines) = 1, read only flag = False)
        - The contents is the default value shown inside the text area
        - Returns: string

        Raw HTML code:          '__rawstr__', 'HTML code'
        - This is mainly intended for read only usage. Even though more advanced
          hacks are possible, it is discouraged.

        Password field:         '__password__'
        - Returns: string

        Genome selection box:   '__genome__'
        - Returns: string

        Track selection box:    '__track__'
        - Requires genome selection box.
        - Returns: colon-separated string denoting track name

        History selection box:  ('__history__',) | ('__history__', 'bed', 'wig')
        - Only history items of specified types are shown.
        - Returns: colon-separated string denoting galaxy track name, as
                   specified in ExternalTrackManager.py.

        History check box list: ('__multihistory__', ) | ('__multihistory__', 'bed', 'wig')
        - Only history items of specified types are shown.
        - Returns: OrderedDict with galaxy id as key and galaxy track name
                   as value if checked, else None.

        Hidden field:           ('__hidden__', 'Hidden value')
        - Returns: string

        Table:                  [['header1','header2'], ['cell1_1','cell1_2'], ['cell2_1','cell2_2']]
        - Returns: None

        Check box list:         OrderedDict([('key1', True), ('key2', False), ('key3', False)])
        - Returns: OrderedDict from key to selection status (bool).
        :param prevChoices:
        """
        return GeneralGuiTool.getHistorySelectionElement(
            *getSupportedFileSuffixesForPointsAndSegments()
        )
Exemple #23
0
    def getOptionsBoxGsuite(prevChoices):  # Alternatively: getOptionsBox2()
        '''
        See getOptionsBoxFirstKey().

        prevChoices is a namedtuple of selections made by the user in the
        previous input boxes (that is, a namedtuple containing only one element
        in this case). The elements can accessed either by index, e.g.
        prevChoices[0] for the result of input box 1, or by key, e.g.
        prevChoices.key (case 2).
        '''
        return GeneralGuiTool.getHistorySelectionElement('gsuite')
 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.
     '''
     errorStr = GeneralGuiTool._checkGSuiteFile(choices.gsuite)
     if errorStr:
         return errorStr
Exemple #25
0
    def getOptionsBoxRefTrack(prevChoices): # Alternatively: getOptionsBox2()
        '''
        See getOptionsBoxFirstKey().

        prevChoices is a namedtuple of selections made by the user in the
        previous input boxes (that is, a namedtuple containing only one element
        in this case). The elements can accessed either by index, e.g.
        prevChoices[0] for the result of input box 1, or by key, e.g.
        prevChoices.key (case 2).
        '''
        if prevChoices.gSuite and prevChoices.normStrat and prevChoices.normStrat in [NormalizeTracksInGSuiteTool.NORM_STRAT_TMM]:
            return GeneralGuiTool.getHistorySelectionElement('gtrack', 'bed')
 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.
     '''
     
     genome = choices[1] if choices[0] == 'Yes' else None
     if genome == '':
         return 'Please select a genome build.'
     
     return GeneralGuiTool._checkHistoryTrack(choices, 2, genome, 'GTrack')
    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.
        '''

        genome = choices[1] if choices[0] == 'Yes' else None
        if genome == '':
            return 'Please select a genome build.'
        
        from gold.origdata.GtrackGenomeElementSource import GtrackGenomeElementSource
        return GeneralGuiTool._checkHistoryTrack(choices, 2, GtrackGenomeElementSource, genome, 'GTrack')
 def validateAndReturnErrors(choices):
     genome = choices.genome if choices.selectGenome == 'Yes' else None
     
     if genome == '':
         return 'Please select a genome build.'
 
     error = GeneralGuiTool._checkHistoryTrack(choices, 'history', GenomeElementSource, genome)
     if error:
        return error
         
     if choices.conversion is None:
         suffix = ExternalTrackManager.extractFileSuffixFromGalaxyTN(choices.history.split(':'))
         return 'No conversions available for the selected file. Please make ' \
                'sure that the file type is correct. Current file type: %s' % suffix
    def getOptionsBoxHistElement(
            prevChoices):  # Alternatively: getOptionsBox1()
        '''
        Defines the type and contents of the input box. User selections are
        returned to the tools in the prevChoices and choices attributes to other
        methods. These are lists of results, one for each input box (in the
        order specified by getInputBoxOrder()).

        The input box is defined according to the following syntax:

        Selection box:          ['choice1','choice2']
        - Returns: string

        Text area:              'textbox' | ('textbox',1) | ('textbox',1,False)
        - Tuple syntax: (contents, height (#lines) = 1, read only flag = False)
        - The contents is the default value shown inside the text area
        - Returns: string

        Password field:         '__password__'
        - Returns: string

        Genome selection box:   '__genome__'
        - Returns: string

        Track selection box:    '__track__'
        - Requires genome selection box.
        - Returns: colon-separated string denoting track name

        History selection box:  ('__history__',) | ('__history__', 'bed', 'wig')
        - Only history items of specified types are shown.
        - Returns: colon-separated string denoting galaxy track name, as
                   specified in ExternalTrackManager.py.

        History check box list: ('__multihistory__', ) | ('__multihistory__', 'bed', 'wig')
        - Only history items of specified types are shown.
        - Returns: OrderedDict with galaxy id as key and galaxy track name
                   as value if checked, else None.

        Hidden field:           ('__hidden__', 'Hidden value')
        - Returns: string

        Table:                  [['header1','header2'], ['cell1_1','cell1_2'], ['cell2_1','cell2_2']]
        - Returns: None

        Check box list:         OrderedDict([('key1', True), ('key2', False), ('key3', False)])
        - Returns: OrderedDict from key to selection status (bool).
        '''
        #should accept only gtrack suite (but user may not be aware of the types, a file uploaded with Upload file galaxy tool will upload a gsuite as txt by default)
        return GeneralGuiTool.getHistorySelectionElement('gsuite')
    def validateAndReturnErrors(choices):
        genome = choices.genome if choices.selectGenome == 'Yes' else None

        if genome == '':
            return 'Please select a genome build.'

        error = GeneralGuiTool._checkHistoryTrack(choices, 'history', genome)
        if error:
            return error

        if choices.conversion is None:
            suffix = ExternalTrackManager.extractFileSuffixFromGalaxyTN(
                choices.history.split(':'))
            return 'No conversions available for the selected file. Please make ' \
                   'sure that the file type is correct. Current file type: %s' % suffix
Exemple #31
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.selectGenome == 'Yes':
            errorStr = GeneralGuiTool._checkGenome(choices.genome)
            if errorStr:
                return errorStr

        if not any(val is not None for val in choices.history.values()):
            return 'Please select at least one history element'
    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.

        '''

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

        if not choices.selectColumns is None and len(choices.selectColumns) == 0:
            return 'GSuite file contains only standard columns'
Exemple #33
0
    def getOptionsBoxGSuiteRef(cls, prevChoices):
        '''
        See getOptionsBoxFirstKey().

        prevChoices is a namedtuple of selections made by the user in the
        previous input boxes (that is, a namedtuple containing only one element
        in this case). The elements can accessed either by index, e.g.
        prevChoices[0] for the result of input box 1, or by key, e.g.
        prevChoices.key (case 2).
        '''
        #TODO: boris 20141102, return reference track gsuite element if
        #appropriate feature extraction strategy is selected
        if prevChoices.similarityTech == cls.SIMILARITY_RELATIONS_TO_OTHER \
        or prevChoices.similarityTech == cls.REGIONS_CLUSTERING:
            return GeneralGuiTool.getHistorySelectionElement('gsuite')
        else:
            return None
 def validateAndReturnErrors(choices):
     if choices.source == 'Tabular file from history':
         if choices.history is None:
             return 'Error: The history does not contain any tabular files. You may need to change the format of your history items to "tabular" or other tabular formats.'
     else:
         if choices.input == '':
             return 'Please type or paste the contents of a tabular file into the input box.'
     
     if choices.numSkipLines is not None:
         try:
             int(choices.numSkipLines.strip())
         except:
             return 'Error: please type a correct number of lines to skip ("%s")' % choices.numSkipLines.strip()
     
     fileContentsInfo = TabularToGtrackTool._getFileContentsInfo(choices)
     if fileContentsInfo.error is not None:
         return fileContentsInfo.error
     
     genome = choices.genome if choices.selectGenome == 'Yes' else None
     if genome == '':
         return 'Please select a genome build.'
     
     if choices.handleSeqId == 'Yes, auto-correct to the best match in the genome build':
         if choices.selectGenome != 'Yes':
             return 'To auto-correct the sequence ids, you need to specify a genome build.'
     
     if choices.columnSelection == 'Base columns on existing GTrack file':
         from gold.origdata.GtrackGenomeElementSource import GtrackGenomeElementSource
         return GeneralGuiTool._checkHistoryTrack(choices, 'colSpecFile', GtrackGenomeElementSource, genome, 'GTrack')
     
     headers = TabularToGtrackTool._getHeaders(choices)
     if not 'seqid' in headers:
         return "Error: the 'seqid' column is mandatory but is missing."
     
     if 'edges' in headers and not 'id' in choices:
         return "Error: the 'id' column is missing, but is mandatory since the 'edges' column has been selected."
     
     if choices.trackType is None:
         return 'Error: the columns selected do not define a GTrack track type. Please refer to the GTrack specification for more information.'
     elif any(x in choices.trackType.lower() for x in ['function', 'partition', 'base pairs']):
         from gold.application.LogSetup import logLackOfSupport
         logLackOfSupport('Track type "%s" is not yet supported by TabularToGtrackTool.' % choices.trackType)
         return 'Error: the track type "%s" is not yet fully supported by this tool.' % choices.trackType
     
     return None
    def validateAndReturnErrors(cls, choices=None):

        errorStr = GeneralGuiTool._checkGSuiteFile(choices.gSuite)
        if errorStr:
            return errorStr

        gSuite = getGSuiteFromGalaxyTN(choices.gSuite)
        if gSuite.numTracks() == 0:
            return 'Please select a GSuite file with at least one track'

        errorStr = cls._checkGSuiteRequirements(
            gSuite,
            allowedFileFormats=cls.GSUITE_ALLOWED_FILE_FORMATS,
            allowedLocations=cls.GSUITE_ALLOWED_LOCATIONS
        )

        if errorStr:
            return errorStr
    def validateAndReturnErrors(cls, choices):

        errorString = GeneralGuiTool._checkGSuiteFile(choices.gSuite)
        if errorString:
            return errorString
        
        gSuite = getGSuiteFromGalaxyTN(choices.gSuite)
        errorString = GeneralGuiTool._checkGSuiteRequirements \
            (gSuite)
        
        if errorString:
            return errorString
        
        columnY = choices.columnY
        if isinstance(columnY, dict):
            if not True in columnY.values():
                errorString = 'Check at least one value for y-Axis'
                return errorString
 def getOptionsBoxLdGraphTrack():
     return GeneralGuiTool.getHistorySelectionElement('gtrack')
 def getOptionsBoxLdTrack(choices):
     return GeneralGuiTool.getHistorySelectionElement('gtrack')
 def getOptionsBoxGSuite():
     return GeneralGuiTool.getHistorySelectionElement('gsuite')