&url_prefix,
const string&alt_prefix,
const boolis_html )
86 const char* pchPrefix =
"";
90 const string&
id= *str_iter;
91 if(
id.
empty() ) {
95 if( is_html && ! url_prefix.empty() ) {
96 stringurl = url_prefix;
100url =
"https://www.ncbi.nlm.nih.gov/Traces/sra/sra.cgi?analysis=";
102 result<<
"<a href=\""<< url <<
id<<
"\">";
105 if( is_html && ! url_prefix.empty() ) {
117 const char* pchPrefix =
"";
121 if( *int_iter == 0 ) {
126pchPrefix = separator.c_str();
132 structSDBLinkLineLessThan {
133 booloperator()(
const string&
line1,
const string&
line2) {
134 const intline1_prefix_order = x_GetPrefixOrder(
line1);
135 const intline2_prefix_order = x_GetPrefixOrder(
line2);
136 if( line1_prefix_order != line2_prefix_order ) {
137 return(line1_prefix_order < line2_prefix_order);
146 intx_GetPrefixOrder(
const string& line)
149 const static intkDefaultPrefixOrder =
kMax_Int;
152string::size_type colon_pos = line.find(
':');
153 if( colon_pos == string::npos ) {
154 returnkDefaultPrefixOrder;
157 const stringsPrefix = line.substr(0, colon_pos);
161 static constTPrefixElem sc_prefix_map[] = {
166{
"BioProject", 10 },
167{
"BioSample", 20 },
169{
"Sequence Read Archive", 40 },
170{
"Trace Assembly Archive", 60 }
175TPrefixMap::const_iterator find_iter = sc_PrefixMap.find(sPrefix.c_str());
176 if( find_iter == sc_PrefixMap.end() ) {
178 returnkDefaultPrefixOrder;
181 returnfind_iter->second;
185 structSDbLinkLabelInfo {
194 const boolbHtml =
ctx.Config().DoHTML();
196 const CUser_object* genome_projects_user_obje =
nullptr;
208 if(! genome_projects_user_obje) {
209genome_projects_user_obje = &uo;
213 if(! dblink_user_obj) {
214dblink_user_obj = &uo;
221 if(genome_projects_user_obje) {
234 static constTDbLinkLabelToInfo kDbLinkLabelToInfo[] = {
235{
"Assembly", {
true,
false,
"https://www.ncbi.nlm.nih.gov/assembly/"} },
236{
"BioProject", {
true,
false,
"https://www.ncbi.nlm.nih.gov/bioproject/"} },
237{
"BioSample", {
true,
false,
"https://www.ncbi.nlm.nih.gov/biosample/"} },
238{
"ProbeDB", {
true,
false,
""} },
239{
"Sequence Read Archive", {
true,
false,
"https://www.ncbi.nlm.nih.gov/sra/"} },
240{
"Trace Assembly Archive", {
false,
true,
""} }
248vector<string> dblinkLines;
249 if(dblink_user_obj) {
255TDbLinkLabelToInfoMap::const_iterator find_iter =
256kDbLinkLabelToInfoMap.find(
label.c_str());
257 if( find_iter == kDbLinkLabelToInfoMap.end() ) {
261 const char* pchNormalizedDbLinkLabel = find_iter->first;
262 constSDbLinkLabelInfo & dbLinkLabelInfo = find_iter->second;
265 constTFieldData & field_data = field.
GetData();
267 if( dbLinkLabelInfo.allow_text &&
268(field_data.IsStrs() || field_data.IsStr()) )
270 constTFieldData::TStrs* pStrs =
nullptr;
274unique_ptr<TFieldData::TStrs> pStrsDestroyer;
276 if( field_data.IsStrs() ) {
277pStrs = & field_data.
GetStrs();
279 _ASSERT( field_data.IsStr() );
280pStrsDestroyer.reset(
newTFieldData::TStrs );
281pStrsDestroyer->push_back( field_data.GetStr() );
282pStrs = pStrsDestroyer.get();
287alt_url =
"https://www.ncbi.nlm.nih.gov/Traces/sra/sra.cgi?analysis=";
290*pStrs, dbLinkLabelInfo.url, alt_url, bHtml );
291 if( ! dblinkValue.empty() ) {
292dblinkLines.push_back(
293pchNormalizedDbLinkLabel +
string(
": ") + dblinkValue );
299}
else if( dbLinkLabelInfo.allow_numeric &&
300(field_data.IsInts() || field_data.IsInt()) )
303 constTFieldData::TInts* pInts =
nullptr;
305unique_ptr<TFieldData::TInts> pIntsDestroyer;
307 if( field_data.IsInts() ) {
308pInts = & field_data.GetInts();
309}
else if( field_data.IsInt() ) {
310pIntsDestroyer.reset(
newTFieldData::TInts );
311pIntsDestroyer->push_back( field_data.GetInt() );
312pInts = pIntsDestroyer.get();
316 if( ! dblinkValue.empty() ) {
317dblinkLines.push_back(
318pchNormalizedDbLinkLabel +
string(
": ") +
325 sort( dblinkLines.begin(), dblinkLines.end(), SDBLinkLineLessThan() );
void x_SetObject(const CSerialObject &obj)
EItem GetItemType() const override
void Format(IFormatter &formatter, IFlatTextOStream &text_os) const override
vector< int > m_ProjectNumbers
TDBLinkLineVec m_DBLinkLines
const TDBLinkLineVec & GetDBLinkLines(void) const
vector< TDBLinkLine > TDBLinkLineVec
const vector< int > & GetProjectNumbers(void) const
void x_GatherInfo(CBioseqContext &ctx) override
class CStaticArrayMap<> provides access to a static array in much the same way as CStaticArraySet<>,...
class CStaticArrayMap<> is an array adaptor that provides an STLish interface to statically-defined a...
virtual void FormatGenomeProject(const CGenomeProjectItem &, IFlatTextOStream &)
Include a standard set of the NCBI C++ Toolkit most basic headers.
static char line1[1024 *16]
static char line2[1024 *16]
static string s_JoinNumbers(const CUser_field_Base::C_Data::TInts &ints, const string &separator)
static string s_JoinLinkableStrs(const CUser_field_Base::C_Data::TStrs &strs, const string &url_prefix, const string &alt_prefix, const bool is_html)
#define ITERATE(Type, Var, Cont)
ITERATE macro to sequence through container elements.
#define END_NCBI_SCOPE
End previously defined NCBI scope.
#define END_SCOPE(ns)
End the previously defined scope.
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
#define BEGIN_SCOPE(ns)
Define a new scope.
static bool StartsWith(const CTempString str, const CTempString start, ECase use_case=eCase)
Check if a string starts with a specified prefix value.
static bool EqualNocase(const CTempString s1, SIZE_TYPE pos, SIZE_TYPE n, const char *s2)
Case-insensitive equality of a substring with another string.
static bool Equal(const CTempString s1, SIZE_TYPE pos, SIZE_TYPE n, const char *s2, ECase use_case=eCase)
Test for equality of a substring with another string.
static const char label[]
bool IsStr(void) const
Check if variant Str is selected.
const TStrs & GetStrs(void) const
Get the variant data.
const TData & GetData(void) const
Get the Data member data.
bool CanGetData(void) const
Check if it is safe to call GetData method.
bool IsSetLabel(void) const
field label Check if a value has been assigned to Label data member.
const TStr & GetStr(void) const
Get the variant data.
TInt GetInt(void) const
Get the variant data.
const TData & GetData(void) const
Get the Data member data.
const TLabel & GetLabel(void) const
Get the Label member data.
const TType & GetType(void) const
Get the Type member data.
vector< CStringUTF8 > TStrs
vector< CRef< CUser_field > > TData
@ e_User
user defined object
constexpr auto sort(_Init &&init)
constexpr bool empty(list< Ts... >) noexcept
void copy(Njn::Matrix< S > *matrix_, const Njn::Matrix< T > &matrix0_)
void TryToSanitizeHtml(std::string &str)
#define DEFINE_STATIC_ARRAY_MAP(Type, Var, Array)
Template structure SStaticPair is simlified replacement of STL pair<> Main reason of introducing this...
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4