~ubuntu-branches/debian/jessie/arb/jessie

« back to all changes in this revision

Viewing changes to GDE/MAFFT/mafft-7.055-with-extensions/extensions/mxscarna_src/BPPMatrix.hpp

  • Committer: Package Import Robot
  • Author(s): Elmar Pruesse, Andreas Tille, Elmar Pruesse
  • Date: 2014-09-02 15:15:06 UTC
  • mfrom: (1.1.6)
  • Revision ID: package-import@ubuntu.com-20140902151506-jihq58b3iz342wif
Tags: 6.0.2-1
[ Andreas Tille ]
* New upstream version
  Closes: #741890
* debian/upstream -> debian/upstream/metadata
* debian/control:
   - Build-Depends: added libglib2.0-dev
   - Depends: added mafft, mrbayes
* debian/rules
   - Add explicite --remove-section=.comment option to manual strip call
* cme fix dpkg-control
* arb-common.dirs: Do not create unneeded lintian dir
* Add turkish debconf translation (thanks for the patch to Mert Dirik
  <mertdirik@gmail.com>)
  Closes: #757497

[ Elmar Pruesse ]
* patches removed:
   - 10_config.makefiles.patch,
     80_no_GL.patch
       removed in favor of creating file from config.makefile.template via 
       sed in debian/control
   - 20_Makefile_main.patch
       merged upstream
   - 21_Makefiles.patch
       no longer needed
   - 30_tmpfile_CVE-2008-5378.patch: 
       merged upstream
   - 50_fix_gcc-4.8.patch:
       merged upstream
   - 40_add_libGLU.patch:
       libGLU not needed for arb_ntree)
   - 60_use_debian_packaged_raxml.patch:
       merged upstream
   - 70_hardening.patch
       merged upstream
   - 72_add_math_lib_to_linker.patch
       does not appear to be needed
* patches added:
   - 10_upstream_r12793__show_db_load_progress:
       backported patch showing progress while ARB is loading a database
       (needed as indicator/splash screen while ARB is launching)
   - 20_upstream_r12794__socket_permissions:
       backported security fix
   - 30_upstream_r12814__desktop_keywords:
       backported add keywords to desktop (fixes lintian warning)
   - 40_upstream_r12815__lintian_spelling:
       backported fix for lintian reported spelling errors
   - 50_private_nameservers
       change configuration to put nameservers into users home dirs
       (avoids need for shared writeable directory)
   - 60_use_debian_phyml
       use phyml from debian package for both interfaces in ARB
* debian/rules:
   - create config.makefile from override_dh_configure target
   - use "make tarfile" in override_dh_install
   - remove extra cleaning not needed for ARB 6
   - use "dh_install --list-missing" to avoid missing files
   - added override_dh_fixperms target
* debian/control:
   - added libarb-dev package
   - Depends: added phyml, xdg-utils
   - Suggests: removed phyml
   - fix lintian duplicate-short-description (new descriptions)
