isotopologues kwargs errors

Issue #22 resolved
jacobrosenstein
created an issue

When I call mass.isotopologues with a 'composition' argument:

mass.isotopologues(composition=composition,
                                               report_abundance=True,
                                               isotope_threshold=isotope_threshold,
                                               overall_threshold=overall_threshold)

It causes an error because it passes 2 'composition' kwargs to another function:

/pyteomics/mass/mass.py", line 715, in isotopologues
   abundance = isotopic_composition_abundance(composition=ic, **kwargs)
TypeError: isotopic_composition_abundance() got multiple values for keyword argument 'composition'

A similar error also happened with the 'formula' argument.

This may or may not be the best solution, but it can be fixed by removing 'composition' and 'formula' from kwargs before passing to isotopic_composition_abundance:

    for isotopologue in product(*all_isotoplogues):

        if 'formula' in kwargs:
            kwargs.pop('formula')

        if 'composition' in kwargs:
            kwargs.pop('composition')

        ic = Composition(formula=''.join(atom for el in isotopologue for atom in el), **kwargs)
        if report_abundance or overall_threshold > 0.0:
            abundance = isotopic_composition_abundance(composition=ic, **kwargs)

Comments (8)

  1. Log in to comment