def removeOutdatedPreProcessedFiles(genome, trackName, allowOverlaps, mode): collector = PreProcMetaDataCollector(genome, trackName) if PreProcessUtils.preProcFilesExist(genome, trackName, allowOverlaps) and not \ collector.hasRemovedPreProcFiles(allowOverlaps): dirPath = createDirPath(trackName, genome, allowOverlaps=allowOverlaps) assert dirPath.startswith(Config.PROCESSED_DATA_PATH), \ "Processed data path '%s' does not start with '%s'" % \ (dirPath, Config.PROCESSED_DATA_PATH) if mode == 'Real': print 'Removing outdated preprocessed data: ', dirPath for fn in os.listdir(dirPath): fullFn = os.path.join(dirPath, fn) if os.path.isfile(fullFn): os.unlink(fullFn) if os.path.isdir(fullFn): if PreProcessUtils._isOldTypeChromDirectory(fullFn, genome): shutil.rmtree(fullFn) else: print 'Would now have removed outdated preprocessed data if real run: ', dirPath collector.updateRemovedPreProcFilesFlag(allowOverlaps, True) if mode == 'Real': ti = TrackInfo(genome, trackName) ti.resetTimeOfPreProcessing()