Ejemplo n.º 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
 def getOptionsBoxGenome(prevChoices):
     if not prevChoices.firstGSuite:
         return
     if not prevChoices.secondGSuite:
         return
     
     #it will be good to have box with selected genome instead of text
     
     if prevChoices.firstGSuite and prevChoices.secondGSuite:
         first = getGSuiteFromGalaxyTN(prevChoices.firstGSuite)
         second = getGSuiteFromGalaxyTN(prevChoices.secondGSuite)
         if first.genome or second.genome:
             return first.genome
         else:
             attributeList1 = first.attributes
             attributeList2 = second.attributes
             retDict = OrderedDict()
             
             for et in attributeList1:
                 retDict[et+' (first GSuite)'] = False
                 
             for et in attributeList2:
                 retDict[et+' (second GSuite)'] = False
             
             return retDict
     else:
         return 
Ejemplo n.º 3
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
Ejemplo n.º 4
0
    def execute(cls, choices, galaxyFn=None, username=''):

        basisTrackNameAsList = choices.basisTrack.split(':')
        extractionOptions = dict(
            GalaxyInterface.getTrackExtractionOptions(choices.genome,
                                                      basisTrackNameAsList))
        extractionFormat = extractionOptions[
            choices.extFormatLbl] if extractionOptions else None

        gsuite = getGSuiteFromGalaxyTN(choices.gsuite)
        outGSuite = GSuite()
        for gsTrack in gsuite.allTracks():
            # outputTrackFn = cls.extraGalaxyFn[gsTrack.title]
            # print '<br>\n<br>\n output track filename: ', outputTrackFn
            # print 'path: ', gsTrack.path
            # print 'parsed uri: ', gsTrack._parsedUri
            newTrackFileName = gsTrack.title + '.' + extractionFormat
            outGalaxyFn = ExternalTrackManager.createGalaxyFilesFn(
                galaxyFn, newTrackFileName)
            ensurePathExists(outGalaxyFn)
            uri = GalaxyGSuiteTrack.generateURI(galaxyFn,
                                                extraFileName=newTrackFileName)
            GalaxyInterface.parseExtFormatAndExtractTrackManyBins(
                choices.genome, basisTrackNameAsList, gsTrack.suffix,
                gsTrack.path, True, choices.extFormatLbl, outGalaxyFn)

            outGSuite.addTrack(
                GSuiteTrack(uri,
                            title=gsTrack.title,
                            fileFormat=gsTrack.fileFormat,
                            trackType=gsTrack.trackType,
                            genome=choices.genome,
                            attributes=gsTrack.attributes))

        GSuiteComposer.composeToFile(outGSuite, galaxyFn)
    def execute(cls, choices, galaxyFn=None, username=''):
        '''
        Is called when execute-button is pushed by web-user. Should print
        output as HTML to standard out, which will be directed to a results page
        in Galaxy history. If getOutputFormat is anything else than HTML, the
        output should be written to the file with path galaxyFn. If needed,
        StaticFile can be used to get a path where additional files can be put
        (e.g. generated image files). choices is a list of selections made by
        web-user in each options box.
        '''
        gSuite = getGSuiteFromGalaxyTN(choices.gsuite)

        attrName = choices.attrName

        outputGSuite = GSuite()

        #Writes the information that has been changed to a new track but jumps over all the empty strings
        for i, track in enumerate(gSuite.allTracks()):
            if i < cls.MAX_NUM_OF_TRACKS:
                newAttrValue = getattr(choices,
                                       'selectAttribute%s' % ((i * 2) + 1))
                if (attrName == TITLE_COL):
                    track.title = newAttrValue
                else:
                    track.setAttribute(attrName, newAttrValue)
            outputGSuite.addTrack(track)

        #Creates the new GSuite
        GSuiteComposer.composeToFile(outputGSuite, galaxyFn)
 def getOptionsBoxGsuiteAttributeValues(cls, prevChoices):
     if prevChoices.gsuite:
         gSuite = getGSuiteFromGalaxyTN(prevChoices.gsuite)
         return '__hidden__', [
             track.getAttribute(prevChoices.attrName)
             for track in gSuite.allTracks()
         ]
    def execute(cls, choices, galaxyFn=None, username=''):

        cls._setDebugModeIfSelected(choices)

        gSuite = getGSuiteFromGalaxyTN(choices.gsuite)
        if gSuite.genome != choices.genome:
            gSuite.setGenomeOfAllTracks(choices.genome)
        regSpec, binSpec = UserBinMixin.getRegsAndBinsSpec(choices)
        paragraphs = []
        paragraphs += generatePilotPageTwoParagraphs(gSuite,
                                                     galaxyFn,
                                                     regSpec=regSpec,
                                                     binSpec=binSpec)
        paragraphs += generatePilotPageThreeParagraphs(gSuite,
                                                       galaxyFn,
                                                       regSpec=regSpec,
                                                       binSpec=binSpec)

        core = HtmlCore()
        core.begin()
        core.divBegin(divId='results-page')
        core.divBegin(divClass='results-section')
        core.header('Similarity and uniqueness of tracks')
        for prg in paragraphs:
            core.paragraph(prg)
        core.divEnd()
        core.divEnd()
        core.end()

        print core
    def execute(cls, choices, galaxyFn=None, username=''):
        import time
        start = time.clock()

        # HTML settings
        from gold.result.HtmlCore import HtmlCore
        htmlCore = HtmlCore()
        htmlCore.divBegin(style=cls.HTML_STYLE)

        # Set debug environment
        cls._setDebugModeIfSelected(choices)

        # Analysis environment
        gSuite = getGSuiteFromGalaxyTN(choices.gSuite)
        analysisBins = GlobalBinSource(gSuite.genome)

        # Print info about tool
        cls.htmlClusterTitle(cls.getToolName(), htmlCore)
        cls.htmlClusterSubtext(choices.corrStat, [cls.CORR_PEARSON, cls.CORR_SPEARMAN],
                               choices.linkageCriterion, htmlCore)
        cls.htmlVectorExplanation(htmlCore)

        corrDict, labels = cls.trackOverlapValuesCorrelation(analysisBins, gSuite)
        if corrDict and labels:
            cls.printCorrPlots(corrDict, labels, choices.corrStat, choices.linkageCriterion, galaxyFn, htmlCore)

        cls.htmlClusterTime(str(time.clock() - start), htmlCore)
        htmlCore.divEnd()
        print htmlCore
    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.'
