Ejemplo n.º 1
0
    def test_metadata(self):
        database: TestDatabase = TestDatabase()
        table1: TestTable = database.create_table("table1")
        entry1: TestEntry = table1.add_entry("0/123.4-13/1/1-1-1-test.mzML",
                                             INPUT)
        it = mzML.Iterator(entry1)
        self.assertEqual(it.header_start_index, 0)
        self.assertEqual(it.header_end_index, 122)
        self.assertEqual(it.spectra_start_index, 123)
        self.assertEqual(it.spectra_end_index, 734)
        self.assertEqual(it.chromatogram_start_index, -1)
        self.assertEqual(it.chromatogram_end_index, -1)
        self.assertEqual(it.index_list_offset, 774)
        self.assertEqual(it.footer_start_index, 735)
        self.assertEqual(it.footer_end_index, len(entry1.get_content()))

        entry2: TestEntry = table1.add_entry("0/123.4-13/1/1-1-1-ctest.mzML",
                                             CHROMATOGRAM_INPUT)
        it = mzML.Iterator(entry2)
        self.assertEqual(it.header_start_index, 0)
        self.assertEqual(it.header_end_index, 122)
        self.assertEqual(it.spectra_start_index, 123)
        self.assertEqual(it.spectra_end_index, 618)
        self.assertEqual(it.chromatogram_start_index, 641)
        self.assertEqual(it.chromatogram_end_index, 847)
        self.assertEqual(it.index_list_offset, 890)
        self.assertEqual(it.footer_start_index, 619)
        self.assertEqual(it.footer_end_index, len(entry2.get_content()))
Ejemplo n.º 2
0
    def test_adjust(self):
        database: TestDatabase = TestDatabase()
        table1: TestTable = database.create_table("table1")
        entry1: TestEntry = table1.add_entry("0/123.4-13/1/1-1-1-test.mzML",
                                             INPUT)

        # Multiple spectra start in range
        it = mzML.Iterator(entry1, OffsetBounds(120, 540))
        [spectra, offset_bounds, more] = it.next()
        self.assertFalse(more)
        self.assertEqual(offset_bounds.start_index, 123)
        self.assertEqual(offset_bounds.end_index, 733)
        self.assertEqual(len(list(spectra)), 3)

        # One spectra starts in range
        it = mzML.Iterator(entry1, OffsetBounds(120, 250))
        [spectra, offset_bounds, more] = it.next()
        self.assertFalse(more)
        self.assertEqual(offset_bounds.start_index, 123)
        self.assertEqual(offset_bounds.end_index, 320)

        # No spectra start in range
        it = mzML.Iterator(entry1, OffsetBounds(126, 240))
        [spectra, offset_bounds, more] = it.next()
        self.assertFalse(more)
        self.assertEqual(offset_bounds.start_index, 123)
        self.assertEqual(offset_bounds.end_index, 320)
Ejemplo n.º 3
0
 def test_identifier(self):
     database: TestDatabase = TestDatabase()
     table1: TestTable = database.create_table("table1")
     entry1: TestEntry = table1.add_entry("0/123.4-13/1/1-1-1-test.mzML",
                                          INPUT)
     it = mzML.Iterator(entry1)
     [items, offset_bounds, more] = it.next()
     spectra = list(items)
     self.assertEqual(
         it.get_identifier_value(spectra[0], mzML.Identifiers.mass), 123.0)
     self.assertEqual(
         it.get_identifier_value(spectra[1], mzML.Identifiers.mass), 4.0)
     self.assertEqual(
         it.get_identifier_value(spectra[2], mzML.Identifiers.mass), 566.0)
Ejemplo n.º 4
0
 def test_next(self):
     database: TestDatabase = TestDatabase()
     table1: TestTable = database.create_table("table1")
     entry1: TestEntry = table1.add_entry("0/123.4-13/1/1-1-1-test.mzML",
                                          INPUT)
     it = mzML.Iterator(entry1)
     [spectra, offset_bounds, more] = it.next()
     spectra = list(spectra)
     self.assertFalse(more)
     self.assertEqual(len(spectra), 3)
     self.assertEqual(spectra[0].get("id"),
                      "controllerType=0 controllerNumber=1 scan=1")
     self.assertEqual(spectra[1].get("id"),
                      "controllerType=0 controllerNumber=1 scan=2")
     self.assertEqual(spectra[2].get("id"),
                      "controllerType=0 controllerNumber=1 scan=3")
Ejemplo n.º 5
0
def create_spectra_file(name, num_spectra):
    spectra = []
    #  name = "10sep2013_yeast_control_1.mzML"
    s3 = S3({})
    bucket_name = "tide-source-data"
    objs = s3.get_entries(bucket_name, "Coon-SingleShotFusionYeast/" + name)

    for obj in objs:
        if len(spectra) < num_spectra:
            it = mzML.Iterator(obj)
            extra = it.get_extra()
            more = True
            while len(spectra) < num_spectra and more:
                [items, _, more] = it.next()
                items = list(items)
                print(len(spectra), len(items))
                add_count = min(len(items), num_spectra - len(spectra))
                spectra += items[:add_count]
        else:
            break

    with open(name, "wb+") as f:
        it.from_array(spectra, f, extra)