def _assertRunEqual(self, target, *args, **kwArgs):
        if self.VERBOSE:
            DebugConfig.PASS_ON_COMPUTE_EXCEPTIONS = True
            print '\n***\n' + str(self.id()) + '\n***'
        
        args = list(args)
        analysisDef = [x.strip() for x in args[2].split('->')]
        if len(analysisDef) == 1:
            analysisDef.append(analysisDef[0])
        analysisDef[0] += ' [randomSeed:=0]'
        
        args[2] = analysisDef[0] + " -> " + analysisDef[1]
        
        for diskMemo in [False, True]:
            gold.statistic.ResultsMemoizer.LOAD_DISK_MEMOIZATION = diskMemo

            if self._usesProfiling():
                gold.application.StatRunner.USE_PROFILING = True
                
            res = GalaxyInterface.run(*args, **{'genome':'TestGenome'})

            self._assertEqualResults(target, res)
            if kwArgs.get('globalTarget') != None:
                self._assertEqualGlobalResults(kwArgs['globalTarget'], res)
                
            if self._usesProfiling():
                self._storeProfile(diskMemo)
    def _assertRunEqual(self, target, *args, **kwArgs):
        if DebugConfig.VERBOSE:
            print '\n***\n' + str(self.id()) + '\n***'
        
        args = list(args)
        analysisDef = [x.strip() for x in args[2].split('->')]
        if len(analysisDef) == 1:
            analysisDef.append(analysisDef[0])
        analysisDef[0] += ' [randomSeed:=0:]'
        
        args[2] = analysisDef[0] + " -> " + analysisDef[1]
        
        for runType in self._runTypeGenerator():
            # if self._usesProfiling():
            #     DebugConfig.USE_PROFILING = True
                
            res = GalaxyInterface.run(*args, **{'genome': 'TestGenome'})

            self._assertEqualResults(target, res)
            if kwArgs.get('globalTarget') is not None:
                self._assertEqualGlobalResults(kwArgs['globalTarget'], res)
 def testCountStat(self):
     #self._assertRunEqual([[('Result', 119121)], [('Result', 0)]],\
     GalaxyInterface.run(["segsMany"],["segs"],'CountStat','TestGenome:chr21:10000000-10004000','2000')
예제 #4
0
# Copyright (C) 2009, Geir Kjetil Sandve, Sveinung Gundersen and Morten Johansen
# This file is part of The Genomic HyperBrowser.
#
#    The Genomic HyperBrowser is free software: you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation, either version 3 of the License, or
#    (at your option) any later version.
#
#    The Genomic HyperBrowser is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with The Genomic HyperBrowser.  If not, see <http://www.gnu.org/licenses/>.

from gold.application.GalaxyInterface import GalaxyInterface

#first you need to create a statistic class. For this you will use a StatisticTemplate, and just add a few custom lines of code..
#In our example we will make a simple statistic that computes the number of bps covered by all segments of a single track (in a bin).
#1: open the file StatisticTemplate.py
#2: save this file with your own name in the folder "quick/statistic". Lets call it "BpCoverageStat.py".  (By putting your new class here, it will automatically be loaded into the Hyperbrowser system.)
#3: rename the classes according to your name for the statistic - the same as used for the file. The file should then have a class "BpCoverageStat" and a class "BpCoverageStatUnsplittable". (The system will automatically use the unsplittable class, and would in certain cases also automatically have used a corresponding splittable class if it had been defined..)
#4: define what input your statistic will need. In our case we will simply need the raw track data. Add the following line in the method "_createChildren":
#self._addChild( RawDataStat(self._region, self._track, TrackFormatReq()) )
#5: define how to compute the result. Add the following line under "_compute":
#return sum( el.end() - el.start() for el in self._children[0].getResult())
#6: Now you can make a simple call that computes full genome-wide results based on your statistics code:
GalaxyInterface.run(['genes','refseq'], ['repeats','LINE'], 'My new statistic -> BpCoverageStat', '*', '*', genome='hg18')
#7: You can also very simply make your new statistic available on the web if you have a web system running against the Hyperbrowser. Simply add the following line somewhere inside the string variable "QUESTION_SPEC_STR" in the file "gold/description/AnalysisList.py":
#'My new statistic -> BpCoverageStat'
예제 #5
0
def main():
    filename = sys.argv[1]
    tool = None
    if len(sys.argv) > 2:
        tool = sys.argv[2]

    job_params, params = hg.load_input_parameters(filename)
    #    print job_params, params

    file_path = None

    trackName1 = ""
    trackName2 = ""
    intensityTrackName = None
    subName1 = ""
    subName2 = ""
    intensityTrackFile = None
    intensityTrackFileType = None
    statClassName = ""
    binSize = "*"
    region = "*"
    userBins = None
    output = filename
    extractFile = None
    customFile = None
    statsFile = None
    method = None
    segLength = 0
    overlaps = None
    genome = 'hg18'
    username = None

    for o, a in params.items():
        if a == "":
            continue
        a = str(a)
        if o == "dbkey":
            genome = a
        elif o == "tool":
            tool = a
        elif o == "track1":
            trackName1 = a
        elif o == "track2":
            trackName2 = a
        elif o == "trackIntensity":
            intensityTrackName = a
        elif o == "grptrack1":
            grpName1 = a
        elif o == "grptrack2":
            grpName2 = a
        elif o == "subtrack1":
            subName1 = a
        elif o == "subtrack2":
            subName2 = a
        elif o == "stats":
            statClassName = a
        elif o == "binsize":
            binSize = a
        elif o == "seglength":
            segLength = int(a)
        elif o == "region":
            region = a
        elif o == "method":
            method = a
        elif o == "output":
            output = a


