Best Python code snippet using avocado_python
main.py
Source:main.py  
...36        self.logger = logging.getLogger('timestamp')37    def blast(self, options):38        """Infer gene tree using BLAST."""39        40        check_file_exists(options.query_proteins)41        check_file_exists(options.db_file)42        check_file_exists(options.taxonomy_file)43        44        # sanity check arguments45        if options.prot_model == 'AUTO' and options.tree_program != 'raxml':46            self.logger.error("The 'AUTO' protein model can only be used with RAxML.")47            sys.exit(-1)48        blast_workflow = BlastWorkflow(options.cpus)49        blast_workflow.run(options.query_proteins,50                           options.db_file,51                           options.custom_db_file,52                           options.taxonomy_file,53                           options.custom_taxonomy_file,54                           options.evalue,55                           options.per_identity,56                           options.per_aln_len,57                           options.max_matches,58                           options.homology_search,59                           options.min_per_taxa,60                           options.consensus,61                           options.min_per_bp,62                           options.use_trimAl,63                           options.restrict_taxon,64                           options.msa_program,65                           options.tree_program,66                           options.prot_model,67                           options.skip_rooting,68                           options.output_dir)69                           70    def concat(self, options):71        """Infer concatenated gene tree."""72        73        make_sure_path_exists(options.output_dir)74        75        c = Concatenate(options.cpus)76        c.run(options.gene_dirs,77                options.min_per_gene,78                options.min_per_bps,79                options.tree_program,80                options.prot_model,81                options.split_chars,82                options.output_dir)83             84    def reduce(self, options):85        """Infer tree for reduced set of genes."""86        87        check_file_exists(options.homolog_file)88        check_file_exists(options.gene_ids)89        check_file_exists(options.taxonomy_file)90        91        make_sure_path_exists(options.output_dir)92        93        r = Reduce(options.cpus)94        r.run(options.homolog_file, 95                options.gene_ids, 96                options.taxonomy_file,97                options.min_per_taxa,98                options.consensus,99                options.min_per_bp,100                options.use_trimAl,101                options.msa_program,102                options.tree_program,103                options.prot_model,104                options.output_dir)105                106    def bootstrap(self, options):107        """Calculate bootstrap support for tree."""108        109        check_file_exists(options.tree)110        111        bootstrap = Bootstrap(options.cpus)112        bootstrap.run(options.tree, 113                    options.msa_file,114                    options.tree_program,115                    options.prot_model,116                    options.num_replicates,117                    options.output_dir)118                    119    def prune(self, options):120        """Prune tree."""121        122        check_file_exists(options.tree)123        check_file_exists(options.taxa_to_retain)124        125        prune = Prune()126        prune.run(options.tree,127                    options.taxa_to_retain,128                    options.output_tree)129    130    def prokka(self, options):131        """Run Prokka across multiple genome bins."""132        133        prokka = Prokka(options.cpus)134        prokka.run(options.genome_dir, 135                    options.kingdom, 136                    options.extension, 137                    options.output_dir)138                    139    def create_db(self, options):      140        """Create dereplicated GeneTreeTk-compatible database."""141        142        create_db = CreateDatabase(options.cpus)143        create_db.run(options.taxonomy,144                         options.type_strains,145                         options.genome_prot_dir,146                         options.extension,147                         options.max_taxa,148                         options.rank,149                         options.per_identity,150                         options.per_aln_len,151                         options.genomes_to_process,152                         options.keep_all_genes,153                         options.no_reformat_gene_ids,154                         options.output_dir)155    def create_arb_db(self, options):156        ArbDbCreator().create_from_protein_alignment(157            alignment_file=options.alignment_file,158            taxonomy_file=options.taxonomy_file,159            output_file=options.output_file)160                         161    def robinson_foulds(self, options):162        """Compare unrooted trees using common statistics."""163        164        check_file_exists(options.tree1)165        check_file_exists(options.tree2)166        167        tc = TreeCompare()168        if options.weighted:169            wrf = tc.weighted_robinson_foulds(options.tree1, 170                                                options.tree2,171                                                options.taxa_list)172            print(('Weighted Robinson-Foulds: %.3f' % wrf))173        else:174            rf, normalized_rf = tc.robinson_foulds(options.tree1, 175                                                    options.tree2,176                                                    options.taxa_list)177            print(('Robinson-Foulds: %d' % rf))178            print(('Normalized Robinson-Foulds: %.3f' % normalized_rf))179                         180    def supported_splits(self, options):181        """Supported bipartitions of common taxa shared between two trees."""182        183        check_file_exists(options.tree1)184        check_file_exists(options.tree2)185        186        tc = TreeCompare()187        tc.supported_splits(options.tree1, 188                            options.tree2,189                            options.split_file,190                            options.min_support,191                            options.max_depth,192                            options.taxa_list)193        194    def missing_splits(self, options):195        """Report supported bipartitions in reference tree not in comparison tree."""196        197        check_file_exists(options.ref_tree)198        check_file_exists(options.compare_tree)199        200        tc = TreeCompare()201        tc.report_missing_splits(options.ref_tree, 202                                    options.compare_tree,203                                    options.min_support,204                                    options.taxa_list)205                                    206    def midpoint(self, options):207        """"Midpoint root tree."""208        209        check_file_exists(options.in_tree)210        211        tree = dendropy.Tree.get_from_path(options.in_tree, 212                                            schema='newick', rooting='force-rooted', 213                                            preserve_underscores=True)214        tree.reroot_at_midpoint()215        216        tree.write_to_path(options.out_tree, 217                            schema='newick', 218                            suppress_rooting=True, 219                            unquoted_underscores=True)220    def orthologue(self, options):221        """Infer gene tree using BLAST after Orthologue clustering."""222        223        check_file_exists(options.query_proteins)224        check_file_exists(options.db_file)225        check_file_exists(options.taxonomy_file)226        # sanity check arguments227        if options.prot_model == 'AUTO' and options.tree_program != 'raxml':228            self.logger.error("The 'AUTO' protein model can only be used with RAxML.")229            sys.exit(-1)230        workflow = OrthologueWorkflow(options.cpus)231        workflow.run(232            query_proteins=options.query_proteins,233            db_file=options.db_file,234            #custom_db_file=options.custom_db_file,235            taxonomy_file=options.taxonomy_file,236            #custom_taxonomy_file=options.custom_taxonomy_file,237            evalue=options.evalue,238            per_identity=options.per_identity,239            per_aln_len=options.per_aln_len,...test_fileOps.py
Source:test_fileOps.py  
...11    @patch('file_check.FileOps.create_file', return_value=False)12    def test_create_file_dir_fail(self, create_file, check_dir_exists, check_file_exists):13        self.assertEqual(create_file(), False)14        self.assertEqual(check_dir_exists(), True)15        self.assertEqual(check_file_exists(), True)16    @patch('file_check.FileOps.check_file_exists', return_value=True)17    @patch('file_check.FileOps.check_dir_exists', return_value=False)18    @patch('file_check.FileOps.create_file', return_value=True)19    def test_create_file_dir_fail_2(self, create_file, check_dir_exists, check_file_exists):20        self.fops.create_file()21        self.fops.check_dir_exists()22        self.fops.check_file_exists()23        assert create_file.called24        check_dir_exists.assert_called_with()...Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!