Ejemplo n.º 10
0
    def getOptionsBoxSelectRows(cls, prevChoices):

        if prevChoices.history == None:
            return
        try:
            gSuite = getGSuiteFromGalaxyTN(prevChoices.history)
            rowIndicesStr = prevChoices.rowIndices
            if rowIndicesStr:
                selectedIndices = CommonFunctionsForTools.processIndicesString(
                    rowIndicesStr)
                resDict = OrderedDict()
                for i, trackTitle in enumerate(gSuite.allTrackTitles()):
                    if (i + 1) in selectedIndices:
                        resDict[cls.addIndexToTitle((i + 1),
                                                    trackTitle)] = True
                    else:
                        resDict[cls.addIndexToTitle((i + 1),
                                                    trackTitle)] = False
                return resDict
#                 if selectedIndices:
#                     return
            return OrderedDict([(cls.addIndexToTitle(
                (i + 1),
                x), True) for i, x in enumerate(gSuite.allTrackTitles())])
        except:
            pass
Ejemplo n.º 11
0
    def execute(choices, galaxyFn=None, username=''):
        '''
        Is called when execute-button is pushed by web-user. Should print
        output as HTML to standard out, which will be directed to a results page
        in Galaxy history. If getOutputFormat is anything else than HTML, the
        output should be written to the file with path galaxyFn. If needed,
        StaticFile can be used to get a path where additional files can be put
        (e.g. generated image files). choices is a list of selections made by
        web-user in each options box.
        '''

        gSuite = getGSuiteFromGalaxyTN(choices.gSuite)
        regSpec, binSpec = UserBinMixin.getRegsAndBinsSpec(choices)
        analysisBins = GalaxyInterface._getUserBinSource(regSpec,
                                                         binSpec,
                                                         genome=gSuite.genome)
        gSuiteOverview = GSuiteOverview(gSuite)
        coreHtml = HtmlCore()
        coreHtml.begin()
        coreHtml.append(
            str(
                getGSuiteOverviewHtmlCore(
                    gSuiteOverview.getGSuiteOverviewData(
                        analysisBins=analysisBins))))
        coreHtml.end()
        print coreHtml
