本文整理汇总了Python中quick.application.ExternalTrackManager.ExternalTrackManager.extractFnFromGalaxyTN方法的典型用法代码示例。如果您正苦于以下问题:Python ExternalTrackManager.extractFnFromGalaxyTN方法的具体用法?Python ExternalTrackManager.extractFnFromGalaxyTN怎么用?Python ExternalTrackManager.extractFnFromGalaxyTN使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类quick.application.ExternalTrackManager.ExternalTrackManager
的用法示例。
在下文中一共展示了ExternalTrackManager.extractFnFromGalaxyTN方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: execute
# 需要导入模块: from quick.application.ExternalTrackManager import ExternalTrackManager [as 别名]
# 或者: from quick.application.ExternalTrackManager.ExternalTrackManager import extractFnFromGalaxyTN [as 别名]
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.
'''
outputFile=open(galaxyFn,"w")
fnSource = ExternalTrackManager.extractFnFromGalaxyTN(choices[0].split(':'))
inputFile = open(ExternalTrackManager.extractFnFromGalaxyTN(choices[0].split(':')), 'r')
if choices[2] == 'Filter on exact values':
if choices[3]!='Select column..':
column = int(choices[3][7:])
filterSet = set([key for key,val in choices[4].items() if val])
for i in inputFile:
if i.split('\t')[column] in filterSet:
print>>outputFile, i
else:
for i in inputFile:
temptab = i.split('\t')
for index in range(len(temptab)):
locals()['c'+str(index)] = temptab[index]
if eval(choices[5]):
print>>outputFile, i
inputFile.close()
outputFile.close()
示例2: execute
# 需要导入模块: from quick.application.ExternalTrackManager import ExternalTrackManager [as 别名]
# 或者: from quick.application.ExternalTrackManager.ExternalTrackManager import extractFnFromGalaxyTN [as 别名]
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.
'''
resultLines = []
outputFile=open(galaxyFn,"w")
fnSource = ExternalTrackManager.extractFnFromGalaxyTN(choices[2].split(':'))
fnDB = ExternalTrackManager.extractFnFromGalaxyTN(choices[3].split(':'))
intersectingFactor = 'id' if choices[4] == 'Element id' else 'position'
colsToAdd = []
colsToAddDict = choices[5]
for key in colsToAddDict:
if colsToAddDict[key]:
colsToAdd.append(key)
genome = choices[1] if choices[0] == 'Yes' else None
try:
complementGtrackFileAndWriteToFile(fnSource, fnDB, galaxyFn, intersectingFactor, colsToAdd, genome)
except Exception, e:
import sys
print >> sys.stderr, e
示例3: execute
# 需要导入模块: from quick.application.ExternalTrackManager import ExternalTrackManager [as 别名]
# 或者: from quick.application.ExternalTrackManager.ExternalTrackManager import extractFnFromGalaxyTN [as 别名]
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. 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.
'''
# get population format
if choices.format == 'File':
pop = [];
popfile = choices.population;
inFn = ExternalTrackManager.extractFnFromGalaxyTN(popfile.split(":"));
infile = open(inFn);
for line in infile:
pop.append(line.rstrip('\n'));
else:
pop = map(str.strip,choices.population.split(","));
# read in file
inFn = ExternalTrackManager.extractFnFromGalaxyTN(choices.vcf.split(":"));
data = open(inFn).read();
# convert and write to GTrack file
outfile = open(galaxyFn, 'w');
outfile.write(addHeader(choices.genome));
outfile.write(convertToGtrackFile(data, pop, choices.genome));
outfile.close();
开发者ID:tuvakt,项目名称:Fast-Parallel-Tools-for-Genome-wide-Analysis-of-Genomic-Divergence,代码行数:32,代码来源:ConvertVCFToGtrackTool.py
示例4: execute
# 需要导入模块: from quick.application.ExternalTrackManager import ExternalTrackManager [as 别名]
# 或者: from quick.application.ExternalTrackManager.ExternalTrackManager import extractFnFromGalaxyTN [as 别名]
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.
'''
try:
historyInputTN = choices[0].split(':') #from history
historyGalaxyFn = ExternalTrackManager.extractFnFromGalaxyTN( historyInputTN) #same as galaxyFn in execute of create benchmark..
randomStatic = RunSpecificPickleFile(historyGalaxyFn) #finds path to static file created for a previous history element, and directs to a pickle file
myInfo = randomStatic.loadPickledObject()
except:
return None
galaxyTN = myInfo[3].split(':')
myFileName = ExternalTrackManager.extractFnFromGalaxyTN(galaxyTN)
genome = myInfo[0]
gtrackSource = GtrackGenomeElementSource(myFileName, genome)
regionList = []
for obj in gtrackSource:
regionList.append(GenomeRegion(obj.genome, obj.chr, obj.start, obj.end))
extractor = TrackExtractor()
fn = extractor.extract(GenomeInfo.getSequenceTrackName(genome), regionList, galaxyFn, 'fasta')
示例5: getOptionsBox6
# 需要导入模块: from quick.application.ExternalTrackManager import ExternalTrackManager [as 别名]
# 或者: from quick.application.ExternalTrackManager.ExternalTrackManager import extractFnFromGalaxyTN [as 别名]
def getOptionsBox6(prevChoices):
if prevChoices[3]:
extraDbColumnsDict = OrderedDict()
fnSource = ExternalTrackManager.extractFnFromGalaxyTN(prevChoices[2].split(':'))
fnDB = ExternalTrackManager.extractFnFromGalaxyTN(prevChoices[3].split(':'))
gtrackDB = GtrackGenomeElementSource(fnDB)
gtrackSource = GtrackGenomeElementSource(fnSource)
extraDbColumns = [v for v in gtrackDB.getColumns() if not v in gtrackSource.getColumns()] #list(set(gtrackDBColumnSpec) - set(gtrackSourceColumnSpec))
for column in extraDbColumns:
extraDbColumnsDict[column] = False
return extraDbColumnsDict
示例6: execute
# 需要导入模块: from quick.application.ExternalTrackManager import ExternalTrackManager [as 别名]
# 或者: from quick.application.ExternalTrackManager.ExternalTrackManager import extractFnFromGalaxyTN [as 别名]
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.
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 time import time
startTime = time()
from quick.application.ExternalTrackManager import ExternalTrackManager
from quick.util.StaticFile import GalaxyRunSpecificFile
import os
motifFn = ExternalTrackManager.extractFnFromGalaxyTN( choices[0].split(':'))
observedFasta = ExternalTrackManager.extractFnFromGalaxyTN( choices[1].split(':'))
randomGalaxyTN = choices[2].split(':')
randomName = ExternalTrackManager.extractNameFromHistoryTN(randomGalaxyTN)
randomGalaxyFn = ExternalTrackManager.extractFnFromGalaxyTN( randomGalaxyTN)
randomStatic = GalaxyRunSpecificFile(['random'],randomGalaxyFn) #finds path to static file created for a previous history element (randomFn), and directs to a folder containing several files..
#print os.listdir(randomStatic.getDiskPath())
randomFastaPath = randomStatic.getDiskPath()
#motifFn, observedFasta, randomFastaPath = '/Users/sandve/egne_dokumenter/_faglig/NullModels/DnaSeqExample/liver.pwm', 'liver.fa', 'randomFastas'
testStatistic = choices[3]
if testStatistic == 'Average of max score per sequence':
scoreFunc = scoreMotifOnFastaAsAvgOfBestScores
elif testStatistic == 'Sum of scores across all positions of all sequences':
scoreFunc = scoreMotifOnFastaAsSumOfAllScores
elif testStatistic == 'Score of Frith et al. (2004)':
scoreFunc = lr4
elif testStatistic == 'Product of max per sequence':
scoreFunc = scoreMotifOnFastaAsProductOfBestScores
else:
raise
pvals = mcPvalFromMotifAndFastas(motifFn, observedFasta, randomFastaPath, scoreFunc)
print 'Pvals for motifs (%s) against observed (%s) vs random (%s - %s) sequences.' % (motifFn, observedFasta, randomName, randomFastaPath)
for motif,pval in sorted(pvals.items()):
print motif+'\t'+('%.4f'%pval)
from quick.util.StaticFile import GalaxyRunSpecificFile
from gold.application.RSetup import r, robjects
histStaticFile = GalaxyRunSpecificFile(['pvalHist.png'],galaxyFn)
#histStaticFile.openRFigure()
histStaticFile.plotRHist(pvals.values(), [x/40.0 for x in range(41)], 'Histogram of p-values', xlim=robjects.FloatVector([0.0, 1.0]))
#r.hist(robjects.FloatVector(pvals.values()), breaks=robjects.FloatVector([x/40.0 for x in range(41)]), xlim=robjects.FloatVector([0.0, 1.0]), main='Histogram of p-values' )
#histStaticFile.closeRFigure()
print histStaticFile.getLink('Histogram')
print 'Time (s):', time()-startTime
示例7: execute
# 需要导入模块: from quick.application.ExternalTrackManager import ExternalTrackManager [as 别名]
# 或者: from quick.application.ExternalTrackManager.ExternalTrackManager import extractFnFromGalaxyTN [as 别名]
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)
示例8: _getHeaders
# 需要导入模块: from quick.application.ExternalTrackManager import ExternalTrackManager [as 别名]
# 或者: from quick.application.ExternalTrackManager.ExternalTrackManager import extractFnFromGalaxyTN [as 别名]
def _getHeaders(prevChoices):
numCols = TabularToGtrackTool._getFileContentsInfo(prevChoices).numCols
if prevChoices.columnSelection == 'Select individual columns':
header = []
for i in xrange(numCols):
if hasattr(prevChoices, 'column%s' % i):
colHeader = getattr(prevChoices, 'column%s' % i)
if colHeader is None or colHeader == '-- ignore --':
header.append('')
elif colHeader == '-- custom --':
header.append(getattr(prevChoices, 'customColumn%s' % i).strip())
else:
header.append(colHeader)
else:
header.append('')
return header
else:
genome = prevChoices.genome if prevChoices.selectGenome == 'Yes' else None
inFn = ExternalTrackManager.extractFnFromGalaxyTN(prevChoices.colSpecFile.split(':'))
try:
geSource = GtrackGenomeElementSource(inFn, genome=genome)
geSource.parseFirstDataLine()
return geSource.getColumns()[:numCols]
except Exception, e:
return []
示例9: getOptionsBoxFileContentsInfo
# 需要导入模块: from quick.application.ExternalTrackManager import ExternalTrackManager [as 别名]
# 或者: from quick.application.ExternalTrackManager.ExternalTrackManager import extractFnFromGalaxyTN [as 别名]
def getOptionsBoxFileContentsInfo(prevChoices):
if prevChoices.history or prevChoices.input:
if prevChoices.history:
inputFile = open(ExternalTrackManager.extractFnFromGalaxyTN(prevChoices.history.split(':')), 'r')
else:
inputFile = StringIO(prevChoices.input)
for i in xrange(TabularToGtrackTool._getNumSkipLines(prevChoices)):
inputFile.readline()
table = []
splitChar = TabularToGtrackTool._getSplitChar(prevChoices)
numCols = None
error = None
for i,line in enumerate(inputFile):
row = [x.strip() for x in line.strip().split(splitChar)]
if numCols == None:
numCols = len(row)
elif numCols != len(row):
numCols = max(numCols, len(row))
# error = 'Error: the number of columns varies over the rows of the tabular file.'
table.append(row)
if i == TabularToGtrackTool.NUM_ROWS_IN_TABLE:
break
numCols = max(len(row) for row in table) if len(table) > 0 else 0
if error is None:
if numCols > TabularToGtrackTool.NUM_COLUMN_FUNCTIONS:
error = 'Error: the tabular file has more columns than is allowed by the tool (%s > %s).' % (numCols, TabularToGtrackTool.NUM_COLUMN_FUNCTIONS)
return ('__hidden__', FileContentsInfo(table=table, numCols=numCols, error=error))
示例10: execute
# 需要导入模块: from quick.application.ExternalTrackManager import ExternalTrackManager [as 别名]
# 或者: from quick.application.ExternalTrackManager.ExternalTrackManager import extractFnFromGalaxyTN [as 别名]
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.
'''
genome = choices.genome if choices.selectGenome == 'Yes' else None
onlyNonDefault = choices.allHeaders == 'Only non-default headers'
try:
if choices.history:
inFn = ExternalTrackManager.extractFnFromGalaxyTN(choices.history.split(':'))
expandHeadersOfGtrackFileAndWriteToFile(inFn, galaxyFn, genome, onlyNonDefault)
else:
if choices.whitespace == 'Keep whitespace exact':
input = choices.input
else:
input = ''
for line in choices.input.split(os.linesep):
line = line.strip()
if (line.startswith('###') and len(line) > 3 and line[3] != '#') \
or not line.startswith('#'):
line = line.replace(' ', '\t')
else:
line = line.replace('\t', ' ')
input += line + os.linesep
composer = expandHeadersOfGtrackFileAndReturnComposer('', genome, strToUseInsteadOfFn=input)
composer.composeToFile(galaxyFn, onlyNonDefault=onlyNonDefault)
except Exception, e:
import sys
print >> sys.stderr, e
示例11: execute
# 需要导入模块: from quick.application.ExternalTrackManager import ExternalTrackManager [as 别名]
# 或者: from quick.application.ExternalTrackManager.ExternalTrackManager import extractFnFromGalaxyTN [as 别名]
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. 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.
'''
# Retrieve the pickled benchmark object from history
try:
historyInputTN = choices[0].split(':')
#same as galaxyFn in execute of create benchmark..
historyGalaxyFn = ExternalTrackManager.extractFnFromGalaxyTN(historyInputTN)
#finds path to static file created for a previous history element, and directs to a pickle file
randomStatic = RunSpecificPickleFile(historyGalaxyFn)
benchmarkSpecification = randomStatic.loadPickledObject()
except:
return None
genome = benchmarkSpecification[0]
benchmarkLevel = benchmarkSpecification[2]
regionTrackName = benchmarkSpecification[3]
benchmarkUtil = BenchmarkUtil(galaxyFn, genome)
if benchmarkLevel == 'Base pair probability level':
return benchmarkUtil.retrieveFeatureTrack(genome, galaxyFn, regionTrackName, benchmarkSpecification[5])
elif type(regionTrackName) is str: # If string, we're dealing with a single track so just retrieve it
return benchmarkUtil.retrieveTrack(regionTrackName, galaxyFn)
elif type(regionTrackName) is list: # If list, we're dealing with a benchmark suite which will have to be zipped
print benchmarkUtil.retrieveBenchmarkSuiteAsZipFile(regionTrackName)
else:
raise Exception('Invalid benchmark')
示例12: createRSquareGraph
# 需要导入模块: from quick.application.ExternalTrackManager import ExternalTrackManager [as 别名]
# 或者: from quick.application.ExternalTrackManager.ExternalTrackManager import extractFnFromGalaxyTN [as 别名]
def createRSquareGraph(cls, ldGraphTrackName, r2_threshold):
"""
Creates a dictionary of all pairs in a linked point track.
Variants in LD must have rsquare >= the rsquare threshold passed to the function.
:param ldGraphTrackName: linked point track, as chosen in tool (choices.ldtrack)
:param r2_threshold: Lower limit of square value
:return: Dictionary of all ld-pairs with sorted key = (rsid1, rsid2), value = rSquare
"""
from quick.application.ExternalTrackManager import ExternalTrackManager
from gold.origdata.GtrackGenomeElementSource import GtrackGenomeElementSource
fileName = ExternalTrackManager.extractFnFromGalaxyTN(ldGraphTrackName)
suffix = ExternalTrackManager.extractFileSuffixFromGalaxyTN(ldGraphTrackName)
gtSource = GtrackGenomeElementSource(fileName, suffix=suffix)
r2graph = {}
for ge in gtSource:
rsid = ge.id
edges = ge.edges
weights = ge.weights
for i in range(0, len(edges)):
ldRsid = edges[i]
r2 = weights[i]
if r2 >= float(r2_threshold):
cls.addEdge(r2graph, rsid, ldRsid, r2)
return r2graph
示例13: execute
# 需要导入模块: from quick.application.ExternalTrackManager import ExternalTrackManager [as 别名]
# 或者: from quick.application.ExternalTrackManager.ExternalTrackManager import extractFnFromGalaxyTN [as 别名]
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 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...'
tempinfofile=ExternalTrackManager.extractFnFromGalaxyTN(choices[0].split(":"))
abbrv=GenomeImporter.getGenomeAbbrv(tempinfofile)
gi = GenomeInfo(abbrv)
chrNamesInFasta=gi.sourceChrNames
chromNamesDict={}
chrDict = InstallGenomeTool._getRenamedChrDictWithSelection(choices)
for i, key in enumerate(chrDict.keys()):
if chrDict[key]:
chromNamesDict[chrNamesInFasta[i]]=key
print 'All chromosomes chosen: ' + str(chromNamesDict)
stdChrDict = InstallGenomeTool._getRenamedChrDictWithSelection(choices, stdChrs=True)
stdChrs = [x for x in stdChrDict if stdChrDict[x]]
print 'Standard chromosomes chosen: ' + ", ".join(stdChrs)
GenomeImporter.createGenome(abbrv, gi.fullName, chromNamesDict, stdChrs, username=username)
gi.installedBy = username
gi.timeOfInstallation = datetime.now()
gi.store()
示例14: _getTempChromosomeNames
# 需要导入模块: from quick.application.ExternalTrackManager import ExternalTrackManager [as 别名]
# 或者: from quick.application.ExternalTrackManager.ExternalTrackManager import extractFnFromGalaxyTN [as 别名]
def _getTempChromosomeNames(galaxyTn):
if isinstance(galaxyTn, str):
galaxyTn = galaxyTn.split(":")
tempinfofile=ExternalTrackManager.extractFnFromGalaxyTN(galaxyTn)
abbrv=GenomeImporter.getGenomeAbbrv(tempinfofile)
return os.linesep.join(GenomeInfo(abbrv).sourceChrNames)
示例15: execute
# 需要导入模块: from quick.application.ExternalTrackManager import ExternalTrackManager [as 别名]
# 或者: from quick.application.ExternalTrackManager.ExternalTrackManager import extractFnFromGalaxyTN [as 别名]
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.
'''
fnSource = ExternalTrackManager.extractFnFromGalaxyTN(choices[2].split(':'))
core = HtmlCore()
core.begin()
valid = False
try:
core.header('Validating GTrack headers')
core.styleInfoBegin(styleClass='debug')
print str(core)
core = HtmlCore()
gtrackSource = GtrackGenomeElementSource(fnSource, choices[1] if choices[0]=='Yes' else None, printWarnings=True)
core.append('Done')
core.styleInfoEnd()
core.header('Validating complete GTrack file')
core.styleInfoBegin(styleClass='debug')
print str(core)
core = HtmlCore()
try:
for ge in gtrackSource:
pass
except Exception, e:
pass
else: