Commit c061808e authored by Yan's avatar Yan
Browse files

Fixed graph-updating error, added graph colors

parent 0e3d2982
......@@ -57,8 +57,8 @@ def get_daughterset(ptable, dtable, ds):
massargs = dt.argsubselect(ds['masses'], startm, endm)
intensity = (np.sum(
ds['matrix'].T[massargs].T, axis=1)) / ds['chrom_dat'][1]
cor = dtable.cellWidget(row, 1).currentIndex()-1
if cor != -1:
cor = dtable.cellWidget(row, 1).currentIndex() -1
if cor not in (-2, -1):
factor = dt.floatize(dtable.cellWidget(row, 2).text())
startm = dt.floatize(ptable.cellWidget(cor, 1).text())
endm = dt.floatize(ptable.cellWidget(cor, 2).text())
......@@ -76,30 +76,32 @@ def update_drlspectrum(ptable, dtable, ds, drlspectrum):
# Dont do when the dataset is not populated
if isinstance(ds['masses'], type(None)):
return
colors = np.array([[255, 0, 0], [0, 255, 0], [0, 0, 255],
[0, 200, 255], [255, 0, 255], [255, 200, 0]])
colors = np.array([[0,0,0], [255, 0, 0], [0, 255, 0], [0, 0, 255],
[0, 200, 255], [255, 200, 0], [255, 100, 0],
[200, 50, 0], [255, 0, 200], [0, 100, 0],
[0, 100, 255], [100, 100, 100]])
names, times, intensities = get_daughterset(ptable, dtable, ds)
for i in range(len(drlspectrum.lines)):
drlspectrum.lines[0].remove()
for i, j in enumerate(intensities):
drlspectrum.plot(times, j, label=names[i],
color=(colors[i % len(colors)] / 255))
if len(names) != 0:
drlspectrum.set_ylim(top=np.amax(intensities)*1.1,
bottom=np.amax(intensities)*-0.01)
drlspectrum.legend()
drlspectrum.figure.canvas.draw()
count = 0
i = 0
for row in range(dtable.rowCount()):
if dtable.cellWidget(row, 0).checkState() == 2:
dtable.item(row, 0).setBackground(QtGui.QBrush(
QtGui.QColor(*colors[count % len(colors)], alpha=50)))
count += 1
QtGui.QColor(*colors[row % len(colors)], alpha=50)))
label = " {}".format(ptable.cellWidget(row, 0).text())
drlspectrum.plot(times, intensities[i], label=label,
color=(colors[row % len(colors)] / 255))
i += 1
else:
dtable.item(row, 0).setBackground(QtGui.QBrush())
if len(names) != 0:
drlspectrum.set_ylim(top=np.amax(intensities)*1.1,
bottom=np.amax(intensities)*-0.01)
drlspectrum.legend(loc=2)
drlspectrum.figure.canvas.draw()
def gettableitemlist(ptable):
ion_list = []
......@@ -133,6 +135,7 @@ def update_drl(start_mz, end_mz, spectrum, dataset, pname,
if float(0) not in (start, end) and pname.text() is "":
pname.setText(str(int((start+end)/2)))
ptnames = gettableitemlist(ptable)
for row in range(dtable.rowCount()):
dtable.item(row, 0).setText(ptnames[row])
......@@ -203,7 +206,6 @@ def add_line(ds, parenttable, daughtertable, drlspectrum):
daughtertable.setRowCount(newrow + 1)
# TODO: decide which box will be used in the final version
checkbox = QtWidgets.QCheckBox()
dname = QtWidgets.QTableWidgetItem()
dname.setFlags(dname.flags() & ~QtCore.Qt.ItemIsEditable)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment