当前位置: 首页>>代码示例>>Python>>正文


Python Status.load_backup方法代码示例

本文整理汇总了Python中status.Status.load_backup方法的典型用法代码示例。如果您正苦于以下问题:Python Status.load_backup方法的具体用法?Python Status.load_backup怎么用?Python Status.load_backup使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在status.Status的用法示例。


在下文中一共展示了Status.load_backup方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: from status import Status [as 别名]
# 或者: from status.Status import load_backup [as 别名]
class Train:

    def __init__(self, cfg, default_ans=False, backup=False, logged=False):
        self.workingdir = os.path.dirname(os.path.realpath(sys.argv[0]))

        # some mappings
        self.tree_organism_map = {}     # node --> list of organisms which were mapped to that node
        self.organism_tree_map = {}     # organism --> closest node on the tree
        self.organism_file_map = {}     # organism --> list of files including sequences

        self.organisms = set()      # all organisms available
        self.nodes = []             # selected organisms = nodes on the taxonomic tree

        self.genomes_excluded = []  # genomes that have not been considered during computation
        self.organisms_invalid = set()  # organisms with a lack of mapping // or that have been mapped to the root

        self.sqlite_taxonomy = None     # SQLite database including the NCBI taxonomy
        self.config = cfg  # contains all settings

        # # # # # # # Advanced training options # # # # # # # # # # # # # #
        # learning
        self.loss_function = 1  # 0:0/1 loss, 1:path loss
        self.z_standardization = 1  # 0:no standardization, 1:z standardization
        self.misc_nodes = 1     # 0:no misc nodes, 1:add misc nodes
        self.n_frags_per_node = 0.0     # number of fragments per node

        self.yes = default_ans    # say yes to every question?

        self.tree_file = ""

        self.backup = backup
        self.stat = None
        self.backupdir = None

        if not logged:
            # this will write a file to cwd
            logmethods.initialise('train.log')
        self.log = logging.getLogger('train')   # better root ?

    def from_backup(self, backupdir):
        assert os.path.isdir(backupdir)
        my_log = logging.getLogger('backup')

        if self.backup:
            my_log.warning('The backup will be produced but can not be used for another run.')

        self.stat = Status(logged=True)
        try:
            self.stat.load_backup(backupdir)
        except SystemExit:
            my_log.critical('Could not load backup from:\n{}'.format(backupdir))
            sys.exit(1)

        pipeline_position = self.stat.variables["status"]

        if pipeline_position == 6:
            my_log.critical("Please re-run the pipeline.. "
                             "There is no secure way to find the correct point to start from")
            sys.exit(1)

        # init all variables
        for variable_name in self.stat.variables:
            val = self.stat.variables[variable_name]
            setattr(self, variable_name, val)   # same as self.variable_name = val

        self.sqlite_taxonomy = taxonomy_ncbi.TaxonomyNcbi(self.config.ncbi_tax_db)

        if pipeline_position < 1:
            self.process_ncbi()
        if pipeline_position < 2:
            self.tree_process()
        if pipeline_position < 3:
            self.map_genomes_on_tree()
        if pipeline_position < 4:
            self.generate_seq(done_files=self.stat.files.keys())
        if pipeline_position < 5:
            self.sample_specific(done_files=self.stat.files.keys())
        if pipeline_position < 6:
            self.generate_kmer_features()
        if pipeline_position < 7:
            self.build_models()

    def main_processing(self):
        """
            all steps of the training pipeline
                - processing ncbi sequences
                - tree processing (copying newick tree or building tree from a clade list)
                - mapping genomes on this tree
                - generating fragments from the sequences
                - dealing with sample specific data
                - generating kmer features
                - building models
        """

        if not self.config.settings["only_models"]:
            # if you do not want to build only models, check if the project directory is empty
            if len(os.listdir(self.config.settings["project_dir"])) != 0:
                self.log.warning("The project directory is not empty, this can result in unpredictable behavior.")
                if self.yes:
                    answer = "y"
#.........这里部分代码省略.........
开发者ID:algbioi,项目名称:docker_ppsp,代码行数:103,代码来源:train.py


注:本文中的status.Status.load_backup方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。