Example #1
0
    def setUp(self):
        """
        """
        self.paths = test_file_paths.paths

        file_compressed_indexed = self.paths[2]
        file_compressed_unindexed = self.paths[1]
        file_uncompressed_indexed = self.paths[0]
        file_uncompressed_unindexed = self.paths[0]
        file_bad_obo_version = self.paths[10]
        file_no_obo_version = self.paths[11]
        self.reader_compressed_indexed = run.Reader(file_compressed_indexed)
        self.reader_compressed_unindexed = run.Reader(file_compressed_unindexed)
        self.reader_uncompressed_indexed = run.Reader(file_uncompressed_indexed)
        self.reader_uncompressed_unindexed = run.Reader(file_uncompressed_unindexed)
        self.reader_bad_obo_version = run.Reader(file_bad_obo_version)
        self.reader_set_obo_version = run.Reader(
            file_bad_obo_version, obo_version="3.25.0"
        )
        self.reader_set_year_obo_version = run.Reader(
            file_uncompressed_indexed, obo_version="23:06:2017"
        )
        self.reader_set_bad_obo_version = run.Reader(
            file_uncompressed_indexed, obo_version="bad_obo_version"
        )
        self.reader_set_no_obo_version = run.Reader(file_no_obo_version)
Example #2
0
 def setUp(self):
     """
     """
     self.paths = test_file_paths.paths
     path  = self.paths[2]
     self.Run    = run.Reader(path)
     self.spec   = self.Run[6]
Example #3
0
    def setUp(self):
        """
        """
        self.paths = test_file_paths.paths

        file_compressed_indexed = self.paths[2]
        file_compressed_unindexed = self.paths[1]
        file_uncompressed_indexed = self.paths[0]
        file_uncompressed_unindexed = self.paths[0]
        self.reader_compressed_indexed = run.Reader(file_compressed_indexed)
        self.reader_compressed_unindexed = run.Reader(
            file_compressed_unindexed)
        self.reader_uncompressed_indexed = run.Reader(
            file_uncompressed_indexed)
        self.reader_uncompressed_unindexed = run.Reader(
            file_uncompressed_unindexed)
Example #4
0
 def test_getitem_index_gzip(self):
     idx_gzip = self.paths[2]
     run_idx_gzip = run.Reader(idx_gzip)
     randInt = 6
     spec = run_idx_gzip[randInt]
     self.assertIsInstance(spec, Spectrum)
     self.assertEqual(spec.ID, randInt)
     self.assertIsInstance(run_idx_gzip['TIC'], Chromatogram)
Example #5
0
 def test_getitem_index_mzml(self):
     idx_mzml    = self.paths[1]
     run_idx_mzml = run.Reader(idx_mzml)
     randInt = 1
     spec = run_idx_mzml[randInt]
     self.assertIsInstance(spec, Spectrum)
     self.assertEqual(spec.ID, randInt)
     self.assertIsInstance(run_idx_mzml['TIC'], Chromatogram)
Example #6
0
 def test_getitem_2_times_standard_mzml(self):
     mzml = self.paths[0]
     RunMzml = run.Reader(mzml)
     randInt = 10
     spec1 = RunMzml[randInt]
     self.assertIn(spec1.ID, RunMzml.info['offset_dict'])
     spec2= RunMzml[randInt]
     self.assertIsInstance(RunMzml[randInt], Spectrum)
     self.assertEqual(spec1.ID, spec2.ID)
Example #7
0
 def setUp(self):
     """
     """
     # self.paths = [
     #     os.path.join( DATA_FOLDER, file ) for file in DATA_FILES]
     self.paths = test_file_paths.paths
     path = self.paths[9]
     self.Run = run.Reader(path)
     self.spec = self.Run[2548]
Example #8
0
 def test_mz(self):
     """
     """
     mz           = self.spec.mz
     self.spec.mz = [1,2,3]
     self.assertCountEqual(self.spec.mz, [1,2,3])
     Run64        = run.Reader(self.paths[0])
     spec64       = Run64[2]
     mz64         = spec64.mz
