Пример #1
0
def plainRun(analysisDef, genome, track1Fn, track2Fn):
    '''
    Currently under development, not yet functioning.
    Note that file names (track1Fn, track2Fn) must either be a valid .dat-file from a Galaxy system,
      or be located in a path where the two deepest levels are numerical values above 1000, and unique between different runs by this tool'''
    #GalaxyInterface.runManual(trackNames, analysisDef, regSpec, binSpec, genome, galaxyFn=None, trackNameIntensity=None, username='', \
    #printResults=True, printProgress=True, printHtmlWarningMsgs=True, applyBoundaryFilter=False, printRunDescription=True, **kwArgs):

    from quick.application.ExternalTrackManager import ExternalTrackManager

    #fixme: is this correct?
    assert all(
        idPart > 1000
        for idPart in ExternalTrackManager.extractIdFromGalaxyFn(track1Fn))
    tn1 = ExternalTrackManager.constructGalaxyTnFromSuitedFn(track1Fn)
    assert all(
        idPart > 1000
        for idPart in ExternalTrackManager.extractIdFromGalaxyFn(track2Fn))
    tn2 = ExternalTrackManager.constructGalaxyTnFromSuitedFn(track2Fn)

    from quick.application.GalaxyInterface import GalaxyInterface
    userBinSource = GalaxyInterface._getUserBinSource('chrs', '*', genome, tn1,
                                                      tn2)

    from gold.application.StatRunner import AnalysisDefJob
    job = AnalysisDefJob(analysisDef, tn1, tn2, userBinSource)
    result = job.run(printProgress=False)
    return result
Пример #2
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.
        '''

        from quick.application.GalaxyInterface import GalaxyInterface
        from proto.hyperbrowser.HtmlCore import HtmlCore

        print GalaxyInterface.getHtmlBeginForRuns(galaxyFn)
        print GalaxyInterface.getHtmlForToggles(withRunDescription=False)
        print str(HtmlCore().styleInfoBegin(styleClass='debug'))

        from quick.application.ExternalTrackManager import ExternalTrackManager
        datasetId = ExternalTrackManager.extractIdFromGalaxyFn(ExternalTrackManager.extractFnFromGalaxyTN(choices[0]))[1]
        #print datasetId
        #print choices

        ##batchid = index for kjoering i batch. Ikke-batch-kjoering: 0
        #batchid = 0

        ##mapId = Definer hva slags type innhold i Google map-bokser (naar du trykker). Innholdet er definert (hardkodet) i GoogleMapsInterface.py: getHtmlText() og getClusterHtmlText()
        ##Eks: encode_tf_vs_tf
        if choices[1] != 'make new map id':
            mapId = choices[1]
        else:
            mapId = choices[2]
            from quick.application.ExternalTrackManager import ExternalTrackManager
            histHtml = open(ExternalTrackManager.extractFnFromGalaxyTN(choices[0].split(':'))).read()

            #rowTrackName = histHtml.split('<h3>TRACK 1</h3>')[-1].split('</b>')[1].split('\n')[0].strip()#.split(':')
            #colTrackName = histHtml.split('<h3>TRACK 2</h3>')[-1].split('</b>')[1].split('\n')[0].strip()#.split(':')

            from quick.application.GalaxyInterface import GalaxyInterface

            batchLine = histHtml.split('<h3>CORRESPONDING BATCH COMMAND LINE</h3>')[-1].split('<p>')[1].split('/p')[0].strip()
            genome = histHtml.split('<h3>GENOME</h3>')[-1].split('name:</b>')[1].split('<')[0].strip()
            fullAccess = GalaxyInterface.userHasFullAccess(username)

            from quick.batch.BatchRunner import BatchRunner
            batchContents = BatchRunner.parseBatchLine(batchLine, genome, fullAccess)
            rowTrackName = ':'.join(batchContents.cleanedTrackName1)
            colTrackName = ':'.join(batchContents.cleanedTrackName2)

            from quick.extra.CreateGoogleMapType import createMapType
            createMapType(mapId, genome, rowTrackName, colTrackName, 'None', 'None', 'None')

            from config.Config import HB_SOURCE_CODE_BASE_DIR
            GMapInterfaceFn = HB_SOURCE_CODE_BASE_DIR+'/quick/extra/GoogleMapsInterface.py'
            GMapInterfaceContent = open(GMapInterfaceFn).read()
            replaceStr = "'%s', 'encode_gwas_vs_dhs'" % mapId
            GMapInterfaceContent = GMapInterfaceContent.replace("'encode_gwas_vs_dhs'", replaceStr)
            open(GMapInterfaceFn,'w').write(GMapInterfaceContent)

        #title = navn paa Regulomet slik brukeren ser det, Eks: "ENCODE test, TFs vs TFs"
        title = choices[3]

        ##name = navn paa katalog for google map: Eks: encode_test_tf_vs_tf
        name = choices[4]

        from quick.extra.CreateGoogleMap import GoogleMapCreator
        from quick.extra.GoogleMapsInterface import Map


        onMedSeqProd = False
        #batchid
        creator = GoogleMapCreator(name, datasetId, mapId, genome=genome)
        creator.tile(onMedSeqProd)
        creator.copyResultFiles()
        creator.createResultShelves()
        creator.createIndexFile(title, genome)
        creator.fixPermissions()

        print str(HtmlCore().styleInfoEnd())

        map = Map(name)

        row = []
        row.append( str(HtmlCore().link(map.getPrettyName(), map.getUrl())) )
        row.append( str(HtmlCore().link('Run description', map.getRunDescriptionUrl())) )
        row.append( str(HtmlCore().link('Counts', map.getCountUrl())) )
        row.append( str(HtmlCore().link('Effect size', map.getEffectSizeUrl())) )
        row.append( str(HtmlCore().link('P-values', map.getPvalUrl())) )

        core = HtmlCore()
        core.tableHeader(None)
        core.tableLine(row)
        core.tableFooter()

        print core
        print GalaxyInterface.getHtmlEndForRuns()