Пример #1
0
	def isotope_plot(self, name):
		isos = []
		for b in self.ad_heat.baskets():
			for comb in itertools.combinations(b.values(), 2):
				isos.append(btools.iso_diff(comb[0].get_pat(), comb[1].get_pat()))
		plt.hist(isos, bins=1000, range=(0.0, 1.0))
		plt.savefig(name + ".pdf")
Пример #2
0
	def basketer(self, ppm, drt, diso, *peaks):
		"""Function takes a delta rt and ppm, and any number of adducts and bins adducts that are
		within the delta rt and ppm differences. Returns a list of basket objects."""

		peaks = sorted(peaks, key=lambda ad: ad.isotopes[0].mz)

		widgets = ['BASKETING: ', Percentage(), ' ', Bar(marker=RotatingMarker()), ' ', ETA(),\
				' ', FileTransferSpeed()]
		pbar = ProgressBar(widgets=widgets, maxval=len(peaks)).start()
	
		baskets = []
		inpro = []
		n = 0
		basknum = 0
		for peak in peaks:
			match = False
			for indbin, in_bask in enumerate(inpro):
				ppmdif = abs(peak.isotopes[0].mz - in_bask.m) / in_bask.m * 1000000
				rtdif = abs(peak.isotopes[0].rt - in_bask.rt)
				if ppmdif <= ppm and rtdif <= drt and str(peak.mode) == in_bask.mode and \
						btools.iso_diff(peak.get_pat(), in_bask.iso_pat()) >= diso:
					in_bask[peak.idrun] = peak
					match = True
					break
				elif ppmdif > ppm:
					baskets.append(in_bask)
					inpro[indbin] = None

			k = 0
			while k < len(inpro) and len(inpro):
				if inpro[k]:
					k += 1
					continue
				else:
					inpro.pop(k)

			if not match:
				inpro.append(basket(basknum))
				inpro[-1][peak.idrun] = peak
				basknum += 1
			n += 1
			pbar.update(n)
		baskets.extend(inpro)
		pbar.finish()
		return baskets