def test_NA_fill(s): """Cluster data with Na present and zeroReplace flag should pass. """ opts = Namespace( layoutInputFormat = "clusterData", layoutInputFile = [mat_with_na], names = ["layout"], metric = 'spearman', directory = "out/nas", singletons = True, clumpinessStats = True, mutualinfo = True, associations = True, zeroReplace = True ) try: layout.makeMapUIfiles(opts) passed = True except ValueError: passed = False s.assertTrue(passed)
def test_xy(s): outDir = outDirBase + '_xy/' opts = Namespace( layoutInputFile= [coordDataFile], names= ["layout"], metric= 'spearman', scores= [attsCodedFile], colormaps= colorDataFile, directory= outDir, singletons=True, clumpinessStats=False, mutualinfo=False, associations=False ) util.removeOldOutFiles(outDir) layout.makeMapUIfiles(opts) #check that it is mostly the same as the other files util.compareActualVsExpectedDir(s,expDir, outDir, excludeFiles = ['log', 'mapMeta.json', 'neighbors_0.tab', 'assignments0.tab', 'hexNames.tab', 'xyPreSquiggle_0.tab'] ) util.compareActualVsExpectedFile(s,'assignments0.tab',expXyDir,outDir) util.compareActualVsExpectedFile(s,'xyPreSquiggle_0.tab',expXyDir,outDir)
def test_xy_no_colorMakeMapUIfiles(s): outDir = outDirBase + '_xy_no_color/' opts = Namespace(coordinates=[coordDataFile], scores=[attsStringsFile], names=["layout"], directory=outDir, singletons=True, clumpinessStats=False, mutualinfo=False, associations=False) util.removeOldOutFiles(outDir) layout.makeMapUIfiles(opts) #check that it is mostly the same as the other files util.compareActualVsExpectedDir(s, expNoColorDir, outDir, excludeFiles=[ 'log', 'assignments0.tab', 'neighbors_0.tab', 'hexNames.tab', 'xyPreSquiggle_0.tab' ]) #theese files are not expected to be the same as other runs, # but to make sure they are correct we have but previous runs in a different # expected directory. util.compareActualVsExpectedFile(s, 'assignments0.tab', expXyDir, outDir) util.compareActualVsExpectedFile(s, 'xyPreSquiggle_0.tab', expXyDir, outDir)
def test_xy_no_attsfromMakeUI(s): outDir = outDirBase + '_xy_no_atts/' opts = Namespace(coordinates=[coordDataFile], names=["layout"], directory=outDir, singletons=True, clumpinessStats=True, mutualinfo=True, associations=True) util.removeOldOutFiles(outDir) layout.makeMapUIfiles(opts) util.compareActualVsExpectedDir(s, expNoAttsDir, outDir, excludeFiles=[ 'log', 'mapMeta.json', 'neighbors_0.tab', 'assignments0.tab', 'hexNames.tab', 'xyPreSquiggle_0.tab' ]) util.compareActualVsExpectedFile(s, 'assignments0.tab', expXyDir, outDir) util.compareActualVsExpectedFile(s, 'xyPreSquiggle_0.tab', expXyDir, outDir)
def test_top6_no_attsfromMakeUIfiles(s): outDir = outDirBase + '_top6_no_atts/' opts = Namespace(similarity=[top6SimDataFile], names=["layout"], directory=outDir, singletons=True, clumpinessStats=True, mutualinfo=True, associations=True) util.removeOldOutFiles(outDir) layout.makeMapUIfiles(opts) util.compareActualVsExpectedDir(s, expNoAttsDir, outDir)
def test_raw_no_attsfromMakeUIfiles(s): outDir = outDirBase + '_raw_no_atts/' opts = Namespace(feature_space=[rawDataFile], names=["layout"], metric='spearman', directory=outDir, singletons=True, clumpinessStats=True, mutualinfo=True, associations=True) util.removeOldOutFiles(outDir) layout.makeMapUIfiles(opts) util.compareActualVsExpectedDir(s, expNoAttsDir, outDir)
def test_full_no_colorfromMakeUIfiles(s): outDir = outDirBase + '_full_no_color/' opts = Namespace(similarity_full=[fullSimDataFile], names=["layout"], scores=[attsStringsFile], directory=outDir, singletons=True, clumpinessStats=False, mutualinfo=False, associations=False) util.removeOldOutFiles(outDir) layout.makeMapUIfiles(opts) util.compareActualVsExpectedDir(s, expNoColorDir, outDir)
def test_top6fromMakeUIfiles(s): outDir = outDirBase + '_top6/' opts = Namespace(similarity=[top6SimDataFile], names=["layout"], scores=[attsCodedFile], colormaps=colorDataFile, directory=outDir, singletons=True, clumpinessStats=False, mutualinfo=False, associations=False) util.removeOldOutFiles(outDir) layout.makeMapUIfiles(opts) util.compareActualVsExpectedDir(s, expDir, outDir)
def test_rawfromMakeUIfiles(s): outDir = outDirBase + '_raw/' opts = Namespace(feature_space=[rawDataFile], names=["layout"], metric='spearman', scores=[attsCodedFile], colormaps=colorDataFile, directory=outDir, singletons=True, clumpinessStats=False, mutualinfo=False, associations=False) util.removeOldOutFiles(outDir) layout.makeMapUIfiles(opts) util.compareActualVsExpectedDir(s, expDir, outDir)
def test_fullfromMakeUIfiles(s): outDir = outDirBase + '_full/' #options for different layout.py executions opts = Namespace( layoutInputFile = [fullSimDataFile], names = ["layout"], scores = [attsCodedFile], colormaps = colorDataFile, directory = outDir, singletons = True, clumpinessStats=False, mutualinfo=False, associations=False ) util.removeOldOutFiles(outDir) layout.makeMapUIfiles(opts) util.compareActualVsExpectedDir(s, expDir, outDir)
def calcMain(parms, ctx): # The main process in which the job executes. # Use standard exceptions here to report errors. # @param parms: the parameters for the operation # @param ctx: the job context # @returns: (status, result) where the status is 'Success' or 'Error' # and the result depends on the status: # Success: a dict like: # { # 'status': 'Success', # 'url': 'https://tumormap.ucsc.edu/?p=myMap', # 'logFile': <logFileName> # } # Error: a dict containing one of the below: # {'error': <message>} # {'error': <message>, 'stackTrace': <trace>} # Fix up relative paths and map any newer parm names to old parm names # that are expected by the calc function. If we want this to become a public # API, we need to accept the new names only. opts = Namespace() # layoutInput is required: accept either a file location relative to the # data root, or a URL. ctx.layoutInputUrls = [] if 'layoutInputDataId' in parms: opts.layoutInputFile = \ [path.join(ctx.app.dataRoot, parms['layoutInputDataId'])] ctx.layoutInputUrls.append(ctx.app.dataServer + '/data/' + parms['layoutInputDataId']) elif 'layoutInputUrl' in parms: opts.layoutInputFile = [parms['layoutInputUrl']] ctx.layoutInputUrls.append(parms['layoutInputUrl']) # names and directory are required opts.names = [parms['layoutInputName']] opts.directory = path.join(ctx.app.dataRoot, parms['outputDirectory']) # colorAttribute is optional: accept either a file location relative to the # data root, or a URL. ctx.colorAttributeUrls = [] if 'colorAttributeDataId' in parms: opts.scores = \ [path.join(ctx.app.dataRoot, parms['colorAttributeDataId'])] ctx.colorAttributeUrls.append(ctx.app.dataServer + '/data/' + parms['colorAttributeDataId']) elif 'colorAttributeUrl' in parms: opts.scores = [parms['colorAttributeUrl']] ctx.colorAttributeUrls.append(parms['colorAttributeUrl']) # The rest of these are optional. if 'zeroReplace' in parms: opts.zeroReplace = parms['zeroReplace'] if 'noLayoutIndependentStats' in parms: opts.associations = not parms['noLayoutIndependentStats'] if 'noLayoutAwareStats' in parms: opts.mutualinfo = not parms['noLayoutAwareStats'] # Call the calc function. result = { 'logFile': layout.makeMapUIfiles(opts), } # Check the calc log for success. checkLog(result, ctx) # Save the url to access the new map. if 'viewServer' in parms: viewServer = parms['viewServer'] else: viewServer = ctx.app.viewServer result['url'] = viewServer + '/?p=' + ctx.map return "Success", result