Пример #1
0
 def setUp(self):
     self.header1 = ['a', 'b', 'c']
     self.header2 = ['a', 'b', 'd']
     self.columns_desc = [['first column'], ['second column'],
                          ['third column']]
     self.data = [[1, 2, 3], [4, 5, 6]]
     self.table1 = DataFrame(self.data, columns=self.header1)
     self.table2 = DataFrame(self.data, columns=self.header2)
     self.columns1 = DataFrame(self.columns_desc,
                               self.header1,
                               columns=['description'])
     self.columns2 = DataFrame(self.columns_desc,
                               self.header2,
                               columns=['description'])
     self.metadata = {'name': 'PLATFORM'}
     self.gpl = GPL(name='name',
                    table=self.table1,
                    metadata=self.metadata,
                    columns=self.columns1)
     self.gsm1 = GSM(name='name',
                     table=self.table1,
                     metadata=self.metadata,
                     columns=self.columns1)
     self.gsm2 = GSM(name='name',
                     table=self.table2,
                     metadata=self.metadata,
                     columns=self.columns2)
     self.gsms = {'a': self.gsm1, 'b': self.gsm2}
     self.gpls = {'a': self.gpl}
Пример #2
0
 def test_head(self):
     gsm = GSM(name='name', table=self.table1, metadata=self.metadata,
               columns=self.columns1)
     try:
         gsm.head()
     except Exception:
         self.fail("GSM.head() raised error!")
Пример #3
0
 def setUp(self):
     self.header1 = ["a", "b", "c"]
     self.header2 = ["a", "b", "d"]
     self.columns_desc = [["first column"], ["second column"],
                          ["third column"]]
     self.data = [[1, 2, 3], [4, 5, 6]]
     self.table1 = DataFrame(self.data, columns=self.header1)
     self.table2 = DataFrame(self.data, columns=self.header2)
     self.columns1 = DataFrame(self.columns_desc,
                               self.header1,
                               columns=["description"])
     self.columns2 = DataFrame(self.columns_desc,
                               self.header2,
                               columns=["description"])
     self.metadata = {"name": "PLATFORM"}
     self.gpl = GPL(
         name="name",
         table=self.table1,
         metadata=self.metadata,
         columns=self.columns1,
     )
     self.gsm1 = GSM(
         name="name",
         table=self.table1,
         metadata=self.metadata,
         columns=self.columns1,
     )
     self.gsm2 = GSM(
         name="name",
         table=self.table2,
         metadata=self.metadata,
         columns=self.columns2,
     )
     self.gsms = {"a": self.gsm1, "b": self.gsm2}
     self.gpls = {"a": self.gpl}
Пример #4
0
 def test_get_columns_as_string(self):
     gsm = GSM(name='name', table=self.table1, metadata=self.metadata,
               columns=self.columns1)
     columns = ("#a = first column\n"
                "#b = second column\n"
                "#c = third column")
     self.assertEqual(gsm._get_columns_as_string(), columns)
Пример #5
0
 def test_metadata_as_string(self):
     metadata = {'name': ['SAMPLE1'], 'data': ["Normal"]}
     metadata_soft = ("!Sample_data = Normal\n"
                      "!Sample_name = SAMPLE1")
     gsm = GSM(name='name', table=self.table1, metadata=metadata, columns=self.columns1)
     self.assertIn("!Sample_data = Normal", gsm._get_metadata_as_string())
     self.assertIn("!Sample_name = SAMPLE1", gsm._get_metadata_as_string())
Пример #6
0
 def test_metadata_as_string(self):
     metadata = {"name": ["SAMPLE1"], "data": ["Normal"]}
     gsm = GSM(name="name",
               table=self.table1,
               metadata=metadata,
               columns=self.columns1)
     self.assertIn("!Sample_data = Normal", gsm._get_metadata_as_string())
     self.assertIn("!Sample_name = SAMPLE1", gsm._get_metadata_as_string())
Пример #7
0
 def test_get_table_as_string(self):
     gsm = GSM(name='name', table=self.table1, metadata=self.metadata, columns=self.columns1)
     table = ("!sample_table_begin\n"
              "a\tb\tc\n"
              "1\t2\t3\n"
              "4\t5\t6\n"
              "!sample_table_end")
     self.assertEqual(gsm._get_table_as_string(), table)
Пример #8
0
 def test_get_type(self):
     gsm = GSM(
         name="name",
         table=self.table1,
         metadata=self.metadata,
         columns=self.columns1,
     )
     self.assertEqual(gsm.get_type(), None)
