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.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.
        '''

        if choices[1] == 'Position Weight Matrix (PWM) id':
            selectedPwms = [x for x in choices[2] if choices[2][x]]
        else:
            if choices[5] == 'Refine':
                selectedPwms = [x for x in choices[6] if choices[6][x]]
            else:
                selectedPwms = sorted(
                    [x for x in cls._getSelectedPwmsSet(choices)])

        tfTrackName = cls.TRACK_DICT[choices[0]]
        tfFns = getOrigFns(cls.GENOME, tfTrackName, '.category.bed')

        open(galaxyFn, 'w')  # In order to remove galaxy content
        if len(tfFns) > 0:
            for tfFn in tfFns:
                FilterOnColumnVal.parseFile(tfFn, galaxyFn, tfTrackName, cls.GENOME,\
                                            valCol = 3, valType=str, \
                                            valKeepFunc=lambda x:x in selectedPwms, append=True)
        else:
            f = open(galaxyFn, 'w')
            f.write(
                'Error: Did not find the TF input file for track name: %s' %
                tfTrackName)
 def _getFilePathList(prevChoices, input=True):
     if input:
         fileTree = StandardizeTrackFilesTool.DIRECTION_DICT[prevChoices.direction].inputFileTree
     else:
         fileTree = StandardizeTrackFilesTool.DIRECTION_DICT[prevChoices.direction].outputFileTree
         
     return getOrigFns(prevChoices[0], prevChoices[1].split(':'), '', fileTree=fileTree)
Exemplo n.º 3
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.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.
        '''

        if choices[1] == 'Single diseases':
            selectedDiseases = [x for x in choices[2] if choices[2][x]]
        else:
            if choices[4] == 'Refine':
                selectedDiseases = [x for x in choices[5] if choices[5][x]]
            else:
                selectedDiseasesDict = cls._getSelectedDiseasesDict(choices)
                selectedDiseases = sorted([
                    x for x in selectedDiseasesDict.keys()
                    if selectedDiseasesDict[x]
                ])

        diseaseTn = cls._getDiseaseTn(choices)
        diseaseFns = getOrigFns(cls.GENOME, diseaseTn, '.category.bed')

        open(galaxyFn, 'w')  # In order to remove galaxy content
        if len(diseaseFns) > 0:
            for diseaseFn in diseaseFns:
                FilterOnColumnVal.parseFile(diseaseFn, galaxyFn, diseaseTn, cls.GENOME,\
                                            valCol = 3, valType=str, \
                                            valKeepFunc=lambda x:x.replace('_',' ') in selectedDiseases,\
                                            append=True)
        else:
            f = open(galaxyFn, 'w')
            f.write(
                'Error: Did not find the disease input file for track name: %s'
                % tfTrackName)
    def execute(cls, choices, galaxyFn=None, username=''):
        #'Genome:','Source of seed TF:','Seed TF: ','Flank size: ', 'Source of potentially cooperative TFs:'
        #genome

        genome = choices[0]
        seedSource = choices[1]
        seedTfTnInput = choices[2]
        if seedSource == 'TFBS from history':
            seedFn = ExternalTrackManager.extractFnFromGalaxyTN(
                seedTfTnInput.split(':'))
        else:
            tfTrackNameMappings = TfInfo.getTfTrackNameMappings(genome)
            seedTfTn = tfTrackNameMappings[seedSource] + [seedTfTnInput]
            #tfTrackName = tfTrackNameMappings[tfSource] + [selectedTF]
            seedFns = getOrigFns(genome, seedTfTn, '')
            assert len(seedFns) == 1
            seedFn = seedFns[0]

        flankSize = choices[3]
        flankSize = int(flankSize) if flankSize != '' else 0
        cooperativeTfSource = choices[4]
        #flankSize = int(choices[4])
        #TFsFromGenes.findOverrepresentedTFsFromGeneSet('hg18', 'UCSC tfbs conserved', ['ENSGflankSizeflankSizeflankSizeflankSizeflankSize2flankSize8234','ENSGflankSizeflankSizeflankSizeflankSizeflankSize199674'],flankSize, flankSize, galaxyFn)
        #TFsFromGenes.findOverrepresentedTFsFromGeneSet('hg18', tfSource, choices[5].split(','),flankSize, flankSize, 'Ensembl', galaxyFn)

        #TFsFromRegions.findOverrepresentedTFsFromGeneSet(genome, tfSource, ensembleGeneIdList,upFlankSize, downFlankSize, geneSource, galaxyFn)

        #TFsFromGenes.findTFsTargetingGenes('hg18', tfSource, choices[5].split(','),flankSize, flankSize, 'Ensembl', galaxyFn)

        TFsFromRegions.findTFsOccurringInRegions(genome, cooperativeTfSource,
                                                 seedFn, flankSize, flankSize,
                                                 galaxyFn)
 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.
     '''
     if choices[1] == 'Single diseases':
         selectedDiseases = [x for x in choices[2] if choices[2][x]]
     else:
         if choices[4] == 'Refine':
             selectedDiseases = [x for x in choices[5] if choices[5][x]]
         else:
             selectedDiseasesDict = SelectDiseaseTool._getSelectedDiseasesDict(choices)
             selectedDiseases = sorted([x for x in selectedDiseasesDict.keys() if selectedDiseasesDict[x]])
         
     diseaseTn = SelectDiseaseTool._getDiseaseTn(choices)
     diseaseFns = getOrigFns(SelectDiseaseTool.GENOME, diseaseTn, '.category.bed')
     
     open(galaxyFn, 'w') # In order to remove galaxy content
     if len(diseaseFns) > 0:
         for diseaseFn in diseaseFns:
             FilterOnColumnVal.parseFile(diseaseFn, galaxyFn, diseaseTn, SelectDiseaseTool.GENOME,\
                                         valCol = 3, valType=str, \
                                         valKeepFunc=lambda x:x.replace('_',' ') in selectedDiseases,\
                                         append=True)
     else:
         f = open(galaxyFn, 'w')
         f.write('Error: Did not find the disease input file for track name: %s' % tfTrackName)
    def execute(choices, galaxyFn=None, username=''):
        #'Genome:','Source of seed TF:','Seed TF: ','Flank size: ', 'Source of potentially cooperative TFs:'
        #genome
        genome = choices[0]
        seedSource = choices[1]
        seedTfTnInput = choices[2]
        if seedSource == 'TFBS from history':
            seedFn = ExternalTrackManager.extractFnFromGalaxyTN(seedTfTnInput.split(':'))
        else:
            tfTrackNameMappings = TfInfo.getTfTrackNameMappings(genome)
            seedTfTn = tfTrackNameMappings[seedSource] + [seedTfTnInput]
            #tfTrackName = tfTrackNameMappings[tfSource] + [selectedTF]
            seedFns = getOrigFns(genome, seedTfTn, '')
            assert len(seedFns) == 1
            seedFn = seedFns[0]
            
        flankSize = choices[3]
        flankSize = int(flankSize) if flankSize != '' else 0
        cooperativeTfSource = choices[4]
        #flankSize = int(choices[4])
        #TFsFromGenes.findOverrepresentedTFsFromGeneSet('hg18', 'UCSC tfbs conserved', ['ENSGflankSizeflankSizeflankSizeflankSizeflankSize2flankSize8234','ENSGflankSizeflankSizeflankSizeflankSizeflankSize199674'],flankSize, flankSize, galaxyFn)
        #TFsFromGenes.findOverrepresentedTFsFromGeneSet('hg18', tfSource, choices[5].split(','),flankSize, flankSize, 'Ensembl', galaxyFn)
        
        #TFsFromRegions.findOverrepresentedTFsFromGeneSet(genome, tfSource, ensembleGeneIdList,upFlankSize, downFlankSize, geneSource, galaxyFn)
        
        #TFsFromGenes.findTFsTargetingGenes('hg18', tfSource, choices[5].split(','),flankSize, flankSize, 'Ensembl', galaxyFn)

        TFsFromRegions.findTFsOccurringInRegions(genome, cooperativeTfSource, seedFn, flankSize, flankSize, galaxyFn)
Exemplo n.º 7
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.
     '''
     if choices[1] == 'Position Weight Matrix (PWM) id':
         selectedPwms = [x for x in choices[2] if choices[2][x]]
     else:
         if choices[5] == 'Refine':
             selectedPwms = [x for x in choices[6] if choices[6][x]]
         else:
             selectedPwms = sorted([x for x in SelectTfTool._getSelectedPwmsSet(choices)])
         
     tfTrackName = SelectTfTool.TRACK_DICT[choices[0]]
     tfFns = getOrigFns(SelectTfTool.GENOME, tfTrackName, '.category.bed')
     
     open(galaxyFn, 'w') # In order to remove galaxy content
     if len(tfFns) > 0:
         for tfFn in tfFns:
             FilterOnColumnVal.parseFile(tfFn, galaxyFn, tfTrackName, SelectTfTool.GENOME,\
                                         valCol = 3, valType=str, \
                                         valKeepFunc=lambda x:x in selectedPwms, append=True)
     else:
         f = open(galaxyFn, 'w')
         f.write('Error: Did not find the TF input file for track name: %s' % tfTrackName)
