Galaxy数据库
发布时间:2022-10-04 11:31:31 所属栏目:Unix 来源:
导读: 当用户执行分析时,与数据集相关联的每一个条目将会添加到历史记录中。 这些条目称为HistoryDatasetAssociation对象。 与数据集有关的信息存储在 Galaxy 数据库的Dataset表中,而数据本身则存储在磁盘上。 Galax
|
当用户执行分析时,与数据集相关联的每一个条目将会添加到历史记录中。 这些条目称为HistoryDatasetAssociation对象。 与数据集有关的信息存储在 Galaxy 数据库的Dataset表中,而数据本身则存储在磁盘上。 Galaxy 配置文件中包含了一个file_path的属性,该属性指向存储数据集的磁盘的位置。 在其他列(字段)中,Dataset表包括以下内容: | id | update_time | deleted | purged | file_size | 在其他的列字段中,HistoryDatasetAssociation表包含了以下内容: | id | update_time | history_id | deleted | dataset_id | 每条HistoryDatasetAssociation记录都通过HistoryDatasetAssociation.history_id和HistoryDatasetAssociation.dataset_id列中的值将数据集 (Dataset) 与历史记录相关联。 任意多个的HistoryDatasetAssociation记录都可以指向一个基础的Dataset数据集 —— 这就是复制 histories,历史条目和 libraries 库的工作方式,这些都无需复制实际的文件内容。 在其他的列字段中,LibraryDatasetDatasetAssociation表包含了以下内容: | id | update_time | library_dataset_id | deleted | dataset_id | 每一条的LibraryDatasetDatasetAssociation记录都通过LibraryDatasetDatasetAssociation.library_dataset_id和LibraryDatasetDatasetAssociation.dataset_id列中的值将Dataset数据集与可版本化的库数据集记录相关联。 任意数量的LibraryDatasetDatasetAssociation记录都可以指向一个基础的Dataset数据集。 2 清除不需要的历史,库和数据集 只有在所有HistoryDatasetAssociations和LibraryDatasetDatasetAssociations都标记为已删除时,一个数据集才能真正被删除(或清除)。 Galaxy 发行版中包含 6 个脚本可用于清除不需要的历史记录,库和数据集。 这些脚本位于GALAXY_ROOT/scripts/cleanup_datasets目录中并命名为: 请注意,我们应该在运行脚本之前激活 Galaxy 虚拟环境,如下所示。 source /path/to/galaxy/root/.venv/bin/activate sh delete_userless_histories.sh sh purge_histories.sh 这些脚本都在同一目录中执行一个名为cleanup_datasets.py的 Python 脚本,在命令行上发送不同的参数值。 如果需要,可以忽略这些脚本,并且可以手动执行cleanup_datasets.py脚本(使用 GALAXY_ROOT 作为工作目录),传入所需的参数值。 但是,我们也可以在cron中轻松配置这些脚本以自动执行。 脚本执行的顺序将影响结果; 为获得最佳效果,建议的运行顺序为: delete_userless_histories.sh purge_histories.sh purge_libraries.sh purge_folders.sh purge_datasets.sh 如果希望在删除外部容器(历史记录,库/库文件夹)之前删除数据集,则可以在purge_datasets.sh脚本之前使用delete_datasets.sh脚本。 此脚本可能需要一些时间才能完成。 Available Flags 以下是有关cleanup_datasets.py脚本可以执行的每个函数的更多详细信息。 Deleting Userless Histories 如上所述,使用 Galaxy 默认是不需要登录的,并且在许多情况下,用户执行分析而无需登录以“一次性”方式查看结果,而不关心保留分析以供以后查看。 在这种情况下,创建的历史记录没有关联的用户 ID。cleanup_dataset.py脚本可用于删除在指定时间段内未更改的这些类型的历史记录。 删除无用户历史记录的命令如下: python cleanup_datasets.py config/galaxy.ini -d 60 -1 请注意,传递给脚本的第一个参数是 Galaxy 的配置文件。这是脚本获取有关数据库连接和磁盘上数据文件位置的信息所必需的。-d标志后面的值是从最后一次更新历史记录以来经过的天数(即,在此示例中,History.update_time列中的值超过 60 天)。根据此条件,将检索所有不包含user_id列中的值且其update_time列值超过 60 天的历史记录。-1标志告诉cleanup_datasets.py脚本执行名为delete_userless_histories()的方法,该方法包含在脚本中。此方法通过将History.delete列的值设置为True来删除update_time值早于指定天数的无用户历史记录。执行相同的命令,但提供-i标志不会写入任何更改;本程序执行后将提供有关要删除的历史记录的 info 信息。 Purging Deleted Histories 在历史记录的生命周期中,“已删除”阶段之后的阶段是“已清除”阶段,即历史记录生命周期的最后一个阶段。 清除历史记录时,将清除与历史记录关联的所有HistoryDatasetAssociation记录。 清除HistoryDatasetAssociation时,会将其标记为已删除。 另外,只有当同时清除了与该数据集的所有关联时,HDA 关联的数据集才会被标记为已删除(HDA 和 LDDA 都标记为已删除);当发生这种情况时,用户不再能够取消使用 HDA 和 LDDA —— 如果使用 “-r”,则会从磁盘中删除关联的文件和元数据文件(主数据集文件仍保留在磁盘上,并且可由管理员检索)。 清除历史记录和相关 HDA 的命令如下: python cleanup_datasets.py config/galaxy.ini -d 60 -2 -r 在此示例中,-2标志告诉cleanup_dataset.py脚本执行脚本中包含的purge_histories()的方法。此方法检索History.deleted列值为True,History.purged列值为False且其History.update_time列值早于指定天数(在此示例中为 60 )的所有History记录。通过将HistoryDatasetAssociation.deleted列值设置为True,也可以清除与历史记录关联的所有HistoryDatasetAssociation记录;轮询任何其他DatasetAssociations(HDA / LDDA),如果它们都具有HistoryDatasetAssociation.deleted==True,则Dataset.deleted列将被设置为True。此示例中的-r标志告诉cleanup_dataset.py脚本从磁盘中删除与HistoryDatasetAssociation记录关联的文件(元数据等)(仅当Dataset.deleted设置为True时)。执行相同的命令但用-i替换-r标志将打印出所有历史记录和关联的HistoryDatasetAssociation记录unix数据库,如果使用-r标志将清除这些记录。 Purging Deleted Datasets 当与数据集关联的所有历史记录和库记录都已经如上面所述,被删除了的时候,数据集记录将进入“已删除”阶段。 删除数据集记录生命周期的下一个阶段是“清除”阶段,即数据集记录生命周期的最后一个阶段。 清除数据集的命令类似于: python cleanup_datasets.py config/galaxy.ini -d 60 -3 -r 在此示例中,-3标志告诉cleanup_dataset.py脚本执行脚本中包含的purge_datasets()方法。 此方法检索Dataset.deleted列值为True,Dataset.purged为False且其Dataset.update_time列的值早于指定天数(本示例中为 60 )的所有Dataset记录。 通过将Dataset.purged列设置为True来清除数据集记录。 如上所述,此示例中的-r标志告诉cleanup_dataset.py脚本从磁盘中删除与数据集记录关联的数据文件。 执行相同的命令但用-i替换-r标志将打印出在使用-r标志时将被清除的所有数据集记录。 Purging Library Folders Besides existing in user’s history, dataset association objects exist with inLibrary Folders; they are known asLibraryDatasetDatasetAssociations(LDDAs). Purging a library folder is similar to purging a History. An example command is: python cleanup_datasets.py config/galaxy.ini -d 60 -5 -r In this example, the -5 flag tells thecleanup_dataset。pyscript to execute thepurge_folders()method included in the script。 This method retrieves allLibraryFolderrecords whoseLibraryFolder。deletedcolumn value isTrue,LibraryFolder。purgedcolumn value isFalseand whoseLibraryFolder。update_timecolumn value is older than the specified number of days ( 60 in this example )。 It works recursively on all subfolders and their contents。 AllLibraryDatasetDatasetAssociationsrecords associated with theLibraryFolderrecord are also purged by setting theLibraryDatasetDatasetAssociation。 deletedcolumn value toTrue; any additionalDatasetAssociations(HDA/LDDA) are polled and if they all haveHistoryDatasetAssociation(LibraryDatasetDatasetAssociation)。deleted==True, theDataset。deletedcolumn is set toTrue。 The-rflag in this example tells thecleanup_dataset。pyscript to remove the files (metadata etc) associated with theLibraryDatasetDatasetAssociationrecord (but not the actual Dataset file) from disk (only ifDataset。deletedis to be set toTrue)。 Executing the same command but replacing the -r flag with -i will print out all of theLibraryFoldersand associatedLibraryDatasetDatasetAssociationrecords that will be purged if the -r flag is used。 As is the case withHistories, thepurge_datasetsscript will need to be used to remove actualDatasetsfrom disk. Purging Libraries Purging a library is similar to purging aLibraryFolder. All libraries which are not purged, but are deleted and exceed the modified date are retrieved. The library is marked as purged andpurge_folderis called on the library’s root folder, deleting all contents. An example command is: python cleanup_datasets.py config/galaxy.ini -d 60 -4 -r In this example, the -4 flag tells thecleanup_dataset。pyscript to execute thepurge_libraries()method included in the script。 This method retrieves allLibraryrecords whoseLibrary。deletedcolumn value is True,Library。purgedcolumn value is False and whoseLibraryFolder。update_timecolumn value is older than the specified number of days ( 60 in this example )。 The Library’s Root Folder is then obtained and allLibraryDatasetDatasetAssociationsrecords associated with theLibraryFolderrecord are also purged by setting theLibraryDatasetDatasetAssociation。 deletedcolumn value to True; any additionalDatasetAssociations(HDA/LDDA) are polled and if they all haveHistoryDatasetAssociation(LibraryDatasetDatasetAssociation)。deleted==True, theDataset。deletedcolumn is set to True。 The -r flag in this example tells thecleanup_dataset。pyscript to remove the files (metadata etc) associated with theLibraryDatasetDatasetAssociationrecord (but not the actual Dataset file) from disk (only ifDataset。deletedis to be set to True)。 Executing the same command but replacing the -r flag with -i will print out all of the Libraries,LibraryFoldersand associatedLibraryDatasetDatasetAssociationrecords that will be purged if the -r flag is used。 Deleting Datasets / Purging Dataset Instances 有时,在清除数据集实例并将基础数据集标记为已删除之前,不希望等待包含的历史记录或库/库文件夹被删除。-6标志用于此目的。 此脚本将查找未删除但与DatasetAssociation相关联的所有数据集记录,该DatasetAssociation被标记为已删除并根据指定的截止值进行更新。 如果所有关联都标记为已删除,则Dataset将标记为已删除,并清除每个DatasetAssociation。 之后需要运行purge_datasets.sh脚本以从磁盘中删除基础数据集。 An example command is: python cleanup_datasets.py config/galaxy.ini -d 60 -6 -r 更多关于 Galaxy (release_18.05) 的数据集对象清理与实际操作,可以点击文章左下角 "阅读原文" 登陆博客查看。 ·end· —如果喜欢,快分享给你的朋友们吧— 我们一起愉快的玩耍吧 (编辑:我爱资讯网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
推荐文章
站长推荐
