File: SimplePosBias.hpp

package info (click to toggle)
salmon 0.7.2%2Bds1-2
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 4,352 kB
  • ctags: 5,243
  • sloc: cpp: 42,341; ansic: 6,252; python: 228; makefile: 207; sh: 190
file content (43 lines) | stat: -rw-r--r-- 1,300 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#ifndef SIMPLE_POS_BIAS_HPP
#define SIMPLE_POS_BIAS_HPP

#include "spline.h"
#include <array>
#include <vector>

class SimplePosBias {
public:
  SimplePosBias(int32_t numBins = 20, bool logSpace = true);

  // Add a mass of @mass to bin @bin
  void addMass(int32_t bin, double mass);

  // Compute the bin for @pos on a transcript of length @length,
  // and add @mass to the appropriate bin
  void addMass(int32_t pos, int32_t length, double mass);

  // Project, via linear interpolation, the weights contained in "bins"
  // into the vector @out.
  void projectWeights(std::vector<double>& out);

  // Combine the distribution @other
  // with this distribution
  void combine(const SimplePosBias& other);

  // We're finished updating this distribution, so
  // compute the cdf etc.
  void finalize();

private:
  int32_t numBins_;
  std::vector<double> masses_;
  bool isLogged_{true};
  tk::spline s_;
  // position bins taken from Cufflinks:
  // https://github.com/cole-trapnell-lab/cufflinks/blob/master/src/biascorrection.cpp
  const std::vector<double> positionBins_{{.02, .04, .06, .08, .10, .15, .2,
                                           .3,  .4,  .5,  .6,  .7,  .8,  .85,
                                           .9,  .92, .94, .96, .98, 1.0}};
};

#endif // SIMPLE_POS_BIAS_HPP