Example #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', '']))
Example #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'
              ])
Example #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', ''
        ]))
Example #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', ''
            ]))
Example #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', ''
            ]))
Example #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
Example #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
Example #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', ''
            ]))
Example #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)', ''
            ]))
Example #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',
            ''
        ]))
Example #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',
            ''
        ]))
Example #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',
            ''
        ]))
Example #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)',
            ''
        ]))
Example #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'], []]))
Example #15
0
 def test_run_search_reaction(self):
     with redirected_stdout():
         main(args=[
             '--model', self._model_dir, 'search', 'reaction',
             '--id', 'rxn_1'])
Example #16
0
 def test_run_search_compound(self):
     with redirected_stdout():
         main(args=[
             '--model', self._model_dir, 'search', 'compound', '--id', 'A'])
Example #17
0
 def test_run_sbmlexport(self):
     with redirected_stdout(BytesIO()):
         main(args=['--model', self._model_dir, 'sbmlexport'])
Example #18
0
 def test_run_formulacheck(self):
     with redirected_stdout():
         main(args=['--model', self._model_dir, 'formulacheck'])
Example #19
0
 def test_run_search_reaction(self):
     with redirected_stdout():
         main(args=[
             '--model', self._model_dir, 'search', 'reaction', '--id',
             'rxn_1'
         ])
Example #20
0
 def test_run_chargecheck(self):
     with redirected_stdout():
         main(args=['--model', self._model_dir, 'chargecheck'])
Example #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'])
Example #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)
Example #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))
Example #24
0
 def test_run_formulacheck(self):
     with redirected_stdout():
         main(args=['--model', self._model_dir, 'formulacheck'])
Example #25
0
 def test_run_sbmlexport(self):
     with redirected_stdout(BytesIO()):
         main(args=['--model', self._model_dir, 'sbmlexport'])
Example #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)
Example #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)
Example #28
0
 def test_run_chargecheck(self):
     with redirected_stdout():
         main(args=['--model', self._model_dir, 'chargecheck'])
Example #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))
Example #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)
Example #31
0
 def test_run_search_compound(self):
     with redirected_stdout():
         main(args=[
             '--model', self._model_dir, 'search', 'compound', '--id', 'A'
         ])
Example #32
0
 def test_metabolic_command_main(self):
     main(MockMetabolicCommand, args=[
         '--model', self._model_dir])
     self.assertTrue(MockMetabolicCommand.has_metabolic_model)
Example #33
0
 def test_metabolic_command_main(self):
     main(MockMetabolicCommand, args=['--model', self._model_dir])
     self.assertTrue(MockMetabolicCommand.has_metabolic_model)