Beispiel #1
0
    def cluster_contigs(self):
        default_clustering = constants.blank_default if self.blank else constants.single_default

        for config_name in self.clustering_configs:
            config_path = self.clustering_configs[config_name]

            config = ClusteringConfiguration(
                config_path,
                self.output_directory,
                db_paths=self.database_paths,
                row_ids_of_interest=self.split_names)

            try:
                clustering_id, newick = clustering.order_contigs_simple(
                    config,
                    distance=self.distance,
                    linkage=self.linkage,
                    progress=self.progress)
            except Exception as e:
                self.run.warning('Clustering has failed for "%s": "%s"' %
                                 (config_name, e))
                self.progress.end()
                continue

            dbops.add_hierarchical_clustering_to_db(self.profile_db_path, config_name, newick, distance=self.distance, linkage=self.linkage, \
                                                    make_default=config_name == default_clustering, run=self.run)
Beispiel #2
0
    def cluster_splits_of_interest(self):
        # clustering of contigs is done for each configuration file under static/clusterconfigs/merged directory;
        # at this point we don't care what those recipes really require because we already merged and generated
        # any data that may be required.
        clusterings = {}

        for config_name in self.clustering_configs:
            config_path = self.clustering_configs[config_name]

            config = ClusteringConfiguration(
                config_path,
                self.input_directory,
                db_paths=self.database_paths,
                row_ids_of_interest=self.split_names_of_interest)

            try:
                clustering_id, newick = clustering.order_contigs_simple(
                    config, progress=self.progress)
            except Exception as e:
                self.run.warning('Clustering has failed for "%s": "%s"' %
                                 (config_name, e))
                self.progress.end()
                continue

            clusterings[clustering_id] = {'newick': newick}

        self.run.info('available_clusterings', list(clusterings.keys()))

        return clusterings
Beispiel #3
0
    def cluster_contigs_anvio(self):
        # clustering of contigs is done for each configuration file under static/clusterconfigs/merged directory;
        # at this point we don't care what those recipes really require because we already merged and generated
        # every data file that may be required.

        if not self.skip_hierarchical_clustering:
            for config_name in self.clustering_configs:
                config_path = self.clustering_configs[config_name]

                config = ClusteringConfiguration(
                    config_path,
                    self.output_directory,
                    db_paths=self.database_paths,
                    row_ids_of_interest=self.split_names)

                try:
                    newick = clustering.order_contigs_simple(
                        config, progress=self.progress)
                except Exception as e:
                    self.run.warning('Clustering has failed for "%s": "%s"' %
                                     (config_name, e))
                    self.progress.end()
                    continue

                dbops.add_hierarchical_clustering_to_db(
                    self.profile_db_path,
                    config_name,
                    newick,
                    make_default=config_name == constants.merged_default,
                    run=self.run)
Beispiel #4
0
    def cluster_contigs_anvio(self):
        # clustering of contigs is done for each configuration file under static/clusterconfigs/merged directory;
        # at this point we don't care what those recipes really require because we already merged and generated
        # every data file that may be required.

        self.run.info_single("Anvi'o hierarchical clustering of contigs...", nl_before=1, nl_after=1, mc="blue")

        if not self.skip_hierarchical_clustering:
            for config_name in self.clustering_configs:
                config_path = self.clustering_configs[config_name]

                config = ClusteringConfiguration(config_path, self.output_directory, db_paths=self.database_paths, row_ids_of_interest=self.split_names)

                try:
                    clustering_id, newick = clustering.order_contigs_simple(config, distance=self.distance, linkage=self.linkage, progress=self.progress)
                except Exception as e:
                    self.run.warning('Clustering has failed for "%s": "%s"' % (config_name, e))
                    self.progress.end()
                    continue

                _, distance, linkage = clustering_id.split(':')

                dbops.add_items_order_to_db(anvio_db_path=self.profile_db_path,
                                            order_name=config_name,
                                            order_data=newick,
                                            distance=distance,
                                            linkage=linkage,
                                            make_default=config_name == constants.merged_default,
                                            run=self.run)