NCBI C++ ToolKit
protein_field_panel.cpp
Go to the documentation of this file.

Go to the SVN repository for this file.

1 /* $Id: protein_field_panel.cpp 47479 2023-05-02 13:24:02Z ucko $
2  * ===========================================================================
3  *
4  * PUBLIC DOMAIN NOTICE
5  * National Center for Biotechnology Information
6  *
7  * This software/database is a "United States Government Work" under the
8  * terms of the United States Copyright Act. It was written as part of
9  * the author's official duties as a United States Government employee and
10  * thus cannot be copyrighted. This software/database is freely available
11  * to the public for use. The National Library of Medicine and the U.S.
12  * Government have not placed any restriction on its use or reproduction.
13  *
14  * Although all reasonable efforts have been taken to ensure the accuracy
15  * and reliability of the software and data, the NLM and the U.S.
16  * Government do not and cannot warrant the performance or results that
17  * may be obtained by using this software or data. The NLM and the U.S.
18  * Government disclaim all warranties, express or implied, including
19  * warranties of performance, merchantability or fitness for any particular
20  * purpose.
21  *
22  * Please cite the author in any work or product based on this material.
23  *
24  * ===========================================================================
25  *
26  * Authors: Andrea Asztalos
27  */
28 
29 
30 #include <ncbi_pch.hpp>
34 
36 
38  : CSingleChoicePanel(parent, GetStrings())
39 {
40 }
41 
42 
43 string CProteinFieldPanel::GetFieldName(const bool subfield)
44 {
45  string qual_name;
46  int val = m_FieldChoice->GetSelection();
47  if (val > -1) {
48  qual_name = ToStdString(m_FieldChoice->GetString(val));
49  if (NStr::StartsWith(qual_name, "mat-peptide")) {
50  NStr::ReplaceInPlace(qual_name, "-", "_");
51  } else {
52  qual_name = "protein " + qual_name;
53  }
54  }
55  return qual_name;
56 }
57 
58 
59 bool CProteinFieldPanel::SetFieldName(const string& field)
60 {
61  bool rval = false;
62  for (size_t i = 0; i < m_FieldChoice->GetStrings().size(); i++) {
63  string qual_name = ToStdString(m_FieldChoice->GetString(static_cast<unsigned int>(i)));
64  if (QualifierNamesAreEquivalent(qual_name, field)) {
65  m_FieldChoice->SetSelection(static_cast<int>(i));
66  rval = true;
67  break;
68  }
69  }
71  return rval;
72 }
73 
75 {
76  vector<string> options;
77  options.push_back("name");
78  options.push_back("description");
79  options.push_back("E.C. number");
80  options.push_back("activity");
81  options.push_back("comment");
82  options.push_back("mat-peptide name");
83  options.push_back("mat-peptide description");
84  options.push_back("mat-peptide comment");
85  return options;
86 }
87 
89 
void x_UpdateParent(void)
virtual string GetFieldName(const bool subfield=false)
Returns the name of the field as selected in the panel.
static vector< string > GetStrings()
CProteinFieldPanel(wxWindow *parent)
virtual bool SetFieldName(const string &field)
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
static bool StartsWith(const CTempString str, const CTempString start, ECase use_case=eCase)
Check if a string starts with a specified prefix value.
Definition: ncbistr.hpp:5412
static string & ReplaceInPlace(string &src, const string &search, const string &replace, SIZE_TYPE start_pos=0, SIZE_TYPE max_replace=0, SIZE_TYPE *num_replace=0)
Replace occurrences of a substring within a string.
Definition: ncbistr.cpp:3405
int i
const struct ncbi::grid::netcache::search::fields::SIZE size
bool QualifierNamesAreEquivalent(string name1, string name2)
string ToStdString(const wxString &s)
Definition: wx_utils.hpp:161
Modified on Thu May 02 14:26:31 2024 by modify_doxy.py rev. 669887