def execute(cls, choices, galaxyFn=None, username=''):

        genome, history = choices[:2]
        track, catColumn, numHeaderLines = choices[3], choices[4], choices[5]
        suffix, catSuffix = choices[6], choices[7]
        private = True if choices[-1]=='Yes' else False
        GalaxyInterface.integrateTrackFromHistory(genome, history.split(':'), track.split(':'), privateAccess=private, username=username)
        #ensurePathExists(NONSTANDARD_DATA_PATH+'/'+'/'.join( [genome]+track.split(':')+['fName.txt'] ) )
        StandTrackFiles.runParserClass([genome, track, 'PlainCopier', 'direction=std_to_coll', 'allSubTypes=False', 'subTypeDepth=1'], printUsageWhenError=False)
        StandTrackFiles.runParserClass([genome, track, 'SplitFileToSubDirs', 'direction=coll_to_coll', 'allSubTypes=False', \
                                        'subTypeDepth=1', 'subTypeCol='+catColumn, 'numHeaderLines='+numHeaderLines, \
                                        'suffix=.%s' % suffix, 'catSuffix=.%s' % catSuffix], printUsageWhenError=False)
        StandTrackFiles.runParserClass([genome, track, 'PlainCopier', 'direction=coll_to_std', 'allSubTypes=True', 'subTypeDepth=1'], printUsageWhenError=False)
        GalaxyInterface.startPreProcessing(genome, track, username)
Exemplo n.º 2
0
    def execute(cls, choices, galaxyFn=None, username=''):
        cls._setDebugModeIfSelected(choices, galaxyFn)

        with stdout_redirector(open(galaxyFn, "w", 0)):
            core = HtmlCore()
            core.append(GalaxyInterface.getHtmlBeginForRuns(galaxyFn))
            core.append(
                GalaxyInterface.getHtmlForToggles(withRunDescription=False))
            core.styleInfoBegin(styleClass='debug')
            core.paragraph(
                'GalaxyInterface.startPreProcessing({}, {}, {})'.format(
                    choices.genome, choices.track, username))
            print core

            if choices.parsingError == cls.MOVE_TO_PARSING_ERROR_CHOICE:
                finished = False
                while not finished:
                    DebugConfig.PASS_ON_PREPROCESS_EXCEPTIONS = True
                    try:
                        GalaxyInterface.startPreProcessing(
                            choices.genome, choices.track, username)
                        finished = True
                    except (PreprocessWarning, PreprocessError) as e:
                        print e
                        match = re.search("trackName=\"([^\"]+)\"", str(e))
                        if match:
                            trackName = match.group(1).split(':')
                            PlainMover().parseFiles(choices.genome,
                                                    trackName,
                                                    direction='std_to_error')
            else:  # cls.DO_NOTHING_CHOICE
                GalaxyInterface.startPreProcessing(choices.genome,
                                                   choices.track, username)

            core = HtmlCore()
            core.styleInfoEnd()
            core.script('done = true;')
            core.end()
            print core
Exemplo n.º 3
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.gtr
        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.
        '''
        print 'Executing...'
        print choices
        print choices[-1]
        genome = choices[0]
        trackNames = choices[1].split(':')
        ucscFileName = trackNames[-2]
        for cellType in InstallUcscTool.cellTypes:
            if ucscFileName.find(cellType) > -1:
                print 'CellType and fileName: ', cellType, ucscFileName
                break
        internalTrackPath = choices[2].split(':')
        bedfil, suffix = None, None
        metaData = None
        if trackNames[0] == 'ucsc':
            ucscObj = UcscHandler()
            print InstallUcscTool.trackNames
            if len(trackNames) == 3:
                lastLevelForTrackList = ucscObj.getFinalLevelTrackNames(
                    genome, trackNames)
            else:
                lastLevelForTrackList = [trackNames[-2]]
                trackNames = trackNames[:-2]

            for i in lastLevelForTrackList:
                bedfil, metaData = ucscObj.getBedData(genome,
                                                      trackNames + [i, 'bed'])
                print 'downloaded %s' % i
                print bedfil[:35]
                time.sleep(0.5)
                #                path = createOrigPath(genome, internalTrackPath+[i])
                path = createOrigPath(genome, internalTrackPath)
                origFn = path + os.sep + internalTrackPath[-1] + '.bed'
                ensurePathExists(origFn)
                open(origFn, 'w').write(bedfil)
                os.chmod(origFn, 0664)
                #                InstallUcscTool.storeTrackInfo(genome, internalTrackPath+[i], metaData)
                InstallUcscTool.storeTrackInfo(genome, internalTrackPath,
                                               metaData)
        else:

            path = createOrigPath(genome, trackNames)
            if os.path.isdir(path):

                filenames = os.listdir(path)
            else:
                fileName = os.listdir(path)[0]
                print fileName
                suffix = fileName.split('.')[-1]
                bedfil = open(path + os.sep + fileName, 'r').read()

            path = createOrigPath(genome, internalTrackPath)

            suffix = trackNames[-1] if not suffix else suffix
            origFn = path + os.sep + internalTrackPath[-1] + '.' + suffix
            ensurePathExists(origFn)
            open(origFn, 'w').write(bedfil)
            os.chmod(origFn, 0664)

        GalaxyInterface.startPreProcessing(genome, internalTrackPath, username)