36 #if defined(__WXMSW__)
40 #elif defined(__WXGTK__)
43 #elif defined(__WXMAC__)
48 #include "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/HIServices.framework/Versions/A/Headers/InternetConfig.h"
62 #include <wx/msw/winundef.h>
66 #include <wx/fileconf.h>
112 wxFont *font = wxFont::New(
113 #
if defined(__WXMSW__)
115 #elif defined(__WXGTK__)
117 #elif defined(__WXMAC__)
120 wxSWISS, wxNORMAL, wxBOLD,
false);
121 if (font && font->Ok())
124 ERRORMSG(
"Can't create default structure window font");
126 if (font)
delete font;
130 #
if defined(__WXMSW__)
132 #elif defined(__WXGTK__)
134 #elif defined(__WXMAC__)
137 wxROMAN, wxNORMAL, wxNORMAL,
false);
138 if (font && font->Ok())
141 ERRORMSG(
"Can't create default sequence window font");
142 if (font)
delete font;
158 "( netscape -noraise -remote 'openURL(<URL>,new-window)' || netscape '<URL>' ) >/dev/null 2>&1 &"
203 wxString regStr =
registry.
Get(section, name).c_str();
204 return (regStr.size() > 0 && regStr.ToLong(&
value));
210 wxString regStr =
registry.
Get(section, name).c_str();
211 return (regStr.size() > 0 && regStr.ToDouble(&
value));
217 return (regStr.size() > 0 && (
218 toupper((
unsigned char) regStr[0]) ==
'T' ||
toupper((
unsigned char) regStr[0]) ==
'F' ||
219 toupper((
unsigned char) regStr[0]) ==
'Y' ||
toupper((
unsigned char) regStr[0]) ==
'N'));
225 return (regStr.size() > 0);
230 wxString regStr =
registry.
Get(section, name).c_str();
232 if (regStr.size() == 0 || !regStr.ToLong(&l)) {
233 WARNINGMSG(
"Can't get long from registry: " << section <<
", " << name);
242 wxString regStr =
registry.
Get(section, name).c_str();
243 if (regStr.size() == 0 || !regStr.ToDouble(
value)) {
244 WARNINGMSG(
"Can't get double from registry: " << section <<
", " << name);
253 if (regStr.size() == 0 || !(
254 toupper((
unsigned char) regStr[0]) ==
'T' ||
toupper((
unsigned char) regStr[0]) ==
'F' ||
255 toupper((
unsigned char) regStr[0]) ==
'Y' ||
toupper((
unsigned char) regStr[0]) ==
'N')) {
256 WARNINGMSG(
"Can't get boolean from registry: " << section <<
", " << name);
259 *
value = (
toupper((
unsigned char) regStr[0]) ==
'T' ||
toupper((
unsigned char) regStr[0]) ==
'Y');
266 if (regStr.size() == 0) {
267 WARNINGMSG(
"Can't get string from registry: " << section <<
", " << name);
278 ERRORMSG(
"registry Set(" << section <<
", " << name <<
") failed");
288 ERRORMSG(
"registry Set(" << section <<
", " << name <<
") failed");
298 regStr =
value ?
"yes" :
"no";
300 regStr =
value ?
"true" :
"false";
303 ERRORMSG(
"registry Set(" << section <<
", " << name <<
") failed");
313 ERRORMSG(
"registry Set(" << section <<
", " << name <<
") failed");
338 if (getenv(
"CN3D_HOME") !=
NULL)
342 if (wxIsAbsolutePath(argv0))
344 else if (wxPathOnly(argv0) ==
"")
353 wxFileName::SplitPath(wxFileConfig::GetLocalFileName(
"unused"), &localDir,
NULL,
NULL);
354 wxString prefsDirLocal = localDir + wxFILE_SEP_PATH +
"Cn3D_User";
355 wxString prefsDirProg = wxString(
programDir.c_str()) + wxFILE_SEP_PATH +
"Cn3D_User";
356 if (wxDirExists(prefsDirLocal))
358 else if (wxDirExists(prefsDirProg))
362 if (wxMkdir(prefsDirLocal) && wxDirExists(prefsDirLocal))
364 else if (wxMkdir(prefsDirProg) && wxDirExists(prefsDirProg))
368 WARNINGMSG(
"Can't create Cn3D_User folder at either:"
369 <<
"\n " << prefsDirLocal
370 <<
"\nor " << prefsDirProg);
389 static bool MSWin_OpenDocument(
const char* doc_name)
391 int status = (
int) ShellExecute(0,
"open", doc_name,
NULL,
NULL, SW_SHOWNORMAL);
393 ERRORMSG(
"Unable to open document \"" << doc_name <<
"\", error = " << status);
402 static OSStatus MacLaunchURL(ConstStr255Param urlStr,
long int len)
409 err = ICStart(&inst,
'Cn3D');
412 err = ICFindConfigFile(inst, 0, nil);
423 endSel = (
len > 0 &&
len <= 255) ?
len : 255;
424 err = ICLaunchURL(inst,
"\p", urlStr, endSel, &startSel, &endSel);
435 INFOMSG(
"launching url " << url);
437 #if defined(__WXMSW__)
438 if (!MSWin_OpenDocument(url)) {
439 ERRORMSG(
"Unable to launch browser");
442 #elif defined(__WXGTK__)
446 while ((pos=
command.find(
"<URL>", pos)) != string::npos)
451 #elif defined(__WXMAC__)
455 unsigned int i = 0, l = strlen(url);
456 unsigned char uc_url[l+1];
457 for (;
i < l &&
i < 255; ++
i) uc_url[
i] = (
unsigned char) *(url +
i);
459 MacLaunchURL(uc_url, l);
467 static const string host(
"eutils.ncbi.nlm.nih.gov"), path(
"/entrez/eutils/efetch.fcgi");
468 string args =
string(
"rettype=asn.1&retmode=binary&maxplex=1&id=") + id;
473 string db = (
round == 1) ?
"protein" :
"nucleotide";
474 INFOMSG(
"Trying to load sequence from URL " << host << path <<
'?' << (args +
"&db=" + db));
478 if (seqEntry.
IsSeq())
483 WARNINGMSG(
"FetchSequenceViaHTTP() - confused by SeqEntry format");
485 WARNINGMSG(
"FetchSequenceViaHTTP() - HTTP Bioseq retrieval failed, err: " << err);
497 static Char2UChar charMap;
499 if (charMap.size() == 0) {
504 Char2UChar::const_iterator
n = charMap.find(
toupper((
unsigned char)
r));
505 if (
n != charMap.end())
508 return charMap.find(
'X')->second;
515 ERRORMSG(
"LookupCharacterFromNCBIStdaaNumber() - valid values are 0 - 27");
523 static const string allowed =
"-ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789[],(){}<>.#";
525 for (
i=0;
i<prosite.size(); ++
i)
526 if (allowed.find(
toupper((
unsigned char) prosite[
i])) == string::npos)
break;
527 if (
i != prosite.size())
throw "invalid ProSite character";
528 if (prosite[prosite.size() - 1] !=
'.')
throw "ProSite pattern must end with '.'";
534 bool inGroup =
false;
535 for (
unsigned int i=0;
i<prosite.size(); ++
i) {
538 bool characterHandled =
true;
539 switch (prosite[
i]) {
540 case '-':
case '.':
case '>':
545 if (prosite[
i] ==
'>') *regex +=
'$';
551 characterHandled =
false;
554 if (characterHandled)
continue;
556 (
isalpha((
unsigned char) prosite[
i]) &&
toupper((
unsigned char) prosite[
i]) !=
'X') ||
557 prosite[
i] ==
'[' || prosite[
i] ==
'{' || prosite[
i] ==
'#')) {
564 switch (prosite[
i]) {
584 *regex +=
toupper((
unsigned char) prosite[
i]);
590 catch (
const char *err) {
591 ERRORMSG(
"Prosite2Regex() - " << err);
601 static const string allowed =
"-ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789[],(){}<>.#";
605 for (
i=0;
i<prosite.size(); ++
i)
606 if (allowed.find(
toupper((
unsigned char) prosite[
i])) == string::npos)
break;
607 if (
i != prosite.size())
return 0;
609 bool hasOnlyX =
true, stopParsing =
false;
610 bool inBraces =
false, inBrackets =
false, inParens =
false;
611 unsigned int length = 0;
613 string betweenParens;
615 for (
i=0;
i < prosite.size() && !stopParsing; ++
i) {
618 bool characterHandled =
true;
619 switch (prosite[
i]) {
620 case '-':
case '.':
case '>':
case '<':
623 characterHandled =
false;
626 if (inParens && prosite[
i] !=
')' && !characterHandled) betweenParens += prosite[
i];
627 if (characterHandled)
continue;
629 if (hasOnlyX &&
isalpha((
unsigned char) prosite[
i]) &&
toupper((
unsigned char) prosite[
i]) !=
'X') {
634 switch (prosite[
i]) {
644 length += nFromParens - 1;
649 betweenParens.erase();
666 if (!inParens && !inBraces && !inBrackets) ++length;
672 if (inParens || inBrackets || inBraces) length = 0;
675 if (hasOnlyX) length = 0;
679 if (stopParsing) length = 0;
bool GetAsnDataViaHTTPS(const std::string &host, const std::string &path, const std::string &args, ASNClass *asnObject, std::string *err, bool binaryData=true)
bool IsWindowedMode(void)
Include a standard set of the NCBI C++ Toolkit most basic headers.
std::ofstream out("events_result.xml")
main entry point for tests
void Reset(void)
Reset reference object.
bool Empty(void) const THROWS_NONE
Check if CRef is empty – not pointing to any object, which means having a null value.
virtual const string & Get(const string §ion, const string &name, TFlags flags=0) const
Get the parameter value.
IRWRegistry * Read(CNcbiIstream &is, TFlags flags=0, const string &path=kEmptyStr)
Read and parse the stream "is", and merge its content with current Registry entries.
bool Write(CNcbiOstream &os, TFlags flags=0) const
Write the registry content to output stream.
bool Set(const string §ion, const string &name, const string &value, TFlags flags=0, const string &comment=kEmptyStr)
Set the configuration parameter value.
#define END_SCOPE(ns)
End the previously defined scope.
#define BEGIN_SCOPE(ns)
Define a new scope.
IO_PREFIX::ofstream CNcbiOfstream
Portable alias for ofstream.
IO_PREFIX::ifstream CNcbiIfstream
Portable alias for ifstream.
static string DoubleToString(double value, int precision=-1, TNumToStringFlags flags=0)
Convert double to string.
static int StringToInt(const CTempString str, TStringToNumFlags flags=0, int base=10)
Convert string to int.
static string IntToString(int value, TNumToStringFlags flags=0, int base=10)
Convert int to string.
@ fConvErr_NoThrow
Do not throw an exception on error.
TSet & SetSet(void)
Select the variant.
const TSet & GetSet(void) const
Get the variant data.
bool IsSeq(void) const
Check if variant Seq is selected.
bool IsSet(void) const
Check if variant Set is selected.
const TSeq_set & GetSeq_set(void) const
Get the Seq_set member data.
TSeq & SetSeq(void)
Select the variant.
TSeq_set & SetSeq_set(void)
Assign a value to Seq_set data member.
unsigned int
A callback function used to compare two keys in a database.
const struct ncbi::grid::netcache::search::fields::SIZE size
Process information in the NCBI Registry, including working with configuration files.
std::istream & in(std::istream &in_, double &x_)
double r(size_t dimension_, const Int4 *score_, const double *prob_, double theta_)