Exemplo n.º 8
0
    def _getFilePathList(cls, prevChoices, input=True):
        if input:
            fileTree = cls.DIRECTION_DICT[prevChoices.direction].inputFileTree
        else:
            fileTree = cls.DIRECTION_DICT[prevChoices.direction].outputFileTree

        return getOrigFns(prevChoices.genome,
                          prevChoices.track.split(':'),
                          '',
                          fileTree=fileTree)
    def _getFilePathList(prevChoices, input=True):
        if input:
            fileTree = StandardizeTrackFilesTool.DIRECTION_DICT[
                prevChoices.direction].inputFileTree
        else:
            fileTree = StandardizeTrackFilesTool.DIRECTION_DICT[
                prevChoices.direction].outputFileTree

        return getOrigFns(prevChoices[0],
                          prevChoices[1].split(':'),
                          '',
                          fileTree=fileTree)
Exemplo n.º 10
0
def updateOrCreateStandardFolders(genome):
    print "update or create ", genome
    for x in standardFolderInfo:
        ti = TrackInfo(genome, x[0])
        ti.description = x[1]
        ti.reference = x[2]
        ti.quality = x[3]

        ### sjekke om folderen eksisterer, hvis ikke lage den. Dette er ikke helt implementer da jeg er usikker om jeg fikk det til med eksisterende metoder.
        if not getOrigFns(
                genome, x[0], ''
        ):  # returns empty list if no folder? But what does it return when no tracks is in the folder?
            print x[0], "is missing"  # lage folder og preprocess?

        #print "ti=", ti
        ti.store()
    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[0]
        seedSource = choices[1]
        seedTfTnInput = choices[2]

        if seedSource != 'TFBS from history':
            tfTrackNameMappings = TfInfo.getTfTrackNameMappings(genome)
            seedTfTn = tfTrackNameMappings[seedSource] + [seedTfTnInput]
            #tfTrackName = tfTrackNameMappings[tfSource] + [selectedTF]
            if len(getOrigFns(genome, seedTfTn,'')) != 1:
                return 'Sorry. Only seed TFs that are internally represented as single files are currently supported. Please contact the HB team for assistance if needed. Track name that was not supported: ' + ':'.join(seedTfTn)
    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[0]
        seedSource = choices[1]
        seedTfTnInput = choices[2]

        if seedSource != 'TFBS from history':
            tfTrackNameMappings = TfInfo.getTfTrackNameMappings(genome)
            seedTfTn = tfTrackNameMappings[seedSource] + [seedTfTnInput]
            #tfTrackName = tfTrackNameMappings[tfSource] + [selectedTF]
            if len(getOrigFns(genome, seedTfTn, '')) != 1:
                return 'Sorry. Only seed TFs that are internally represented as single files are currently supported. Please contact the HB team for assistance if needed. Track name that was not supported: ' + ':'.join(
                    seedTfTn)