Ejemplo n.º 12
0
    def validateAndReturnErrors(cls, choices):
        errMessage = GeneralGuiTool._checkGSuiteFile(choices.gsuite)
        if errMessage:
            return errMessage

        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

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

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

        errorString = cls._checkGSuiteTrackListSize(gSuite=gSuite, minSize=2)
        if errorString:
            return errorString
    def execute(cls, choices, galaxyFn=None, username=''):
        from quick.util.CommonFunctions import getFileSuffix
        import gold.gsuite.GSuiteComposer as GSuiteComposer
        from gold.gsuite.GSuite import GSuite
        from gold.gsuite.GSuiteTrack import registerGSuiteTrackClass, GSuiteTrack, FileGSuiteTrack

        registerGSuiteTrackClass(FileGSuiteTrack)

        gSuite = getGSuiteFromGalaxyTN(choices.gsuite)

        outGSuite = GSuite()

        for track in gSuite.allTracks():
            path = track.path
            suffix = track.suffix if track.suffix != getFileSuffix(
                path) else ''
            uri = FileGSuiteTrack.generateURI(path=path, suffix=suffix)

            newTrack = GSuiteTrack(uri,
                                   title=track.title,
                                   trackType=track.trackType,
                                   genome=track.genome,
                                   attributes=track.attributes)

            outGSuite.addTrack(newTrack)

        GSuiteComposer.composeToFile(outGSuite, galaxyFn)
    def getOptionsBoxColors(cls, prevChoices):

        if not prevChoices.refTrackCollection:
            return

        start = '<div style="float:left;width:50px; height:20px; margin-right:5px; background-color:rgb('
        end = ')"></div>'

        try:
            refGSuite = getGSuiteFromGalaxyTN(prevChoices.refTrackCollection)
        except Exception as e:
            cls.exception = str(e)
            return

        maxSize = 10
        size = refGSuite.numTracks()
        if size > maxSize:
            errorString = 'Selected GSuite must have at most %s tracks' %maxSize
            errorString += '.<br /> Current number of tracks = ' + str(refGSuite.numTracks())
            cls.exception = errorString
            return

        col = [['Track','Color']]
        i=1
        for trackTitle in refGSuite.allTrackTitles():
            c=[]
            c.append(trackTitle)
            c.append(start + colorTab.getRGB(i) + end)
            col.append(c)
            i+=1

        return col
Ejemplo n.º 15
0
    def execute(cls, choices, galaxyFn=None, username=''):
        '''
        Is called when execute-button is pushed by web-user. Should print
        output as HTML to standard out, which will be directed to a results page
        in Galaxy history. If getOutputFormat is anything else than HTML, the
        output should be written to the file with path galaxyFn. If needed,
        StaticFile can be used to get a path where additional files can be put
        (e.g. generated image files). choices is a list of selections made by
        web-user in each options box.
        '''

        import gold.gsuite.GSuiteComposer as GSuiteComposer
        from gold.gsuite.GSuite import GSuite
        from gold.gsuite.GSuiteTrack import GSuiteTrack, GalaxyGSuiteTrack
        from quick.application.UserBinSource import GlobalBinSource
        from quick.extra.ProgressViewer import ProgressViewer
        from quick.extra.TrackExtractor import TrackExtractor

        genome = choices.genome
        fullGenomeBins = GlobalBinSource(genome)
        gSuite = getGSuiteFromGalaxyTN(choices.gsuite)

        progressViewer = ProgressViewer(
            [(cls.PROGRESS_PROCESS_DESCRIPTION, len(gSuite))], galaxyFn)

        outGSuite = GSuite()
        hiddenStorageFn = cls.extraGalaxyFn[getGSuiteHistoryOutputName(
            'storage', datasetInfo=choices.gsuite)]

        fileNameSet = set()
        for track in gSuite.allTracks():
            fileName = cls._getUniqueFileName(fileNameSet, track.trackName)
            title = track.title
            attributes = track.attributes
            fi = cls._getFileFormatInfo(choices, gSuite, genome, track)

            uri = GalaxyGSuiteTrack.generateURI(galaxyFn=hiddenStorageFn,
                                                extraFileName=fileName,
                                                suffix=fi.suffix)

            gSuiteTrack = GSuiteTrack(uri,
                                      title=title,
                                      genome=genome,
                                      attributes=attributes)

            TrackExtractor.extractOneTrackManyRegsToOneFile(
                track.trackName,
                fullGenomeBins,
                gSuiteTrack.path,
                fileFormatName=fi.fileFormatName,
                globalCoords=True,
                asOriginal=fi.asOriginal,
                allowOverlaps=fi.allowOverlaps)

            outGSuite.addTrack(gSuiteTrack)
            progressViewer.update()

        primaryFn = cls.extraGalaxyFn[getGSuiteHistoryOutputName(
            'primary', datasetInfo=choices.gsuite)]
        GSuiteComposer.composeToFile(outGSuite, primaryFn)
 def getOptionsBoxSecondGSuiteColumn(prevChoices):
     if prevChoices.secondGSuite:
         second = getGSuiteFromGalaxyTN(prevChoices.secondGSuite)
         attributeList = [None] + second.attributes
         return attributeList
     else:
         return
    def execute(cls,choices, galaxyFn=None, username=''):
        '''
        Is called when execute-button is pushed by web-user. Should print
        output as HTML to standard out, which will be directed to a results page
        in Galaxy history. If getOutputFormat is anything else than HTML, the
        output should be written to the file with path galaxyFn. If needed,
        StaticFile can be used to get a path where additional files can be put
        (e.g. generated image files). choices is a list of selections made by
        web-user in each options box.
        '''

        from quick.multitrack.MultiTrackCommon import getGSuiteFromGalaxyTN
        from gold.gsuite.GSuiteEditor import selectColumnsFromGSuite
        from gold.gsuite.GSuiteConstants import TITLE_COL
        from gold.gsuite.GSuiteComposer import composeToFile

        gSuite = getGSuiteFromGalaxyTN(choices.history)

        colList = [col for col,selected in choices.selectColumns.iteritems() if selected]
        selectedAttributes = [col for col in colList if col != TITLE_COL]
        selectTitle = TITLE_COL in colList

        filteredGSuite = selectColumnsFromGSuite(gSuite, selectedAttributes,
                                                 selectTitle=selectTitle)

        composeToFile(filteredGSuite, galaxyFn)
