cacheFile.Printf(
"%s%c%i.%i", cachePath.c_str(), wxFILE_SEP_PATH, mmdbID, modelType);
72cachePath = cacheFile.c_str();
74 ERRORMSG(
"Can't get cache folder from registry");
82 if(wxDirExists(cacheFolder.c_str()))
return true;
83 boolokay = wxMkdir(cacheFolder.c_str());
84 TRACEMSG((okay ?
"created":
"failed to create") <<
" folder "<< cacheFolder);
90list < CRef < CSeq_entry > >::iterator e, ee = seqEntries.end();
91 for(e=seqEntries.begin(); e!=ee; ++e) {
103 ERRORMSG(
"ExtractBiostrucAndBioseqs() - expecting strucseq mime");
122 INFOMSG(
"looking for "<< mmdbID <<
" (model type "<< (
int) modelType <<
") in cache:");
130<<
" (model type "<< (
int) modelType <<
") from cache: "<< err);
135 INFOMSG(
"loaded "<< cacheFile);
136wxFileName fn(cacheFile.c_str());
148 const string& uid,
intmmdbID,
EModel_typemodelType,
intassemblyId = 0)
150 stringhost, path, args;
152 if(assemblyId == 0) {
155 #ifdef _USE_TEST_MMDBSRV_ 160host =
"dev.ncbi.nlm.nih.gov";
161path =
"/Structure/pdbtest/mmdb/mmdbsrv.cgi";
164host =
"www.ncbi.nlm.nih.gov";
165path =
"/Structure/mmdb/mmdbsrv.cgi";
168args =
"save=Save&dopt=j&uid=";
173args +=
"&Complexity=";
179args +=
"2";
break;
184args +=
"&sanitize=0";
186 #ifdef _USE_TEST_MMDBSRV_ 195host =
"www.ncbi.nlm.nih.gov";
196path =
"/Structure/mmdb/mmdb_strview.cgi";
197args =
"program=cn3d&display=1&uid=";
202args +=
"&complexity=";
209args +=
"2";
break;
215 INFOMSG(
"Trying to load structure data from "<< host << path <<
'?'<< args);
220!mime->IsStrucseq()) {
221 ERRORMSG(
"Failed to read structure "<< uid <<
" from network\nreason: "<< err);
227 if(mime->GetStrucseq().GetStructure().GetId().front()->IsMmdb_id())
228mmdbID = mime->GetStrucseq().GetStructure().GetId().front()->GetMmdb_id().Get();
230 ERRORMSG(
"Can't get MMDB ID from Biostruc!");
240 INFOMSG(
"stored "<< mmdbID <<
" (model type "<< (
int) modelType <<
") in cache");
246 WARNINGMSG(
"Failed to write structure to cache folder");
247 if(err.size() > 0)
WARNINGMSG(
"reason: "<< err);
259 if(uid.size() == 4 && (
isalpha((
unsigned char) uid[1]) ||
isalpha((
unsigned char) uid[2]) ||
isalpha((
unsigned char) uid[3]))) {
263 if(wxString(uid.c_str()).ToULong(&
tmp)) {
266 ERRORMSG(
"LoadStructureViaCache() - invalid uid "<< uid);
269 TRACEMSG(
"Fetching MMDB "<< mmdbID);
303!wxDirExists(cacheFolder.c_str())) {
307 INFOMSG(
"truncating cache to "<< maxSize <<
" MB");
309wxString cacheFolderFiles;
310cacheFolderFiles.Printf(
"%s%c*", cacheFolder.c_str(), wxFILE_SEP_PATH);
315 while((
f=wxFindFirstFile(cacheFolderFiles, wxFILE)).
size() > 0) {
316 if(!wxRemoveFile(
f))
323 unsigned longtotalSize = 0;
324wxString oldestFileName;
329 if(totalSize > 0 && !wxRemoveFile(oldestFileName))
330 WARNINGMSG(
"can't remove file "<< oldestFileName);
334time_t oldestFileDate = wxDateTime::GetTimeNow(), date;
335wxString
file= wxFindFirstFile(cacheFolderFiles, wxFILE);
336 for(;
file.size() > 0;
file= wxFindNextFile()) {
337date = wxFileModificationTime(
file);
338 if(date < oldestFileDate) {
339oldestFileDate = date;
340oldestFileName =
file;
342wxFile wx_file(
file, wxFile::read);
343 if(wx_file.IsOpened()) {
344totalSize += wx_file.Length();
349 INFOMSG(
"total size: "<< totalSize <<
" oldest file: "<< oldestFileName.c_str());
351}
while(totalSize > maxSize * 1024 * 1024);
User-defined methods of the data storage class.
User-defined methods of the data storage class.
User-defined methods of the data storage class.
User-defined methods of the data storage class.
bool GetAsnDataViaHTTPS(const std::string &host, const std::string &path, const std::string &args, ASNClass *asnObject, std::string *err, bool binaryData=true)
void TruncateCache(unsigned int maxSize)
static CNcbi_mime_asn1 * GetStructureFromCacheFolder(int mmdbID, EModel_type modelType)
bool ExtractBiostrucAndBioseqs(CNcbi_mime_asn1 &mime, CRef< CBiostruc > &biostruc, BioseqRefList *sequences)
static CNcbi_mime_asn1 * GetStructureViaHTTPAndAddToCache(const string &uid, int mmdbID, EModel_type modelType, int assemblyId=0)
static string GetCacheFilePath(int mmdbID, EModel_type modelType)
static void ExtractBioseqs(list< CRef< CSeq_entry > > &seqEntries, BioseqRefList *sequences)
static bool CreateCacheFolder(void)
CNcbi_mime_asn1 * LoadStructureViaCache(const std::string &uid, ncbi::objects::EModel_type modelType, int assemblyId)
std::list< ncbi::CRef< ncbi::objects::CBioseq > > BioseqRefList
Include a standard set of the NCBI C++ Toolkit most basic headers.
static bool ReadASNFromFile(const char *filename, ASNClass *ASNobject, bool isBinary, std::string *err)
static bool WriteASNToFile(const char *filename, const ASNClass &ASNobject, bool isBinary, std::string *err, ncbi::EFixNonPrint fixNonPrint=ncbi::eFNP_Default)
EDiagSev SetDiagPostLevel(EDiagSev post_sev=eDiag_Error)
Set the threshold severity for posting the messages.
@ eDiag_Info
Informational message.
@ eDiag_Fatal
Fatal error â guarantees exit(or abort)
TObjectType * GetPointer(void) THROWS_NONE
Get pointer,.
void Reset(void)
Reset reference object.
bool NotEmpty(void) const THROWS_NONE
Check if CRef is not empty â pointing to an object and has a non-null value.
TObjectType * Release(void)
Release a reference to the object and return a pointer to the object.
#define END_SCOPE(ns)
End the previously defined scope.
#define BEGIN_SCOPE(ns)
Define a new scope.
static string IntToString(int value, TNumToStringFlags flags=0, int base=10)
Convert int to string.
EModel_type
Access to EModel_type's attributes (values, names) as defined in spec.
@ eModel_type_ncbi_all_atom
@ eModel_type_ncbi_backbone
@ eModel_type_ncbi_vector
void SetStructure(TStructure &value)
Assign a value to Structure data member.
TStrucseq & SetStrucseq(void)
Select the variant.
bool IsStrucseq(void) const
Check if variant Strucseq is selected.
TSequences & SetSequences(void)
Assign a value to Sequences data member.
unsigned int
A callback function used to compare two keys in a database.
const struct ncbi::grid::netcache::search::fields::SIZE size
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