Skip to content

Commit

Permalink
Fix CSeqDB::GetDiskUsage to include top level BLASTDB files common to…
Browse files Browse the repository at this point in the history
… entire database JIRA SB-2084

git-svn-id: https://anonsvn.ncbi.nlm.nih.gov/repos/v1/trunk/c++@101660 78c7ea69-d796-4a43-9a09-de51944f1b03
  • Loading branch information
christiam authored and gouriano committed Feb 3, 2024
1 parent 2cdfe03 commit a536b45
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions src/objtools/blast/seqdb_reader/seqdb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1472,6 +1472,7 @@ Int8 CSeqDB::GetDiskUsage() const
vector<string> extn;
const bool is_protein(GetSequenceType() == CSeqDB::eProtein);
SeqDB_GetFileExtensions(is_protein, extn, GetBlastDbVersion());
string blastdb_dirname;

ITERATE(vector<string>, path, paths) {
ITERATE(vector<string>, ext, extn) {
Expand All @@ -1480,6 +1481,37 @@ Int8 CSeqDB::GetDiskUsage() const
Int8 length = file.GetLength();
if (length != -1) {
retval += length;
LOG_POST(Trace << "File " << file.GetPath() << " " << length << " bytes");
blastdb_dirname = file.GetDir();
} else {
ERR_POST(Error << "Error retrieving file size for "
<< file.GetPath());
}
}
}
}
// For multi-volume databases, take into account files that apply to the
// entire BLASTDB
if (paths.size() > 1) {
_ASSERT( !blastdb_dirname.empty() );
auto dbname = GetDBNameList();
vector<string> dblist;
NStr::Split(dbname, " ", dblist, NStr::fSplit_Tokenize);
if (dblist.size() > 1) {
CNcbiOstrstream oss;
oss << "Cannot compute disk usage for multiple BLASTDBs (i.e.: '"
<< dbname << "') at once. Please try again using one BLASTDB "
<< "at a time.";
NCBI_THROW(CSeqDBException, eArgErr, CNcbiOstrstreamToString(oss));
}

for (const auto& ext: extn) {
CFile file(CDirEntry::MakePath(blastdb_dirname, dbname, ext));
if (file.Exists()) {
Int8 length = file.GetLength();
if (length != -1) {
retval += length;
LOG_POST(Trace << "File " << file.GetPath() << " " << length << " bytes");
} else {
ERR_POST(Error << "Error retrieving file size for "
<< file.GetPath());
Expand Down

0 comments on commit a536b45

Please sign in to comment.