-
Notifications
You must be signed in to change notification settings - Fork 0
/
mainwindow.cpp
208 lines (187 loc) · 6.49 KB
/
mainwindow.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
#include "mainwindow.h"
#include "processing/sprocessor.h"
#include "ui_mainwindow.h"
#include <QFileDialog>
#include <QTableWidgetItem>
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent), ui(new Ui::MainWindow) {
ui->setupUi(this);
ui->mainToolBar->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
aw = new AnalysisWindow();
aw->show();
// REMOVE NEXT LINES
// protein = new Protein(
// "/Users/Venky/Work/Softwares/Interlink/test_files/HDH_wt++.fasta");
// update_protein_changes();
// SProcessor *s = new SProcessor();
// // s->parse_ms2("/Users/Venky/Work/Softwares/Interlink/test_files/"
// // "CM_151128_Elite_32_N94HDH_gel_band_UV_CID.ms2");
// aw->add_one_cell();
}
MainWindow::~MainWindow() {
delete aw;
delete ui;
}
void MainWindow::closeEvent(QCloseEvent *event) {
if (aw->isVisible()) {
aw->close();
}
QApplication::closeAllWindows();
}
void MainWindow::on_actionProtein_triggered() {
protein = new Protein(QFileDialog::getOpenFileName(
this, tr("Protein Sequence"), get_homedirectory(),
tr("FASTA (*.fasta *.fa)")));
update_protein_changes();
}
void MainWindow::on_actionUV_ms2_file_triggered() {}
void MainWindow::on_actionUV_ms2_file_2_triggered() {}
void MainWindow::on_protease_currentIndexChanged(const QString &arg1) {}
void MainWindow::on_missed_cleavages_valueChanged(int arg1) {
update_protein_changes();
}
void MainWindow::on_a_released() { update_protein_changes(); }
void MainWindow::on_b_released() { update_protein_changes(); }
void MainWindow::on_c_released() { update_protein_changes(); }
void MainWindow::on_x_released() { update_protein_changes(); }
void MainWindow::on_y_released() { update_protein_changes(); }
void MainWindow::on_z_released() { update_protein_changes(); }
void MainWindow::on_p1_clicked() { update_protein_changes(); }
void MainWindow::on_p12_clicked() { update_protein_changes(); }
void MainWindow::on_p123_clicked() { update_protein_changes(); }
// void MainWindow::on_protein_sequence_textChanged() {
// protein->set_sequence(ui->protein_sequence->toPlainText());
// update_protein_changes();
//}
void MainWindow::update_protein_changes() {
read_values();
protein->digest(ui->missed_cleavages->value(), charges);
update_protein_data();
update_peptides_list_table();
protein->fragment_ions(charges, fragment_types_n, fragment_types_c);
update_fragments_list_table();
}
void MainWindow::update_fragments_list_table() {
QVector<Peptide *> peptides = protein->get_peptides();
aw->reset_fragments_list_table();
int len = peptides.length();
for (int i = 0; i < len; i++) {
Peptide *p = peptides.at(i);
if (p->crosslinker) {
aw->update_fragments_list_table(p->fragments);
}
}
}
void MainWindow::update_peptides_list_table() {
QVector<Peptide *> peptides = protein->get_peptides();
QTableWidgetItem *item1;
QTableWidgetItem *item2;
reset_peptides_list_table();
int len = peptides.length();
int count = 0;
for (int i = 0; i < len; i++) {
Peptide *p = peptides.at(i);
ui->peptides_list_table->insertRow(count);
item1 = new QTableWidgetItem(p->sequence);
item2 = new QTableWidgetItem(QString::number(p->mass, 'f', 6));
if (p->crosslinker) {
item1->setForeground(Qt::red);
item2->setForeground(Qt::red);
}
ui->peptides_list_table->setItem(count, 0, item1);
ui->peptides_list_table->setItem(count, 1, item2);
count += 1;
}
set_peptides_list_table_column_names();
}
void MainWindow::set_peptides_list_table_column_names() {
QStringList labels;
labels << "Sequence"
<< "Mass";
ui->peptides_list_table->setHorizontalHeaderLabels(labels);
ui->peptides_list_table->resizeRowsToContents();
ui->peptides_list_table->resizeColumnsToContents();
}
void MainWindow::reset_peptides_list_table() {
// Clear contents of the table and set the row count to zero
ui->peptides_list_table->clear();
ui->peptides_list_table->setRowCount(0);
}
void MainWindow::update_protein_data() {
QFontMetrics metrics(ui->sequence_name->font());
QString elidedText =
metrics.elidedText("Name: " + protein->get_name(), Qt::ElideRight, 300);
QString html_text = protein->get_sequence().replace(
QRegExp("X"), "<strong><font color=\"red\">X</font></strong>");
html_text = html_text.replace(
QRegExp("B"), "<strong><font color=\"red\">B</font></strong>");
QString sequence_text = "<html><body>" + html_text + "</body></html>";
// ui->protein_sequence->setText(protein->get_sequence());
// qDebug() << sequence_text;
ui->protein_sequence->setHtml(sequence_text);
ui->sequence_name->setText(elidedText);
}
void MainWindow::read_values() {
charges.clear();
fragment_types_n.clear();
fragment_types_c.clear();
charges.append(1);
if (ui->p12->isChecked()) {
charges.append(2);
}
if (ui->p123->isChecked()) {
charges.append(3);
}
if (ui->a->isChecked()) {
if (fragment_types_n.contains(A) == false) {
fragment_types_n.append(A);
}
// if (fragment_types_n.contains(A_HYDRATED) == false) {
// fragment_types_n.append(A_HYDRATED);
// }
// if (fragment_types_n.contains(A_AMIDATED) == false) {
// fragment_types_n.append(A_AMIDATED);
// }
}
if (ui->b->isChecked()) {
if (fragment_types_n.contains(B) == false) {
fragment_types_n.append(B);
}
// if (fragment_types_n.contains(B_HYDRATED) == false) {
// fragment_types_n.append(B_HYDRATED);
// }
// if (fragment_types_n.contains(B_AMIDATED) == false) {
// fragment_types_n.append(B_AMIDATED);
// }
}
if (ui->c->isChecked()) {
if (fragment_types_n.contains(C) == false) {
fragment_types_n.append(C);
}
}
if (ui->x->isChecked()) {
if (fragment_types_c.contains(X) == false) {
fragment_types_c.append(X);
}
}
if (ui->y->isChecked()) {
if (fragment_types_c.contains(Y) == false) {
fragment_types_c.append(Y);
}
// if (fragment_types_c.contains(Y_HYDRATED) == false) {
// fragment_types_c.append(Y_HYDRATED);
// }
// if (fragment_types_c.contains(Y_AMIDATED) == false) {
// fragment_types_c.append(Y_AMIDATED);
// }
}
if (ui->z->isChecked()) {
if (fragment_types_c.contains(Z) == false) {
fragment_types_c.append(Z);
}
}
qDebug() << fragment_types_n << fragment_types_c;
}
QString MainWindow::get_homedirectory() { return QDir::homePath(); }
void MainWindow::on_find_x_ms2_peaks_clicked() {}
void MainWindow::on_find_binding_peptides_clicked() {}