* debian/*.install:
   - "unrolled" confusing globbing to select files
   - pick files from debian/tmp
   - moved all config files to /etc/arb
* debian/arb-common.templates: updated
* scripts:
   - removed arb-add-pt-server
   - launch-wrapper: 
     - only add demo.arb to newly created $ARBUSERDATA
     - pass commandline arguments through bin/arb wrapper
   - preinst: removing old PT server index files on upgrade from 5.5*
   - postinst: set setgid on shared PT dir
* rewrote arb.1 manfile
* added file icon for ARB databases
* using upstream arb_tcp.dat

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
//////////////////////////////////////////////////////////////
 
2
// BPPMatrix.hpp
 
3
//
 
4
// save the Base Pairing Probability Matrix for each sequences
 
5
//////////////////////////////////////////////////////////////
 
6
 
 
7
#ifndef __BBPMatrix_HPP__
 
8
#define __BBPMatrix_HPP__
 
9
 
 
10
#include <iostream>
 
11
#include <string>
 
12
#include "SparseMatrix.h"
 
13
#include "McCaskill.hpp"
 
14
#include "nrutil.h"
 
15
 
 
16
 
 
17
 
 
18
using namespace std;
 
19
 
 
20
namespace MXSCARNA{
 
21
class BPPMatrix {
 
22
private:
 
23
 
 
24
    int seqLength;       // sequence length;
 
25
    float cutOff;        // the threshold of probability 
 
26
 
 
27
    BPPMatrix() {}
 
28
public:
 
29
    SparseMatrix bppMat; // base pairing probability matrix 1-origin(1..seqLength)
 
30
    BPPMatrix(int bppmode, const string &seq, int seqLength, float inCutOff = 0.0001) : seqLength (seqLength), cutOff(inCutOff) {
 
31
      if( bppmode == 'r' ) // by katoh
 
32
        readBPPMatrix(seq);
 
33
      else if( bppmode == 'w' )
 
34
        setandwriteBPPMatrix(seq);
 
35
      else
 
36
        setBPPMatrix(seq);
 
37
    }
 
38
    BPPMatrix(int seqLength, float inCutOff, const Trimat<float> & tmpBppMat) : seqLength(seqLength), cutOff(inCutOff) {
 
39
      bppMat.SetSparseMatrix(seqLength, seqLength, tmpBppMat, cutOff);
 
40
    }
 
41
 
 
42
      
 
43
    void setBPPMatrix(const string &seq) {
 
44
        const char *tmpSeq = seq.c_str();
 
45
        McCaskill mc(seqLength, &tmpSeq[1]);
 
46
        mc.calcPartitionFunction();
 
47
        Trimat<float> tmpBppMat(seqLength + 1);
 
48
 
 
49
        for (int i = 0; i < seqLength; i++) {
 
50
          for(int j = i; j < seqLength; j++) {
 
51
            tmpBppMat.ref(i+1, j+1) = mc.getProb(i,j);
 
52
          }
 
53
        }
 
54
        bppMat.SetSparseMatrix(seqLength, seqLength, tmpBppMat, cutOff);
 
55
    }
 
56
 
 
57
    void setandwriteBPPMatrix(const string &seq) { // by katoh
 
58
        const char *tmpSeq = seq.c_str();
 
59
        McCaskill mc(seqLength, &tmpSeq[1]);
 
60
        mc.calcPartitionFunction();
 
61
        Trimat<float> tmpBppMat(seqLength + 1);
 
62
        float tmpbp;
 
63
 
 
64
        fprintf( stdout, ">\n" );
 
65
        for (int i = 0; i < seqLength; i++) {
 
66
          for(int j = i; j < seqLength; j++) {
 
67
        tmpbp = mc.getProb(i,j);
 
68
        if (tmpbp > 0.0001)
 
69
          fprintf( stdout, "%d %d %50.40f\n", i, j, tmpbp );
 
70
            tmpBppMat.ref(i+1, j+1) = tmpbp;
 
71
          }
 
72
        }
 
73
        bppMat.SetSparseMatrix(seqLength, seqLength, tmpBppMat, cutOff);
 
74
    }
 
75
 
 
76
    void readBPPMatrix(const string &seq) { // by katoh
 
77
        const char *tmpSeq = seq.c_str();
 
78
        char oneline[1000];
 
79
        int onechar;
 
80
        float prob;
 
81
        int posi, posj;
 
82
        static FILE *bppfp = NULL;
 
83
 
 
84
 
 
85
        if( bppfp == NULL )
 
86
        {
 
87
                bppfp = fopen( "_bpp", "r" );
 
88
                if( bppfp == NULL )
 
89
                {
 
90
                        fprintf( stderr, "Cannot open _bpp.\n" );
 
91
                        exit( 1 );
 
92
                }
 
93
        }
 
94
 
 
95
        Trimat<float> tmpBppMat(seqLength + 1);
 
96
        fgets( oneline, 999, bppfp );
 
97
        if( oneline[0] != '>' )
 
98
        {
 
99
                fprintf( stderr, "Format error\n" );
 
100
                exit( 1 );
 
101
        }
 
102
        while( 1 )
 
103
        {
 
104
                onechar = getc( bppfp ); 
 
105
                ungetc( onechar, bppfp );
 
106
                if( onechar == '>' || onechar == EOF ) break;
 
107
 
 
108
                fgets( oneline, 999, bppfp );
 
109
                sscanf( oneline, "%d %d %f", &posi, &posj, &prob );
 
110
//              fprintf( stderr, "%d %d -> %f\n", posi, posj, prob );
 
111
                tmpBppMat.ref(posi+1, posj+1) = prob;
 
112
        }
 
113
 
 
114
        bppMat.SetSparseMatrix(seqLength, seqLength, tmpBppMat, cutOff);
 
115
    }
 
116
 
 
117
    float GetProb(int i, int j) {
 
118
        return bppMat.GetValue(i,j);
 
119
    }
 
120
 
 
121
    float GetLength() const {
 
122
        return seqLength;
 
123
    }
 
124
    
 
125
    void updateBPPMatrix(const Trimat<float> &inbppMat) {
 
126
        bppMat.SetSparseMatrix(seqLength, seqLength, inbppMat, cutOff);
 
127
    }
 
128
};
 
129
}
 
130
#endif // __BPPMatrix_HPP__