Exemple #1
0
    def test_run_tableexport_compounds(self):
        with redirected_stdout() as f:
            main(args=['--model', self._model_dir, 'tableexport', 'compounds'])

        self.assertEqual(
            f.getvalue(), '\n'.join(
                ['id\tin_model', 'A_\u2206\tTrue', 'B\tTrue', 'C\tTrue', '']))
Exemple #2
0
 def test_solver_command_main(self):
     with self.assertRaises(generic.RequirementsError):
         main(MockSolverCommand,
              args=[
                  '--model', self._model_dir, '--solver',
                  'name=not-an-actual-solver'
              ])
Exemple #3
0
    def test_run_tableexport_compounds(self):
        with redirected_stdout() as f:
            main(args=[
                '--model', self._model_dir, 'tableexport', 'compounds'])

        self.assertEqual(f.getvalue(), '\n'.join([
            'id', 'A_\u2206', 'B', 'C', ''
        ]))
Exemple #4
0
    def test_run_tableexport_limits(self):
        with redirected_stdout() as f:
            main(args=['--model', self._model_dir, 'tableexport', 'limits'])

        self.assertEqual(
            f.getvalue(), '\n'.join([
                'Reaction ID\tLower Limits\tUpper Limits',
                'rxn_2_\u03c0\tNone\t100', ''
            ]))
Exemple #5
0
    def test_run_tableexport_metadata(self):
        with redirected_stdout() as f:
            main(args=['--model', self._model_dir, 'tableexport', 'metadata'])

        self.assertEqual(
            f.getvalue(), '\n'.join([
                'Model Name: Test model', 'Biomass Reaction: rxn_1',
                'Default Flux Limits: 1000', ''
            ]))
Exemple #6
0
    def run_solver_command(self, args, requirements):
        with redirected_stdout() as f:
            if self.is_solver_available(**requirements):
                main(args=args)
            else:
                with self.assertRaises(generic.RequirementsError):
                    main(args=args)

        return f
Exemple #7
0
    def run_solver_command(self, args, requirements):
        with redirected_stdout() as f:
            if self.is_solver_available(**requirements):
                main(args=args)
            else:
                with self.assertRaises(generic.RequirementsError):
                    main(args=args)

        return f
Exemple #8
0
    def test_run_tableexport_medium(self):
        with redirected_stdout() as f:
            main(args=['--model', self._model_dir, 'tableexport', 'medium'])

        self.assertEqual(
            f.getvalue(), '\n'.join([
                'Compound ID\tReaction ID\tLower Limit\tUpper Limit',
                'A_\u2206[e]\tNone\t-1000\t1000', 'C[e]\tNone\t-1000\t1000', ''
            ]))
Exemple #9
0
    def test_run_tableexport_reactions(self):
        with redirected_stdout() as f:
            main(args=['--model', self._model_dir, 'tableexport', 'reactions'])

        self.assertEqual(
            f.getvalue(), '\n'.join([
                'id\tequation\tgenes',
                "rxn_1\t|A[e]| => |B[c]|\t['gene_1', 'gene_2']",
                'rxn_2\t|B[c]| => |C[e]|\tgene_3 or (gene_4 and gene_5)', ''
            ]))
Exemple #10
0
    def test_run_tableexport_limits(self):
        with redirected_stdout() as f:
            main(args=[
                '--model', self._model_dir, 'tableexport', 'limits'])

        self.assertEqual(f.getvalue(), '\n'.join([
            'Reaction ID\tLower Limits\tUpper Limits',
            'rxn_2_\u03c0\tNone\t100',
            ''
        ]))
Exemple #11
0
    def test_run_tableexport_metadata(self):
        with redirected_stdout() as f:
            main(args=[
                '--model', self._model_dir, 'tableexport', 'metadata'])

        self.assertEqual(f.getvalue(), '\n'.join([
            'Model Name: Test model',
            'Biomass Reaction: rxn_1',
            'Default Flux Limits: 1000',
            ''
        ]))
Exemple #12
0
    def test_run_tableexport_medium(self):
        with redirected_stdout() as f:
            main(args=[
                '--model', self._model_dir, 'tableexport', 'medium'])

        self.assertEqual(f.getvalue(), '\n'.join([
            'Compound ID\tReaction ID\tLower Limit\tUpper Limit',
            'A_\u2206[e]\tNone\t-1000\t1000',
            'C[e]\tNone\t-1000\t1000',
            ''
        ]))
Exemple #13
0
    def test_run_tableexport_reactions(self):
        with redirected_stdout() as f:
            main(args=[
                '--model', self._model_dir, 'tableexport', 'reactions'])

        self.assertEqual(f.getvalue(), '\n'.join([
            'id\tequation\tgenes',
            "rxn_1\t|A_\u2206[e]| => |B[c]|\t['gene_1', 'gene_2']",
            'rxn_2_\u03c0\t|B[c]| => |C[e]|\tgene_3 or (gene_4 and gene_5)',
            ''
        ]))