#            sys.stdout = open(a, "w", 0)
        elif o == "extract":
            extractFile = a
        elif o == "custom":
            sys.stdout = open(a, "w", 0)
            customFile = a
        elif o == "binfile":
            region = "bed"
            userBins = a
        elif o == "statsfile":
            statsFile = a
        elif o == "file_path":
            file_path = a
        elif o == "overlaps":
            overlaps = unquote(a)
        elif o == "userEmail":
            username = a

    if method in ['__chrs__', '__chrBands__', '__chrArms__', '__genes__']:
        region = method
        binSize = params[method]
    elif method == '__brs__':
        region = method
        binSize = '*'

    if userBins:
        if userBins[0] == 'galaxy':  # For backwards compatibility
            binSize = userBins[1]
            region = userBins[2]
        elif userBins.startswith('galaxy'):
            binSize, region = getSecureIdAndExtFromDatasetInfoAsStr(userBins)

    tracks1 = trackName1.split(':')

    tracks2 = trackName2.split(':')

    if intensityTrackName != None:
        intensityTracks = intensityTrackName.split(':')
    else:
        intensityTracks = []

    # if statClassName.startswith('galaxy'):
    #     statsFileId = statClassName.split(',')[1]
    #     statsFile = getGalaxyFnFromDatasetId(statsFileId)
    #     statClassName = '[scriptFn:=' + statsFile.encode('hex_codec') + ':] -> CustomRStat'

    if tool == 'extract':
        #print 'GalaxyInterface.parseExtFormatAndExtractTrackManyBins*', (genome, tracks1, region, binSize, True, overlaps, output)
        if output != None:
            sys.stdout = open(output, "w", 0)
        if params.has_key('sepFilePrRegion'):
            GalaxyInterface.parseExtFormatAndExtractTrackManyBinsToRegionDirsInZipFile(
                genome, tracks1, region, binSize, True, overlaps, output)
        else:
            GalaxyInterface.parseExtFormatAndExtractTrackManyBins(
                genome, tracks1, region, binSize, True, overlaps, output)

    else:  #run analysis
        if output != None:
            sys.stdout = open(output, "w", 0)
        demoID = params['demoID'] if params.has_key('demoID') else None
        GalaxyInterface.run(tracks1, tracks2, statClassName, region, binSize,
                            genome, output, intensityTracks, username, demoID)
def test3():
    GalaxyInterface.run(['repeats','SINE'],['repeats'],\
                        '[scriptFn:='+fn+':] -> CustomRStat',\
                        'chr1:1-100000000','10m')
 def testCountStat(self):
     #self._assertRunEqual([[('Result', 119121)], [('Result', 0)]],\
     GalaxyInterface.run(["segsMany"], ["segs"], 'CountStat',
                         'TestGenome:chr21:10000000-10004000', '2000')
예제 #8
0
# Copyright (C) 2009, Geir Kjetil Sandve, Sveinung Gundersen and Morten Johansen
# This file is part of The Genomic HyperBrowser.
#
#    The Genomic HyperBrowser is free software: you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation, either version 3 of the License, or
#    (at your option) any later version.
#
#    The Genomic HyperBrowser is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with The Genomic HyperBrowser.  If not, see <http://www.gnu.org/licenses/>.

from gold.application.GalaxyInterface import GalaxyInterface

trackName1 = ['Genes and Gene Prediction Tracks','Genes','Refseq'] #or any other track that are precomputed on the server
trackName2 = ['Sequence','Repeating elements']
question = 'Are track1-points occurring [tail:=different:with different frequency] inside track2-segment than outside? -> PointCountInSegsPvalStat' #or any other statistic from the HB collection
regSpec = 'chr1:1-10000000' #could also be e.g. 'chr1' for the whole chromosome or '*' for the whole genome
binSpec = '1m' #could also be e.g.'100', '1k' or '*' for whole regions/chromosomes as bins 

GalaxyInterface.run(trackName1, trackName2, question, regSpec, binSpec, genome='hg18')
예제 #9
0
from gold.application.GalaxyInterface import GalaxyInterface

#first you need to create a statistic class. For this you will use a StatisticTemplate, and just add a few custom lines of code..
#In our example we will make a simple statistic that computes the number of bps covered by all segments of a single track (in a bin).
#1: open the file StatisticTemplate.py
#2: save this file with your own name in the folder "quick/statistic". Lets call it "BpCoverageStat.py".  (By putting your new class here, it will automatically be loaded into the Hyperbrowser system.)
#3: rename the classes according to your name for the statistic - the same as used for the file. The file should then have a class "BpCoverageStat" and a class "BpCoverageStatUnsplittable". (The system will automatically use the unsplittable class, and would in certain cases also automatically have used a corresponding splittable class if it had been defined..)
#4: define what input your statistic will need. In our case we will simply need the raw track data. Add the following line in the method "_createChildren":
#self._addChild( RawDataStat(self._region, self._track, TrackFormatReq()) )
#5: define how to compute the result. Add the following line under "_compute":
#return sum( el.end() - el.start() for el in self._children[0].getResult())
#6: Now you can make a simple call that computes full genome-wide results based on your statistics code:
GalaxyInterface.run(['genes', 'refseq'], ['repeats', 'LINE'],
                    'My new statistic -> BpCoverageStat',
                    '*',
                    '*',
                    genome='hg18')
#7: You can also very simply make your new statistic available on the web if you have a web system running against the Hyperbrowser. Simply add the following line somewhere inside the string variable "QUESTION_SPEC_STR" in the file "gold/description/AnalysisList.py":
#'My new statistic -> BpCoverageStat'