How to use the ms2pip.ms2pip_tools.get_elude_predictions.get_elude_predictions function in ms2pip

To help you get started, we’ve selected a few ms2pip 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 compomics / ms2pip_c / fasta2speclib / fasta2speclib.py View on Github external
if i + b_size < len(peprec):
            peprec_batch = peprec[i:i + b_size]
        else:
            peprec_batch = peprec[i:]
        b_count += 1
        logging.info("Predicting batch %d of %d, containing %d unmodified peptides", b_count, num_b_counts, len(peprec_batch))

        logging.debug("Adding all modification combinations")
        peprec_mods = pd.DataFrame(columns=peprec_batch.columns)
        with Pool(params['num_cpu']) as p:
            peprec_mods = peprec_mods.append(p.map(add_mods, peprec_batch.iterrows()), ignore_index=True)
        peprec_batch = peprec_mods

        if type(params['elude_model_file']) == str:
            logging.debug("Adding ELUDE predicted retention times")
            peprec_batch['rt'] = get_elude_predictions(
                peprec_batch,
                params['elude_model_file'],
                unimod_mapping={mod['name']: mod['unimod_accession'] for mod in params['modifications']}
            )

        if type(params['rt_predictions_file']) == str:
            logging.info("Adding RT predictions from file")
            rt_df = pd.read_csv(params['rt_predictions_file'])
            for col in ['peptide', 'modifications', 'rt']:
                assert col in rt_df.columns, "RT file should contain a `%s` column" % col
            peprec_batch = peprec_batch.merge(rt_df, on=['peptide', 'modifications'], how='left')
            assert not peprec_batch['rt'].isna().any(), "Not all required peptide-modification combinations could be found in RT file"

        logging.debug("Adding charge states %s", str(params['charges']))
        peprec_batch = add_charges(peprec_batch)