Exemple #14
0
    def test_run_tableexport_reactions(self):
        with redirected_stdout() as f:
            main(args=['--model', self._model_dir, 'tableexport', 'reactions'])

        self.assertEqual(
            f.getvalue(),
            '\n'.join('\t'.join(row) for row in
                      [['id', 'equation', 'genes', 'in_model'],
                       [
                           'rxn_1', '|A_\u2206[e]| => |B[c]|',
                           "['gene_1', 'gene_2']", 'True'
                       ],
                       [
                           'rxn_2_\u03c0', '|B[c]| => |C[e]|',
                           'gene_3 or (gene_4 and gene_5)', 'True'
                       ], ['rxn_3', '|D[c]| => |E[c]|', 'None', 'True'], []]))
Exemple #15
0
 def test_run_search_reaction(self):
     with redirected_stdout():
         main(args=[
             '--model', self._model_dir, 'search', 'reaction',
             '--id', 'rxn_1'])
Exemple #16
0
 def test_run_search_compound(self):
     with redirected_stdout():
         main(args=[
             '--model', self._model_dir, 'search', 'compound', '--id', 'A'])
Exemple #17
0
 def test_run_sbmlexport(self):
     with redirected_stdout(BytesIO()):
         main(args=['--model', self._model_dir, 'sbmlexport'])
Exemple #18
0
 def test_run_formulacheck(self):
     with redirected_stdout():
         main(args=['--model', self._model_dir, 'formulacheck'])
Exemple #19
0
 def test_run_search_reaction(self):
     with redirected_stdout():
         main(args=[
             '--model', self._model_dir, 'search', 'reaction', '--id',
             'rxn_1'
         ])
Exemple #20
0
 def test_run_chargecheck(self):
     with redirected_stdout():
         main(args=['--model', self._model_dir, 'chargecheck'])
Exemple #21
0
 def test_solver_command_main(self):
     with self.assertRaises(generic.RequirementsError):
         main(MockSolverCommand, args=[
             '--model', self._model_dir,
             '--solver', 'name=not-an-actual-solver'])
Exemple #22
0
 def test_command_main(self):
     main(MockCommand, args=['--model', self._model_dir, '--test-argument'])
     self.assertTrue(MockCommand.run_called)
     self.assertTrue(MockCommand.init_parser_called)
     self.assertTrue(MockCommand.has_native_model)
Exemple #23
0
    def test_run_excelexport(self):
        dest_path = os.path.join(self._model_dir, 'model.xlsx')
        with redirected_stdout():
            main(args=['--model', self._model_dir, 'excelexport', dest_path])

        self.assertTrue(os.path.isfile(dest_path))
Exemple #24
0
 def test_run_formulacheck(self):
     with redirected_stdout():
         main(args=['--model', self._model_dir, 'formulacheck'])
Exemple #25
0
 def test_run_sbmlexport(self):
     with redirected_stdout(BytesIO()):
         main(args=['--model', self._model_dir, 'sbmlexport'])
Exemple #26
0
 def test_invoke_version(self):
     with redirected_stdout():
         with self.assertRaises(SystemExit) as context:
             main(args=['--version'])
         self.assertEqual(context.exception.code, 0)
Exemple #27
0
 def test_invoke_version(self):
     with redirected_stdout():
         with self.assertRaises(SystemExit) as context:
             main(args=['--version'])
         self.assertEqual(context.exception.code, 0)
Exemple #28
0
 def test_run_chargecheck(self):
     with redirected_stdout():
         main(args=['--model', self._model_dir, 'chargecheck'])
Exemple #29
0
    def test_run_excelexport(self):
        dest_path = os.path.join(self._model_dir, 'model.xlsx')
        with redirected_stdout():
            main(args=['--model', self._model_dir, 'excelexport', dest_path])

        self.assertTrue(os.path.isfile(dest_path))
Exemple #30
0
 def test_command_main(self):
     main(MockCommand, args=[
         '--model', self._model_dir, '--test-argument'])
     self.assertTrue(MockCommand.run_called)
     self.assertTrue(MockCommand.init_parser_called)
     self.assertTrue(MockCommand.has_native_model)
Exemple #31
0
 def test_run_search_compound(self):
     with redirected_stdout():
         main(args=[
             '--model', self._model_dir, 'search', 'compound', '--id', 'A'
         ])
Exemple #32
0
 def test_metabolic_command_main(self):
     main(MockMetabolicCommand, args=[
         '--model', self._model_dir])
     self.assertTrue(MockMetabolicCommand.has_metabolic_model)
Exemple #33
0
 def test_metabolic_command_main(self):
     main(MockMetabolicCommand, args=['--model', self._model_dir])
     self.assertTrue(MockMetabolicCommand.has_metabolic_model)