Mise à jour terminée. Pour connaître les apports de la version 13.8.4 par rapport à notre ancienne version vous pouvez lire les "Release Notes" suivantes :
https://about.gitlab.com/releases/2021/02/11/security-release-gitlab-13-8-4-released/
https://about.gitlab.com/releases/2021/02/05/gitlab-13-8-3-released/

dynprog.h 2.84 KB
Newer Older
Mikaël Salson's avatar
Mikaël Salson committed
1 2 3 4 5 6 7 8 9 10
#ifndef DYNPROG_H
#define DYNPROG_H

#include <string>
#include <vector>

#include <iostream>
#include <iomanip>


Mikaël Salson's avatar
Mikaël Salson committed
11
#define MINUS_INF -9999
Mikaël Salson's avatar
Mikaël Salson committed
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 44 45 46 47 48 49

using namespace std;


float identity_percent(int score);

class Cost
{
 public:
  int match;
  int mismatch;

  /**
   * @param homopolymer: if MINUS_INF => same score as indel 
   */

  // del_end -> utilise seulement pour LocalEndWithSomeDeletions
  Cost (int match, int mismatch, int indel, int del_end = 0, int homopolymer = MINUS_INF);
  Cost ();

  int insertion;
  int deletion;
  int deletion_end;
  int homopolymer;
  int substitution(char a, char b);
  //int ins(char current, char next);
  //int del(char current, char next);
  int homo2(char xa, char xb, char y);
};


ostream& operator<<(ostream& out, const Cost& cost);


/* const Cost DNA = Cost(+5, -4, -10); */
/* const Cost VDJ = Cost(+5, -8, -8, -1); */

const Cost DNA = Cost(+5, -4, -10, 0, 0);
Mathieu Giraud's avatar
Mathieu Giraud committed
50
const Cost VDJ = Cost(+4, -6, -10, -1, -2);
Mikaël Salson's avatar
Mikaël Salson committed
51 52 53 54 55 56 57
const Cost Identity = Cost(+1, -1, -1, 0, 0);

const Cost Homopolymers = Cost(+1, MINUS_INF, -1); // TODO: true homopolymer
const Cost IdentityToto= Cost(+1, -1, -1); // avec seuil de length-2: un homopoly xou une substituion
/* const Cost Identity = Cost(+1, 0, 0); */
const Cost IdentityDirty = Cost(+1000, -1, -1); // pour avoir une estimation de longueur de l'alignement, utilise dans compare-all
const Cost Hamming = Cost(0, -1, MINUS_INF);
WebTogz's avatar
WebTogz committed
58
const Cost Levenshtein = Cost(0, -1, -1);
Mikaël Salson's avatar
Mikaël Salson committed
59 60 61 62 63 64 65 66 67 68 69 70
const Cost Cluster = Cost(+1, -4, -4, 0, 0);

//const Cost Hamming = Cost();

class DynProg
{
 public:
  enum DynProgMode {
    Local,            // partial x / partial y
    LocalEndWithSomeDeletions, // local + some deletions on __
    SemiGlobalTrans,  // start-to-partial x / partial-to-end y 
    SemiGlobal,       // complete x / partial y
Mathieu Giraud's avatar
Mathieu Giraud committed
71
    GlobalButMostlyLocal,  // complete x / complete y, but deletions at begin (DONE) and end (TODO) are cheaper
Mikaël Salson's avatar
Mikaël Salson committed
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99
    Global            // complete x / complete y
  } ;

  DynProgMode mode ;
  Cost cost;

 private:
  string x ;
  string y ;
  int m ;
  int n ;
  bool reverse_x ;
  bool reverse_y ;

 public:
  int best_score ;
  int best_i ;                  /* Start at 1 */
  int best_j ;                  /* Start at 1 */
  int first_i ;                 /* Start at 1 */
  int first_j ;                 /* Start at 1 */
  string str_back ;

  DynProg(const string &x, const string &y, DynProgMode mode, const Cost &c, const bool reverse_x=false, const bool reverse_y=false);
  ~DynProg();
  void init();
  int compute();
  void backtrack();
  void SemiGlobal_hits_threshold(vector<int> &hits, int threshold, int shift_pos, int verbose);
Mikaël Salson's avatar
Mikaël Salson committed
100

Mikaël Salson's avatar
Mikaël Salson committed
101 102 103 104 105 106
  string SemiGlobal_extract_best();

  friend ostream& operator<<(ostream& out, const DynProg& dp);
  
  int **S;
  int ***B;
Mikaël Salson's avatar
Mikaël Salson committed
107 108 109
  int *gap1 ;
  int *linkgap ;
  int *gap2 ;
Mikaël Salson's avatar
Mikaël Salson committed
110 111 112 113 114 115 116 117 118

};

ostream& operator<<(ostream& out, const DynProg& dp);

Cost strToCost(string str, Cost default_cost);

#endif