63 #include <unordered_map>
121 vector<CMappedFeatOrObject>& search_results)
146 for (; sub_it != subtypes.
GetSubtypes().cend(); ++sub_it)
151 for (
const auto& annot : subtypes.
GetAnnots())
168 unordered_map<string, CConstIRef<INonAsnDataSource>> NonAsnDSs(subtypes.
GetNonAsnBlobs());
169 for (
auto vcf_ds : NonAsnDSs) {
170 list<CRef<CObject>> results;
171 vcf_ds.second->DoSearch(vcf_ds.first,
text, results);
172 for (
auto result : results) {
179 search_results.push_back(mfo);
185 if (!search_results.empty()) {
189 unordered_map<string, set<CSeqFeatData::ESubtype>> named_annot_subtypes = subtypes.
GetNamedAnnotSubtypes();
194 CRegexp re_snp(
"^([rs]s)([0-9]{3,})(?::.+)?$");
195 CRegexp re_var(
"^([en]s)(td|v|sv)([0-9]+)(?::.+)?$");
203 named_annot_subtypes.clear();
209 catch (exception&) {}
215 NCBI_ASSERT((*iSNPSearchResult)->CanGetPlacements(),
"Unexpected absence of placements in SNP Search Result!");
216 if (!(*iSNPSearchResult)->CanGetPlacements())
219 NCBI_ASSERT(Placements.size(),
"Unexpected number of placements in SNP Search Result!");
220 if (Placements.empty())
222 pPlacement = Placements.front();
258 auto f =
fi->GetSeq_feat_Handle();
259 string annot =
f.GetAnnot().IsNamed() ?
f.GetAnnot().GetName() :
kEmptyStr;
260 if (named_annot_subtypes.find(annot) == named_annot_subtypes.end() ||
261 named_annot_subtypes[annot].find(
f.GetFeatSubtype()) == named_annot_subtypes[annot].end())
264 vector<string> feat_labels;
269 auto it = find_if(feat_labels.begin(), feat_labels.end(),
270 [&
text, &case_sens](
const string& elem) { return (NStr::Find(elem, text, case_sens) != NPOS); });
271 if (it != feat_labels.end()) {
274 search_results.push_back(mfo);
297 multiplier = 1000000;
300 return TSeqRange(NStr::StringToNumeric<TSeqPos>(pos) * multiplier, NStr::StringToNumeric<TSeqPos>(pos) * multiplier);
320 multiplier0 = 1000000;
325 multiplier1 = 1000000;
328 return TSeqRange(NStr::StringToNumeric<TSeqPos>(pos0) * multiplier0, NStr::StringToNumeric<TSeqPos>(pos1) * multiplier1);
372 bool got_label =
false;
377 label = (*it)->GetVal();
457 bool got_label =
false;
462 label += (*it)->GetVal();
503 feat_labels.push_back(aux_label);
514 feat_labels.push_back(
label);
528 static vector<string> quals{
"regulatory_class",
"recombination_class",
"feat_class",
"bound_moiety",
"mobile_element_type",
"mobile_element",
"rpt_type",
529 "satellite",
"rpt_family",
"mod_base",
"operon",
"standard_name",
"allele" };
531 for (
const auto& qual_name : quals) {
543 static vector<string> class_quals{
"feat_class",
"regulatory_class",
"recombination_class",
"mobile_element_type",
"mobile_element",
"rpt_type",
"satellite",
"rpt_family" };
544 for (
const auto& qual_name : class_quals) {
545 const string&
value = feat.GetNamedQual(qual_name);
566 size_t pos = second_part.find(
';');
567 if (pos != string::npos)
568 second_part = second_part.substr(0, pos);
570 if (!second_part.empty()) {
573 label += second_part;
625 size_t intervals = 0;
626 switch (loc.
Which()) {
649 if (intervals != 0) {
650 if (!extra_info.empty())
653 extra_info +=
" interval";
654 if (intervals != 1) {
658 if (!extra_info.empty()) {
660 *
label += extra_info;
User-defined methods of the data storage class.
User-defined methods of the data storage class.
User-defined methods of the data storage class.
CDataTrack - a abstract base class for layout tracks which need to deal with background data retrieva...
virtual CRef< CSGGenBankDS > GetDataSource()=0
Method for accessing the data source.
void SetMappedFeat(const objects::CMappedFeat &mapped_feat)
void SetRange(const TSeqRange &range)
void SetObject(const CObject *object)
ESubtype GetSubtype(void) const
static E_Choice GetTypeFromSubtype(ESubtype subtype)
@ eSubtype_misc_structure
@ eSubtype_mobile_element
static CTempString SubtypeValueToName(ESubtype eSubtype)
Turns a ESubtype into its string value which is NOT necessarily related to the identifier of the enum...
namespace ncbi::objects::
const string & GetNamedQual(const CTempString &qual_name) const
Return a named qualifier.
CTempString implements a light-weight string on top of a storage buffer whose lifetime management is ...
void Traverse(Tr &&tr, bool visible)
virtual bool IsVarTrack() const
virtual string GetAnnot() const =0
virtual void GetFeatSubtypes(set< objects::CSeqFeatData::ESubtype > &subtypes) const =0
virtual bool IsSnpTrack() const
unordered_map< string, CConstIRef< INonAsnDataSource > > GetNonAsnBlobs()
bool Track(const CTempTrackProxy *, const CLayoutTrack *t, bool visible)
set< objects::CSeqFeatData::ESubtype > m_subtypes
set< string > m_annots_snp
set< string > m_annots_var
const set< string > & GetAnnots()
const set< string > & GetAnnotsSnp()
unordered_map< string, set< objects::CSeqFeatData::ESubtype > > m_named_annot_subtypes
const set< string > & GetAnnotsVar()
unordered_map< string, CConstIRef< INonAsnDataSource > > m_NonAsnBlobs
unordered_map< string, set< objects::CSeqFeatData::ESubtype > > GetNamedAnnotSubtypes()
const set< objects::CSeqFeatData::ESubtype > & GetSubtypes()
static TRsid GetRsid(const CMappedFeat &mapped_feat)
Return rsid of SNP.
iterator_bool insert(const value_type &val)
const_iterator begin() const
const_iterator end() const
#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 NCBI_ASSERT(expr, mess)
static objects::SAnnotSelector GetAnnotSelector(TAnnotFlags flags=0)
request an annotation selector for a given type
static TAnnotNameType NameTypeStrToValue(const string &type)
virtual bool HasNonAsnData(const string &annot_name) const =0
@ eAnnot_Unnamed
unnamed annotation
list< TSNPSearchCompoundResult > TSNPSearchCompoundResultList
results of a search for one or several ids
list< CRef< CVariation > > TSNPSearchResultList
various placements of a variation
static void Search(const std::string &sTerms, const std::string &sAssemblyAccession, TSNPSearchCompoundResultList &ResultList)
search for given SNP ID(s) and get a list of results
const objects::CSeq_loc & GetLocation() const
void GetLabel(string *label, ELabelType type=eDefault, TLabelFlags flags=fLabel_Default) const
Append a label for this Seq-id to the supplied string.
string GetLabel(const CSeq_id &id)
@ fLabel_Default
default options - always show the version
@ eContent
Untagged human-readable accession or the like.
TRange GetTotalRange(void) const
const CSeq_id * GetId(void) const
Get the id of the location return NULL if has multiple ids or no id at all.
@ fFGL_NoComments
Leave out comments, even as fallbacks.
@ fFGL_NoQualifiers
Leave out qualifiers.
@ fFGL_Content
Include its content if there is any.
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,...
ENa_strand GetStrand(const CSeq_loc &loc, CScope *scope=0)
Returns eNa_strand_unknown if multiple Bioseqs in loc Returns eNa_strand_other if multiple strands in...
bool IsSameBioseq(const CSeq_id &id1, const CSeq_id &id2, CScope *scope, CScope::EGetBioseqFlag get_flag=CScope::eGetBioseq_All)
Determines if two CSeq_ids represent the same CBioseq.
CConstRef< CSeq_id > GetSeqId(void) const
Get id which can be used to access this bioseq handle Throws an exception if none is available.
SAnnotSelector & IncludeFeatSubtype(TFeatSubtype subtype)
Include feature subtype in the search.
SAnnotSelector & ExcludeAnnotType(TAnnotType type)
Exclude annotation type from the search.
SAnnotSelector & ResetAnnotsNames(void)
Select annotations from all Seq-annots.
SAnnotSelector & IncludeNamedAnnotAccession(const string &acc, int zoom_level=0)
SAnnotSelector & AddNamedAnnots(const CAnnotName &name)
Add named annot to set of annots names to look for.
SAnnotSelector & SetFeatSubtype(TFeatSubtype subtype)
Set feature subtype (also set annotation and feat type)
SAnnotSelector & AddUnnamedAnnots(void)
Add unnamed annots to set of annots names to look for.
TObjectType * GetPointerOrNull(void) const THROWS_NONE
Get pointer value.
CRange< TSeqPos > TSeqRange
typedefs for sequence ranges
bool IsMatch(CTempString str, TMatch flags=fMatch_default)
Check existence substring which match a specified pattern.
CTempString GetSub(CTempString str, size_t idx=0) const
Get pattern/subpattern from previous GetMatch().
CTempString GetMatch(CTempString str, size_t offset=0, size_t idx=0, TMatch flags=fMatch_default, bool noreturn=false)
Get matching pattern and subpatterns.
int NumFound() const
Get number of patterns + subpatterns.
#define END_NCBI_SCOPE
End previously defined NCBI scope.
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
static string SizetToString(size_t value, TNumToStringFlags flags=0, int base=10)
Convert size_t to string.
static bool EndsWith(const CTempString str, const CTempString end, ECase use_case=eCase)
Check if a string ends with a specified suffix value.
static string IntToString(int value, TNumToStringFlags flags=0, int base=10)
Convert int to string.
static bool EqualCase(const CTempString s1, SIZE_TYPE pos, SIZE_TYPE n, const char *s2)
Case-sensitive equality of a substring with another string.
static bool StartsWith(const CTempString str, const CTempString start, ECase use_case=eCase)
Check if a string starts with a specified prefix value.
static void TrimSuffixInPlace(string &str, const CTempString suffix, ECase use_case=eCase)
Trim suffix from a string (in-place)
static bool EqualNocase(const CTempString s1, SIZE_TYPE pos, SIZE_TYPE n, const char *s2)
Case-insensitive equality of a substring with another string.
ECase
Which type of string comparison.
static enable_if< is_arithmetic< TNumeric >::value||is_convertible< TNumeric, Int8 >::value, string >::type NumericToString(TNumeric value, TNumToStringFlags flags=0, int base=10)
Convert numeric value to string.
@ fWithCommas
Use commas as thousands separator.
@ eNocase
Case insensitive compare.
@ eCase
Case sensitive compare.
static const char label[]
bool IsSetLocus_tag(void) const
systematic gene name (e.g., MI0001, ORF0069) Check if a value has been assigned to Locus_tag data mem...
const TLocus_tag & GetLocus_tag(void) const
Get the Locus_tag member data.
const TTag & GetTag(void) const
Get the Tag member data.
bool IsId(void) const
Check if variant Id is selected.
const TDb & GetDb(void) const
Get the Db member data.
const TStr & GetStr(void) const
Get the variant data.
TId GetId(void) const
Get the variant data.
bool IsSetTitle(void) const
for user defined label Check if a value has been assigned to Title data member.
bool IsSetComment(void) const
Check if a value has been assigned to Comment data member.
const TClone & GetClone(void) const
Get the variant data.
bool IsSetQual(void) const
qualifiers Check if a value has been assigned to Qual data member.
const TRegion & GetRegion(void) const
Get the variant data.
const TTitle & GetTitle(void) const
Get the Title member data.
const TSeq & GetSeq(void) const
Get the variant data.
bool IsSetDescr(void) const
text description Check if a value has been assigned to Descr data member.
const TQual & GetQual(void) const
Get the Qual member data.
const TLocation & GetLocation(void) const
Get the Location member data.
const TData & GetData(void) const
Get the Data member data.
const TName & GetName(void) const
Get the Name member data.
const TDescr & GetDescr(void) const
Get the Descr member data.
const TProduct & GetProduct(void) const
Get the Product member data.
const TComment & GetComment(void) const
Get the Comment member data.
bool IsSetName(void) const
Official clone symbol Check if a value has been assigned to Name data member.
const TGene & GetGene(void) const
Get the variant data.
TSite GetSite(void) const
Get the variant data.
vector< CRef< CGb_qual > > TQual
bool IsSetProduct(void) const
product of process Check if a value has been assigned to Product data member.
const TVariation & GetVariation(void) const
Get the variant data.
bool IsRegion(void) const
Check if variant Region is selected.
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.
ENa_strand
strand of nucleic acid
const Tdata & Get(void) const
Get the member data.
E_Choice Which(void) const
Which variant is currently selected.
const Tdata & Get(void) const
Get the member data.
const TPacked_pnt & GetPacked_pnt(void) const
Get the variant data.
const TPoints & GetPoints(void) const
Get the Points member data.
const TMix & GetMix(void) const
Get the variant data.
const TPacked_int & GetPacked_int(void) const
Get the variant data.
@ e_Ids
used for communication between tools
@ e_not_set
No variant selected.
@ e_Locs
used for communication between tools
list< CRef< CVariantPlacement > > TPlacements
bool IsSetLoc(void) const
actual concrete placement we are considering Check if a value has been assigned to Loc data member.
const TLoc & GetLoc(void) const
Get the Loc member data.
const TId & GetId(void) const
Get the Id member data.
bool CanGetId(void) const
Check if it is safe to call GetId method.
static void text(MDB_val *v)
void s_GetSeqLabel(const CSeq_id &id, string *label, CScope *scope)
bool s_IncludeFeatureTypeInLabel(const objects::CSeq_feat &feat)
void s_GetSeq_TotalRangeLabel(const CSeq_loc &loc, string *label, CScope *scope)
void GetSubtypesForType(set< objects::CSeqFeatData::ESubtype > &subtypes, objects::CSeqFeatData::E_Choice feat)
void s_GetCustomLabel(const CSeq_feat &feat, string &label)
TSeqRange SplitPosOrRange(const string &text)
bool s_UseCustomLabel(const CSeq_feat &feat)
void GatherFeatures(const string &text, bool match_case, objects::CBioseq_Handle bsh, objects::CScope &scope, CFeaturePanel *panel, vector< CMappedFeatOrObject > &search_results)
void s_GetFeatureLabel(const CSeq_feat &feat, vector< string > &feat_labels, CScope *scope)
void s_LabelFromQualifiers(const CSeq_feat &feat, string &label)
range(_Ty, _Ty) -> range< _Ty >
constexpr bool empty(list< Ts... >) noexcept
double f(double x_, const double &y_)
C++ wrappers for the Perl-compatible regular expression (PCRE) library.