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

Go to the SVN repository for this file.

1 /* ===========================================================================
2  *
3  * PUBLIC DOMAIN NOTICE
4  * National Center for Biotechnology Information
5  *
6  * This software/database is a "United States Government Work" under the
7  * terms of the United States Copyright Act. It was written as part of
8  * the author's official duties as a United States Government employee and
9  * thus cannot be copyrighted. This software/database is freely available
10  * to the public for use. The National Library of Medicine and the U.S.
11  * Government have not placed any restriction on its use or reproduction.
12  *
13  * Although all reasonable efforts have been taken to ensure the accuracy
14  * and reliability of the software and data, the NLM and the U.S.
15  * Government do not and cannot warrant the performance or results that
16  * may be obtained by using this software or data. The NLM and the U.S.
17  * Government disclaim all warranties, express or implied, including
18  * warranties of performance, merchantability or fitness for any particular
19  * purpose.
20  *
21  * Please cite the author in any work or product based on this material.
22  *
23  * ===========================================================================
24  *
25  * Author: Christiam Camacho
26  *
27  */
28 
29 /** @file rps_aux.cpp
30  * Implements auxiliary classes to manage RPS-BLAST related C-structures
31  */
32 
33 
34 #include <ncbi_pch.hpp>
35 #include <corelib/ncbifile.hpp>
40 #include <memory>
41 
42 /** @addtogroup AlgoBlast
43  *
44  * @{
45  */
46 
48 BEGIN_SCOPE(blast)
49 
50 /////////////////////////////////////////////////////////////////////////////
51 //
52 // CBlastRPSAuxInfo
53 //
54 /////////////////////////////////////////////////////////////////////////////
55 
56 /// Wrapper class to manage the BlastRPSAuxInfo structure, as currently
57 /// there aren't any allocation or deallocation functions for this structure in
58 /// the CORE of BLAST. This class is meant to be kept in a CRef<>. Note that
59 /// only the fields currently used are being passed to the constructor
60 class CBlastRPSAuxInfo : public CObject {
61 public:
62  /// Parametrized constructor
63  /// @param matrix name of the scoring matrix used to build the RPS-BLAST
64  /// database
65  /// @param gap_open gap opening cost
66  /// @param gap_extend gap extension cost
67  /// @param scale_factor scaling factor
68  /// @param karlin_k statistical K parameter calculated when building the
69  /// RPS-BLAST database
70  CBlastRPSAuxInfo(const string& matrix,
71  int gap_open,
72  int gap_extend,
73  double scale_factor,
74  const vector<double>& karlin_k);
75 
76  /// Destructor
78 
79  /// Lend the caller the pointer to the data structure this object manages.
80  /// Caller MUST NOT deallocate the return value.
81  const BlastRPSAuxInfo* operator()() const;
82 private:
83  /// Prohibit copy-constructor
85  /// Prohibit assignment operator
87 
88  /// Deallocates the structure owned by this class
89  void x_DoDestroy();
90 
91  /// The data structure this class manages
93 };
94 
96  int gap_open,
97  int gap_extend,
98  double scale_factor,
99  const vector<double>& karlin_k)
100  : m_Data(0)
101 {
102  _ASSERT(!matrix.empty());
103  _ASSERT(!karlin_k.empty());
104 
105  try {
106  m_Data = new BlastRPSAuxInfo;
107  memset(m_Data, 0, sizeof(BlastRPSAuxInfo));
108  m_Data->orig_score_matrix = strdup(matrix.c_str());
109  m_Data->gap_open_penalty = gap_open;
110  m_Data->gap_extend_penalty = gap_extend;
111  m_Data->scale_factor = scale_factor;
112  m_Data->karlin_k = new double[karlin_k.size()];
113  copy(karlin_k.begin(), karlin_k.end(), &m_Data->karlin_k[0]);
114  } catch (const bad_alloc&) {
115  x_DoDestroy();
116  NCBI_THROW(CBlastSystemException, eOutOfMemory,
117  "Failed to allocate memory for BlastRPSAuxInfo structure");
118  }
119 }
120 
122 {
123  x_DoDestroy();
124 }
125 
126 const BlastRPSAuxInfo*
128 {
129  return m_Data;
130 }
131 
132 void
134 {
135  if ( !m_Data ) {
136  return;
137  }
138  if (m_Data->orig_score_matrix) {
140  }
141  if (m_Data->karlin_k) {
142  delete [] m_Data->karlin_k;
143  m_Data->karlin_k = NULL;
144  }
145  delete m_Data;
146  m_Data = NULL;
147 }
148 
149 /////////////////////////////////////////////////////////////////////////////
150 //
151 // CRpsAuxFile
152 //
153 /////////////////////////////////////////////////////////////////////////////
154 
155 /// This class represents the .aux file in a RPS-BLAST file, which contains
156 /// information about the scoring matrix to be used during the RPS-BLAST
157 /// search, the scaling factor, an array of K statistical values (karlin_k),
158 /// as well as various fields that are currently unused.
159 class CRpsAuxFile : public CObject {
160 public:
161  /// Extension associated with the RPS-BLAST database auxiliary file
162  static const string kExtension;
163 
164  /// Parametrized constructor
165  /// @param filename_no_extn name of the file without extension
166  CRpsAuxFile(const string& filename_no_extn);
167 
168  /// Lend the caller the pointer to the data structure this object manages.
169  /// Caller MUST NOT deallocate the return value.
170  const BlastRPSAuxInfo* operator()() const;
171 
172 private:
173  /// Auxiliary method to read the contents of the file into m_Data
176 };
177 
178 const string CRpsAuxFile::kExtension(".aux");
179 
180 CRpsAuxFile::CRpsAuxFile(const string& filename_no_extn)
181 {
182  // Open the file
183  const string file2open(filename_no_extn + kExtension);
184  CNcbiIfstream auxfile(file2open.c_str());
185  if (auxfile.bad() || auxfile.fail()) {
186  NCBI_THROW(CBlastException, eRpsInit,
187  "Cannot open RPS-BLAST auxiliary file: " + file2open);
188  }
189  // Read the file
190  m_Data = x_ReadFromFile(auxfile);
191  auxfile.close();
192 }
193 
196 {
197  // Declare data to read
198  string matrix;
199  int gap_open;
200  int gap_extend;
201  double scale_factor;
202  vector<double> karlinK;
203  double ignore_me_d;
204  int ignore_me_i;
205 
206  // Read the data
207  input >> matrix;
208  input >> gap_open;
209  input >> gap_extend;
210  input >> ignore_me_d; // corresponds to BlastRPSAuxInfo::ungapped_k
211  input >> ignore_me_d; // corresponds to BlastRPSAuxInfo::ungapped_h
212  input >> ignore_me_i; // corresponds to BlastRPSAuxInfo::max_db_seq_length
213  input >> ignore_me_i; // corresponds to BlastRPSAuxInfo::db_length
214  input >> scale_factor;
215  while (input) {
216  int seq_size; // unused value
217  double k;
218  input >> seq_size;
219  input >> k;
220  karlinK.push_back(k);
221  }
222 
223  CRef<CBlastRPSAuxInfo> retval(new CBlastRPSAuxInfo(matrix,
224  gap_open,
225  gap_extend,
226  scale_factor,
227  karlinK));
228  return retval;
229 }
230 
231 const BlastRPSAuxInfo*
233 {
234  return (*m_Data)();
235 }
236 
237 /////////////////////////////////////////////////////////////////////////////
238 //
239 // CRpsMmappedFile
240 //
241 /////////////////////////////////////////////////////////////////////////////
242 
243 /// Encapsulates logic of mmap'ing and performing sanity checks on RPS-BLAST
244 /// database files
245 class CRpsMmappedFile : public CObject {
246 public:
247  /// Parametrized constructor
248  /// @param filename name of the file to mmap
249  CRpsMmappedFile(const string& filename);
250 protected:
251  /// The data structure this class manages
252  unique_ptr<CMemoryFile> m_MmappedFile;
253 };
254 
255 CRpsMmappedFile::CRpsMmappedFile(const string& filename)
256 {
257  try { m_MmappedFile.reset(new CMemoryFile(filename)); }
258  catch (const CFileException& e) {
259  NCBI_RETHROW(e, CBlastException, eRpsInit,
260  "Cannot memory map RPS-BLAST database file: " + filename);
261  }
262 }
263 
264 /////////////////////////////////////////////////////////////////////////////
265 //
266 // CRpsLookupTblFile
267 //
268 /////////////////////////////////////////////////////////////////////////////
269 
270 /// This class represents the .loo file in a RPS-BLAST file, which contains the
271 /// pre-computed lookup table
273 public:
274  /// Extension associated with the RPS-BLAST database lookup table file
275  static const string kExtension;
276 
277  /// Parametrized constructor
278  /// @param filename_no_extn name of the file without extension
279  CRpsLookupTblFile(const string& filename_no_extn);
280 
281  /// Lend the caller the pointer to the data structure this object manages.
282  /// Caller MUST NOT deallocate the return value.
283  const BlastRPSLookupFileHeader* operator()() const;
284 private:
285  /// The data structure this class manages
287 };
288 
289 const string CRpsLookupTblFile::kExtension(".loo");
290 
291 CRpsLookupTblFile::CRpsLookupTblFile(const string& filename_no_extn)
292  : CRpsMmappedFile(filename_no_extn + kExtension)
293 {
297  m_Data = NULL;
298  NCBI_THROW(CBlastException, eRpsInit,
299  "RPS BLAST profile file (" + filename_no_extn + kExtension +
300  ") is either corrupt or constructed for an incompatible "
301  "architecture");
302  }
303 }
304 
307 {
308  return m_Data;
309 }
310 
311 /////////////////////////////////////////////////////////////////////////////
312 //
313 // CRpsPssmFile
314 //
315 /////////////////////////////////////////////////////////////////////////////
316 
317 /// This class represents the .rps file in a RPS-BLAST file, which contains the
318 /// PSSMs for the database
320 public:
321  /// Extension associated with the RPS-BLAST database PSSM file
322  static const string kExtension;
323 
324  /// Parametrized constructor
325  /// @param filename_no_extn name of the file without extension
326  CRpsPssmFile(const string& filename_no_extn);
327 
328  /// Lend the caller the pointer to the data structure this object manages.
329  /// Caller MUST NOT deallocate the return value.
330  const BlastRPSProfileHeader* operator()() const;
331 private:
332  /// The data structure this class manages
334 };
335 
336 const string CRpsPssmFile::kExtension(".rps");
337 
338 CRpsPssmFile::CRpsPssmFile(const string& filename_no_extn)
339  : CRpsMmappedFile(filename_no_extn + kExtension)
340 {
344  m_Data = NULL;
345  NCBI_THROW(CBlastException, eRpsInit,
346  "RPS BLAST profile file (" + filename_no_extn + kExtension +
347  ") is either corrupt or constructed for an incompatible "
348  "architecture");
349  }
350 }
351 
354 {
355  return m_Data;
356 }
357 
358 
359 /////////////////////////////////////////////////////////////////////////////
360 //
361 // CRpsFreqsFile
362 //
363 /////////////////////////////////////////////////////////////////////////////
364 
365 /// This class represents the .wcounts file in a RPS-BLAST file, which contains
366 /// the weighted residue frequencies for the database
368 public:
369  /// Extension associated with the RPS-BLAST database PSSM file
370  static const string kExtension;
371 
372  /// Parametrized constructor
373  /// @param filename_no_extn name of the file without extension
374  CRpsFreqsFile(const string& filename_no_extn);
375 
376  /// Lend the caller the pointer to the data structure this object manages.
377  /// Caller MUST NOT deallocate the return value.
378  const BlastRPSProfileHeader* operator()() const;
379 private:
380  /// The data this class manages
382 };
383 
384 const string CRpsFreqsFile::kExtension(".wcounts");
385 
386 CRpsFreqsFile::CRpsFreqsFile(const string& filename_no_extn)
387  : CRpsMmappedFile(filename_no_extn + kExtension)
388 {
389 
391 
394  m_Data = NULL;
395  NCBI_THROW(CBlastException, eRpsInit,
396  "RPS BLAST profile file (" + filename_no_extn + kExtension +
397  ") is either corrupt or constructed for an incompatible "
398  "architecture");
399  }
400 }
401 
404 {
405  return m_Data;
406 }
407 
408 
409 /////////////////////////////////////////////////////////////////////////////
410 //
411 // CRpsObsrFile
412 //
413 /////////////////////////////////////////////////////////////////////////////
414 
415 /// This class represents the .obsr file in a RPS-BLAST file, which contains
416 /// the numbers of independent observations for the database
418 public:
419  /// Extension associated with the RPS-BLAST database PSSM file
420  static const string kExtension;
421 
422  /// Parametrized constructor
423  /// @param filename_no_extn name of the file without extension
424  CRpsObsrFile(const string& filename_no_extn);
425 
426  /// Lend the caller the pointer to the data structure this object manages.
427  /// Caller MUST NOT deallocate the return value.
428  const BlastRPSProfileHeader* operator()() const;
429 private:
430  /// Header
432 };
433 
434 const string CRpsObsrFile::kExtension(".obsr");
435 
436 CRpsObsrFile::CRpsObsrFile(const string& filename_no_extn)
437  : CRpsMmappedFile(filename_no_extn + kExtension)
438 {
440 
443  m_Data = NULL;
444  NCBI_THROW(CBlastException, eRpsInit,
445  "RPS BLAST profile file (" + filename_no_extn + kExtension +
446  ") is either corrupt or constructed for an incompatible "
447  "architecture");
448  }
449 }
450 
453 {
454  return m_Data;
455 }
456 
457 /////////////////////////////////////////////////////////////////////////////
458 //
459 // CRpsFreqRatiosFile
460 //
461 /////////////////////////////////////////////////////////////////////////////
462 
463 /// This class represents the .freq file in a RPS-BLAST file, which contains
464 /// the frequency ratios for the database
466 public:
467  /// Extension associated with the RPS-BLAST database PSSM file
468  static const string kExtension;
469 
470  /// Parametrized constructor
471  /// @param filename_no_extn name of the file without extension
472  CRpsFreqRatiosFile(const string& filename_no_extn);
473 
474  virtual ~CRpsFreqRatiosFile(){};
475 
476  /// Lend the caller the pointer to the data structure this object manages.
477  /// Caller MUST NOT deallocate the return value.
478  const BlastRPSFreqRatiosHeader* operator()() const;
479 private:
480  /// The data this class manages
482 };
483 
484 const string CRpsFreqRatiosFile::kExtension(".freq");
485 
486 CRpsFreqRatiosFile::CRpsFreqRatiosFile(const string& filename_no_extn)
487  : CRpsMmappedFile(filename_no_extn + kExtension), m_Data(NULL)
488 {
492  m_Data = NULL;
493  NCBI_THROW(CBlastException, eRpsInit,
494  "RPS BLAST freq ratios file (" + filename_no_extn + kExtension +
495  ") is either corrupt or constructed for an incompatible "
496  "architecture");
497  }
498 
499 }
500 
503 {
504  return m_Data;
505 }
506 
507 
508 CBlastRPSInfo::CBlastRPSInfo(const string& rps_dbname)
509 {
510  x_Init(rps_dbname, fRpsBlast);
511 }
512 
513 CBlastRPSInfo::CBlastRPSInfo(const string& rps_dbname, int flags)
514 {
515  x_Init(rps_dbname, flags);
516 }
517 
518 void CBlastRPSInfo::x_Init(const string& rps_dbname, int flags)
519 {
520  // Obtain the full path to the database
521  string path;
522  try {
523  vector<string> dbpath;
524  CSeqDB::FindVolumePaths(rps_dbname, CSeqDB::eProtein, dbpath);
525  path = *dbpath.begin();
526  } catch (const CSeqDBException& e) {
527  NCBI_RETHROW(e, CBlastException, eRpsInit,
528  "Cannot retrieve path to RPS database");
529  }
530  _ASSERT(!path.empty());
531 
532  unique_ptr<BlastRPSInfo> rps_info;
533 
534  // Allocate the core data structure
535  try { m_RpsInfo.reset(new BlastRPSInfo); }
536  catch (const bad_alloc&) {
537  NCBI_THROW(CBlastSystemException, eOutOfMemory,
538  "RPSInfo allocation failed");
539  }
540 
541  // Assign the pointers to the core data structure
542  m_RpsInfo->lookup_header = NULL;
543  m_RpsInfo->profile_header = NULL;
544  m_RpsInfo->freq_header = NULL;
545  m_RpsInfo->obsr_header = NULL;
546  m_RpsInfo->freq_ratios_header = NULL;
547 
548  // Load the various files
549  if (flags & fAuxInfoFile) {
550  m_AuxFile.Reset(new CRpsAuxFile(path));
551 
552  // Note that these const_casts are only needed because the data structure
553  // doesn't take const pointers, but these won't be modified at all
554  m_RpsInfo->aux_info =
555  *const_cast<BlastRPSAuxInfo*>((*m_AuxFile)());
556  }
557 
558  if (flags & fLookupTableFile) {
559  m_LutFile.Reset(new CRpsLookupTblFile(path));
560 
561  // Note that these const_casts are only needed because the data structure
562  // doesn't take const pointers, but these won't be modified at all
563  m_RpsInfo->lookup_header =
564  const_cast<BlastRPSLookupFileHeader*>((*m_LutFile)());
565  }
566 
567  if (flags & fPssmFile) {
568  m_PssmFile.Reset(new CRpsPssmFile(path));
569 
570  // Note that these const_casts are only needed because the data structure
571  // doesn't take const pointers, but these won't be modified at all
572  m_RpsInfo->profile_header =
573  const_cast<BlastRPSProfileHeader*>((*m_PssmFile)());
574  }
575 
576  if (flags & fFrequenciesFile) {
577  m_FreqsFile.Reset(new CRpsFreqsFile(path));
578 
579  // Note that these const_casts are only needed because the data structure
580  // doesn't take const pointers, but these won't be modified at all
581  m_RpsInfo->freq_header =
582  const_cast<BlastRPSProfileHeader*>((*m_FreqsFile)());
583  }
584 
585  if (flags & fObservationsFile) {
586  m_ObsrFile.Reset(new CRpsObsrFile(path));
587 
588  // Note that these const_casts are only needed because the data structure
589  // doesn't take const pointers, but these won't be modified at all
590  m_RpsInfo->obsr_header =
591  const_cast<BlastRPSProfileHeader*>((*m_ObsrFile)());
592  }
593 
594  if (flags & fFreqRatiosFile) {
595  try {
596  // read frequency ratios data
598  } catch (const CBlastException& e) {
599  string msg = rps_dbname + " contains no frequency ratios needed for composition-based statistics.\n" \
600  "Please disable composition-based statistics when searching against " + rps_dbname + ".";
601  NCBI_RETHROW(e, CBlastException, eRpsInit, msg);
602  }
603  m_RpsInfo->freq_ratios_header =
604  const_cast<BlastRPSFreqRatiosHeader*>((*m_FreqRatiosFile)());
605  }
606 }
607 
608 // Trivial at this point, but left out-of-line so that the header doesn't
609 // need to pull in full declarations of the classes to which it takes CRefs.
611 {
612 }
613 
614 const BlastRPSInfo*
616 {
617  return m_RpsInfo.get();
618 }
619 
620 double
622 {
623  return m_RpsInfo->aux_info.scale_factor;
624 }
625 
626 const char*
628 {
629  return m_RpsInfo->aux_info.orig_score_matrix;
630 }
631 
632 int
634 {
635  return m_RpsInfo->aux_info.gap_open_penalty;
636 }
637 
638 int
640 {
641  return m_RpsInfo->aux_info.gap_extend_penalty;
642 }
643 
644 END_SCOPE(blast)
646 
647 /* @} */
Definitions used throughout BLAST.
#define sfree(x)
Safe free a pointer: belongs to a higher level header.
Definition: blast_def.h:112
Declares the BLAST exception class.
#define RPS_MAGIC_NUM_28
Version number for 28-letter alphabet.
Definition: blast_rps.h:44
struct BlastRPSAuxInfo BlastRPSAuxInfo
information derived from RPS blast '.aux' file
#define RPS_MAGIC_NUM
RPS blast version number.
Definition: blast_rps.h:43
Defines BLAST error codes (user errors included)
Wrapper class to manage the BlastRPSAuxInfo structure, as currently there aren't any allocation or de...
Definition: rps_aux.cpp:60
Defines system exceptions occurred while running BLAST.
CFileException –.
Definition: ncbifile.hpp:136
CMemoryFile –.
Definition: ncbifile.hpp:2861
CObject –.
Definition: ncbiobj.hpp:180
This class represents the .aux file in a RPS-BLAST file, which contains information about the scoring...
Definition: rps_aux.cpp:159
This class represents the .freq file in a RPS-BLAST file, which contains the frequency ratios for the...
Definition: rps_aux.cpp:465
This class represents the .wcounts file in a RPS-BLAST file, which contains the weighted residue freq...
Definition: rps_aux.cpp:367
This class represents the .loo file in a RPS-BLAST file, which contains the pre-computed lookup table...
Definition: rps_aux.cpp:272
Encapsulates logic of mmap'ing and performing sanity checks on RPS-BLAST database files.
Definition: rps_aux.cpp:245
This class represents the .obsr file in a RPS-BLAST file, which contains the numbers of independent o...
Definition: rps_aux.cpp:417
This class represents the .rps file in a RPS-BLAST file, which contains the PSSMs for the database.
Definition: rps_aux.cpp:319
CSeqDBException.
Definition: seqdbcommon.hpp:73
static void FindVolumePaths(const string &dbname, ESeqType seqtype, vector< string > &paths, vector< string > *alias_paths=NULL, bool recursive=true, bool expand_links=true)
Find volume paths.
Definition: seqdb.cpp:1040
@ eProtein
Definition: seqdb.hpp:174
static uch flags
void x_Init(const string &rps_dbname, int flags)
Initialize attributes.
Definition: rps_aux.cpp:518
int GetGapExtensionCost() const
Returns the gap extension cost associated with the scoring matrix above.
Definition: rps_aux.cpp:639
CRef< CRpsLookupTblFile > m_LutFile
The lookup table RPS-BLAST file (.loo)
Definition: rps_aux.hpp:150
BlastRPSProfileHeader * m_Data
Header.
Definition: rps_aux.cpp:431
CBlastRPSAuxInfo & operator=(const CBlastRPSAuxInfo &rhs)
Prohibit assignment operator.
const BlastRPSAuxInfo * operator()() const
Lend the caller the pointer to the data structure this object manages.
Definition: rps_aux.cpp:127
CRef< CRpsFreqRatiosFile > m_FreqRatiosFile
Frequency ratios file (.freq) used for composition based statistics and cobalt.
Definition: rps_aux.hpp:162
BlastRPSProfileHeader * m_Data
The data structure this class manages.
Definition: rps_aux.cpp:333
BlastRPSFreqRatiosHeader * m_Data
The data this class manages.
Definition: rps_aux.cpp:481
const BlastRPSProfileHeader * operator()() const
Lend the caller the pointer to the data structure this object manages.
Definition: rps_aux.cpp:353
BlastRPSAuxInfo * m_Data
The data structure this class manages.
Definition: rps_aux.cpp:92
const BlastRPSProfileHeader * operator()() const
Lend the caller the pointer to the data structure this object manages.
Definition: rps_aux.cpp:403
static const string kExtension
Extension associated with the RPS-BLAST database PSSM file.
Definition: rps_aux.cpp:370
const BlastRPSProfileHeader * operator()() const
Lend the caller the pointer to the data structure this object manages.
Definition: rps_aux.cpp:452
unique_ptr< BlastRPSInfo > m_RpsInfo
Pointer which contains pointers to data managed by the data members above.
Definition: rps_aux.hpp:167
CRpsPssmFile(const string &filename_no_extn)
Parametrized constructor.
Definition: rps_aux.cpp:338
double GetScalingFactor() const
Returns the scaling factor used to build RPS-BLAST database.
Definition: rps_aux.cpp:621
~CBlastRPSInfo()
Destructor.
Definition: rps_aux.cpp:610
CRpsAuxFile(const string &filename_no_extn)
Parametrized constructor.
Definition: rps_aux.cpp:180
BlastRPSProfileHeader * m_Data
The data this class manages.
Definition: rps_aux.cpp:381
const BlastRPSFreqRatiosHeader * operator()() const
Lend the caller the pointer to the data structure this object manages.
Definition: rps_aux.cpp:502
CRpsMmappedFile(const string &filename)
Parametrized constructor.
Definition: rps_aux.cpp:255
~CBlastRPSAuxInfo()
Destructor.
Definition: rps_aux.cpp:121
void x_DoDestroy()
Deallocates the structure owned by this class.
Definition: rps_aux.cpp:133
CRef< CBlastRPSAuxInfo > m_Data
Definition: rps_aux.cpp:175
CBlastRPSInfo(const string &rps_dbname)
Parametrized constructor.
Definition: rps_aux.cpp:508
CBlastRPSAuxInfo(const string &matrix, int gap_open, int gap_extend, double scale_factor, const vector< double > &karlin_k)
Parametrized constructor.
Definition: rps_aux.cpp:95
CBlastRPSAuxInfo(const CBlastRPSAuxInfo &rhs)
Prohibit copy-constructor.
CRef< CRpsAuxFile > m_AuxFile
The auxiliary RPS-BLAST file (.aux)
Definition: rps_aux.hpp:146
static const string kExtension
Extension associated with the RPS-BLAST database auxiliary file.
Definition: rps_aux.cpp:162
CRpsObsrFile(const string &filename_no_extn)
Parametrized constructor.
Definition: rps_aux.cpp:436
CRef< CBlastRPSAuxInfo > x_ReadFromFile(CNcbiIfstream &input)
Auxiliary method to read the contents of the file into m_Data.
Definition: rps_aux.cpp:195
static const string kExtension
Extension associated with the RPS-BLAST database PSSM file.
Definition: rps_aux.cpp:322
const BlastRPSInfo * operator()() const
Accessor for the underlying C structure (managed by this class)
Definition: rps_aux.cpp:615
CRpsFreqRatiosFile(const string &filename_no_extn)
Parametrized constructor.
Definition: rps_aux.cpp:486
virtual ~CRpsFreqRatiosFile()
Definition: rps_aux.cpp:474
CRef< CRpsPssmFile > m_PssmFile
The PSSM RPS-BLAST file (.rps)
Definition: rps_aux.hpp:148
static const string kExtension
Extension associated with the RPS-BLAST database PSSM file.
Definition: rps_aux.cpp:420
BlastRPSLookupFileHeader * m_Data
The data structure this class manages.
Definition: rps_aux.cpp:286
const BlastRPSLookupFileHeader * operator()() const
Lend the caller the pointer to the data structure this object manages.
Definition: rps_aux.cpp:306
const char * GetMatrixName() const
Returns the name of the scoring matrix used to build the RPS-BLAST database.
Definition: rps_aux.cpp:627
CRef< CRpsObsrFile > m_ObsrFile
Number of independent observations file (.obsr) used by delta-blast.
Definition: rps_aux.hpp:158
CRpsFreqsFile(const string &filename_no_extn)
Parametrized constructor.
Definition: rps_aux.cpp:386
CRpsLookupTblFile(const string &filename_no_extn)
Parametrized constructor.
Definition: rps_aux.cpp:291
CRef< CRpsFreqsFile > m_FreqsFile
Weighted residue frequencies file (.wcounts) used by delta-blast.
Definition: rps_aux.hpp:154
static const string kExtension
Extension associated with the RPS-BLAST database PSSM file.
Definition: rps_aux.cpp:468
unique_ptr< CMemoryFile > m_MmappedFile
The data structure this class manages.
Definition: rps_aux.cpp:252
static const string kExtension
Extension associated with the RPS-BLAST database lookup table file.
Definition: rps_aux.cpp:275
const BlastRPSAuxInfo * operator()() const
Lend the caller the pointer to the data structure this object manages.
Definition: rps_aux.cpp:232
int GetGapOpeningCost() const
Returns the gap opening cost associated with the scoring matrix above.
Definition: rps_aux.cpp:633
@ fLookupTableFile
Definition: rps_aux.hpp:74
@ fFrequenciesFile
Open residue frequencies file.
Definition: rps_aux.hpp:80
@ fFreqRatiosFile
Open file with frequency ratios.
Definition: rps_aux.hpp:84
@ fObservationsFile
Open file with numbers of independent observations.
Definition: rps_aux.hpp:82
@ fRpsBlast
Flags set for RPS-BLAST.
Definition: rps_aux.hpp:90
@ fAuxInfoFile
Open auxiliary information file.
Definition: rps_aux.hpp:78
@ fPssmFile
Open pssm file.
Definition: rps_aux.hpp:76
#define NULL
Definition: ncbistd.hpp:225
#define NCBI_THROW(exception_class, err_code, message)
Generic macro to throw an exception, given the exception class, error code and message string.
Definition: ncbiexpt.hpp:704
#define NCBI_RETHROW(prev_exception, exception_class, err_code, message)
Generic macro to re-throw an exception.
Definition: ncbiexpt.hpp:737
void Reset(void)
Reset reference object.
Definition: ncbiobj.hpp:773
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define END_SCOPE(ns)
End the previously defined scope.
Definition: ncbistl.hpp:75
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
#define BEGIN_SCOPE(ns)
Define a new scope.
Definition: ncbistl.hpp:72
IO_PREFIX::ifstream CNcbiIfstream
Portable alias for ifstream.
Definition: ncbistre.hpp:439
static int input()
#define strdup
Definition: ncbi_ansi_ext.h:70
Defines classes: CDirEntry, CFile, CDir, CSymLink, CMemoryFile, CFileUtil, CFileLock,...
void copy(Njn::Matrix< S > *matrix_, const Njn::Matrix< T > &matrix0_)
Definition: njn_matrix.hpp:613
Declares auxiliary classes to manage RPS-BLAST related C-structures.
Defines BLAST database access classes.
static SLJIT_INLINE sljit_ins msg(sljit_gpr r, sljit_s32 d, sljit_gpr x, sljit_gpr b)
information derived from RPS blast '.aux' file
Definition: blast_rps.h:100
Int4 gap_extend_penalty
gap extend penalty used in deriving PSSMs
Definition: blast_rps.h:103
double * karlin_k
one Karlin value for each DB sequence
Definition: blast_rps.h:113
double scale_factor
the PSSMs are scaled by this amount, and so all scores and all cutoff values must be similarly scaled...
Definition: blast_rps.h:110
Int4 gap_open_penalty
gap open penalty used in deriving PSSMs
Definition: blast_rps.h:102
char * orig_score_matrix
score matrix used to derive PSSMs
Definition: blast_rps.h:101
The RPS engine uses this structure to access all of the RPS blast related data (assumed to be collect...
Definition: blast_rps.h:120
header of RPS blast '.loo' file
Definition: blast_rps.h:49
Int4 magic_number
value should be RPS_MAGIC_NUM
Definition: blast_rps.h:50
header of RPS blast '.rps' file
Definition: blast_rps.h:62
Int4 magic_number
value should be RPS_MAGIC_NUM
Definition: blast_rps.h:63
#define _ASSERT
Modified on Fri Sep 20 14:57:07 2024 by modify_doxy.py rev. 669887