Ejemplo n.º 18
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 getOptionsBoxFirstGSuiteColumn(prevChoices):
     if prevChoices.firstGSuite:
         first = getGSuiteFromGalaxyTN(prevChoices.firstGSuite)
         attributeList = [None] + first.attributes
         return attributeList
     else:
         return
Ejemplo n.º 20
0
    def execute(cls, choices, galaxyFn=None, username=''):
        """
        Is called when execute-button is pushed by web-user. Should print
        output as HTML to standard out, which will be directed to a results
        page in Galaxy history. If getOutputFormat is anything else than
        'html', the output should be written to the file with path galaxyFn.
        If needed, StaticFile can be used to get a path where additional
        files can be put (cls, e.g. generated image files). choices is a list
        of selections made by web-user in each options box.

        Mandatory unless isRedirectTool() returns True.
        """
        choices_gsuite = choices.chooseTrackFiles
        choices_randType = choices.randType
        choices_randAlg = choices.randAlg
        choices_numberOfTimesToRandomize = choices.numberOfTimesToRandomize
        assert choices_gsuite is not None

        genome =  choices.genome
        assert genome is not None
        analysisBins = UserBinMixin.getUserBinSource(choices)

        gsuite = getGSuiteFromGalaxyTN(choices_gsuite)
        for i, gsTrack in enumerate(gsuite.allTracks()):
            assert gsTrack.trackName is not None, "gsuite track %s has track name None" % gsTrack
        ts = getFlatTracksTS(genome, choices_gsuite)

        cls.run_on_extracted_variables(ts, analysisBins, choices_numberOfTimesToRandomize, choices_randAlg,
                                       choices_randType, galaxyFn, genome)
    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 execute(choices, galaxyFn=None, username=''):

        gsuite = getGSuiteFromGalaxyTN(choices.gsuite)
        bedRegions = choices.bedRegions

        rp = RP(gsuite)
        bedData = rp.openBedFile(bedRegions)
        chrOrder, chrLength = rp.sortChrDict()
        dataDict, dataDictLine, elementOrder, listResCopy, newDictRegions = rp.countMutations(
            chrLength, bedData)

        vg = visualizationGraphs()
        tName = gsuite.allTrackTitles()

        uniformDictList = OrderedDict()  # expected values
        observedDictList = OrderedDict()  # observed values
        seriesNameRegionUDL = OrderedDict()
        seriesNameRegionODL = OrderedDict()
        seriesNameRegion = OrderedDict()

        GenerateDistributionOfPointsOfInterestTool.countRegionsForDistribution(
            newDictRegions, observedDictList, rp, seriesNameRegion,
            seriesNameRegionODL, seriesNameRegionUDL, tName, uniformDictList)
        res = ''
        for elK in uniformDictList.keys():
            res += GenerateDistributionOfPointsOfInterestTool.drawDistribution(
                elK, observedDictList, seriesNameRegion, seriesNameRegionODL,
                seriesNameRegionUDL, uniformDictList, vg)

        htmlCore = HtmlCore()
        htmlCore.begin()
        htmlCore.line(res)
        htmlCore.end()
        htmlCore.hideToggle(styleClass='debug')
        print htmlCore
    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_TYPES,
            allowedTrackTypes=cls.GSUITE_ALLOWED_TRACK_TYPES)
        if errorString:
            return errorString

        errorString = cls._validateGenome(choices.genome)
        if errorString:
            return errorString
