Exemple #1
0
 def _createTrackCommon(cls, genome, inTrackName, outTrackName, windowSize,
                        func, username, chrList):
     regionList = [
         GenomeRegion(genome, chr, 0, GenomeInfo.getChrLen(genome, chr))
         for chr in chrList
     ]
     for region in regionList:
         PreProcessCustomTrackJob(genome,
                                  outTrackName, [region],
                                  cls._getGeSourceForRegion,
                                  username=username,
                                  preProcess=True,
                                  finalize=False,
                                  inTrackName=inTrackName,
                                  windowSize=windowSize,
                                  func=func).process()
     PreProcessCustomTrackJob(genome,
                              outTrackName,
                              regionList,
                              cls._getGeSourceForRegion,
                              username=username,
                              preProcess=False,
                              finalize=True,
                              inTrackName=inTrackName,
                              windowSize=windowSize,
                              func=func).process()
Exemple #2
0
    def _compute(self):
        if self._kwArgs.get('minimal') == True:
            return False
        
        job = PreProcessCustomTrackJob(self._region.genome, self._outTrackName, [self._region], \
                                       self._getGESource, username=self._username, preProcess=True, finalize=False)
        job.process()

        #To reduce memory consumption
        self._children = []

        return True
Exemple #3
0
    def _combineResults(self):
        if False in self._childResults:
            return False

        assert isIter(self._region)
        regionList = list(self._region)
        genome = regionList[0].genome
        
        job = PreProcessCustomTrackJob(genome, self._outTrackName, regionList, self._getGESource, \
                                       username=self._username, preProcess=False, finalize=True)
        job.process()
                
        return True
    def _createNmerTrack(self, nmerList, lowerOrder=None):
        nmerLengths = list(set([len(nmer) for nmer in nmerList]))
        assert len(nmerLengths) == 1

        chainOrder = lowerOrder if lowerOrder is not None else nmerLengths[0]

        regionList = GenomeInfo.getStdChrRegionList(self._genome)

        for region in regionList:
            print '|',

            chains = SameValueIndexChainsFactory.load(
                self._createPath(chainOrder), region.chr)

            for nmer in nmerList:
                if len(nmerList) > 1:
                    print '.',

                if lowerOrder is not None:
                    nmerPrefix = nmer[0:chainOrder]
                    rawIndexGenerator = chains.getIndexGenerator(
                        NmerTools.nmerAsInt(nmerPrefix))
                    indexGenerator = LowerOrderChainWrapper(
                        rawIndexGenerator, nmerPrefix, nmer, self._genome,
                        region.chr)
                else:
                    indexGenerator = chains.getIndexGenerator(
                        NmerTools.nmerAsInt(nmer))

                #print 'Length of lower order chain: %i and %i' % (sum(1 for x in indexGenerator), sum(1 for x in indexGenerator))
                #print 'Length of wrapped chain: %i and %i' % (sum(1 for x in wrappedIndexGenerator), sum(1 for x in wrappedIndexGenerator))

                PreProcessCustomTrackJob(self._genome, self._createTrackName(nmer), [region], \
                                         self._getNmerGeSourceForChr, finalize=False, preProcess=True, \
                                         indexGenerator=indexGenerator).process()

        for nmer in nmerList:
            try:
                PreProcessCustomTrackJob(self._genome, self._createTrackName(nmer), regionList, \
                                         self._getNmerGeSourceForChr, preProcess=False, finalize=True, \
                                         indexGenerator=[0]).process()
            except EmptyGESourceError:
                PreProcessCustomTrackJob(self._genome, self._createTrackName(nmer), [GenomeRegion(self._genome, regionList[0].chr, -1, 0)], \
                                         self._getNmerGeSourceForChr, preProcess=True, finalize=True, \
                                         indexGenerator=[-1]).process()

        return
Exemple #5
0
 def _createTrackCommon(cls, genome, inTrackName, outTrackName, windowSize,
                        func, username, chrList):
     regionList = [
         GenomeRegion(genome, chr, 0, GenomeInfo.getChrLen(genome, chr))
         for chr in chrList
     ]
     PreProcessCustomTrackJob(genome, outTrackName, regionList, cls._getGeSourceForRegion, \
                              username=username, inTrackName=inTrackName, windowSize=windowSize, func=func).process()
Exemple #6
0
    def _preProcessCustomTracks(self,
                                subTrackName,
                                regionList,
                                getGeSourceCallBackFunc,
                                noOverlapsFileCount=None,
                                withOverlapsFileCount=None,
                                noOverlapsChrElCount=None,
                                withOverlapsChrElCount=None,
                                **callBackArgs):
        trackName = self.TRACK_NAME_PREFIX + subTrackName

        for mergeChrFolders in [False, True]:
            self._removePreprocessedTrackData(trackName)
            print 'mergeChrFolders: {}'.format(mergeChrFolders)
            PreProcessCustomTrackJob(self.GENOME,
                                     trackName,
                                     regionList,
                                     getGeSourceCallBackFunc,
                                     username='******',
                                     preProcess=True,
                                     finalize=False,
                                     mergeChrFolders=mergeChrFolders,
                                     **callBackArgs).process()
            PreProcessCustomTrackJob(self.GENOME,
                                     trackName,
                                     regionList,
                                     getGeSourceCallBackFunc,
                                     username='******',
                                     preProcess=False,
                                     finalize=True,
                                     mergeChrFolders=mergeChrFolders,
                                     **callBackArgs).process()

            if not mergeChrFolders:
                if noOverlapsFileCount:
                    noOverlapsFileCount = (noOverlapsFileCount -
                                           1) * len(regionList)
                if withOverlapsFileCount:
                    withOverlapsFileCount = (withOverlapsFileCount -
                                             1) * len(regionList)

            self._assertCounts(trackName, noOverlapsFileCount,
                               withOverlapsFileCount, noOverlapsChrElCount,
                               withOverlapsChrElCount)