48 #include <wx/msw/winundef.h>
51 #include <wx/numdlg.h>
86 void OnCloseWindow(wxCloseEvent& event);
87 void OnButton(wxCommandEvent& event);
111 BlockMultipleAlignment::UngappedAlignedBlockList::const_iterator
112 m, me = multipleABlocks.end(), p, pe = pairwiseABlocks.end();
113 const Block::Range *multipleRangeMaster, *pairwiseRangeMaster, *pairwiseRangeDependent;
115 for (
i=0, m=multipleABlocks.begin(); m!=me; ++
i, ++m) {
116 multipleRangeMaster = (*m)->GetRangeOfRow(0);
117 for (p=pairwiseABlocks.begin(); p!=pe; ++p) {
118 pairwiseRangeMaster = (*p)->GetRangeOfRow(0);
119 if (pairwiseRangeMaster->
from <= multipleRangeMaster->
from &&
120 pairwiseRangeMaster->
to >= multipleRangeMaster->
to) {
121 pairwiseRangeDependent = (*p)->GetRangeOfRow(1);
123 (multipleRangeMaster->
from - pairwiseRangeMaster->
from);
148 ERRORMSG(
"dpScoreFunction() - bad parameters: block " << block <<
" queryPos " << queryPos <<
170 unique_ptr<BlockMultipleAlignment>
175 int s, blockScoreSum = 0;
176 for (
unsigned int b=0;
b<
result->nBlocks; ++
b) {
185 bma->AddAlignedBlockAtEnd(newBlock);
188 <<
" position: " << (
result->blockPositions[
b] + 1)
192 if (blockScoreSum !=
result->score)
193 ERRORMSG(
"block aligner reported score doesn't match sum of block scores");
196 if (!bma->AddUnalignedBlocks() || !bma->UpdateBlockMapAndColors(
false)) {
197 ERRORMSG(
"Error finalizing new alignment!");
203 score.Printf(
" raw score: %i",
result->score);
204 bma->SetRowStatusLine(0,
WX_TO_STD(score));
205 bma->SetRowStatusLine(1,
WX_TO_STD(score));
208 return bma.release();
215 newAlignments->clear();
216 *nRowsAddedToMultiple = 0;
221 ERRORMSG(
"merge selected but NULL sequenceViewer");
225 unsigned int nAln = toRealign.size(),
a = 0;
230 ERRORMSG(
"Must have at least one aligned block to use the block aligner");
236 unique_ptr < ProgressMeter > progress;
238 long u = wxGetNumberFromUser(
"How many sequences do you want to realign?",
"Max:",
"Alignments...", nAln, 1, nAln,
NULL);
241 nAln = (
unsigned int) u;
243 progress.reset(
new ProgressMeter(
NULL,
"Running block alignment...",
"Working", nAln));
246 BlockMultipleAlignment::UngappedAlignedBlockList::const_iterator
b, be =
blocks.end();
251 unsigned int *loopLengths =
new unsigned int[multiple->
NRows()];
252 BlockMultipleAlignment::UngappedAlignedBlockList::const_iterator
n;
255 range = (*b)->GetRangeOfRow(0);
263 for (
unsigned int r=0;
r<multiple->
NRows(); ++
r) {
264 range = (*b)->GetRangeOfRow(
r);
265 nextRange = (*n)->GetRangeOfRow(
r);
266 loopLengths[
r] = nextRange->
from -
range->to - 1;
278 bool errorsEncountered =
false;
280 AlignmentList::const_iterator s, se = toRealign.end();
281 for (s=toRealign.begin(); s!=se; ++s, ++
a) {
283 ERRORMSG(
"master sequence mismatch");
291 newAlignments->push_back(newAlignment);
296 progress->SetValue(
a);
299 dpQuery = (*s)->GetSequenceOfRow(1);
300 int startQueryPosition =
301 ((*s)->alignDependentFrom >= 0 && (*s)->alignDependentFrom < (
int)
dpQuery->
Length()) ?
302 (*s)->alignDependentFrom : 0;
303 int endQueryPosition =
304 ((*s)->alignDependentTo >= 0 && (*s)->alignDependentTo < (
int)
dpQuery->
Length()) ?
306 TRACEMSG(
"query region: " << (startQueryPosition+1) <<
" to " << (endQueryPosition+1));
323 startQueryPosition, endQueryPosition, &dpResult);
326 startQueryPosition, endQueryPosition, &dpResult);
335 ERRORMSG(
"Couldn't create BlockMultipleAlignment from DP result");
348 ++(*nRowsAddedToMultiple);
355 newAlignments->push_back(dpAlignment);
362 WARNINGMSG(
"block aligner found no significant alignment - current alignment unchanged");
363 status =
"alignment unchanged";
365 WARNINGMSG(
"block aligner encountered a problem - current alignment unchanged");
366 errorsEncountered =
true;
367 status =
"block aligner error!";
374 newAlignments->push_back(newAlignment);
387 if (progress.get()) {
388 progress->Close(
true);
394 if (errorsEncountered)
395 ERRORMSG(
"Block aligner encountered problem(s) - see message log for details");
409 bool ok = (dialog.ShowModal() == wxOK);
411 ERRORMSG(
"Error getting options from dialog!");
421 #define ID_TEXT 10000
422 #define ID_T_PERCENT 10001
423 #define ID_S_EXT 10002
424 #define ID_T_EXTENSION 10003
425 #define ID_S_PERCENT 10004
426 #define ID_T_CUTOFF 10005
427 #define ID_S_LAMBDA 10006
428 #define ID_C_GLOBAL 10007
429 #define ID_C_KEEP 10008
430 #define ID_C_MERGE 10009
431 #define ID_B_OK 10010
432 #define ID_B_CANCEL 10011
441 wxDialog(parent, -1, "Set
Block Aligner Options", wxPoint(100,100), wxDefaultSize, wxDEFAULT_DIALOG_STYLE)
443 wxPanel *panel =
new wxPanel(
this, -1);
444 wxBoxSizer *item0 =
new wxBoxSizer( wxVERTICAL );
445 wxStaticBox *item2 =
new wxStaticBox( panel, -1,
wxT(
"Block Aligner Options") );
446 wxStaticBoxSizer *item1 =
new wxStaticBoxSizer( item2, wxVERTICAL );
447 wxFlexGridSizer *item3 =
new wxFlexGridSizer( 2, 0, 0 );
448 item3->AddGrowableCol( 1 );
450 wxStaticText *item4 =
new wxStaticText( panel,
ID_TEXT,
wxT(
"Loop percentile:"), wxDefaultPosition, wxDefaultSize, 0 );
451 item3->Add( item4, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
453 0.0, 100.0, 0.1,
init.loopPercentile,
454 wxDefaultPosition, wxSize(80, SPIN_CTRL_HEIGHT), 0,
455 wxDefaultPosition, wxSize(-1, SPIN_CTRL_HEIGHT));
456 item3->Add(fpPercent->GetTextCtrl(), 0, wxALIGN_CENTRE|wxLEFT|wxTOP|wxBOTTOM, 5);
459 wxStaticText *item7 =
new wxStaticText( panel,
ID_TEXT,
wxT(
"Loop extension:"), wxDefaultPosition, wxDefaultSize, 0 );
460 item3->Add( item7, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
462 0, 100000, 10,
init.loopExtension,
463 wxDefaultPosition, wxSize(80, SPIN_CTRL_HEIGHT), 0,
464 wxDefaultPosition, wxSize(-1, SPIN_CTRL_HEIGHT));
465 item3->Add(iExtension->GetTextCtrl(), 0, wxALIGN_CENTRE|wxLEFT|wxTOP|wxBOTTOM, 5);
468 wxStaticText *item10 =
new wxStaticText( panel,
ID_TEXT,
wxT(
"Loop cutoff (0=none):"), wxDefaultPosition, wxDefaultSize, 0 );
469 item3->Add( item10, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
471 0, 100000, 0,
init.loopCutoff,
472 wxDefaultPosition, wxSize(80, SPIN_CTRL_HEIGHT), 0,
473 wxDefaultPosition, wxSize(-1, SPIN_CTRL_HEIGHT));
474 item3->Add(iCutoff->GetTextCtrl(), 0, wxALIGN_CENTRE|wxLEFT|wxTOP|wxBOTTOM, 5);
477 item3->Add( 5, 5, 0, wxALIGN_CENTRE|wxALL, 5 );
478 item3->Add( 5, 5, 0, wxALIGN_CENTRE|wxALL, 5 );
481 wxStaticText *item13 =
new wxStaticText( panel,
ID_TEXT,
wxT(
"Global alignment:"), wxDefaultPosition, wxDefaultSize, 0 );
482 item3->Add( item13, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
483 cGlobal =
new wxCheckBox( panel,
ID_C_GLOBAL,
wxT(
""), wxDefaultPosition, wxDefaultSize, 0 );
484 cGlobal->SetValue(
init.globalAlignment);
485 item3->Add( cGlobal, 0, wxALIGN_CENTRE|wxALL, 5 );
488 wxStaticText *item15 =
new wxStaticText( panel,
ID_TEXT,
wxT(
"Keep existing blocks (global only):"), wxDefaultPosition, wxDefaultSize, 0 );
489 item3->Add( item15, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
490 cKeep =
new wxCheckBox( panel,
ID_C_KEEP,
wxT(
""), wxDefaultPosition, wxDefaultSize, 0 );
491 cKeep->SetValue(
init.keepExistingBlocks);
492 item3->Add( cKeep, 0, wxALIGN_CENTRE|wxALL, 5 );
495 wxStaticText *item17 =
new wxStaticText( panel,
ID_TEXT,
wxT(
"When to merge new alignments:"), wxDefaultPosition, wxDefaultSize, 0 );
496 item3->Add( item17, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
497 wxString choices[3] = {
"No Merge",
"After Each",
"After All" };
498 cMerge =
new wxChoice( panel,
ID_C_MERGE, wxDefaultPosition, wxDefaultSize, 3, choices );
499 cMerge->SetSelection(
init.mergeType);
500 item3->Add( cMerge, 0, wxALIGN_CENTRE|wxALL, 5 );
503 item1->Add( item3, 0, wxALIGN_CENTRE, 5 );
504 item0->Add( item1, 0, wxALIGN_CENTRE|wxALL, 5 );
505 wxBoxSizer *item19 =
new wxBoxSizer( wxHORIZONTAL );
506 wxButton *item20 =
new wxButton( panel,
ID_B_OK,
wxT(
"OK"), wxDefaultPosition, wxDefaultSize, 0 );
507 item19->Add( item20, 0, wxALIGN_CENTRE|wxALL, 5 );
508 item19->Add( 20, 20, 0, wxALIGN_CENTRE|wxALL, 5 );
509 wxButton *item21 =
new wxButton( panel,
ID_B_CANCEL,
wxT(
"Cancel"), wxDefaultPosition, wxDefaultSize, 0 );
510 item19->Add( item21, 0, wxALIGN_CENTRE|wxALL, 5 );
511 item0->Add( item19, 0, wxALIGN_CENTRE|wxALL, 5 );
513 panel->SetAutoLayout(
true);
514 panel->SetSizer(item0);
517 item0->SetSizeHints(
this);
546 if (event.GetId() ==
ID_B_OK) {
User-defined methods of the data storage class.
FloatingPointSpinCtrl * fpPercent
void OnCloseWindow(wxCloseEvent &event)
IntegerSpinCtrl * iExtension
IntegerSpinCtrl * iCutoff
bool GetValues(BlockAligner::BlockAlignerOptions *options)
~BlockAlignerOptionsDialog(void)
void OnButton(wxCommandEvent &event)
bool CreateNewPairwiseAlignmentsByBlockAlignment(BlockMultipleAlignment *multiple, const AlignmentList &toRealign, AlignmentList *newAlignments, int *nRowsAddedToMultiple, SequenceViewer *sequenceViewer)
std::list< BlockMultipleAlignment * > AlignmentList
BlockAlignerOptions currentOptions
bool SetOptions(wxWindow *parent)
BlockMultipleAlignment * Clone(void) const
std::vector< const Sequence * > SequenceList
void SetRowDouble(unsigned int row, double value) const
void SetRowStatusLine(unsigned int row, const std::string &value) const
const Sequence * GetMaster(void) const
std::vector< const UngappedAlignedBlock * > UngappedAlignedBlockList
void GetUngappedAlignedBlocks(UngappedAlignedBlockList *blocks) const
unsigned int NRows(void) const
bool MergeAlignment(const BlockMultipleAlignment *newAlignment)
void SetRangeOfRow(unsigned int row, int from, int to)
bool GetDouble(double *value) const
bool GetUnsignedInteger(unsigned int *value) const
std::string ToString(void) const
const MoleculeIdentifier * identifier
unsigned int Length(void) const
AlignmentManager * alignmentManager
bool EditorIsOn(void) const
void SetDialogSevereErrors(bool status)
unique_ptr< BlockMultipleAlignment > dpMultiple
static void FreezeBlocks(const BlockMultipleAlignment *multiple, const BlockMultipleAlignment *pairwise, DP_BlockInfo *blockInfo)
int dpScoreFunction(unsigned int block, unsigned int queryPos)
static BlockMultipleAlignment * UnpackDPResult(DP_BlockInfo *blocks, DP_AlignmentResult *result, const Sequence *master, const Sequence *query)
Include a standard set of the NCBI C++ Toolkit most basic headers.
static void DLIST_NAME() init(DLIST_LIST_TYPE *list)
#define END_SCOPE(ns)
End the previously defined scope.
#define BEGIN_SCOPE(ns)
Define a new scope.
unsigned int
A callback function used to compare two keys in a database.
range(_Ty, _Ty) -> range< _Ty >
double r(size_t dimension_, const Int4 *score_, const double *prob_, double theta_)
unsigned int loopExtension
unsigned int * freezeBlocks
unsigned int * blockPositions
unsigned int * blockSizes
int DP_LocalBlockAlign(const DP_BlockInfo *blocks, DP_BlockScoreFunction BlockScore, unsigned int queryFrom, unsigned int queryTo, DP_AlignmentResult **alignment)
void DP_DestroyBlockInfo(DP_BlockInfo *blocks)
unsigned int DP_CalculateMaxLoopLength(unsigned int nLoops, const unsigned int *loopLengths, double percentile, unsigned int extension, unsigned int cutoff)
#define STRUCT_DP_FOUND_ALIGNMENT
int DP_GlobalBlockAlign(const DP_BlockInfo *blocks, DP_BlockScoreFunction BlockScore, unsigned int queryFrom, unsigned int queryTo, DP_AlignmentResult **alignment)
static const int DP_NEGATIVE_INFINITY
static const unsigned int DP_UNFROZEN_BLOCK
#define STRUCT_DP_NO_ALIGNMENT
void DP_DestroyAlignmentResult(DP_AlignmentResult *alignment)
DP_BlockInfo * DP_CreateBlockInfo(unsigned int nBlocks)
static DP_BlockInfo * blocks
unsigned char LookupNCBIStdaaNumberFromCharacter(char r)