Ejemplo n.º 24
0
    def getOptionsBoxRowIndices(cls, prevChoices):
        if prevChoices.history == None:
            return

        gSuite = getGSuiteFromGalaxyTN(prevChoices.history)

        return '1-%i' % (gSuite.numTracks() + 1)
Ejemplo n.º 25
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 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 _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
    def execute(cls, choices, galaxyFn=None, username=''):
        import time
        start = time.clock()

        # HTML settings
        from gold.result.HtmlCore import HtmlCore
        htmlCore = HtmlCore()
        htmlCore.divBegin(style=cls.HTML_STYLE)

        # Set debug environment
        cls._setDebugModeIfSelected(choices)

        # Analysis environment
        gSuite = getGSuiteFromGalaxyTN(choices.gSuite)
        analysisBins = GlobalBinSource(gSuite.genome)
        analysisSpec = AnalysisSpec(GeneticLociOverlapStat)
        analysisSpec.addParameter('filterThreshold', int(choices.geneticLocus))

        # Print tool information:
        cls.htmlClusterTitle(cls.getToolName(), htmlCore)
        cls.htmlClusterSubtext(choices.corrStat, [cls.CORR_PEARSON, cls.CORR_SPEARMAN],
                               choices.linkageCriterion, htmlCore)
        cls.htmlVectorHandling(htmlCore)

        # Get correlations
        overlapMatrix, labels = cls.getOverlapMatrix(analysisBins, analysisSpec, gSuite)
        corrDict = cls.getTriangularCorrMatrix(overlapMatrix)
        cls.printCorrPlots(corrDict, labels, choices.corrStat, choices.linkageCriterion, galaxyFn, htmlCore)

        cls.htmlClusterTime(str(time.clock() - start), htmlCore)
        htmlCore.divEnd()
        print htmlCore
Ejemplo n.º 28
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'
Ejemplo n.º 29
0
 def getOptionsBoxChangeFormat(cls, prevChoices):
     if prevChoices.gsuite and prevChoices.genome:
         gSuite = getGSuiteFromGalaxyTN(prevChoices.gsuite)
         if cls._allTracksHasOriginalFormat(gSuite, prevChoices.genome):
             return [cls.OUTPUT_FORMAT_ORIGINAL, cls.OUTPUT_FORMAT_OTHER]
         else:
             return [cls.OUTPUT_FORMAT_OTHER]
Ejemplo n.º 30
0
    def execute(cls, choices, galaxyFn=None, username=''):
        '''
        Is called when execute-button is pushed by web-user. Should print
        output as HTML to standard out, which will be directed to a results page
        in Galaxy history. If getOutputFormat is anything else than HTML, the
        output should be written to the file with path galaxyFn. If needed,
        StaticFile can be used to get a path where additional files can be put
        (e.g. generated image files). choices is a list of selections made by
        web-user in each options box.
        '''

        gSuite = getGSuiteFromGalaxyTN(choices.history)

        #         titleList = []
        #         if choices.rowIndices:
        #             selectedIndices = CommonFunctionsForTools.processIndicesString(choices.rowIndices)
        #             titleList = [tt for i, tt in enumerate(gSuite.allTrackTitles()) if i in selectedIndices]
        #         else:
        titleList = [
            cls.removeIndexFromTitleName(title)
            for title, selected in choices.selectRows.iteritems() if selected
        ]
        filteredGSuite = selectRowsFromGSuiteByTitle(gSuite, titleList)

        composeToFile(filteredGSuite, galaxyFn)
 def getOptionsBoxAdditionalAttributes(cls, prevChoices):
     galaxyGSName = getattr(prevChoices, cls.GSUITE_FILE_OPTIONS_BOX_KEY)
     if galaxyGSName:
         gsuite = getGSuiteFromGalaxyTN(galaxyGSName)
         if gsuite.attributes:
             return OrderedDict(
                 zip(gsuite.attributes, [False] * len(gsuite.attributes)))
    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.'
