How to use the pyteomics.mass.calculate_mass function in pyteomics

To help you get started, we’ve selected a few pyteomics 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 kusterlab / prosit / prosit / converters / msp.py View on Github external
iRT,
        aMass,
        precursor_charge,
        sequence_integer,
        aIons,
    ):
        self.aIntensity = aIntensity
        self.collision_energy = collision_energy
        self.iRT = iRT
        self.aMass = aMass
        self.precursor_charge = precursor_charge
        self.aIons = aIons
        self.mod, self.mod_string = generate_mod_strings(sequence_integer)
        self.sequence = utils.get_sequence(sequence_integer)
        # amino acid Z which is defined at the toplevel in generate_aa_comp
        self.precursor_mass = pyteomics.mass.calculate_mass(
            self.sequence.replace("M(ox)", "Z"),
            aa_comp=aa_comp,
            ion_type="M",
            charge=int(self.precursor_charge),
        )
github compomics / ms2pip_c / fasta2speclib / fasta2speclib.py View on Github external
def prot_to_peprec(protein):
    params = get_params()
    # Calculate longest and shortest possible peptide with given max_pepmass
    max_pepmass_min_len = int(params['max_pepmass'] / 186.08 + 2)
    max_pepmass_max_len = int(params['max_pepmass'] / 57.02 + 2)
    tmp = pd.DataFrame(columns=['spec_id', 'peptide', 'modifications', 'charge'])
    pep_count = 0
    for peptide in cleave(str(protein.seq), expasy_rules['trypsin'], params['missed_cleavages']):
        if False not in [aa not in peptide for aa in ['B', 'J', 'O', 'U', 'X', 'Z']]:
            if params['min_peplen'] <= len(peptide) <= max_pepmass_max_len:
                # Skip peptide if it's mass is larger than allowed
                # Only calculate if longer than shortest possible peptide with max_pepmass
                if len(peptide) > max_pepmass_min_len:
                    if mass.calculate_mass(sequence=peptide) > params['max_pepmass']:
                        continue
                pep_count += 1
                row = {
                    'spec_id': '{}_{:03d}'.format(protein.id, pep_count),
                    'peptide': peptide, 'modifications': '-', 'charge': np.nan
                }
                tmp = tmp.append(row, ignore_index=True)
    return tmp