本文整理汇总了Python中quick.application.ExternalTrackManager.ExternalTrackManager类的典型用法代码示例。如果您正苦于以下问题:Python ExternalTrackManager类的具体用法?Python ExternalTrackManager怎么用?Python ExternalTrackManager使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ExternalTrackManager类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: createRSquareGraph
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
示例2: execute
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')
示例3: execute
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
示例4: execute
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,代码行数:30,代码来源:ConvertVCFToGtrackTool.py
示例5: _collectTracks
def _collectTracks(self):
tracks = [self._track, self._track2]
if 'trackNameIntensity' in self._kwArgs:
assert not 'extraTracks' in self._kwArgs
self._kwArgs['extraTracks'] = self._kwArgs['trackNameIntensity']
if 'extraTracks' in self._kwArgs:
from gold.track.Track import PlainTrack
import re
from config.Config import MULTIPLE_EXTRA_TRACKS_SEPARATOR
extraTracks = self._kwArgs['extraTracks']
if type(extraTracks) == str:
extraTracks = extraTracks.split(MULTIPLE_EXTRA_TRACKS_SEPARATOR)
for extraT in extraTracks:
if type(extraT) == str:
#extraT = extraT.split('|')
#extraT = re.split('\^|\|',extraT)
extraT = convertTNstrToTNListFormat(extraT)
if type(extraT) == list:
#print 'TEMP1: ', extraT
from urllib import unquote
extraT = [unquote(part) for part in extraT]
from quick.application.ExternalTrackManager import ExternalTrackManager
if ExternalTrackManager.isGalaxyTrack(extraT):
extraT = ExternalTrackManager.getPreProcessedTrackFromGalaxyTN(self.getGenome(), extraT)
extraT = PlainTrack(extraT)
tracks.append(extraT)
return tracks
示例6: execute
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()
示例7: findOverrepresentedTFsFromGeneSet
def findOverrepresentedTFsFromGeneSet(genome, tfSource, ensembleGeneIdList,upFlankSize, downFlankSize, geneSource, galaxyFn):
#galaxyFn = '/usit/insilico/web/lookalike/galaxy_dist-20090924-dev/database/files/003/dataset_3347.dat'
#print 'overriding galaxyFN!: ', galaxyFn
galaxyId = extractIdFromGalaxyFn(galaxyFn)
uniqueWebPath = getUniqueWebPath(extractIdFromGalaxyFn(galaxyFn))
assert genome == 'hg18'
tfTrackNameMappings = TfInfo.getTfTrackNameMappings(genome)
tfTrackName = tfTrackNameMappings[tfSource]
#Get gene track
assert geneSource == 'Ensembl'
targetGeneRegsTempFn = uniqueWebPath + os.sep + 'geneRegs.bed'
geneRegsTrackName = GenomeInfo.getStdGeneRegsTn(genome)
geneRegsFn = getOrigFn(genome, geneRegsTrackName, '.category.bed')
GalaxyInterface.getGeneTrackFromGeneList(genome, geneRegsTrackName, ensembleGeneIdList, targetGeneRegsTempFn )
assert upFlankSize == downFlankSize == 0 #Should instead extend regions to include flanks
tcGeneRegsTempFn = uniqueWebPath + os.sep + 'tcGeneRegs.targetcontrol.bedgraph'
#Think this will be okay, subtraction not necessary as targets are put first:
controlGeneRegsTempFn = geneRegsFn
#print targetGeneRegsTempFn, controlGeneRegsTempFn, tcGeneRegsTempFn
GalaxyInterface.combineToTargetControl(targetGeneRegsTempFn, controlGeneRegsTempFn, tcGeneRegsTempFn)
#tcGeneRegsExternalTN = ['external'] +galaxyId + [tcGeneRegsTempFn]
tcGeneRegsExternalTN = ExternalTrackManager.createStdTrackName(galaxyId, 'tempTc')
#tcGeneRegsExternalTN = ['external'] +targetGalaxyId + [tcGeneRegsTempFn]
#tcGeneRegsExternalTN = ['galaxy', externalId, tcGeneRegsTempFn]
targetGeneRegsExternalTN = ExternalTrackManager.createStdTrackName(galaxyId, 'tempTc', '1')
controlGeneRegsExternalTN = ExternalTrackManager.createStdTrackName(galaxyId, 'tempTc', '0')
#pre-process
print 'Pre-processing file: %s, with trackname: %s ' % (tcGeneRegsTempFn, tcGeneRegsExternalTN)
ExternalTrackManager.preProcess(tcGeneRegsTempFn, tcGeneRegsExternalTN, 'targetcontrol.bedgraph',genome)
print 'Pre-processing TN: ', targetGeneRegsExternalTN
ExternalTrackManager.preProcess(targetGeneRegsTempFn, targetGeneRegsExternalTN, 'bed',genome)
print 'Pre-processing TN: ', controlGeneRegsExternalTN
ExternalTrackManager.preProcess(controlGeneRegsTempFn, controlGeneRegsExternalTN, 'bed',genome)
#print tcGeneRegsExternalTN
trackName1, trackName2 = tfTrackName, tcGeneRegsExternalTN
analysisDef = 'Categories differentially located in targets?: Which categories of track1-points fall more inside case than control track2-segments? [rawStatistic:=PointCountInsideSegsStat:]' +\
'[tf1:=SegmentToStartPointFormatConverter:] [tf2:=TrivialFormatConverter:]' +\
'-> DivergentRowsInCategoryMatrixStat'
regSpec, binSpec = '*','*'
#print 'skipping preproc!!'
#ExternalTrackManager.preProcess(tcGeneRegsExternalTN[-1], tcGeneRegsExternalTN, 'targetcontrol.bedgraph', genome)
#ExternalTrackManager.preProcess(targetGeneRegsTempFn, targetGeneRegsExternalTN, 'bed', genome)
GalaxyInterface.runManual([trackName1, trackName2], analysisDef, regSpec, binSpec, genome, printResults=True, printHtmlWarningMsgs=False)
示例8: createLinkedPointTrack
def createLinkedPointTrack(cls, rsids, isUndirected, trackFn, r2):
from quick.webtools.clustering.CreateLDTrack import CreateLDTrack
from quick.application.ExternalTrackManager import ExternalTrackManager
# Create file for GTrack
galaxyTN = ExternalTrackManager.constructGalaxyTnFromSuitedFn(trackFn, fileEnding='gtrack', name='ld_graph')
fn = ExternalTrackManager.extractFnFromGalaxyTN(galaxyTN)
f = open(fn, 'w')
# Get LD information and create linked point track
ldDict = CreateLDTrack.getLDDict(r2)
expansionDict = CreateLDTrack.getExpansionDict(rsids, ldDict)
f.write(CreateLDTrack.formatLinkedPointTrack(expansionDict, isUndirected))
示例9: getOptionsBox6
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
示例10: execute
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
示例11: getRedirectURL
def getRedirectURL(choices):
genome = choices[0]
track1file = ExternalTrackManager.createSelectValueFromGalaxyTN(choices[1].split(':'))
track2file = ExternalTrackManager.createSelectValueFromGalaxyTN(choices[2].split(':'))
return createHyperBrowserURL(genome, trackName1=['galaxy'], trackName2=['galaxy'], \
track1file=track1file, track2file=track2file, \
analysis='Category pairs differentially co-located?', \
configDict={'Method of counting points': 'Only 1 count per bin (binary)',\
'Normalize counts': 'Differentially in both directions' if \
choices[3] == 'Both rows and columns (focusing on column differences)'\
else 'Differentially for points only',\
'P-value threshold for significance': '0.01'},\
method='__chrs__')
示例12: execute
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[1] if choices[0] == 'Yes' else None
suffix = ExternalTrackManager.extractFileSuffixFromGalaxyTN(choices[2].split(':'))
inFn = ExternalTrackManager.extractFnFromGalaxyTN(choices[2].split(':'))
try:
standardizeGtrackFileAndWriteToFile(inFn, galaxyFn, genome, suffix=suffix)
except Exception, e:
import sys
print >> sys.stderr, e
示例13: getOptionsBoxFileContentsInfo
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))
示例14: execute
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
示例15: execute
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.
'''
genome = choices[0]
trackName = choices[1].split(':')
galaxyOutTrackName = 'galaxy:hbfunction:%s:Create function track of distance to nearest segment' % galaxyFn
outTrackName = ExternalTrackManager.getStdTrackNameFromGalaxyTN(galaxyOutTrackName.split(':'))
if choices[2] == 'No transformation':
valTransformation = 'None'
elif choices[2] =='Logarithmic (log10(x))':
valTransformation = 'log10'
elif choices[2] == 'Fifth square root (x**0.2)':
valTransformation = 'power0.2'
analysisDef ='[dataStat=MakeDistanceToNearestSegmentStat] [valTransformation=%s][outTrackName=' % valTransformation \
+ '^'.join(outTrackName) + '] -> CreateFunctionTrackStat'
#userBinSource, fullRunArgs = GalaxyInterface._prepareRun(trackName, None, analysisDef, '*', '*', genome)
#
#for el in userBinSource:
# print el.chr, el.start, el.end
from quick.application.GalaxyInterface import GalaxyInterface
print GalaxyInterface.getHbFunctionOutputBegin(galaxyFn, withDebug=False)
GalaxyInterface.runManual([trackName], analysisDef, '*', '*', genome, username=username, printResults=False, printHtmlWarningMsgs=False)
#job = AnalysisDefJob(analysisDef, trackName, None, userBinSource).run()
print GalaxyInterface.getHbFunctionOutputEnd('A custom track has been created by finding the bp-distance to the nearest segment', withDebug=False)