Ejemplo n.º 33
0
    def execute(cls, choices, galaxyFn=None, username=''):
        from quick.webtools.clustering.GSuitePrimaryTrackModifier import GSuitePrimaryTrackModifier

        # Set analysis environment
        gSuite = getGSuiteFromGalaxyTN(choices.gSuite)
        outGSuite = GSuite()
        errorGSuite = GSuite()
        progressViewer = ProgressViewer([('Manipulate tracks', gSuite.numTracks() + 24)],
                                        cls.extraGalaxyFn[cls.HISTORY_PROGRESS_TITLE])
        hiddenStorageFn = cls.extraGalaxyFn[cls.HISTORY_HIDDEN_TRACK_STORAGE]

        # Get rsID map for the chosen reference genome
        rsidMap = RsidMapper.createRsidMappingFromStaticFiles(progressViewer, choices.refGenome)

        # Lift over all tracks
        for track in gSuite.allTracks():
            fileName = cls.getFilenameWithGTrackSuffix(track.path)
            title = getTitleWithSuffixReplaced(track.title, 'gtrack')

            try:
                uri = GalaxyGSuiteTrack.generateURI(
                    galaxyFn=hiddenStorageFn,
                    extraFileName=fileName,
                    suffix='gtrack'
                )

                gSuiteTrack = GSuiteTrack(
                    uri,
                    title=title,
                    genome=track.genome,
                    trackType=track.trackType,
                    attributes=track.attributes
                )

                trackFn = gSuiteTrack.path
                GSuitePrimaryTrackModifier.liftOverGTrack(track.path, trackFn, rsidMap)
                outGSuite.addTrack(gSuiteTrack)

            except Exception as e:
                track.comment = 'An error occurred for the following track: ' + str(e)
                errorGSuite.addTrack(track)

            progressViewer.update()

        # Update reference genome of all tracks and write to file
        outGSuite.setGenomeOfAllTracks(choices.refGenome)
        composeToFile(outGSuite, galaxyFn)
        composeToFile(errorGSuite, cls.extraGalaxyFn[cls.HISTORY_ERROR_TITLE])
        writeGSuiteHiddenTrackStorageHtml(hiddenStorageFn)
    def execute(cls, choices, galaxyFn=None, username=''):
        import time
        start = time.clock()

        # HTML settings
        from gold.result.HtmlCore import HtmlCore
        htmlCore = HtmlCore()
        htmlCore.divBegin(style=cls.HTML_STYLE)

        # Set debug environment
        cls._setDebugModeIfSelected(choices)

        # Print tool information
        cls.htmlClusterTitle(choices.ldGraphMatching, htmlCore)
        cls.htmlClusterSubtext(choices.distanceMeasure, cls.CLUSTER_LIST, choices.linkageCriterion, htmlCore)
        htmlCore.line('Threshold of r<sup>2</sup>: ' + choices.rSquare)

        # Analysis environment
        gSuite = getGSuiteFromGalaxyTN(choices.gSuite)
        analysisBins = GlobalBinSource(gSuite.genome)

        graph = LDExpansions.createRSquareGraph(choices.ldGraphTrack, float(choices.rSquare))
        tracks, labels = LDExpansions.generateTracksAndLabels(gSuite, analysisBins)

        # Find distance/correlation matrices
        size = gSuite.numTracks()
        distDict = cls.createDistDict(cls.CLUSTER_LIST)
        for i in range(0, size):
            for j in range(i + 1, size):

                track1 = tracks[i]
                track2 = tracks[j]

                cost_matrix = BipartiteMatching.generateCostMatrix(track1, track2, graph)

                if choices.ldGraphMatching == LDBipartiteMatchingTool.LD_GREEDY:
                    count = BipartiteMatching.greedyBipartite(cost_matrix)
                else:
                    count = BipartiteMatching.lapjvBipartite(cost_matrix)

                cls.updateDistDict(distDict, count)

        # Cluster and print plots
        cls.printDistPlots(distDict, labels, choices.distanceMeasure, choices.linkageCriterion, galaxyFn, htmlCore)

        cls.htmlClusterTime(str(time.clock() - start), htmlCore)
        htmlCore.divEnd()
        print htmlCore
    def execute(cls, choices, galaxyFn=None, username=''):
        from quick.webtools.clustering.CreateLDTrack import CreateLDTrack
        from quick.webtools.clustering.RsidMapper import RsidMapper

        gSuite = getGSuiteFromGalaxyTN(choices.gSuite)
        outGSuite = GSuite()
        errorGSuite = GSuite()

        progressViewer = ProgressViewer([('Manipulate tracks', gSuite.numTracks() + 24)],
                                        cls.extraGalaxyFn[cls.HISTORY_PROGRESS_TITLE])

        ldDict = CreateLDTrack.getLDDict(float(choices.rsquare))
        rsidDict = RsidMapper.createRsidMappingFromStaticFiles(progressViewer, choices.refGenome)
        hiddenStorageFn = cls.extraGalaxyFn[cls.HISTORY_HIDDEN_TRACK_STORAGE]

        for track in gSuite.allTracks():
            fileName = cls.getFilenameWithGTrackSuffix(track.path)
            title = getTitleWithSuffixReplaced(track.title, 'gtrack')

            try:
                uri = GalaxyGSuiteTrack.generateURI(
                    galaxyFn=hiddenStorageFn,
                    extraFileName=fileName,
                    suffix='gtrack'
                )

                gSuiteTrack = GSuiteTrack(
                    uri,
                    title=title,
                    genome=track.genome,
                    trackType='points',
                    attributes=track.attributes
                )

                trackFn = gSuiteTrack.path
                CreateLDTrack.parseFileIntoPointTrack(track.path, trackFn, ldDict, rsidDict)
                outGSuite.addTrack(gSuiteTrack)

            except Exception as e:
                track.comment = 'An error occurred for the following track: ' + str(e)
                errorGSuite.addTrack(track)

            progressViewer.update()

        outGSuite.setGenomeOfAllTracks(choices.refGenome)
        composeToFile(outGSuite, galaxyFn)
        composeToFile(errorGSuite, cls.extraGalaxyFn[cls.HISTORY_ERROR_TITLE])
        writeGSuiteHiddenTrackStorageHtml(hiddenStorageFn)
    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
    def execute(cls, choices, galaxyFn=None, username=''):
        import time
        start = time.clock()

        # HTML settings
        from gold.result.HtmlCore import HtmlCore
        htmlCore = HtmlCore()
        htmlCore.divBegin(style=cls.HTML_STYLE)

        # Set debug environment
        cls._setDebugModeIfSelected(choices)

        # Print tool information
        cls.htmlClusterTitle(cls.getToolName(), htmlCore)
        cls.htmlClusterSubtext(choices.distanceMeasure, cls.CLUSTER_LIST, choices.linkageCriterion, htmlCore)
        htmlCore.line('Threshold of r<sup>2</sup>: ' + choices.rSquare)

        # Analysis environment
        gSuite = getGSuiteFromGalaxyTN(choices.gSuite)
        analysisBins = GlobalBinSource(gSuite.genome)
        analysisSpec = AnalysisSpec(ExpandTrackAndMatchStat)

        splitName = choices.ldTrack.split(":")
        trackName = ExternalTrackManager.getPreProcessedTrackFromGalaxyTN(gSuite.genome, splitName)
        linkedPointTrack = Track(trackName)

        # Find distance/correlation matrix
        labels = []
        distDict = cls.createDistDict(cls.CLUSTER_LIST)
        size = gSuite.numTracks()
        for i in range(0, size):
            gSuiteTrack1 = gSuite.getTrackFromIndex(i)
            labels.append(gSuiteTrack1.title)
            for j in range(i + 1, size):
                gSuiteTrack2 = gSuite.getTrackFromIndex(j)
                track1 = Track(gSuiteTrack1.trackName)
                track2 = Track(gSuiteTrack2.trackName)
                count = doAnalysis(analysisSpec, analysisBins, [track1, track2, linkedPointTrack]).getGlobalResult()
                cls.updateDistDict(distDict, count)

        # Cluster and print plots
        cls.printDistPlots(distDict, labels, choices.distanceMeasure, choices.linkageCriterion, galaxyFn, htmlCore)

        cls.htmlClusterTime(str(time.clock() - start), htmlCore)
        htmlCore.divEnd()
        print htmlCore
