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

« back to all changes in this revision

Viewing changes to GDE/MUSCLE/src/distfunc.cpp

  • 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
#include "muscle.h"
 
2
#include "distfunc.h"
 
3
#include <assert.h>
 
4
 
 
5
DistFunc::DistFunc()
 
6
        {
 
7
        m_Dists = 0;
 
8
        m_uCount = 0;
 
9
        m_uCacheCount = 0;
 
10
        m_Names = 0;
 
11
        m_Ids = 0;
 
12
        }
 
13
 
 
14
DistFunc::~DistFunc()
 
15
        {
 
16
        if (0 != m_Names)
 
17
                {
 
18
                for (unsigned i = 0; i < m_uCount; ++i)
 
19
                        free(m_Names[i]);
 
20
                }
 
21
        delete[] m_Dists;
 
22
        delete[] m_Names;
 
23
        delete[] m_Ids;
 
24
        }
 
25
 
 
26
float DistFunc::GetDist(unsigned uIndex1, unsigned uIndex2) const
 
27
        {
 
28
        return m_Dists[VectorIndex(uIndex1, uIndex2)];
 
29
        }
 
30
 
 
31
unsigned DistFunc::GetCount() const
 
32
        {
 
33
        return m_uCount;
 
34
        }
 
35
 
 
36
void DistFunc::SetCount(unsigned uCount)
 
37
        {
 
38
        m_uCount = uCount;
 
39
        if (uCount <= m_uCacheCount)
 
40
                return;
 
41
        delete[] m_Dists;
 
42
        m_Dists = new float[VectorLength()];
 
43
        m_Names = new char *[m_uCount];
 
44
        m_Ids = new unsigned[m_uCount];
 
45
        m_uCacheCount = uCount;
 
46
 
 
47
        memset(m_Names, 0, m_uCount*sizeof(char *));
 
48
        memset(m_Ids, 0xff, m_uCount*sizeof(unsigned));
 
49
        memset(m_Dists, 0, VectorLength()*sizeof(float));
 
50
        }
 
51
 
 
52
void DistFunc::SetDist(unsigned uIndex1, unsigned uIndex2, float dDist)
 
53
        {
 
54
        m_Dists[VectorIndex(uIndex1, uIndex2)] = dDist;
 
55
        m_Dists[VectorIndex(uIndex2, uIndex1)] = dDist;
 
56
        }
 
57
 
 
58
unsigned DistFunc::VectorIndex(unsigned uIndex1, unsigned uIndex2) const
 
59
        {
 
60
        assert(uIndex1 < m_uCount && uIndex2 < m_uCount);
 
61
        return uIndex1*m_uCount + uIndex2;
 
62
        }
 
63
 
 
64
unsigned DistFunc::VectorLength() const
 
65
        {
 
66
        return m_uCount*m_uCount;
 
67
        }
 
68
 
 
69
void DistFunc::SetName(unsigned uIndex, const char szName[])
 
70
        {
 
71
        assert(uIndex < m_uCount);
 
72
        m_Names[uIndex] = strsave(szName);
 
73
        }
 
74
 
 
75
void DistFunc::SetId(unsigned uIndex, unsigned uId)
 
76
        {
 
77
        assert(uIndex < m_uCount);
 
78
        m_Ids[uIndex] = uId;
 
79
        }
 
80
 
 
81
const char *DistFunc::GetName(unsigned uIndex) const
 
82
        {
 
83
        assert(uIndex < m_uCount);
 
84
        return m_Names[uIndex];
 
85
        }
 
86
 
 
87
unsigned DistFunc::GetId(unsigned uIndex) const
 
88
        {
 
89
        assert(uIndex < m_uCount);
 
90
        return m_Ids[uIndex];
 
91
        }
 
92
 
 
93
void DistFunc::LogMe() const
 
94
        {
 
95
        Log("DistFunc::LogMe count=%u\n", m_uCount);
 
96
        Log("                     ");
 
97
        for (unsigned i = 0; i < m_uCount; ++i)
 
98
                Log(" %7u", i);
 
99
        Log("\n");
 
100
 
 
101
        Log("                     ");
 
102
        for (unsigned i = 0; i < m_uCount; ++i)
 
103
                Log(" %7.7s", m_Names[i] ? m_Names[i] : "");
 
104
        Log("\n");
 
105
 
 
106
        for (unsigned i = 0; i < m_uCount; ++i)
 
107
                {
 
108
                Log("%4u  %10.10s  :  ", i, m_Names[i] ? m_Names[i] : "");
 
109
                for (unsigned j = 0; j <= i; ++j)
 
110
                        Log(" %7.4g", GetDist(i, j));
 
111
                Log("\n");
 
112
                }
 
113
        }