""" Tests of observables  generation"

:Author: <NAME> <<EMAIL>>
:Date: 2018-07-19
:Copyright: 2018, Karr Lab
:License: MIT
"""

import os
import shutil
import tempfile
import unittest
import wc_kb
from wc_kb_gen.random import observables, genome, properties, compartments, complex


class ObservablesGeneratorTestCase(unittest.TestCase):
    def setUp(self):
        self.dir = tempfile.mkdtemp()

        kb = wc_kb.core.KnowledgeBase()
        self.cell = kb.cell = wc_kb.core.Cell()

        gen = properties.PropertiesGenerator(kb)
        gen.run()

        gen = compartments.CompartmentsGenerator(kb)
        gen.run()

        gen = genome.GenomeGenerator(
            kb, options={
                'num_chromosomes': 1, 
                'num_genes': 200, 
                'seq_path': os.path.join(self.dir, 'kb_seq.fna')})
        gen.run()

        gen = complex.ComplexGenerator(kb)
        gen.run()

        gen = observables.ObservablesGenerator(
            kb, options={
                'assigned_proteins': ['a', 'b', 'c'], 
                'assigned_trnas': ['x', 'y', 'z']})
        gen.run()

    def tearDown(self):
        shutil.rmtree(self.dir)

    '''def test_assignment(self):
        cell = self.cell

        self.assertIsInstance(cell.species_types.get_one(
            id='a'), wc_kb.prokaryote.ProteinSpeciesType)
        self.assertIsInstance(cell.species_types.get_one(
            id='x'), wc_kb.prokaryote.RnaSpeciesType)'''

    def test_observables(self):
        cell = self.cell

        obs1 = cell.observables.get_one(id='a_obs')
        self.assertIsInstance(obs1, wc_kb.core.Observable)
        species = obs1.expression.species[0]
        species_type = species.species_type
        self.assertIsInstance(species, wc_kb.core.Species)
        self.assertIsInstance(species_type, wc_kb.prokaryote.ProteinSpeciesType)
        '''self.assertEqual(species.id(), 'a[c]')
        self.assertEqual(species_type.id, 'a')'''

""" Tests of observables  generation"

:Author: <NAME> <<EMAIL>>
:Date: 2018-07-19
:Copyright: 2018, Karr Lab
:License: MIT
"""

import os
import shutil
import tempfile
import unittest
import wc_kb
from wc_kb_gen.random import observables, genome, properties, compartments, complex


class ObservablesGeneratorTestCase(unittest.TestCase):
    def setUp(self):
        self.dir = tempfile.mkdtemp()

        kb = wc_kb.core.KnowledgeBase()
        self.cell = kb.cell = wc_kb.core.Cell()

        gen = properties.PropertiesGenerator(kb)
        gen.run()

        gen = compartments.CompartmentsGenerator(kb)
        gen.run()

        gen = genome.GenomeGenerator(
            kb, options={
                'num_chromosomes': 1, 
                'num_genes': 200, 
                'seq_path': os.path.join(self.dir, 'kb_seq.fna')})
        gen.run()

        gen = complex.ComplexGenerator(kb)
        gen.run()

        gen = observables.ObservablesGenerator(
            kb, options={
                'assigned_proteins': ['a', 'b', 'c'], 
                'assigned_trnas': ['x', 'y', 'z']})
        gen.run()

    def tearDown(self):
        shutil.rmtree(self.dir)

    '''def test_assignment(self):
        cell = self.cell

        self.assertIsInstance(cell.species_types.get_one(
            id='a'), wc_kb.prokaryote.ProteinSpeciesType)
        self.assertIsInstance(cell.species_types.get_one(
            id='x'), wc_kb.prokaryote.RnaSpeciesType)'''

    def test_observables(self):
        cell = self.cell

        obs1 = cell.observables.get_one(id='a_obs')
        self.assertIsInstance(obs1, wc_kb.core.Observable)
        species = obs1.expression.species[0]
        species_type = species.species_type
        self.assertIsInstance(species, wc_kb.core.Species)
        self.assertIsInstance(species_type, wc_kb.prokaryote.ProteinSpeciesType)
        '''self.assertEqual(species.id(), 'a[c]')
        self.assertEqual(species_type.id, 'a')'''

Tests of observables  generation"  :Author: <NAME> <<EMAIL>> :Date: 2018-07-19 :Copyright: 2018, Karr Lab :License: MIT def test_assignment(self):         cell = self.cell          self.assertIsInstance(cell.species_types.get_one(             id='a'), wc_kb.prokaryote.ProteinSpeciesType)         self.assertIsInstance(cell.species_types.get_one(             id='x'), wc_kb.prokaryote.RnaSpeciesType) self.assertEqual(species.id(), 'a[c]')         self.assertEqual(species_type.id, 'a')