Ejemplo n.º 38
0
    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
Ejemplo n.º 39
0
    def execute(cls, choices, galaxyFn=None, username=''):

        cls._setDebugModeIfSelected(choices)

        gSuite = getGSuiteFromGalaxyTN(choices.gSuite)
        analysisBins = GlobalBinSource(gSuite.genome)

        core = HtmlCore()
        core.divBegin(style=CommonClusteringFunctions.HTML_STYLE)

        if choices.getEmpiricalCase == PrintingTool.PRINT_SNPS:
            core.header(PrintingTool.PRINT_SNPS)
            core.divider(True)
            cls.printUniqueRsIDs(analysisBins, gSuite, core)
        elif choices.getEmpiricalCase == PrintingTool.PRINT_DISEASE:
            core.header(PrintingTool.PRINT_DISEASE)
            core.divider(True)
            cls.printDiseaseRsIDs(analysisBins, gSuite, core)

        core.divEnd()
        print core
Ejemplo n.º 40
0
    def execute(cls, choices, galaxyFn=None, username=''):
        from gold.description.AnalysisDefHandler import AnalysisSpec
        from quick.statistic.UniquePointTrackStat import UniquePointTrackStat
        from quick.application.UserBinSource import GlobalBinSource

        cls._setDebugModeIfSelected(choices)

        # Analysis environment
        gSuite = getGSuiteFromGalaxyTN(choices.gSuite)
        analysisBins = GlobalBinSource(gSuite.genome)
        analysisSpec = AnalysisSpec(UniquePointTrackStat)

        # Get unique rsids for whole GSuite
        rsids = set()
        for gSuiteTrack in gSuite.allTracks():
            track = Track(gSuiteTrack.trackName)
            result = doAnalysis(analysisSpec, analysisBins, [track]).getGlobalResult()
            if 'Result' in result:
                rsids.update(result['Result'])

        # Create linked point track
        cls.createLinkedPointTrack(rsids, str(choices.isUndirected), galaxyFn, float(choices.rsquare))
