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

Go to the SVN repository for this file.

1 /* $Id: seq_masker_score_mean.cpp 86312 2019-04-29 12:24:20Z morgulis $
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  * Author: Aleksandr Morgulis
27  *
28  * File Description:
29  * CSeqMaskerScoreMean class member and method definitions.
30  *
31  */
32 
33 #include <ncbi_pch.hpp>
36 
38 
39 
40 //-------------------------------------------------------------------------
42  const CRef< CSeqMaskerIstat > & ustat )
43 : CSeqMaskerScore( ustat ), sum( 0 ), start( 0 ), num( 0 )
44 {
45 }
46 
47 //-------------------------------------------------------------------------
49 { return sum/num; }
50 
51 //-------------------------------------------------------------------------
53 {
54  if( step == 1 && window->UnitStep() == 1 )
55  {
56  start = window->Start();
57  sum -= *scores_start;
58  }
59 }
60 
61 //-------------------------------------------------------------------------
63 {
64  if( step == 1
65  && window->UnitStep() == 1
66  && window->Start() - start == 1 )
67  {
68  /*!!!!NEW CODE*/ sum -= *scores_start;
69  *scores_start = (*ustat)[(*window)[num - 1]];
70 
71  // std::cerr << std::hex << (*window)[num - 1] << ' ' << *scores_start << std::dec << std::endl;
72 
73  sum += *scores_start;
74  scores_start = (scores_start - &scores[0] == (int)(num - 1) )
75  ? &scores[0]
76  : scores_start + 1;
77  /*!!!!NEW CODE*/ start = window->Start();
78  }
79  else{ FillScores(); }
80 }
81 
82 //-------------------------------------------------------------------------
84 {
85  start = window->Start();
86  num = window->NumUnits();
87  scores.resize( num, 0 );
88 
89  FillScores();
90 }
91 
92 //-------------------------------------------------------------------------
94 {
95  sum = 0;
96  scores_start = &scores[0];
97 
98  for( Uint1 i = 0; i < num; ++i )
99  {
100  scores[i] = (*ustat)[(*window)[i]];
101 
102  // TODO: delete
103  // std::cerr << std::hex << (*window)[i] << ' ' << scores[i] << std::dec << std::endl;
104 
105  sum += scores[i];
106  }
107 
108  /*!!!!NEW CODE*/ start = window->Start();
109 }
110 
CSeqMaskerScoreMean(const CRef< CSeqMaskerIstat > &ustat)
Object constructor.
virtual Uint4 operator()()
Access the score of the current window.
virtual void Init()
Object initialization.
virtual void PostAdvance(Uint4 step)
Postprocessing after window advancement.
virtual void PreAdvance(Uint4 step)
Preprocessing before window advancement.
Abstract base class for score function objects.
const CSeqMaskerWindow * window
Points to the window information object.
Uint4 Start() const
Get the current starting position of the window.
Uint1 NumUnits() const
Get the number of units in a window.
Uint1 UnitStep() const
Get the current value of the unit step.
uint8_t Uint1
1-byte (8-bit) unsigned integer
Definition: ncbitype.h:99
uint32_t Uint4
4-byte (32-bit) unsigned integer
Definition: ncbitype.h:103
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
unsigned int
A callback function used to compare two keys in a database.
Definition: types.hpp:1210
int i
Modified on Fri Sep 20 14:57:20 2024 by modify_doxy.py rev. 669887