71 "Create a Needleman-Wunsch Alignment",
72 "Generate a global alignment using the "
73 "Needleman-Wunsch algorithm",
74 "https://www.ncbi.nlm.nih.gov/tools/gbench/",
75 "Alignment Creation"),
83 return "create_needleman_wunsch_tool_manager";
89 return "Needleman-Wunsch Tool";
161 : m_Params(params), m_Done(0)
163 m_Descr =
"Creating alignments";
175 float pct_done = (100.0f /
info->m_iter_total) *
info->m_iter_done;
176 sprintf(
buf,
"%2.0lf %% completed", pct_done);
203 if (locs.size() != 2) {
205 "Algorithm acepts exactly two sequences");
211 vector<string> seq_labels;
213 typedef vector< CConstRef<CSeq_id> > TIds;
218 const CSeq_loc& loc =
dynamic_cast<const CSeq_loc&
>(loc_iter->object.GetObject());
219 CScope& scope = loc_iter->scope.GetObject();
221 new_scope.
Reset(&scope);
228 "location on multiple bioseqs ignored: " <<
str);
238 seqs.push_back(
string());
245 seq_labels.push_back(loc_str);
254 bool use_myers_miller =
false;
256 const size_t nw_limit = 200*1024*1024;
257 vector<string>::const_iterator iter_seqs = seqs.begin();
258 double dim_square = (iter_seqs++)->length();
259 dim_square *= iter_seqs->length();
260 use_myers_miller = dim_square > nw_limit;
268 const char* seq1 = seqs[0].c_str(), * seq2 = seqs[1].c_str();
269 size_t dim1 = seqs[0].size(), dim2 = seqs[1].size();
271 unique_ptr<CNWAligner> aligner;
279 if(use_myers_miller) {
281 aligner.reset(
new CMMAligner (seq1, dim1, seq2, dim2,
285 "Using Myers-Miller method");
290 aligner.reset(
new CNWAligner (seq1, dim1, seq2, dim2,
298 aligner->SetScoreMatrix(
NULL);
313 aligner->SetEndSpaceFree(left1, right1, left2, right2);
327 list< CRef<CSeq_loc> > from_locs;
329 const CSeq_loc& loc =
dynamic_cast<const CSeq_loc&
>(loc_iter->object.GetObject());
332 switch (loc.
Which()) {
343 from_locs.push_back(ref);
346 TIds::iterator seq_id_iter = seq_ids.begin();
348 align->
SetSegs().SetDenseg().SetIds()) {
349 (*iter)->Assign(**seq_id_iter++);
354 list< CRef<CSeq_loc> >::const_iterator iter1 = from_locs.begin();
356 const CSeq_loc& loc =
dynamic_cast<const CSeq_loc&
>(loc_iter->object.GetObject());
357 CScope& scope = loc_iter->scope.GetObject();
365 align = mapper.
Map(*align);
370 annot->
SetData().SetAlign().push_back(align);
374 ITERATE (vector<string>, iter, seq_labels) {
375 if ( !title.empty() ) {
381 title =
"Global alignment of " + title;
387 str =
"This alignment was produced on ";
389 str +=
" using the Needleman-Wunsch alignment algorithm";
394 annot->
SetDesc().Set().push_back(desc);
397 item->
SetItem().SetAnnot(*annot);
User-defined methods of the data storage class.
User-defined methods of the data storage class.
User-defined methods of the data storage class.
User-defined methods of the data storage class.
void SetObjects(TConstScopedObjects *objects)
CNeedlemanWunschToolParams & GetData()
virtual void SetRegistryPath(const string &path)
CAlgoToolManagerParamsPanel.
void SetData(const CNeedlemanWunschToolParams &data)
bool Create(wxWindow *parent, wxWindowID id=ID_CALIGNNEEDLEMANWUNSCHPANEL, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxSize(400, 300), long style=wxTAB_TRAVERSAL)
virtual void LoadSettings()
CAppJobProgress Default implementation for IAppJobProgress - the class encapsulates a text message an...
CCreateNeedlemanWunschJob.
CDataLoadingAppJob - a base class for Jobs loading data into projects.
void AddProjectItem(objects::CProjectItem &item)
void SetNameDesc(const string &name)
void SetCreateDate(const CTime &dt)
void AddComment(const string &comment)
IRegSettings An interface for objects that save / restore settings using CGuiRegistry.
static SQLCHAR output[256]
static const char * str(char *buf, int n)
#define ITERATE(Type, Var, Cont)
ITERATE macro to sequence through container elements.
#define NON_CONST_ITERATE(Type, Var, Cont)
Non constant version of ITERATE macro.
#define LOG_POST(message)
This macro is deprecated and it's strongly recomended to move in all projects (except tests) to macro...
#define NCBI_THROW(exception_class, err_code, message)
Generic macro to throw an exception, given the exception class, error code and message string.
void Info(CExceptionArgs_Base &args)
virtual IRegSettings * x_GetParamsAsRegSetting()
return a pointer to Parameters object as IRegSettings interface
TConstScopedObjects m_Objects
virtual CConstIRef< IAppJobProgress > GetProgress()
implement Run() in derived classes, make sure that exceptions are handled and m_StopRequested flag is...
virtual string GetExtensionIdentifier() const
returns the unique human-readable identifier for the extension the id should use lowercase letters se...
virtual CAlgoToolManagerParamsPanel * x_GetParamsPanel()
returns a pointer to the parameters panel, override in derived classes
virtual bool x_CreateParamsPanelIfNeeded()
returns / creates Parameters panel, override in derived classes see cpp file for example
CNeedlemanWunschToolParams m_Params
int GetFirstSeqFreeEnds() const
int GetMismatchCost() const
bool ProgressCallback(const string &status, float done)
virtual CDataLoadingAppJob * x_CreateLoadingJob()
factory method for creating the job that executes the tool algorithm override in derived classes
TConstScopedObjects & SetObjects()
CCreateNeedlemanWunschJob(const CNeedlemanWunschToolParams ¶ms)
CCreateNeedlemanWunschJob.
int GetSecondSeqFreeEnds() const
CCreateNeedlemanWunschToolManager()
void x_SelectCompatibleInputObjects()
select only Seq-aligns
virtual void InitUI()
override this function in a derived class and initialize extra members
int GetGapOpenCost() const
CAlignNeedlemanWunschPanel * m_Panel
int GetGapExtendCost() const
virtual string GetExtensionLabel() const
returns a displayable label for this extension ( please capitalize the key words - "My Extension" )
CNeedlemanWunschToolParams m_Params
virtual void x_CreateProjectItems()
override this function in derived classes and populate m_Items.
virtual void CleanUI()
override this function in a derived class and clean extra members
static void GetLabel(const CObject &obj, string *label, ELabelType type=eDefault)
string m_Descr
mutex to sync our internals
virtual bool IsCanceled() const override
string m_Status
Current status of the Job.
vector< SConstScopedObject > TConstScopedObjects
virtual void Assign(const CSerialObject &source, ESerialRecursionMode how=eRecursive)
Override Assign() to incorporate cache invalidation.
void SetId(CSeq_id &id)
set the 'id' field in all parts of this location
TRange GetTotalRange(void) const
const CSeq_id & GetId(const CSeq_loc &loc, CScope *scope)
If all CSeq_ids embedded in CSeq_loc refer to the same CBioseq, returns the first CSeq_id found,...
bool IsOneBioseq(const CSeq_loc &loc, CScope *scope)
Returns true if all embedded CSeq_ids represent the same CBioseq, else false.
CRef< CSeq_loc > Map(const CSeq_loc &src_loc)
Map seq-loc.
CBioseq_Handle GetBioseqHandle(const CSeq_id &id)
Get bioseq handle by seq-id.
CConstRef< CSeq_id > GetSeqId(void) const
Get id which can be used to access this bioseq handle Throws an exception if none is available.
@ eCoding_Iupac
Set coding to printable coding (Iupacna or Iupacaa)
void GetSeqData(TSeqPos start, TSeqPos stop, string &buffer) const
Fill the buffer string with the sequence data for the interval [start, stop).
bool IsNucleotide(void) const
void Reset(void)
Reset reference object.
position_type GetLength(void) const
#define END_NCBI_SCOPE
End previously defined NCBI scope.
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
static string & ToUpper(string &str)
Convert string to upper case – string& version.
string AsString(const CTimeFormat &format=kEmptyStr, TSeconds out_tz=eCurrentTimeZone) const
Transform time to string.
@ eCurrent
Use current time. See also CCurrentTime.
void SetLabel(const TLabel &value)
Assign a value to Label data member.
void SetItem(TItem &value)
Assign a value to Item data member.
TStr & SetStr(void)
Select the variant.
void SetSegs(TSegs &value)
Assign a value to Segs data member.
vector< CRef< CSeq_id > > TIds
E_Choice Which(void) const
Which variant is currently selected.
bool IsWhole(void) const
Check if variant Whole is selected.
void SetData(TData &value)
Assign a value to Data data member.
void SetDesc(TDesc &value)
Assign a value to Desc data member.
TCreate_date & SetCreate_date(void)
Select the variant.
const SNCBIPackedScoreMatrix NCBISM_Blosum62