Ejemplo n.º 41
0
    def execute(cls, choices, galaxyFn=None, username=''):

        cls._setDebugModeIfSelected(choices)

        gSuite = getGSuiteFromGalaxyTN(choices.gSuite)
        analysisBins = GlobalBinSource(gSuite.genome)

        htmlCore = HtmlCore()
        htmlCore.divBegin(style=CommonClusteringFunctions.HTML_STYLE)

        if choices.getEmpiricalCase == SNPStatsTool.SNP_COUNT:
            htmlCore.bigHeader(SNPStatsTool.SNP_COUNT)
            htmlCore.divider(True)
            cls.getSNPFrequencyStats(analysisBins, gSuite, galaxyFn, htmlCore)
        elif choices.getEmpiricalCase == SNPStatsTool.SNP_BETWEEN:
            htmlCore.bigHeader(SNPStatsTool.SNP_BETWEEN)
            htmlCore.divider(True)
            cls.getDistancesBetween(analysisBins, gSuite, galaxyFn, htmlCore)
        elif choices.getEmpiricalCase == SNPStatsTool.SNP_WITHIN:
            htmlCore.bigHeader(SNPStatsTool.SNP_WITHIN)
            htmlCore.divider(True)
            cls.getDistancesWithin(analysisBins, gSuite, galaxyFn, htmlCore)

        print htmlCore
Ejemplo n.º 42
0
    def execute(cls, choices, galaxyFn=None, username=''):
        import time
        start = time.clock()

        # HTML settings
        from gold.result.HtmlCore import HtmlCore
        htmlCore = HtmlCore()
        htmlCore.divBegin(style=cls.HTML_STYLE)

        # Set debug environment
        cls._setDebugModeIfSelected(choices)

        # Analysis environment
        gSuite = getGSuiteFromGalaxyTN(choices.gSuite)
        analysisBins = GlobalBinSource(gSuite.genome)
        distDict = None
        labels = None

        # Print tool information:
        cls.htmlClusterTitle(choices.vectorDef, htmlCore)
        cls.htmlClusterSubtext(choices.distanceCorrMeasure, cls.CORR_DISTLIST, choices.linkageCriterion, htmlCore)

        # Get distance / correlation matrixes
        if choices.vectorDef == BinaryClusteringTool.COMP_DIRECT:
            distDict, labels = cls.directVectorDistance(gSuite, analysisBins)
        elif choices.vectorDef == BinaryClusteringTool.COMP_BINS:
            distDict, labels = cls.microBinDistance(gSuite, analysisBins, choices)

        # Print plots
        if distDict and labels:
            cls.printDistPlots(distDict, labels, choices.distanceCorrMeasure, choices.linkageCriterion, galaxyFn,
                               htmlCore)

        cls.htmlClusterTime(str(time.clock() - start), htmlCore)
        htmlCore.divEnd()
        print htmlCore