58 #include <wx/textdlg.h>
66 bool create_xref_map =
true;
68 create_xref_map =
false;
69 return apply_impl(
objects, to_known, adjust_features, old_to_new, create_xref_map);
77 bool create_general_only =
false;
83 const CGapEdit* gap_edit =
dynamic_cast<const CGapEdit*
>((*it).object.GetPointer());
97 if (bsh_to_inst.
find(bsh) != bsh_to_inst.
end())
114 bsh_to_inst[bsh] = make_pair(new_inst,
false);
124 const CGapEdit* gap_edit =
dynamic_cast<const CGapEdit*
>((*it).object.GetPointer());
140 for (
const auto& d : diffs[bsh])
150 if (delta_i->Empty())
159 else if (seg.
IsLoc())
176 diffs[bsh][start] = diff;
182 NRawToDeltaSeq::SGap gap;
184 gap.length = delta_len;
185 gap.is_known =
false;
186 gap.is_replace =
true;
187 gaps[bsh].push_back(gap);
190 bsh_to_inst[bsh].second =
true;
220 if (!bsh_to_inst[bsh].second && new_inst->
IsSetLength())
222 diffs[bsh][start] = diff;
226 NRawToDeltaSeq::SGap gap;
228 gap.length = delta_len;
229 gap.is_known =
false;
230 gap.is_replace =
true;
231 gaps[bsh].push_back(gap);
233 bsh_to_inst[bsh].second =
true;
261 for (
const auto& it : bsh_to_inst)
265 bool modified = it.second.second;
285 wxTextEntryDialog dlg(
NULL,
_(
"Convert gaps longer or equal to"),
_(
"Convert Known Length Gaps to Unknown"),
_(
"100"));
286 dlg.SetTextValidator(wxFILTER_NUMERIC);
287 if (dlg.ShowModal() == wxID_OK)
289 wxString
val = dlg.GetValue();
291 if(
val.ToLong(&min_size))
293 CScope &scope = seh.GetScope();
311 if ( (*iter)->IsLoc() )
326 if (delta_i->Empty())
342 }
catch (
CException ) {}
catch (std::exception ) {}
358 bool create_xref_map =
true;
360 create_xref_map =
false;
368 wxTextEntryDialog dlg(
NULL,
_(
"Change length to"),
_(
"Change length of selected gaps"),
_(
"100"));
369 dlg.SetTextValidator(wxFILTER_NUMERIC);
370 if (dlg.ShowModal() == wxID_OK)
372 wxString
val = dlg.GetValue();
374 if(
val.ToLong(&new_size))
379 bool create_general_only =
false;
385 const CGapEdit* gap_edit =
dynamic_cast<const CGapEdit*
>((*it).object.GetPointer());
399 if (bsh_to_inst.
find(bsh) != bsh_to_inst.
end())
416 if ( (*iter)->IsLoc() )
427 bsh_to_inst[bsh] = make_pair(new_inst,
false);
437 const CGapEdit* gap_edit =
dynamic_cast<const CGapEdit*
>((*it).object.GetPointer());
453 for (
const auto& d : diffs[bsh])
463 if (delta_i->Empty())
472 int diff =
static_cast<int>(new_size);
476 diffs[bsh][start] = diff;
482 NRawToDeltaSeq::SGap gap;
484 gap.length =
static_cast<int>(new_size - delta_len);
486 gap.is_replace =
false;
487 gaps[bsh].push_back(gap);
490 bsh_to_inst[bsh].second =
true;
509 diff =
static_cast<int>(new_size);
515 if (!bsh_to_inst[bsh].second && new_inst->
IsSetLength())
517 diffs[bsh][start] = diff;
521 NRawToDeltaSeq::SGap gap;
523 gap.length =
static_cast<int>(new_size - delta_len);
525 gap.is_replace =
false;
526 gaps[bsh].push_back(gap);
528 bsh_to_inst[bsh].second =
true;
557 for (
const auto& it : bsh_to_inst)
561 bool modified = it.second.second;
576 for (objects::CAlign_CI align_ci(tse); align_ci; ++ align_ci)
578 const objects::CSeq_align& align = *align_ci;
580 int num_rows = align.CheckNumRows();
583 if (!align.IsSetSegs() || !align.GetSegs().IsDenseg() ||
584 !align.GetSegs().GetDenseg().IsSetStarts() || !align.GetSegs().GetDenseg().IsSetLens())
587 vector< TSignedSeqPos > starts(align.GetSegs().GetDenseg().GetStarts());
588 size_t num_segs = align.GetSegs().GetDenseg().GetLens().size();
589 for (
size_t s = 0; s < num_segs; s++)
590 for (
auto row = 0; row < num_rows; row++)
595 const CSeq_id&
id = align.GetSeq_id(row);
599 for (
const auto& d : diffs[bsh])
604 starts[num_rows * s + row] = from;
609 new_align->
SetSegs().SetDenseg().SetStarts() = starts;
610 new_align->
SetSegs().SetDenseg().TrimEndGaps();
611 new_align->
SetSegs().SetDenseg().RemovePureGapSegs();
612 new_align->
SetSegs().SetDenseg().Compact();
625 bool create_xref_map =
true;
627 create_xref_map =
false;
628 return apply_impl(seh, old_to_new, create_xref_map);
634 bool any_modified =
false;
640 bool bsh_modified =
false;
654 if ( (*iter)->IsLoc() )
667 vector<pair<int, bool> > gap_len;
672 if (delta_i->Empty())
679 gap_len.push_back(pair<int, bool> (delta_len, unknown));
683 gap_len.push_back(pair<int, bool> (0,
false));
690 CDelta_ext::Tdata::iterator delta_i = new_inst->
SetExt().SetDelta().Set().begin();
691 while(delta_i != new_inst->
SetExt().SetDelta().Set().end())
693 if (delta_i->Empty())
700 int delta_len = gap_len[
i].first;
703 delta_i = new_inst->
SetExt().SetDelta().Set().erase(delta_i);
711 bool unknown = gap_len[
i].second;
712 bool modified =
false;
713 for (
size_t j =
i + 1; j < gap_len.size(); j++)
715 if (gap_len[j].
first <= 0)
717 delta_len += gap_len[j].first;
718 unknown |= gap_len[j].second;
719 gap_len[j].first = -1;
737 NRawToDeltaSeq::SGap gap;
741 gap.is_replace =
false;
742 gaps[bsh].push_back(gap);
752 }
catch (
CException ) {}
catch (std::exception ) {}
763 auto local_cmd = composite;
766 local_cmd->Unexecute();
User-defined methods of the data storage class.
User-defined methods of the data storage class.
User-defined methods of the data storage class.
@ eExtreme_Positional
numerical value
User-defined methods of the data storage class.
User-defined methods of the data storage class.
bool IsGeneralIdProtPresent(objects::CSeq_entry_Handle tse)
void AddCommand(IEditCommand &command)
virtual void Unexecute()
Undo (opposite to Execute())
virtual void Execute()
Do the editing action.
static CRef< CCmdComposite > apply(objects::CSeq_entry_Handle seh)
static CRef< CCmdComposite > apply_impl(objects::CSeq_entry_Handle seh, map< objects::CObject_id::TId, objects::CObject_id::TId > &old_to_new, bool create_xref_map)
static CRef< CCmdComposite > apply(objects::CSeq_entry_Handle seh)
static CRef< CCmdComposite > apply_impl(const TConstScopedObjects &objects, bool to_known, bool adjust_features, map< objects::CObject_id::TId, objects::CObject_id::TId > &old_to_new, bool create_xref_map)
static CRef< CCmdComposite > apply(const TConstScopedObjects &objects, bool to_known, bool adjust_features=false)
static CRef< CCmdComposite > apply(const TConstScopedObjects &objects)
static CRef< CCmdComposite > apply_impl(const TConstScopedObjects &objects, map< objects::CObject_id::TId, objects::CObject_id::TId > &old_to_new, bool create_xref_map)
static TId s_FindHighestFeatureId(const objects::CSeq_entry_Handle &entry)
TSeqPos GetFrom(void) const
CBioseq_Handle GetBioseq_Handle() const
namespace ncbi::objects::
void AddOrReplaceQualifier(const string &qual_name, const string &qual_val)
Add a qualifier to this feature, or replace the value for the first one if it already exists.
const_iterator begin() const
const_iterator end() const
const_iterator find(const key_type &key) const
void AdjustFeatureLocations(const map< objects::CBioseq_Handle, vector< SGap >> &map_gaps, CRef< CCmdComposite > composite, bool split_gene_locations, bool break_features, bool keep_gap_length, bool create_general_only, objects::CObject_id::TId &max_feat_id, map< objects::CObject_id::TId, objects::CObject_id::TId > &old_to_new, bool create_xref_map)
USING_SCOPE(ncbi::objects)
static DLIST_TYPE *DLIST_NAME() first(DLIST_LIST_TYPE *list)
unsigned int TSeqPos
Type for sequence locations and lengths.
#define ITERATE(Type, Var, Cont)
ITERATE macro to sequence through container elements.
int TSignedSeqPos
Type for signed sequence position.
#define NON_CONST_ITERATE(Type, Var, Cont)
Non constant version of ITERATE macro.
vector< SConstScopedObject > TConstScopedObjects
virtual void Assign(const CSerialObject &source, ESerialRecursionMode how=eRecursive)
Set object to copy of another one.
TRange GetTotalRange(void) const
TSeqPos GetStart(ESeqLocExtremes ext) const
Return start and stop positions of the seq-loc.
TSeqPos GetLength(const CSeq_id &id, CScope *scope)
Get sequence length if scope not null, else return max possible TSeqPos.
CBioseq_Handle GetBioseqHandle(const CSeq_id &id)
Get bioseq handle by seq-id.
CScope & GetScope(void) const
Get scope this handle belongs to.
TSeqPos GetBioseqLength(void) const
bool IsSetInst(void) const
CSeq_entry_Handle GetTopLevelEntry(void) const
Get top level Seq-entry handle.
CSeqVector GetSeqVector(EVectorCoding coding, ENa_strand strand=eNa_strand_plus) const
Get sequence: Iupacna or Iupacaa if use_iupac_coding is true.
const TInst & GetInst(void) const
@ eCoding_Iupac
Set coding to printable coding (Iupacna or Iupacaa)
bool IsInGap(TSeqPos pos) const
true if sequence at 0-based position 'pos' has gap Note: this method is not MT-safe,...
TObjectType * GetPointer(void) THROWS_NONE
Get pointer,.
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 LongToString(long value, TNumToStringFlags flags=0, int base=10)
Convert Int to string.
static string UIntToString(unsigned int value, TNumToStringFlags flags=0, int base=10)
Convert UInt to string.
bool IsLim(void) const
Check if variant Lim is selected.
TLim GetLim(void) const
Get the variant data.
void SetSegs(TSegs &value)
Assign a value to Segs data member.
const TKey & GetKey(void) const
Get the Key member data.
bool IsSetData(void) const
the specific data Check if a value has been assigned to Data data member.
void SetLocation(TLocation &value)
Assign a value to Location data member.
bool IsImp(void) const
Check if variant Imp is selected.
bool IsSetKey(void) const
Check if a value has been assigned to Key data member.
const TLocation & GetLocation(void) const
Get the Location member data.
const TData & GetData(void) const
Get the Data member data.
const TImp & GetImp(void) const
Get the variant data.
bool IsSetLocation(void) const
feature made from Check if a value has been assigned to Location data member.
TFrom GetFrom(void) const
Get the From member data.
TTo GetTo(void) const
Get the To member data.
bool IsInt(void) const
Check if variant Int is selected.
const TInt & GetInt(void) const
Get the variant data.
TLiteral & SetLiteral(void)
Select the variant.
void SetLength(TLength value)
Assign a value to Length data member.
void SetExt(TExt &value)
Assign a value to Ext data member.
const TLiteral & GetLiteral(void) const
Get the variant data.
bool IsLoc(void) const
Check if variant Loc is selected.
bool IsSetExt(void) const
extensions for special types Check if a value has been assigned to Ext data member.
TLength GetLength(void) const
Get the Length member data.
TLength GetLength(void) const
Get the Length member data.
const TFuzz & GetFuzz(void) const
Get the Fuzz member data.
bool IsSetFuzz(void) const
could be unsure Check if a value has been assigned to Fuzz data member.
bool IsDelta(void) const
Check if variant Delta is selected.
void SetFuzz(TFuzz &value)
Assign a value to Fuzz data member.
bool IsSetLength(void) const
length of sequence in residues Check if a value has been assigned to Length data member.
const TExt & GetExt(void) const
Get the Ext member data.
const TDelta & GetDelta(void) const
Get the variant data.
const TLoc & GetLoc(void) const
Get the variant data.
const Tdata & Get(void) const
Get the member data.
bool IsLiteral(void) const
Check if variant Literal is selected.
void SetLength(TLength value)
Assign a value to Length data member.
list< CRef< CDelta_seq > > Tdata
void ResetFuzz(void)
Reset Fuzz data member.
@ eMol_na
just a nucleic acid
where boath are integers</td > n< td ></td > n</tr > n< tr > n< td > tse</td > n< td > optional</td > n< td > String</td > n< td class=\"description\"> TSE option controls what blob is orig