How to use the pythoms.molecule.IPMolecule function in pythoms

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_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 / pythoms / tome.py View on Github external
if 'colour' not in dct[species]:
                dct[species]['colour'] = 'k'
            if 'alpha' not in dct[species]:
                dct[species]['alpha'] = 0.5
        return dct

    if resolution is None:
        if spectype != 'centroid':
            resolution = autoresolution(realspec[0], realspec[1])  # calculate resolution
        else:
            resolution = 5000

    simdict = checksimdict(simdict)  # checks the simulation dictionary
    for species in simdict:  # generate Molecule object and set x and y lists
        simdict[species]['colour'] = Colour(simdict[species]['colour'])
        simdict[species]['mol'] = IPMolecule(
            species,
            resolution=resolution,
            **ipmol_kwargs,
        )
        # simdict[species]['mol'] = Molecule(species, res=res, dropmethod='threshold')
        if simtype == 'bar':
            simdict[species]['x'], simdict[species]['y'] = simdict[species]['mol'].barip
        if simtype == 'gaussian':
            simdict[species]['x'], simdict[species]['y'] = simdict[species]['mol'].gausip

    if mz == 'auto':  # automatically determine m/z range
        if verbose is True:
            sys.stdout.write('Automatically determining m/z window')
        mz = [10000000, 0]
        for species in simdict:
            simdict[species]['bounds'] = simdict[species]['mol'].bounds  # calculate bounds
github larsyunker / PythoMS / _scratch.py View on Github external
kwargs = {'string': 'C61H51IP3Pd', 'dropmethod': 'consolidate'}

mol = IPMolecule(
    verbose=True,
    **kwargs,
)

# mol2 = IPMolecule(
#
#     ** kwargs,
#     ipmethod='combinatorics',
# )

mol3 = IPMolecule(
    **kwargs,
    ipmethod='hybrid',
)
github larsyunker / PythoMS / PyRSIR.py View on Github external
n = check_integer(n, 'number of scans to sum')  # checks integer input and converts to list

    if type(xlsx) != dict:
        if verbose is True:
            sys.stdout.write('Loading processing parameters from excel file')
            sys.stdout.flush()
        xlfile = XLSX(xlsx, verbose=verbose)
        sp = xlfile.pullrsimparams()
    else:  # if parameters were provided in place of an excel file
        sp = xlsx

    mskeys = ['+', '-']
    for key in sp:
        if 'formula' in sp[key] and sp[key]['formula'] is not None:  # if formula is specified
            sp[key]['mol'] = IPMolecule(sp[key]['formula'])  # create Molecule object
            sp[key]['bounds'] = sp[key]['mol'].calculate_bounds(
                bounds_confidence
            )  # generate bounds from molecule object with this confidence interval
    if verbose is True:
        sys.stdout.write(' DONE\n')

    rtime = {}  # empty dictionaries for time and tic
    tic = {}
    rd = False
    for mode in mskeys:  # look for existing positive and negative mode raw data
        try:
            modedata, modetime, modetic = xlfile.pullrsim('Raw Data (' + mode + ')')
        except KeyError:
            continue
        except UnboundLocalError:  # catch for if pyrsir was not handed an excel file
            continue
github larsyunker / PythoMS / _scratch.py View on Github external
from pythoms.molecule import Molecule, IPMolecule, molecular_weight_error
import pickle
import os


kwargs = {'string': 'C61H51IP3Pd', 'dropmethod': 'consolidate'}

mol = IPMolecule(
    verbose=True,
    **kwargs,
)

# mol2 = IPMolecule(
#
#     ** kwargs,
#     ipmethod='combinatorics',
# )

mol3 = IPMolecule(
    **kwargs,
    ipmethod='hybrid',
)
github larsyunker / PythoMS / pythoms / molecule.py View on Github external
if self.verbose is True:
            sys.stdout.write(f'Saving {name} to {os.path.join(os.getcwd(), "molecules")}')
            sys.stdout.flush()

        with open(os.path.join(os.getcwd(), "molecules", name), 'wb') as outfile:
            pickle.dump(
                self,
                outfile
            )

        # todo differentiate between generation methods in the output files


if __name__ == '__main__':  # for testing and troubleshooting
    # st.printstart()
    mol = IPMolecule(
        'L2PdAr+I',
        # charge= 2, # specify charge (if not specified in formula)
        # res=1050000, # specify spectrometer resolution (default 5000)
        verbose=True,
        # decpl=10,
        # dropmethod='threshold',
        # threshold=0.00001,
        # ipmethod='hybrid',
        ipmethod='combinatorics',
        # keepall=True,