Skip to content
Commits on Source (8)
......@@ -4,12 +4,18 @@ Upstream-Contact: UniPro <ugene@unipro.ru>
Ivan Efremov <iefremov@unipro.ru>
Source: https://github.com/ugeneunipro/ugene/releases
Files-Excluded: */src/libs_3rdparty/zlib
*/src/libs_3rdparty/sqlite3
*/macosx
*/windows
*/windows_x64
*/i686
*/x86_64
*/ubuntu
src/plugins_3rdparty/phylip/src/c*
src/plugins_3rdparty/phylip/src/d*
src/plugins_3rdparty/phylip/src/n*
src/plugins_3rdparty/phylip/src/p*
src/plugins_3rdparty/phylip/src/s*
Files: *
Copyright: © 2008-2015 UniPro <ugene@unipro.ru>
......@@ -231,27 +237,10 @@ License: LGPL-2.1
On Debian systems, see /usr/share/common-licenses/LGPL-2.1 for the
full text of the license.
Files: src/plugins_3rdparty/phylyp/src/*
Copyright: © 1993-2004 by the University of Washington.
Joseph Felsenstein, Akiko Fuseki, Sean Lamont, and Andrew Keeffe.
License: non-free_phylip
Permission is granted to copy and use this program provided no fee is
charged for it and provided that this copyright notice is not removed.
Files: src/plugins_3rdparty/kalign/src/*
Copyright: © 2006 Timo Lassmann <timolassmann@gmail.com>
License: GPL-2+
Files: src/libs_3rdparty/sqlite3/src/*
Copyright: The author D. Richard Hipp <drh@hwaci.com> disclaims copyright
to this source code.
License: PD+blessing
In place of a legal notice, here is a blessing:
.
May you do good and not evil.
May you find forgiveness for yourself and forgive others.
May you share freely, never taking more than you give.
Files: src/include/opencl/legacy/*
Copyright: © 2008-2010 The Khronos Group Inc.
License: BSD+Khronos
......
Author: Andreas Tille <tille@debian.org>
Last-Update: Sun, 03 Dec 2017 19:10:03 +0100
Description: Replace zlib and sqlite3 by Debian packaged libs
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -35,8 +35,6 @@ set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS
......
Author: Andreas Tille <tille@debian.org>
Last-Update: Sun, 03 Dec 2017 19:10:03 +0100
Description: Do not build phylip plugin which is removed since
the code copy of the old version has no free license
--- a/ugene.pro
+++ b/ugene.pro
@@ -45,7 +45,6 @@ SUBDIRS += \
src/plugins_3rdparty/gor4 \
src/plugins_3rdparty/psipred \
src/plugins_3rdparty/primer3 \
- src/plugins_3rdparty/phylip \
src/plugins_3rdparty/kalign \
src/plugins_3rdparty/ptools \
src/plugins_3rdparty/variants \
......@@ -2,3 +2,4 @@ use_debian_sqlite.patch
hardening.patch
debian_packaged_libs.patch
add_missing_header.patch
do_not_build_phylip.patch
......@@ -165,3 +165,75 @@ Last-Updated: 2013-11-30
if(exclude_list_enabled()|!exists( ../libs_3rdparty/QSpec/QSpec.pro )) {
LIBS -= -lQSpecd
}
--- a/src/corelibs/U2Core/src/dbi/U2SQLiteTripleStore.cpp
+++ b/src/corelibs/U2Core/src/dbi/U2SQLiteTripleStore.cpp
@@ -19,7 +19,7 @@
* MA 02110-1301, USA.
*/
-#include <3rdparty/sqlite3/sqlite3.h>
+#include <sqlite3.h>
#include <U2Core/Log.h>
#include <U2Core/U2SafePoints.h>
--- a/src/include/3rdparty/sqlite3/sqlite3.h
+++ b/src/include/3rdparty/sqlite3/sqlite3.h
@@ -1 +1 @@
-#include "../../../libs_3rdparty/sqlite3/src/sqlite3.h"
\ No newline at end of file
+#include "sqlite3.h"
--- a/src/corelibs/U2Core/src/dbi/U2SqlHelpers.cpp
+++ b/src/corelibs/U2Core/src/dbi/U2SqlHelpers.cpp
@@ -25,7 +25,7 @@
#include <U2Core/U2DbiUtils.h>
#include <U2Core/U2SafePoints.h>
-#include <3rdparty/sqlite3/sqlite3.h>
+#include <sqlite3.h>
namespace U2 {
--- a/src/corelibs/U2Formats/src/sqlite_dbi/SQLiteBlobInputStream.cpp
+++ b/src/corelibs/U2Formats/src/sqlite_dbi/SQLiteBlobInputStream.cpp
@@ -19,7 +19,7 @@
* MA 02110-1301, USA.
*/
-#include <3rdparty/sqlite3/sqlite3.h>
+#include <sqlite3.h>
#include <U2Core/U2DbiUtils.h>
#include <U2Core/U2SafePoints.h>
--- a/src/corelibs/U2Formats/src/sqlite_dbi/SQLiteBlobOutputStream.cpp
+++ b/src/corelibs/U2Formats/src/sqlite_dbi/SQLiteBlobOutputStream.cpp
@@ -19,7 +19,7 @@
* MA 02110-1301, USA.
*/
-#include <3rdparty/sqlite3/sqlite3.h>
+#include <sqlite3.h>
#include <U2Core/U2SafePoints.h>
#include <U2Core/UdrSchema.h>
--- a/src/corelibs/U2Formats/src/sqlite_dbi/SQLiteDbi.cpp
+++ b/src/corelibs/U2Formats/src/sqlite_dbi/SQLiteDbi.cpp
@@ -41,7 +41,7 @@
#include <QFile>
-#include <3rdparty/sqlite3/sqlite3.h>
+#include <sqlite3.h>
namespace U2 {
--- a/src/plugins/dbi_bam/src/Dbi.cpp
+++ b/src/plugins/dbi_bam/src/Dbi.cpp
@@ -33,7 +33,7 @@
#include <U2Core/U2OpStatusUtils.h>
#include <U2Core/IOAdapterUtils.h>
-#include <3rdparty/sqlite3/sqlite3.h>
+#include <sqlite3.h>
namespace U2 {
namespace BAM {
......@@ -2,22 +2,12 @@
export DH_OPTIONS
CPPFLAGS=$(shell dpkg-buildflags --get CPPFLAGS)
CFLAGS=$(shell dpkg-buildflags --get CFLAGS) $(CPPFLAGS)
CXXFLAGS=$(shell dpkg-buildflags --get CXXFLAGS) $(CPPFLAGS)
LDFLAGS=$(shell dpkg-buildflags --get LDFLAGS)
export QT_SELECT=qt5
UPSTREAM_NAME=ugene
pkg := $(shell dpkg-parsechangelog | sed -n 's/^Source: //p')
include /usr/share/dpkg/default.mk
export DEB_BUILD_MAINT_OPTIONS = hardening=+all
#.PHONY: override_dh_strip
#override_dh_strip:
# dh_strip --dbg-package=ugene-dbg
%:
dh $@ --buildsystem=qmake
......@@ -37,9 +27,9 @@ override_dh_auto_clean:
override_dh_auto_install:
dh_auto_install
# This should be default:
# $(MAKE) INSTALL_ROOT=$$(pwd)/debian/$(pkg) install
# $(MAKE) INSTALL_ROOT=$$(pwd)/debian/$(DEB_SOURCE) install
# Remove data dir which goes to ugene-data package
rm -rf debian/$(pkg)/usr/share/$(pkg)
rm -rf debian/$(DEB_SOURCE)/usr/share/$(DEB_SOURCE)
override_dh_fixperms-indep:
dh_fixperms
......@@ -48,7 +38,7 @@ override_dh_fixperms-indep:
rm -f debian/ugene-data/usr/share/ugene/data/license
override_dh_shlibdeps:
dh_shlibdeps -l$(CURDIR)/debian/$(pkg)/usr/lib/$(pkg)/
dh_shlibdeps -l$(CURDIR)/debian/$(DEB_SOURCE)/usr/lib/$(DEB_SOURCE)/:/build/ugene-1.31.1+dfsg/debian/$(DEB_SOURCE)/usr/lib/$(DEB_SOURCE)/plugins/
override_dh_dwz:
echo "Do not run dh_dwz since it just results in:"
......
data /usr/share/ugene
usr/share/ugene/data
ugene usr/bin
src/_release/* usr/lib/ugene
usr/bin
usr/lib/ugene
usr/share/applications
usr/share/pixmaps
usr/share/mime
usr/share/man/man1/*
cmake_minimum_required(VERSION 3.4)
project(ugenedb)
include_directories(src)
file(GLOB_RECURSE SRCS src/*.c)
file(GLOB_RECURSE HDRS src/*.h)
add_definitions(
-DSQLITE_ENABLE_COLUMN_METADATA
-DSQLITE_ENABLE_RTREE
-DSQLITE_OMIT_LOAD_EXTENSION
-DTHREADSAFE
)
add_library(ugenedb SHARED ${HDRS} ${SRCS})
target_link_libraries(ugenedb)
# include (sqlite.pri)
include( ../../ugene_globals.pri )
UGENE_RELATIVE_DESTDIR = ''
TARGET = ugenedb
TEMPLATE = lib
CONFIG +=thread debug_and_release warn_off
INCLUDEPATH += src
DEFINES+=SQLITE_ENABLE_COLUMN_METADATA
DEFINES+=SQLITE_ENABLE_RTREE
unix:DEFINES+=SQLITE_OMIT_LOAD_EXTENSION
DEFINES+=THREADSAFE
LIBS += -L../../_release
!debug_and_release|build_pass {
CONFIG(debug, debug|release) {
TARGET = ugenedbd
DEFINES+=_DEBUG
CONFIG +=console
DESTDIR=../../_debug/
OBJECTS_DIR=_tmp/obj/debug
LIBS -= -L../../_release
LIBS += -L../../_debug
}
CONFIG(release, debug|release) {
TARGET = ugenedb
DEFINES+=NDEBUG
DESTDIR=../../_release/
OBJECTS_DIR=_tmp/obj/release
}
}
win32 {
DEF_FILE=$$PWD/src/sqlite3.def
QMAKE_CXXFLAGS_WARN_ON = -W3
QMAKE_CFLAGS_WARN_ON = -W3
QMAKE_MSVC_PROJECT_NAME=lib_3rd_sqlite3
}
unix {
target.path = $$UGENE_INSTALL_DIR/$$UGENE_RELATIVE_DESTDIR
INSTALLS += target
}
macx {
QMAKE_RPATHDIR += @executable_path/
QMAKE_LFLAGS_SONAME = -Wl,-dylib_install_name,@rpath/
}
include (sqlite3.pri)
# Input
HEADERS += src/sqlite3.h
SOURCES += src/sqlite3.c
\ No newline at end of file
This diff is collapsed.
EXPORTS
sqlite3_aggregate_context
sqlite3_aggregate_count
sqlite3_auto_extension
sqlite3_backup_finish
sqlite3_backup_init
sqlite3_backup_pagecount
sqlite3_backup_remaining
sqlite3_backup_step
sqlite3_bind_blob
sqlite3_bind_double
sqlite3_bind_int
sqlite3_bind_int64
sqlite3_bind_null
sqlite3_bind_parameter_count
sqlite3_bind_parameter_index
sqlite3_bind_parameter_name
sqlite3_bind_text
sqlite3_bind_text16
sqlite3_bind_value
sqlite3_bind_zeroblob
sqlite3_blob_bytes
sqlite3_blob_close
sqlite3_blob_open
sqlite3_blob_read
sqlite3_blob_write
sqlite3_busy_handler
sqlite3_busy_timeout
sqlite3_changes
sqlite3_clear_bindings
sqlite3_close
sqlite3_collation_needed
sqlite3_collation_needed16
sqlite3_column_blob
sqlite3_column_bytes
sqlite3_column_bytes16
sqlite3_column_count
sqlite3_column_database_name
sqlite3_column_database_name16
sqlite3_column_decltype
sqlite3_column_decltype16
sqlite3_column_double
sqlite3_column_int
sqlite3_column_int64
sqlite3_column_name
sqlite3_column_name16
sqlite3_column_origin_name
sqlite3_column_origin_name16
sqlite3_column_table_name
sqlite3_column_table_name16
sqlite3_column_text
sqlite3_column_text16
sqlite3_column_type
sqlite3_column_value
sqlite3_commit_hook
sqlite3_compileoption_get
sqlite3_compileoption_used
sqlite3_complete
sqlite3_complete16
sqlite3_config
sqlite3_context_db_handle
sqlite3_create_collation
sqlite3_create_collation16
sqlite3_create_collation_v2
sqlite3_create_function
sqlite3_create_function16
sqlite3_create_module
sqlite3_create_module_v2
sqlite3_data_count
sqlite3_db_config
sqlite3_db_handle
sqlite3_db_mutex
sqlite3_db_readonly
sqlite3_db_status
sqlite3_declare_vtab
sqlite3_enable_load_extension
sqlite3_enable_shared_cache
sqlite3_errcode
sqlite3_errmsg
sqlite3_errmsg16
sqlite3_exec
sqlite3_expired
sqlite3_extended_errcode
sqlite3_extended_result_codes
sqlite3_file_control
sqlite3_finalize
sqlite3_free
sqlite3_free_table
sqlite3_get_autocommit
sqlite3_get_auxdata
sqlite3_get_table
sqlite3_global_recover
sqlite3_initialize
sqlite3_interrupt
sqlite3_last_insert_rowid
sqlite3_libversion
sqlite3_libversion_number
sqlite3_limit
sqlite3_load_extension
sqlite3_log
sqlite3_malloc
sqlite3_memory_alarm
sqlite3_memory_highwater
sqlite3_memory_used
sqlite3_mprintf
sqlite3_mutex_alloc
sqlite3_mutex_enter
sqlite3_mutex_free
sqlite3_mutex_leave
sqlite3_mutex_try
sqlite3_next_stmt
sqlite3_open
sqlite3_open16
sqlite3_open_v2
sqlite3_os_end
sqlite3_os_init
sqlite3_overload_function
sqlite3_prepare
sqlite3_prepare16
sqlite3_prepare16_v2
sqlite3_prepare_v2
sqlite3_profile
sqlite3_progress_handler
sqlite3_randomness
sqlite3_realloc
sqlite3_release_memory
sqlite3_reset
sqlite3_reset_auto_extension
sqlite3_result_blob
sqlite3_result_double
sqlite3_result_error
sqlite3_result_error16
sqlite3_result_error_code
sqlite3_result_error_nomem
sqlite3_result_error_toobig
sqlite3_result_int
sqlite3_result_int64
sqlite3_result_null
sqlite3_result_text
sqlite3_result_text16
sqlite3_result_text16be
sqlite3_result_text16le
sqlite3_result_value
sqlite3_result_zeroblob
sqlite3_rollback_hook
sqlite3_set_authorizer
sqlite3_set_auxdata
sqlite3_shutdown
sqlite3_sleep
sqlite3_snprintf
sqlite3_soft_heap_limit
sqlite3_sourceid
sqlite3_sql
sqlite3_status
sqlite3_step
sqlite3_stmt_status
sqlite3_strnicmp
sqlite3_table_column_metadata
sqlite3_test_control
sqlite3_thread_cleanup
sqlite3_threadsafe
sqlite3_total_changes
sqlite3_trace
sqlite3_transfer_bindings
sqlite3_update_hook
sqlite3_user_data
sqlite3_value_blob
sqlite3_value_bytes
sqlite3_value_bytes16
sqlite3_value_double
sqlite3_value_int
sqlite3_value_int64
sqlite3_value_numeric_type
sqlite3_value_text
sqlite3_value_text16
sqlite3_value_text16be
sqlite3_value_text16le
sqlite3_value_type
sqlite3_version
sqlite3_vfs_find
sqlite3_vfs_register
sqlite3_vfs_unregister
sqlite3_vmprintf
sqlite3_wal_autocheckpoint
sqlite3_wal_checkpoint
sqlite3_wal_hook
sqlite3_win32_mbcs_to_utf8
This diff is collapsed.
This diff is collapsed.
#pragma once
#define OVER_C 8
#define ADJACENT_PAIRS 1
#define CORR_IN_1_AND_2 2
#define ALL_IN_1_AND_2 3
#define NO_PAIRING 4
#define ALL_IN_FIRST 5
#define TREE1 8
#define TREE2 9
#define FULL_MATRIX 11
#define VERBOSE 22
#define SPARSE 33
/* Number of columns per block in a matrix output */
#define COLUMNS_PER_BLOCK 10
extern int tree_pairing;
extern Phylip_Char outfilename[FNMLNGTH], intreename[FNMLNGTH], intree2name[FNMLNGTH], outtreename[FNMLNGTH];
extern node *root;
extern long numopts, outgrno_cons, col, setsz;
extern long maxgrp; /* max. no. of groups in all trees found */
extern boolean trout, firsttree, noroot, outgropt_cons, didreroot, prntsets,
treeprint_cons, goteof, strict, mr, mre,
ml; /* initialized all false for Treedist */
extern boolean progress;
extern pointarray nodep_cons;
extern pointarray treenode;
extern group_type **grouping, **grping2, **group2;/* to store groups found */
extern double *lengths, *lengths2;
extern long **order, **order2, lasti;
extern group_type *fullset;
extern node *grbg;
extern long tipy;
extern double **timesseen, **tmseen2, **times2 ;
extern double *tchange2;
extern double trweight, ntrees, mlfrac;
typedef struct pattern_elm {
group_type *apattern;
long *patternsize;
double *length;
} pattern_elm;
#define NUM_BUCKETS 100
typedef struct namenode {
struct namenode *next;
plotstring naym;
int hitCount;
} namenode;
typedef namenode **hashtype;
extern hashtype hashp;
long namesGetBucket(plotstring);
void namesAdd(plotstring);
boolean namesSearch(plotstring);
void namesDelete(plotstring);
void namesClearTable(void);
void namesCheckTable(void);
void missingnameRecurs(node *p);
#ifndef OLDC
/* function prototypes */
void consens_starter(const char* filename, double fraction, bool _strict, bool _mre, bool _mr, bool _m1);
void consens_free_res();
void initconsnode(node **, node **, node *, long, long, long *, long *,
initops, pointarray, pointarray, Phylip_Char *, Phylip_Char *, FILE *);
void compress(long *);
void sort(long);
void eliminate(long *, long *);
void printset(long);
void bigsubset(group_type *, long);
void recontraverse(node **, group_type *, long, long *);
void reconstruct(long);
void coordinates(node *, long *);
void drawline(long i);
void printree(void);
void consensus(pattern_elm ***, long);
void rehash(void);
void enternodeset(node *r);
void accumulate(node *);
void dupname2(Phylip_Char *, node *, node *);
void dupname(node *);
void missingname(node *);
void gdispose(node *);
void initreenode(node *);
void reroot(node *, long *);
void store_pattern (pattern_elm ***, int);
boolean samename(naym, plotstring);
void reordertips(void);
void read_groups (pattern_elm ****, long, long, FILE *);
void clean_up_final(void);
/* function prototypes */
#endif
extern long setsz;
#include "phylip.h"
#include "dist.h"
#include <QString>
/* version 3.696.
Written by Joseph Felsenstein, Akiko Fuseki, Sean Lamont, and Andrew Keeffe.
Copyright (c) 1993-2014, Joseph Felsenstein
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
void dist_alloctree(pointptr *treenode, long nonodes, U2::MemoryLocker& memLocker)
{
/* allocate spp tips and (nonodes - spp) forks, each containing three
* nodes. Fill in treenode where 0..spp-1 are pointers to tip nodes, and
* spp..nonodes-1 are pointers to one node in each fork. */
/* used in fitch, kitsch, neighbor */
long i, j;
node *p, *q;
if(!memLocker.tryAcquire(nonodes*sizeof(node *) + spp * sizeof(node) + nonodes*3*sizeof(node))) {
return;
}
*treenode = (pointptr)Malloc(nonodes*sizeof(node *));
for (i = 0; i < spp; i++)
(*treenode)[i] = (node *)Malloc(sizeof(node));
for (i = spp; i < nonodes; i++) {
q = NULL;
for (j = 1; j <= 3; j++) {
p = (node *)Malloc(sizeof(node));
p->next = q;
q = p;
}
p->next->next->next = p;
(*treenode)[i] = p;
}
} /* alloctree */
void dist_freetree(pointptr *treenode, long nonodes)
{
long i;
node *p, *q;
for (i = 0; i < spp; i++)
free((*treenode)[i]);
for (i = spp; i < nonodes; i++) {
p = (*treenode)[i];
q = p->next;
while(q != p)
{
node * r = q;
q = q->next;
free(r);
}
free(p);
}
free(*treenode);
} /* freetree */
void allocd(long nonodes, pointptr treenode)
{
/* used in fitch & kitsch */
long i, j;
node *p;
for (i = 0; i < (spp); i++) {
treenode[i]->d = (vector)Malloc(nonodes*sizeof(double));
}
for (i = spp; i < nonodes; i++) {
p = treenode[i];
for (j = 1; j <= 3; j++) {
p->d = (vector)Malloc(nonodes*sizeof(double));
p = p->next;
}
}
}
void freed(long nonodes, pointptr treenode)
{
/* used in fitch */
long i, j;
node *p;
for (i = 0; i < (spp); i++) {
free(treenode[i]->d);
}
for (i = spp; i < nonodes; i++) {
p = treenode[i];
for (j = 1; j <= 3; j++) {
free(p->d);
p = p->next;
}
}
}
void allocw(long nonodes, pointptr treenode)
{
/* used in fitch & kitsch */
long i, j;
node *p;
for (i = 0; i < (spp); i++) {
treenode[i]->w = (vector)Malloc(nonodes*sizeof(double));
}
for (i = spp; i < nonodes; i++) {
p = treenode[i];
for (j = 1; j <= 3; j++) {
p->w = (vector)Malloc(nonodes*sizeof(double));
p = p->next;
}
}
}
void freew(long nonodes, pointptr treenode)
{
/* used in fitch */
long i, j;
node *p;
for (i = 0; i < (spp); i++) {
free(treenode[i]->w);
}
for (i = spp; i < nonodes; i++) {
p = treenode[i];
for (j = 1; j <= 3; j++) {
free(p->w);
p = p->next;
}
}
}
void dist_setuptree(tree *a, long nonodes)
{
/* initialize a tree */
/* used in fitch, kitsch, & neighbor */
long i=0;
node *p;
for (i = 1; i <= nonodes; i++) {
a->nodep[i - 1]->back = NULL;
a->nodep[i - 1]->tip = (i <= spp);
a->nodep[i - 1]->iter = true;
a->nodep[i - 1]->index = i;
a->nodep[i - 1]->t = 0.0;
a->nodep[i - 1]->sametime = false;
a->nodep[i - 1]->v = 0.0;
if (i > spp) {
p = a->nodep[i-1]->next;
while (p != a->nodep[i-1]) {
p->back = NULL;
p->tip = false;
p->iter = true;
p->index = i;
p->t = 0.0;
p->sametime = false;
p = p->next;
}
}
}
a->likelihood = -1.0;
a->start = a->nodep[0];
a->root = NULL;
} /* setuptree */
void initname_modified(long i)
{
/* read in species name */
long j;
for (j = 0; j < nmlngth; j++) {
if ((nayme[i][j] == '(') || (nayme[i][j] == ')') || (nayme[i][j] == ':')
|| (nayme[i][j] == ',') || (nayme[i][j] == ';') || (nayme[i][j] == '[')
|| (nayme[i][j] == ']')) {
const char message[] = "Species name may not contain characters ( ) : ; , [ ]";
ugene_exit(message);
//printf("\nERROR: Species name may not contain characters ( ) : ; , [ ] \n");
//printf(" In name of species number %ld there is character %c\n\n",
// i+1, nayme[i][j]);
//exxit(-1);
}
}
} /* initname */
void dist_inputdata_modified(boolean replicates, boolean printdata, boolean lower,
boolean upper, vector *x, intvector *reps)
{
/* read in distance matrix */
/* used in fitch & neighbor */
long i=0, j=0, k=0, columns=0;
boolean skipit=false, skipother=false;
if (replicates)
columns = 4;
else
columns = 6;
for (i = 0; i < spp; i++) {
x[i][i] = 0.0;
initname_modified(i);
for (j = 0; j < spp; j++) {
skipit = ((lower && j + 1 >= i + 1) || (upper && j + 1 <= i + 1));
skipother = ((lower && i + 1 >= j + 1) || (upper && i + 1 <= j + 1));
if (!skipit) {
if (replicates) {
assert(0);
// if (eoln(infile))
// scan_eoln(infile);
// if (fscanf(infile, "%ld", &reps[i][j]) != 1) {
// printf("The infile is of the wrong type\n");
// exxit(-1);
// }
} else
reps[i][j] = 1;
}
if (!skipit && skipother) {
x[j][i] = x[i][j];
reps[j][i] = reps[i][j];
}
if ((i == j) && (fabs(x[i][j]) > 0.000000001)) {
printf("\nERROR: diagonal element of row %ld of distance matrix ", i+1);
printf("is not zero.\n");
printf(" Is it a distance matrix?\n\n");
exxit(-1);
}
if ((j < i) && (fabs(x[i][j]-x[j][i]) > 0.000000001)) {
printf("ERROR: distance matrix is not symmetric:\n");
printf(" (%ld,%ld) element and (%ld,%ld) element are unequal.\n",
i+1, j+1, j+1, i+1);
printf(" They are %10.6f and %10.6f, respectively.\n",
x[i][j], x[j][i]);
printf(" Is it a distance matrix?\n\n");
exxit(-1);
}
}
}
} /* inputdata */
void dist_inputdata(boolean replicates, boolean printdata, boolean lower,
boolean upper, vector *x, intvector *reps)
{
/* read in distance matrix */
/* used in fitch & neighbor */
long i=0, j=0, k=0, columns=0;
boolean skipit=false, skipother=false;
if (replicates)
columns = 4;
else
columns = 6;
/* if (printdata) {
fprintf(outfile, "\nName Distances");
if (replicates)
fprintf(outfile, " (replicates)");
fprintf(outfile, "\n---- ---------");
if (replicates)
fprintf(outfile, "-------------");
fprintf(outfile, "\n\n");
}*/
for (i = 0; i < spp; i++) {
x[i][i] = 0.0;
scan_eoln(infile);
initname(i);
for (j = 0; j < spp; j++) {
skipit = ((lower && j + 1 >= i + 1) || (upper && j + 1 <= i + 1));
skipother = ((lower && i + 1 >= j + 1) || (upper && i + 1 <= j + 1));
if (!skipit) {
if (eoln(infile))
scan_eoln(infile);
if (fscanf(infile, "%lf", &x[i][j]) != 1) {
printf("The infile is of the wrong type\n");
exxit(-1);
}
if (replicates) {
if (eoln(infile))
scan_eoln(infile);
if (fscanf(infile, "%ld", &reps[i][j]) != 1) {
printf("The infile is of the wrong type\n");
exxit(-1);
}
} else
reps[i][j] = 1;
}
if (!skipit && skipother) {
x[j][i] = x[i][j];
reps[j][i] = reps[i][j];
}
if ((i == j) && (fabs(x[i][j]) > 0.000000001)) {
printf("\nERROR: diagonal element of row %ld of distance matrix ", i+1);
printf("is not zero.\n");
printf(" Is it a distance matrix?\n\n");
exxit(-1);
}
if ((j < i) && (fabs(x[i][j]-x[j][i]) > 0.000000001)) {
printf("ERROR: distance matrix is not symmetric:\n");
printf(" (%ld,%ld) element and (%ld,%ld) element are unequal.\n",
i+1, j+1, j+1, i+1);
printf(" They are %10.6f and %10.6f, respectively.\n",
x[i][j], x[j][i]);
printf(" Is it a distance matrix?\n\n");
exxit(-1);
}
}
}
scan_eoln(infile);
if (!printdata)
return;
for (i = 0; i < spp; i++) {
for (j = 0; j < nmlngth; j++)
putc(nayme[i][j], outfile);
putc(' ', outfile);
for (j = 1; j <= spp; j++) {
fprintf(outfile, "%10.5f", x[i][j - 1]);
if (replicates)
fprintf(outfile, " (%3ld)", reps[i][j - 1]);
if (j % columns == 0 && j < spp) {
putc('\n', outfile);
for (k = 1; k <= nmlngth + 1; k++)
putc(' ', outfile);
}
}
putc('\n', outfile);
}
putc('\n', outfile);
} /* inputdata */
void dist_coordinates(node *p, double lengthsum, long *tipy, double *tipmax,
node *start, boolean njoin)
{
/* establishes coordinates of nodes */
node *q, *first, *last;
if (p->tip) {
p->xcoord = (long)(over * lengthsum + 0.5);
p->ycoord = *tipy;
p->ymin = *tipy;
p->ymax = *tipy;
(*tipy) += down;
if (lengthsum > *tipmax)
*tipmax = lengthsum;
return;
}
q = p->next;
do {
if (q->back)
dist_coordinates(q->back, lengthsum + q->v, tipy,tipmax, start, njoin);
q = q->next;
} while ((p == start || p != q) && (p != start || p->next != q));
first = p->next->back;
q = p;
while (q->next != p && q->next->back) /* is this right ? */
q = q->next;
last = q->back;
p->xcoord = (long)(over * lengthsum + 0.5);
if (p == start && p->back)
p->ycoord = p->next->next->back->ycoord;
else
p->ycoord = (first->ycoord + last->ycoord) / 2;
p->ymin = first->ymin;
p->ymax = last->ymax;
} /* coordinates */
void dist_drawline(long i, double scale, node *start, boolean rooted)
{
/* draws one row of the tree diagram by moving up tree */
node *p, *q;
long n=0, j=0;
boolean extra=false, trif=false;
node *r, *first =NULL, *last =NULL;
boolean done=false;
p = start;
q = start;
extra = false;
trif = false;
if (i == (long)p->ycoord && p == start) { /* display the root */
if (rooted) {
if (p->index - spp >= 10)
fprintf(outfile, "-");
else
fprintf(outfile, "--");
}
else {
if (p->index - spp >= 10)
fprintf(outfile, " ");
else
fprintf(outfile, " ");
}
if (p->index - spp >= 10)
fprintf(outfile, "%2ld", p->index - spp);
else
fprintf(outfile, "%ld", p->index - spp);
extra = true;
trif = true;
} else
fprintf(outfile, " ");
do {
if (!p->tip) { /* internal nodes */
r = p->next;
/* r->back here is going to the same node. */
do {
if (!r->back) {
r = r->next;
continue;
}
if (i >= r->back->ymin && i <= r->back->ymax) {
q = r->back;
break;
}
r = r->next;
} while (!((p != start && r == p) || (p == start && r == p->next)));
first = p->next->back;
r = p;
while (r->next != p)
r = r->next;
last = r->back;
if (!rooted && (p == start))
last = p->back;
} /* end internal node case... */
/* draw the line: */
done = (p->tip || p == q);
n = (long)(scale * (q->xcoord - p->xcoord) + 0.5);
if (!q->tip) {
if ((n < 3) && (q->index - spp >= 10))
n = 3;
if ((n < 2) && (q->index - spp < 10))
n = 2;
}
if (extra) {
n--;
extra = false;
}
if ((long)q->ycoord == i && !done) {
if (p->ycoord != q->ycoord)
putc('+', outfile);
if (trif) {
n++;
trif = false;
}
if (!q->tip) {
for (j = 1; j <= n - 2; j++)
putc('-', outfile);
if (q->index - spp >= 10)
fprintf(outfile, "%2ld", q->index - spp);
else
fprintf(outfile, "-%ld", q->index - spp);
extra = true;
} else {
for (j = 1; j < n; j++)
putc('-', outfile);
}
} else if (!p->tip) {
if ((long)last->ycoord > i && (long)first->ycoord < i
&& i != (long)p->ycoord) {
putc('!', outfile);
for (j = 1; j < n; j++)
putc(' ', outfile);
} else {
for (j = 1; j <= n; j++)
putc(' ', outfile);
trif = false;
}
}
if (q != p)
p = q;
} while (!done);
if ((long)p->ycoord == i && p->tip) {
for (j = 0; j < nmlngth; j++)
putc(nayme[p->index - 1][j], outfile);
}
putc('\n', outfile);
} /* drawline */
void dist_printree(node *start, boolean treeprint,
boolean njoin, boolean rooted)
{
/* prints out diagram of the tree */
/* used in fitch & neighbor */
long i;
long tipy;
double scale,tipmax;
if (!treeprint)
return;
putc('\n', outfile);
tipy = 1;
tipmax = 0.0;
dist_coordinates(start, 0.0, &tipy, &tipmax, start, njoin);
scale = 1.0 / (long)(tipmax + 1.000);
for (i = 1; i <= (tipy - down); i++)
dist_drawline(i, scale, start, rooted);
putc('\n', outfile);
} /* printree */
void treeoutr(node *p, long *col, tree *curtree)
{
/* write out file with representation of final tree.
* Rooted case. Used in kitsch and neighbor. */
long i, n, w;
Phylip_Char c;
double x;
if (p->tip) {
n = 0;
for (i = 1; i <= nmlngth; i++) {
if (nayme[p->index - 1][i - 1] != ' ')
n = i;
}
for (i = 0; i < n; i++) {
c = nayme[p->index - 1][i];
if (c == ' ')
c = '_';
putc(c, outtree);
}
(*col) += n;
} else {
putc('(', outtree);
(*col)++;
treeoutr(p->next->back,col,curtree);
putc(',', outtree);
(*col)++;
if ((*col) > 55) {
putc('\n', outtree);
(*col) = 0;
}
treeoutr(p->next->next->back,col,curtree);
putc(')', outtree);
(*col)++;
}
x = p->v;
if (x > 0.0)
w = (long)(0.43429448222 * log(x));
else if (x == 0.0)
w = 0;
else
w = (long)(0.43429448222 * log(-x)) + 1;
if (w < 0)
w = 0;
if (p == curtree->root)
fprintf(outtree, ";\n");
else {
// HACK: format using Qt instead of ":%*.5f" which uses system locale radix sign, which can be ","
QString number = QString("%1").arg(x, (int)(w + 7), 'f', 5);
fprintf(outtree, ":%s", number.toStdString().c_str());
(*col) += w + 8;
}
} /* treeoutr */
void dist_treeout(node *p, long *col, double m, boolean njoin, node *start)
{
/* write out file with representation of final tree */
/* used in fitch & neighbor */
long i=0, n=0, w=0;
Phylip_Char c;
double x=0.0;
if (p->tip) {
n = 0;
for (i = 1; i <= nmlngth; i++) {
if (nayme[p->index - 1][i - 1] != ' ')
n = i;
}
for (i = 0; i < n; i++) {
c = nayme[p->index - 1][i];
if (c == ' ')
c = '_';
putc(c, outtree);
}
*col += n;
} else {
putc('(', outtree);
(*col)++;
dist_treeout(p->next->back, col, m, njoin, start);
putc(',', outtree);
(*col)++;
if (*col > 55) {
putc('\n', outtree);
*col = 0;
}
dist_treeout(p->next->next->back, col, m, njoin, start);
if (p == start && njoin) {
putc(',', outtree);
dist_treeout(p->back, col, m, njoin, start);
}
putc(')', outtree);
(*col)++;
}
x = p->v;
if (x > 0.0)
w = (long)(m * log(x));
else if (x == 0.0)
w = 0;
else
w = (long)(m * log(-x)) + 1;
if (w < 0)
w = 0;
if (p == start)
fprintf(outtree, ";\n");
else {
// HACK: format using Qt instead of ":%*.5f" which uses system locale radix sign, which can be ","
QString number = QString("%1").arg(x, (int)(w + 7), 'f', 5);
fprintf(outtree, ":%s", number.toStdString().c_str());
*col += w + 8;
}
} /* treeout */
#ifndef NDIST_H
#define NDIST_H
#include "phylip.h"
#include <U2Core/AppResources.h>
/* version 3.696.
Written by Joseph Felsenstein, Akiko Fuseki, Sean Lamont, and Andrew Keeffe.
Copyright (c) 1993-2014, Joseph Felsenstein
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
/*
dist.h: included in fitch, kitsch, & neighbor
*/
#define over 60
typedef long *intvector;
typedef node **pointptr;
#ifndef OLDC
/*function prototypes*/
void dist_alloctree(pointptr *, long, U2::MemoryLocker& memLocker);
void dist_freetree(pointptr *, long);
void allocd(long, pointptr);
void freed(long, pointptr);
void allocw(long, pointptr);
void freew(long, pointptr);
void dist_setuptree(tree *, long);
void dist_inputdata(boolean, boolean, boolean, boolean, vector *, intvector *);
void dist_inputdata_modified(boolean replicates, boolean printdata, boolean lower,
boolean upper, vector *x, intvector *reps);
void dist_coordinates(node *, double, long *, double *, node *, boolean);
void dist_drawline(long, double, node *, boolean);
void dist_printree(node *, boolean, boolean, boolean);
void treeoutr(node *, long *, tree *);
void dist_treeout(node *, long *, double, boolean, node *);
/*function prototypes*/
#endif
#endif
This diff is collapsed.