Ejemplo n.º 1
0
 def run_network(self, args):
     self._check_network(args)
     network_analyser = NetworkAnalyser()
     network_analyser.network_pipeline(
         args.subparser_name, args.matrix, args.genome_metadata,
         args.tpm_values, args.tpm_metadata, args.abundance,
         args.abundance_metadata, args.metabolome, args.enrichment_output,
         args.depth, args.filter, args.limit, args.queries, args.output)
Ejemplo n.º 2
0
    def test_hello_query(self):
        '''
        Testing normal explore workflow, no abundance or transcriptome or metabolome data included
        '''

        tmp = tempfile.mkdtemp()

        network_analyser = NetworkAnalyser()
        network_analyser.network_pipeline(
            NetworkAnalyser.EXPLORE,
            self.genome_annotations_path,
            self.genome_metadata_path,
            None,
            None,  # No transcriptome data
            None,
            None,  # No metagenome data
            None,  # No metabolome data
            None,  # No fisher results
            1,  # No depth (explore runs only)
            list(),  # Dont filter anything out
            list(),  # Filter to keep it small.
            self.queries_file_path,  # No queries
            tmp  # Output directory
        )

        expected_files = sorted(os.listdir(tmp))
        observed_files = sorted(os.listdir(self.expected_explore_output_path))

        self.assertEqual(len(expected_files), len(observed_files))

        for expected_file, observed_file in zip(expected_files,
                                                observed_files):
            expected_file_path = os.path.join(tmp, expected_file)
            observed_file_path = os.path.join(
                self.expected_explore_output_path, observed_file)
            # Are all files present?
            self.assertEqual(expected_file, observed_file)

            # Do the all look the same on the inside?
            with open(expected_file_path) as expected_file_io:

                with open(observed_file_path) as observed_file_io:
                    expected_lines = sorted(expected_file_io.readlines())
                    observed_lines = sorted(observed_file_io.readlines())
                    self.assertEqual(len(expected_lines), len(observed_lines))

                    for expected_line, observed_line in zip(
                            expected_lines, observed_lines):
                        self.assertEqual(expected_line, observed_line)
Ejemplo n.º 3
0
    def run_enrichm(self, args, command):
        '''
        Parameters
        ----------

        Output
        ------
        '''
        self._check_general(args)
        self._logging_setup(args)

        logging.info("Command: %s" % ' '.join(command))
        logging.info("Running the %s pipeline" % args.subparser_name)

        if args.subparser_name == self.DATA:
            d = Data()
            d.do(args.uninstall, args.dry)

        if args.subparser_name == self.ANNOTATE:
            self._check_annotate(args)
            annotate = Annotate(# Define inputs and outputs
                                args.output,
                                # Define type of annotation to be carried out
                                args.ko, args.ko_hmm, args.pfam, args.tigrfam,
                                args.clusters, args.orthologs, args.cazy,
                                args.ec,
                                # Cutoffs
                                args.evalue, args.bit, args.id, args.aln_query,
                                args.aln_reference, args.c, args.cut_ga, 
                                args.cut_nc, args.cut_tc, args.cut_ko,
                                args.inflation, args.chunk_number, args.chunk_max,
                                args.count_domains,
                                # Parameters
                                args.threads, args.parallel, args.suffix, args.light)

            annotate.annotate_pipeline(args.genome_directory,
                                       args.protein_directory,
                                       args.genome_files,
                                       args.protein_files)

        elif args.subparser_name == self.CLASSIFY:
            self._check_classify(args)
            classify = Classify()
            classify.classify_pipeline(args.custom_modules, args.cutoff, args.aggregate,
                                       args.genome_and_annotation_matrix, args.output)

        elif args.subparser_name == self.ENRICHMENT:
            self._check_enrichment(args)
            enrichment = Enrichment()
            enrichment.enrichment_pipeline(# Input options
                                           args.annotate_output, args.annotation_matrix,
                                           args.metadata, args.abundance, args.abundance_metadata,
                                           args.transcriptome, args.transcriptome_metadata,
                                           # Runtime options
                                           args.pval_cutoff, args.proportions_cutoff, 
                                           args.threshold, args.multi_test_correction, 
                                           args.batchfile, args.processes, 
                                           args.allow_negative_values, args.ko, args.pfam, 
                                           args.tigrfam, args.cluster, args.ortholog, args.cazy,
                                           args.ec, args.ko_hmm,
                                           # Outputs
                                           args.output)

        elif(args.subparser_name == NetworkAnalyser.PATHWAY or
             args.subparser_name == NetworkAnalyser.EXPLORE):
            self._check_network(args)
            network_analyser=NetworkAnalyser()
            network_analyser.network_pipeline(args.subparser_name, args.matrix, 
                                              args.genome_metadata, args.tpm_values,
                                              args.tpm_metadata, args.abundance, 
                                              args.abundance_metadata, args.metabolome,
                                              args.enrichment_output, args.depth, args.filter,
                                              args.limit, args.queries, args.output)

        if args.subparser_name == self.PREDICT:
            self._check_predict(args)
            predict = Predict()
            predict.predict_pipeline(args.forester_model_directory,
                 args.input_matrix,
                 args.output)

        elif args.subparser_name == self.GENERATE:
            self._check_generate(args)
            generate_model = GenerateModel()
            generate_model.generate_pipeline(args.input_matrix,
                  args.groups,
                  args.model_type,
                  args.testing_portion,
                  args.grid_search,
                  args.threads,
                  args.output)

        elif args.subparser_name == self.USES:
            self._check_uses(args)
            uses = Uses()
            uses.uses_pipeline(args.compounds_list,
                    args.annotation_matrix,
                    args.metadata,
                    args.output,
                    args.count)

        logging.info('Finished running EnrichM')