How to use pythoms - 10 common examples

To help you get started, we’ve selected a few pythoms examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github larsyunker / PythoMS / tests.py View on Github external
def test_spectrum(self):
        spec = Spectrum(3)
        spec.add_value(479.1, 1000)
        self.assertEqual(
            spec.trim(),
            [[479.1], [1000]]
        )

        spec2 = Spectrum(3)
        spec2.add_value(443.1, 1000)
        self.assertEqual(
            spec2.trim(),
            [[443.1], [1000]]
        )
        spec += spec2
        self.assertEqual(
            spec.trim(),
            [[443.1, 479.1], [1000, 1000]]
        )
        spec3 = Spectrum(3, start=50, end=2500)
        spec3.add_value(2150.9544, 1000)
        self.assertEqual(
            spec3.trim(),
            [[2150.954], [1000]]
        )
github larsyunker / PythoMS / tests.py View on Github external
def test_xlsx(self):
        xlfile = XLSX(
            validation_path / 'xlsx_validation',
            verbose=False
        )
        spec, xunit, yunit = xlfile.pullspectrum('example MS spectrum')
        multispec = xlfile.pullmultispectrum('example multi-spectrum')
        rsimparams = xlfile.pullrsimparams()
        xlout = XLSX(
            validation_path / 'xlsxtestout.xlsx',
            create=True,
            verbose=False
        )
        xlout.writespectrum(spec[0], spec[1], 'test single spectrum out', xunit, yunit)
        for key, val in sorted(multispec.items()):
            xlout.writemultispectrum(
                multispec[key]['x'],
                multispec[key]['y'],
github larsyunker / PythoMS / tests.py View on Github external
def test_xlsx(self):
        xlfile = XLSX(
            validation_path / 'xlsx_validation',
            verbose=False
        )
        spec, xunit, yunit = xlfile.pullspectrum('example MS spectrum')
        multispec = xlfile.pullmultispectrum('example multi-spectrum')
        rsimparams = xlfile.pullrsimparams()
        xlout = XLSX(
            validation_path / 'xlsxtestout.xlsx',
            create=True,
            verbose=False
        )
        xlout.writespectrum(spec[0], spec[1], 'test single spectrum out', xunit, yunit)
        for key, val in sorted(multispec.items()):
            xlout.writemultispectrum(
                multispec[key]['x'],
                multispec[key]['y'],
                multispec[key]['xunit'],
                multispec[key]['yunit'],
                'Function Chromatograms',
                key
            )
        xlout.save()
        os.remove(
github larsyunker / PythoMS / tests.py View on Github external
def test_mzml(self):
        mzml = mzML(
            validation_path / 'MultiTest',
            verbose=False
        )
        self.assertEqual(  # check that the correct function keys were pulled
            mzml.functions.keys(),
            {1, 3, 4},
        )

        @mzml.foreachchrom
        def testperchrom(chromatogram):
            attr = branch_attributes(chromatogram)
            return attr['id']

        self.assertEqual(  # test chromatogram decorator
            testperchrom(),
            [u'TIC', u'SRM SIC Q1=200 Q3=100 function=2 offset=0']
github larsyunker / PythoMS / tests.py View on Github external
def test_ipmolecule_methods(self):
        for ipmethod in VALID_IPMETHODS:
            for dropmethod in VALID_DROPMETHODS:
                mol = IPMolecule(
                    'Pd2C10H5',
                    ipmethod=ipmethod,
                    dropmethod=dropmethod,
                )
                test = mol.gaussian_isotope_pattern  # test gaussian isotope pattern generation
github larsyunker / PythoMS / tests.py View on Github external
def setUp(self):
        self.mol = Molecule('L2PdAr+I')
        self.ipmol = IPMolecule(
            'L2PdAr+I',
            ipmethod='multiplicative',
            dropmethod='threshold',
            threshold=0.01,
        )
github larsyunker / PythoMS / tests.py View on Github external
self.assertEqual(
            self.ipmol.estimated_exact_mass,
            1109.1303706381723,
        )
        self.assertEqual(
            self.ipmol.barip,
            [[1105.130443, 1106.133823749481, 1107.1290292337153, 1108.1305157201678, 1109.1303706381723,
              1110.1328590930914, 1111.1301978511672, 1112.1325950611867, 1113.1318575059308, 1114.134086933976,
              1115.1370272665604, 1116.140052, 1117.143407],
             [2.287794397621507, 1.5228133756325326, 25.476059354316945, 66.8193866193291, 100.0, 52.65050639843156,
              74.88108058795096, 42.5730473226288, 39.36707265932168, 20.17253048748261, 5.990476280101723,
              1.1848920932846654, 0.16082254122736006]]
        )
        self.ipmol - 'PPh3'  # test subtraction
        self.ipmol + 'PPh3'  # test addition
        mol2 = IPMolecule('N(Et)2(CH2(13C)H2(2H))2')
        self.ipmol + mol2  # test class addition
github larsyunker / PythoMS / tests.py View on Github external
def setUp(self):
        self.mol = Molecule('L2PdAr+I')
        self.ipmol = IPMolecule(
            'L2PdAr+I',
            ipmethod='multiplicative',
            dropmethod='threshold',
            threshold=0.01,
        )
github larsyunker / PythoMS / tests.py View on Github external
def test_element(self):
        mol = Spectrum(
            3,
            start=0.,
            end=100.,
            filler=0.,
        )
        mol.add_spectrum(  # start with a Cl
            *element_intensity_list('Cl')
        )
        mol.add_element(  # add another Cl
            *element_intensity_list('Cl')
        )
        self.assertEqual(
            mol.trim(),
            [[69.938, 71.935, 73.932], [0.5739577600000001, 0.36728448, 0.05875776]]
        )
        mol.add_element(
            *element_intensity_list('Pd')
        )
        self.assertEqual(
            mol.trim(),
            [[171.843, 173.84, 173.841, 174.842, 175.837, 175.838, 175.841, 176.839, 177.835, 177.838, 177.841, 178.836,
              179.835, 179.838, 179.843, 181.835, 181.84, 183.837],
             [0.005854369152000001, 0.0037463016960000003, 0.06393889446400002, 0.128164767808, 0.000599329152,
github larsyunker / PythoMS / tests.py View on Github external
start=0.,
            end=100.,
            filler=0.,
        )
        mol.add_spectrum(  # start with a Cl
            *element_intensity_list('Cl')
        )
        mol.add_element(  # add another Cl
            *element_intensity_list('Cl')
        )
        self.assertEqual(
            mol.trim(),
            [[69.938, 71.935, 73.932], [0.5739577600000001, 0.36728448, 0.05875776]]
        )
        mol.add_element(
            *element_intensity_list('Pd')
        )
        self.assertEqual(
            mol.trim(),
            [[171.843, 173.84, 173.841, 174.842, 175.837, 175.838, 175.841, 176.839, 177.835, 177.838, 177.841, 178.836,
              179.835, 179.838, 179.843, 181.835, 181.84, 183.837],
             [0.005854369152000001, 0.0037463016960000003, 0.06393889446400002, 0.128164767808, 0.000599329152,
              0.040915491072, 0.15686265580800002, 0.082014624384, 0.006545614464, 0.100378848384, 0.15186922329600003,
              0.013120607808, 0.016058495808, 0.097183473408, 0.06726784947200001, 0.015547303296, 0.043045741056,
              0.0068864094719999994]]

        )
        mol.charge = 2
        self.assertEqual(
            mol.trim()[0],
            [85.922, 86.92, 86.921, 87.421, 87.919, 87.919, 87.921, 88.42, 88.918, 88.919, 88.921, 89.418, 89.918,
             89.919, 89.922, 90.918, 90.92, 91.919]