예제 #1
0
    def __init__(self,
                 args,
                 run=terminal.Run(),
                 progress=terminal.Progress(),
                 skip_sanity_check=False):
        """Parses arguments and run sanity_check"""

        self.args = args
        self.run = run
        self.progress = progress

        # Parse arguments
        A = lambda x: args.__dict__[x] if x in args.__dict__ else None
        self.annotation_source = A('annotation_source')
        self.window_range = A('ngram_window_range') or "2:3"
        self.in_in_unknowns_mode = A('analyze_unknown_functions')
        self.output_file = A('output_file')
        self.genomes = genomedescriptions.GenomeDescriptions(self.args)
        self.genomes.load_genomes_descriptions(init=False)

        # This houses the ngrams' data
        self.ngram_attributes_list = []

        self.num_contigs_in_external_genomes_with_genes = 0

        if not skip_sanity_check:
            self.sanity_check()

        # unless we are in debug mode, let's keep things quiet.
        if anvio.DEBUG:
            self.run_object = terminal.Run()
        else:
            self.run_object = terminal.Run(verbose=False)
예제 #2
0
    def init_genome_descriptions(self):
        self.progress.new('Genome descriptions')
        self.progress.update('Initializing')

        self.descriptions = genomedescriptions.GenomeDescriptions(self.args)

        if len(self.descriptions.external_genomes_dict):
            raise ConfigError("Anvi'o doesn't know how you did it, but you managed to inherit this class with an\
                               `args` object that describes external genomes. Unfortunately anvi'o metapangneomic\
                               workflow only works with internal genomes since it is all about making sense of\
                               pangenomes in the context of metageomes. So this is not really working for us :(")

        if len(set([g['profile_db_path'] for g in list(self.descriptions.internal_genomes_dict.values())])) > 1:
            raise ConfigError("There are multiple profile databases in your internal genomes file. We are simply\
                               not ready to deal with this complexity. If you think this is a mistake, let us know\
                               and we will work with you to make anvi'o work with multiple profile databases (in\
                               fact anvi'o is able to make sense of internal genomes across multiple profile\
                               databases, but we haven't tested it to understand potential caveats associated\
                               with that level of complexity).")

        if len(set([g['collection_id'] for g in list(self.descriptions.internal_genomes_dict.values())])) > 1:
            raise ConfigError("For the sake of simplicity, we expect collection names to be identical in a given\
                               internal genomes file. Anvi'o is kind of a paranoid, and it apologizes for it.")

        self.descriptions.load_genomes_descriptions(skip_functions=True)

        self.progress.end()

        self.run.info("Internal genomes found", "%d (%s)" % (len(self.descriptions.internal_genome_names), ', '.join(self.descriptions.internal_genome_names)))