def identify(self, options): """Identify marker genes in genomes. Parameters ---------- options : argparse.Namespace The CLI arguments input by the user. """ if options.genome_dir: assert_dir_exists(options.genome_dir) if options.batchfile: assert_file_exists(options.batchfile) make_sure_path_exists(options.out_dir) genomes = self._genomes_to_process(options.genome_dir, options.batchfile, options.extension) markers = Markers(options.cpus) markers.identify(genomes, options.out_dir, options.prefix, options.force, options.genes) self.logger.info('Done.')
def infer(self, options): """Infer a tree from a user specified MSA. Parameters ---------- options : argparse.Namespace The CLI arguments input by the user. """ assert_file_exists(options.msa_file) make_sure_path_exists(options.out_dir) if options.cpus > 1: check_dependencies(['FastTreeMP']) os.environ['OMP_NUM_THREADS'] = '%d' % options.cpus else: check_dependencies(['FastTree']) if hasattr(options, 'suffix'): output_tree = os.path.join( options.out_dir, PATH_MARKER_UNROOTED_TREE.format(prefix=options.prefix, marker=options.suffix)) tree_log = os.path.join( options.out_dir, PATH_MARKER_TREE_LOG.format(prefix=options.prefix, marker=options.suffix)) fasttree_log = os.path.join( options.out_dir, PATH_MARKER_FASTTREE_LOG.format(prefix=options.prefix, marker=options.suffix)) else: output_tree = os.path.join( options.out_dir, PATH_UNROOTED_TREE.format(prefix=options.prefix)) tree_log = os.path.join( options.out_dir, PATH_TREE_LOG.format(prefix=options.prefix)) fasttree_log = os.path.join( options.out_dir, PATH_FASTTREE_LOG.format(prefix=options.prefix)) fasttree = FastTree() fasttree.run(output_tree, tree_log, fasttree_log, options.prot_model, options.no_support, options.no_gamma, options.msa_file, options.cpus) if hasattr(options, 'subparser_name') and options.subparser_name == 'infer': symlink_f( output_tree[len(options.out_dir) + 1:], os.path.join(options.out_dir, os.path.basename(output_tree))) self.logger.info('Done.')
def decorate(self, options): """Decorate tree with GTDB taxonomy. Parameters ---------- options : argparse.Namespace The CLI arguments input by the user. """ assert_file_exists(options.input_tree) # Config.TAXONOMY_FILE self.logger.warning('DECORATE NOT YET IMPLEMENTED!') self.logger.info('Done.')
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!") assert_file_exists(options.input_tree) if options.custom_taxonomy_file: assert_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.iteritems(): 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.')