Пример #1
0
class WhenParsingIDF(unittest.TestCase):
    def setUp(self):
        self.parser = MageTabParser()
        self.test_path = os.path.join(MAGETAB_DATA_DIR, 'E-MEXP-31.idf.txt')

    def test_should_parse_idf_without_error(self):
        self.parser.parse_idf(self.test_path)

    def test_should_create_ISA(self):
        self.parser.parse_idf(self.test_path)
        self.assertIsInstance(self.parser.ISA, Investigation)

    def test_should_return_ISA(self):
        self.assertIsInstance(self.parser.parse_idf(self.test_path),
                              Investigation)
Пример #2
0
def convert(idf_file_path, output_path):
    """ Converter for MAGE-TAB to ISA-Tab
    :param idf_file_path: File descriptor of input IDF file
    :param output_path: Path to directory to write output ISA-Tab files to
    """
    parser = MageTabParser()
    parser.parse_idf(idf_file_path)
    sdrf_files = [x.value for x in parser.ISA.studies[-1].comments if 'SDRF File' in x.name]
    if len(sdrf_files) == 1:
        sdrf_files = sdrf_files[0].split(';')
        for sdrf_file in sdrf_files:
            table_files = parser.parse_sdrf_to_isa_table_files(os.path.join(os.path.dirname(idf_file_path), sdrf_file))
            for in_fp in table_files:
                log.info("Writing {0} to {1}".format(in_fp.name, output_path))
                with open(os.path.join(output_path, in_fp.name), 'w') as out_fp:
                    out_fp.write(in_fp.read())
    log.info("Writing {0} to {1}".format("i_investigation.txt", output_path))
    isatab.dump(parser.ISA, output_path=output_path, skip_dump_tables=True)
Пример #3
0
class WhenParsedIDF(unittest.TestCase):
    """ Test case using E-MEXP-31.idf.txt """
    def setUp(self):
        self.parser = MageTabParser()
        self.test_path = os.path.join(MAGETAB_DATA_DIR, 'E-MEXP-31.idf.txt')
        self.parser.parse_idf(self.test_path)

    def test_should_load_five_ontology_sources(self):
        self.assertEqual(len(self.parser.ISA.ontology_source_references), 5)

    def test_should_load_one_study(self):
        self.assertEqual(len(self.parser.ISA.studies), 1)

    def test_should_load_three_study_designs(self):
        self.assertEqual(len(self.parser.ISA.studies[-1].design_descriptors),
                         3)

    def test_should_load_one_study_factor(self):
        self.assertEqual(len(self.parser.ISA.studies[-1].factors), 1)

    def test_should_load_one_person(self):
        self.assertEqual(len(self.parser.ISA.studies[-1].contacts), 1)

    def test_should_load_one_publication(self):
        self.assertEqual(len(self.parser.ISA.studies[-1].publications), 1)

    def test_should_load_six_protocols(self):
        self.assertEqual(len(self.parser.ISA.studies[-1].protocols), 6)

    def test_should_load_one_assay(self):
        self.assertEqual(len(self.parser.ISA.studies[-1].assays), 1)

    def test_should_load_assay_with_transcription_micro(self):
        self.assertEqual(
            self.parser.ISA.studies[-1].assays[-1].measurement_type.term,
            "transcription profiling")
        self.assertEqual(
            self.parser.ISA.studies[-1].assays[-1].technology_type.term,
            "DNA microarray")
Пример #4
0
 def setUp(self):
     self.parser = MageTabParser()
Пример #5
0
 def setUp(self):
     self.parser = MageTabParser()
     self.test_path = os.path.join(MAGETAB_DATA_DIR, 'E-MEXP-31.idf.txt')
     self.parser.parse_idf(self.test_path)