Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def process_peptides(worker_num, data, afile, modfile, modfile2, PTMmap, model):
"""
Function for each worker to process a list of peptides. The models are
chosen based on model. PTMmap, Ntermmap and Ctermmap determine the
modifications applied to each peptide sequence. Returns the predicted
spectra for all the peptides.
"""
ms2pip_pyx.ms2pip_init(
bytearray(afile.encode()),
bytearray(modfile.encode()),
bytearray(modfile2.encode()),
)
pcount = 0
# Prepare output variables
mz_buf = []
prediction_buf = []
peplen_buf = []
charge_buf = []
pepid_buf = []
# transform pandas dataframe into dictionary for easy access
if "ce" in data.columns:
)
)
else:
# Predict the b- and y-ion intensities from the peptide
pepid_buf.append(title)
peplen_buf.append(len(peptide) - 2)
charge_buf.append(charge)
# get/append ion mzs, targets and predictions
targets = ms2pip_pyx.get_targets(
modpeptide, msms, peaks, float(fragerror), peaks_version
)
target_buf.append([np.array(t, dtype=np.float32) for t in targets])
mzs = ms2pip_pyx.get_mzs(modpeptide, peaks_version)
mz_buf.append([np.array(m, dtype=np.float32) for m in mzs])
predictions = ms2pip_pyx.get_predictions(
peptide, modpeptide, charge, model_id, peaks_version, colen
) # SD: added colen
prediction_buf.append(
[np.array(p, dtype=np.float32) for p in predictions]
)
pcount += 1
if (pcount % 500) == 0:
sys.stdout.write("(%i)%i " % (worker_num, pcount))
sys.stdout.flush()
f.close()
if tableau:
ft.close()
ft2.close()