1 /**
2  * UGENE - Integrated Bioinformatics Tools.
3  * Copyright (C) 2008-2021 UniPro <ugene@unipro.ru>
4  * http://ugene.net
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 2
9  * of the License, or (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19  * MA 02110-1301, USA.
20  */
21 
22 #include <GTUtilsMdi.h>
23 #include <GTUtilsNotifications.h>
24 #include <base_dialogs/GTFileDialog.h>
25 #include <drivers/GTKeyboardDriver.h>
26 #include <drivers/GTMouseDriver.h>
27 #include <primitives/GTComboBox.h>
28 #include <primitives/GTLineEdit.h>
29 #include <primitives/GTSpinBox.h>
30 #include <primitives/GTWidget.h>
31 
32 #include <U2Core/U2IdTypes.h>
33 
34 #include "GTTestsInSilicoPcr.h"
35 #include "GTUtilsAnnotationsTreeView.h"
36 #include "GTUtilsOptionPanelSequenceView.h"
37 #include "GTUtilsPcr.h"
38 #include "GTUtilsProject.h"
39 #include "GTUtilsProjectTreeView.h"
40 #include "GTUtilsSequenceView.h"
41 #include "GTUtilsTaskTreeView.h"
42 #include "primitives/PopupChooser.h"
43 #include "runnables/ugene/plugins/pcr/PrimersDetailsDialogFiller.h"
44 #include "runnables/ugene/ugeneui/SequenceReadingModeSelectorDialogFiller.h"
45 
46 namespace U2 {
47 namespace GUITest_common_scenarios_in_silico_pcr {
48 using namespace HI;
GUI_TEST_CLASS_DEFINITION(test_0001)49 GUI_TEST_CLASS_DEFINITION(test_0001) {
50     GTUtilsPcr::clearPcrDir(os);
51     // The PCR options panel is available only for nucleic sequences
52 
53     // 1. Open "_common_data/fasta/alphabet.fa".
54     GTUtilsDialog::waitForDialog(os, new SequenceReadingModeSelectorDialogFiller(os, SequenceReadingModeSelectorDialogFiller::Separate));
55     GTUtilsProject::openFile(os, testDir + "_common_data/fasta/alphabet.fa");
56     GTUtilsSequenceView::checkSequenceViewWindowIsActive(os);
57 
58     // 2. Activate the "Amino" sequence in the sequence view (set the focus for it).
59     GTWidget::click(os, GTUtilsSequenceView::getPanOrDetView(os, 0));
60 
61     // 3. Open the PCR OP.
62     GTWidget::click(os, GTWidget::findWidget(os, "OP_IN_SILICO_PCR"));
63 
64     // Expected: The panel is unavailable, the info message about alphabets is shown.
65     QWidget *params = GTWidget::findWidget(os, "runPcrWidget");
66     QWidget *warning = GTWidget::findWidget(os, "algoWarningLabel");
67     CHECK_SET_ERR(!params->isEnabled(), "The panel is enabled for a wrong alphabet");
68     CHECK_SET_ERR(warning->isVisible(), "No alphabet warning");
69 
70     // 4. Activate the "Nucl" sequence.
71     GTWidget::click(os, GTUtilsSequenceView::getPanOrDetView(os, 1));
72 
73     // Expected: The panel is available, the info message is hidden.
74     CHECK_SET_ERR(params->isEnabled(), "The panel is disabled for the right alphabet");
75     CHECK_SET_ERR(!warning->isVisible(), "The alphabet warning is shown");
76 }
77 
GUI_TEST_CLASS_DEFINITION(test_0002)78 GUI_TEST_CLASS_DEFINITION(test_0002) {
79     GTUtilsPcr::clearPcrDir(os);
80     // Primer group box
81 
82     // 1. Open "_common_data/fasta/pcr_test.fa".
83     GTFileDialog::openFile(os, testDir + "_common_data/fasta", "pcr_test.fa");
84     GTUtilsTaskTreeView::waitTaskFinished(os);
85 
86     // 2. Open the PCR OP.
87     GTWidget::click(os, GTWidget::findWidget(os, "OP_IN_SILICO_PCR"));
88 
89     // 3. Set the focus at the primer line edit and write "Q%1" (not ACGT).
90     //  TODO: wrap into api
91     QWidget *forwardPrimerBox = GTWidget::findWidget(os, "forwardPrimerBox");
92     QLineEdit *forwardPrimerLine = dynamic_cast<QLineEdit *>(GTWidget::findWidget(os, "primerEdit", forwardPrimerBox));
93     GTLineEdit::setText(os, forwardPrimerLine, "Q%1", true);
94 
95     // Expected: the line edit is empty, the statistics label is empty.
96     CHECK_SET_ERR(forwardPrimerLine->text().isEmpty(), "Wrong input");
97 
98     // 4. Write "atcg".
99     GTLineEdit::setText(os, forwardPrimerLine, "atcg", true);
100 
101     // Expected: the line edit content is "ATCG", the statistics label shows the temperature and "4-mer".
102     QLabel *statsLabel = dynamic_cast<QLabel *>(GTWidget::findWidget(os, "characteristicsLabel", forwardPrimerBox));
103     CHECK_SET_ERR(forwardPrimerLine->text() == "ATCG", "No upper-case");
104     CHECK_SET_ERR(statsLabel->text().endsWith("4-mer"), "Wrong statistics label");
105 
106     // 5. Click the reverse complement button.
107     GTWidget::click(os, GTWidget::findWidget(os, "reverseComplementButton", forwardPrimerBox));
108 
109     // Expected: the line edit content is "CGAT".
110     CHECK_SET_ERR(forwardPrimerLine->text() == "CGAT", "Incorrect reverse-complement");
111 }
112 
GUI_TEST_CLASS_DEFINITION(test_0003)113 GUI_TEST_CLASS_DEFINITION(test_0003) {
114     GTUtilsPcr::clearPcrDir(os);
115     // Availability of the PCR OP find button
116 
117     // 1. Open "_common_data/fasta/pcr_test.fa".
118     GTFileDialog::openFile(os, testDir + "_common_data/fasta", "pcr_test.fa");
119     GTUtilsTaskTreeView::waitTaskFinished(os);
120 
121     // 2. Open the PCR OP.
122     GTWidget::click(os, GTWidget::findWidget(os, "OP_IN_SILICO_PCR"));
123 
124     // Expected: the find buttom is disabled.
125     QWidget *findButton = GTWidget::findWidget(os, "findProductButton");
126     CHECK_SET_ERR(!findButton->isEnabled(), "Find button is enabled 1");
127 
128     // 3. Enter the forward primer "TTCGGTGATGACGGTGAAAACCTCTGACACATGCAGCT".
129     GTUtilsPcr::setPrimer(os, U2Strand::Direct, "TTCGGTGATGACGGTGAAAACCTCTGACACATGCAGCT");
130 
131     // Expected: the find buttom is disabled.
132     CHECK_SET_ERR(!findButton->isEnabled(), "Find button is enabled 2");
133 
134     // 4. Enter the reverse primer "GTGACCTTGGATGACAATAGGTTCCAAGGCTC".
135     GTUtilsPcr::setPrimer(os, U2Strand::Complementary, "GTGACCTTGGATGACAATAGGTTCCAAGGCTC");
136 
137     // Expected: the find buttom is enabled.
138     CHECK_SET_ERR(findButton->isEnabled(), "Find button is disabled");
139 
140     // 5. Clear the forward primer.
141     GTUtilsPcr::setPrimer(os, U2Strand::Direct, "");
142 
143     // Expected: the find buttom is disabled.
144     CHECK_SET_ERR(!findButton->isEnabled(), "Find button is enabled 3");
145 }
146 
GUI_TEST_CLASS_DEFINITION(test_0004)147 GUI_TEST_CLASS_DEFINITION(test_0004) {
148     GTUtilsPcr::clearPcrDir(os);
149     // Products table:
150     //     Availability of the extract button
151     //     Extract product result
152     //     Double click
153 
154     // 1. Open "_common_data/fasta/pcr_test.fa".
155     GTFileDialog::openFile(os, testDir + "_common_data/fasta", "pcr_test.fa");
156     GTUtilsTaskTreeView::waitTaskFinished(os);
157 
158     // 2. Open the PCR OP.
159     GTWidget::click(os, GTWidget::findWidget(os, "OP_IN_SILICO_PCR"));
160 
161     // 3. Enter the primers: "TTCGGTGATGACGGTGAAAACCTCTGACACATGCAGCT" and "GTGACCTTGGATGACAATAGGTTCCAAGGCTC".
162     GTUtilsPcr::setPrimer(os, U2Strand::Direct, "TTCGGTGATGACGGTGAAAACCTCTGACACATGCAGCT");
163     GTUtilsPcr::setPrimer(os, U2Strand::Complementary, "GTGACCTTGGATGACAATAGGTTCCAAGGCTC");
164 
165     // 4. Click the find button.
166     GTWidget::click(os, GTWidget::findWidget(os, "findProductButton"));
167     GTUtilsTaskTreeView::waitTaskFinished(os);
168 
169     // Expected: the product table is shown with one result [9..1196].
170     CHECK_SET_ERR(1 == GTUtilsPcr::productsCount(os), "Wrong results count");
171     CHECK_SET_ERR("9 - 1196" == GTUtilsPcr::getResultRegion(os, 0), "Wrong result");
172 
173     // 5. Click the result.
174     GTMouseDriver::moveTo(GTUtilsPcr::getResultPoint(os, 0));
175     GTMouseDriver::click();
176 
177     // Expected: the extract button is enabled.
178     QWidget *extractButton = GTWidget::findWidget(os, "extractProductButton");
179     CHECK_SET_ERR(extractButton->isEnabled(), "Extract button is disabled");
180 
181     // 6. Click the empty place of the table.
182     QPoint emptyPoint = QPoint(GTUtilsPcr::getResultPoint(os, 0));
183     emptyPoint.setY(emptyPoint.y() + 30);
184     GTMouseDriver::moveTo(emptyPoint);
185     GTMouseDriver::click();
186 
187     // Expected: the extract button is disabled.
188     CHECK_SET_ERR(!extractButton->isEnabled(), "Extract button is enabled");
189 
190     // 7. Double click the result.
191     GTMouseDriver::moveTo(GTUtilsPcr::getResultPoint(os, 0));
192     GTMouseDriver::doubleClick();
193 
194     // Expected: the new file is opened "pIB2-SEC13_9-1196.gb".
195     GTUtilsTaskTreeView::waitTaskFinished(os);
196     GTUtilsProjectTreeView::findIndex(os, "pIB2-SEC13_9-1196.gb");
197 
198     // TODO: remove it after fixing UGENE-3657
199     GTKeyboardDriver::keyClick('w', Qt::ControlModifier);
200 }
201 
GUI_TEST_CLASS_DEFINITION(test_0005)202 GUI_TEST_CLASS_DEFINITION(test_0005) {
203     GTUtilsPcr::clearPcrDir(os);
204     // Products table:
205     //     Sequence view selection
206     //     Extract several products result
207 
208     // 1. Open "_common_data/fasta/pcr_test.fa".
209     GTFileDialog::openFile(os, testDir + "_common_data/fasta", "pcr_test.fa");
210     GTUtilsTaskTreeView::waitTaskFinished(os);
211 
212     // 2. Open the PCR OP.
213     GTWidget::click(os, GTWidget::findWidget(os, "OP_IN_SILICO_PCR"));
214 
215     // 3. Enter the primers: "CGCGCGTTTCGGTGA" with 0 mismatched and "CGGCATCCGCTTACAGAC" with 6.
216     GTUtilsPcr::setPrimer(os, U2Strand::Direct, "CGCGCGTTTCGGTGA");
217     GTUtilsPcr::setPrimer(os, U2Strand::Complementary, "CGGCATCCGCTTACAGAC");
218     GTUtilsPcr::setMismatches(os, U2Strand::Complementary, 6);
219     GTUtilsPcr::setPerfectMatch(os, 0);
220 
221     // 4. Click the find button.
222     GTWidget::click(os, GTWidget::findWidget(os, "findProductButton"));
223     GTUtilsTaskTreeView::waitTaskFinished(os);
224 
225     // Expected: the product table is shown with three results.
226     CHECK_SET_ERR(3 == GTUtilsPcr::productsCount(os), "Wrong results count");
227 
228     // 5. Click the 3rd result.
229     GTMouseDriver::moveTo(GTUtilsPcr::getResultPoint(os, 2));
230     GTMouseDriver::click();
231 
232     // Expected: the sequence selection is [2..3775].
233     //  TODO
234 
235     // 6. Click the 2nd result with CTRL pressed.
236     GTMouseDriver::moveTo(GTUtilsPcr::getResultPoint(os, 1));
237     GTKeyboardDriver::keyPress(Qt::Key_Control);
238     GTMouseDriver::click();
239     GTKeyboardDriver::keyRelease(Qt::Key_Control);
240 
241     // Expected: the sequence selection is not changed, two results are selected in the table.
242     //  TODO
243 
244     // 7. Click the extract button.
245     GTWidget::click(os, GTWidget::findWidget(os, "extractProductButton"));
246 
247     // Expected: two new files are opened "pIB2-SEC13_2-133.gb" and "pIB2-SEC13_2-3775.gb".
248     GTUtilsTaskTreeView::waitTaskFinished(os);
249     GTUtilsProjectTreeView::findIndex(os, "pIB2-SEC13_2-133.gb");
250     GTUtilsProjectTreeView::findIndex(os, "pIB2-SEC13_2-3775.gb");
251 
252     // TODO: remove it after fixing UGENE-3657
253     GTKeyboardDriver::keyClick('w', Qt::ControlModifier);
254     GTKeyboardDriver::keyClick('w', Qt::ControlModifier);
255     GTKeyboardDriver::keyClick('w', Qt::ControlModifier);
256 }
257 
GUI_TEST_CLASS_DEFINITION(test_0006)258 GUI_TEST_CLASS_DEFINITION(test_0006) {
259     GTUtilsPcr::clearPcrDir(os);
260     // Primers pair warning and details dialog
261 
262     // 1. Open "_common_data/fasta/pcr_test.fa".
263     GTFileDialog::openFile(os, testDir + "_common_data/fasta", "pcr_test.fa");
264     GTUtilsTaskTreeView::waitTaskFinished(os);
265 
266     // 2. Open the PCR OP.
267     GTWidget::click(os, GTWidget::findWidget(os, "OP_IN_SILICO_PCR"));
268 
269     // 3. Enter the forward primer "AGACTCTTTCGTCTCACGCACTTCGCTGATA".
270     GTUtilsPcr::setPrimer(os, U2Strand::Direct, "AGACTCTTTCGTCTCACGCACTTCGCTGATA");
271 
272     // Expected: primer warning is hidden.
273     QWidget *warning = GTWidget::findWidget(os, "warningLabel");
274     CHECK_SET_ERR(!warning->isVisible(), "Primer warning is visible");
275 
276     // 4. Enter the reverse primer  and "TGACCGTCTCAGGAGGTGGTTGTGTCAGAGGTTTT".
277     GTUtilsPcr::setPrimer(os, U2Strand::Complementary, "TGACCGTCTCAGGAGGTGGTTGTGTCAGAGGTTTT");
278 
279     // Expected: primer warning is shown, the find button text is "Find product(s) anyway".
280     QAbstractButton *findButton = dynamic_cast<QAbstractButton *>(GTWidget::findWidget(os, "findProductButton"));
281     CHECK_SET_ERR(warning->isVisible(), "Primer warning is not visible");
282     CHECK_SET_ERR(findButton->text() == "Find product(s) anyway", "Wrong find button text 1");
283 
284     // 5. Click "Show details".
285     // Expected: the details dialog is shown, the GC note of the forward primer is red.
286     GTUtilsDialog::waitForDialog(os, new PrimersDetailsDialogFiller(os));
287     GTMouseDriver::moveTo(GTUtilsPcr::getDetailsPoint(os));
288     GTMouseDriver::click();
289 
290     // 6. Remove the last character of the forward primer.
291     GTUtilsPcr::setPrimer(os, U2Strand::Direct, "AGACTCTTTCGTCTCACGCACTTCGCTGAT");
292     // Expected: the warning is hidden, the find button text is "Find product(s)".
293     CHECK_SET_ERR(!warning->isVisible(), "Primer warning is visible");
294     CHECK_SET_ERR(findButton->text() == "Find product(s)", "Wrong find button text 2");
295 }
296 
GUI_TEST_CLASS_DEFINITION(test_0007)297 GUI_TEST_CLASS_DEFINITION(test_0007) {
298     GTUtilsPcr::clearPcrDir(os);
299     // Algorithm parameters:
300     //     Mismatches
301     //     Product size
302 
303     // 1. Open "_common_data/fasta/pcr_test.fa".
304     GTFileDialog::openFile(os, testDir + "_common_data/fasta", "pcr_test.fa");
305     GTUtilsTaskTreeView::waitTaskFinished(os);
306 
307     // 2. Open the PCR OP.
308     GTWidget::click(os, GTWidget::findWidget(os, "OP_IN_SILICO_PCR"));
309 
310     // 3. Enter the primers: "CGCGCGTTTCGGTGA" and "CGGCATCCGCTTACAGAC".
311     GTUtilsPcr::setPrimer(os, U2Strand::Direct, "CGCGCGTTTCGGTGA");
312     GTUtilsPcr::setPrimer(os, U2Strand::Complementary, "CGGCATCCGCTTACAGAC");
313 
314     // 4. Click the find button.
315     GTWidget::click(os, GTWidget::findWidget(os, "findProductButton"));
316     GTUtilsTaskTreeView::waitTaskFinished(os);
317 
318     // Expected: the product table is shown with one result.
319     CHECK_SET_ERR(1 == GTUtilsPcr::productsCount(os), "Wrong results count");
320 
321     // 5. Set the reverse mismatches: 6. Click the find button.
322     GTUtilsPcr::setMismatches(os, U2Strand::Complementary, 6);
323     GTUtilsPcr::setPerfectMatch(os, 0);
324     GTWidget::click(os, GTWidget::findWidget(os, "findProductButton"));
325     GTUtilsTaskTreeView::waitTaskFinished(os);
326 
327     // Expected: there are 3 results in the table.
328     CHECK_SET_ERR(3 == GTUtilsPcr::productsCount(os), "Wrong results count");
329 
330     // 6. Set the maximum product size: 3773. Click the find button.
331     GTUtilsPcr::setMaxProductSize(os, 3773);
332     GTWidget::click(os, GTWidget::findWidget(os, "findProductButton"));
333     GTUtilsTaskTreeView::waitTaskFinished(os);
334 
335     // Expected: there are 2 results in the table.
336     CHECK_SET_ERR(2 == GTUtilsPcr::productsCount(os), "Wrong results count");
337 }
338 
GUI_TEST_CLASS_DEFINITION(test_0008)339 GUI_TEST_CLASS_DEFINITION(test_0008) {
340     GTUtilsPcr::clearPcrDir(os);
341     // Circular sequences
342 
343     // 1. Open "_common_data/fasta/pcr_test.fa".
344     GTFileDialog::openFile(os, testDir + "_common_data/fasta", "pcr_test.fa");
345     GTUtilsTaskTreeView::waitTaskFinished(os);
346 
347     // 2. Open the PCR OP.
348     GTWidget::click(os, GTWidget::findWidget(os, "OP_IN_SILICO_PCR"));
349 
350     // 3. Enter the primers: "AGGCCCTTTCGTCTCGCGCGTTTCGGTGATG" and "TGACCGTCTCCGGGAGCTGCATGTGTCAGAGGTTTT".
351     GTUtilsPcr::setPrimer(os, U2Strand::Direct, "AGGCCCTTTCGTCTCGCGCGTTTCGGTGATG");
352     GTUtilsPcr::setPrimer(os, U2Strand::Complementary, "TGACCGTCTCCGGGAGCTGCATGTGTCAGAGGTTTT");
353 
354     // 4. Click the find button.
355     GTWidget::click(os, GTWidget::findWidget(os, "findProductButton"));
356     GTUtilsTaskTreeView::waitTaskFinished(os);
357 
358     // Expected: no results found.
359     CHECK_SET_ERR(0 == GTUtilsPcr::productsCount(os), "Wrong results count 1");
360 
361     // 5. Right click on the sequence object in the project view -> Mark as circular.
362     GTMouseDriver::moveTo(GTUtilsProjectTreeView::getItemCenter(os, "pIB2-SEC13"));
363     GTUtilsDialog::waitForDialog(os, new PopupChooserByText(os, QStringList() << "Mark as circular"));
364     GTMouseDriver::click(Qt::RightButton);
365 
366     // 6. Click the find button.
367     GTWidget::click(os, GTWidget::findWidget(os, "findProductButton"));
368     GTUtilsTaskTreeView::waitTaskFinished(os);
369 
370     // Expected: one result found that goes through the 0 position [7223-60].
371     CHECK_SET_ERR(1 == GTUtilsPcr::productsCount(os), "Wrong results count 2");
372     CHECK_SET_ERR("7223 - 60" == GTUtilsPcr::getResultRegion(os, 0), "Wrong result");
373 }
374 
GUI_TEST_CLASS_DEFINITION(test_0009)375 GUI_TEST_CLASS_DEFINITION(test_0009) {
376     GTUtilsPcr::clearPcrDir(os);
377     // Algorithm parameters:
378     //     3' perfect match
379     // 1. Open "_common_data/fasta/pcr_test.fa".
380     GTFileDialog::openFile(os, testDir + "_common_data/fasta", "pcr_test.fa");
381     GTUtilsTaskTreeView::waitTaskFinished(os);
382 
383     // 2. Open the PCR OP.
384     GTWidget::click(os, GTWidget::findWidget(os, "OP_IN_SILICO_PCR"));
385 
386     // 3. Enter the primers: "CGCGCGTTTCGGTGA" and "CGACATCCGCTTACAGAC".
387     GTUtilsPcr::setPrimer(os, U2Strand::Direct, "CGCGCGTTTCGGTGA");
388     GTUtilsPcr::setPrimer(os, U2Strand::Complementary, "CGACATCCGCTTACAGAC");
389 
390     // 4. Set the reverse mismatches: 1.
391     GTUtilsPcr::setMismatches(os, U2Strand::Complementary, 1);
392 
393     // 5. Click the find button.
394     GTWidget::click(os, GTWidget::findWidget(os, "findProductButton"));
395     GTUtilsTaskTreeView::waitTaskFinished(os);
396 
397     // Expected: the product table is shown with one result.
398     CHECK_SET_ERR(1 == GTUtilsPcr::productsCount(os), "Wrong results count 1");
399 
400     // 6. Set the 3' perfect match: 16.
401     QSpinBox *perfectSpinBox = dynamic_cast<QSpinBox *>(GTWidget::findWidget(os, "perfectSpinBox"));
402     GTSpinBox::setValue(os, perfectSpinBox, 16, GTGlobals::UseKeyBoard);
403 
404     // 7. Click the find button.
405     GTWidget::click(os, GTWidget::findWidget(os, "findProductButton"));
406     GTUtilsTaskTreeView::waitTaskFinished(os);
407 
408     // Expected: there are no results in the table.
409     CHECK_SET_ERR(0 == GTUtilsPcr::productsCount(os), "Wrong results count 2");
410 }
411 
GUI_TEST_CLASS_DEFINITION(test_0010)412 GUI_TEST_CLASS_DEFINITION(test_0010) {
413     // Export annotations
414     // 1. Open "_common_data/cmdline/pcr/begin-end.gb".
415     GTFileDialog::openFile(os, testDir + "_common_data/cmdline/pcr/begin-end.gb");
416     GTUtilsSequenceView::checkSequenceViewWindowIsActive(os);
417 
418     // 2. Open the PCR OP.
419     GTWidget::click(os, GTWidget::findWidget(os, "OP_IN_SILICO_PCR"));
420 
421     // 3. Enter the forward primer "GGGCCAAACAGGATATCTGTGGTAAGCAGT".
422     GTUtilsPcr::setPrimer(os, U2Strand::Direct, "GGGCCAAACAGGATATCTGTGGTAAGCAGT");
423 
424     // 4. Enter the reverse primer  and "AAGCGCGCGAACAGAAGCGAGAAGCGAACT".
425     GTUtilsPcr::setPrimer(os, U2Strand::Complementary, "AAGCGCGCGAACAGAAGCGAGAAGCGAACT");
426 
427     // 5. Click "Find product(s) anyway".
428     GTWidget::click(os, GTWidget::findWidget(os, "findProductButton"));
429     GTUtilsTaskTreeView::waitTaskFinished(os);
430 
431     // Expected: one product is found.
432     CHECK_SET_ERR(GTUtilsPcr::productsCount(os) == 1, "Wrong results count");
433 
434     // 6. Choose "Inner" annotation extraction.
435     QComboBox *annsComboBox = qobject_cast<QComboBox *>(GTWidget::findWidget(os, "annsComboBox"));
436     GTComboBox::selectItemByIndex(os, annsComboBox, 1);
437 
438     // 7. Click "Export product(s)".
439     QWidget *extractPB = GTWidget::findWidget(os, "extractProductButton");
440     GTUtilsNotifications::waitAllNotificationsClosed(os);
441     GTWidget::click(os, extractPB);
442     GTUtilsTaskTreeView::waitTaskFinished(os);
443 
444     // Expected: there are 3 annotations in the exported document: 2 primers and center 51..150.
445     CHECK_SET_ERR(GTUtilsAnnotationsTreeView::findItem(os, "middle", GTGlobals::FindOptions(false)) == nullptr, "Unexpected annotation 1");
446     CHECK_SET_ERR("complement(51..150)" == GTUtilsAnnotationsTreeView::getAnnotationRegionString(os, "center"), "Wrong region 1");
447 
448     // 8. Choose "All annotations" annotation extraction.
449     GTUtilsProjectTreeView::doubleClickItem(os, "begin-end.gb");
450     GTUtilsMdi::checkWindowIsActive(os, "begin-end");
451     GTComboBox::selectItemByIndex(os, annsComboBox, 0);
452 
453     // 9. Click "Export product(s)".
454     extractPB = GTWidget::findWidget(os, "extractProductButton");
455     GTUtilsNotifications::waitAllNotificationsClosed(os);
456     GTWidget::click(os, extractPB);
457     GTUtilsTaskTreeView::waitTaskFinished(os);
458 
459     // Expected: there are 4 annotations in the exported document: 2 primers, center 51..150 and middle 1..200. Middle has the warning qualifier.
460     CHECK_SET_ERR(GTUtilsAnnotationsTreeView::getAnnotationRegionString(os, "middle") == "1..200", "Wrong region 2");
461     CHECK_SET_ERR(GTUtilsAnnotationsTreeView::getAnnotationRegionString(os, "center") == "complement(51..150)", "Wrong region 3");
462 
463     // 10. Choose "None" annotation extraction.
464     GTUtilsProjectTreeView::doubleClickItem(os, "begin-end.gb");
465     GTUtilsMdi::checkWindowIsActive(os, "begin-end");
466     GTComboBox::selectItemByIndex(os, annsComboBox, 2);
467 
468     // 11. Click "Export product(s)".
469     extractPB = GTWidget::findWidget(os, "extractProductButton");
470     GTUtilsNotifications::waitAllNotificationsClosed(os);
471     GTWidget::click(os, extractPB);
472     GTUtilsTaskTreeView::waitTaskFinished(os);
473 
474     // Expected: there are only 2 primers annotations in the exported document.
475     CHECK_SET_ERR(GTUtilsAnnotationsTreeView::findItem(os, "middle", GTGlobals::FindOptions(false)) == nullptr, "Unexpected annotation 2");
476     CHECK_SET_ERR(GTUtilsAnnotationsTreeView::findItem(os, "center", GTGlobals::FindOptions(false)) == nullptr, "Unexpected annotation 3");
477 }
478 
GUI_TEST_CLASS_DEFINITION(test_0011)479 GUI_TEST_CLASS_DEFINITION(test_0011) {
480     // The temperature label for one primer
481     GTUtilsPcr::clearPcrDir(os);
482 
483     // 1. Open "_common_data/fasta/pcr_test.fa"
484     GTFileDialog::openFile(os, testDir + "_common_data/fasta", "pcr_test.fa");
485     GTUtilsTaskTreeView::waitTaskFinished(os);
486 
487     // 2. Open the PCR OP
488     GTUtilsOptionPanelSequenceView::openTab(os, GTUtilsOptionPanelSequenceView::InSilicoPcr);
489 
490     // 3. Enter the primer "TTNGGTGATGWCGGTGAAARCCTCTGACMCATGCAGCT"
491     GTUtilsPcr::setPrimer(os, U2Strand::Direct, "TTNGGTGATGWCGGTGAAARCCTCTGACMCATGCAGCT");
492 
493     // Expected: the temperature label contains the correct temperature, because the sequence has only one suitable region
494     CHECK_SET_ERR(!GTUtilsPcr::getPrimerInfo(os, U2Strand::Direct).contains("N/A"), "The temperature is not configured")
495 
496     // 4. Clear the primer line edit
497     GTUtilsPcr::setPrimer(os, U2Strand::Direct, "");
498 
499     // Expected: the temperature label is empty
500     CHECK_SET_ERR(GTUtilsPcr::getPrimerInfo(os, U2Strand::Direct).isEmpty(), "The temperature was not updated");
501 
502     // 5. Enter the primer "TTCGGTS"
503     GTUtilsPcr::setPrimer(os, U2Strand::Direct, "TTCGGTS");
504     // Expected: the temperature is N/A, because the sequence contains a few regions that correspond to the primer
505     CHECK_SET_ERR(GTUtilsPcr::getPrimerInfo(os, U2Strand::Direct).contains("N/A"), "The temperature is not configured");
506 }
507 
GUI_TEST_CLASS_DEFINITION(test_0012)508 GUI_TEST_CLASS_DEFINITION(test_0012) {
509     // The warning messages for the primer pair
510     GTUtilsPcr::clearPcrDir(os);
511 
512     // 1. Open "_common_data/fasta/begin-end.fa"
513     GTFileDialog::openFile(os, testDir + "_common_data/cmdline/pcr/begin-end.gb");
514     GTUtilsTaskTreeView::waitTaskFinished(os);
515 
516     // 2. Open the PCR OP
517     GTUtilsOptionPanelSequenceView::openTab(os, GTUtilsOptionPanelSequenceView::InSilicoPcr);
518 
519     // 3. Enter the forward primer "KGGCCAHACAGRATATCTSTGGTAAGCAGT"
520     GTUtilsPcr::setPrimer(os, U2Strand::Direct, "KGGCCAHACAGRATATCTSTGGTAAGCAGT");
521 
522     // Expected: the temperature is defined
523     CHECK_SET_ERR(!GTUtilsPcr::getPrimerInfo(os, U2Strand::Direct).contains("N/A"), "The temperature is not configured");
524 
525     // 4. Clear the reverse primer "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNR"
526     GTUtilsPcr::setPrimer(os, U2Strand::Complementary, "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNR");
527 
528     // Expected: the temperature is N/A, the primer pair info contains the message about non-ACGTN symbols
529     CHECK_SET_ERR(GTUtilsPcr::getPrimerInfo(os, U2Strand::Complementary).contains("N/A"), "The temperature is configured");
530 
531     QLabel *warningLabel = qobject_cast<QLabel *>(GTWidget::findWidget(os, "warningLabel"));
532     CHECK_SET_ERR(warningLabel != nullptr, "Cannot find warningLabel");
533     CHECK_SET_ERR(warningLabel->text().contains("The primers contain a character from the Extended DNA alphabet."), "Incorrect warning message");
534 }
535 
GUI_TEST_CLASS_DEFINITION(test_0013)536 GUI_TEST_CLASS_DEFINITION(test_0013) {
537     // Find the product with degenerated primers
538     GTUtilsPcr::clearPcrDir(os);
539 
540     // 1. Open "_common_data/fasta/pcr_test.fa"
541     GTFileDialog::openFile(os, testDir + "_common_data/fasta", "pcr_test.fa");
542     GTUtilsTaskTreeView::waitTaskFinished(os);
543 
544     // 2. Open the PCR OP
545     GTUtilsOptionPanelSequenceView::openTab(os, GTUtilsOptionPanelSequenceView::InSilicoPcr);
546 
547     // 3. Enter the forward primer "TTNGGTGATGWCGGTGAAARCCTCTGACMCATGCAGCT"
548     GTUtilsPcr::setPrimer(os, U2Strand::Direct, "TTNGGTGATGWCGGTGAAARCCTCTGACMCATGCAGCT");
549 
550     // Expected: the temperature label contains the correct temperature, because the sequence has only one suitable region
551     CHECK_SET_ERR(!GTUtilsPcr::getPrimerInfo(os, U2Strand::Direct).contains("N/A"), "The temperature is not configured");
552 
553     // 4. Enter the reverse primer "GBGNCCTTGGATGACAATVGGTTCCAAGRCTC"
554     GTUtilsPcr::setPrimer(os, U2Strand::Complementary, "GBGNCCTTGGATGACAATVGGTTCCAAGRCTC");
555 
556     // Expected: the temperature label contains the correct temperature, because the sequence has only one suitable region
557     CHECK_SET_ERR(!GTUtilsPcr::getPrimerInfo(os, U2Strand::Complementary).contains("N/A"), "The temperature is not configured");
558 
559     // 5. Find product
560     GTWidget::click(os, GTWidget::findWidget(os, "findProductButton"));
561     GTUtilsTaskTreeView::waitTaskFinished(os);
562 
563     // Expected: one product is found
564     CHECK_SET_ERR(1 == GTUtilsPcr::productsCount(os), "Wrong results count");
565     CHECK_SET_ERR("9 - 1196" == GTUtilsPcr::getResultRegion(os, 0), "Wrong result");
566 }
567 
GUI_TEST_CLASS_DEFINITION(test_0014)568 GUI_TEST_CLASS_DEFINITION(test_0014) {
569     // Reverse-complement for the extended DNA alphabet
570     // 1. Open the PCT OP
571     // 2. Enter all symbols of extended DNA alphabet: "ACGTMRWSYKVHDBNX"
572     // 3. Click "Reverse-complement" button
573     // Expected state: the content of primer line edit is "XNVHDBMRSWYKACGT"
574     GTUtilsPcr::clearPcrDir(os);
575 
576     GTFileDialog::openFile(os, testDir + "_common_data/fasta", "pcr_test.fa");
577     GTUtilsTaskTreeView::waitTaskFinished(os);
578 
579     GTUtilsOptionPanelSequenceView::openTab(os, GTUtilsOptionPanelSequenceView::InSilicoPcr);
580 
581     GTUtilsPcr::setPrimer(os, U2Strand::Direct, "ACGTMRWSYKVHDBNX");
582 
583     GTWidget::click(os, GTWidget::findWidget(os, "reverseComplementButton", GTUtilsPcr::primerBox(os, U2Strand::Direct)));
584 
585     QLineEdit *primerLineEdit = GTWidget::findExactWidget<QLineEdit *>(os, "primerEdit", GTUtilsPcr::primerBox(os, U2Strand::Direct));
586     CHECK_SET_ERR(primerLineEdit != nullptr, "Forward primerEdit is NULL");
587 
588     CHECK_SET_ERR(primerLineEdit->text() == "XNVHDBMRSWYKACGT", "Incorrect reverse-complement primer translation");
589 }
590 
GUI_TEST_CLASS_DEFINITION(test_0015)591 GUI_TEST_CLASS_DEFINITION(test_0015) {
592     // Degenerated character in perfect match region
593 
594     // 1. Open murine.gb
595     GTUtilsPcr::clearPcrDir(os);
596     GTFileDialog::openFile(os, dataDir + "samples/Genbank/", "murine.gb");
597     GTUtilsTaskTreeView::waitTaskFinished(os);
598 
599     // 2. Go to the PCR OP tab and add primers:
600     //    Forward: ACCCGTAGGTGGCAAGCTAGCTTAA
601     //    Reverse: TTTTCTATTCTCAGTTATGTATTTTT
602     GTUtilsOptionPanelSequenceView::openTab(os, GTUtilsOptionPanelSequenceView::InSilicoPcr);
603     GTUtilsPcr::setPrimer(os, U2Strand::Direct, "ACCCGTAGGTGGCAAGCTAGCTTAA");
604     GTUtilsPcr::setPrimer(os, U2Strand::Complementary, "TTTTCTATTCTCAGTTATGTATTTTT");
605 
606     // 3. Find products
607     //    Expected state: there are two results
608     GTWidget::click(os, GTWidget::findWidget(os, "findProductButton"));
609     GTUtilsTaskTreeView::waitTaskFinished(os);
610     CHECK_SET_ERR(2 == GTUtilsPcr::productsCount(os), "Wrong results count 1");
611 
612     // 4. Replace reverse primer with TTTTCTATTCTCAGTTATGTATTTTA
613     GTUtilsPcr::setPrimer(os, U2Strand::Complementary, "TTTTCTATTCTCAGTTATGTATTTTA");
614 
615     // 5. Set mismatches to 1
616     GTUtilsPcr::setMismatches(os, U2Strand::Complementary, 1);
617 
618     // 6. Find products
619     //    Expected state: there no products because the mismatch is located in 'Perfect Match' area
620     GTWidget::click(os, GTWidget::findWidget(os, "findProductButton"));
621     GTUtilsTaskTreeView::waitTaskFinished(os);
622     CHECK_SET_ERR(0 == GTUtilsPcr::productsCount(os), "Wrong results count 2");
623 
624     // 7. Replace reverse primer with ATTTCTATTCTCAGTTATGTATTTTW
625     GTUtilsPcr::setPrimer(os, U2Strand::Complementary, "ATTTCTATTCTCAGTTATGTATTTTW");
626 
627     // 8. Find products
628     //    Expected state: there are two results, because W= {A, T}
629     GTWidget::click(os, GTWidget::findWidget(os, "findProductButton"));
630     GTUtilsTaskTreeView::waitTaskFinished(os);
631     CHECK_SET_ERR(2 == GTUtilsPcr::productsCount(os), "Wrong results count 3");
632 }
633 
GUI_TEST_CLASS_DEFINITION(test_0016)634 GUI_TEST_CLASS_DEFINITION(test_0016) {
635     // Gaps are not allowed for primers
636     // 1. Open murine.gb
637     GTUtilsPcr::clearPcrDir(os);
638     GTFileDialog::openFile(os, dataDir + "samples/Genbank/", "murine.gb");
639     GTUtilsTaskTreeView::waitTaskFinished(os);
640 
641     // 2. Go to the PCR OP tab
642     GTUtilsOptionPanelSequenceView::openTab(os, GTUtilsOptionPanelSequenceView::InSilicoPcr);
643 
644     // 3. Try to input gap symbol '-'
645     GTUtilsPcr::setPrimer(os, U2Strand::Direct, "---");
646 
647     // Expected state: '-' pressing is ignored
648     QLineEdit *primerEdit = dynamic_cast<QLineEdit *>(GTWidget::findWidget(os, "primerEdit", GTUtilsPcr::primerBox(os, U2Strand::Direct)));
649     CHECK_SET_ERR(primerEdit != nullptr, "Cannot find primer line edit");
650     CHECK_SET_ERR(primerEdit->text().isEmpty(), "There are unexpected characters in PrimerLineEdit");
651 }
652 
GUI_TEST_CLASS_DEFINITION(test_0017)653 GUI_TEST_CLASS_DEFINITION(test_0017) {
654     // Reverse-complement for the extended DNA alphabet
655     // 1. Open the PCT OP
656     // 2. Enter primer with whitespaces
657     // Expected state: whitespaces removed successfuly
658     GTUtilsPcr::clearPcrDir(os);
659 
660     GTFileDialog::openFile(os, testDir + "_common_data/fasta", "pcr_test.fa");
661     GTUtilsTaskTreeView::waitTaskFinished(os);
662 
663     GTUtilsOptionPanelSequenceView::openTab(os, GTUtilsOptionPanelSequenceView::InSilicoPcr);
664 
665     QLineEdit *primerEdit = dynamic_cast<QLineEdit *>(GTWidget::findWidget(os, "primerEdit", GTWidget::findWidget(os, "forwardPrimerBox")));
666     GTLineEdit::setText(os, primerEdit, "AC\r\nCCTG   GAGAG\nCATCG\tAT", true, true);
667 
668     CHECK_SET_ERR(primerEdit->text() == "ACCCTGGAGAGCATCGAT", "Incorrect whitespaces removing");
669 }
670 
671 }  // namespace GUITest_common_scenarios_in_silico_pcr
672 }  // namespace U2
673