예제 #1
0
    def process(self):
        assert self._genome is not None, 'Error: genome must be specified when preprocessing tracks.'

        atLeastOneFinalized = False
        for trackName in self._allTrackNames():
            assert trackName != ['']
            overlapRulesProcessedForTrackName = []
            collector = PreProcMetaDataCollector(self._genome, trackName)

            try:
                trackName = self._renameTrackNameIfIllegal(trackName)

                for allowOverlaps in [True, False]:
                    anyGeSourceManagers = False

                    for geSourceManager in self._allGESourceManagers(trackName, allowOverlaps):
                        anyGeSourceManagers = True

                        # PreProcess if needed
                        if self._shouldPreProcess():
                            PreProcessUtils.removeOutdatedPreProcessedFiles(self._genome, trackName, allowOverlaps, self._mode)

                            if self._shouldPrintProcessMessages() and allowOverlaps not in overlapRulesProcessedForTrackName:
                                self._printProcessTrackMessage(trackName, allowOverlaps)
                                overlapRulesProcessedForTrackName.append(allowOverlaps)

                            self._status = 'Trying to preprocess geSource...'
                            geSourceJob = PreProcessGeSourceJob(trackName, geSourceManager, allowOverlaps, self._mode)
                            anyWarnings = geSourceJob.process()

                            if self._raiseIfAnyWarnings and anyWarnings and trackName not in self._warningTrackNames:
                                self._warningTrackNames.append(trackName)

                            collector.updatePreProcDirtyStatus(geSourceJob.hasModifiedData())

                    # Finalize overlapRule output if needed
                    if anyGeSourceManagers and self._shouldFinalize() and collector.preProcIsDirty():
                        if self._mode == 'Real' and self._shouldMergeChrFolders():
                            self._status = 'Trying to combine chromosome vectors into combined vectors.'
                            PreProcessUtils.createBoundingRegionShelve(self._genome, trackName, allowOverlaps)
                            ChrMemmapFolderMerger.merge(self._genome, trackName, allowOverlaps)

                            self._status = 'Trying to remove chromosome folders'
                            PreProcessUtils.removeChrMemmapFolders(self._genome, trackName, allowOverlaps)

                        self._status = 'Trying to check whether 3D data is correct'
                        PreProcessUtils.checkIfEdgeIdsExist(self._genome, trackName, allowOverlaps)
                        PreProcessUtils.checkUndirectedEdges(self._genome, trackName, allowOverlaps)
                        PreProcessUtils.checkUndirectedEdges(self._genome, trackName, allowOverlaps)
                        collector.markOverlapRuleAsFinalized(allowOverlaps)

                # Finalize track if needed
                if self._shouldFinalize():
                    if collector.preProcIsDirty():
                        self._status = 'Trying to finalize.'
                        collector.finalize(self._username, self._shouldPrintProcessMessages())
                        if not atLeastOneFinalized:
                            atLeastOneFinalized = True
                    else:
                        collector.removeEntry()

            except NotSupportedError, e:
                collector.removeEntry()
                if self.PASS_ON_EXCEPTIONS:
                    raise
                else:
                    self._printExceptionMsg(e, trackName, Error=False)
            except Exception, e:
                collector.removeEntry()
                if self.PASS_ON_EXCEPTIONS:
                    raise
                else:
                    self._printExceptionMsg(e, trackName, Error=True)
예제 #2
0
    def process(self):
        assert self._genome is not None, 'Error: genome must be specified when preprocessing tracks.'

        atLeastOneFinalized = False
        for trackName in self._allTrackNames():
            assert trackName != ['']
            overlapRulesProcessedForTrackName = []
            collector = PreProcMetaDataCollector(self._genome, trackName)

            try:
                trackName = self._renameTrackNameIfIllegal(trackName)

                for allowOverlaps in [True, False]:
                    anyGeSourceManagers = False

                    for geSourceManager in self._allGESourceManagers(
                            trackName, allowOverlaps):
                        anyGeSourceManagers = True

                        # PreProcess if needed
                        if self._shouldPreProcess():
                            PreProcessUtils.removeOutdatedPreProcessedFiles(
                                self._genome, trackName, allowOverlaps,
                                self._mode)

                            if self._shouldPrintProcessMessages(
                            ) and allowOverlaps not in overlapRulesProcessedForTrackName:
                                self._printProcessTrackMessage(
                                    trackName, allowOverlaps)
                                overlapRulesProcessedForTrackName.append(
                                    allowOverlaps)

                            self._status = 'Trying to preprocess geSource...'
                            geSourceJob = PreProcessGeSourceJob(
                                trackName, geSourceManager, allowOverlaps,
                                self._mode)
                            anyWarnings = geSourceJob.process()

                            if self._raiseIfAnyWarnings and anyWarnings and trackName not in self._warningTrackNames:
                                self._warningTrackNames.append(trackName)

                            collector.updatePreProcDirtyStatus(
                                geSourceJob.hasModifiedData())

                    # Finalize overlapRule output if needed
                    if anyGeSourceManagers and self._shouldFinalize(
                    ) and collector.preProcIsDirty():
                        if self._mode == 'Real' and self._shouldMergeChrFolders(
                        ):
                            self._status = 'Trying to combine chromosome vectors into combined vectors.'
                            PreProcessUtils.createBoundingRegionShelve(
                                self._genome, trackName, allowOverlaps)
                            ChrMemmapFolderMerger.merge(
                                self._genome, trackName, allowOverlaps)

                            self._status = 'Trying to remove chromosome folders'
                            PreProcessUtils.removeChrMemmapFolders(
                                self._genome, trackName, allowOverlaps)

                        self._status = 'Trying to check whether 3D data is correct'
                        PreProcessUtils.checkIfEdgeIdsExist(
                            self._genome, trackName, allowOverlaps)
                        PreProcessUtils.checkUndirectedEdges(
                            self._genome, trackName, allowOverlaps)
                        PreProcessUtils.checkUndirectedEdges(
                            self._genome, trackName, allowOverlaps)
                        collector.markOverlapRuleAsFinalized(allowOverlaps)

                # Finalize track if needed
                if self._shouldFinalize():
                    if collector.preProcIsDirty():
                        self._status = 'Trying to finalize.'
                        collector.finalize(self._username,
                                           self._shouldPrintProcessMessages())
                        if not atLeastOneFinalized:
                            atLeastOneFinalized = True
                    else:
                        collector.removeEntry()

            except NotSupportedError, e:
                collector.removeEntry()
                if self.PASS_ON_EXCEPTIONS:
                    raise
                else:
                    self._printExceptionMsg(e, trackName, Error=False)
            except Exception, e:
                collector.removeEntry()
                if self.PASS_ON_EXCEPTIONS:
                    raise
                else:
                    self._printExceptionMsg(e, trackName, Error=True)
 def _assertMerge(self, target, source1, source2):
     self.assertListsOrDicts(target, ChrMemmapFolderMerger.mergeArrays(source1, source2))
 def _assertHeight(self, target, source, delta, val):
     self.assertListsOrDicts(target, ChrMemmapFolderMerger.appendHeight(source, delta, val))
예제 #5
0
 def _assertMerge(self, target, source1, source2):
     self.assertListsOrDicts(
         target, ChrMemmapFolderMerger.mergeArrays(source1, source2))
예제 #6
0
 def _assertHeight(self, target, source, delta, val):
     self.assertListsOrDicts(
         target, ChrMemmapFolderMerger.appendHeight(source, delta, val))