def test_read_table_missing_node(self): """ Raise FormatError if a node is missing from the header """ TRUTH_TABLE = join(self.TABLE_PATH, "missing_node.txt") with self.assertRaises(FormatError): LogicNetwork.read_table(TRUTH_TABLE)
def test_read_table_invalid_condition(self): """ Raise FormatError if a condition has an invalid state """ TRUTH_TABLE = join(self.TABLE_PATH, "invalid_condition.txt") with self.assertRaises(FormatError): LogicNetwork.read_table(TRUTH_TABLE)
def test_logic_simple_read_no_header(self): """ Test simple network read in (no header) """ TRUTH_TABLE = join(self.TABLE_PATH, "no_header.txt") with self.assertRaises(FormatError): LogicNetwork.read_table(TRUTH_TABLE)
def test_logic_simple_read_no_node_headers(self): """ Test simple network read in (no node headers) """ SIMPLE_TRUTH_TABLE = join(self.TABLE_PATH, "no_node_headers.txt") with self.assertRaises(FormatError): LogicNetwork.read_table(SIMPLE_TRUTH_TABLE)
def test_read_table_condition_len_mismatch(self): """ Raise FormatError if a condition has too many or too few bits in it """ TRUTH_TABLE = join(self.TABLE_PATH, "missing_condition.txt") with self.assertRaises(FormatError): LogicNetwork.read_table(TRUTH_TABLE) TRUTH_TABLE = join(self.TABLE_PATH, "extra_condition.txt") with self.assertRaises(FormatError): LogicNetwork.read_table(TRUTH_TABLE)
def test_logic_simple_read_no_node_headers(self): from os.path import dirname, abspath, realpath, join # Determine the path to the "data" directory of the neet.test module DATA_PATH = join(dirname(abspath(realpath(__file__))), "data") # Test simple network read in (no header) SIMPLE_TRUTH_TABLE = join( DATA_PATH, "test_simple_no_node_headers-truth_table.txt") with self.assertRaises(FormatError): LogicNetwork.read_table(SIMPLE_TRUTH_TABLE)
def test_read_table_skips_empty(self): """ Empty lines are skipped when reading truth tables """ TRUTH_TABLE = join(self.TABLE_PATH, "empty_lines.txt") simple = LogicNetwork.read_table(TRUTH_TABLE) self.assertEqual(simple.names, ['A', 'B', 'C']) self.assertEqual(simple.table, [((1, 2), set(['10', '11'])), ((0, ), set(['1'])), ((1, 2, 0), set(['101', '010', '011']))])
def test_logic_simple_read_empty(self): """ Test simple network read in (empty table) """ TRUTH_TABLE = join(self.TABLE_PATH, "empty_table.txt") simple = LogicNetwork.read_table(TRUTH_TABLE) self.assertEqual(simple.names, ['A', 'B', 'C', 'D']) self.assertEqual(simple.table, [((0, ), set(['1'])), ((1, ), set(['1'])), ((2, ), set(['1'])), ((3, ), set(['1']))])
def test_logic_simple_read_custom_comment(self): """ Test simple network read in with custom comments """ TRUTH_TABLE = join(self.TABLE_PATH, "custom_comment.txt") simple = LogicNetwork.read_table(TRUTH_TABLE) self.assertEqual(simple.names, ['A', 'B', 'C', 'D']) self.assertEqual(simple.table, [((1, 2), set(['11', '10'])), ((0, ), set(['1'])), ((1, 2, 0), set(['010', '011', '101'])), ((3, ), set(['1']))])
def test_logic_simple_read(self): """ Read a network from a truth table file """ TRUTH_TABLE = join(self.TABLE_PATH, "simple_table.txt") simple = LogicNetwork.read_table(TRUTH_TABLE) self.assertEqual(simple.names, ['A', 'B', 'C', 'D']) self.assertEqual(simple.table, [((1, 2), set(['11', '10'])), ((0, ), set(['1'])), ((1, 2, 0), set(['010', '011', '101'])), ((3, ), set(['1']))])
def test_logic_simple_read_empty(self): from os.path import dirname, abspath, realpath, join # Determine the path to the "data" directory of the neet.test module DATA_PATH = join(dirname(abspath(realpath(__file__))), "data") # Test simple network read in (no header) SIMPLE_TRUTH_TABLE = join(DATA_PATH, "test_simple_empty-truth_table.txt") simple = LogicNetwork.read_table(SIMPLE_TRUTH_TABLE) self.assertEqual(simple.names, ['A', 'B', 'C', 'D']) self.assertEqual(simple.table, [((0, ), set(['1'])), ((1, ), set(['1'])), ((2, ), set(['1'])), ((3, ), set(['1']))])
'The p53 GRN with damage present.', 'citation': 'Choi, Minsoo, Jue Shi, Sung Hoon Jung, Xi Chen, and' ' Kwang-Hyun Cho. Attractor Landscape Analysis Reveals' ' Feedback Loops in the p53 Network That Control the' ' Cellular Response to DNA Damage. Science Signaling 5,' ' no. 251 (2012): ra83. doi:10.1126/scisignal.2003363.', }) MOUSE_CORTICAL_7B_TRUTH_TABLE = join(DATA_PATH, "mouse_cortical_fig_7B-truth_table.txt") MOUSE_CORTICAL_7B_EXPRESSIONS = join( DATA_PATH, "mouse_cortical_fig_7B-logic_expressions.txt") #: The gene regulatory network for *mouse cortical* (7B edges) mouse_cortical_7B = LogicNetwork.read_table(MOUSE_CORTICAL_7B_TRUTH_TABLE) mouse_cortical_7B.metadata.update({ 'name': 'mouse_cortical_fig_7B', 'description': 'The gene regulatory network for *mouse cortical*' ' (Taken from figure 7B in citation below).', 'citation': 'Giacomantonio, Clare E., and Geoffrey J. Goodhill. "A' ' Boolean model of the gene regulatory network underlying' ' Mammalian cortical area development." PLoS' ' computational biology 6, no. 9 (2010):' ' e1000936. doi:10.1371/journal.pcbi.1000936', }) mouse_cortical_7B_from_expr = LogicNetwork.read_logic( MOUSE_CORTICAL_7B_EXPRESSIONS)
}) MOUSE_CORTICAL_7B_TRUTH_TABLE = join(DATA_PATH, "mouse_cortical_fig_7B-truth_table.txt") MOUSE_CORTICAL_7B_EXPRESSIONS = join( DATA_PATH, "mouse_cortical_fig_7B-logic_expressions.txt") #: A gene regulatory network model for cortical area development in mice, as #: described in fig. 7B of [Giacomantonio2010]_. mouse_cortical_7B = LogicNetwork.read_table( MOUSE_CORTICAL_7B_TRUTH_TABLE, metadata={ 'name': 'Mouse Cortical Area Development (fig. 7B)', 'description': 'The gene regulatory network for cortical area development ' 'in mice. Network taken from fig. 7B.', 'citation': 'C. E. Giacomantonio and G. J. Goodhill, "A Boolean model of ' 'the gene regulatory network underlying Mammalian cortical ' 'area development," PLoS Comput. Biol., vol. 6, no. 9, Sep. ' '2010. doi:10.1371/journal.pcbi.1000936' }) mouse_cortical_7B_from_expr = LogicNetwork.read_logic( MOUSE_CORTICAL_7B_EXPRESSIONS, metadata={ 'name': 'Mouse Cortical Area Development (fig. 7B)', 'description': 'The gene regulatory network for cortical area development ' 'in mice. Network taken from fig. 7B.', 'citation':