Ejemplo n.º 1
0
 def test_isatab_load_bii_s_7(self):
     with io.open(
             os.path.join(self._tab_data_dir, 'BII-S-7',
                          'i_matteo.txt')) as fp:
         investigation_parser = isatab.InvestigationParser()
         investigation_parser.parse(fp)
         self.parser = isatab.StudySampleTableParser(
             investigation_parser.isa)
         self.parser.parse(
             os.path.join(self._tab_data_dir, 'BII-S-7',
                          investigation_parser.isa.studies[-1].filename))
         self.assertEqual(len(self.parser.sources), 29)
         self.assertEqual(len(self.parser.samples), 29)
         self.assertEqual(len(self.parser.process_sequence), 29)
Ejemplo n.º 2
0
    def test_isatab_parse_study_table_bii_s_1(self):
        with io.open(
                os.path.join(self._tab_data_dir, 'BII-I-1',
                             'i_investigation.txt')) as fp:
            investigation_parser = isatab.InvestigationParser()
            investigation_parser.parse(fp)

            self.parser = isatab.StudySampleTableParser(
                investigation_parser.isa)
            self.parser.parse(
                os.path.join(self._tab_data_dir, 'BII-I-1',
                             investigation_parser.isa.studies[0].filename))
            self.assertEqual(len(self.parser.sources), 18)
            self.assertEqual(len(self.parser.samples), 164)
            self.assertEqual(len(self.parser.process_sequence), 18)
Ejemplo n.º 3
0
 def test_isatab_parse_study_no_investigation_object(self):
     with self.assertRaises(IOError):
         isatab.StudySampleTableParser()
     with self.assertRaises(IOError):
         isatab.StudySampleTableParser(isa=object())
Ejemplo n.º 4
0
    def setUp(self):
        self.isa = Investigation()
        self.isa.ontology_source_references = [
            OntologySource('A', 'f1', '1', 'd1'),
            OntologySource('B', 'f2', '2', 'd2')
        ]
        self.parser = isatab.StudySampleTableParser(self.isa)

        self.study_sample_table = \
            u'Source Name\tSample Name\n' \
            u'source1\tsample1\n' \
            u'source2\tsample2'

        self.study_sample_table_with_two_sample_names_columns = \
            u'Source Name\tSample Name\tSample Name\n' \
            u'source1\tsample1\tsample2\n'

        self.study_sample_table_with_numbers_as_ids = \
            u'Source Name\tSample Name\tSample Name\n' \
            u'source1\t1\t2\n'

        self.study_sample_table_with_process = \
            u'Source Name\tProtocol REF\tSample Name\n' \
            u'source1\tsample collection\tsample1\n' \
            u'source2\tsample collection\tsample2'

        self.study_sample_table_with_process_split = \
            u'Source Name\tProtocol REF\tSample Name\n' \
            u'source1\tsample collection\tsample1\n' \
            u'source1\tsample collection\tsample2'

        self.study_sample_table_with_process_pool = \
            u'Source Name\tProtocol REF\tSample Name\n' \
            u'source1\tsample collection\tsample1\n' \
            u'source2\tsample collection\tsample1'

        self.study_sample_table_source_characteristics_fragment = \
            u'Source Name\tCharacteristics[c1]\tCharacteristics[c2]\n' \
            u'source1\tsource1-c1\tsource1-c2\n' \
            u'source2\tsource2-c1\tsource2-c2'

        self.study_sample_table_sample_characteristics_fragment = \
            u'Sample Name\tCharacteristics[c1]\tCharacteristics[c2]\n' \
            u'sample1\tsample1-c1\tsample1-c2\n' \
            u'sample2\tsample2-c1\tsample2-c2'

        self.study_sample_table_source_comments_fragment = \
            u'Source Name\tComment[c1]\tComment[c2]\n' \
            u'source1\tsource1-c1\tsource1-c2\n' \
            u'source2\tsource2-c1\tsource2-c2'

        self.study_sample_table_sample_comments_fragment = \
            u'Sample Name\tComment[c1]\tComment[c2]\n' \
            u'sample1\tsample1-c1\tsample1-c2\n' \
            u'sample2\tsample2-c1\tsample2-c2'

        self.source_list = [Source(name='source1'), Source(name='source2')]
        self.sample_list = [Sample(name='sample1'), Sample(name='sample2')]
        self.sample_list_with_numbers_as_ids = [
            Sample(name='1'), Sample(name='2')
        ]
        characteristic_category_c1 = OntologyAnnotation(term='c1')
        characteristic_category_c2 = OntologyAnnotation(term='c2')
        self.source_list_with_characteristics = [
            Source(name='source1',
                   characteristics=[
                       Characteristic(category=characteristic_category_c1,
                                      value='source1-c1'),
                       Characteristic(category=characteristic_category_c2,
                                      value='source1-c2')
                   ]),
            Source(name='source2',
                   characteristics=[
                       Characteristic(characteristic_category_c1,
                                      value='source2-c1'),
                       Characteristic(category=characteristic_category_c2,
                                      value='source2-c2')
                   ])
        ]
        self.sample_list_with_characteristics = [
            Sample(name='sample1',
                   characteristics=[
                       Characteristic(category=characteristic_category_c1,
                                      value='sample1-c1'),
                       Characteristic(category=characteristic_category_c2,
                                      value='sample1-c2')
                   ]),
            Sample(name='sample2',
                   characteristics=[
                       Characteristic(characteristic_category_c1,
                                      value='sample2-c1'),
                       Characteristic(category=characteristic_category_c2,
                                      value='sample2-c2')
                   ])
        ]
        self.source_list_with_comments = [
            Source(name='source1',
                   comments=[
                       Comment(name='c1', value='source1-c1'),
                       Comment(name='c2', value='source1-c2')
                   ]),
            Source(name='source2',
                   comments=[
                       Comment(name='c1', value='source2-c1'),
                       Comment(name='c2', value='source2-c2')
                   ])
        ]
        self.sample_list_with_comments = [
            Sample(name='sample1',
                   comments=[
                       Comment(name='c1', value='sample1-c1'),
                       Comment(name='c2', value='sample1-c2')
                   ]),
            Sample(name='sample2',
                   comments=[
                       Comment(name='c1', value='sample2-c1'),
                       Comment(name='c2', value='sample2-c2')
                   ])
        ]