Example #9
0
 def test_read_custom_regex(self):
     custom_regex_file = os.path.join(os.path.dirname(__file__), "data",
                                      "Manuels_custom_ids.mzML")
     reader = run.Reader(
         custom_regex_file,
         index_regex=re.compile(
             b'.*idRef="ManuelsCustomID=(?P<ID>.*) diesdas">(?P<offset>[0-9]*)</offset>'
         ))
     ids = sorted(
         [k for k in reader.info['offset_dict'].keys() if k != 'TIC'])
     assert ids == list(range(1, 11))
Example #10
0
 def __init__(self, path, *args, **kwargs):
     """
     Imports mzML file, adds the chromatogram into a single spectrum.
     :param path: .mzML file path
     :param args: arguments (unused)
     :param kwargs: keywords (unused)
     :return: mzMLimporter object
     """
     print "Reading mzML:", path
     self.msrun = pymzml_run.Reader(path)
     self.data = []
     self.scans = []
     self.times = []
     for i, spectrum in enumerate(self.msrun):
         if 'scan start time' in spectrum.keys():
             impdat = np.transpose([spectrum.mz, spectrum.i])
             impdat = impdat[impdat[:, 0] > 10]
             self.data.append(impdat)
             self.times.append(float(spectrum['scan start time']))
             self.scans.append(i)
     self.times = np.array(self.times)
     self.scans = np.array(self.scans)
     self.data = np.array(self.data)
Example #11
0
 def test_setting_measured_precision(self):
     reader = run.Reader(self.paths[2], MS_precisions={1: 61})
     spec = reader[1]
     self.assertEqual(spec.measured_precision, 61)
Example #12
0
 def test_getitem_standard_gzip_tic(self):
     gzip = self.paths[1]
     run_gzip = run.Reader(gzip)
     self.assertIsInstance(run_gzip['TIC'], Chromatogram)
Example #13
0
 def test_getitem_index_mzml_double(self):
     idx_mzml    = self.paths[0]
     run_idx_mzml = run.Reader(idx_mzml)
     self.assertIsInstance(run_idx_mzml[4], Spectrum)
     self.assertIn(4, run_idx_mzml.info['offset_dict'])
     self.assertIsInstance(run_idx_mzml[4], Spectrum)
Example #14
0
 def test_get_search_spec_with_string(self):
     mzml = self.paths[0]
     Reader = run.Reader(mzml)
     string = 'scan=2'
     self.assertIsInstance(Reader[string], Spectrum)
Example #15
0
 def create_parser(self):
     return pymzml_run.Reader(self.filename)
Example #16
0
 def test_getitem_index_mzml_last(self):
     idx_mzml    = self.paths[0]
     run_idx_mzml = run.Reader(idx_mzml)
     spec = run_idx_mzml[11]
     self.assertIsInstance(spec, Spectrum)
     self.assertEqual(spec.ID, 11)
Example #17
0
 def test_getitems_end_standard_mzml(self):
     mzml = self.paths[0]
     RunMzml = run.Reader(mzml)
     spec = RunMzml[11]
     self.assertEqual(spec.ID, 11)
Example #18
0
 def reset(self):
     self.source = pymzml_run.Reader(self.filename)
     self.last_scan = 1
 def setUp(self):
     self.paths = test_file_paths.paths
     path  = self.paths[2]
     self.Run_np  = run.Reader(path)
     self.chrom  = self.Run_np['TIC']
Example #20
0
 def test_getitem_standard_gzip_1(self):
     gzip = self.paths[1]
     run_gzip = run.Reader(gzip)
     self.assertIsInstance(run_gzip[1], Spectrum)
Example #21
0
 def test_chrom_count_spec_file(self):
     reader = run.Reader(self.paths[0])
     self.assertEqual(reader.get_chromatogram_count(), None)
Example #22
0
 def test_with_context(self):
     with run.Reader(self.paths[0]) as reader:
         reader[2]
Example #23
0
 def test_getitem_standard_mzml_random(self):
     mzml = self.paths[0]
     RunMzml = run.Reader(mzml)
     randInt = 4
     self.assertIsInstance(RunMzml[randInt], Spectrum)
     self.assertIsInstance(RunMzml['TIC'], Chromatogram)