Пример #9
0
 def test_get_metadata_attribute(self):
     metadata = {'name': 'SAMPLE', 'samples': ["sam1", "sam2"]}
     gsm = GSM(name='name', table=self.table1, metadata=self.metadata, columns=self.columns1)
     gsm2 = GSM(name='name', table=self.table1, metadata=metadata, columns=self.columns1)
     with self.assertRaises(TypeError):
         gsm2.get_metadata_attribute('name')
     self.assertEqual(gsm.get_metadata_attribute('name'), "SAMPLE")
     self.assertEqual(gsm2.get_metadata_attribute('samples'), ["sam1", "sam2"])
     with self.assertRaises(NoMetadataException):
         gsm.get_metadata_attribute('dupa')
Пример #10
0
 def test_to_soft(self):
     gsm = GSM(name='name', table=self.table1, metadata=self.metadata, columns=self.columns1)
     soft = ("^SAMPLE = name\n"
             "!Sample_name = SAMPLE\n"
             "#a = first column\n"
             "#b = second column\n"
             "#c = third column\n"
             "!sample_table_begin\n"
             "a\tb\tc\n"
             "1\t2\t3\n"
             "4\t5\t6\n"
             "!sample_table_end")
     self.assertEqual(gsm._get_object_as_soft(), soft)
Пример #11
0
 def test_simple_data(self):
     gsm = GSM(name='name',
               table=self.table1,
               metadata=self.metadata,
               columns=self.columns1)
     self.assertEqual(gsm.table.ix[0, 'a'], 1)
     self.assertEqual(gsm.table.ix[1, 'b'], 5)
Пример #12
0
 def test_simple_data(self):
     gsm = GSM(
         name="name",
         table=self.table1,
         metadata=self.metadata,
         columns=self.columns1,
     )
     self.assertEqual(gsm.table.loc[0, "a"], 1)
     self.assertEqual(gsm.table.loc[1, "b"], 5)
Пример #13
0
 def test_get_metadata_attribute(self):
     metadata = {"name": "SAMPLE", "samples": ["sam1", "sam2"]}
     gsm = GSM(
         name="name",
         table=self.table1,
         metadata=self.metadata,
         columns=self.columns1,
     )
     gsm2 = GSM(name="name",
                table=self.table1,
                metadata=metadata,
                columns=self.columns1)
     with self.assertRaises(TypeError):
         gsm2.get_metadata_attribute("name")
     self.assertEqual(gsm.get_metadata_attribute("name"), "SAMPLE")
     self.assertEqual(gsm2.get_metadata_attribute("samples"),
                      ["sam1", "sam2"])
     with self.assertRaises(NoMetadataException):
         gsm.get_metadata_attribute("dupa")
Пример #14
0
 def test_creation_of_object(self):
     with self.assertRaises(ValueError):
         GSM(name='name',
             table=['a'],
             metadata=self.metadata,
             columns=self.columns1)
     with self.assertRaises(TypeError):
         GSM(name='name',
             table=self.table1,
             metadata=[],
             columns=self.columns1)
     with self.assertRaises(ValueError):
         GSM(name='name',
             table=self.table1,
             metadata=self.metadata,
             columns=[])
     with self.assertRaises(DataIncompatibilityException):
         GSM(name='name',
             table=self.table1,
             metadata=self.metadata,
             columns=self.columns2)
     with self.assertRaises(ValueError):
         GSM(name='name',
             table=self.table1,
             metadata=self.metadata,
             columns=self.columns_no_desc)
     GSM(name='name',
         table=self.table1,
         metadata=self.metadata,
         columns=self.columns1)
Пример #15
0
 def test_metadata_as_string(self):
     metadata = {'name': ['SAMPLE1'], 'data': ["Normal"]}
     metadata_soft = ("!Sample_data = Normal\n"
                      "!Sample_name = SAMPLE1")
     gsm = GSM(name='name', table=self.table1, metadata=metadata, columns=self.columns1)
     self.assertEqual(gsm._get_metadata_as_string(), metadata_soft)
Пример #16
0
 def test_get_type(self):
     gsm = GSM(name='name', table=self.table1, metadata=self.metadata, columns=self.columns1)
     self.assertEqual(gsm.get_type(), None)
Пример #17
0
 def test_metadata_as_string(self):
     metadata = {'name': ['SAMPLE1'], 'data': ["Normal"]}
     gsm = GSM(name='name', table=self.table1, metadata=metadata,
               columns=self.columns1)
     self.assertIn("!Sample_data = Normal", gsm._get_metadata_as_string())
     self.assertIn("!Sample_name = SAMPLE1", gsm._get_metadata_as_string())