Exemple #1
0
    def root(self, options):
        """Root tree using outgroup.

        Parameters
        ----------
        options : argparse.Namespace
            The CLI arguments input by the user.
        """

        check_file_exists(options.input_tree)

        taxonomy = self._read_taxonomy_files(options)

        self.logger.info(f'Identifying genomes from the specified outgroup: {options.outgroup_taxon}')
        outgroup = set()
        for genome_id, taxa in taxonomy.items():
            if options.outgroup_taxon in taxa:
                outgroup.add(genome_id)

        reroot = RerootTree()
        reroot.root_with_outgroup(options.input_tree,
                                  options.output_tree,
                                  outgroup)

        self.logger.info('Done.')
Exemple #2
0
    def root(self, options):
        """Root tree using outgroup.

        Parameters
        ----------
        options : argparse.Namespace
            The CLI arguments input by the user.
        """
        self.logger.warning("Tree rooting is still under development!")

        check_file_exists(options.input_tree)

        if options.custom_taxonomy_file:
            check_file_exists(options.custom_taxonomy_file)
            taxonomy = Taxonomy().read(options.custom_taxonomy_file)
        else:
            taxonomy = Taxonomy().read(Config.TAXONOMY_FILE)

        self.logger.info('Identifying genomes from the specified outgroup.')
        outgroup = set()
        for genome_id, taxa in taxonomy.items():
            if options.outgroup_taxon in taxa:
                outgroup.add(genome_id)

        reroot = RerootTree()
        reroot.root_with_outgroup(options.input_tree, options.output_tree,
                                  outgroup)

        # Symlink to the tree summary file, if not run independently
        if hasattr(options, 'suffix'):
            if options.suffix == 'bac120':
                symlink_f(
                    PATH_BAC120_ROOTED_TREE.format(prefix=options.prefix),
                    os.path.join(
                        options.out_dir,
                        os.path.basename(
                            PATH_AR122_ROOTED_TREE.format(
                                prefix=options.prefix))))
            elif options.suffix == 'ar122':
                symlink_f(
                    PATH_AR122_ROOTED_TREE.format(prefix=options.prefix),
                    os.path.join(
                        options.out_dir,
                        os.path.basename(
                            PATH_AR122_ROOTED_TREE.format(
                                prefix=options.prefix))))
            else:
                raise GenomeMarkerSetUnknown(
                    'There was an error determining the marker set.')

        self.logger.info('Done.')