Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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)