本文整理汇总了Python中quick.util.GenomeInfo.GenomeInfo类的典型用法代码示例。如果您正苦于以下问题:Python GenomeInfo类的具体用法?Python GenomeInfo怎么用?Python GenomeInfo使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了GenomeInfo类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: 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 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()
示例2: __iter__
def __iter__(self):
brShelve1 = self._getBoundingRegionShelve(self._trackName1)
brShelve2 = self._getBoundingRegionShelve(self._trackName2)
for chr in GenomeInfo.getExtendedChrList(self.genome):
if brShelve1 is None:
yield GenomeRegion(self.genome, chr, 0, GenomeInfo.getChrLen(self.genome, chr))
else:
brList1 = brShelve1.getAllBoundingRegions(chr)
allBrsAreWholeChrs1 = self._commonAllBoundingRegionsAreWholeChr(brShelve1)
allBrsAreWholeChrs2 = self._commonAllBoundingRegionsAreWholeChr(brShelve2) \
if brShelve2 is not None else False
if brShelve2 is None or \
(allBrsAreWholeChrs2 and not allBrsAreWholeChrs1):
for reg in brList1:
yield reg
else:
brList2 = brShelve2.getAllBoundingRegions(chr)
if allBrsAreWholeChrs1 and not allBrsAreWholeChrs2:
for reg in brList2:
yield reg
else:
for reg in self.getAllIntersectingRegions(self.genome, chr, brList1, brList2):
yield reg
示例3: _removeBoundingRegionTuplesIfFullChrsAndNotFixedGapSize
def _removeBoundingRegionTuplesIfFullChrsAndNotFixedGapSize(self):
if self.getFixedGapSize() == 0 and not self._reprIsDense:
# If only full chromosomes
if all(brt.region.chr in GenomeInfo.getExtendedChrList(self._genome) and \
brt.region.start == 0 and \
brt.region.end == GenomeInfo.getChrLen(self._genome, brt.region.chr) \
for brt in self._boundingRegionTuples):
self._boundingRegionTuples = []
示例4: _checkValidStart
def _checkValidStart(self, chr, start):
if start < 0:
raise InvalidFormatError('Error: start position is negative: %s' % start)
if self.genome and \
GenomeInfo.isValidChr(self.genome, chr) and \
start > GenomeInfo.getChrLen(self.genome, chr):
raise InvalidFormatError('Error: start position is larger than chromosome size (%s) < %d' % \
(GenomeInfo.getChrLen(self.genome, chr), start))
return start
示例5: createNmerChains
def createNmerChains(self, n):
for chr in GenomeInfo.getChrList(self._genome):
print 'Creating chains of nmers of length ', n, ' for chromosome ', chr
chrLen = GenomeInfo.getChrLen(self._genome,chr)
chrReg = GenomeRegion( self._genome, chr, 0, chrLen )
seqTV = PlainTrack( GenomeInfo.getSequenceTrackName(self._genome) ).getTrackView(chrReg)
#nmersAsInts = NmerAsIntSlidingWindow(n, FuncValTvWrapper(seqTV))
nmersAsInts = NmerAsIntSlidingWindow(n, seqTV.valsAsNumpyArray())
SameValueIndexChainsFactory.generate( nmersAsInts, chrLen, 4**n, self._createPath(n), chr )
示例6: _checkValidEnd
def _checkValidEnd(self, chr, end, start=None):
if end < 0:
raise InvalidFormatError('Error: end position is negative: %s' % end)
if self.genome and \
GenomeInfo.isValidChr(self.genome, chr) and \
end-1 > GenomeInfo.getChrLen(self.genome, chr):
raise InvalidFormatError('Error: end position is larger than chromosome size (%s)' % \
GenomeInfo.getChrLen(self.genome, chr))
if start is not None and end <= start:
raise InvalidFormatError('Error: end position (end-exclusive) is smaller than or equal to start position: %d <= %d' % (end, start))
return end
示例7: _getBoundingRegionTupleList
def _getBoundingRegionTupleList(self, case, sortedAssertElList):
boundingRegions = [br for br in sorted(case.boundingRegionsAssertList) if br.region.chr is not None]
if len(boundingRegions) > 0:
return [BoundingRegionTuple(GenomeRegion(self.GENOME, chr=br.region.chr, \
start=br.region.start if br.region.start is not None else 0, \
end=br.region.end if br.region.end is not None else \
GenomeInfo.getChrLen(self.GENOME, br.region.chr)), br.elCount)
for br in boundingRegions]
else:
totChrList = [ge.chr for ge in sortedAssertElList]
chrBrList = OrderedDict( [ (i, totChrList.count(i)) for i in sorted(set(totChrList)) ] )
return [BoundingRegionTuple(GenomeRegion(self.GENOME, chr=chr, start=0, \
end=GenomeInfo.getChrLen(self.GENOME, chr)), elCount) \
for chr, elCount in chrBrList.iteritems()]
示例8: 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')
示例9: getTrackView
def getTrackView(self, region):
assert self._origRegion == region
allChrArmRegs = GenomeInfo.getContainingChrArms(region)
if len(allChrArmRegs) != 1:
raise CentromerError
chrArm = allChrArmRegs[0]
buffer = self._getIndepencyBufferSize(region)
sourceRegs = chrArm.exclude( copy(region).extend(-buffer).extend(buffer) )
assert len(sourceRegs) in [1,2]
if not any(len(sourceReg) >= self.MIN_SOURCE_TO_SAMPLE_SIZE_RATIO * len(region) for sourceReg in sourceRegs):
raise TooLargeBinError('Source region lengths of ' + str([len(x) for x in sourceRegs]) +
' are too small compared to region length of ' + str(len(region)) +
' according to MIN_SOURCE_TO_SAMPLE_SIZE_RATIO: ' + str(self.MIN_SOURCE_TO_SAMPLE_SIZE_RATIO))
if len(sourceRegs) == 1:
sourceReg = sourceRegs[0]
else:
firstSourceProportion = (len(sourceRegs[0])-len(region)) / sum(len(sourceRegs[i])-len(region) for i in range(2))
sourceReg = sourceRegs[0] if random.random() < firstSourceProportion else sourceRegs[1]
randOffset = random.randint( 0, len(sourceReg) - len(region) )
start = sourceReg.start + randOffset
end = start + len(region)
randRegion = GenomeRegion(region.genome, region.chr, start, end)
rawData = RawDataStat(randRegion, self._origTrack, self._trackFormatReq)
tv = rawData.getResult()
assert region != tv.genomeAnchor
return tv
示例10: _createPreProcFiles
def _createPreProcFiles(self):
collector = TrackInfoDataCollector(self._genome, self._trackName)
collector.updateMetaDataForFinalization(self._geSource.getFileSuffix(), self._geSource.getPrefixList(), \
self._geSource.getValDataType(), self._geSource.getValDim(), \
self._geSource.getEdgeWeightDataType(), self._geSource.getEdgeWeightDim(), \
self._geSource.hasUndirectedEdges(),
self._geSource.getVersion(), PreProcessUtils.constructId(self._geSource))
if collector.getNumElements(self._chr, self._allowOverlaps) == 0:
return
if self._mode != 'Real':
for ge in self._geSource:
pass
return
dirPath = createDirPath(self._trackName, self._genome, self._chr, self._allowOverlaps)
dir = OutputDirectory(dirPath, collector.getPrefixList(self._allowOverlaps), \
collector.getNumElements(self._chr, self._allowOverlaps),\
GenomeInfo.getChrLen(self._genome, self._chr), \
collector.getValDataType(), collector.getValDim(), \
collector.getEgdeWeightDataType(), collector.getEgdeWeightDim(), \
collector.getMaxNumEdges(self._chr, self._allowOverlaps), \
collector.getMaxStrLens(self._chr, self._allowOverlaps))
writeFunc = dir.writeRawSlice if self._geSource.isSliceSource() else dir.writeElement
for ge in self._geSource:
writeFunc(ge)
collector.appendPreProcessedChr(self._allowOverlaps, self._chr)
dir.close()
示例11: execute
def execute(cls, choices, galaxyFn=None, username=''):
start = time.time()
genome = choices[0]
trackName = choices[1].split(':')
outFn = galaxyFn
if choices[5] == 'Write to Standardised file':
outFn = createOrigPath(genome, choices[-1].split(':'), 'collapsed_result.bedgraph')
ensurePathExists(outFn[:outFn.rfind('/')+1])
combineMethod = choices[2]
category = choices[3] if choices[3] else ''
numSamples = choices[4] if choices[4] else '1'
analysisDef = 'dummy [combineMethod=%s] %s [numSamples=%s] -> ConvertToNonOverlappingCategorySegmentsPythonStat' % \
(combineMethod, '[category=%s]' % category if category != '' else '', numSamples) #'Python'
for regSpec in GenomeInfo.getChrList(genome):
res = GalaxyInterface.runManual([trackName], analysisDef, regSpec, '*', genome, username=username, \
printResults=False, printHtmlWarningMsgs=False)
from gold.origdata.TrackGenomeElementSource import TrackViewGenomeElementSource
from gold.origdata.BedComposer import CategoryBedComposer
for resDict in res.values():
tvGeSource = TrackViewGenomeElementSource(genome, resDict['Result'], trackName)
CategoryBedComposer(tvGeSource).composeToFile(outFn)
示例12: isValidTrack
def isValidTrack(genome, trackName, fullAccess=False):
if not TrackInfo(genome, trackName).isValid(fullAccess):
return False
for fn in ProcTrackOptions._getDirContents(genome, trackName):
if GenomeInfo.isValidChr(genome, fn) or isBoundingRegionFileName(fn):
return True
return False
示例13: assertChrElCounts
def assertChrElCounts(self, trackName, chrElCountDict, allowOverlaps, customBins):
for chr in chrElCountDict.keys():
if chr in customBins:
region = customBins[chr]
else:
region = GenomeRegion(self.GENOME, chr, 0, GenomeInfo.getChrLen(self.GENOME, chr))
tv = self._getTrackView(trackName, region, allowOverlaps)
self.assertEquals(chrElCountDict[chr], len([x for x in tv]))
示例14: getGlobalSource
def getGlobalSource(globalSourceStr, genome, minimal):
if minimal == True:
return MinimalBinSource(genome)
elif globalSourceStr == 'test':
return UserBinSource('TestGenome:chr21:10000000-15000000','1000000')
elif globalSourceStr == 'chrs':
return GenomeInfo.getChrRegs(genome)
elif globalSourceStr == 'chrarms':
return GenomeInfo.getChrArmRegs(genome)
elif globalSourceStr == 'ensembl':
return GenomeInfo.getStdGeneRegs(genome)
elif globalSourceStr == 'userbins':
from gold.application.StatRunner import StatJob
assert StatJob.USER_BIN_SOURCE is not None
return StatJob.USER_BIN_SOURCE
#return kwArgs['userBins']
else:
raise ShouldNotOccurError('globalSource not recognized')
示例15: 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)