mirror of
https://github.com/BioArchLinux/Packages.git
synced 2025-03-10 12:02:42 +00:00
add mafft
This commit is contained in:
commit
eeb4358381
183 changed files with 155355 additions and 0 deletions
12
mafft/.SRCINFO
Normal file
12
mafft/.SRCINFO
Normal file
|
@ -0,0 +1,12 @@
|
|||
pkgbase = mafft
|
||||
pkgdesc = Multiple alignment program for amino acid or nucleotide sequences
|
||||
pkgver = 7.481
|
||||
pkgrel = 1
|
||||
url = https://mafft.cbrc.jp/alignment/software
|
||||
arch = x86_64
|
||||
license = BSD
|
||||
depends = perl
|
||||
source = mafft-7.481.tgz::https://mafft.cbrc.jp/alignment/software/mafft-7.481-with-extensions-src.tgz
|
||||
sha1sums = 235d91ea4fab0108b01b9e6518563af74abc00f7
|
||||
|
||||
pkgname = mafft
|
28
mafft/PKGBUILD
Normal file
28
mafft/PKGBUILD
Normal file
|
@ -0,0 +1,28 @@
|
|||
# Maintainer: Butui Hu <hot123tea123@gmail.com>
|
||||
# Contributor: Steffen Weber <-boenki-gmx-de->
|
||||
# Contributor: Mick Elliot <micke at sfu dot ca>
|
||||
|
||||
pkgname=mafft
|
||||
pkgver=7.487
|
||||
pkgrel=1
|
||||
pkgdesc='Multiple alignment program for amino acid or nucleotide sequences'
|
||||
arch=('x86_64')
|
||||
url='https://mafft.cbrc.jp/alignment/software'
|
||||
license=('BSD')
|
||||
depends=(
|
||||
perl
|
||||
)
|
||||
source=("${pkgname}-${pkgver}.tgz::https://mafft.cbrc.jp/alignment/software/${pkgname}-${pkgver}-with-extensions-src.tgz")
|
||||
sha1sums=('d94137e79ea14c2d235c3f10a6d0537e86768a2e')
|
||||
|
||||
build() {
|
||||
make -C "${pkgname}-${pkgver}-with-extensions/core" PREFIX=/usr LIBDIR=/usr/lib/mafft
|
||||
make -C "${pkgname}-${pkgver}-with-extensions/extensions" PREFIX=/usr LIBDIR=/usr/lib/mafft
|
||||
}
|
||||
|
||||
package() {
|
||||
make DESTDIR="${pkgdir}" -C "${pkgname}-${pkgver}-with-extensions/core" install PREFIX=/usr LIBDIR=/usr/lib/mafft
|
||||
make DESTDIR="${pkgdir}" -C "${pkgname}-${pkgver}-with-extensions/extensions" install PREFIX=/usr LIBDIR=/usr/lib/mafft
|
||||
install -Dm644 "${srcdir}/${pkgname}-${pkgver}-with-extensions/license" "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"
|
||||
rm -vf "${pkgdir}/usr/lib/mafft/mafft-homologs.1" "${pkgdir}/usr/lib/mafft/mafft.1"
|
||||
}
|
0
mafft/PKGBUILD-namcap.log
Normal file
0
mafft/PKGBUILD-namcap.log
Normal file
BIN
mafft/__pycache__/lilac.cpython-39.pyc
Normal file
BIN
mafft/__pycache__/lilac.cpython-39.pyc
Normal file
Binary file not shown.
5
mafft/lilac.py
Executable file
5
mafft/lilac.py
Executable file
|
@ -0,0 +1,5 @@
|
|||
#!/usr/bin/env python3
|
||||
from lilaclib import *
|
||||
|
||||
def pre_build():
|
||||
update_pkgver_and_pkgrel(_G.newver.lstrip('v'))
|
8
mafft/lilac.yaml
Normal file
8
mafft/lilac.yaml
Normal file
|
@ -0,0 +1,8 @@
|
|||
build_prefix: extra-x86_64
|
||||
maintainers:
|
||||
- github: starsareintherose
|
||||
email: starsareintherose@outlook.com
|
||||
update_on:
|
||||
- regex: mafft-([\d.]+)-with-extensions-src.tgz
|
||||
source: regex
|
||||
url: https://mafft.cbrc.jp/alignment/software/source.html
|
130
mafft/mafft-7.487-2-x86_64-build.log
Normal file
130
mafft/mafft-7.487-2-x86_64-build.log
Normal file
|
@ -0,0 +1,130 @@
|
|||
make: Entering directory '/build/mafft/src/mafft-7.487-with-extensions/core'
|
||||
cp mafftash_premafft.tmpl mafftash_premafft.pl
|
||||
cp seekquencer_premafft.tmpl seekquencer_premafft.pl
|
||||
gcc -Denablemultithread -std=c99 -O3 -c mtxutl.c
|
||||
gcc -Denablemultithread -std=c99 -O3 -c io.c
|
||||
gcc -Denablemultithread -std=c99 -O3 -c mltaln9.c
|
||||
mltaln9.c: In function ‘check_guidetreefile’:
|
||||
mltaln9.c:2850:9: warning: ‘fgets’ writing 999 bytes into a region of size 100 overflows the destination [-Wstringop-overflow=]
|
||||
2850 | fgets( string, 999, fp );
|
||||
| ^~~~~~~~~~~~~~~~~~~~~~~~
|
||||
mltaln9.c:2834:14: note: destination object ‘string’ of size 100
|
||||
2834 | char string[100];
|
||||
| ^~~~~~
|
||||
In file included from mltaln.h:12,
|
||||
from mltaln9.c:1:
|
||||
/usr/include/stdio.h:568:14: note: in a call to function ‘fgets’ declared with attribute ‘access (write_only, 1, 2)’
|
||||
568 | extern char *fgets (char *__restrict __s, int __n, FILE *__restrict __stream)
|
||||
| ^~~~~
|
||||
gcc -Denablemultithread -std=c99 -O3 -c tddis.c
|
||||
gcc -Denablemultithread -std=c99 -O3 -c constants.c
|
||||
gcc -Denablemultithread -std=c99 -O3 -c nj.c
|
||||
gcc -Denablemultithread -std=c99 -O3 -c partSalignmm.c
|
||||
gcc -Denablemultithread -std=c99 -O3 -c Lalignmm.c
|
||||
gcc -Denablemultithread -std=c99 -O3 -c rna.c
|
||||
gcc -Denablemultithread -std=c99 -O3 -c Salignmm.c
|
||||
gcc -Denablemultithread -std=c99 -O3 -c Dalignmm.c
|
||||
gcc -Denablemultithread -std=c99 -O3 -c Falign.c
|
||||
gcc -Denablemultithread -std=c99 -O3 -c Falign_localhom.c
|
||||
gcc -Denablemultithread -std=c99 -O3 -c Galign11.c
|
||||
gcc -Denablemultithread -std=c99 -O3 -c Lalign11.c
|
||||
gcc -Denablemultithread -std=c99 -O3 -c genalign11.c
|
||||
gcc -Denablemultithread -std=c99 -O3 -c MSalignmm.c
|
||||
gcc -Denablemultithread -std=c99 -O3 -c fftFunctions.c
|
||||
gcc -Denablemultithread -std=c99 -O3 -c fft.c
|
||||
gcc -Denablemultithread -std=c99 -O3 -c tditeration.c
|
||||
gcc -Denablemultithread -std=c99 -O3 -c dvtditr.c
|
||||
gcc -Denablemultithread -std=c99 -O3 -c defs.c
|
||||
gcc -Denablemultithread -std=c99 -O3 -c SAalignmm.c -o SAalignmm.o
|
||||
gcc -Denablemultithread -std=c99 -O3 -c treeOperation.c
|
||||
gcc -Denablemultithread -std=c99 -O3 -c addfunctions.c
|
||||
gcc -o dvtditr mtxutl.o io.o mltaln9.o tddis.o constants.o nj.o partSalignmm.o Lalignmm.o rna.o Salignmm.o Dalignmm.o Falign.o Falign_localhom.o Galign11.o Lalign11.o genalign11.o MSalignmm.o fftFunctions.o fft.o tditeration.o dvtditr.o defs.o SAalignmm.o treeOperation.o addfunctions.o -Denablemultithread -std=c99 -O3 -Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now -lm -lpthread
|
||||
gcc -Denablemultithread -std=c99 -O3 -c dndfast7.c
|
||||
gcc -o dndfast7 dndfast7.o io.o constants.o mtxutl.o mltaln9.o tddis.o defs.o Galign11.o Lalign11.o genalign11.o -Denablemultithread -std=c99 -O3 -Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now -lm -lpthread
|
||||
gcc -Denablemultithread -std=c99 -O3 -c dndblast.c
|
||||
gcc -o dndblast dndblast.o io.o constants.o mtxutl.o mltaln9.o tddis.o defs.o Galign11.o Lalign11.o genalign11.o -Denablemultithread -std=c99 -O3 -Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now -lm -lpthread
|
||||
gcc -Denablemultithread -std=c99 -O3 -c sextet5.c
|
||||
gcc -o sextet5 io.o constants.o mtxutl.o mltaln9.o tddis.o sextet5.o defs.o Galign11.o Lalign11.o genalign11.o -Denablemultithread -std=c99 -O3 -Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now -lm -lpthread
|
||||
gcc -Denablemultithread -std=c99 -O3 -c mafft-distance.c
|
||||
gcc -o mafft-distance io.o constants.o mtxutl.o mltaln9.o tddis.o mafft-distance.o defs.o Galign11.o Lalign11.o genalign11.o -Denablemultithread -std=c99 -O3 -Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now -lm -lpthread
|
||||
gcc -Denablemultithread -std=c99 -O3 -c MSalign11.c
|
||||
gcc -Denablemultithread -std=c99 -O3 -c suboptalign11.c
|
||||
gcc -Denablemultithread -std=c99 -O3 -c pairlocalalignmain.c
|
||||
gcc -Denablemultithread -std=c99 -O3 -c pairlocalalign.c
|
||||
gcc -o pairlocalalign mtxutl.o io.o mltaln9.o tddis.o constants.o partSalignmm.o Lalignmm.o rna.o Salignmm.o Dalignmm.o Falign.o MSalignmm.o Galign11.o Lalign11.o genalign11.o MSalign11.o suboptalign11.o SAalignmm.o pairlocalalignmain.o pairlocalalign.o defs.o fft.o fftFunctions.o -Denablemultithread -std=c99 -O3 -Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now -lm -lpthread
|
||||
gcc -Denablemultithread -std=c99 -O3 -c multi2hat3s.c
|
||||
gcc -o multi2hat3s mtxutl.o io.o mltaln9.o tddis.o constants.o multi2hat3s.o defs.o fft.o fftFunctions.o Galign11.o Lalign11.o genalign11.o -Denablemultithread -std=c99 -O3 -Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now -lm -lpthread
|
||||
gcc -Denablemultithread -std=c99 -O3 -c pairash.c
|
||||
gcc -o pairash mtxutl.o io.o mltaln9.o tddis.o constants.o partSalignmm.o Lalignmm.o rna.o Salignmm.o Dalignmm.o Falign.o MSalignmm.o Galign11.o Lalign11.o genalign11.o MSalign11.o suboptalign11.o SAalignmm.o pairash.o defs.o fft.o fftFunctions.o -Denablemultithread -std=c99 -O3 -Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now -lm -lpthread
|
||||
gcc -Denablemultithread -std=c99 -O3 -c addsingle.c
|
||||
gcc -o addsingle mtxutl.o io.o mltaln9.o tddis.o constants.o MSalignmm.o partSalignmm.o Lalignmm.o rna.o Salignmm.o Dalignmm.o Falign.o Falign_localhom.o Galign11.o Lalign11.o genalign11.o SAalignmm.o addsingle.o defs.o fft.o fftFunctions.o addfunctions.o -Denablemultithread -std=c99 -O3 -Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now -lm -lpthread
|
||||
gcc -o maffttext2hex maffttext2hex.c -Denablemultithread -std=c99 -O3 -Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now -lm -lpthread
|
||||
gcc -o hex2maffttext hex2maffttext.c -Denablemultithread -std=c99 -O3 -Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now -lm -lpthread
|
||||
gcc -Denablemultithread -std=c99 -O3 -c splittbfast.c
|
||||
gcc -o splittbfast mtxutl.o io.o mltaln9.o tddis.o constants.o partSalignmm.o Lalignmm.o rna.o Salignmm.o Dalignmm.o Falign.o Falign_localhom.o Galign11.o Lalign11.o genalign11.o SAalignmm.o MSalignmm.o splittbfast.o defs.o fft.o fftFunctions.o -Denablemultithread -std=c99 -O3 -Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now -lm -lpthread
|
||||
gcc -Denablemultithread -std=c99 -O3 -c disttbfast.c
|
||||
gcc -o disttbfast mtxutl.o io.o mltaln9.o tddis.o constants.o partSalignmm.o Lalignmm.o rna.o Salignmm.o Dalignmm.o Falign.o Falign_localhom.o Galign11.o Lalign11.o genalign11.o SAalignmm.o MSalignmm.o disttbfast.o defs.o fft.o fftFunctions.o addfunctions.o -Denablemultithread -std=c99 -O3 -Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now -lm -lpthread
|
||||
gcc -Denablemultithread -std=c99 -O3 -c tbfast.c
|
||||
gcc -o tbfast mtxutl.o io.o mltaln9.o tddis.o constants.o MSalignmm.o partSalignmm.o Lalignmm.o rna.o Salignmm.o Dalignmm.o Falign.o Falign_localhom.o Galign11.o Lalign11.o genalign11.o SAalignmm.o tbfast.o defs.o fft.o fftFunctions.o addfunctions.o pairlocalalign.o MSalign11.o -Denablemultithread -std=c99 -O3 -Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now -lm -lpthread
|
||||
gcc -Denablemultithread -std=c99 -O3 -c nodepair.c
|
||||
gcc -o nodepair mtxutl.o io.o mltaln9.o tddis.o constants.o MSalignmm.o partSalignmm.o Lalignmm.o rna.o Salignmm.o Dalignmm.o Falign.o Falign_localhom.o Galign11.o Lalign11.o genalign11.o SAalignmm.o nodepair.o defs.o fft.o fftFunctions.o addfunctions.o pairlocalalign.o MSalign11.o -Denablemultithread -std=c99 -O3 -Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now -lm -lpthread
|
||||
gcc -Denablemultithread -std=c99 -O3 -c mafft-profile.c
|
||||
gcc -o mafft-profile io.o mtxutl.o mltaln9.o tddis.o constants.o partSalignmm.o MSalignmm.o Lalignmm.o rna.o Salignmm.o Dalignmm.o SAalignmm.o Galign11.o Lalign11.o genalign11.o Falign.o Falign_localhom.o fftFunctions.o fft.o mafft-profile.o defs.o -Denablemultithread -std=c99 -O3 -Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now -lm -lpthread
|
||||
gcc -Denablemultithread -std=c99 -O3 -c f2cl.c
|
||||
gcc -o f2cl mtxutl.o io.o f2cl.o constants.o defs.o -Denablemultithread -std=c99 -O3 -Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now -lm -lpthread
|
||||
gcc -Denablemultithread -std=c99 -O3 -c mccaskillwrap.c
|
||||
gcc -o mccaskillwrap mtxutl.o io.o mccaskillwrap.o constants.o defs.o mltaln9.o Galign11.o Lalign11.o genalign11.o -Denablemultithread -std=c99 -O3 -Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now -lm -lpthread
|
||||
gcc -Denablemultithread -std=c99 -O3 -c contrafoldwrap.c
|
||||
gcc -o contrafoldwrap mtxutl.o io.o contrafoldwrap.o constants.o defs.o mltaln9.o Galign11.o Lalign11.o genalign11.o -Denablemultithread -std=c99 -O3 -Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now -lm -lpthread
|
||||
gcc -Denablemultithread -std=c99 -O3 -c countlen.c
|
||||
gcc -o countlen mtxutl.o io.o countlen.o defs.o -Denablemultithread -std=c99 -O3 -Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now -lm -lpthread
|
||||
gcc -Denablemultithread -std=c99 -O3 -c seq2regtable.c
|
||||
gcc -o seq2regtable mtxutl.o io.o seq2regtable.o defs.o -Denablemultithread -std=c99 -O3 -Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now -lm -lpthread
|
||||
gcc -Denablemultithread -std=c99 -O3 -c regtable2seq.c
|
||||
gcc -o regtable2seq mtxutl.o io.o regtable2seq.o defs.o mltaln9.o Galign11.o Lalign11.o genalign11.o -Denablemultithread -std=c99 -O3 -Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now -lm -lpthread
|
||||
gcc -Denablemultithread -std=c99 -O3 -c score.c
|
||||
gcc -o score io.o mtxutl.o mltaln9.o score.o constants.o defs.o Galign11.o Lalign11.o genalign11.o -Denablemultithread -std=c99 -O3 -Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now -lm -lpthread
|
||||
gcc -Denablemultithread -std=c99 -O3 -c getlag.c
|
||||
gcc -o getlag mtxutl.o io.o mltaln9.o tddis.o constants.o partSalignmm.o Lalignmm.o rna.o Salignmm.o Falign.o Falign_localhom.o Galign11.o Lalign11.o genalign11.o SAalignmm.o MSalignmm.o Dalignmm.o getlag.o defs.o fft.o fftFunctions.o -Denablemultithread -std=c99 -O3 -Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now -lm -lpthread
|
||||
gcc -Denablemultithread -std=c99 -O3 -c dndpre.c
|
||||
gcc -o dndpre dndpre.o io.o constants.o mtxutl.o mltaln9.o defs.o Galign11.o Lalign11.o genalign11.o -Denablemultithread -std=c99 -O3 -Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now -lm -lpthread
|
||||
gcc -Denablemultithread -std=c99 -O3 -c setcore.c
|
||||
gcc -o setcore mtxutl.o io.o mltaln9.o tddis.o constants.o partSalignmm.o Lalignmm.o rna.o Salignmm.o Dalignmm.o Falign.o Falign_localhom.o Galign11.o Lalign11.o genalign11.o SAalignmm.o MSalignmm.o setcore.o defs.o fft.o fftFunctions.o -Denablemultithread -std=c99 -O3 -Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now -lm -lpthread
|
||||
gcc -O3 -D_FORTIFY_SOURCE=2 -c -o filter.o filter.c
|
||||
gcc -o filter mtxutl.o io.o filter.o defs.o mltaln9.o Galign11.o Lalign11.o genalign11.o -Denablemultithread -std=c99 -O3 -Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now -lm -lpthread
|
||||
gcc -Denablemultithread -std=c99 -O3 -c replaceu.c
|
||||
gcc -o replaceu mtxutl.o io.o replaceu.o defs.o mltaln9.o Galign11.o Lalign11.o genalign11.o -Denablemultithread -std=c99 -O3 -Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now -lm -lpthread
|
||||
gcc -Denablemultithread -std=c99 -O3 -c restoreu.c
|
||||
gcc -o restoreu mtxutl.o io.o restoreu.o defs.o mltaln9.o Galign11.o Lalign11.o genalign11.o -Denablemultithread -std=c99 -O3 -Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now -lm -lpthread
|
||||
gcc -Denablemultithread -std=c99 -O3 -c setdirection.c
|
||||
gcc -o setdirection mtxutl.o io.o setdirection.o defs.o mltaln9.o Galign11.o Lalign11.o genalign11.o -Denablemultithread -std=c99 -O3 -Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now -lm -lpthread
|
||||
gcc -Denablemultithread -std=c99 -O3 -c makedirectionlist.c
|
||||
gcc -o makedirectionlist mtxutl.o io.o mltaln9.o tddis.o constants.o partSalignmm.o Lalignmm.o rna.o Salignmm.o Dalignmm.o Falign.o Falign_localhom.o Galign11.o Lalign11.o genalign11.o SAalignmm.o MSalignmm.o makedirectionlist.o defs.o fft.o fftFunctions.o addfunctions.o -Denablemultithread -std=c99 -O3 -Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now -lm -lpthread
|
||||
gcc -o version version.c -Denablemultithread -std=c99 -O3 -Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now -lm -lpthread
|
||||
sed "s:_LIBDIR:/usr/lib/mafft:" mafft.tmpl > mafft
|
||||
sed "s:_BINDIR:/usr/bin:" mafft-homologs.tmpl > mafft-homologs.rb
|
||||
sed "s:_BINDIR:/usr/bin:" mafft-sparsecore.tmpl > mafft-sparsecore.rb
|
||||
cp mafft mafft-homologs.rb mafft-sparsecore.rb ../scripts
|
||||
chmod 755 ../scripts/*
|
||||
cp mafftash_premafft.pl seekquencer_premafft.pl dvtditr dndfast7 dndblast sextet5 mafft-distance pairlocalalign multi2hat3s pairash addsingle maffttext2hex hex2maffttext splittbfast disttbfast tbfast nodepair mafft-profile f2cl mccaskillwrap contrafoldwrap countlen seq2regtable regtable2seq score getlag dndpre setcore filter replaceu restoreu setdirection makedirectionlist version ../binaries
|
||||
chmod 755 ../binaries/*
|
||||
cp mafft.1 mafft-homologs.1 ../binaries
|
||||
done.
|
||||
make: Leaving directory '/build/mafft/src/mafft-7.487-with-extensions/core'
|
||||
make: Entering directory '/build/mafft/src/mafft-7.487-with-extensions/extensions'
|
||||
make CFLAGS1="" -C mxscarna_src
|
||||
make[1]: Entering directory '/build/mafft/src/mafft-7.487-with-extensions/extensions/mxscarna_src'
|
||||
g++ -I./probconsRNA -I./vienna -I./ -DNDEBUG -DNumInsertStates=1 -DVERSION="2.0" -O3 -std=c++98 -c Main.cc -o Main.o
|
||||
g++ -I./probconsRNA -I./vienna -I./ -DNDEBUG -DNumInsertStates=1 -DVERSION="2.0" -O3 -std=c++98 -c McCaskill.cpp -o McCaskill.o
|
||||
g++ -I./probconsRNA -I./vienna -I./ -DNDEBUG -DNumInsertStates=1 -DVERSION="2.0" -O3 -std=c++98 -c ./vienna/energy_param.cpp -o ./vienna/energy_param.o
|
||||
g++ -I./probconsRNA -I./vienna -I./ -DNDEBUG -DNumInsertStates=1 -DVERSION="2.0" -O3 -std=c++98 -c seq2scs.cpp -o seq2scs.o
|
||||
g++ -I./probconsRNA -I./vienna -I./ -DNDEBUG -DNumInsertStates=1 -DVERSION="2.0" -O3 -std=c++98 -c Globaldp.cpp -o Globaldp.o
|
||||
g++ -I./probconsRNA -I./vienna -I./ -DNDEBUG -DNumInsertStates=1 -DVERSION="2.0" -O3 -std=c++98 -c postProcessings.cpp -o postProcessings.o
|
||||
g++ -I./probconsRNA -I./vienna -I./ -DNDEBUG -DNumInsertStates=1 -DVERSION="2.0" -O3 -std=c++98 -c AlifoldMEA.cpp -o AlifoldMEA.o
|
||||
g++ -L./probconsRNA -L./ -DNDEBUG -DNumInsertStates=1 -DVERSION="2.0" -O3 -std=c++98 -lm -o mxscarna Main.o McCaskill.o vienna/energy_param.o seq2scs.o Globaldp.o postProcessings.o AlifoldMEA.o
|
||||
make[1]: Leaving directory '/build/mafft/src/mafft-7.487-with-extensions/extensions/mxscarna_src'
|
||||
mv mxscarna_src/mxscarna mxscarnamod
|
||||
cp mxscarnamod ../binaries
|
||||
chmod 755 ../binaries/*
|
||||
done.
|
||||
make: Leaving directory '/build/mafft/src/mafft-7.487-with-extensions/extensions'
|
44
mafft/mafft-7.487-2-x86_64-package.log
Normal file
44
mafft/mafft-7.487-2-x86_64-package.log
Normal file
|
@ -0,0 +1,44 @@
|
|||
make: Entering directory '/build/mafft/src/mafft-7.487-with-extensions/core'
|
||||
cp mafft mafft-homologs.rb mafft-sparsecore.rb ../scripts
|
||||
chmod 755 ../scripts/*
|
||||
cp mafftash_premafft.pl seekquencer_premafft.pl dvtditr dndfast7 dndblast sextet5 mafft-distance pairlocalalign multi2hat3s pairash addsingle maffttext2hex hex2maffttext splittbfast disttbfast tbfast nodepair mafft-profile f2cl mccaskillwrap contrafoldwrap countlen seq2regtable regtable2seq score getlag dndpre setcore filter replaceu restoreu setdirection makedirectionlist version ../binaries
|
||||
chmod 755 ../binaries/*
|
||||
cp mafft.1 mafft-homologs.1 ../binaries
|
||||
done.
|
||||
mkdir -p /build/mafft/pkg/mafft/usr/lib/mafft
|
||||
chmod 755 /build/mafft/pkg/mafft/usr/lib/mafft
|
||||
mkdir -p /build/mafft/pkg/mafft/usr/bin
|
||||
chmod 755 /build/mafft/pkg/mafft/usr/bin
|
||||
chmod 755 mafft mafft-homologs.rb mafft-sparsecore.rb
|
||||
install mafft mafft-homologs.rb mafft-sparsecore.rb /build/mafft/pkg/mafft/usr/bin
|
||||
chmod 755 dvtditr dndfast7 dndblast sextet5 mafft-distance pairlocalalign multi2hat3s pairash addsingle maffttext2hex hex2maffttext splittbfast disttbfast tbfast nodepair mafft-profile f2cl mccaskillwrap contrafoldwrap countlen seq2regtable regtable2seq score getlag dndpre setcore filter replaceu restoreu setdirection makedirectionlist version ||: # in MinGW, it's ok if this fails
|
||||
strip dvtditr dndfast7 dndblast sextet5 mafft-distance pairlocalalign multi2hat3s pairash addsingle maffttext2hex hex2maffttext splittbfast disttbfast tbfast nodepair mafft-profile f2cl mccaskillwrap contrafoldwrap countlen seq2regtable regtable2seq score getlag dndpre setcore filter replaceu restoreu setdirection makedirectionlist version ||: # may fail for dash_client on mac.
|
||||
install dvtditr dndfast7 dndblast sextet5 mafft-distance pairlocalalign multi2hat3s pairash addsingle maffttext2hex hex2maffttext splittbfast disttbfast tbfast nodepair mafft-profile f2cl mccaskillwrap contrafoldwrap countlen seq2regtable regtable2seq score getlag dndpre setcore filter replaceu restoreu setdirection makedirectionlist version /build/mafft/pkg/mafft/usr/lib/mafft
|
||||
install mafftash_premafft.pl seekquencer_premafft.pl /build/mafft/pkg/mafft/usr/lib/mafft
|
||||
install -m 644 mafft.1 mafft-homologs.1 /build/mafft/pkg/mafft/usr/lib/mafft
|
||||
( cd /build/mafft/pkg/mafft/usr/bin; \
|
||||
rm -f linsi ginsi einsi fftns fftnsi nwns nwnsi xinsi qinsi; \
|
||||
rm -f mafft-linsi mafft-ginsi mafft-einsi mafft-fftns mafft-fftnsi mafft-nwns mafft-nwnsi mafft-xinsi mafft-qinsi mafft-randomcore.rb ; \
|
||||
ln -s mafft linsi; ln -s mafft ginsi; ln -s mafft fftns; \
|
||||
ln -s mafft fftnsi; ln -s mafft nwns; ln -s mafft nwnsi; \
|
||||
ln -s mafft einsi; \
|
||||
ln -s mafft mafft-linsi; ln -s mafft mafft-ginsi; ln -s mafft mafft-fftns; \
|
||||
ln -s mafft mafft-fftnsi; ln -s mafft mafft-nwns; ln -s mafft mafft-nwnsi; \
|
||||
ln -s mafft mafft-einsi; ln -s mafft mafft-xinsi; ln -s mafft mafft-qinsi;\
|
||||
rm -f mafft-profile mafft-profile.exe; ln -s /usr/lib/mafft/mafft-profile .; \
|
||||
rm -f mafft-distance mafft-distance.exe; ln -s /usr/lib/mafft/mafft-distance . )
|
||||
mkdir -p /build/mafft/pkg/mafft/usr/share/man/man1
|
||||
chmod 755 /build/mafft/pkg/mafft/usr/share/man/man1
|
||||
install -m 644 mafft.1 mafft-homologs.1 /build/mafft/pkg/mafft/usr/share/man/man1
|
||||
make: Leaving directory '/build/mafft/src/mafft-7.487-with-extensions/core'
|
||||
make: Entering directory '/build/mafft/src/mafft-7.487-with-extensions/extensions'
|
||||
cp mxscarnamod ../binaries
|
||||
chmod 755 ../binaries/*
|
||||
done.
|
||||
mkdir -p /build/mafft/pkg/mafft/usr/lib/mafft
|
||||
chmod 755 /build/mafft/pkg/mafft/usr/lib/mafft
|
||||
chmod 755 mxscarnamod
|
||||
install mxscarnamod /build/mafft/pkg/mafft/usr/lib/mafft
|
||||
make: Leaving directory '/build/mafft/src/mafft-7.487-with-extensions/extensions'
|
||||
removed '/build/mafft/pkg/mafft/usr/lib/mafft/mafft-homologs.1'
|
||||
removed '/build/mafft/pkg/mafft/usr/lib/mafft/mafft.1'
|
BIN
mafft/mafft-7.487-2-x86_64.pkg.tar.zst
Normal file
BIN
mafft/mafft-7.487-2-x86_64.pkg.tar.zst
Normal file
Binary file not shown.
2
mafft/mafft-7.487-2-x86_64.pkg.tar.zst-namcap.log
Normal file
2
mafft/mafft-7.487-2-x86_64.pkg.tar.zst-namcap.log
Normal file
|
@ -0,0 +1,2 @@
|
|||
mafft W: ELF file ('usr/lib/mafft/mxscarnamod') lacks FULL RELRO, check LDFLAGS.
|
||||
mafft W: Referenced library 'ruby' is an uninstalled dependency
|
BIN
mafft/mafft-7.487-2-x86_64.pkg.tar.zst.sig
Normal file
BIN
mafft/mafft-7.487-2-x86_64.pkg.tar.zst.sig
Normal file
Binary file not shown.
BIN
mafft/mafft-7.487.tgz
Normal file
BIN
mafft/mafft-7.487.tgz
Normal file
Binary file not shown.
80
mafft/src/mafft-7.487-with-extensions/MPI/Makefile
Normal file
80
mafft/src/mafft-7.487-with-extensions/MPI/Makefile
Normal file
|
@ -0,0 +1,80 @@
|
|||
PREFIX = /usr/local
|
||||
LIBDIR = $(PREFIX)/libexec/mafft
|
||||
BINDIR = $(PREFIX)/bin
|
||||
MANDIR = $(PREFIX)/share/man/man1
|
||||
DESTDIR =
|
||||
|
||||
|
||||
#CC := mpicc -cc=gcc
|
||||
CC := mpicc
|
||||
#CC := /u33/app/openmpi/bin/mpicc
|
||||
#CFLAGS := -O3 -ipo -no-prec-div -xHost -std=c99
|
||||
#CFLAGS := -O3 -std=c99
|
||||
CFLAGS := -O3
|
||||
#CFLAGS = -O0 -fPIC -pedantic -Wall -std=c99 -g -DMALLOC_CHECK_=3 # for shark, valgrind
|
||||
# CFLAGS := -O0 -g -ipo -no-prec-div -xHost -std=c99
|
||||
TARGET_ARCH :=
|
||||
LDLIBS := -lm -lrt -lpthread # -lrt?
|
||||
|
||||
|
||||
ENABLE_MULTITHREAD := -Denablemultithread
|
||||
#ENABLE_ATOMIC := -Denableatomic
|
||||
VPATH := ../core
|
||||
|
||||
ifdef ENABLE_ATOMIC
|
||||
STDF = -std=c11
|
||||
else
|
||||
STDF = -std=c99
|
||||
endif
|
||||
|
||||
MYCFLAGS := $(ENABLE_MULTITHREAD) $(ENABLE_ATOMIC) $(STDF) $(CFLAGS) -I../core -MMD -MP
|
||||
|
||||
OBJDIR := ./obj
|
||||
ifeq "$(strip $(OBJDIR))" ""
|
||||
OBJDIR := .
|
||||
endif
|
||||
|
||||
INSTALL = install
|
||||
|
||||
PROGS := nodepair_mpi
|
||||
SCRIPTS := mpiscript
|
||||
OBJNODPAIR := mtxutl.o io.o mltaln9_mpi.o tddis.o constants.o MSalignmm.o partSalignmm.o Lalignmm.o rna.o Salignmm.o Dalignmm.o \
|
||||
Falign.o Falign_localhom.o Galign11.o Lalign11.o genalign11.o SAalignmm.o \
|
||||
nodepair_mpi.o defs.o fft.o fftFunctions.o addfunctions.o \
|
||||
pairlocalalign_mpi.o MSalign11.o
|
||||
OBJNODPAIR := $(addprefix $(OBJDIR)/, $(OBJNODPAIR))
|
||||
DEPSNODPAIR := $(OBJNODPAIR:%.o=%.d)
|
||||
|
||||
|
||||
all : $(PROGS) $(SCRIPTS)
|
||||
cp $(PROGS) $(SCRIPTS) ../binaries
|
||||
chmod 755 ../binaries/*
|
||||
@echo done.
|
||||
|
||||
install : all
|
||||
mkdir -p $(DESTDIR)$(LIBDIR)
|
||||
chmod 755 $(DESTDIR)$(LIBDIR)
|
||||
chmod 755 $(PROGS) ||: # in MinGW, it's ok if this fails
|
||||
$(INSTALL) -s $(PROGS) $(DESTDIR)$(LIBDIR)
|
||||
$(INSTALL) $(SCRIPTS) $(DESTDIR)$(LIBDIR)
|
||||
@echo done.
|
||||
|
||||
nodepair_mpi : $(OBJNODPAIR)
|
||||
$(CC) $(LDFLAGS) $(TARGET_ARCH) $^ $(LOADLIBES) $(LDLIBS) -o $@
|
||||
|
||||
shmclear : shmclear.c
|
||||
$(CC) $(LDFLAGS) $(TARGET_ARCH) $^ $(LOADLIBES) $(LDLIBS) -o $@
|
||||
|
||||
mpiscript : mpiscript.tmpl
|
||||
cp mpiscript.tmpl mpiscript
|
||||
|
||||
$(OBJDIR)/%.o : %.c
|
||||
-@mkdir -p $(OBJDIR)
|
||||
@[ -d $(OBJDIR) ]
|
||||
$(CC) $(MYCFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -o $@ -c $<
|
||||
|
||||
clean :
|
||||
rm -f $(OBJNODPAIR) $(DEPSNODPAIR) $(PROGS) $(SCRIPTS) *.o *.a *.exe *~
|
||||
rm -rf obj/
|
||||
|
||||
-include $(DEPSNODPAIR)
|
17073
mafft/src/mafft-7.487-with-extensions/MPI/mltaln9_mpi.c
Normal file
17073
mafft/src/mafft-7.487-with-extensions/MPI/mltaln9_mpi.c
Normal file
File diff suppressed because it is too large
Load diff
30
mafft/src/mafft-7.487-with-extensions/MPI/mpiscript.tmpl
Normal file
30
mafft/src/mafft-7.487-with-extensions/MPI/mpiscript.tmpl
Normal file
|
@ -0,0 +1,30 @@
|
|||
trap "echo 'Cancel' 1>&2" 0 15
|
||||
|
||||
if [ ! $MAFFT_N_THREADS_PER_PROCESS ]; then
|
||||
echo "set MAFFT_N_THREADS_PER_PROCESS, the number of cores to be used by a process." 1>&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ ! "$MAFFT_MPIRUN" ]; then
|
||||
MAFFT_MPIRUN="mpirun"
|
||||
fi
|
||||
|
||||
|
||||
|
||||
command="$* -C $MAFFT_N_THREADS_PER_PROCESS"
|
||||
|
||||
#rm -rf hat3dir # To avoid cache, don't touch hat3dir here
|
||||
|
||||
$MAFFT_MPIRUN $command 1>&2
|
||||
sync;
|
||||
|
||||
if [ -s hat3dir/tree ]; then
|
||||
#if [ -s infile.tree ]; then
|
||||
val=0
|
||||
else
|
||||
echo "error in MPI" 1>&2
|
||||
val=1
|
||||
fi
|
||||
|
||||
trap - 0 15
|
||||
exit $val
|
561
mafft/src/mafft-7.487-with-extensions/MPI/nodepair_mpi.c
Normal file
561
mafft/src/mafft-7.487-with-extensions/MPI/nodepair_mpi.c
Normal file
|
@ -0,0 +1,561 @@
|
|||
#include "mltaln.h"
|
||||
#include "mpi.h"
|
||||
#include <errno.h>
|
||||
|
||||
#define DEBUG 0
|
||||
#define IODEBUG 0
|
||||
#define SCOREOUT 0
|
||||
#define SHISHAGONYU 0 // for debug
|
||||
|
||||
|
||||
// from tbfast
|
||||
static int treein;
|
||||
static int treeout;
|
||||
|
||||
|
||||
// from pairlocalalign
|
||||
static int stdout_dist;
|
||||
|
||||
|
||||
static void arguments( int argc, char *argv[] )
|
||||
{
|
||||
int c;
|
||||
|
||||
nthread = 1;
|
||||
nadd = 0;
|
||||
inputfile = NULL;
|
||||
fftkeika = 0;
|
||||
pslocal = -1000.0;
|
||||
nblosum = 62;
|
||||
fmodel = 0;
|
||||
calledByXced = 0;
|
||||
devide = 0;
|
||||
use_fft = 0;
|
||||
fftscore = 1;
|
||||
fftRepeatStop = 0;
|
||||
fftNoAnchStop = 0;
|
||||
weight = 3;
|
||||
utree = 1;
|
||||
tbutree = 1;
|
||||
refine = 0;
|
||||
check = 1;
|
||||
cut = 0.0;
|
||||
disp = 0;
|
||||
outgap = 1;
|
||||
alg = 'A';
|
||||
mix = 0;
|
||||
tbitr = 0;
|
||||
scmtd = 5;
|
||||
tbweight = 0;
|
||||
tbrweight = 3;
|
||||
checkC = 0;
|
||||
treemethod = 'x';
|
||||
contin = 0;
|
||||
scoremtx = 1;
|
||||
kobetsubunkatsu = 0;
|
||||
divpairscore = 0;
|
||||
stdout_dist = 0;
|
||||
// dorp = NOTSPECIFIED;
|
||||
ppenalty = NOTSPECIFIED;
|
||||
ppenalty_OP = NOTSPECIFIED;
|
||||
ppenalty_ex = NOTSPECIFIED;
|
||||
ppenalty_EX = NOTSPECIFIED;
|
||||
penalty_shift_factor = 1000.0;
|
||||
poffset = NOTSPECIFIED;
|
||||
kimuraR = NOTSPECIFIED;
|
||||
pamN = NOTSPECIFIED;
|
||||
geta2 = GETA2;
|
||||
fftWinSize = NOTSPECIFIED;
|
||||
fftThreshold = NOTSPECIFIED;
|
||||
RNAppenalty = NOTSPECIFIED;
|
||||
RNApthr = NOTSPECIFIED;
|
||||
specificityconsideration = 0.0;
|
||||
usenaivescoreinsteadofalignmentscore = 0;
|
||||
specifictarget = 0;
|
||||
nwildcard = 0;
|
||||
compacttree = 2; // tsuneni!
|
||||
treein = 0;
|
||||
treeout = 0;
|
||||
fastathreshold = 2.7;
|
||||
constraint = 2;
|
||||
|
||||
// localhomfile = 0; // tbfast.c no wo tsukaunode comment out
|
||||
|
||||
// reporterr( "argc=%d\n", argc );
|
||||
// reporterr( "*argv=%s\n", *argv );
|
||||
// reporterr( "(*argv)[0]=%c\n", (*argv)[0] );
|
||||
while( --argc > 0 && (*++argv)[0] == '-' )
|
||||
{
|
||||
// reporterr( "(*argv)[0] in while loop = %s\n", (*argv) );
|
||||
while ( ( c = *++argv[0] ) )
|
||||
{
|
||||
switch( c )
|
||||
{
|
||||
case 'i':
|
||||
inputfile = *++argv;
|
||||
// fprintf( stderr, "inputfile = %s\n", inputfile );
|
||||
--argc;
|
||||
goto nextoption;
|
||||
case 'f':
|
||||
ppenalty = (int)( atof( *++argv ) * 1000 - 0.5 );
|
||||
--argc;
|
||||
goto nextoption;
|
||||
case 'g':
|
||||
ppenalty_ex = (int)( atof( *++argv ) * 1000 - 0.5 );
|
||||
--argc;
|
||||
goto nextoption;
|
||||
case 'O':
|
||||
ppenalty_OP = (int)( atof( *++argv ) * 1000 - 0.5 );
|
||||
--argc;
|
||||
goto nextoption;
|
||||
case 'E':
|
||||
ppenalty_EX = (int)( atof( *++argv ) * 1000 - 0.5 );
|
||||
--argc;
|
||||
goto nextoption;
|
||||
case 'Q':
|
||||
penalty_shift_factor = atof( *++argv );
|
||||
--argc;
|
||||
goto nextoption;
|
||||
case 'h':
|
||||
poffset = (int)( atof( *++argv ) * 1000 - 0.5 );
|
||||
--argc;
|
||||
goto nextoption;
|
||||
case 'k':
|
||||
kimuraR = myatoi( *++argv );
|
||||
// fprintf( stderr, "kimuraR = %d\n", kimuraR );
|
||||
--argc;
|
||||
goto nextoption;
|
||||
case 'b':
|
||||
nblosum = myatoi( *++argv );
|
||||
scoremtx = 1;
|
||||
// fprintf( stderr, "blosum %d\n", nblosum );
|
||||
--argc;
|
||||
goto nextoption;
|
||||
case 'j':
|
||||
pamN = myatoi( *++argv );
|
||||
scoremtx = 0;
|
||||
TMorJTT = JTT;
|
||||
// fprintf( stderr, "jtt %d\n", pamN );
|
||||
--argc;
|
||||
goto nextoption;
|
||||
case 'm':
|
||||
pamN = myatoi( *++argv );
|
||||
scoremtx = 0;
|
||||
TMorJTT = TM;
|
||||
// fprintf( stderr, "TM %d\n", pamN );
|
||||
--argc;
|
||||
goto nextoption;
|
||||
case 'l':
|
||||
fastathreshold = atof( *++argv );
|
||||
constraint = 2;
|
||||
--argc;
|
||||
goto nextoption;
|
||||
#if 0
|
||||
case 'l':
|
||||
ppslocal = (int)( atof( *++argv ) * 1000 + 0.5 );
|
||||
pslocal = (int)( 600.0 / 1000.0 * ppslocal + 0.5);
|
||||
// fprintf( stderr, "ppslocal = %d\n", ppslocal );
|
||||
// fprintf( stderr, "pslocal = %d\n", pslocal );
|
||||
--argc;
|
||||
goto nextoption;
|
||||
#else
|
||||
#endif
|
||||
case 'C':
|
||||
nthread = myatoi( *++argv );
|
||||
if( nthread == 0 ) nthread = 1;
|
||||
// fprintf( stderr, "nthread = %d\n", nthread );
|
||||
--argc;
|
||||
#ifndef enablemultithread
|
||||
nthread = 0;
|
||||
#endif
|
||||
goto nextoption;
|
||||
case 'I':
|
||||
nadd = myatoi( *++argv );
|
||||
// fprintf( stderr, "nadd = %d\n", nadd );
|
||||
--argc;
|
||||
goto nextoption;
|
||||
case 'u':
|
||||
specificityconsideration = (double)myatof( *++argv );
|
||||
// fprintf( stderr, "specificityconsideration = %f\n", specificityconsideration );
|
||||
--argc;
|
||||
goto nextoption;
|
||||
case 'c':
|
||||
stdout_dist = 1;
|
||||
break;
|
||||
#if 1
|
||||
case 'a':
|
||||
fmodel = 1;
|
||||
break;
|
||||
#endif
|
||||
case 'K':
|
||||
addprofile = 0;
|
||||
break;
|
||||
#if 0
|
||||
case 'r':
|
||||
fmodel = -1;
|
||||
break;
|
||||
#endif
|
||||
case 'D':
|
||||
dorp = 'd';
|
||||
break;
|
||||
case 'P':
|
||||
dorp = 'p';
|
||||
break;
|
||||
#if 0
|
||||
case 'e':
|
||||
fftscore = 0;
|
||||
break;
|
||||
case 'O':
|
||||
fftNoAnchStop = 1;
|
||||
break;
|
||||
#endif
|
||||
#if 0
|
||||
case 'Q':
|
||||
calledByXced = 1;
|
||||
break;
|
||||
case 'x':
|
||||
disp = 1;
|
||||
break;
|
||||
case 'a':
|
||||
alg = 'a';
|
||||
break;
|
||||
case 'S':
|
||||
alg = 'S';
|
||||
break;
|
||||
#endif
|
||||
case 'N':
|
||||
alg = 'N';
|
||||
break;
|
||||
case 'A':
|
||||
alg = 'A';
|
||||
break;
|
||||
case 'L':
|
||||
alg = 'L';
|
||||
break;
|
||||
case 'Z':
|
||||
usenaivescoreinsteadofalignmentscore = 1;
|
||||
break;
|
||||
case 'B': // hitsuyou! memopt -M -B no tame
|
||||
break;
|
||||
#if 0
|
||||
case 'Y':
|
||||
alg = 'Y'; // nadd>0 no toki nomi. moto no hairetsu to atarashii hairetsuno alignmnt -> L;
|
||||
break;
|
||||
case 's':
|
||||
alg = 's';
|
||||
break;
|
||||
case 'G':
|
||||
alg = 'G';
|
||||
break;
|
||||
case 'B': // hitsuyou! memopt -M -B no tame
|
||||
break;
|
||||
case 'T':
|
||||
alg = 'T';
|
||||
break;
|
||||
case 'H':
|
||||
alg = 'H';
|
||||
break;
|
||||
case 'M':
|
||||
alg = 'M';
|
||||
break;
|
||||
case 'R':
|
||||
alg = 'R';
|
||||
break;
|
||||
case 'r':
|
||||
alg = 'r'; // nadd>0 no toki nomi. moto no hairetsu to atarashii hairetsuno alignmnt -> R, last
|
||||
break;
|
||||
case 'V':
|
||||
alg = 'V';
|
||||
break;
|
||||
#endif
|
||||
case 'T': // tbfast.c no noalign ni taiou
|
||||
break;
|
||||
case 'F':
|
||||
use_fft = 1;
|
||||
break;
|
||||
case 'U':
|
||||
treein = 1;
|
||||
break;
|
||||
case 't':
|
||||
treeout = 1;
|
||||
break;
|
||||
case 'y':
|
||||
divpairscore = 1;
|
||||
break;
|
||||
case '=':
|
||||
specifictarget = 1;
|
||||
break;
|
||||
case ':':
|
||||
nwildcard = 1;
|
||||
break;
|
||||
case 'q':
|
||||
lhlimit = myatoi( *++argv );
|
||||
--argc;
|
||||
goto nextoption;
|
||||
/* Modified 01/08/27, default: user tree */
|
||||
case 'J':
|
||||
tbutree = 0;
|
||||
break;
|
||||
/* modification end. */
|
||||
default:
|
||||
fprintf( stderr, "illegal option %c\n", c );
|
||||
argc = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
nextoption:
|
||||
;
|
||||
}
|
||||
if( argc == 1 )
|
||||
{
|
||||
cut = atof( (*argv) );
|
||||
argc--;
|
||||
}
|
||||
if( argc != 0 )
|
||||
{
|
||||
fprintf( stderr, "pairlocalalign options: Check source file !\n" );
|
||||
exit( 1 );
|
||||
}
|
||||
if( tbitr == 1 && outgap == 0 )
|
||||
{
|
||||
fprintf( stderr, "conflicting options : o, m or u\n" );
|
||||
exit( 1 );
|
||||
}
|
||||
}
|
||||
|
||||
int main( int argc, char *argv[] )
|
||||
{
|
||||
static int *nlen = NULL;
|
||||
static int *selfscore = NULL;
|
||||
static char **name = NULL, **seq = NULL;
|
||||
static double *eff = NULL;
|
||||
int i;
|
||||
static int ***topol = NULL;
|
||||
static Treedep *dep = NULL;
|
||||
static double **len = NULL;
|
||||
FILE *infp = NULL;
|
||||
|
||||
char c;
|
||||
|
||||
|
||||
#if 1
|
||||
// int required = MPI_THREAD_MULTIPLE;
|
||||
int required = MPI_THREAD_FUNNELED;
|
||||
int provided;
|
||||
MPI_Init_thread(&argc, &argv, required, &provided);
|
||||
#else
|
||||
MPI_Init(&argc,&argv);
|
||||
#endif
|
||||
|
||||
int my_rank;
|
||||
int num_of_processes;
|
||||
MPI_Comm_rank(MPI_COMM_WORLD,&my_rank);
|
||||
MPI_Comm_size(MPI_COMM_WORLD,&num_of_processes);
|
||||
|
||||
|
||||
if (provided < required) {
|
||||
#if 0
|
||||
if (my_rank == 0) {
|
||||
reporterr( "MPI_THREAD_MULTIPLE (mpi thread support level) is required\n");
|
||||
reporterr( "required level is %d and provided level is %d\n", required, provided );
|
||||
}
|
||||
MPI_Finalize();
|
||||
exit( 1 );
|
||||
#else
|
||||
if (my_rank == 0) reporterr( "WARNING: mpi thread support level %d is required, but provided level is %d.\n", required, provided );
|
||||
#endif
|
||||
} else {
|
||||
if (my_rank == 0) reporterr( "mpi thread support level : required level is %d and provided level is %d\n", required, provided );
|
||||
}
|
||||
|
||||
|
||||
arguments( argc, argv );
|
||||
|
||||
if( alg != 'A' && alg != 'L' && alg != 'N' )
|
||||
{
|
||||
reporterr( "alg %c is not yet supported\n", alg );
|
||||
exit( 1 );
|
||||
}
|
||||
if( alg != 'N' && usenaivescoreinsteadofalignmentscore == 1 )
|
||||
{
|
||||
reporterr( "The combination of usenaivescoreinsteadofalignmentscore and alg %c is not yet supported\n", alg );
|
||||
exit( 1 );
|
||||
}
|
||||
|
||||
if( fastathreshold < 0.0001 )
|
||||
{
|
||||
constraint = 0;
|
||||
lhlimit = 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
if(my_rank==0){
|
||||
if( inputfile )
|
||||
{
|
||||
infp = fopen( inputfile, "r" );
|
||||
if( !infp )
|
||||
{
|
||||
fprintf( stderr, "Cannot open %s\n", inputfile );
|
||||
exit( 1 );
|
||||
}
|
||||
}
|
||||
else
|
||||
infp = stdin;
|
||||
|
||||
getnumlen( infp );
|
||||
rewind( infp );
|
||||
}
|
||||
// getnumlen
|
||||
MPI_Bcast(&njob,1, MPI_INT, 0, MPI_COMM_WORLD);
|
||||
MPI_Bcast(&nlenmax,1, MPI_INT, 0, MPI_COMM_WORLD);
|
||||
MPI_Bcast(&dorp,1, MPI_INT, 0, MPI_COMM_WORLD);
|
||||
fprintf( stderr, "my_rank: %d, njob: %d, nlenmax: %d\n", my_rank, njob, nlenmax);
|
||||
|
||||
|
||||
|
||||
if( njob < 2 )
|
||||
{
|
||||
fprintf( stderr, "At least 2 sequences should be input!\n"
|
||||
"Only %d sequence found.\n", njob );
|
||||
exit( 1 );
|
||||
}
|
||||
|
||||
|
||||
#ifndef mingw
|
||||
setstacksize( 200 * njob ); // topolorder() de ookime no stack wo shiyou.
|
||||
#endif
|
||||
|
||||
|
||||
seq = AllocateCharMtx( njob, nlenmax+1 );
|
||||
|
||||
name = AllocateCharMtx( njob, B+1 );
|
||||
nlen = AllocateIntVec( njob );
|
||||
selfscore = AllocateIntVec( njob );
|
||||
|
||||
topol = AllocateIntCub( njob, 2, 0 );
|
||||
len = AllocateFloatMtx( njob, 2 );
|
||||
eff = AllocateDoubleVec( njob );
|
||||
|
||||
|
||||
dep = (Treedep *)calloc( njob, sizeof( Treedep ) );
|
||||
|
||||
|
||||
if(my_rank==0){
|
||||
#if 0
|
||||
readData( infp, name, nlen, seq );
|
||||
#else
|
||||
readData_pointer( infp, name, nlen, seq );
|
||||
fclose( infp );
|
||||
#endif
|
||||
}
|
||||
for(i=0;i<njob;i++){
|
||||
MPI_Bcast(name[i], B+1, MPI_CHAR, 0, MPI_COMM_WORLD);
|
||||
MPI_Bcast(seq[i], nlenmax+1, MPI_CHAR, 0, MPI_COMM_WORLD);
|
||||
}
|
||||
MPI_Bcast(nlen, njob, MPI_INT, 0, MPI_COMM_WORLD);
|
||||
|
||||
|
||||
constants( njob, seq );
|
||||
|
||||
#if 0
|
||||
fprintf( stderr, "params = %d, %d, %d\n", penalty, penalty_ex, offset );
|
||||
#endif
|
||||
|
||||
initSignalSM();
|
||||
initFiles();
|
||||
|
||||
// WriteOptions( trap_g );
|
||||
|
||||
c = seqcheck( seq );
|
||||
if( c )
|
||||
{
|
||||
fprintf( stderr, "Illegal character %c\n", c );
|
||||
exit( 1 );
|
||||
}
|
||||
|
||||
// writePre( njob, name, nlen, seq, 0 );
|
||||
|
||||
if( treein ) loadtree( njob, topol, len, name, nlen, dep, treeout );
|
||||
pairalign_node( njob, nlenmax, name, seq, topol, len, dep, treein, treeout );
|
||||
|
||||
|
||||
FreeCharMtx( seq ); seq = NULL;
|
||||
|
||||
FreeCharMtx( name ); name = NULL;
|
||||
free( nlen ); nlen = NULL;
|
||||
free( selfscore ); selfscore = NULL;
|
||||
|
||||
for( i=0; i<njob; i++ )
|
||||
{
|
||||
free( topol[i][0] ); topol[i][0] = NULL;
|
||||
free( topol[i][1] ); topol[i][1] = NULL;
|
||||
free( topol[i] ); topol[i] = NULL;
|
||||
free( len[i] ); len[i] = NULL;
|
||||
}
|
||||
free( topol ); topol = NULL;
|
||||
free( len ); len = NULL;
|
||||
free( eff ); eff = NULL;
|
||||
free( dep ); dep = NULL;
|
||||
|
||||
|
||||
freeconstants();
|
||||
closeFiles();
|
||||
FreeCommonIP();
|
||||
|
||||
MPI_Finalize();
|
||||
|
||||
// reporterr( "nodepair_mpi used " );
|
||||
// use_getrusage();
|
||||
return( 0 );
|
||||
|
||||
#if 0 // gui mitaiou
|
||||
chudan:
|
||||
if( seq ) FreeCharMtx( seq ); seq = NULL;
|
||||
|
||||
if( name ) FreeCharMtx( name ); name = NULL;
|
||||
if( nlen ) free( nlen ); nlen = NULL;
|
||||
if( selfscore ) free( selfscore ); selfscore = NULL;
|
||||
|
||||
|
||||
|
||||
if( topol ) FreeIntCub( topol ); topol = NULL;
|
||||
if( dep ) free( dep ); dep = NULL;
|
||||
|
||||
freeconstants();
|
||||
closeFiles();
|
||||
FreeCommonIP();
|
||||
|
||||
if( topol )
|
||||
{
|
||||
for( i=0; i<njob; i++ )
|
||||
{
|
||||
if( topol[i] )
|
||||
{
|
||||
if( topol[i][0] ) free( topol[i][0] ); topol[i][0] = NULL;
|
||||
if( topol[i][1] ) free( topol[i][1] ); topol[i][1] = NULL;
|
||||
}
|
||||
free( topol[i] ); topol[i] = NULL;
|
||||
}
|
||||
free( topol ); topol = NULL;
|
||||
}
|
||||
if( len )
|
||||
{
|
||||
for( i=0; i<njob; i++ )
|
||||
{
|
||||
if( len[i] ) free( len[i] ); len[i] = 0;
|
||||
}
|
||||
free( len ); len = NULL;
|
||||
}
|
||||
if( eff ) free( eff ); eff = NULL;
|
||||
if( dep ) free( dep ); dep = NULL;
|
||||
|
||||
|
||||
|
||||
MPI_Finalize();
|
||||
|
||||
|
||||
return( 0 );
|
||||
#endif
|
||||
|
||||
}
|
3573
mafft/src/mafft-7.487-with-extensions/MPI/pairlocalalign_mpi.c
Normal file
3573
mafft/src/mafft-7.487-with-extensions/MPI/pairlocalalign_mpi.c
Normal file
File diff suppressed because it is too large
Load diff
0
mafft/src/mafft-7.487-with-extensions/binaries/.gitkeep
Normal file
0
mafft/src/mafft-7.487-with-extensions/binaries/.gitkeep
Normal file
210
mafft/src/mafft-7.487-with-extensions/core/DNA.h
Normal file
210
mafft/src/mafft-7.487-with-extensions/core/DNA.h
Normal file
|
@ -0,0 +1,210 @@
|
|||
#define DEFAULTGOP_N -1530
|
||||
#define DEFAULTGEP_N 0
|
||||
#define DEFAULTOFS_N -369
|
||||
#define DEFAULTPAMN 200
|
||||
|
||||
#define DEFAULTRNAGOP_N -1530
|
||||
#define DEFAULTRNAGEP_N 0
|
||||
#define DEFAULTRNATHR_N 0
|
||||
|
||||
// -h 0.11150 -> all positive
|
||||
|
||||
double ribosum4[4][4] =
|
||||
{
|
||||
// a g c t
|
||||
{ 2.22, -1.46, -1.86, -1.39, }, // a
|
||||
{ -1.46, 1.03, -2.48, -1.74, }, // g
|
||||
{ -1.86, -2.48, 1.16, -1.05, }, // c
|
||||
{ -1.39, -1.74, -1.05, 1.65, }, // t
|
||||
};
|
||||
|
||||
double ribosum16[16][16] =
|
||||
{
|
||||
// aa ag ac at ga gg gc gt ca cg cc ct ta tg tc tt
|
||||
{ -2.49, -8.24, -7.04, -4.32, -6.86, -8.39, -5.03, -5.84, -8.84, -4.68, -14.37, -12.64, -4.01, -6.16, -11.32, -9.05, }, // aa
|
||||
{ -8.24, -0.80, -8.89, -5.13, -8.61, -5.38, -5.77, -6.60, -10.41, -4.57, -14.53, -10.14, -5.43, -5.94, -8.87, -11.07, }, // ag
|
||||
{ -7.04, -8.89, -2.11, -2.04, -9.73, -11.05, -3.81, -4.72, -9.37, -5.86, -9.08, -10.45, -5.33, -6.93, -8.67, -7.83, }, // ac
|
||||
{ -4.32, -5.13, -2.04, 4.49, -5.33, -5.61, 2.70, 0.59, -5.56, 1.67, -6.71, -5.17, 1.61, -0.51, -4.81, -2.98, }, // at
|
||||
{ -6.86, -8.61, -9.73, -5.33, -1.05, -8.67, -4.88, -6.10, -7.98, -6.00, -12.43, -7.71, -5.85, -7.55, -6.63, -11.54, }, // ga
|
||||
{ -8.39, -5.38, -11.05, -5.61, -8.67, -1.98, -4.13, -5.77, -11.36, -4.66, -12.58, -13.69, -5.75, -4.27, -12.01, -10.79, }, // gg
|
||||
{ -5.03, -5.77, -3.81, 2.70, -4.88, -4.13, 5.62, 1.21, -5.95, 2.11, -3.70, -5.84, 1.60, -0.08, -4.49, -3.90, }, // gc
|
||||
{ -5.84, -6.60, -4.72, 0.59, -6.10, -5.77, 1.21, 3.47, -7.93, -0.27, -7.88, -5.61, -0.57, -2.09, -5.30, -4.45, }, // gt
|
||||
{ -8.84, -10.41, -9.37, -5.56, -7.98, -11.36, -5.95, -7.93, -5.13, -3.57, -10.45, -8.49, -2.42, -5.63, -7.08, -8.39, }, // ca
|
||||
{ -4.68, -4.57, -5.86, 1.67, -6.00, -4.66, 2.11, -0.27, -3.57, 5.36, -5.71, -4.96, 2.75, 1.32, -4.91, -3.67, }, // cg
|
||||
{ -14.37, -14.53, -9.08, -6.71, -12.43, -12.58, -3.70, -7.88, -10.45, -5.71, -3.59, -5.77, -6.88, -8.41, -7.40, -5.41, }, // cc
|
||||
{ -12.64, -10.14, -10.45, -5.17, -7.71, -13.69, -5.84, -5.61, -8.49, -4.96, -5.77, -2.28, -4.72, -7.36, -3.83, -5.21, }, // ct
|
||||
{ -4.01, -5.43, -5.33, 1.61, -5.85, -5.75, 1.60, -0.57, -2.42, 2.75, -6.88, -4.72, 4.97, 1.14, -2.98, -3.39, }, // ta
|
||||
{ -6.16, -5.94, -6.93, -0.51, -7.55, -4.27, -0.08, -2.09, -5.63, 1.32, -8.41, -7.36, 1.14, 3.36, -4.76, -4.28, }, // tg
|
||||
{ -11.32, -8.87, -8.67, -4.81, -6.63, -12.01, -4.49, -5.30, -7.08, -4.91, -7.40, -3.83, -2.98, -4.76, -3.21, -5.97, }, // tc
|
||||
{ -9.05, -11.07, -7.83, -2.98, -11.54, -10.79, -3.90, -4.45, -8.39, -3.67, -5.41, -5.21, -3.39, -4.28, -5.97, -0.02, }, // tt
|
||||
};
|
||||
|
||||
int locpenaltyn = -1750;
|
||||
char locaminon[] = "agctuAGCTUnNbdhkmnrsvwyx-O";
|
||||
char locgrpn[] =
|
||||
{
|
||||
0, 1, 2, 3, 3, 0, 1, 2, 3, 3,
|
||||
4, 4, 5, 5, 5, 5, 5, 5, 5, 5,
|
||||
5, 5, 5, 5, 5, 5
|
||||
};
|
||||
int exgpn = +00;
|
||||
int locn_disn[26][26] =
|
||||
/* u ha constants.c no nakade shori */
|
||||
/* 0 - 4 dake yomareru. */
|
||||
{
|
||||
{
|
||||
1000, 600, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, -500,
|
||||
},
|
||||
|
||||
{
|
||||
600, 1000, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, -500,
|
||||
},
|
||||
|
||||
{
|
||||
0, 0, 1000, 600, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, -500,
|
||||
},
|
||||
|
||||
{
|
||||
0, 0, 600, 1000, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, -500,
|
||||
},
|
||||
|
||||
{
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, -500,
|
||||
},
|
||||
|
||||
{
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, -500,
|
||||
},
|
||||
|
||||
{
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, -500,
|
||||
},
|
||||
|
||||
{
|
||||
0, 500, 500, 0, 0, 0, 500, 500, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, -500,
|
||||
},
|
||||
|
||||
{
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, -500,
|
||||
},
|
||||
|
||||
{
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, -500,
|
||||
},
|
||||
|
||||
{
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, -500,
|
||||
},
|
||||
|
||||
{
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, -500,
|
||||
},
|
||||
|
||||
{
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, -500,
|
||||
},
|
||||
|
||||
{
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, -500,
|
||||
},
|
||||
|
||||
{
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, -500,
|
||||
},
|
||||
|
||||
{
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, -500,
|
||||
},
|
||||
|
||||
{
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, -500,
|
||||
},
|
||||
|
||||
{
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, -500,
|
||||
},
|
||||
|
||||
{
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, -500,
|
||||
},
|
||||
|
||||
{
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, -500,
|
||||
},
|
||||
|
||||
{
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, -500,
|
||||
},
|
||||
|
||||
{
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, -500,
|
||||
},
|
||||
|
||||
{
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, -500,
|
||||
},
|
||||
|
||||
{
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, -500,
|
||||
},
|
||||
|
||||
{
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0,
|
||||
},
|
||||
|
||||
{
|
||||
-500, -500, -500, -500, -500, -500, -500, -500, -500, -500,
|
||||
-500, -500, -500, -500, -500, -500, -500, -500, -500, -500,
|
||||
-500, -500, -500, -500, 0, 500,
|
||||
},
|
||||
};
|
6266
mafft/src/mafft-7.487-with-extensions/core/Dalignmm.c
Normal file
6266
mafft/src/mafft-7.487-with-extensions/core/Dalignmm.c
Normal file
File diff suppressed because it is too large
Load diff
3611
mafft/src/mafft-7.487-with-extensions/core/Falign.c
Normal file
3611
mafft/src/mafft-7.487-with-extensions/core/Falign.c
Normal file
File diff suppressed because it is too large
Load diff
875
mafft/src/mafft-7.487-with-extensions/core/Falign_localhom.c
Normal file
875
mafft/src/mafft-7.487-with-extensions/core/Falign_localhom.c
Normal file
|
@ -0,0 +1,875 @@
|
|||
#include "mltaln.h"
|
||||
|
||||
//static FILE *fftfp;
|
||||
static TLS int n20or4or2;
|
||||
|
||||
#define KEIKA 0
|
||||
#define RND 0
|
||||
#define DEBUG 0
|
||||
|
||||
extern int fft( int, Fukusosuu *, int );
|
||||
|
||||
|
||||
#if 0
|
||||
static void generateRndSeq( char *seq, int len )
|
||||
{
|
||||
while( len-- )
|
||||
#if 1
|
||||
*seq++ = (int)( rnd() * n20or4or2 );
|
||||
#else
|
||||
*seq++ = (int)1;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
static void vec_init( Fukusosuu *result, int nlen )
|
||||
{
|
||||
while( nlen-- )
|
||||
{
|
||||
result->R = result->I = 0.0;
|
||||
result++;
|
||||
}
|
||||
}
|
||||
|
||||
#if 0
|
||||
static void vec_init2( Fukusosuu **result, char *seq, double eff, int st, int ed )
|
||||
{
|
||||
int i;
|
||||
for( i=st; i<ed; i++ )
|
||||
result[(int)*seq++][i].R += eff;
|
||||
}
|
||||
#endif
|
||||
|
||||
static void seq_vec_2( Fukusosuu *result, double *score, double incr, char *seq )
|
||||
{
|
||||
static TLS int n;
|
||||
for( ; *seq; result++ )
|
||||
{
|
||||
n = amino_n[(unsigned char)*seq++];
|
||||
if( n < 20 && n >= 0 ) result->R += incr * score[n];
|
||||
#if 0
|
||||
fprintf( stderr, "n=%d, score=%f, inc=%f R=%f\n",n, score[n], incr * score[n], result->R );
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
static void seq_vec_3( Fukusosuu **result, double incr, char *seq )
|
||||
{
|
||||
int i;
|
||||
int n;
|
||||
for( i=0; *seq; i++ )
|
||||
{
|
||||
n = amino_n[(unsigned char)*seq++];
|
||||
if( n < n20or4or2 && n >= 0 ) result[n][i].R += incr;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#if 0
|
||||
static void seq_vec( Fukusosuu *result, char query, double incr, char *seq )
|
||||
{
|
||||
#if 0
|
||||
int bk = nlen;
|
||||
#endif
|
||||
while( *seq )
|
||||
{
|
||||
if( *seq++ == query ) result->R += incr;
|
||||
result++;
|
||||
#if 0
|
||||
fprintf( stderr, "i = %d result->R = %f\n", bk-nlen, (result-1)->R );
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
static int checkRepeat( int num, int *cutpos )
|
||||
{
|
||||
int tmp, buf;
|
||||
|
||||
buf = *cutpos;
|
||||
while( num-- )
|
||||
{
|
||||
if( ( tmp = *cutpos++ ) < buf ) return( 1 );
|
||||
buf = tmp;
|
||||
}
|
||||
return( 0 );
|
||||
}
|
||||
|
||||
static int segcmp( void *ptr1, void *ptr2 )
|
||||
{
|
||||
int diff;
|
||||
Segment **seg1 = (Segment **)ptr1;
|
||||
Segment **seg2 = (Segment **)ptr2;
|
||||
#if 0
|
||||
return( (*seg1)->center - (*seg2)->center );
|
||||
#else
|
||||
diff = (*seg1)->center - (*seg2)->center;
|
||||
if( diff ) return( diff );
|
||||
|
||||
diff = (*seg1)->start - (*seg2)->start;
|
||||
if( diff ) return( diff );
|
||||
|
||||
diff = (*seg1)->end - (*seg2)->end;
|
||||
if( diff ) return( diff );
|
||||
|
||||
fprintf( stderr, "USE STABLE SORT !!\n" );
|
||||
exit( 1 );
|
||||
return( 0 );
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
static void mymergesort( int first, int last, Segment **seg )
|
||||
{
|
||||
int middle;
|
||||
static TLS int i, j, k, p;
|
||||
static TLS int allo = 0;
|
||||
static TLS Segment **work = NULL;
|
||||
|
||||
if( seg == NULL )
|
||||
{
|
||||
free( work ); work = NULL;
|
||||
return;
|
||||
}
|
||||
|
||||
if( last > allo )
|
||||
{
|
||||
allo = last;
|
||||
if( work ) free( work );
|
||||
work = (Segment **)calloc( allo / 2 + 1, sizeof( Segment *) );
|
||||
}
|
||||
|
||||
if( first < last )
|
||||
{
|
||||
middle = ( first + last ) / 2;
|
||||
mymergesort( first, middle, seg );
|
||||
mymergesort( middle+1, last, seg );
|
||||
p = 0;
|
||||
for( i=first; i<=middle; i++ ) work[p++] = seg[i];
|
||||
i = middle + 1; j = 0; k = first;
|
||||
while( i <= last && j < p )
|
||||
{
|
||||
if( work[j]->center <= seg[i]->center )
|
||||
seg[k++] = work[j++];
|
||||
else
|
||||
seg[k++] = seg[i++];
|
||||
}
|
||||
while( j < p ) seg[k++] = work[j++];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
double Falign_localhom( int **whichmtx, double ***scoringmatrices, double **n_dynamicmtx,
|
||||
char **seq1, char **seq2,
|
||||
double *eff1, double *eff2,
|
||||
double **eff1s, double **eff2s,
|
||||
int clus1, int clus2,
|
||||
int alloclen,
|
||||
int constraint, double *totalimpmatch,
|
||||
int *gapmap1, int *gapmap2,
|
||||
int *chudanpt, int chudanref, int *chudanres )
|
||||
{
|
||||
// tditeration.c deha alloclen ha huhen nanode
|
||||
// prevalloclen ha iranai.
|
||||
int i, j, k, l, m, maxk;
|
||||
int nlen, nlen2, nlen4;
|
||||
static TLS int crossscoresize = 0;
|
||||
static TLS char **tmpseq1 = NULL;
|
||||
static TLS char **tmpseq2 = NULL;
|
||||
static TLS char **tmpptr1 = NULL;
|
||||
static TLS char **tmpptr2 = NULL;
|
||||
static TLS char **tmpres1 = NULL;
|
||||
static TLS char **tmpres2 = NULL;
|
||||
static TLS char **result1 = NULL;
|
||||
static TLS char **result2 = NULL;
|
||||
#if RND
|
||||
static TLS char **rndseq1 = NULL;
|
||||
static TLS char **rndseq2 = NULL;
|
||||
#endif
|
||||
static TLS Fukusosuu **seqVector1 = NULL;
|
||||
static TLS Fukusosuu **seqVector2 = NULL;
|
||||
static TLS Fukusosuu **naiseki = NULL;
|
||||
static TLS Fukusosuu *naisekiNoWa = NULL;
|
||||
static TLS double *soukan = NULL;
|
||||
static TLS double **crossscore = NULL;
|
||||
int nlentmp;
|
||||
static TLS int *kouho = NULL;
|
||||
static TLS Segment *segment = NULL;
|
||||
static TLS Segment *segment1 = NULL;
|
||||
static TLS Segment *segment2 = NULL;
|
||||
static TLS Segment **sortedseg1 = NULL;
|
||||
static TLS Segment **sortedseg2 = NULL;
|
||||
static TLS int *cut1 = NULL;
|
||||
static TLS int *cut2 = NULL;
|
||||
static TLS char *sgap1, *egap1, *sgap2, *egap2;
|
||||
static TLS int localalloclen = 0;
|
||||
int lag;
|
||||
int tmpint;
|
||||
int count, count0;
|
||||
int len1, len2;
|
||||
int totallen;
|
||||
double totalscore;
|
||||
double impmatch;
|
||||
|
||||
extern Fukusosuu *AllocateFukusosuuVec();
|
||||
extern Fukusosuu **AllocateFukusosuuMtx();
|
||||
|
||||
if( seq1 == NULL )
|
||||
{
|
||||
if( result1 )
|
||||
{
|
||||
// fprintf( stderr, "Freeing localarrays in Falign\n" );
|
||||
localalloclen = 0;
|
||||
crossscoresize = 0;
|
||||
mymergesort( 0, 0, NULL );
|
||||
alignableReagion( 0, 0, NULL, NULL, NULL, NULL, NULL );
|
||||
fft( 0, NULL, 1 );
|
||||
// A__align( NULL, NULL, NULL, NULL, NULL, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, NULL, 0, 0, -1, -1 ); // iru?
|
||||
G__align11( NULL, NULL, NULL, 0, 0, 0 );
|
||||
partA__align( NULL, NULL, NULL, NULL, 0, 0, 0, 0, NULL, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, NULL );
|
||||
partA__align_variousdist( NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, 0, 0, 0, NULL, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, NULL );
|
||||
blockAlign2( NULL, NULL, NULL, NULL, NULL, NULL );
|
||||
if( crossscore ) FreeDoubleMtx( crossscore );
|
||||
FreeCharMtx( result1 );
|
||||
FreeCharMtx( result2 );
|
||||
FreeCharMtx( tmpres1 );
|
||||
FreeCharMtx( tmpres2 );
|
||||
FreeCharMtx( tmpseq1 );
|
||||
FreeCharMtx( tmpseq2 );
|
||||
free( sgap1 );
|
||||
free( egap1 );
|
||||
free( sgap2 );
|
||||
free( egap2 );
|
||||
free( kouho );
|
||||
free( cut1 );
|
||||
free( cut2 );
|
||||
free( tmpptr1 );
|
||||
free( tmpptr2 );
|
||||
free( segment );
|
||||
free( segment1 );
|
||||
free( segment2 );
|
||||
free( sortedseg1 );
|
||||
free( sortedseg2 );
|
||||
if( !kobetsubunkatsu )
|
||||
{
|
||||
FreeFukusosuuMtx ( seqVector1 );
|
||||
FreeFukusosuuMtx ( seqVector2 );
|
||||
FreeFukusosuuVec( naisekiNoWa );
|
||||
FreeFukusosuuMtx( naiseki );
|
||||
FreeDoubleVec( soukan );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// fprintf( stderr, "Did not allocate localarrays in Falign\n" );
|
||||
}
|
||||
|
||||
return( 0.0 );
|
||||
}
|
||||
|
||||
len1 = strlen( seq1[0] );
|
||||
len2 = strlen( seq2[0] );
|
||||
nlentmp = MAX( len1, len2 );
|
||||
|
||||
nlen = 1;
|
||||
while( nlentmp >= nlen ) nlen <<= 1;
|
||||
#if 0
|
||||
fprintf( stderr, "### nlen = %d\n", nlen );
|
||||
#endif
|
||||
|
||||
nlen2 = nlen/2; nlen4 = nlen2 / 2;
|
||||
|
||||
#if DEBUG
|
||||
fprintf( stderr, "len1 = %d, len2 = %d\n", len1, len2 );
|
||||
fprintf( stderr, "nlentmp = %d, nlen = %d\n", nlentmp, nlen );
|
||||
#endif
|
||||
|
||||
if( !localalloclen )
|
||||
{
|
||||
sgap1 = AllocateCharVec( njob );
|
||||
egap1 = AllocateCharVec( njob );
|
||||
sgap2 = AllocateCharVec( njob );
|
||||
egap2 = AllocateCharVec( njob );
|
||||
kouho = AllocateIntVec( NKOUHO );
|
||||
cut1 = AllocateIntVec( MAXSEG );
|
||||
cut2 = AllocateIntVec( MAXSEG );
|
||||
tmpptr1 = AllocateCharMtx( njob, 0 );
|
||||
tmpptr2 = AllocateCharMtx( njob, 0 );
|
||||
result1 = AllocateCharMtx( njob, alloclen );
|
||||
result2 = AllocateCharMtx( njob, alloclen );
|
||||
tmpres1 = AllocateCharMtx( njob, alloclen );
|
||||
tmpres2 = AllocateCharMtx( njob, alloclen );
|
||||
// crossscore = AllocateDoubleMtx( MAXSEG, MAXSEG );
|
||||
segment = (Segment *)calloc( MAXSEG, sizeof( Segment ) );
|
||||
segment1 = (Segment *)calloc( MAXSEG, sizeof( Segment ) );
|
||||
segment2 = (Segment *)calloc( MAXSEG, sizeof( Segment ) );
|
||||
sortedseg1 = (Segment **)calloc( MAXSEG, sizeof( Segment * ) );
|
||||
sortedseg2 = (Segment **)calloc( MAXSEG, sizeof( Segment * ) );
|
||||
if( !( segment && segment1 && segment2 && sortedseg1 && sortedseg2 ) )
|
||||
ErrorExit( "Allocation error\n" );
|
||||
|
||||
if ( scoremtx == -1 ) n20or4or2 = 4;
|
||||
else if( fftscore == 1 ) n20or4or2 = 2;
|
||||
else n20or4or2 = 20;
|
||||
}
|
||||
if( localalloclen < nlen )
|
||||
{
|
||||
if( localalloclen )
|
||||
{
|
||||
#if 1
|
||||
if( !kobetsubunkatsu )
|
||||
{
|
||||
FreeFukusosuuMtx ( seqVector1 );
|
||||
FreeFukusosuuMtx ( seqVector2 );
|
||||
FreeFukusosuuVec( naisekiNoWa );
|
||||
FreeFukusosuuMtx( naiseki );
|
||||
FreeDoubleVec( soukan );
|
||||
}
|
||||
FreeCharMtx( tmpseq1 );
|
||||
FreeCharMtx( tmpseq2 );
|
||||
#endif
|
||||
#if RND
|
||||
FreeCharMtx( rndseq1 );
|
||||
FreeCharMtx( rndseq2 );
|
||||
#endif
|
||||
}
|
||||
|
||||
tmpseq1 = AllocateCharMtx( njob, nlen );
|
||||
tmpseq2 = AllocateCharMtx( njob, nlen );
|
||||
if( !kobetsubunkatsu )
|
||||
{
|
||||
naisekiNoWa = AllocateFukusosuuVec( nlen );
|
||||
naiseki = AllocateFukusosuuMtx( n20or4or2, nlen );
|
||||
seqVector1 = AllocateFukusosuuMtx( n20or4or2+1, nlen+1 );
|
||||
seqVector2 = AllocateFukusosuuMtx( n20or4or2+1, nlen+1 );
|
||||
soukan = AllocateDoubleVec( nlen+1 );
|
||||
}
|
||||
#if RND
|
||||
rndseq1 = AllocateCharMtx( njob, nlen );
|
||||
rndseq2 = AllocateCharMtx( njob, nlen );
|
||||
for( i=0; i<njob; i++ )
|
||||
{
|
||||
generateRndSeq( rndseq1[i], nlen );
|
||||
generateRndSeq( rndseq2[i], nlen );
|
||||
}
|
||||
#endif
|
||||
localalloclen = nlen;
|
||||
}
|
||||
|
||||
for( j=0; j<clus1; j++ ) strcpy( tmpseq1[j], seq1[j] );
|
||||
for( j=0; j<clus2; j++ ) strcpy( tmpseq2[j], seq2[j] );
|
||||
|
||||
#if 0
|
||||
fftfp = fopen( "input_of_Falign", "w" );
|
||||
fprintf( fftfp, "nlen = %d\n", nlen );
|
||||
fprintf( fftfp, "seq1: ( %d sequences ) \n", clus1 );
|
||||
for( i=0; i<clus1; i++ )
|
||||
fprintf( fftfp, "%s\n", seq1[i] );
|
||||
fprintf( fftfp, "seq2: ( %d sequences ) \n", clus2 );
|
||||
for( i=0; i<clus2; i++ )
|
||||
fprintf( fftfp, "%s\n", seq2[i] );
|
||||
fclose( fftfp );
|
||||
system( "less input_of_Falign < /dev/tty > /dev/tty" );
|
||||
#endif
|
||||
if( !kobetsubunkatsu )
|
||||
{
|
||||
fprintf( stderr, "FFT ... " );
|
||||
|
||||
for( j=0; j<n20or4or2; j++ ) vec_init( seqVector1[j], nlen );
|
||||
if( fftscore && scoremtx != -1 )
|
||||
{
|
||||
for( i=0; i<clus1; i++ )
|
||||
{
|
||||
seq_vec_2( seqVector1[0], polarity, eff1[i], tmpseq1[i] );
|
||||
seq_vec_2( seqVector1[1], volume, eff1[i], tmpseq1[i] );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
#if 0
|
||||
for( i=0; i<clus1; i++ ) for( j=0; j<n20or4or2; j++ )
|
||||
seq_vec( seqVector1[j], amino[j], eff1[i], tmpseq1[i] );
|
||||
#else
|
||||
for( i=0; i<clus1; i++ )
|
||||
seq_vec_3( seqVector1, eff1[i], tmpseq1[i] );
|
||||
#endif
|
||||
}
|
||||
#if RND
|
||||
for( i=0; i<clus1; i++ )
|
||||
{
|
||||
vec_init2( seqVector1, rndseq1[i], eff1[i], len1, nlen );
|
||||
}
|
||||
#endif
|
||||
#if 0
|
||||
fftfp = fopen( "seqVec", "w" );
|
||||
fprintf( fftfp, "before transform\n" );
|
||||
for( k=0; k<n20or4or2; k++ )
|
||||
{
|
||||
fprintf( fftfp, "nlen=%d\n", nlen );
|
||||
fprintf( fftfp, "%c\n", amino[k] );
|
||||
for( l=0; l<nlen; l++ )
|
||||
fprintf( fftfp, "%f %f\n", seqVector1[k][l].R, seqVector1[k][l].I );
|
||||
}
|
||||
fclose( fftfp );
|
||||
system( "less seqVec < /dev/tty > /dev/tty" );
|
||||
#endif
|
||||
|
||||
for( j=0; j<n20or4or2; j++ ) vec_init( seqVector2[j], nlen );
|
||||
if( fftscore && scoremtx != -1 )
|
||||
{
|
||||
for( i=0; i<clus2; i++ )
|
||||
{
|
||||
seq_vec_2( seqVector2[0], polarity, eff2[i], tmpseq2[i] );
|
||||
seq_vec_2( seqVector2[1], volume, eff2[i], tmpseq2[i] );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
#if 0
|
||||
for( i=0; i<clus2; i++ ) for( j=0; j<n20or4or2; j++ )
|
||||
seq_vec( seqVector2[j], amino[j], eff2[i], tmpseq2[i] );
|
||||
#else
|
||||
for( i=0; i<clus2; i++ )
|
||||
seq_vec_3( seqVector2, eff2[i], tmpseq2[i] );
|
||||
#endif
|
||||
}
|
||||
#if RND
|
||||
for( i=0; i<clus2; i++ )
|
||||
{
|
||||
vec_init2( seqVector2, rndseq2[i], eff2[i], len2, nlen );
|
||||
}
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
fftfp = fopen( "seqVec2", "w" );
|
||||
fprintf( fftfp, "before fft\n" );
|
||||
for( k=0; k<n20or4or2; k++ )
|
||||
{
|
||||
fprintf( fftfp, "%c\n", amino[k] );
|
||||
for( l=0; l<nlen; l++ )
|
||||
fprintf( fftfp, "%f %f\n", seqVector2[k][l].R, seqVector2[k][l].I );
|
||||
}
|
||||
fclose( fftfp );
|
||||
system( "less seqVec2 < /dev/tty > /dev/tty" );
|
||||
#endif
|
||||
|
||||
for( j=0; j<n20or4or2; j++ )
|
||||
{
|
||||
fft( nlen, seqVector2[j], (j==0) );
|
||||
fft( nlen, seqVector1[j], 0 );
|
||||
}
|
||||
#if 0
|
||||
fftfp = fopen( "seqVec2", "w" );
|
||||
fprintf( fftfp, "#after fft\n" );
|
||||
for( k=0; k<n20or4or2; k++ )
|
||||
{
|
||||
fprintf( fftfp, "#%c\n", amino[k] );
|
||||
for( l=0; l<nlen; l++ )
|
||||
fprintf( fftfp, "%f %f\n", seqVector2[k][l].R, seqVector2[k][l].I );
|
||||
}
|
||||
fclose( fftfp );
|
||||
system( "less seqVec2 < /dev/tty > /dev/tty" );
|
||||
#endif
|
||||
|
||||
for( k=0; k<n20or4or2; k++ )
|
||||
{
|
||||
for( l=0; l<nlen; l++ )
|
||||
calcNaiseki( naiseki[k]+l, seqVector1[k]+l, seqVector2[k]+l );
|
||||
}
|
||||
for( l=0; l<nlen; l++ )
|
||||
{
|
||||
naisekiNoWa[l].R = 0.0;
|
||||
naisekiNoWa[l].I = 0.0;
|
||||
for( k=0; k<n20or4or2; k++ )
|
||||
{
|
||||
naisekiNoWa[l].R += naiseki[k][l].R;
|
||||
naisekiNoWa[l].I += naiseki[k][l].I;
|
||||
}
|
||||
}
|
||||
|
||||
#if 0
|
||||
fftfp = fopen( "naisekiNoWa", "w" );
|
||||
fprintf( fftfp, "#Before fft\n" );
|
||||
for( l=0; l<nlen; l++ )
|
||||
fprintf( fftfp, "%d %f %f\n", l, naisekiNoWa[l].R, naisekiNoWa[l].I );
|
||||
fclose( fftfp );
|
||||
system( "less naisekiNoWa < /dev/tty > /dev/tty " );
|
||||
#endif
|
||||
|
||||
fft( -nlen, naisekiNoWa, 0 );
|
||||
|
||||
for( m=0; m<=nlen2; m++ )
|
||||
soukan[m] = naisekiNoWa[nlen2-m].R;
|
||||
for( m=nlen2+1; m<nlen; m++ )
|
||||
soukan[m] = naisekiNoWa[nlen+nlen2-m].R;
|
||||
|
||||
#if 0
|
||||
fftfp = fopen( "naisekiNoWa", "w" );
|
||||
fprintf( fftfp, "#After fft\n" );
|
||||
for( l=0; l<nlen; l++ )
|
||||
fprintf( fftfp, "%d %f\n", l, naisekiNoWa[l].R );
|
||||
fclose( fftfp );
|
||||
fftfp = fopen( "list.plot", "w" );
|
||||
fprintf( fftfp, "plot 'naisekiNoWa'\npause -1" );
|
||||
fclose( fftfp );
|
||||
system( "/usr/bin/gnuplot list.plot &" );
|
||||
#endif
|
||||
#if 0
|
||||
fprintf( stderr, "frt write start\n" );
|
||||
fftfp = fopen( "frt", "w" );
|
||||
for( l=0; l<nlen; l++ )
|
||||
fprintf( fftfp, "%d %f\n", l-nlen2, soukan[l] );
|
||||
fclose( fftfp );
|
||||
system( "less frt < /dev/tty > /dev/tty" );
|
||||
#if 0
|
||||
fftfp = fopen( "list.plot", "w" );
|
||||
fprintf( fftfp, "plot 'frt'\n pause +1" );
|
||||
fclose( fftfp );
|
||||
system( "/usr/bin/gnuplot list.plot" );
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
getKouho( kouho, NKOUHO, soukan, nlen );
|
||||
|
||||
#if 0
|
||||
for( i=0; i<NKOUHO; i++ )
|
||||
{
|
||||
fprintf( stderr, "kouho[%d] = %d\n", i, kouho[i] );
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#if KEIKA
|
||||
fprintf( stderr, "Searching anchors ... " );
|
||||
#endif
|
||||
count = 0;
|
||||
|
||||
|
||||
|
||||
#define CAND 0
|
||||
#if CAND
|
||||
fftfp = fopen( "cand", "w" );
|
||||
fclose( fftfp );
|
||||
#endif
|
||||
if( kobetsubunkatsu )
|
||||
{
|
||||
maxk = 1;
|
||||
kouho[0] = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
maxk = NKOUHO;
|
||||
}
|
||||
|
||||
for( k=0; k<maxk; k++ )
|
||||
{
|
||||
lag = kouho[k];
|
||||
zurasu2( lag, clus1, clus2, seq1, seq2, tmpptr1, tmpptr2 );
|
||||
#if CAND
|
||||
fftfp = fopen( "cand", "a" );
|
||||
fprintf( fftfp, "Candidate No.%d lag = %d\n", k+1, lag );
|
||||
fprintf( fftfp, "%s\n", tmpptr1[0] );
|
||||
fprintf( fftfp, "%s\n", tmpptr2[0] );
|
||||
fclose( fftfp );
|
||||
#endif
|
||||
tmpint = alignableReagion( clus1, clus2, tmpptr1, tmpptr2, eff1, eff2, segment+count );
|
||||
|
||||
if( count+tmpint > MAXSEG -3 ) ErrorExit( "TOO MANY SEGMENTS.\n" );
|
||||
|
||||
|
||||
while( tmpint-- > 0 )
|
||||
{
|
||||
if( lag > 0 )
|
||||
{
|
||||
segment1[count].start = segment[count].start ;
|
||||
segment1[count].end = segment[count].end ;
|
||||
segment1[count].center = segment[count].center;
|
||||
segment1[count].score = segment[count].score;
|
||||
|
||||
segment2[count].start = segment[count].start + lag;
|
||||
segment2[count].end = segment[count].end + lag;
|
||||
segment2[count].center = segment[count].center + lag;
|
||||
segment2[count].score = segment[count].score ;
|
||||
}
|
||||
else
|
||||
{
|
||||
segment1[count].start = segment[count].start - lag;
|
||||
segment1[count].end = segment[count].end - lag;
|
||||
segment1[count].center = segment[count].center - lag;
|
||||
segment1[count].score = segment[count].score ;
|
||||
|
||||
segment2[count].start = segment[count].start ;
|
||||
segment2[count].end = segment[count].end ;
|
||||
segment2[count].center = segment[count].center;
|
||||
segment2[count].score = segment[count].score ;
|
||||
}
|
||||
#if 0
|
||||
fftfp = fopen( "cand", "a" );
|
||||
fprintf( fftfp, "Goukaku=%dko\n", tmpint );
|
||||
fprintf( fftfp, "in 1 %d\n", segment1[count].center );
|
||||
fprintf( fftfp, "in 2 %d\n", segment2[count].center );
|
||||
fclose( fftfp );
|
||||
#endif
|
||||
segment1[count].pair = &segment2[count];
|
||||
segment2[count].pair = &segment1[count];
|
||||
count++;
|
||||
#if 0
|
||||
fprintf( stderr, "count=%d\n", count );
|
||||
#endif
|
||||
}
|
||||
}
|
||||
#if 1
|
||||
if( !kobetsubunkatsu )
|
||||
fprintf( stderr, "%d segments found\n", count );
|
||||
#endif
|
||||
if( !count && fftNoAnchStop )
|
||||
ErrorExit( "Cannot detect anchor!" );
|
||||
#if 0
|
||||
fftfp = fopen( "fft", "a" );
|
||||
fprintf( fftfp, "RESULT before sort:\n" );
|
||||
for( l=0; l<count; l++ )
|
||||
{
|
||||
fprintf( fftfp, "cut[%d]=%d, ", l, segment1[l].center );
|
||||
fprintf( fftfp, "%d score = %f\n", segment2[l].center, segment1[l].score );
|
||||
}
|
||||
fclose( fftfp );
|
||||
#endif
|
||||
|
||||
#if KEIKA
|
||||
fprintf( stderr, "Aligning anchors ... " );
|
||||
#endif
|
||||
for( i=0; i<count; i++ )
|
||||
{
|
||||
sortedseg1[i] = &segment1[i];
|
||||
sortedseg2[i] = &segment2[i];
|
||||
}
|
||||
#if 0
|
||||
tmpsort( count, sortedseg1 );
|
||||
tmpsort( count, sortedseg2 );
|
||||
qsort( sortedseg1, count, sizeof( Segment * ), segcmp );
|
||||
qsort( sortedseg2, count, sizeof( Segment * ), segcmp );
|
||||
#else
|
||||
mymergesort( 0, count-1, sortedseg1 );
|
||||
mymergesort( 0, count-1, sortedseg2 );
|
||||
#endif
|
||||
for( i=0; i<count; i++ ) sortedseg1[i]->number = i;
|
||||
for( i=0; i<count; i++ ) sortedseg2[i]->number = i;
|
||||
|
||||
|
||||
if( kobetsubunkatsu )
|
||||
{
|
||||
for( i=0; i<count; i++ )
|
||||
{
|
||||
cut1[i+1] = sortedseg1[i]->center;
|
||||
cut2[i+1] = sortedseg2[i]->center;
|
||||
}
|
||||
cut1[0] = 0;
|
||||
cut2[0] = 0;
|
||||
cut1[count+1] = len1;
|
||||
cut2[count+1] = len2;
|
||||
count += 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
if( crossscoresize < count+2 )
|
||||
{
|
||||
crossscoresize = count+2;
|
||||
#if 1
|
||||
fprintf( stderr, "######allocating crossscore, size = %d\n", crossscoresize );
|
||||
#endif
|
||||
if( crossscore ) FreeDoubleMtx( crossscore );
|
||||
crossscore = AllocateDoubleMtx( crossscoresize, crossscoresize );
|
||||
}
|
||||
for( i=0; i<count+2; i++ ) for( j=0; j<count+2; j++ )
|
||||
crossscore[i][j] = 0.0;
|
||||
for( i=0; i<count; i++ )
|
||||
{
|
||||
crossscore[segment1[i].number+1][segment1[i].pair->number+1] = segment1[i].score;
|
||||
cut1[i+1] = sortedseg1[i]->center;
|
||||
cut2[i+1] = sortedseg2[i]->center;
|
||||
}
|
||||
|
||||
#if DEBUG
|
||||
fprintf( stderr, "AFTER SORT\n" );
|
||||
for( i=0; i<count; i++ ) fprintf( stderr, "%d, %d\n", segment1[i].start, segment2[i].start );
|
||||
#endif
|
||||
|
||||
crossscore[0][0] = 10000000.0;
|
||||
cut1[0] = 0;
|
||||
cut2[0] = 0;
|
||||
crossscore[count+1][count+1] = 10000000.0;
|
||||
cut1[count+1] = len1;
|
||||
cut2[count+1] = len2;
|
||||
count += 2;
|
||||
count0 = count;
|
||||
|
||||
blockAlign2( cut1, cut2, sortedseg1, sortedseg2, crossscore, &count );
|
||||
if( count0 > count )
|
||||
{
|
||||
#if 0
|
||||
fprintf( stderr, "\7 REPEAT!? \n" );
|
||||
#else
|
||||
fprintf( stderr, "REPEAT!? \n" );
|
||||
#endif
|
||||
if( fftRepeatStop ) exit( 1 );
|
||||
}
|
||||
#if KEIKA
|
||||
else fprintf( stderr, "done\n" );
|
||||
#endif
|
||||
}
|
||||
|
||||
#if 0
|
||||
fftfp = fopen( "fft", "a" );
|
||||
fprintf( fftfp, "RESULT after sort:\n" );
|
||||
for( l=0; l<count; l++ )
|
||||
{
|
||||
fprintf( fftfp, "cut[%d]=%d, ", l, segment1[l].center );
|
||||
fprintf( fftfp, "%d\n", segment2[l].center );
|
||||
}
|
||||
fclose( fftfp );
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
fftfp = fopen( "fft", "a" );
|
||||
fprintf( fftfp, "RESULT after sort:\n" );
|
||||
for( l=0; l<count; l++ )
|
||||
{
|
||||
fprintf( fftfp, "cut : %d %d\n", cut1[l], cut2[l] );
|
||||
}
|
||||
fclose( fftfp );
|
||||
#endif
|
||||
|
||||
#if KEIKA
|
||||
fprintf( trap_g, "Devided to %d segments\n", count-1 );
|
||||
fprintf( trap_g, "%d %d forg\n", MIN( clus1, clus2 ), count-1 );
|
||||
#endif
|
||||
|
||||
totallen = 0;
|
||||
for( j=0; j<clus1; j++ ) result1[j][0] = 0;
|
||||
for( j=0; j<clus2; j++ ) result2[j][0] = 0;
|
||||
totalscore = 0.0;
|
||||
*totalimpmatch = 0.0;
|
||||
for( i=0; i<count-1; i++ )
|
||||
{
|
||||
#if DEBUG
|
||||
fprintf( stderr, "DP %03d / %03d %4d to ", i+1, count-1, totallen );
|
||||
#else
|
||||
#if KEIKA
|
||||
fprintf( stderr, "DP %03d / %03d\r", i+1, count-1 );
|
||||
#endif
|
||||
#endif
|
||||
|
||||
if( cut1[i] )
|
||||
{
|
||||
getkyokaigap( sgap1, seq1, cut1[i]-1, clus1 );
|
||||
getkyokaigap( sgap2, seq2, cut2[i]-1, clus2 );
|
||||
}
|
||||
else
|
||||
{
|
||||
for( j=0; j<clus1; j++ ) sgap1[j] = 'o';
|
||||
for( j=0; j<clus2; j++ ) sgap2[j] = 'o';
|
||||
}
|
||||
if( cut1[i+1] != len1 )
|
||||
{
|
||||
getkyokaigap( egap1, seq1, cut1[i+1], clus1 );
|
||||
getkyokaigap( egap2, seq2, cut2[i+1], clus2 );
|
||||
}
|
||||
else
|
||||
{
|
||||
for( j=0; j<clus1; j++ ) egap1[j] = 'o';
|
||||
for( j=0; j<clus2; j++ ) egap2[j] = 'o';
|
||||
}
|
||||
|
||||
for( j=0; j<clus1; j++ )
|
||||
{
|
||||
strncpy( tmpres1[j], seq1[j]+cut1[i], cut1[i+1]-cut1[i] );
|
||||
tmpres1[j][cut1[i+1]-cut1[i]] = 0;
|
||||
}
|
||||
if( kobetsubunkatsu ) commongappick_record( clus1, tmpres1, gapmap1 );
|
||||
for( j=0; j<clus2; j++ )
|
||||
{
|
||||
strncpy( tmpres2[j], seq2[j]+cut2[i], cut2[i+1]-cut2[i] );
|
||||
tmpres2[j][cut2[i+1]-cut2[i]] = 0;
|
||||
}
|
||||
if( kobetsubunkatsu ) commongappick_record( clus2, tmpres2, gapmap2 );
|
||||
|
||||
#if 0
|
||||
fprintf( stderr, "count = %d\n", count );
|
||||
fprintf( stderr, "### reg1 = %d-%d\n", cut1[i], cut1[i+1]-1 );
|
||||
fprintf( stderr, "### reg2 = %d-%d\n", cut2[i], cut2[i+1]-1 );
|
||||
#endif
|
||||
|
||||
switch( alg )
|
||||
{
|
||||
case( 'a' ):
|
||||
totalscore += Aalign( tmpres1, tmpres2, eff1, eff2, clus1, clus2, alloclen );
|
||||
break;
|
||||
case( 'A' ):
|
||||
if( scoringmatrices ) // called by tditeration.c
|
||||
{
|
||||
totalscore += partA__align_variousdist( whichmtx, scoringmatrices, NULL, tmpres1, tmpres2, eff1, eff2, eff1s, eff2s, clus1, clus2, alloclen, constraint, &impmatch, cut1[i], cut1[i+1]-1, cut2[i], cut2[i+1]-1, gapmap1, gapmap2, sgap1, sgap2, egap1, egap2, chudanpt, chudanref, chudanres );
|
||||
}
|
||||
else
|
||||
totalscore += partA__align( tmpres1, tmpres2, eff1, eff2, clus1, clus2, alloclen, constraint, &impmatch, cut1[i], cut1[i+1]-1, cut2[i], cut2[i+1]-1, gapmap1, gapmap2, sgap1, sgap2, egap1, egap2, chudanpt, chudanref, chudanres );
|
||||
*totalimpmatch += impmatch;
|
||||
// fprintf( stderr, "*totalimpmatch in Falign_localhom = %f\n", *totalimpmatch );
|
||||
|
||||
|
||||
break;
|
||||
default:
|
||||
fprintf( stderr, "alg = %c\n", alg );
|
||||
ErrorExit( "ERROR IN SOURCE FILE Falign.c" );
|
||||
break;
|
||||
}
|
||||
#ifdef enablemultithread
|
||||
if( chudanres && *chudanres )
|
||||
{
|
||||
// fprintf( stderr, "\n\n## CHUUDAN!!! at Falign_localhom\n" );
|
||||
return( -1.0 );
|
||||
}
|
||||
#endif
|
||||
|
||||
nlen = strlen( tmpres1[0] );
|
||||
if( totallen + nlen > alloclen )
|
||||
{
|
||||
fprintf( stderr, "totallen=%d + nlen=%d > alloclen = %d\n", totallen, nlen, alloclen );
|
||||
ErrorExit( "LENGTH OVER in Falign\n " );
|
||||
}
|
||||
for( j=0; j<clus1; j++ ) strcat( result1[j], tmpres1[j] );
|
||||
for( j=0; j<clus2; j++ ) strcat( result2[j], tmpres2[j] );
|
||||
totallen += nlen;
|
||||
#if 0
|
||||
fprintf( stderr, "%4d\r", totallen );
|
||||
fprintf( stderr, "\n\n" );
|
||||
for( j=0; j<clus1; j++ )
|
||||
{
|
||||
fprintf( stderr, "%s\n", tmpres1[j] );
|
||||
}
|
||||
fprintf( stderr, "-------\n" );
|
||||
for( j=0; j<clus2; j++ )
|
||||
{
|
||||
fprintf( stderr, "%s\n", tmpres2[j] );
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#if KEIKA
|
||||
fprintf( stderr, "DP ... done \n" );
|
||||
#endif
|
||||
|
||||
for( j=0; j<clus1; j++ ) strcpy( seq1[j], result1[j] );
|
||||
for( j=0; j<clus2; j++ ) strcpy( seq2[j], result2[j] );
|
||||
#if 0
|
||||
for( j=0; j<clus1; j++ )
|
||||
{
|
||||
fprintf( stderr, "%s\n", result1[j] );
|
||||
}
|
||||
fprintf( stderr, "- - - - - - - - - - -\n" );
|
||||
for( j=0; j<clus2; j++ )
|
||||
{
|
||||
fprintf( stderr, "%s\n", result2[j] );
|
||||
}
|
||||
#endif
|
||||
return( totalscore );
|
||||
}
|
1052
mafft/src/mafft-7.487-with-extensions/core/Galign11.c
Normal file
1052
mafft/src/mafft-7.487-with-extensions/core/Galign11.c
Normal file
File diff suppressed because it is too large
Load diff
244
mafft/src/mafft-7.487-with-extensions/core/JTT.c
Normal file
244
mafft/src/mafft-7.487-with-extensions/core/JTT.c
Normal file
|
@ -0,0 +1,244 @@
|
|||
#if 0
|
||||
#include "mltaln.h"
|
||||
#endif
|
||||
#define DEFAULTGOP_J -1530
|
||||
#define DEFAULTGEP_J -00
|
||||
#define DEFAULTOFS_J -123 /* +10 -- -50 teido ka ? */
|
||||
#define DEFAULTPAMN 200
|
||||
|
||||
void JTTmtx( double **rsr, double *freq, unsigned char locamino[26], char locgrp[26], int isTM )
|
||||
{
|
||||
int i, j;
|
||||
double r[20][20];
|
||||
// char locamino0[] = "ARNDCQEGHILKMFPSTWYVBZX.-U";
|
||||
char locamino0[] = "ARNDCQEGHILKMFPSTWYVBZX.-J";
|
||||
char locgrp0[] =
|
||||
{
|
||||
0, 3, 2, 2, 5, 2, 2, 0, 3, 1, 1, 3, 1, 4, 0, 0, 0, 4, 4, 1, 2, 2,
|
||||
6, 6, 6, 1,
|
||||
};
|
||||
|
||||
double freq0[20] =
|
||||
{
|
||||
0.077,
|
||||
0.051,
|
||||
0.043,
|
||||
0.052,
|
||||
0.020,
|
||||
0.041,
|
||||
0.062,
|
||||
0.074,
|
||||
0.023,
|
||||
0.052,
|
||||
0.091,
|
||||
0.059,
|
||||
0.024,
|
||||
0.040,
|
||||
0.051,
|
||||
0.069,
|
||||
0.059,
|
||||
0.014,
|
||||
0.032,
|
||||
0.066,
|
||||
};
|
||||
double freq0_TM[20] =
|
||||
{
|
||||
0.1051,
|
||||
0.0157,
|
||||
0.0185,
|
||||
0.0089,
|
||||
0.0219,
|
||||
0.0141,
|
||||
0.0097,
|
||||
0.0758,
|
||||
0.0168,
|
||||
0.1188,
|
||||
0.1635,
|
||||
0.0112,
|
||||
0.0333,
|
||||
0.0777,
|
||||
0.0260,
|
||||
0.0568,
|
||||
0.0523,
|
||||
0.0223,
|
||||
0.0324,
|
||||
0.1195,
|
||||
};
|
||||
|
||||
/* Lower triangular is JTT's Accepted point mutations */
|
||||
r[ 1][ 0]= 247;
|
||||
|
||||
r[ 2][ 0]= 216; r[ 2][ 1]= 116;
|
||||
|
||||
r[ 3][ 0]= 386; r[ 3][ 1]= 48; r[ 3][ 2]= 1433;
|
||||
|
||||
r[ 4][ 0]= 106; r[ 4][ 1]= 125; r[ 4][ 2]= 32; r[ 4][ 3]= 13;
|
||||
|
||||
r[ 5][ 0]= 208; r[ 5][ 1]= 750; r[ 5][ 2]= 159; r[ 5][ 3]= 130;
|
||||
r[ 5][ 4]= 9;
|
||||
|
||||
r[ 6][ 0]= 600; r[ 6][ 1]= 119; r[ 6][ 2]= 180; r[ 6][ 3]= 2914;
|
||||
r[ 6][ 4]= 8; r[ 6][ 5]= 1027;
|
||||
|
||||
r[ 7][ 0]= 1183; r[ 7][ 1]= 614; r[ 7][ 2]= 291; r[ 7][ 3]= 577;
|
||||
r[ 7][ 4]= 98; r[ 7][ 5]= 84; r[ 7][ 6]= 610;
|
||||
|
||||
r[ 8][ 0]= 46; r[ 8][ 1]= 446; r[ 8][ 2]= 466; r[ 8][ 3]= 144;
|
||||
r[ 8][ 4]= 40; r[ 8][ 5]= 635; r[ 8][ 6]= 41; r[ 8][ 7]= 41;
|
||||
|
||||
r[ 9][ 0]= 173; r[ 9][ 1]= 76; r[ 9][ 2]= 130; r[ 9][ 3]= 37;
|
||||
r[ 9][ 4]= 19; r[ 9][ 5]= 20; r[ 9][ 6]= 43; r[ 9][ 7]= 25;
|
||||
r[ 9][ 8]= 26;
|
||||
|
||||
r[10][ 0]= 257; r[10][ 1]= 205; r[10][ 2]= 63; r[10][ 3]= 34;
|
||||
r[10][ 4]= 36; r[10][ 5]= 314; r[10][ 6]= 65; r[10][ 7]= 56;
|
||||
r[10][ 8]= 134; r[10][ 9]= 1324;
|
||||
|
||||
r[11][ 0]= 200; r[11][ 1]= 2348; r[11][ 2]= 758; r[11][ 3]= 102;
|
||||
r[11][ 4]= 7; r[11][ 5]= 858; r[11][ 6]= 754; r[11][ 7]= 142;
|
||||
r[11][ 8]= 85; r[11][ 9]= 75; r[11][10]= 94;
|
||||
|
||||
r[12][ 0]= 100; r[12][ 1]= 61; r[12][ 2]= 39; r[12][ 3]= 27;
|
||||
r[12][ 4]= 23; r[12][ 5]= 52; r[12][ 6]= 30; r[12][ 7]= 27;
|
||||
r[12][ 8]= 21; r[12][ 9]= 704; r[12][10]= 974; r[12][11]= 103;
|
||||
|
||||
r[13][ 0]= 51; r[13][ 1]= 16; r[13][ 2]= 15; r[13][ 3]= 8;
|
||||
r[13][ 4]= 66; r[13][ 5]= 9; r[13][ 6]= 13; r[13][ 7]= 18;
|
||||
r[13][ 8]= 50; r[13][ 9]= 196; r[13][10]= 1093; r[13][11]= 7;
|
||||
r[13][12]= 49;
|
||||
|
||||
r[14][ 0]= 901; r[14][ 1]= 217; r[14][ 2]= 31; r[14][ 3]= 39;
|
||||
r[14][ 4]= 15; r[14][ 5]= 395; r[14][ 6]= 71; r[14][ 7]= 93;
|
||||
r[14][ 8]= 157; r[14][ 9]= 31; r[14][10]= 578; r[14][11]= 77;
|
||||
r[14][12]= 23; r[14][13]= 36;
|
||||
|
||||
r[15][ 0]= 2413; r[15][ 1]= 413; r[15][ 2]= 1738; r[15][ 3]= 244;
|
||||
r[15][ 4]= 353; r[15][ 5]= 182; r[15][ 6]= 156; r[15][ 7]= 1131;
|
||||
r[15][ 8]= 138; r[15][ 9]= 172; r[15][10]= 436; r[15][11]= 228;
|
||||
r[15][12]= 54; r[15][13]= 309; r[15][14]= 1138;
|
||||
|
||||
r[16][ 0]= 2440; r[16][ 1]= 230; r[16][ 2]= 693; r[16][ 3]= 151;
|
||||
r[16][ 4]= 66; r[16][ 5]= 149; r[16][ 6]= 142; r[16][ 7]= 164;
|
||||
r[16][ 8]= 76; r[16][ 9]= 930; r[16][10]= 172; r[16][11]= 398;
|
||||
r[16][12]= 343; r[16][13]= 39; r[16][14]= 412; r[16][15]= 2258;
|
||||
|
||||
r[17][ 0]= 11; r[17][ 1]= 109; r[17][ 2]= 2; r[17][ 3]= 5;
|
||||
r[17][ 4]= 38; r[17][ 5]= 12; r[17][ 6]= 12; r[17][ 7]= 69;
|
||||
r[17][ 8]= 5; r[17][ 9]= 12; r[17][10]= 82; r[17][11]= 9;
|
||||
r[17][12]= 8; r[17][13]= 37; r[17][14]= 6; r[17][15]= 36;
|
||||
r[17][16]= 8;
|
||||
|
||||
r[18][ 0]= 41; r[18][ 1]= 46; r[18][ 2]= 114; r[18][ 3]= 89;
|
||||
r[18][ 4]= 164; r[18][ 5]= 40; r[18][ 6]= 15; r[18][ 7]= 15;
|
||||
r[18][ 8]= 514; r[18][ 9]= 61; r[18][10]= 84; r[18][11]= 20;
|
||||
r[18][12]= 17; r[18][13]= 850; r[18][14]= 22; r[18][15]= 164;
|
||||
r[18][16]= 45; r[18][17]= 41;
|
||||
|
||||
r[19][ 0]= 1766; r[19][ 1]= 69; r[19][ 2]= 55; r[19][ 3]= 127;
|
||||
r[19][ 4]= 99; r[19][ 5]= 58; r[19][ 6]= 226; r[19][ 7]= 276;
|
||||
r[19][ 8]= 22; r[19][ 9]= 3938; r[19][10]= 1261; r[19][11]= 58;
|
||||
r[19][12]= 559; r[19][13]= 189; r[19][14]= 84; r[19][15]= 219;
|
||||
r[19][16]= 526; r[19][17]= 27; r[19][18]= 42;
|
||||
|
||||
|
||||
/* Upper triangular is JTT's Accepted point mutations for transmembrane */
|
||||
r[ 0][ 1]= 21; r[ 0][ 2]= 2; r[ 0][ 3]= 7; r[ 0][ 4]= 13;
|
||||
r[ 0][ 5]= 4; r[ 0][ 6]= 6; r[ 0][ 7]= 160; r[ 0][ 8]= 6;
|
||||
r[ 0][ 9]= 44; r[ 0][10]= 43; r[ 0][11]= 5; r[ 0][12]= 10;
|
||||
r[ 0][13]= 21; r[ 0][14]= 34; r[ 0][15]= 198; r[ 0][16]= 202;
|
||||
r[ 0][17]= 0; r[ 0][18]= 1; r[ 0][19]= 292;
|
||||
|
||||
r[ 1][ 2]= 0; r[ 1][ 3]= 1; r[ 1][ 4]= 2; r[ 1][ 5]= 21;
|
||||
r[ 1][ 6]= 3; r[ 1][ 7]= 22; r[ 1][ 8]= 21; r[ 1][ 9]= 4;
|
||||
r[ 1][10]= 8; r[ 1][11]= 53; r[ 1][12]= 19; r[ 1][13]= 0;
|
||||
r[ 1][14]= 1; r[ 1][15]= 5; r[ 1][16]= 5; r[ 1][17]= 28;
|
||||
r[ 1][18]= 0; r[ 1][19]= 0;
|
||||
|
||||
r[ 2][ 3]= 14; r[ 2][ 4]= 1; r[ 2][ 5]= 7; r[ 2][ 6]= 0;
|
||||
r[ 2][ 7]= 0; r[ 2][ 8]= 8; r[ 2][ 9]= 4; r[ 2][10]= 5;
|
||||
r[ 2][11]= 11; r[ 2][12]= 3; r[ 2][13]= 1; r[ 2][14]= 2;
|
||||
r[ 2][15]= 32; r[ 2][16]= 19; r[ 2][17]= 1; r[ 2][18]= 1;
|
||||
r[ 2][19]= 2;
|
||||
|
||||
r[ 3][ 4]= 0; r[ 3][ 5]= 0; r[ 3][ 6]= 12; r[ 3][ 7]= 15;
|
||||
r[ 3][ 8]= 4; r[ 3][ 9]= 1; r[ 3][10]= 0; r[ 3][11]= 2;
|
||||
r[ 3][12]= 1; r[ 3][13]= 0; r[ 3][14]= 1; r[ 3][15]= 0;
|
||||
r[ 3][16]= 6; r[ 3][17]= 0; r[ 3][18]= 1; r[ 3][19]= 4;
|
||||
|
||||
r[ 4][ 5]= 0; r[ 4][ 6]= 0; r[ 4][ 7]= 13; r[ 4][ 8]= 2;
|
||||
r[ 4][ 9]= 4; r[ 4][10]= 11; r[ 4][11]= 0; r[ 4][12]= 1;
|
||||
r[ 4][13]= 34; r[ 4][14]= 0; r[ 4][15]= 48; r[ 4][16]= 13;
|
||||
r[ 4][17]= 8; r[ 4][18]= 23; r[ 4][19]= 47;
|
||||
|
||||
r[ 5][ 6]= 16; r[ 5][ 7]= 1; r[ 5][ 8]= 26; r[ 5][ 9]= 1;
|
||||
r[ 5][10]= 16; r[ 5][11]= 6; r[ 5][12]= 3; r[ 5][13]= 0;
|
||||
r[ 5][14]= 5; r[ 5][15]= 7; r[ 5][16]= 2; r[ 5][17]= 0;
|
||||
r[ 5][18]= 0; r[ 5][19]= 0;
|
||||
|
||||
r[ 6][ 7]= 21; r[ 6][ 8]= 0; r[ 6][ 9]= 0; r[ 6][10]= 0;
|
||||
r[ 6][11]= 0; r[ 6][12]= 0; r[ 6][13]= 0; r[ 6][14]= 0;
|
||||
r[ 6][15]= 4; r[ 6][16]= 2; r[ 6][17]= 0; r[ 6][18]= 0;
|
||||
r[ 6][19]= 7;
|
||||
|
||||
r[ 7][ 8]= 1; r[ 7][ 9]= 10; r[ 7][10]= 0; r[ 7][11]= 0;
|
||||
r[ 7][12]= 3; r[ 7][13]= 4; r[ 7][14]= 7; r[ 7][15]= 64;
|
||||
r[ 7][16]= 12; r[ 7][17]= 5; r[ 7][18]= 0; r[ 7][19]= 53;
|
||||
|
||||
r[ 8][ 9]= 3; r[ 8][10]= 2; r[ 8][11]= 0; r[ 8][12]= 1;
|
||||
r[ 8][13]= 0; r[ 8][14]= 0; r[ 8][15]= 0; r[ 8][16]= 4;
|
||||
r[ 8][17]= 0; r[ 8][18]= 29; r[ 8][19]= 2;
|
||||
|
||||
r[ 9][10]= 273; r[ 9][11]= 0; r[ 9][12]= 161; r[ 9][13]= 66;
|
||||
r[ 9][14]= 4; r[ 9][15]= 22; r[ 9][16]= 150; r[ 9][17]= 1;
|
||||
r[ 9][18]= 4; r[ 9][19]= 883;
|
||||
|
||||
r[10][11]= 1; r[10][12]= 153; r[10][13]= 251; r[10][14]= 37;
|
||||
r[10][15]= 43; r[10][16]= 26; r[10][17]= 20; r[10][18]= 6;
|
||||
r[10][19]= 255;
|
||||
|
||||
r[11][12]= 4; r[11][13]= 0; r[11][14]= 0; r[11][15]= 1;
|
||||
r[11][16]= 2; r[11][17]= 0; r[11][18]= 5; r[11][19]= 1;
|
||||
|
||||
r[12][13]= 8; r[12][14]= 0; r[12][15]= 1; r[12][16]= 32;
|
||||
r[12][17]= 1; r[12][18]= 5; r[12][19]= 89;
|
||||
|
||||
r[13][14]= 0; r[13][15]= 32; r[13][16]= 9; r[13][17]= 2;
|
||||
r[13][18]= 54; r[13][19]= 37;
|
||||
|
||||
r[14][15]= 9; r[14][16]= 10; r[14][17]= 0; r[14][18]= 1;
|
||||
r[14][19]= 1;
|
||||
|
||||
r[15][16]= 134; r[15][17]= 1; r[15][18]= 22; r[15][19]= 13;
|
||||
|
||||
r[16][17]= 1; r[16][18]= 3; r[16][19]= 48;
|
||||
|
||||
r[17][18]= 2; r[17][19]= 18;
|
||||
|
||||
r[18][19]= 2;
|
||||
|
||||
|
||||
|
||||
for (i = 0; i < 20; i++) r[i][i] = 0.0;
|
||||
if( isTM )
|
||||
{
|
||||
for (i = 1; i < 20; i++) for (j = 0; j < i; j++)
|
||||
{
|
||||
r[j][i] /= 400.0 * freq0_TM[i] * freq0_TM[j];
|
||||
r[i][j] = r[j][i];
|
||||
}
|
||||
for( i=0; i<20; i++ ) freq[i] = freq0_TM[i];
|
||||
}
|
||||
else
|
||||
{
|
||||
for (i = 1; i < 20; i++) for (j = 0; j < i; j++)
|
||||
{
|
||||
r[i][j] /= 400.0 * freq0[i] * freq0[j];
|
||||
r[j][i] = r[i][j];
|
||||
}
|
||||
for( i=0; i<20; i++ ) freq[i] = freq0[i];
|
||||
}
|
||||
|
||||
for( i=0; i<26; i++ ) locamino[i] = locamino0[i];
|
||||
for( i=0; i<26; i++ ) locgrp[(int)locamino[i]] = locgrp0[i];
|
||||
for( i=0; i<20; i++ ) for( j=0; j<20; j++ ) rsr[i][j] = r[i][j];
|
||||
}
|
1153
mafft/src/mafft-7.487-with-extensions/core/Lalign11.c
Normal file
1153
mafft/src/mafft-7.487-with-extensions/core/Lalign11.c
Normal file
File diff suppressed because it is too large
Load diff
2563
mafft/src/mafft-7.487-with-extensions/core/Lalignmm.c
Normal file
2563
mafft/src/mafft-7.487-with-extensions/core/Lalignmm.c
Normal file
File diff suppressed because it is too large
Load diff
665
mafft/src/mafft-7.487-with-extensions/core/MSalign11.c
Normal file
665
mafft/src/mafft-7.487-with-extensions/core/MSalign11.c
Normal file
|
@ -0,0 +1,665 @@
|
|||
#include "mltaln.h"
|
||||
#include "dp.h"
|
||||
|
||||
#define DEBUG 0
|
||||
#define XXXXXXX 0
|
||||
#define USE_PENALTY_EX 0
|
||||
|
||||
static void extendmseq( char **mseq1, char **mseq2, char **seq1, char **seq2, int i, int j, int prevhiti, int prevhitj )
|
||||
{
|
||||
// char gap[] = "-";
|
||||
char *gap;
|
||||
gap = newgapstr;
|
||||
int l;
|
||||
|
||||
fprintf( stderr, "i=%d, prevhiti=%d\n", i, prevhiti );
|
||||
fprintf( stderr, "j=%d, prevhitj=%d\n", j, prevhitj );
|
||||
l = prevhiti - i - 1;
|
||||
fprintf( stderr, "l=%d\n", l );
|
||||
while( l>0 )
|
||||
{
|
||||
*--mseq1[0] = seq1[0][i+l--];
|
||||
*--mseq2[0] = *gap;
|
||||
}
|
||||
l= prevhitj - j - 1;
|
||||
fprintf( stderr, "l=%d\n", l );
|
||||
while( l>0 )
|
||||
{
|
||||
*--mseq1[0] = *gap;
|
||||
*--mseq2[0] = seq2[0][j+l--];
|
||||
}
|
||||
if( i < 0 || j < 0 ) return;
|
||||
*--mseq1[0] = seq1[0][i];
|
||||
*--mseq2[0] = seq2[0][j];
|
||||
fprintf( stderr, "added %c to mseq1, mseq1 = %s \n", seq1[0][i], mseq1[0] );
|
||||
fprintf( stderr, "added %c to mseq2, mseq2 = %s \n", seq2[0][j], mseq2[0] );
|
||||
}
|
||||
|
||||
static void match_calc( double *match, char **s1, char **s2, int i1, int lgth2 )
|
||||
{
|
||||
char tmpc = s1[0][i1];
|
||||
char *seq2 = s2[0];
|
||||
|
||||
while( lgth2-- )
|
||||
*match++ = amino_dis[(int)tmpc][(int)*seq2++];
|
||||
}
|
||||
|
||||
static double Atracking( double *lasthorizontalw, double *lastverticalw,
|
||||
char **seq1, char **seq2,
|
||||
char **mseq1, char **mseq2,
|
||||
double **cpmx1, double **cpmx2,
|
||||
int **ijp )
|
||||
{
|
||||
int i, j, l, iin, jin, ifi, jfi, lgth1, lgth2, k, limk;
|
||||
// char gap[] = "-";
|
||||
char *gap;
|
||||
gap = newgapstr;
|
||||
lgth1 = strlen( seq1[0] );
|
||||
lgth2 = strlen( seq2[0] );
|
||||
|
||||
|
||||
#if 0
|
||||
for( i=0; i<lgth1; i++ )
|
||||
{
|
||||
fprintf( stderr, "lastverticalw[%d] = %f\n", i, lastverticalw[i] );
|
||||
}
|
||||
#endif
|
||||
|
||||
for( i=0; i<lgth1+1; i++ )
|
||||
{
|
||||
ijp[i][0] = i + 1;
|
||||
}
|
||||
for( j=0; j<lgth2+1; j++ )
|
||||
{
|
||||
ijp[0][j] = -( j + 1 );
|
||||
}
|
||||
|
||||
|
||||
mseq1[0] += lgth1+lgth2;
|
||||
*mseq1[0] = 0;
|
||||
mseq2[0] += lgth1+lgth2;
|
||||
*mseq2[0] = 0;
|
||||
iin = lgth1; jin = lgth2;
|
||||
limk = lgth1+lgth2 + 1;
|
||||
for( k=0; k<limk; k++ )
|
||||
{
|
||||
if( ijp[iin][jin] < 0 )
|
||||
{
|
||||
ifi = iin-1; jfi = jin+ijp[iin][jin];
|
||||
}
|
||||
else if( ijp[iin][jin] > 0 )
|
||||
{
|
||||
ifi = iin-ijp[iin][jin]; jfi = jin-1;
|
||||
}
|
||||
else
|
||||
{
|
||||
ifi = iin-1; jfi = jin-1;
|
||||
}
|
||||
l = iin - ifi;
|
||||
while( --l )
|
||||
{
|
||||
*--mseq1[0] = seq1[0][ifi+l];
|
||||
*--mseq2[0] = *gap;
|
||||
k++;
|
||||
}
|
||||
l= jin - jfi;
|
||||
while( --l )
|
||||
{
|
||||
*--mseq1[0] = *gap;
|
||||
*--mseq2[0] = seq2[0][jfi+l];
|
||||
k++;
|
||||
}
|
||||
if( iin <= 0 || jin <= 0 ) break;
|
||||
*--mseq1[0] = seq1[0][ifi];
|
||||
*--mseq2[0] = seq2[0][jfi];
|
||||
k++;
|
||||
iin = ifi; jin = jfi;
|
||||
}
|
||||
return( 0.0 );
|
||||
}
|
||||
|
||||
void backdp( double **WMMTX, double wmmax, double *maxinw, double *maxinh, int lgth1, int lgth2, int alloclen, double *w1, double *w2, double *initverticalw, double *m, int *mp, int iin, int jin, char **seq1, char **seq2, char **mseq1, char **mseq2 )
|
||||
{
|
||||
register int i, j;
|
||||
int prevhiti, prevhitj;
|
||||
// int lasti, lastj;
|
||||
double g;
|
||||
double fpenalty = (double)penalty;
|
||||
#if USE_PENALTY_EX
|
||||
double fpenalty_ex = (double)penalty_ex;
|
||||
#endif
|
||||
double *currentw, *previousw, *wtmp;
|
||||
double mi;
|
||||
int mpi;
|
||||
int *mpjpt;
|
||||
double *mjpt, *prept, *curpt;
|
||||
double wm = 0.0;
|
||||
double forwwm;
|
||||
|
||||
currentw = w1;
|
||||
previousw = w2;
|
||||
|
||||
match_calc( initverticalw, seq2, seq1, lgth2-1, lgth1 );
|
||||
match_calc( currentw, seq1, seq2, lgth1-1, lgth2 );
|
||||
|
||||
|
||||
prevhiti = iin;
|
||||
prevhitj = jin;
|
||||
fprintf( stderr, "prevhiti = %d, lgth1 = %d\n", prevhiti, lgth1 );
|
||||
fprintf( stderr, "prevhitj = %d, lgth2 = %d\n", prevhitj, lgth2 );
|
||||
extendmseq( mseq1, mseq2, seq1, seq2, prevhiti, prevhitj, lgth1, lgth2 );
|
||||
|
||||
for( i=0; i<lgth1-1; i++ )
|
||||
{
|
||||
initverticalw[i] += fpenalty;
|
||||
WMMTX[i][lgth2-1] += fpenalty;
|
||||
}
|
||||
for( j=0; j<lgth2-1; j++ )
|
||||
{
|
||||
currentw[j] += fpenalty;
|
||||
WMMTX[lgth1-1][j] += fpenalty;
|
||||
}
|
||||
|
||||
|
||||
#if 0
|
||||
fprintf( stderr, "initverticalw = \n" );
|
||||
for( i=0; i<lgth1; i++ )
|
||||
fprintf( stderr, "% 8.2f", initverticalw[i] );
|
||||
fprintf( stderr, "\n" );
|
||||
fprintf( stderr, "currentw = \n" );
|
||||
for( i=0; i<lgth2; i++ )
|
||||
fprintf( stderr, "% 8.2f", currentw[i] );
|
||||
fprintf( stderr, "\n" );
|
||||
#endif
|
||||
|
||||
for( j=lgth2-1; j>0; --j )
|
||||
{
|
||||
m[j-1] = currentw[j];
|
||||
mp[j] = 0; // iranai
|
||||
}
|
||||
|
||||
for( j=0; j<lgth2; j++ ) m[j] = 0.0;
|
||||
//m[lgth2-1] ga, irunoka iranainoka irahai.
|
||||
|
||||
for( i=lgth1-2; i>-1; i-- )
|
||||
{
|
||||
wtmp = previousw;
|
||||
previousw = currentw;
|
||||
currentw = wtmp;
|
||||
|
||||
previousw[lgth2-1] = initverticalw[i+1];
|
||||
|
||||
match_calc( currentw, seq1, seq2, i, lgth2 );
|
||||
|
||||
#if 0
|
||||
fprintf( stderr, "i=%d, currentw = \n", i );
|
||||
for( j=0; j<lgth2; j++ ) fprintf( stderr, "% 8.2f", currentw[j] );
|
||||
fprintf( stderr, "\n" );
|
||||
#endif
|
||||
|
||||
currentw[lgth2-1] = initverticalw[i];
|
||||
|
||||
mi = previousw[lgth2-1];
|
||||
mpi = lgth2-1; //iranai
|
||||
|
||||
|
||||
mjpt = m + lgth2 - 2;
|
||||
prept = previousw + lgth2 - 1;
|
||||
curpt = currentw + lgth2 - 2;
|
||||
mpjpt = mp + lgth2 - 2;
|
||||
|
||||
for( j=lgth2-2; j>-1; j-- )
|
||||
{
|
||||
|
||||
// fprintf( stderr, "i,j=%d,%d %c-%c ", i, j, seq1[0][i], seq2[0][j] );
|
||||
wm = *prept;
|
||||
g = mi + fpenalty;
|
||||
#if 0
|
||||
fprintf( stderr, "%5.0f?", g );
|
||||
#endif
|
||||
if( g > wm )
|
||||
{
|
||||
wm = g;
|
||||
}
|
||||
g = *prept;
|
||||
if( g >= mi )
|
||||
{
|
||||
mi = g;
|
||||
mpi = j+1; //iranai
|
||||
}
|
||||
#if USE_PENALTY_EX
|
||||
mi += fpenalty_ex;
|
||||
#endif
|
||||
|
||||
g = *mjpt + fpenalty;
|
||||
#if 0
|
||||
fprintf( stderr, "%5.0f?", g );
|
||||
#endif
|
||||
if( g > wm )
|
||||
{
|
||||
wm = g;
|
||||
}
|
||||
g = *prept;
|
||||
if( g >= *mjpt )
|
||||
{
|
||||
*mjpt = g;
|
||||
*mpjpt = i-1; //iranai
|
||||
}
|
||||
#if USE_PENALTY_EX
|
||||
m[j] += fpenalty_ex;
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
fprintf( stderr, "*curpt = %5.0f \n", *curpt );
|
||||
#endif
|
||||
|
||||
// forwwm = wm + MIN( maxinw[i], maxinh[j] );
|
||||
forwwm = wm + MIN( maxinw[i], maxinh[j] );
|
||||
WMMTX[i][j] = forwwm;
|
||||
if( forwwm == wmmax && i<prevhiti && j<prevhitj )
|
||||
{
|
||||
fprintf( stderr, "hit!\n" );
|
||||
extendmseq( mseq1, mseq2, seq1, seq2, i, j, prevhiti, prevhitj );
|
||||
if( forwwm == wmmax )
|
||||
{
|
||||
*--mseq1[0] = 'u';
|
||||
*--mseq2[0] = 'u';
|
||||
}
|
||||
prevhiti = i;
|
||||
prevhitj = j;
|
||||
}
|
||||
*curpt += wm;
|
||||
|
||||
mjpt--;
|
||||
prept--;
|
||||
mpjpt--;
|
||||
curpt--;
|
||||
}
|
||||
}
|
||||
extendmseq( mseq1, mseq2, seq1, seq2, -1, -1, prevhiti, prevhitj );
|
||||
}
|
||||
|
||||
|
||||
double MSalign11( char **seq1, char **seq2, int alloclen )
|
||||
/* score no keisan no sai motokaraaru gap no atukai ni mondai ga aru */
|
||||
{
|
||||
// int k;
|
||||
register int i, j;
|
||||
int lasti, lastj;
|
||||
int iin = 0, jin = 0; // by Mathog, a guess
|
||||
int lgth1, lgth2;
|
||||
int resultlen;
|
||||
double wm = 0.0; /* int ?????? */
|
||||
double g;
|
||||
double *currentw, *previousw;
|
||||
double fpenalty = (double)penalty;
|
||||
#if USE_PENALTY_EX
|
||||
double fpenalty_ex = (double)penalty_ex;
|
||||
#endif
|
||||
double *maxinw = NULL, *maxinwpt = NULL; // by D.Mathog, guess
|
||||
double *maxinh = NULL; // by D.Mathog, guess
|
||||
#if 1
|
||||
double wmmax;
|
||||
double *wtmp;
|
||||
int *ijppt;
|
||||
double *mjpt, *prept, *curpt;
|
||||
int *mpjpt;
|
||||
#endif
|
||||
static double mi, *m;
|
||||
static int **ijp;
|
||||
static int mpi, *mp;
|
||||
static double *w1, *w2;
|
||||
static double *match;
|
||||
static double *initverticalw; /* kufuu sureba iranai */
|
||||
static double *lastverticalw; /* kufuu sureba iranai */
|
||||
static char **mseq1;
|
||||
static char **mseq2;
|
||||
static char **mseq;
|
||||
static double **cpmx1;
|
||||
static double **cpmx2;
|
||||
static int **intwork;
|
||||
static double **WMMTX;
|
||||
static double **doublework;
|
||||
static int orlgth1 = 0, orlgth2 = 0;
|
||||
|
||||
if( orlgth1 == 0 )
|
||||
{
|
||||
mseq1 = AllocateCharMtx( njob, 0 );
|
||||
mseq2 = AllocateCharMtx( njob, 0 );
|
||||
}
|
||||
|
||||
|
||||
lgth1 = strlen( seq1[0] );
|
||||
lgth2 = strlen( seq2[0] );
|
||||
|
||||
if( lgth1 > orlgth1 || lgth2 > orlgth2 )
|
||||
{
|
||||
int ll1, ll2;
|
||||
|
||||
if( orlgth1 > 0 && orlgth2 > 0 )
|
||||
{
|
||||
FreeFloatVec( w1 );
|
||||
FreeFloatVec( w2 );
|
||||
FreeFloatVec( match );
|
||||
FreeFloatVec( initverticalw );
|
||||
FreeFloatVec( lastverticalw );
|
||||
FreeFloatVec( maxinw );
|
||||
FreeFloatVec( maxinh );
|
||||
|
||||
FreeFloatVec( m );
|
||||
FreeIntVec( mp );
|
||||
|
||||
FreeCharMtx( mseq );
|
||||
|
||||
|
||||
FreeFloatMtx( cpmx1 );
|
||||
FreeFloatMtx( cpmx2 );
|
||||
|
||||
FreeFloatMtx( doublework );
|
||||
FreeIntMtx( intwork );
|
||||
}
|
||||
|
||||
ll1 = MAX( (int)(1.3*lgth1), orlgth1 ) + 100;
|
||||
ll2 = MAX( (int)(1.3*lgth2), orlgth2 ) + 100;
|
||||
|
||||
#if DEBUG
|
||||
fprintf( stderr, "\ntrying to allocate (%d+%d)xn matrices ... ", ll1, ll2 );
|
||||
#endif
|
||||
|
||||
w1 = AllocateFloatVec( ll2+2 );
|
||||
w2 = AllocateFloatVec( ll2+2 );
|
||||
match = AllocateFloatVec( ll2+2 );
|
||||
|
||||
initverticalw = AllocateFloatVec( ll1+2 );
|
||||
lastverticalw = AllocateFloatVec( ll1+2 );
|
||||
maxinw = AllocateFloatVec( ll1+2 );
|
||||
|
||||
|
||||
m = AllocateFloatVec( ll2+2 );
|
||||
mp = AllocateIntVec( ll2+2 );
|
||||
maxinh = AllocateFloatVec( ll2+2 );
|
||||
|
||||
mseq = AllocateCharMtx( njob, ll1+ll2 );
|
||||
|
||||
cpmx1 = AllocateFloatMtx( nalphabets, ll1+2 );
|
||||
cpmx2 = AllocateFloatMtx( nalphabets, ll2+2 );
|
||||
|
||||
doublework = AllocateFloatMtx( nalphabets, MAX( ll1, ll2 )+2 );
|
||||
intwork = AllocateIntMtx( nalphabets, MAX( ll1, ll2 )+2 );
|
||||
|
||||
#if DEBUG
|
||||
fprintf( stderr, "succeeded\n" );
|
||||
#endif
|
||||
|
||||
orlgth1 = ll1 - 100;
|
||||
orlgth2 = ll2 - 100;
|
||||
}
|
||||
|
||||
|
||||
mseq1[0] = mseq[0];
|
||||
mseq2[0] = mseq[1];
|
||||
|
||||
|
||||
if( orlgth1 > commonAlloc1 || orlgth2 > commonAlloc2 )
|
||||
{
|
||||
int ll1, ll2;
|
||||
|
||||
if( commonAlloc1 && commonAlloc2 )
|
||||
{
|
||||
FreeIntMtx( commonIP );
|
||||
FreeFloatMtx( WMMTX );
|
||||
}
|
||||
|
||||
ll1 = MAX( orlgth1, commonAlloc1 );
|
||||
ll2 = MAX( orlgth2, commonAlloc2 );
|
||||
|
||||
#if DEBUG
|
||||
fprintf( stderr, "\n\ntrying to allocate %dx%d matrices ... ", ll1+1, ll2+1 );
|
||||
#endif
|
||||
|
||||
commonIP = AllocateIntMtx( ll1+10, ll2+10 );
|
||||
WMMTX = AllocateFloatMtx( ll1+10, ll2+10 );
|
||||
|
||||
#if DEBUG
|
||||
fprintf( stderr, "succeeded\n\n" );
|
||||
#endif
|
||||
|
||||
commonAlloc1 = ll1;
|
||||
commonAlloc2 = ll2;
|
||||
}
|
||||
ijp = commonIP;
|
||||
|
||||
|
||||
#if 0
|
||||
for( i=0; i<lgth1; i++ )
|
||||
fprintf( stderr, "ogcp1[%d]=%f\n", i, ogcp1[i] );
|
||||
#endif
|
||||
|
||||
currentw = w1;
|
||||
previousw = w2;
|
||||
|
||||
match_calc( initverticalw, seq2, seq1, 0, lgth1 );
|
||||
|
||||
|
||||
match_calc( currentw, seq1, seq2, 0, lgth2 );
|
||||
|
||||
WMMTX[0][0] = initverticalw[0];
|
||||
|
||||
maxinh[0] = initverticalw[0];
|
||||
for( i=1; i<lgth1+1; i++ )
|
||||
{
|
||||
initverticalw[i] += fpenalty;
|
||||
WMMTX[i][0] = initverticalw[i];
|
||||
if( maxinh[0] < initverticalw[i] ) maxinh[0] = initverticalw[i];
|
||||
}
|
||||
maxinw[0] = currentw[0];
|
||||
for( j=1; j<lgth2+1; j++ )
|
||||
{
|
||||
currentw[j] += fpenalty;
|
||||
WMMTX[0][j] = currentw[j];
|
||||
if( maxinw[0] < currentw[j] ) maxinw[0] = currentw[j];
|
||||
}
|
||||
|
||||
for( j=1; j<lgth2+1; ++j )
|
||||
{
|
||||
m[j] = currentw[j-1]; mp[j] = 0;
|
||||
}
|
||||
|
||||
lastverticalw[0] = currentw[lgth2-1];
|
||||
|
||||
lasti = lgth1+1;
|
||||
|
||||
for( i=1; i<lasti; i++ )
|
||||
{
|
||||
wtmp = previousw;
|
||||
previousw = currentw;
|
||||
currentw = wtmp;
|
||||
|
||||
previousw[0] = initverticalw[i-1];
|
||||
|
||||
match_calc( currentw, seq1, seq2, i, lgth2 );
|
||||
|
||||
currentw[0] = initverticalw[i];
|
||||
|
||||
mi = previousw[0]; mpi = 0;
|
||||
|
||||
maxinwpt = maxinw + i;
|
||||
*maxinwpt = currentw[0];
|
||||
|
||||
fprintf( stderr, "currentw[0] = %f, *maxinwpt = %f\n", currentw[0], maxinw[i] );
|
||||
|
||||
ijppt = ijp[i] + 1;
|
||||
mjpt = m + 1;
|
||||
prept = previousw;
|
||||
curpt = currentw + 1;
|
||||
mpjpt = mp + 1;
|
||||
lastj = lgth2+1;
|
||||
|
||||
for( j=1; j<lastj; j++ )
|
||||
{
|
||||
wm = *prept;
|
||||
*ijppt = 0;
|
||||
|
||||
#if 0
|
||||
fprintf( stderr, "%5.0f->", wm );
|
||||
#endif
|
||||
g = mi + fpenalty;
|
||||
#if 0
|
||||
fprintf( stderr, "%5.0f?", g );
|
||||
#endif
|
||||
if( g > wm )
|
||||
{
|
||||
wm = g;
|
||||
*ijppt = -( j - mpi );
|
||||
}
|
||||
g = *prept;
|
||||
if( g >= mi )
|
||||
{
|
||||
mi = g;
|
||||
mpi = j-1;
|
||||
}
|
||||
#if USE_PENALTY_EX
|
||||
mi += fpenalty_ex;
|
||||
#endif
|
||||
|
||||
g = *mjpt + fpenalty;
|
||||
#if 0
|
||||
fprintf( stderr, "%5.0f?", g );
|
||||
#endif
|
||||
if( g > wm )
|
||||
{
|
||||
wm = g;
|
||||
*ijppt = +( i - *mpjpt );
|
||||
}
|
||||
g = *prept;
|
||||
if( g >= *mjpt )
|
||||
{
|
||||
*mjpt = g;
|
||||
*mpjpt = i-1;
|
||||
}
|
||||
#if USE_PENALTY_EX
|
||||
m[j] += fpenalty_ex;
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
fprintf( stderr, "%5.0f ", wm );
|
||||
#endif
|
||||
*curpt += wm;
|
||||
|
||||
WMMTX[i][j] = *curpt;
|
||||
|
||||
|
||||
if( j<lgth2 && *maxinwpt < *curpt ) *maxinwpt = *curpt;
|
||||
if( j<lgth2 && maxinh[j] < *curpt ) maxinh[j] = *curpt;
|
||||
// fprintf( stderr, "maxintwpt = %f\n", *maxinwpt );
|
||||
|
||||
ijppt++;
|
||||
mjpt++;
|
||||
prept++;
|
||||
mpjpt++;
|
||||
curpt++;
|
||||
}
|
||||
lastverticalw[i] = currentw[lgth2-1];
|
||||
}
|
||||
|
||||
wmmax = -999.9;
|
||||
for( i=0; i<lgth1; i++ )
|
||||
{
|
||||
g = lastverticalw[i];
|
||||
if( g > wmmax )
|
||||
{
|
||||
wmmax = g;
|
||||
iin = i;
|
||||
jin = lgth2-1;
|
||||
}
|
||||
}
|
||||
for( j=0; j<lgth2; j++ )
|
||||
{
|
||||
g = currentw[j];
|
||||
if( g > wmmax )
|
||||
{
|
||||
wmmax = g;
|
||||
iin = lgth1-1;
|
||||
jin = j;
|
||||
}
|
||||
}
|
||||
|
||||
for( i=0; i<lgth1; i++ )
|
||||
fprintf( stderr, "maxinw[%d] = %f\n", i, maxinw[i] );
|
||||
for( j=0; j<lgth2; j++ )
|
||||
fprintf( stderr, "maxinh[%d] = %f\n", j, maxinh[j] );
|
||||
|
||||
fprintf( stderr, "wmmax = %f (%d,%d)\n", wmmax, iin, jin );
|
||||
if( iin == lgth1 - 1 && jin == lgth2 - 1 )
|
||||
;
|
||||
else
|
||||
wmmax += fpenalty;
|
||||
|
||||
fprintf( stderr, "wmmax = %f\n", wmmax );
|
||||
|
||||
#if 0
|
||||
for( i=0; i<lgth1; i++ )
|
||||
{
|
||||
for( j=0; j<lgth2; j++ )
|
||||
{
|
||||
fprintf( stderr, "% 10.2f ", WMMTX[i][j] );
|
||||
}
|
||||
fprintf( stderr, "\n" );
|
||||
}
|
||||
#endif
|
||||
|
||||
mseq1[0] += lgth1+lgth2;
|
||||
*mseq1[0] = 0;
|
||||
mseq2[0] += lgth1+lgth2;
|
||||
*mseq2[0] = 0;
|
||||
|
||||
backdp( WMMTX, wmmax, maxinw, maxinh, lgth1, lgth2, alloclen, w1, w2, initverticalw, m, mp, iin, jin, seq1, seq2, mseq1, mseq2 );
|
||||
|
||||
fprintf( stderr, "\n" );
|
||||
#if 1
|
||||
fprintf( stderr, "\n" );
|
||||
fprintf( stderr, ">MSres\n%s\n", mseq1[0] );
|
||||
fprintf( stderr, ">MSres\n%s\n", mseq2[0] );
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
for( i=0; i<lgth1; i++ )
|
||||
{
|
||||
for( j=0; j<lgth2; j++ )
|
||||
{
|
||||
fprintf( stderr, "% 10.2f ", WMMTX[i][j] );
|
||||
}
|
||||
fprintf( stderr, "\n" );
|
||||
}
|
||||
#endif
|
||||
|
||||
mseq1[0] = mseq[0];
|
||||
mseq2[0] = mseq[1];
|
||||
mseq1[0] += lgth1+lgth2;
|
||||
*mseq1[0] = 0;
|
||||
mseq2[0] += lgth1+lgth2;
|
||||
*mseq2[0] = 0;
|
||||
|
||||
Atracking( currentw, lastverticalw, seq1, seq2, mseq1, mseq2, cpmx1, cpmx2, ijp );
|
||||
|
||||
|
||||
resultlen = strlen( mseq1[0] );
|
||||
if( alloclen < resultlen || resultlen > N )
|
||||
{
|
||||
fprintf( stderr, "alloclen=%d, resultlen=%d, N=%d\n", alloclen, resultlen, N );
|
||||
ErrorExit( "LENGTH OVER!\n" );
|
||||
}
|
||||
|
||||
|
||||
strcpy( seq1[0], mseq1[0] );
|
||||
strcpy( seq2[0], mseq2[0] );
|
||||
#if 1
|
||||
fprintf( stderr, "\n" );
|
||||
fprintf( stderr, ">\n%s\n", mseq1[0] );
|
||||
fprintf( stderr, ">\n%s\n", mseq2[0] );
|
||||
#endif
|
||||
|
||||
|
||||
return( wm );
|
||||
}
|
||||
|
4198
mafft/src/mafft-7.487-with-extensions/core/MSalignmm.c
Normal file
4198
mafft/src/mafft-7.487-with-extensions/core/MSalignmm.c
Normal file
File diff suppressed because it is too large
Load diff
590
mafft/src/mafft-7.487-with-extensions/core/Makefile
Normal file
590
mafft/src/mafft-7.487-with-extensions/core/Makefile
Normal file
|
@ -0,0 +1,590 @@
|
|||
PREFIX = /usr/local
|
||||
LIBDIR = $(PREFIX)/libexec/mafft
|
||||
BINDIR = $(PREFIX)/bin
|
||||
MANDIR = $(PREFIX)/share/man/man1
|
||||
DESTDIR =
|
||||
|
||||
#MNO_CYGWIN = -mno-cygwin
|
||||
|
||||
ENABLE_MULTITHREAD = -Denablemultithread
|
||||
# Comment out the above line if your compiler
|
||||
# does not support TLS (thread-local strage).
|
||||
|
||||
#ENABLE_ATOMIC = -Denableatomic
|
||||
# Comment out the above line if your compiler
|
||||
# does not support "atomic_int".
|
||||
|
||||
#DASH_CLIENT = dash_client
|
||||
# Uncomment the above line to use protein 3D
|
||||
# structural information. Go language is required.
|
||||
|
||||
CC = gcc
|
||||
#CC = icc
|
||||
CFLAGS = -O3
|
||||
#CFLAGS = -O3 -fPIC
|
||||
# add -fPIC when building .so files
|
||||
|
||||
#CC = icc
|
||||
#CFLAGS = -fast
|
||||
# if you have icc, use this.
|
||||
|
||||
#CFLAGS = -O0 -fPIC -pedantic -Wall -std=c99 -g -pg -DMALLOC_CHECK_=3
|
||||
#CFLAGS = -O0 -fPIC -pedantic -Wall -std=c99 -g -pg -DMALLOC_CHECK_=3 -fprofile-arcs -ftest-coverage
|
||||
#CFLAGS = -O0 -fPIC -pedantic -Wall -std=c99 -g -DMALLOC_CHECK_=3 # for shark, valgrind
|
||||
#CFLAGS = -O0 -fPIC -pedantic -Wall -std=c99 -g -DMALLOC_CHECK_=3 -lprofiler # ?
|
||||
|
||||
|
||||
|
||||
ifdef ENABLE_MULTITHREAD
|
||||
LIBS = -lm -lpthread
|
||||
else
|
||||
LIBS = -lm
|
||||
endif
|
||||
|
||||
ifdef ENABLE_ATOMIC
|
||||
STDF = -std=c11
|
||||
else
|
||||
STDF = -std=c99
|
||||
endif
|
||||
|
||||
MYCFLAGS = $(MNO_CYGWIN) $(ENABLE_MULTITHREAD) $(ENABLE_ATOMIC) $(STDF) $(CFLAGS)
|
||||
|
||||
INSTALL = install
|
||||
|
||||
STRIP = strip
|
||||
#STRIP = true # to disable strip
|
||||
|
||||
PROGS = dvtditr dndfast7 dndblast sextet5 mafft-distance pairlocalalign \
|
||||
multi2hat3s pairash addsingle maffttext2hex hex2maffttext \
|
||||
splittbfast disttbfast tbfast nodepair mafft-profile f2cl mccaskillwrap contrafoldwrap countlen \
|
||||
seq2regtable regtable2seq score getlag dndpre setcore filter replaceu restoreu setdirection makedirectionlist version \
|
||||
$(DASH_CLIENT)
|
||||
SOS = libdisttbfast.so
|
||||
DLLS = libdisttbfast.dll
|
||||
DYLIBS = libdisttbfast.dylib
|
||||
|
||||
PERLPROGS = mafftash_premafft.pl seekquencer_premafft.pl
|
||||
SCRIPTS = mafft mafft-homologs.rb mafft-sparsecore.rb
|
||||
OBJSETDIRECTION = mtxutl.o io.o setdirection.o defs.o mltaln9.o Galign11.o Lalign11.o genalign11.o
|
||||
OBJFILTER = mtxutl.o io.o filter.o defs.o mltaln9.o Galign11.o Lalign11.o genalign11.o
|
||||
OBJREPLACEU = mtxutl.o io.o replaceu.o defs.o mltaln9.o Galign11.o Lalign11.o genalign11.o
|
||||
OBJRESTOREU = mtxutl.o io.o restoreu.o defs.o mltaln9.o Galign11.o Lalign11.o genalign11.o
|
||||
OBJREGTABLE2SEQ = mtxutl.o io.o regtable2seq.o defs.o mltaln9.o Galign11.o Lalign11.o genalign11.o
|
||||
OBJSEQ2REGTABLE = mtxutl.o io.o seq2regtable.o defs.o
|
||||
OBJCOUNTLEN = mtxutl.o io.o countlen.o defs.o
|
||||
OBJF2CL = mtxutl.o io.o f2cl.o constants.o defs.o
|
||||
OBJMCCASKILLWRAP = mtxutl.o io.o mccaskillwrap.o constants.o defs.o mltaln9.o Galign11.o Lalign11.o genalign11.o
|
||||
OBJCONTRAFOLDWRAP = mtxutl.o io.o contrafoldwrap.o constants.o defs.o mltaln9.o Galign11.o Lalign11.o genalign11.o
|
||||
OBJMULTI2HAT3S = mtxutl.o io.o mltaln9.o tddis.o constants.o \
|
||||
multi2hat3s.o defs.o fft.o fftFunctions.o Galign11.o Lalign11.o genalign11.o
|
||||
OBJPAIRASH = mtxutl.o io.o mltaln9.o tddis.o constants.o partSalignmm.o Lalignmm.o rna.o Salignmm.o Dalignmm.o \
|
||||
Falign.o MSalignmm.o Galign11.o Lalign11.o genalign11.o MSalign11.o suboptalign11.o SAalignmm.o \
|
||||
pairash.o defs.o fft.o fftFunctions.o
|
||||
OBJPAIRLOCALALIGN = mtxutl.o io.o mltaln9.o tddis.o constants.o partSalignmm.o Lalignmm.o rna.o Salignmm.o Dalignmm.o \
|
||||
Falign.o MSalignmm.o Galign11.o Lalign11.o genalign11.o MSalign11.o suboptalign11.o SAalignmm.o \
|
||||
pairlocalalignmain.o pairlocalalign.o defs.o fft.o fftFunctions.o
|
||||
OBJDUMMY = mtxutl.o io.o mltaln9.o tddis.o constants.o partSalignmm.o Lalignmm.o rna.o Salignmm.o Dalignmm.o \
|
||||
Falign.o Falign_localhom.o Galign11.o Lalign11.o genalign11.o SAalignmm.o MSalignmm.o \
|
||||
disttbfast_dummy.o dummy.o defs.o fft.o fftFunctions.o
|
||||
OBJSPLITFROMALN = mtxutl.o io.o mltaln9.o tddis.o constants.o partSalignmm.o Lalignmm.o rna.o Salignmm.o Dalignmm.o \
|
||||
Falign.o Falign_localhom.o Galign11.o Lalign11.o genalign11.o SAalignmm.o MSalignmm.o \
|
||||
splitfromaln.o defs.o fft.o fftFunctions.o
|
||||
OBJSPLITTBFAST = mtxutl.o io.o mltaln9.o tddis.o constants.o partSalignmm.o Lalignmm.o rna.o Salignmm.o Dalignmm.o \
|
||||
Falign.o Falign_localhom.o Galign11.o Lalign11.o genalign11.o SAalignmm.o MSalignmm.o \
|
||||
splittbfast.o defs.o fft.o fftFunctions.o
|
||||
OBJSPLITTBFASTP = mtxutl.o io.o mltaln9.o tddis.o constants.o partSalignmm.o Lalignmm.o rna.o Salignmm.o Dalignmm.o \
|
||||
Falign.o Falign_localhom.o Galign11.o Lalign11.o genalign11.o SAalignmm.o MSalignmm.o \
|
||||
defs.o fft.o fftFunctions.o
|
||||
OBJDISTTBFAST = mtxutl.o io.o mltaln9.o tddis.o constants.o partSalignmm.o Lalignmm.o rna.o Salignmm.o Dalignmm.o \
|
||||
Falign.o Falign_localhom.o Galign11.o Lalign11.o genalign11.o SAalignmm.o MSalignmm.o \
|
||||
disttbfast.o defs.o fft.o fftFunctions.o addfunctions.o
|
||||
OBJMAKEDIRECTIONLIST = mtxutl.o io.o mltaln9.o tddis.o constants.o partSalignmm.o Lalignmm.o rna.o Salignmm.o Dalignmm.o \
|
||||
Falign.o Falign_localhom.o Galign11.o Lalign11.o genalign11.o SAalignmm.o MSalignmm.o \
|
||||
makedirectionlist.o defs.o fft.o fftFunctions.o addfunctions.o
|
||||
OBJTBFAST = mtxutl.o io.o mltaln9.o tddis.o constants.o MSalignmm.o partSalignmm.o Lalignmm.o rna.o Salignmm.o Dalignmm.o \
|
||||
Falign.o Falign_localhom.o Galign11.o Lalign11.o genalign11.o SAalignmm.o \
|
||||
tbfast.o defs.o fft.o fftFunctions.o addfunctions.o \
|
||||
pairlocalalign.o MSalign11.o
|
||||
OBJNODPAIR = mtxutl.o io.o mltaln9.o tddis.o constants.o MSalignmm.o partSalignmm.o Lalignmm.o rna.o Salignmm.o Dalignmm.o \
|
||||
Falign.o Falign_localhom.o Galign11.o Lalign11.o genalign11.o SAalignmm.o \
|
||||
nodepair.o defs.o fft.o fftFunctions.o addfunctions.o \
|
||||
pairlocalalign.o MSalign11.o
|
||||
OBJADDSINGLE = mtxutl.o io.o mltaln9.o tddis.o constants.o MSalignmm.o partSalignmm.o Lalignmm.o rna.o Salignmm.o Dalignmm.o \
|
||||
Falign.o Falign_localhom.o Galign11.o Lalign11.o genalign11.o SAalignmm.o \
|
||||
addsingle.o defs.o fft.o fftFunctions.o addfunctions.o
|
||||
OBJSETCORE = mtxutl.o io.o mltaln9.o tddis.o constants.o partSalignmm.o Lalignmm.o rna.o Salignmm.o Dalignmm.o \
|
||||
Falign.o Falign_localhom.o Galign11.o Lalign11.o genalign11.o SAalignmm.o MSalignmm.o \
|
||||
setcore.o defs.o fft.o fftFunctions.o
|
||||
OBJTDITR = mtxutl.o io.o mltaln9.o tddis.o constants.o nj.o partSalignmm.o Lalignmm.o rna.o Salignmm.o Dalignmm.o \
|
||||
Falign.o Falign_localhom.o Galign11.o Lalign11.o genalign11.o fftFunctions.o fft.o \
|
||||
tditeration.o tditr.o defs.o SAalignmm.o treeOperation.o
|
||||
OBJDVTDITR = mtxutl.o io.o mltaln9.o tddis.o constants.o nj.o partSalignmm.o Lalignmm.o rna.o Salignmm.o Dalignmm.o \
|
||||
Falign.o Falign_localhom.o Galign11.o Lalign11.o genalign11.o MSalignmm.o fftFunctions.o fft.o \
|
||||
tditeration.o dvtditr.o defs.o SAalignmm.o treeOperation.o addfunctions.o
|
||||
OBJGETLAG = mtxutl.o io.o mltaln9.o tddis.o constants.o partSalignmm.o Lalignmm.o rna.o Salignmm.o \
|
||||
Falign.o Falign_localhom.o Galign11.o Lalign11.o genalign11.o SAalignmm.o MSalignmm.o Dalignmm.o \
|
||||
getlag.o defs.o fft.o fftFunctions.o
|
||||
OBJGAPFILL = mtxutl.o io.o constants.o gapfill.o defs.o
|
||||
OBJDNDFAST5 = dndfast5.o io.o constants.o mtxutl.o mltaln9.o tddis.o defs.o
|
||||
OBJDNDBLAST = dndblast.o io.o constants.o mtxutl.o mltaln9.o tddis.o defs.o Galign11.o Lalign11.o genalign11.o
|
||||
OBJDNDFAST7 = dndfast7.o io.o constants.o mtxutl.o mltaln9.o tddis.o defs.o Galign11.o Lalign11.o genalign11.o
|
||||
OBJDNDFAST6 = dndfast6.o io.o constants.o mtxutl.o mltaln9.o tddis.o defs.o
|
||||
OBJDNDFAST4 = dndfast4.o io.o constants.o mtxutl.o mltaln9.o tddis.o defs.o
|
||||
OBJDNDFAST6 = dndfast6.o io.o constants.o mtxutl.o mltaln9.o tddis.o defs.o
|
||||
OBJSEXTET5 = io.o constants.o mtxutl.o mltaln9.o tddis.o sextet5.o defs.o Galign11.o Lalign11.o genalign11.o
|
||||
OBJDISTANCE = io.o constants.o mtxutl.o mltaln9.o tddis.o mafft-distance.o defs.o Galign11.o Lalign11.o genalign11.o
|
||||
OBJTRIPLET6 = io.o constants.o mtxutl.o mltaln9.o tddis.o triplet6.o defs.o
|
||||
OBJTRIPLET5 = io.o constants.o mtxutl.o mltaln9.o tddis.o triplet5.o defs.o
|
||||
OBJOCTET4 = io.o constants.o mtxutl.o mltaln9.o tddis.o octet4.o defs.o
|
||||
OBJDNDPRE = dndpre.o io.o constants.o mtxutl.o mltaln9.o defs.o Galign11.o Lalign11.o genalign11.o
|
||||
OBJGALN = io.o mtxutl.o mltaln9.o tddis.o constants.o partSalignmm.o MSalignmm.o Lalignmm.o rna.o Salignmm.o Dalignmm.o \
|
||||
SAalignmm.o Galign11.o Lalign11.o genalign11.o Falign.o Falign_localhom.o fftFunctions.o fft.o mafft-profile.o defs.o
|
||||
OBJSCORE = io.o mtxutl.o mltaln9.o score.o constants.o defs.o Galign11.o Lalign11.o genalign11.o
|
||||
|
||||
HEADER = mltaln.h mtxutl.h mafft.h
|
||||
FFTHEADER = fft.h
|
||||
|
||||
MANPAGES = mafft.1 mafft-homologs.1
|
||||
|
||||
|
||||
|
||||
|
||||
all : $(PERLPROGS) $(PROGS) $(SCRIPTS)
|
||||
cp $(SCRIPTS) ../scripts
|
||||
chmod 755 ../scripts/*
|
||||
cp $(PERLPROGS) $(PROGS) ../binaries
|
||||
chmod 755 ../binaries/*
|
||||
cp $(MANPAGES) ../binaries
|
||||
@echo done.
|
||||
|
||||
sos : $(SOS)
|
||||
dylibs : $(DYLIBS)
|
||||
dlls : $(DLLS)
|
||||
|
||||
$(DASH_CLIENT): dash_client.go
|
||||
# go build dash_client.go
|
||||
env CGO_ENABLED=0 go build --ldflags '-extldflags "-static"' dash_client.go # for conda
|
||||
|
||||
|
||||
univscript: univscript.tmpl Makefile
|
||||
sed "s:_PROGS:$(PROGS):" univscript.tmpl > univscript
|
||||
|
||||
mafft: mafft.tmpl mltaln.h
|
||||
sed "s:_LIBDIR:$(LIBDIR):" mafft.tmpl > mafft
|
||||
|
||||
mafft-homologs.rb: mafft-homologs.tmpl
|
||||
# cp mafft-homologs.tmpl mafft-homologs.rb
|
||||
sed "s:_BINDIR:$(BINDIR):" mafft-homologs.tmpl > mafft-homologs.rb
|
||||
|
||||
mafft-sparsecore.rb: mafft-sparsecore.tmpl
|
||||
# cp mafft-sparsecore.tmpl mafft-sparsecore.rb
|
||||
sed "s:_BINDIR:$(BINDIR):" mafft-sparsecore.tmpl > mafft-sparsecore.rb
|
||||
|
||||
mltaln.h : functions.h
|
||||
touch mltaln.h
|
||||
|
||||
version : version.c mltaln.h
|
||||
$(CC) -o $@ version.c $(MYCFLAGS) $(LDFLAGS) $(LIBS)
|
||||
|
||||
maffttext2hex : maffttext2hex.c
|
||||
$(CC) -o $@ maffttext2hex.c $(MYCFLAGS) $(LDFLAGS) $(LIBS)
|
||||
|
||||
hex2maffttext : hex2maffttext.c
|
||||
$(CC) -o $@ hex2maffttext.c $(MYCFLAGS) $(LDFLAGS) $(LIBS)
|
||||
|
||||
tbfast : $(OBJTBFAST)
|
||||
$(CC) -o $@ $(OBJTBFAST) $(MYCFLAGS) $(LDFLAGS) $(LIBS)
|
||||
|
||||
nodepair : $(OBJNODPAIR)
|
||||
$(CC) -o $@ $(OBJNODPAIR) $(MYCFLAGS) $(LDFLAGS) $(LIBS)
|
||||
|
||||
addsingle : $(OBJADDSINGLE)
|
||||
$(CC) -o $@ $(OBJADDSINGLE) $(MYCFLAGS) $(LDFLAGS) $(LIBS)
|
||||
|
||||
disttbfast : $(OBJDISTTBFAST)
|
||||
$(CC) -o $@ $(OBJDISTTBFAST) $(MYCFLAGS) $(LDFLAGS) $(LIBS)
|
||||
|
||||
libdisttbfast.so : $(OBJDISTTBFAST)
|
||||
$(CC) -shared -o $@ $(OBJDISTTBFAST) $(MYCFLAGS) $(LDFLAGS) $(LIBS)
|
||||
|
||||
libdisttbfast.dylib : $(OBJDISTTBFAST)
|
||||
$(CC) -dynamiclib -o $@ $(OBJDISTTBFAST) $(MYCFLAGS) $(LDFLAGS) $(LIBS)
|
||||
|
||||
libdisttbfast.dll : $(OBJDISTTBFAST)
|
||||
$(CC) -shared -o $@ $(OBJDISTTBFAST) $(MYCFLAGS) $(LDFLAGS) $(LIBS)
|
||||
|
||||
makedirectionlist : $(OBJMAKEDIRECTIONLIST)
|
||||
$(CC) -o $@ $(OBJMAKEDIRECTIONLIST) $(MYCFLAGS) $(LDFLAGS) $(LIBS)
|
||||
|
||||
splittbfast : $(OBJSPLITTBFAST)
|
||||
$(CC) -o $@ $(OBJSPLITTBFAST) $(MYCFLAGS) $(LDFLAGS) $(LIBS)
|
||||
|
||||
splitfromaln : $(OBJSPLITFROMALN)
|
||||
$(CC) -o $@ $(OBJSPLITFROMALN) $(MYCFLAGS) $(LDFLAGS) $(LIBS)
|
||||
|
||||
dummy : $(OBJDUMMY)
|
||||
$(CC) -o $@ $(OBJDUMMY) $(MYCFLAGS) $(LDFLAGS) $(LIBS)
|
||||
|
||||
setcore : $(OBJSETCORE)
|
||||
$(CC) -o $@ $(OBJSETCORE) $(MYCFLAGS) $(LDFLAGS) $(LIBS)
|
||||
|
||||
countlen : $(OBJCOUNTLEN)
|
||||
$(CC) -o $@ $(OBJCOUNTLEN) $(MYCFLAGS) $(LDFLAGS) $(LIBS)
|
||||
|
||||
seq2regtable : $(OBJSEQ2REGTABLE)
|
||||
$(CC) -o $@ $(OBJSEQ2REGTABLE) $(MYCFLAGS) $(LDFLAGS) $(LIBS)
|
||||
|
||||
regtable2seq : $(OBJREGTABLE2SEQ)
|
||||
$(CC) -o $@ $(OBJREGTABLE2SEQ) $(MYCFLAGS) $(LDFLAGS) $(LIBS)
|
||||
|
||||
setdirection : $(OBJSETDIRECTION)
|
||||
$(CC) -o $@ $(OBJSETDIRECTION) $(MYCFLAGS) $(LDFLAGS) $(LIBS)
|
||||
|
||||
replaceu : $(OBJREPLACEU)
|
||||
$(CC) -o $@ $(OBJREPLACEU) $(MYCFLAGS) $(LDFLAGS) $(LIBS)
|
||||
|
||||
filter : $(OBJFILTER)
|
||||
$(CC) -o $@ $(OBJFILTER) $(MYCFLAGS) $(LDFLAGS) $(LIBS)
|
||||
|
||||
restoreu : $(OBJRESTOREU)
|
||||
$(CC) -o $@ $(OBJRESTOREU) $(MYCFLAGS) $(LDFLAGS) $(LIBS)
|
||||
|
||||
f2cl : $(OBJF2CL)
|
||||
$(CC) -o $@ $(OBJF2CL) $(MYCFLAGS) $(LDFLAGS) $(LIBS)
|
||||
|
||||
mccaskillwrap : $(OBJMCCASKILLWRAP)
|
||||
$(CC) -o $@ $(OBJMCCASKILLWRAP) $(MYCFLAGS) $(LDFLAGS) $(LIBS)
|
||||
|
||||
contrafoldwrap : $(OBJCONTRAFOLDWRAP)
|
||||
$(CC) -o $@ $(OBJCONTRAFOLDWRAP) $(MYCFLAGS) $(LDFLAGS) $(LIBS)
|
||||
|
||||
pairlocalalign : $(OBJPAIRLOCALALIGN)
|
||||
$(CC) -o $@ $(OBJPAIRLOCALALIGN) $(MYCFLAGS) $(LDFLAGS) $(LIBS)
|
||||
|
||||
pairash : $(OBJPAIRASH)
|
||||
$(CC) -o $@ $(OBJPAIRASH) $(MYCFLAGS) $(LDFLAGS) $(LIBS)
|
||||
|
||||
multi2hat3s : $(OBJMULTI2HAT3S)
|
||||
$(CC) -o $@ $(OBJMULTI2HAT3S) $(MYCFLAGS) $(LDFLAGS) $(LIBS)
|
||||
|
||||
getlag : $(OBJGETLAG)
|
||||
$(CC) -o $@ $(OBJGETLAG) $(MYCFLAGS) $(LDFLAGS) $(LIBS)
|
||||
|
||||
tditr : $(OBJTDITR)
|
||||
$(CC) -o $@ $(OBJTDITR) $(MYCFLAGS) $(LDFLAGS) $(LIBS)
|
||||
|
||||
dvtditr : $(OBJDVTDITR)
|
||||
$(CC) -o $@ $(OBJDVTDITR) $(MYCFLAGS) $(LDFLAGS) $(LIBS)
|
||||
|
||||
mafft-profile : $(OBJGALN)
|
||||
$(CC) -o $@ $(OBJGALN) $(MYCFLAGS) $(LDFLAGS) $(LIBS)
|
||||
|
||||
gapfill : $(OBJGAPFILL)
|
||||
$(CC) -o $@ $(OBJGAPFILL) $(MYCFLAGS) $(LDFLAGS) $(LIBS)
|
||||
|
||||
dndfast4 : $(OBJDNDFAST4)
|
||||
$(CC) -o $@ $(OBJDNDFAST4) $(MYCFLAGS) $(LDFLAGS) $(LIBS)
|
||||
|
||||
dndfast5 : $(OBJDNDFAST5)
|
||||
$(CC) -o $@ $(OBJDNDFAST5) $(MYCFLAGS) $(LDFLAGS) $(LIBS)
|
||||
|
||||
dndfast6 : $(OBJDNDFAST6)
|
||||
$(CC) -o $@ $(OBJDNDFAST6) $(MYCFLAGS) $(LDFLAGS) $(LIBS)
|
||||
|
||||
dndfast7 : $(OBJDNDFAST7)
|
||||
$(CC) -o $@ $(OBJDNDFAST7) $(MYCFLAGS) $(LDFLAGS) $(LIBS)
|
||||
|
||||
dndblast : $(OBJDNDBLAST)
|
||||
$(CC) -o $@ $(OBJDNDBLAST) $(MYCFLAGS) $(LDFLAGS) $(LIBS)
|
||||
|
||||
dndfast3 : $(OBJDNDFAST3)
|
||||
$(CC) -o $@ $(OBJDNDFAST3) $(MYCFLAGS) $(LDFLAGS) $(LIBS)
|
||||
|
||||
triplet : $(OBJTRIPLET)
|
||||
$(CC) -o $@ $(OBJTRIPLET) $(MYCFLAGS) $(LDFLAGS) $(LIBS)
|
||||
|
||||
triplet3 : $(OBJTRIPLET3)
|
||||
$(CC) -o $@ $(OBJTRIPLET3) $(MYCFLAGS) $(LDFLAGS) $(LIBS)
|
||||
|
||||
sextet3 : $(OBJSEXTET3)
|
||||
$(CC) -o $@ $(OBJSEXTET3) $(MYCFLAGS) $(LDFLAGS) $(LIBS)
|
||||
|
||||
sextet4 : $(OBJSEXTET4)
|
||||
$(CC) -o $@ $(OBJSEXTET4) $(MYCFLAGS) $(LDFLAGS) $(LIBS)
|
||||
|
||||
sextet5 : $(OBJSEXTET5)
|
||||
$(CC) -o $@ $(OBJSEXTET5) $(MYCFLAGS) $(LDFLAGS) $(LIBS)
|
||||
|
||||
mafft-distance : $(OBJDISTANCE)
|
||||
$(CC) -o $@ $(OBJDISTANCE) $(MYCFLAGS) $(LDFLAGS) $(LIBS)
|
||||
|
||||
triplet5 : $(OBJTRIPLET5)
|
||||
$(CC) -o $@ $(OBJTRIPLET5) $(MYCFLAGS) $(LDFLAGS) $(LIBS)
|
||||
|
||||
triplet6 : $(OBJTRIPLET6)
|
||||
$(CC) -o $@ $(OBJTRIPLET6) $(MYCFLAGS) $(LDFLAGS) $(LIBS)
|
||||
|
||||
octet4 : $(OBJOCTET4)
|
||||
$(CC) -o $@ $(OBJOCTET4) $(MYCFLAGS) $(LDFLAGS) $(LIBS)
|
||||
|
||||
dndpre : $(OBJDNDPRE)
|
||||
$(CC) -o $@ $(OBJDNDPRE) $(MYCFLAGS) $(LDFLAGS) $(LIBS)
|
||||
|
||||
score : $(OBJSCORE)
|
||||
$(CC) -o $@ $(OBJSCORE) $(MYCFLAGS) $(LDFLAGS) $(LIBS)
|
||||
|
||||
genMtx : $(OBJGENMTX)
|
||||
$(CC) -o $@ $(OBJGENMTX) $(MYCFLAGS) $(LDFLAGS) $(LIBS)
|
||||
|
||||
mafftash_premafft.pl : mafftash_premafft.tmpl
|
||||
cp mafftash_premafft.tmpl mafftash_premafft.pl
|
||||
|
||||
seekquencer_premafft.pl : seekquencer_premafft.tmpl
|
||||
cp seekquencer_premafft.tmpl seekquencer_premafft.pl
|
||||
|
||||
gapfill.o : gapfill.c $(HEADER)
|
||||
$(CC) $(MYCFLAGS) -c gapfill.c
|
||||
|
||||
mltaln9.o : mltaln9.c $(HEADER)
|
||||
$(CC) $(MYCFLAGS) -c mltaln9.c
|
||||
|
||||
tddis.o : tddis.c $(HEADER)
|
||||
$(CC) $(MYCFLAGS) -c tddis.c
|
||||
|
||||
constants.o : constants.c miyata.h miyata5.h blosum.c DNA.h JTT.c $(HEADER)
|
||||
$(CC) $(MYCFLAGS) -c constants.c
|
||||
|
||||
defs.o : defs.c
|
||||
$(CC) $(MYCFLAGS) -c defs.c
|
||||
|
||||
#A+++alignmm.o : SA+++alignmm.c $(HEADER)
|
||||
# $(CC) $(MYCFLAGS) -c SA+++alignmm.c -o A+++alignmm.o
|
||||
|
||||
Salignmm.o : Salignmm.c $(HEADER)
|
||||
$(CC) $(MYCFLAGS) -c Salignmm.c
|
||||
|
||||
Dalignmm.o : Dalignmm.c $(HEADER)
|
||||
$(CC) $(MYCFLAGS) -c Dalignmm.c
|
||||
|
||||
MSalignmm.o : MSalignmm.c $(HEADER)
|
||||
$(CC) $(MYCFLAGS) -c MSalignmm.c
|
||||
|
||||
partSalignmm.o : partSalignmm.c $(HEADER)
|
||||
$(CC) $(MYCFLAGS) -c partSalignmm.c
|
||||
|
||||
Lalign11.o : Lalign11.c $(HEADER)
|
||||
$(CC) $(MYCFLAGS) -c Lalign11.c
|
||||
|
||||
genalign11.o : genalign11.c $(HEADER)
|
||||
$(CC) $(MYCFLAGS) -c genalign11.c
|
||||
|
||||
suboptalign11.o : suboptalign11.c $(HEADER)
|
||||
$(CC) $(MYCFLAGS) -c suboptalign11.c
|
||||
|
||||
Galign11.o : Galign11.c $(HEADER)
|
||||
$(CC) $(MYCFLAGS) -c Galign11.c
|
||||
|
||||
MSalign11.o : MSalign11.c $(HEADER)
|
||||
$(CC) $(MYCFLAGS) -c MSalign11.c
|
||||
|
||||
SAalignmm.o : SAalignmm.c $(HEADER)
|
||||
$(CC) $(MYCFLAGS) -c SAalignmm.c -o SAalignmm.o
|
||||
|
||||
Lalignmm.o : Lalignmm.c $(HEADER)
|
||||
$(CC) $(MYCFLAGS) -c Lalignmm.c
|
||||
|
||||
rna.o : rna.c $(HEADER)
|
||||
$(CC) $(MYCFLAGS) -c rna.c
|
||||
|
||||
disttbfast.o : disttbfast.c $(HEADER) $(FFTHEADER)
|
||||
$(CC) $(MYCFLAGS) -c disttbfast.c
|
||||
|
||||
splitfromaln.o : splitfromaln.c $(HEADER) $(FFTHEADER)
|
||||
$(CC) $(MYCFLAGS) -c splitfromaln.c
|
||||
|
||||
splittbfast.o : splittbfast.c $(HEADER) $(FFTHEADER)
|
||||
$(CC) $(MYCFLAGS) -c splittbfast.c
|
||||
|
||||
splittbfast2.o : splittbfast2.c $(HEADER) $(FFTHEADER)
|
||||
$(CC) $(MYCFLAGS) -c splittbfast2.c
|
||||
|
||||
makedirectionlist.o : makedirectionlist.c $(HEADER) $(FFTHEADER)
|
||||
$(CC) $(MYCFLAGS) -c makedirectionlist.c
|
||||
|
||||
disttbfast_dummy.o : disttbfast_dummy.c $(HEADER) $(FFTHEADER)
|
||||
$(CC) $(MYCFLAGS) -c disttbfast_dummy.c
|
||||
|
||||
dummy.o : dummy.c $(HEADER) $(FFTHEADER)
|
||||
$(CC) $(MYCFLAGS) -c dummy.c
|
||||
|
||||
tbfast.o : tbfast.c $(HEADER) $(FFTHEADER)
|
||||
$(CC) $(MYCFLAGS) -c tbfast.c
|
||||
|
||||
nodepair.o : nodepair.c $(HEADER) $(FFTHEADER)
|
||||
$(CC) $(MYCFLAGS) -c nodepair.c
|
||||
|
||||
addsingle.o : addsingle.c $(HEADER) $(FFTHEADER)
|
||||
addsingle.o : addsingle.c $(HEADER) $(FFTHEADER)
|
||||
$(CC) $(MYCFLAGS) -c addsingle.c
|
||||
|
||||
tbfast2.o : tbfast2.c $(HEADER) $(FFTHEADER)
|
||||
$(CC) $(MYCFLAGS) -c tbfast2.c
|
||||
|
||||
setcore.o : setcore.c $(HEADER) $(FFTHEADER)
|
||||
$(CC) $(MYCFLAGS) -c setcore.c
|
||||
|
||||
getlag.o : getlag.c $(HEADER) $(FFTHEADER)
|
||||
$(CC) $(MYCFLAGS) -c getlag.c
|
||||
|
||||
tditr.o : tditr.c $(HEADER)
|
||||
$(CC) $(MYCFLAGS) -c tditr.c
|
||||
|
||||
dvtditr.o : dvtditr.c $(HEADER)
|
||||
$(CC) $(MYCFLAGS) -c dvtditr.c
|
||||
|
||||
tditeration.o : tditeration.c $(HEADER)
|
||||
$(CC) $(MYCFLAGS) -c tditeration.c
|
||||
|
||||
mafft-profile.o : mafft-profile.c $(HEADER) $(MTXHEADER)
|
||||
$(CC) $(MYCFLAGS) -c mafft-profile.c
|
||||
|
||||
dndfast4.o : dndfast4.c $(HEADER) $(MTXHEADER)
|
||||
$(CC) $(MYCFLAGS) -c dndfast4.c
|
||||
|
||||
dndfast5.o : dndfast5.c $(HEADER) $(MTXHEADER)
|
||||
$(CC) $(MYCFLAGS) -c dndfast5.c
|
||||
|
||||
dndfast6.o : dndfast6.c $(HEADER) $(MTXHEADER)
|
||||
$(CC) $(MYCFLAGS) -c dndfast6.c
|
||||
|
||||
dndfast7.o : dndfast7.c $(HEADER) $(MTXHEADER)
|
||||
$(CC) $(MYCFLAGS) -c dndfast7.c
|
||||
|
||||
dndblast.o : dndblast.c $(HEADER) $(MTXHEADER)
|
||||
$(CC) $(MYCFLAGS) -c dndblast.c
|
||||
|
||||
dndfast3.o : dndfast3.c $(HEADER) $(MTXHEADER)
|
||||
$(CC) $(MYCFLAGS) -c dndfast3.c
|
||||
|
||||
dndpre.o : dndpre.c $(HEADER)
|
||||
$(CC) $(MYCFLAGS) -c dndpre.c
|
||||
|
||||
countlen.o : countlen.c $(HEADER)
|
||||
$(CC) $(MYCFLAGS) -c countlen.c
|
||||
|
||||
seq2regtable.o : seq2regtable.c $(HEADER)
|
||||
$(CC) $(MYCFLAGS) -c seq2regtable.c
|
||||
|
||||
regtable2seq.o : regtable2seq.c $(HEADER)
|
||||
$(CC) $(MYCFLAGS) -c regtable2seq.c
|
||||
|
||||
f2cl.o : f2cl.c $(HEADER)
|
||||
$(CC) $(MYCFLAGS) -c f2cl.c
|
||||
|
||||
setdirection.o : setdirection.c $(HEADER)
|
||||
$(CC) $(MYCFLAGS) -c setdirection.c
|
||||
|
||||
replaceu.o : replaceu.c $(HEADER)
|
||||
$(CC) $(MYCFLAGS) -c replaceu.c
|
||||
|
||||
restoreu.o : restoreu.c $(HEADER)
|
||||
$(CC) $(MYCFLAGS) -c restoreu.c
|
||||
|
||||
mccaskillwrap.o : mccaskillwrap.c $(HEADER)
|
||||
$(CC) $(MYCFLAGS) -c mccaskillwrap.c
|
||||
|
||||
contrafoldwrap.o : contrafoldwrap.c $(HEADER)
|
||||
$(CC) $(MYCFLAGS) -c contrafoldwrap.c
|
||||
|
||||
pairlocalalign.o : pairlocalalign.c $(HEADER) $(FFTHEADER)
|
||||
$(CC) $(MYCFLAGS) -c pairlocalalign.c
|
||||
|
||||
pairlocalalignmain.o : pairlocalalignmain.c $(HEADER) $(FFTHEADER)
|
||||
$(CC) $(MYCFLAGS) -c pairlocalalignmain.c
|
||||
|
||||
pairash.o : pairash.c $(HEADER) $(FFTHEADER)
|
||||
$(CC) $(MYCFLAGS) -c pairash.c
|
||||
|
||||
multi2hat3s.o : multi2hat3s.c $(HEADER) $(FFTHEADER)
|
||||
$(CC) $(MYCFLAGS) -c multi2hat3s.c
|
||||
|
||||
io.o : io.c $(HEADER) $(FFTHEADER)
|
||||
$(CC) $(MYCFLAGS) -c io.c
|
||||
|
||||
nj.o : nj.c $(HEADER)
|
||||
$(CC) $(MYCFLAGS) -c nj.c
|
||||
|
||||
treeOperation.o : treeOperation.c $(HEADER)
|
||||
$(CC) $(MYCFLAGS) -c treeOperation.c
|
||||
|
||||
sextet5.o : sextet5.c $(HEADER) $(MTXHEADER)
|
||||
$(CC) $(MYCFLAGS) -c sextet5.c
|
||||
|
||||
mafft-distance.o : mafft-distance.c $(HEADER) $(MTXHEADER)
|
||||
$(CC) $(MYCFLAGS) -c mafft-distance.c
|
||||
|
||||
maffttext2hex.o : maffttext2hex.c
|
||||
$(CC) $(MYCFLAGS) -c maffttext2hex.c
|
||||
|
||||
hex2maffttext.o : hex2maffttext.c
|
||||
$(CC) $(MYCFLAGS) -c hex2maffttext.c
|
||||
|
||||
triplet6.o : triplet6.c $(HEADER) $(MTXHEADER)
|
||||
$(CC) $(MYCFLAGS) -c triplet6.c
|
||||
|
||||
fft.o : fft.c $(HEADER) $(FFTHEADER)
|
||||
$(CC) $(MYCFLAGS) -c fft.c
|
||||
|
||||
fftFunctions.o : fftFunctions.c $(HEADER) $(FFTHEADER)
|
||||
$(CC) $(MYCFLAGS) -c fftFunctions.c
|
||||
|
||||
Falign.o : Falign.c $(HEADER) $(FFTHEADER) $(MTXHEADER)
|
||||
$(CC) $(MYCFLAGS) -c Falign.c
|
||||
|
||||
Falign_localhom.o : Falign_localhom.c $(HEADER) $(FFTHEADER) $(MTXHEADER)
|
||||
$(CC) $(MYCFLAGS) -c Falign_localhom.c
|
||||
|
||||
mtxutl.o : mtxutl.c
|
||||
$(CC) $(MYCFLAGS) -c mtxutl.c
|
||||
|
||||
addfunctions.o : addfunctions.c $(HEADER)
|
||||
$(CC) $(MYCFLAGS) -c addfunctions.c
|
||||
|
||||
score.o : score.c $(HEADER)
|
||||
$(CC) $(MYCFLAGS) -c score.c
|
||||
|
||||
clean :
|
||||
rm -f *.o *.a *.exe *~ $(PERLPROGS) $(PROGS) $(SCRIPTS) $(SOS) $(DYLIBS) $(DLLS) *.gcda *.gcno $(DASH_CLIENT)
|
||||
# rm -f ../binaries/* ../scripts/*
|
||||
|
||||
install : all
|
||||
mkdir -p $(DESTDIR)$(LIBDIR)
|
||||
chmod 755 $(DESTDIR)$(LIBDIR)
|
||||
mkdir -p $(DESTDIR)$(BINDIR)
|
||||
chmod 755 $(DESTDIR)$(BINDIR)
|
||||
chmod 755 $(SCRIPTS)
|
||||
$(INSTALL) $(SCRIPTS) $(DESTDIR)$(BINDIR)
|
||||
chmod 755 $(PROGS) ||: # in MinGW, it's ok if this fails
|
||||
# $(INSTALL) -s $(PROGS) $(DESTDIR)$(LIBDIR)
|
||||
$(STRIP) $(PROGS) ||: # may fail for dash_client on mac.
|
||||
$(INSTALL) $(PROGS) $(DESTDIR)$(LIBDIR)
|
||||
$(INSTALL) $(PERLPROGS) $(DESTDIR)$(LIBDIR)
|
||||
$(INSTALL) -m 644 $(MANPAGES) $(DESTDIR)$(LIBDIR)
|
||||
|
||||
( cd $(DESTDIR)$(BINDIR); \
|
||||
rm -f linsi ginsi einsi fftns fftnsi nwns nwnsi xinsi qinsi; \
|
||||
rm -f mafft-linsi mafft-ginsi mafft-einsi mafft-fftns mafft-fftnsi mafft-nwns mafft-nwnsi mafft-xinsi mafft-qinsi mafft-randomcore.rb ; \
|
||||
ln -s mafft linsi; ln -s mafft ginsi; ln -s mafft fftns; \
|
||||
ln -s mafft fftnsi; ln -s mafft nwns; ln -s mafft nwnsi; \
|
||||
ln -s mafft einsi; \
|
||||
ln -s mafft mafft-linsi; ln -s mafft mafft-ginsi; ln -s mafft mafft-fftns; \
|
||||
ln -s mafft mafft-fftnsi; ln -s mafft mafft-nwns; ln -s mafft mafft-nwnsi; \
|
||||
ln -s mafft mafft-einsi; ln -s mafft mafft-xinsi; ln -s mafft mafft-qinsi;\
|
||||
rm -f mafft-profile mafft-profile.exe; ln -s $(LIBDIR)/mafft-profile .; \
|
||||
rm -f mafft-distance mafft-distance.exe; ln -s $(LIBDIR)/mafft-distance . )
|
||||
|
||||
mkdir -p $(DESTDIR)$(MANDIR)
|
||||
chmod 755 $(DESTDIR)$(MANDIR)
|
||||
$(INSTALL) -m 644 $(MANPAGES) $(DESTDIR)$(MANDIR)
|
||||
# remove incorrectly installed manpages by previous versions
|
||||
# rm -f /usr/local/man/man1/mafft.1 /usr/local/man/man1/mafft-homologs.1
|
545
mafft/src/mafft-7.487-with-extensions/core/Makefile.sos
Normal file
545
mafft/src/mafft-7.487-with-extensions/core/Makefile.sos
Normal file
|
@ -0,0 +1,545 @@
|
|||
PREFIX = /usr/local
|
||||
LIBDIR = $(PREFIX)/libexec/mafft
|
||||
BINDIR = $(PREFIX)/bin
|
||||
MANDIR = $(PREFIX)/share/man/man1
|
||||
|
||||
#MNO_CYGWIN = -mno-cygwin
|
||||
|
||||
ENABLE_MULTITHREAD = -Denablemultithread
|
||||
# Comment out the above line if your compiler
|
||||
# does not support TLS (thread-local strage).
|
||||
|
||||
CC = gcc
|
||||
#CFLAGS = -O3
|
||||
#CFLAGS = -O3 -fPIC
|
||||
# add -fPIC when building .so files
|
||||
|
||||
#CC = icc
|
||||
#CFLAGS = -fast
|
||||
# if you have icc, use this.
|
||||
|
||||
#CFLAGS = -O0 -fPIC -pedantic -Wall -std=c99 -g -pg -DMALLOC_CHECK_=3
|
||||
CFLAGS = -fPIC -O0 -fPIC -pedantic -Wall -std=c99 -g -DMALLOC_CHECK_=3 # for shark, valgrind
|
||||
|
||||
|
||||
MYCFLAGS = $(MNO_CYGWIN) $(ENABLE_MULTITHREAD) $(CFLAGS)
|
||||
|
||||
ifdef ENABLE_MULTITHREAD
|
||||
LIBS = -lm -lpthread
|
||||
else
|
||||
LIBS = -lm
|
||||
endif
|
||||
|
||||
INSTALL = install
|
||||
|
||||
PROGS = dvtditr dndfast7 dndblast sextet5 mafft-distance pairlocalalign \
|
||||
pair2hat3s multi2hat3s pairash addsingle \
|
||||
splittbfast disttbfast tbfast mafft-profile f2cl mccaskillwrap contrafoldwrap countlen \
|
||||
seq2regtable regtable2seq score getlag dndpre setcore replaceu restoreu setdirection makedirectionlist version
|
||||
SOS = libdisttbfast.so
|
||||
DLLS = libdisttbfast.dll
|
||||
DYLIBS = libdisttbfast.dylib
|
||||
|
||||
PERLPROGS = mafftash_premafft.pl seekquencer_premafft.pl
|
||||
SCRIPTS = mafft mafft-homologs.rb
|
||||
OBJSETDIRECTION = mtxutl.o io.o setdirection.o defs.o mltaln9.o
|
||||
OBJREPLACEU = mtxutl.o io.o replaceu.o defs.o mltaln9.o
|
||||
OBJRESTOREU = mtxutl.o io.o restoreu.o defs.o mltaln9.o
|
||||
OBJREGTABLE2SEQ = mtxutl.o io.o regtable2seq.o defs.o mltaln9.o
|
||||
OBJSEQ2REGTABLE = mtxutl.o io.o seq2regtable.o defs.o
|
||||
OBJCOUNTLEN = mtxutl.o io.o countlen.o defs.o
|
||||
OBJF2CL = mtxutl.o io.o f2cl.o constants.o defs.o
|
||||
OBJMCCASKILLWRAP = mtxutl.o io.o mccaskillwrap.o constants.o defs.o mltaln9.o
|
||||
OBJCONTRAFOLDWRAP = mtxutl.o io.o contrafoldwrap.o constants.o defs.o mltaln9.o
|
||||
OBJMULTI2HAT3S = mtxutl.o io.o mltaln9.o tddis.o constants.o \
|
||||
multi2hat3s.o defs.o fft.o fftFunctions.o
|
||||
OBJPAIR2HAT3S = mtxutl.o io.o mltaln9.o tddis.o constants.o \
|
||||
pair2hat3s.o defs.o fft.o fftFunctions.o
|
||||
OBJPAIRASH = mtxutl.o io.o mltaln9.o tddis.o constants.o partSalignmm.o Lalignmm.o rna.o Salignmm.o \
|
||||
Falign.o MSalignmm.o Galign11.o MSalign11.o suboptalign11.o genalign11.o Lalign11.o SAalignmm.o \
|
||||
pairash.o defs.o fft.o fftFunctions.o
|
||||
OBJPAIRLOCALALIGN = mtxutl.o io.o mltaln9.o tddis.o constants.o partSalignmm.o Lalignmm.o rna.o Salignmm.o \
|
||||
Falign.o MSalignmm.o Galign11.o MSalign11.o suboptalign11.o genalign11.o Lalign11.o SAalignmm.o \
|
||||
pairlocalalign.o defs.o fft.o fftFunctions.o
|
||||
OBJDUMMY = mtxutl.o io.o mltaln9.o tddis.o constants.o partSalignmm.o Lalignmm.o rna.o Salignmm.o \
|
||||
Falign.o Falign_localhom.o Galign11.o SAalignmm.o MSalignmm.o \
|
||||
disttbfast_dummy.o dummy.o defs.o fft.o fftFunctions.o
|
||||
OBJSPLITFROMALN = mtxutl.o io.o mltaln9.o tddis.o constants.o partSalignmm.o Lalignmm.o rna.o Salignmm.o \
|
||||
Falign.o Falign_localhom.o Galign11.o SAalignmm.o MSalignmm.o \
|
||||
Lalign11.o splitfromaln.o defs.o fft.o fftFunctions.o
|
||||
OBJSPLITTBFAST = mtxutl.o io.o mltaln9.o tddis.o constants.o partSalignmm.o Lalignmm.o rna.o Salignmm.o \
|
||||
Falign.o Falign_localhom.o Galign11.o SAalignmm.o MSalignmm.o \
|
||||
Lalign11.o splittbfast.o defs.o fft.o fftFunctions.o
|
||||
OBJSPLITTBFAST2 = mtxutl.o io.o mltaln9.o tddis.o constants.o partSalignmm.o Lalignmm.o rna.o Salignmm.o \
|
||||
Falign.o Falign_localhom.o Galign11.o SAalignmm.o MSalignmm.o \
|
||||
Lalign11.o splittbfast2.o defs.o fft.o fftFunctions.o
|
||||
OBJSPLITTBFASTP = mtxutl.o io.o mltaln9.o tddis.o constants.o partSalignmm.o Lalignmm.o rna.o Salignmm.o \
|
||||
Falign.o Falign_localhom.o Galign11.o SAalignmm.o MSalignmm.o \
|
||||
Lalign11.o defs.o fft.o fftFunctions.o
|
||||
OBJDISTTBFAST = mtxutl.o io.o mltaln9.o tddis.o constants.o partSalignmm.o Lalignmm.o rna.o Salignmm.o \
|
||||
Falign.o Falign_localhom.o Galign11.o SAalignmm.o MSalignmm.o \
|
||||
disttbfast.o defs.o fft.o fftFunctions.o addfunctions.o
|
||||
OBJMAKEDIRECTIONLIST = mtxutl.o io.o mltaln9.o tddis.o constants.o partSalignmm.o Lalignmm.o rna.o Salignmm.o \
|
||||
Falign.o Falign_localhom.o Galign11.o SAalignmm.o MSalignmm.o \
|
||||
Lalign11.o makedirectionlist.o defs.o fft.o fftFunctions.o addfunctions.o
|
||||
OBJTBFAST = mtxutl.o io.o mltaln9.o tddis.o constants.o MSalignmm.o partSalignmm.o Lalignmm.o rna.o Salignmm.o \
|
||||
Falign.o Falign_localhom.o Galign11.o SAalignmm.o \
|
||||
tbfast.o defs.o fft.o fftFunctions.o addfunctions.o
|
||||
OBJADDSINGLE = mtxutl.o io.o mltaln9.o tddis.o constants.o MSalignmm.o partSalignmm.o Lalignmm.o rna.o Salignmm.o \
|
||||
Falign.o Falign_localhom.o Galign11.o SAalignmm.o \
|
||||
addsingle.o defs.o fft.o fftFunctions.o addfunctions.o
|
||||
OBJTBFAST2 = mtxutl.o io.o mltaln9.o tddis.o constants.o partSalignmm.o Lalignmm.o rna.o Salignmm.o MSalignmm.o \
|
||||
Falign.o Falign_localhom.o Galign11.o SAalignmm.o \
|
||||
tbfast2.o defs.o fft.o fftFunctions.o
|
||||
OBJSETCORE = mtxutl.o io.o mltaln9.o tddis.o constants.o partSalignmm.o Lalignmm.o rna.o Salignmm.o \
|
||||
Falign.o Falign_localhom.o Galign11.o SAalignmm.o MSalignmm.o \
|
||||
setcore.o defs.o fft.o fftFunctions.o
|
||||
OBJTDITR = mtxutl.o io.o mltaln9.o tddis.o constants.o nj.o partSalignmm.o Lalignmm.o rna.o Salignmm.o \
|
||||
Falign.o Falign_localhom.o Galign11.o fftFunctions.o fft.o \
|
||||
tditeration.o tditr.o defs.o SAalignmm.o treeOperation.o
|
||||
OBJDVTDITR = mtxutl.o io.o mltaln9.o tddis.o constants.o nj.o partSalignmm.o Lalignmm.o rna.o Salignmm.o \
|
||||
Falign.o Falign_localhom.o Galign11.o MSalignmm.o fftFunctions.o fft.o \
|
||||
tditeration.o dvtditr.o defs.o SAalignmm.o treeOperation.o addfunctions.o
|
||||
OBJGETLAG = mtxutl.o io.o mltaln9.o tddis.o constants.o partSalignmm.o Lalignmm.o rna.o Salignmm.o \
|
||||
Falign.o Falign_localhom.o Galign11.o SAalignmm.o MSalignmm.o \
|
||||
getlag.o defs.o fft.o fftFunctions.o
|
||||
OBJGAPFILL = mtxutl.o io.o constants.o gapfill.o defs.o
|
||||
OBJDNDFAST5 = dndfast5.o io.o constants.o mtxutl.o mltaln9.o tddis.o defs.o
|
||||
OBJDNDBLAST = dndblast.o io.o constants.o mtxutl.o mltaln9.o tddis.o defs.o
|
||||
OBJDNDFAST7 = dndfast7.o io.o constants.o mtxutl.o mltaln9.o tddis.o defs.o
|
||||
OBJDNDFAST6 = dndfast6.o io.o constants.o mtxutl.o mltaln9.o tddis.o defs.o
|
||||
OBJDNDFAST4 = dndfast4.o io.o constants.o mtxutl.o mltaln9.o tddis.o defs.o
|
||||
OBJDNDFAST6 = dndfast6.o io.o constants.o mtxutl.o mltaln9.o tddis.o defs.o
|
||||
OBJSEXTET5 = io.o constants.o mtxutl.o mltaln9.o tddis.o sextet5.o defs.o
|
||||
OBJDISTANCE = io.o constants.o mtxutl.o mltaln9.o tddis.o mafft-distance.o defs.o
|
||||
OBJTRIPLET6 = io.o constants.o mtxutl.o mltaln9.o tddis.o triplet6.o defs.o
|
||||
OBJTRIPLET5 = io.o constants.o mtxutl.o mltaln9.o tddis.o triplet5.o defs.o
|
||||
OBJOCTET4 = io.o constants.o mtxutl.o mltaln9.o tddis.o octet4.o defs.o
|
||||
OBJDNDPRE = dndpre.o io.o constants.o mtxutl.o mltaln9.o defs.o
|
||||
OBJGALN = io.o mtxutl.o mltaln9.o tddis.o constants.o partSalignmm.o MSalignmm.o Lalignmm.o rna.o Salignmm.o \
|
||||
SAalignmm.o Galign11.o Falign.o Falign_localhom.o fftFunctions.o fft.o mafft-profile.o defs.o
|
||||
OBJSCORE = io.o mtxutl.o mltaln9.o score.o constants.o defs.o
|
||||
|
||||
HEADER = mltaln.h mtxutl.h mafft.h
|
||||
FFTHEADER = fft.h
|
||||
|
||||
MANPAGES = mafft.1 mafft-homologs.1
|
||||
|
||||
|
||||
|
||||
|
||||
all : $(PERLPROGS) $(PROGS) $(SCRIPTS)
|
||||
cp $(SCRIPTS) ../scripts
|
||||
chmod 755 ../scripts/*
|
||||
cp $(PERLPROGS) $(PROGS) ../binaries
|
||||
chmod 755 ../binaries/*
|
||||
cp $(MANPAGES) ../binaries
|
||||
@echo done.
|
||||
|
||||
sos : $(SOS)
|
||||
dylibs : $(DYLIBS)
|
||||
dlls : $(DLLS)
|
||||
|
||||
univscript: univscript.tmpl Makefile
|
||||
sed "s:_PROGS:$(PROGS):" univscript.tmpl > univscript
|
||||
|
||||
mafft: mafft.tmpl mltaln.h
|
||||
sed "s:_LIBDIR:$(LIBDIR):" mafft.tmpl > mafft
|
||||
|
||||
mafft-homologs.rb: mafft-homologs.tmpl
|
||||
# cp mafft-homologs.tmpl mafft-homologs.rb
|
||||
sed "s:_BINDIR:$(BINDIR):" mafft-homologs.tmpl > mafft-homologs.rb
|
||||
|
||||
mltaln.h : functions.h
|
||||
touch mltaln.h
|
||||
|
||||
version : version.c mltaln.h
|
||||
$(CC) -o $@ version.c $(MYCFLAGS) $(LDFLAGS)
|
||||
|
||||
tbfast : $(OBJTBFAST)
|
||||
$(CC) -o $@ $(OBJTBFAST) $(MYCFLAGS) $(LDFLAGS) $(LIBS)
|
||||
|
||||
addsingle : $(OBJADDSINGLE)
|
||||
$(CC) -o $@ $(OBJADDSINGLE) $(MYCFLAGS) $(LDFLAGS) $(LIBS)
|
||||
|
||||
tbfast2 : $(OBJTBFAST2)
|
||||
$(CC) -o $@ $(OBJTBFAST2) $(MYCFLAGS) $(LDFLAGS) $(LIBS)
|
||||
|
||||
disttbfast : $(OBJDISTTBFAST)
|
||||
$(CC) -o $@ $(OBJDISTTBFAST) $(MYCFLAGS) $(LDFLAGS) $(LIBS)
|
||||
|
||||
libdisttbfast.so : $(OBJDISTTBFAST)
|
||||
$(CC) -shared -o $@ $(OBJDISTTBFAST) $(MYCFLAGS) $(LDFLAGS) $(LIBS)
|
||||
|
||||
libdisttbfast.dylib : $(OBJDISTTBFAST)
|
||||
$(CC) -dynamiclib -o $@ $(OBJDISTTBFAST) $(MYCFLAGS) $(LDFLAGS) $(LIBS)
|
||||
|
||||
libdisttbfast.dll : $(OBJDISTTBFAST)
|
||||
$(CC) -shared -o $@ $(OBJDISTTBFAST) $(MYCFLAGS) $(LDFLAGS) $(LIBS)
|
||||
|
||||
makedirectionlist : $(OBJMAKEDIRECTIONLIST)
|
||||
$(CC) -o $@ $(OBJMAKEDIRECTIONLIST) $(MYCFLAGS) $(LDFLAGS) $(LIBS)
|
||||
|
||||
splittbfast : $(OBJSPLITTBFAST)
|
||||
$(CC) -o $@ $(OBJSPLITTBFAST) $(MYCFLAGS) $(LDFLAGS) $(LIBS)
|
||||
|
||||
splitfromaln : $(OBJSPLITFROMALN)
|
||||
$(CC) -o $@ $(OBJSPLITFROMALN) $(MYCFLAGS) $(LDFLAGS) $(LIBS)
|
||||
|
||||
splittbfast2 : $(OBJSPLITTBFAST2)
|
||||
$(CC) -o $@ $(OBJSPLITTBFAST2) $(MYCFLAGS) $(LDFLAGS) $(LIBS)
|
||||
|
||||
dummy : $(OBJDUMMY)
|
||||
$(CC) -o $@ $(OBJDUMMY) $(MYCFLAGS) $(LDFLAGS) $(LIBS)
|
||||
|
||||
setcore : $(OBJSETCORE)
|
||||
$(CC) -o $@ $(OBJSETCORE) $(MYCFLAGS) $(LDFLAGS) $(LIBS)
|
||||
|
||||
countlen : $(OBJCOUNTLEN)
|
||||
$(CC) -o $@ $(OBJCOUNTLEN) $(MYCFLAGS) $(LDFLAGS) $(LIBS)
|
||||
|
||||
seq2regtable : $(OBJSEQ2REGTABLE)
|
||||
$(CC) -o $@ $(OBJSEQ2REGTABLE) $(MYCFLAGS) $(LDFLAGS) $(LIBS)
|
||||
|
||||
regtable2seq : $(OBJREGTABLE2SEQ)
|
||||
$(CC) -o $@ $(OBJREGTABLE2SEQ) $(MYCFLAGS) $(LDFLAGS) $(LIBS)
|
||||
|
||||
setdirection : $(OBJSETDIRECTION)
|
||||
$(CC) -o $@ $(OBJSETDIRECTION) $(MYCFLAGS) $(LDFLAGS) $(LIBS)
|
||||
|
||||
replaceu : $(OBJREPLACEU)
|
||||
$(CC) -o $@ $(OBJREPLACEU) $(MYCFLAGS) $(LDFLAGS) $(LIBS)
|
||||
|
||||
restoreu : $(OBJRESTOREU)
|
||||
$(CC) -o $@ $(OBJRESTOREU) $(MYCFLAGS) $(LDFLAGS) $(LIBS)
|
||||
|
||||
f2cl : $(OBJF2CL)
|
||||
$(CC) -o $@ $(OBJF2CL) $(MYCFLAGS) $(LDFLAGS) $(LIBS)
|
||||
|
||||
mccaskillwrap : $(OBJMCCASKILLWRAP)
|
||||
$(CC) -o $@ $(OBJMCCASKILLWRAP) $(MYCFLAGS) $(LDFLAGS) $(LIBS)
|
||||
|
||||
contrafoldwrap : $(OBJCONTRAFOLDWRAP)
|
||||
$(CC) -o $@ $(OBJCONTRAFOLDWRAP) $(MYCFLAGS) $(LDFLAGS) $(LIBS)
|
||||
|
||||
pairlocalalign : $(OBJPAIRLOCALALIGN)
|
||||
$(CC) -o $@ $(OBJPAIRLOCALALIGN) $(MYCFLAGS) $(LDFLAGS) $(LIBS)
|
||||
|
||||
pairash : $(OBJPAIRASH)
|
||||
$(CC) -o $@ $(OBJPAIRASH) $(MYCFLAGS) $(LDFLAGS) $(LIBS)
|
||||
|
||||
pair2hat3s : $(OBJPAIR2HAT3S)
|
||||
$(CC) -o $@ $(OBJPAIR2HAT3S) $(MYCFLAGS) $(LDFLAGS) $(LIBS)
|
||||
|
||||
multi2hat3s : $(OBJMULTI2HAT3S)
|
||||
$(CC) -o $@ $(OBJMULTI2HAT3S) $(MYCFLAGS) $(LDFLAGS) $(LIBS)
|
||||
|
||||
getlag : $(OBJGETLAG)
|
||||
$(CC) -o $@ $(OBJGETLAG) $(MYCFLAGS) $(LDFLAGS) $(LIBS)
|
||||
|
||||
tditr : $(OBJTDITR)
|
||||
$(CC) -o $@ $(OBJTDITR) $(MYCFLAGS) $(LDFLAGS) $(LIBS)
|
||||
|
||||
dvtditr : $(OBJDVTDITR)
|
||||
$(CC) -o $@ $(OBJDVTDITR) $(MYCFLAGS) $(LDFLAGS) $(LIBS)
|
||||
|
||||
mafft-profile : $(OBJGALN)
|
||||
$(CC) -o $@ $(OBJGALN) $(MYCFLAGS) $(LDFLAGS) $(LIBS)
|
||||
|
||||
gapfill : $(OBJGAPFILL)
|
||||
$(CC) -o $@ $(OBJGAPFILL) $(MYCFLAGS) $(LDFLAGS) $(LIBS)
|
||||
|
||||
dndfast4 : $(OBJDNDFAST4)
|
||||
$(CC) -o $@ $(OBJDNDFAST4) $(MYCFLAGS) $(LDFLAGS) $(LIBS)
|
||||
|
||||
dndfast5 : $(OBJDNDFAST5)
|
||||
$(CC) -o $@ $(OBJDNDFAST5) $(MYCFLAGS) $(LDFLAGS) $(LIBS)
|
||||
|
||||
dndfast6 : $(OBJDNDFAST6)
|
||||
$(CC) -o $@ $(OBJDNDFAST6) $(MYCFLAGS) $(LDFLAGS) $(LIBS)
|
||||
|
||||
dndfast7 : $(OBJDNDFAST7)
|
||||
$(CC) -o $@ $(OBJDNDFAST7) $(MYCFLAGS) $(LDFLAGS) $(LIBS)
|
||||
|
||||
dndblast : $(OBJDNDBLAST)
|
||||
$(CC) -o $@ $(OBJDNDBLAST) $(MYCFLAGS) $(LDFLAGS) $(LIBS)
|
||||
|
||||
dndfast3 : $(OBJDNDFAST3)
|
||||
$(CC) -o $@ $(OBJDNDFAST3) $(MYCFLAGS) $(LDFLAGS) $(LIBS)
|
||||
|
||||
triplet : $(OBJTRIPLET)
|
||||
$(CC) -o $@ $(OBJTRIPLET) $(MYCFLAGS) $(LDFLAGS) $(LIBS)
|
||||
|
||||
triplet3 : $(OBJTRIPLET3)
|
||||
$(CC) -o $@ $(OBJTRIPLET3) $(MYCFLAGS) $(LDFLAGS) $(LIBS)
|
||||
|
||||
sextet3 : $(OBJSEXTET3)
|
||||
$(CC) -o $@ $(OBJSEXTET3) $(MYCFLAGS) $(LDFLAGS) $(LIBS)
|
||||
|
||||
sextet4 : $(OBJSEXTET4)
|
||||
$(CC) -o $@ $(OBJSEXTET4) $(MYCFLAGS) $(LDFLAGS) $(LIBS)
|
||||
|
||||
sextet5 : $(OBJSEXTET5)
|
||||
$(CC) -o $@ $(OBJSEXTET5) $(MYCFLAGS) $(LDFLAGS) $(LIBS)
|
||||
|
||||
mafft-distance : $(OBJDISTANCE)
|
||||
$(CC) -o $@ $(OBJDISTANCE) $(MYCFLAGS) $(LDFLAGS) $(LIBS)
|
||||
|
||||
triplet5 : $(OBJTRIPLET5)
|
||||
$(CC) -o $@ $(OBJTRIPLET5) $(MYCFLAGS) $(LDFLAGS) $(LIBS)
|
||||
|
||||
triplet6 : $(OBJTRIPLET6)
|
||||
$(CC) -o $@ $(OBJTRIPLET6) $(MYCFLAGS) $(LDFLAGS) $(LIBS)
|
||||
|
||||
octet4 : $(OBJOCTET4)
|
||||
$(CC) -o $@ $(OBJOCTET4) $(MYCFLAGS) $(LDFLAGS) $(LIBS)
|
||||
|
||||
dndpre : $(OBJDNDPRE)
|
||||
$(CC) -o $@ $(OBJDNDPRE) $(MYCFLAGS) $(LDFLAGS) $(LIBS)
|
||||
|
||||
score : $(OBJSCORE)
|
||||
$(CC) -o $@ $(OBJSCORE) $(MYCFLAGS) $(LDFLAGS) $(LIBS)
|
||||
|
||||
genMtx : $(OBJGENMTX)
|
||||
$(CC) -o $@ $(OBJGENMTX) $(MYCFLAGS) $(LDFLAGS) $(LIBS)
|
||||
|
||||
mafftash_premafft.pl : mafftash_premafft.tmpl
|
||||
cp mafftash_premafft.tmpl mafftash_premafft.pl
|
||||
|
||||
seekquencer_premafft.pl : seekquencer_premafft.tmpl
|
||||
cp seekquencer_premafft.tmpl seekquencer_premafft.pl
|
||||
|
||||
gapfill.o : gapfill.c $(HEADER)
|
||||
$(CC) $(MYCFLAGS) -c gapfill.c
|
||||
|
||||
mltaln9.o : mltaln9.c $(HEADER)
|
||||
$(CC) $(MYCFLAGS) -c mltaln9.c
|
||||
|
||||
tddis.o : tddis.c $(HEADER)
|
||||
$(CC) $(MYCFLAGS) -c tddis.c
|
||||
|
||||
constants.o : constants.c miyata.h miyata5.h blosum.c DNA.h JTT.c $(HEADER)
|
||||
$(CC) $(MYCFLAGS) -c constants.c
|
||||
|
||||
defs.o : defs.c
|
||||
$(CC) $(MYCFLAGS) -c defs.c
|
||||
|
||||
#A+++alignmm.o : SA+++alignmm.c $(HEADER)
|
||||
# $(CC) $(MYCFLAGS) -c SA+++alignmm.c -o A+++alignmm.o
|
||||
|
||||
Salignmm.o : Salignmm.c $(HEADER)
|
||||
$(CC) $(MYCFLAGS) -c Salignmm.c
|
||||
|
||||
MSalignmm.o : MSalignmm.c $(HEADER)
|
||||
$(CC) $(MYCFLAGS) -c MSalignmm.c
|
||||
|
||||
partSalignmm.o : partSalignmm.c $(HEADER)
|
||||
$(CC) $(MYCFLAGS) -c partSalignmm.c
|
||||
|
||||
Lalign11.o : Lalign11.c $(HEADER)
|
||||
$(CC) $(MYCFLAGS) -c Lalign11.c
|
||||
|
||||
genalign11.o : genalign11.c $(HEADER)
|
||||
$(CC) $(MYCFLAGS) -c genalign11.c
|
||||
|
||||
suboptalign11.o : suboptalign11.c $(HEADER)
|
||||
$(CC) $(MYCFLAGS) -c suboptalign11.c
|
||||
|
||||
Galign11.o : Galign11.c $(HEADER)
|
||||
$(CC) $(MYCFLAGS) -c Galign11.c
|
||||
|
||||
MSalign11.o : MSalign11.c $(HEADER)
|
||||
$(CC) $(MYCFLAGS) -c MSalign11.c
|
||||
|
||||
SAalignmm.o : SAalignmm.c $(HEADER)
|
||||
$(CC) $(MYCFLAGS) -c SAalignmm.c -o SAalignmm.o
|
||||
|
||||
Lalignmm.o : Lalignmm.c $(HEADER)
|
||||
$(CC) $(MYCFLAGS) -c Lalignmm.c
|
||||
|
||||
rna.o : rna.c $(HEADER)
|
||||
$(CC) $(MYCFLAGS) -c rna.c
|
||||
|
||||
disttbfast.o : disttbfast.c $(HEADER) $(FFTHEADER)
|
||||
$(CC) $(MYCFLAGS) -c disttbfast.c
|
||||
|
||||
splitfromaln.o : splitfromaln.c $(HEADER) $(FFTHEADER)
|
||||
$(CC) $(MYCFLAGS) -c splitfromaln.c
|
||||
|
||||
splittbfast.o : splittbfast.c $(HEADER) $(FFTHEADER)
|
||||
$(CC) $(MYCFLAGS) -c splittbfast.c
|
||||
|
||||
splittbfast2.o : splittbfast2.c $(HEADER) $(FFTHEADER)
|
||||
$(CC) $(MYCFLAGS) -c splittbfast2.c
|
||||
|
||||
makedirectionlist.o : makedirectionlist.c $(HEADER) $(FFTHEADER)
|
||||
$(CC) $(MYCFLAGS) -c makedirectionlist.c
|
||||
|
||||
disttbfast_dummy.o : disttbfast_dummy.c $(HEADER) $(FFTHEADER)
|
||||
$(CC) $(MYCFLAGS) -c disttbfast_dummy.c
|
||||
|
||||
dummy.o : dummy.c $(HEADER) $(FFTHEADER)
|
||||
$(CC) $(MYCFLAGS) -c dummy.c
|
||||
|
||||
tbfast.o : tbfast.c $(HEADER) $(FFTHEADER)
|
||||
$(CC) $(MYCFLAGS) -c tbfast.c
|
||||
|
||||
addsingle.o : addsingle.c $(HEADER) $(FFTHEADER)
|
||||
$(CC) $(MYCFLAGS) -c addsingle.c
|
||||
|
||||
tbfast2.o : tbfast2.c $(HEADER) $(FFTHEADER)
|
||||
$(CC) $(MYCFLAGS) -c tbfast2.c
|
||||
|
||||
setcore.o : setcore.c $(HEADER) $(FFTHEADER)
|
||||
$(CC) $(MYCFLAGS) -c setcore.c
|
||||
|
||||
getlag.o : getlag.c $(HEADER) $(FFTHEADER)
|
||||
$(CC) $(MYCFLAGS) -c getlag.c
|
||||
|
||||
tditr.o : tditr.c $(HEADER)
|
||||
$(CC) $(MYCFLAGS) -c tditr.c
|
||||
|
||||
dvtditr.o : dvtditr.c $(HEADER)
|
||||
$(CC) $(MYCFLAGS) -c dvtditr.c
|
||||
|
||||
tditeration.o : tditeration.c $(HEADER)
|
||||
$(CC) $(MYCFLAGS) -c tditeration.c
|
||||
|
||||
mafft-profile.o : mafft-profile.c $(HEADER) $(MTXHEADER)
|
||||
$(CC) $(MYCFLAGS) -c mafft-profile.c
|
||||
|
||||
dndfast4.o : dndfast4.c $(HEADER) $(MTXHEADER)
|
||||
$(CC) $(MYCFLAGS) -c dndfast4.c
|
||||
|
||||
dndfast5.o : dndfast5.c $(HEADER) $(MTXHEADER)
|
||||
$(CC) $(MYCFLAGS) -c dndfast5.c
|
||||
|
||||
dndfast6.o : dndfast6.c $(HEADER) $(MTXHEADER)
|
||||
$(CC) $(MYCFLAGS) -c dndfast6.c
|
||||
|
||||
dndfast7.o : dndfast7.c $(HEADER) $(MTXHEADER)
|
||||
$(CC) $(MYCFLAGS) -c dndfast7.c
|
||||
|
||||
dndblast.o : dndblast.c $(HEADER) $(MTXHEADER)
|
||||
$(CC) $(MYCFLAGS) -c dndblast.c
|
||||
|
||||
dndfast3.o : dndfast3.c $(HEADER) $(MTXHEADER)
|
||||
$(CC) $(MYCFLAGS) -c dndfast3.c
|
||||
|
||||
dndpre.o : dndpre.c $(HEADER)
|
||||
$(CC) $(MYCFLAGS) -c dndpre.c
|
||||
|
||||
countlen.o : countlen.c $(HEADER)
|
||||
$(CC) $(MYCFLAGS) -c countlen.c
|
||||
|
||||
seq2regtable.o : seq2regtable.c $(HEADER)
|
||||
$(CC) $(MYCFLAGS) -c seq2regtable.c
|
||||
|
||||
regtable2seq.o : regtable2seq.c $(HEADER)
|
||||
$(CC) $(MYCFLAGS) -c regtable2seq.c
|
||||
|
||||
f2cl.o : f2cl.c $(HEADER)
|
||||
$(CC) $(MYCFLAGS) -c f2cl.c
|
||||
|
||||
setdirection.o : setdirection.c $(HEADER)
|
||||
$(CC) $(MYCFLAGS) -c setdirection.c
|
||||
|
||||
replaceu.o : replaceu.c $(HEADER)
|
||||
$(CC) $(MYCFLAGS) -c replaceu.c
|
||||
|
||||
restoreu.o : restoreu.c $(HEADER)
|
||||
$(CC) $(MYCFLAGS) -c restoreu.c
|
||||
|
||||
mccaskillwrap.o : mccaskillwrap.c $(HEADER)
|
||||
$(CC) $(MYCFLAGS) -c mccaskillwrap.c
|
||||
|
||||
contrafoldwrap.o : contrafoldwrap.c $(HEADER)
|
||||
$(CC) $(MYCFLAGS) -c contrafoldwrap.c
|
||||
|
||||
pairlocalalign.o : pairlocalalign.c $(HEADER) $(FFTHEADER)
|
||||
$(CC) $(MYCFLAGS) -c pairlocalalign.c
|
||||
|
||||
pairash.o : pairash.c $(HEADER) $(FFTHEADER)
|
||||
$(CC) $(MYCFLAGS) -c pairash.c
|
||||
|
||||
multi2hat3s.o : multi2hat3s.c $(HEADER) $(FFTHEADER)
|
||||
$(CC) $(MYCFLAGS) -c multi2hat3s.c
|
||||
|
||||
pair2hat3s.o : pair2hat3s.c $(HEADER) $(FFTHEADER)
|
||||
$(CC) $(MYCFLAGS) -c pair2hat3s.c
|
||||
|
||||
io.o : io.c $(HEADER) $(FFTHEADER)
|
||||
$(CC) $(MYCFLAGS) -c io.c
|
||||
|
||||
nj.o : nj.c $(HEADER)
|
||||
$(CC) $(MYCFLAGS) -c nj.c
|
||||
|
||||
treeOperation.o : treeOperation.c $(HEADER)
|
||||
$(CC) $(MYCFLAGS) -c treeOperation.c
|
||||
|
||||
sextet5.o : sextet5.c $(HEADER) $(MTXHEADER)
|
||||
$(CC) $(MYCFLAGS) -c sextet5.c
|
||||
|
||||
mafft-distance.o : mafft-distance.c $(HEADER) $(MTXHEADER)
|
||||
$(CC) $(MYCFLAGS) -c mafft-distance.c
|
||||
|
||||
triplet5.o : triplet5.c $(HEADER) $(MTXHEADER)
|
||||
$(CC) $(MYCFLAGS) -c triplet5.c
|
||||
|
||||
triplet6.o : triplet6.c $(HEADER) $(MTXHEADER)
|
||||
$(CC) $(MYCFLAGS) -c triplet6.c
|
||||
|
||||
fft.o : fft.c $(HEADER) $(FFTHEADER)
|
||||
$(CC) $(MYCFLAGS) -c fft.c
|
||||
|
||||
fftFunctions.o : fftFunctions.c $(HEADER) $(FFTHEADER)
|
||||
$(CC) $(MYCFLAGS) -c fftFunctions.c
|
||||
|
||||
Falign.o : Falign.c $(HEADER) $(FFTHEADER) $(MTXHEADER)
|
||||
$(CC) $(MYCFLAGS) -c Falign.c
|
||||
|
||||
Falign_localhom.o : Falign_localhom.c $(HEADER) $(FFTHEADER) $(MTXHEADER)
|
||||
$(CC) $(MYCFLAGS) -c Falign_localhom.c
|
||||
|
||||
mtxutl.o : mtxutl.c
|
||||
$(CC) $(MYCFLAGS) -c mtxutl.c
|
||||
|
||||
addfunctions.o : addfunctions.c $(HEADER)
|
||||
$(CC) $(MYCFLAGS) -c addfunctions.c
|
||||
|
||||
score.o : score.c $(HEADER)
|
||||
$(CC) $(MYCFLAGS) -c score.c
|
||||
|
||||
clean :
|
||||
rm -f *.o *.a *.exe *~ $(PERLPROGS) $(PROGS) $(SCRIPTS) $(SOS) $(DYLIBS) $(DLLS)
|
||||
# rm -f ../binaries/* ../scripts/*
|
||||
|
||||
install : all
|
||||
mkdir -p $(LIBDIR)
|
||||
chmod 755 $(LIBDIR)
|
||||
mkdir -p $(BINDIR)
|
||||
chmod 755 $(BINDIR)
|
||||
chmod 755 $(SCRIPTS)
|
||||
$(INSTALL) $(SCRIPTS) $(BINDIR)
|
||||
chmod 755 $(PROGS)
|
||||
$(INSTALL) -s $(PROGS) $(LIBDIR)
|
||||
$(INSTALL) $(PERLPROGS) $(LIBDIR)
|
||||
$(INSTALL) -m 644 $(MANPAGES) $(LIBDIR)
|
||||
|
||||
( cd $(BINDIR); \
|
||||
rm -f linsi ginsi einsi fftns fftnsi nwns nwnsi xinsi qinsi; \
|
||||
rm -f mafft-linsi mafft-ginsi mafft-einsi mafft-fftns mafft-fftnsi mafft-nwns mafft-nwnsi mafft-xinsi mafft-qinsi; \
|
||||
ln -s mafft linsi; ln -s mafft ginsi; ln -s mafft fftns; \
|
||||
ln -s mafft fftnsi; ln -s mafft nwns; ln -s mafft nwnsi; \
|
||||
ln -s mafft einsi; \
|
||||
ln -s mafft mafft-linsi; ln -s mafft mafft-ginsi; ln -s mafft mafft-fftns; \
|
||||
ln -s mafft mafft-fftnsi; ln -s mafft mafft-nwns; ln -s mafft mafft-nwnsi; \
|
||||
ln -s mafft mafft-einsi; ln -s mafft mafft-xinsi; ln -s mafft mafft-qinsi;\
|
||||
rm -f mafft-profile mafft-profile.exe; ln -s $(LIBDIR)/mafft-profile .; \
|
||||
rm -f mafft-distance mafft-distance.exe; ln -s $(LIBDIR)/mafft-distance . )
|
||||
|
||||
mkdir -p $(MANDIR)
|
||||
chmod 755 $(MANDIR)
|
||||
$(INSTALL) -m 644 $(MANPAGES) $(MANDIR)
|
||||
# remove incorrectly installed manpages by previous versions
|
||||
# rm -f /usr/local/man/man1/mafft.1 /usr/local/man/man1/mafft-homologs.1
|
381
mafft/src/mafft-7.487-with-extensions/core/SAalignmm.c
Normal file
381
mafft/src/mafft-7.487-with-extensions/core/SAalignmm.c
Normal file
|
@ -0,0 +1,381 @@
|
|||
#include "mltaln.h"
|
||||
#include "dp.h"
|
||||
|
||||
#define DEBUG 0
|
||||
|
||||
static void match_calc( double *match, double **cpmx1, double **cpmx2, int i1, int lgth2, double **doublework, int **intwork, int initialize )
|
||||
{
|
||||
int j, k, l;
|
||||
// double scarr[26];
|
||||
double **cpmxpd = doublework;
|
||||
int **cpmxpdn = intwork;
|
||||
int count = 0;
|
||||
double *scarr;
|
||||
scarr = calloc( nalphabets, sizeof( double ) );
|
||||
|
||||
if( initialize )
|
||||
{
|
||||
for( j=0; j<lgth2; j++ )
|
||||
{
|
||||
count = 0;
|
||||
for( l=0; l<nalphabets; l++ )
|
||||
{
|
||||
if( cpmx2[l][j] )
|
||||
{
|
||||
cpmxpd[count][j] = cpmx2[l][j];
|
||||
cpmxpdn[count][j] = l;
|
||||
count++;
|
||||
}
|
||||
}
|
||||
cpmxpdn[count][j] = -1;
|
||||
}
|
||||
}
|
||||
|
||||
for( l=0; l<nalphabets; l++ )
|
||||
{
|
||||
scarr[l] = 0.0;
|
||||
for( k=0; k<nalphabets; k++ )
|
||||
scarr[l] += n_dis[k][l] * cpmx1[k][i1];
|
||||
}
|
||||
for( j=0; j<lgth2; j++ )
|
||||
{
|
||||
match[j] = 0;
|
||||
for( k=0; cpmxpdn[k][j] > -1; k++ )
|
||||
match[j] += scarr[cpmxpdn[k][j]] * cpmxpd[k][j];
|
||||
}
|
||||
free( scarr );
|
||||
}
|
||||
|
||||
static double Atracking( double *lasthorizontalw, double *lastverticalw,
|
||||
char **seq1, char **seq2,
|
||||
char **mseq1, char **mseq2,
|
||||
double **cpmx1, double **cpmx2,
|
||||
int **ijp, int icyc, int jcyc )
|
||||
{
|
||||
int i, j, k, l, iin, jin, ifi, jfi, lgth1, lgth2;
|
||||
// char gap[] = "-";
|
||||
char *gap;
|
||||
double wm;
|
||||
gap = newgapstr;
|
||||
lgth1 = strlen( seq1[0] );
|
||||
lgth2 = strlen( seq2[0] );
|
||||
|
||||
#if DEBUG
|
||||
for( i=0; i<lgth1; i++ )
|
||||
{
|
||||
fprintf( stderr, "lastverticalw[%d] = %f\n", i, lastverticalw[i] );
|
||||
}
|
||||
#endif
|
||||
|
||||
if( outgap == 1 )
|
||||
;
|
||||
else
|
||||
{
|
||||
wm = lastverticalw[0];
|
||||
for( i=0; i<lgth1; i++ )
|
||||
{
|
||||
if( lastverticalw[i] >= wm )
|
||||
{
|
||||
wm = lastverticalw[i];
|
||||
iin = i; jin = lgth2-1;
|
||||
ijp[lgth1][lgth2] = +( lgth1 - i );
|
||||
}
|
||||
}
|
||||
for( j=0; j<lgth2; j++ )
|
||||
{
|
||||
if( lasthorizontalw[j] >= wm )
|
||||
{
|
||||
wm = lasthorizontalw[j];
|
||||
iin = lgth1-1; jin = j;
|
||||
ijp[lgth1][lgth2] = -( lgth2 - j );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for( i=0; i<lgth1+1; i++ )
|
||||
{
|
||||
ijp[i][0] = i + 1;
|
||||
}
|
||||
for( j=0; j<lgth2+1; j++ )
|
||||
{
|
||||
ijp[0][j] = -( j + 1 );
|
||||
}
|
||||
|
||||
for( i=0; i<icyc; i++ )
|
||||
{
|
||||
mseq1[i] += lgth1+lgth2;
|
||||
*mseq1[i] = 0;
|
||||
}
|
||||
for( j=0; j<jcyc; j++ )
|
||||
{
|
||||
mseq2[j] += lgth1+lgth2;
|
||||
*mseq2[j] = 0;
|
||||
}
|
||||
iin = lgth1; jin = lgth2;
|
||||
for( k=0; k<=lgth1+lgth2; k++ )
|
||||
{
|
||||
if( ijp[iin][jin] < 0 )
|
||||
{
|
||||
ifi = iin-1; jfi = jin+ijp[iin][jin];
|
||||
}
|
||||
else if( ijp[iin][jin] > 0 )
|
||||
{
|
||||
ifi = iin-ijp[iin][jin]; jfi = jin-1;
|
||||
}
|
||||
else
|
||||
{
|
||||
ifi = iin-1; jfi = jin-1;
|
||||
}
|
||||
l = iin - ifi;
|
||||
while( --l )
|
||||
{
|
||||
for( i=0; i<icyc; i++ )
|
||||
*--mseq1[i] = seq1[i][ifi+l];
|
||||
for( j=0; j<jcyc; j++ )
|
||||
*--mseq2[j] = *gap;
|
||||
k++;
|
||||
}
|
||||
l= jin - jfi;
|
||||
while( --l )
|
||||
{
|
||||
for( i=0; i<icyc; i++ )
|
||||
*--mseq1[i] = *gap;
|
||||
for( j=0; j<jcyc; j++ )
|
||||
*--mseq2[j] = seq2[j][jfi+l];
|
||||
k++;
|
||||
}
|
||||
if( iin <= 0 || jin <= 0 ) break;
|
||||
for( i=0; i<icyc; i++ )
|
||||
*--mseq1[i] = seq1[i][ifi];
|
||||
for( j=0; j<jcyc; j++ )
|
||||
*--mseq2[j] = seq2[j][jfi];
|
||||
k++;
|
||||
iin = ifi; jin = jfi;
|
||||
}
|
||||
return( 0.0 );
|
||||
}
|
||||
|
||||
|
||||
double Aalign( char **seq1, char **seq2, double *eff1, double *eff2, int icyc, int jcyc, int alloclen )
|
||||
/* score no keisan no sai motokaraaru gap no atukai ni mondai ga aru */
|
||||
{
|
||||
register int i, j;
|
||||
int lasti; /* outgap == 0 -> lgth1, outgap == 1 -> lgth1+1 */
|
||||
int lgth1, lgth2;
|
||||
int resultlen;
|
||||
double wm = 0.0; /* int ?????? */
|
||||
double g;
|
||||
double x;
|
||||
static TLS double mi, *m;
|
||||
static TLS int **ijp;
|
||||
static TLS int mpi, *mp;
|
||||
static TLS double *currentw;
|
||||
static TLS double *previousw;
|
||||
static TLS double *match;
|
||||
static TLS double *initverticalw; /* kufuu sureba iranai */
|
||||
static TLS double *lastverticalw; /* kufuu sureba iranai */
|
||||
static TLS char **mseq1;
|
||||
static TLS char **mseq2;
|
||||
static TLS char **mseq;
|
||||
static TLS double **cpmx1;
|
||||
static TLS double **cpmx2;
|
||||
static TLS int **intwork;
|
||||
static TLS double **doublework;
|
||||
static TLS int orlgth1 = 0, orlgth2 = 0;
|
||||
|
||||
#if DEBUG
|
||||
fprintf( stderr, "eff in SA+++align\n" );
|
||||
for( i=0; i<icyc; i++ ) fprintf( stderr, "eff1[%d] = %f\n", i, eff1[i] );
|
||||
#endif
|
||||
if( orlgth1 == 0 )
|
||||
{
|
||||
mseq1 = AllocateCharMtx( njob, 1 );
|
||||
mseq2 = AllocateCharMtx( njob, 1 ); /* by J. Thompson */
|
||||
}
|
||||
|
||||
lgth1 = strlen( seq1[0] );
|
||||
lgth2 = strlen( seq2[0] );
|
||||
|
||||
if( lgth1 > orlgth1 || lgth2 > orlgth2 )
|
||||
{
|
||||
int ll1, ll2;
|
||||
|
||||
if( orlgth1 > 0 && orlgth2 > 0 )
|
||||
{
|
||||
FreeFloatVec( currentw );
|
||||
FreeFloatVec( previousw );
|
||||
FreeFloatVec( match );
|
||||
FreeFloatVec( initverticalw );
|
||||
FreeFloatVec( lastverticalw );
|
||||
|
||||
FreeFloatVec( m );
|
||||
FreeIntVec( mp );
|
||||
|
||||
FreeCharMtx( mseq );
|
||||
|
||||
FreeFloatMtx( cpmx1 );
|
||||
FreeFloatMtx( cpmx2 );
|
||||
|
||||
FreeFloatMtx( doublework );
|
||||
FreeIntMtx( intwork );
|
||||
}
|
||||
|
||||
ll1 = MAX( (int)(1.1*lgth1), orlgth1 ) + 100;
|
||||
ll2 = MAX( (int)(1.1*lgth2), orlgth2 ) + 100;
|
||||
|
||||
fprintf( stderr, "\ntrying to allocate (%d+%d)xn matrices ... ", ll1, ll2 );
|
||||
|
||||
currentw = AllocateFloatVec( ll2+2 );
|
||||
previousw = AllocateFloatVec( ll2+2 );
|
||||
match = AllocateFloatVec( ll2+2 );
|
||||
|
||||
initverticalw = AllocateFloatVec( ll1+2 );
|
||||
lastverticalw = AllocateFloatVec( ll1+2 );
|
||||
|
||||
m = AllocateFloatVec( ll2+2 );
|
||||
mp = AllocateIntVec( ll2+2 );
|
||||
|
||||
mseq = AllocateCharMtx( njob, ll1+ll2 );
|
||||
|
||||
cpmx1 = AllocateFloatMtx( nalphabets, ll1+2 );
|
||||
cpmx2 = AllocateFloatMtx( nalphabets, ll2+2 );
|
||||
|
||||
doublework = AllocateFloatMtx( nalphabets, MAX( ll1, ll2 )+2 );
|
||||
intwork = AllocateIntMtx( nalphabets, MAX( ll1, ll2 )+2 );
|
||||
|
||||
fprintf( stderr, "succeeded\n" );
|
||||
|
||||
orlgth1 = ll1;
|
||||
orlgth2 = ll2;
|
||||
}
|
||||
|
||||
for( i=0; i<icyc; i++ ) mseq1[i] = mseq[i];
|
||||
for( j=0; j<jcyc; j++ ) mseq2[j] = mseq[icyc+j];
|
||||
|
||||
|
||||
if( orlgth1 > commonAlloc1 || orlgth2 > commonAlloc2 )
|
||||
{
|
||||
int ll1, ll2;
|
||||
|
||||
if( commonAlloc1 && commonAlloc2 )
|
||||
{
|
||||
FreeIntMtx( commonIP );
|
||||
}
|
||||
|
||||
ll1 = MAX( orlgth1, commonAlloc1 );
|
||||
ll2 = MAX( orlgth2, commonAlloc2 );
|
||||
|
||||
fprintf( stderr, "\n\ntrying to allocate %dx%d matrices ... ", ll1+1, ll2+1 );
|
||||
|
||||
commonIP = AllocateIntMtx( ll1+10, ll2+10 );
|
||||
|
||||
fprintf( stderr, "succeeded\n\n" );
|
||||
|
||||
commonAlloc1 = ll1;
|
||||
commonAlloc2 = ll2;
|
||||
}
|
||||
ijp = commonIP;
|
||||
|
||||
cpmx_calc( seq1, cpmx1, eff1, strlen( seq1[0] ), icyc );
|
||||
cpmx_calc( seq2, cpmx2, eff2, strlen( seq2[0] ), jcyc );
|
||||
|
||||
match_calc( initverticalw, cpmx2, cpmx1, 0, lgth1, doublework, intwork, 1 );
|
||||
match_calc( currentw, cpmx1, cpmx2, 0, lgth2, doublework, intwork, 1 );
|
||||
|
||||
if( outgap == 1 )
|
||||
{
|
||||
for( i=1; i<lgth1+1; i++ )
|
||||
{
|
||||
initverticalw[i] += penalty * 0.5;
|
||||
}
|
||||
for( j=1; j<lgth2+1; j++ )
|
||||
{
|
||||
currentw[j] += penalty * 0.5;
|
||||
}
|
||||
}
|
||||
|
||||
for( j=0; j<lgth2+1; ++j )
|
||||
{
|
||||
m[j] = currentw[j-1] + penalty * 0.5; mp[j] = 0;
|
||||
}
|
||||
|
||||
lastverticalw[0] = currentw[lgth2-1];
|
||||
|
||||
if( outgap ) lasti = lgth1+1; else lasti = lgth1;
|
||||
|
||||
for( i=1; i<lasti; i++ )
|
||||
{
|
||||
|
||||
doublencpy( previousw, currentw, lgth2+1 );
|
||||
previousw[0] = initverticalw[i-1];
|
||||
|
||||
match_calc( currentw, cpmx1, cpmx2, i, lgth2, doublework, intwork, 0 );
|
||||
currentw[0] = initverticalw[i];
|
||||
|
||||
mi = previousw[0] + penalty * 0.5; mpi = 0;
|
||||
for( j=1; j<lgth2+1; j++ )
|
||||
{
|
||||
wm = previousw[j-1];
|
||||
ijp[i][j] = 0;
|
||||
|
||||
g = penalty * 0.5;
|
||||
x = mi + g;
|
||||
if( x > wm )
|
||||
{
|
||||
wm = x;
|
||||
ijp[i][j] = -( j - mpi );
|
||||
}
|
||||
g = penalty * 0.5;
|
||||
x = previousw[j-1] + g;
|
||||
if( mi <= x )
|
||||
{
|
||||
mi = x;
|
||||
mpi = j-1;
|
||||
}
|
||||
|
||||
g = penalty * 0.5;
|
||||
x = m[j] + g;
|
||||
if( x > wm )
|
||||
{
|
||||
wm = x;
|
||||
ijp[i][j] = +( i - mp[j] );
|
||||
}
|
||||
g = penalty * 0.5;
|
||||
x = previousw[j-1] + g;
|
||||
if( m[j] <= x )
|
||||
{
|
||||
m[j] = x;
|
||||
mp[j] = i-1;
|
||||
}
|
||||
currentw[j] += wm;
|
||||
}
|
||||
lastverticalw[i] = currentw[lgth2-1];
|
||||
}
|
||||
/*
|
||||
fprintf( stderr, "\n" );
|
||||
for( i=0; i<icyc; i++ ) fprintf( stderr,"%s\n", seq1[i] );
|
||||
fprintf( stderr, "#####\n" );
|
||||
for( j=0; j<jcyc; j++ ) fprintf( stderr,"%s\n", seq2[j] );
|
||||
fprintf( stderr, "====>" );
|
||||
for( i=0; i<icyc; i++ ) strcpy( mseq1[i], seq1[i] );
|
||||
for( j=0; j<jcyc; j++ ) strcpy( mseq2[j], seq2[j] );
|
||||
*/
|
||||
Atracking( currentw, lastverticalw, seq1, seq2, mseq1, mseq2, cpmx1, cpmx2, ijp, icyc, jcyc );
|
||||
|
||||
resultlen = strlen( mseq1[0] );
|
||||
if( alloclen < resultlen || resultlen > N )
|
||||
{
|
||||
fprintf( stderr, "alloclen=%d, resultlen=%d, N=%d\n", alloclen, resultlen, N );
|
||||
ErrorExit( "LENGTH OVER!\n" );
|
||||
}
|
||||
|
||||
for( i=0; i<icyc; i++ ) strcpy( seq1[i], mseq1[i] );
|
||||
for( j=0; j<jcyc; j++ ) strcpy( seq2[j], mseq2[j] );
|
||||
/*
|
||||
fprintf( stderr, "\n" );
|
||||
for( i=0; i<icyc; i++ ) fprintf( stderr, "%s\n", mseq1[i] );
|
||||
fprintf( stderr, "#####\n" );
|
||||
for( j=0; j<jcyc; j++ ) fprintf( stderr, "%s\n", mseq2[j] );
|
||||
*/
|
||||
return( wm );
|
||||
}
|
3099
mafft/src/mafft-7.487-with-extensions/core/Salignmm.c
Normal file
3099
mafft/src/mafft-7.487-with-extensions/core/Salignmm.c
Normal file
File diff suppressed because it is too large
Load diff
1851
mafft/src/mafft-7.487-with-extensions/core/addfunctions.c
Normal file
1851
mafft/src/mafft-7.487-with-extensions/core/addfunctions.c
Normal file
File diff suppressed because it is too large
Load diff
3795
mafft/src/mafft-7.487-with-extensions/core/addsingle.c
Normal file
3795
mafft/src/mafft-7.487-with-extensions/core/addsingle.c
Normal file
File diff suppressed because it is too large
Load diff
444
mafft/src/mafft-7.487-with-extensions/core/blosum.c
Normal file
444
mafft/src/mafft-7.487-with-extensions/core/blosum.c
Normal file
|
@ -0,0 +1,444 @@
|
|||
#define DEFAULTGOP_B -1530
|
||||
#define DEFAULTGEP_B -00
|
||||
#define DEFAULTOFS_B -123 /* +10 -- -50 teido ka ? */
|
||||
|
||||
|
||||
void BLOSUMmtx( int n, double **matrix, double *freq, unsigned char *amino, char *amino_grp, int *rescalept )
|
||||
{
|
||||
/*
|
||||
char locaminod[26] = "GASTPLIMVDNEQFYWKRHCXXX.-U";
|
||||
*/
|
||||
// char locaminod[] = "ARNDCQEGHILKMFPSTWYVBZX.-U";
|
||||
char locaminod[] = "ARNDCQEGHILKMFPSTWYVBZX.-J";
|
||||
char locgrpd[] =
|
||||
{
|
||||
0, 3, 2, 2, 5, 2, 2, 0, 3, 1, 1, 3, 1, 4, 0, 0, 0, 4, 4, 1, 2, 2,
|
||||
6, 6, 6, 1,
|
||||
};
|
||||
double freqd[20] =
|
||||
{
|
||||
0.077,
|
||||
0.051,
|
||||
0.043,
|
||||
0.052,
|
||||
0.020,
|
||||
0.041,
|
||||
0.062,
|
||||
0.074,
|
||||
0.023,
|
||||
0.052,
|
||||
0.091,
|
||||
0.059,
|
||||
0.024,
|
||||
0.040,
|
||||
0.051,
|
||||
0.069,
|
||||
0.059,
|
||||
0.014,
|
||||
0.032,
|
||||
0.066,
|
||||
};
|
||||
|
||||
double tmpmtx30[] =
|
||||
{
|
||||
4,
|
||||
-1, 8,
|
||||
0, -2, 8,
|
||||
0, -1, 1, 9,
|
||||
-3, -2, -1, -3, 17,
|
||||
1, 3, -1, -1, -2, 8,
|
||||
0, -1, -1, 1, 1, 2, 6,
|
||||
0, -2, 0, -1, -4, -2, -2, 8,
|
||||
-2, -1, -1, -2, -5, 0, 0, -3, 14,
|
||||
0, -3, 0, -4, -2, -2, -3, -1, -2, 6,
|
||||
-1, -2, -2, -1, 0, -2, -1, -2, -1, 2, 4,
|
||||
0, 1, 0, 0, -3, 0, 2, -1, -2, -2, -2, 4,
|
||||
1, 0, 0, -3, -2, -1, -1, -2, 2, 1, 2, 2, 6,
|
||||
-2, -1, -1, -5, -3, -3, -4, -3, -3, 0, 2, -1, -2, 10,
|
||||
-1, -1, -3, -1, -3, 0, 1, -1, 1, -3, -3, 1, -4, -4, 11,
|
||||
1, -1, 0, 0, -2, -1, 0, 0, -1, -1, -2, 0, -2, -1, -1, 4,
|
||||
1, -3, 1, -1, -2, 0, -2, -2, -2, 0, 0, -1, 0, -2, 0, 2, 5,
|
||||
-5, 0, -7, -4, -2, -1, -1, 1, -5, -3, -2, -2, -3, 1, -3, -3, -5, 20,
|
||||
-4, 0, -4, -1, -6, -1, -2, -3, 0, -1, 3, -1, -1, 3, -2, -2, -1, 5, 9,
|
||||
1, -1, -2, -2, -2, -3, -3, -3, -3, 4, 1, -2, 0, 1, -4, -1, 1, -3, 1, 5,
|
||||
0, -2, 4, 5, -2, -1, 0, 0, -2, -2, -1, 0, -2, -3, -2, 0, 0, -5, -3, -2, 5,
|
||||
0, 0, -1, 0, 0, 4, 5, -2, 0, -3, -1, 1, -1, -4, 0, -1, -1, -1, -2, -3, 0, 4,
|
||||
0, -1, 0, -1, -2, 0, -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, 0, -2, -1, 0, -1, 0, -1,
|
||||
};
|
||||
|
||||
double tmpmtx45[] =
|
||||
{
|
||||
5,
|
||||
-2, 7,
|
||||
-1, 0, 6,
|
||||
-2, -1, 2, 7,
|
||||
-1, -3, -2, -3, 12,
|
||||
-1, 1, 0, 0, -3, 6,
|
||||
-1, 0, 0, 2, -3, 2, 6,
|
||||
0, -2, 0, -1, -3, -2, -2, 7,
|
||||
-2, 0, 1, 0, -3, 1, 0, -2, 10,
|
||||
-1, -3, -2, -4, -3, -2, -3, -4, -3, 5,
|
||||
-1, -2, -3, -3, -2, -2, -2, -3, -2, 2, 5,
|
||||
-1, 3, 0, 0, -3, 1, 1, -2, -1, -3, -3, 5,
|
||||
-1, -1, -2, -3, -2, 0, -2, -2, 0, 2, 2, -1, 6,
|
||||
-2, -2, -2, -4, -2, -4, -3, -3, -2, 0, 1, -3, 0, 8,
|
||||
-1, -2, -2, -1, -4, -1, 0, -2, -2, -2, -3, -1, -2, -3, 9,
|
||||
1, -1, 1, 0, -1, 0, 0, 0, -1, -2, -3, -1, -2, -2, -1, 4,
|
||||
0, -1, 0, -1, -1, -1, -1, -2, -2, -1, -1, -1, -1, -1, -1, 2, 5,
|
||||
-2, -2, -4, -4, -5, -2, -3, -2, -3, -2, -2, -2, -2, 1, -3, -4, -3, 15,
|
||||
-2, -1, -2, -2, -3, -1, -2, -3, 2, 0, 0, -1, 0, 3, -3, -2, -1, 3, 8,
|
||||
0, -2, -3, -3, -1, -3, -3, -3, -3, 3, 1, -2, 1, 0, -3, -1, 0, -3, -1, 5,
|
||||
};
|
||||
double tmpmtx50[] =
|
||||
{
|
||||
5,
|
||||
-2, 7,
|
||||
-1, -1, 7,
|
||||
-2, -2, 2, 8,
|
||||
-1, -4, -2, -4, 13,
|
||||
-1, 1, 0, 0, -3, 7,
|
||||
-1, 0, 0, 2, -3, 2, 6,
|
||||
0, -3, 0, -1, -3, -2, -3, 8,
|
||||
-2, 0, 1, -1, -3, 1, 0, -2, 10,
|
||||
-1, -4, -3, -4, -2, -3, -4, -4, -4, 5,
|
||||
-2, -3, -4, -4, -2, -2, -3, -4, -3, 2, 5,
|
||||
-1, 3, 0, -1, -3, 2, 1, -2, 0, -3, -3, 6,
|
||||
-1, -2, -2, -4, -2, 0, -2, -3, -1, 2, 3, -2, 7,
|
||||
-3, -3, -4, -5, -2, -4, -3, -4, -1, 0, 1, -4, 0, 8,
|
||||
-1, -3, -2, -1, -4, -1, -1, -2, -2, -3, -4, -1, -3, -4, 10,
|
||||
1, -1, 1, 0, -1, 0, -1, 0, -1, -3, -3, 0, -2, -3, -1, 5,
|
||||
0, -1, 0, -1, -1, -1, -1, -2, -2, -1, -1, -1, -1, -2, -1, 2, 5,
|
||||
-3, -3, -4, -5, -5, -1, -3, -3, -3, -3, -2, -3, -1, 1, -4, -4, -3, 15,
|
||||
-2, -1, -2, -3, -3, -1, -2, -3, 2, -1, -1, -2, 0, 4, -3, -2, -2, 2, 8,
|
||||
0, -3, -3, -4, -1, -3, -3, -4, -4, 4, 1, -3, 1, -1, -3, -2, 0, -3, -1, 5,
|
||||
};
|
||||
#if 0
|
||||
double tmpmtx62[] =
|
||||
{
|
||||
6,
|
||||
-2, 8,
|
||||
-2, -1, 8,
|
||||
-3, -2, 2, 9,
|
||||
-1, -5, -4, -5, 13,
|
||||
-1, 1, 0, 0, -4, 8,
|
||||
-1, 0, 0, 2, -5, 3, 7,
|
||||
0, -3, -1, -2, -4, -3, -3, 8,
|
||||
-2, 0, 1, -2, -4, 1, 0, -3, 11,
|
||||
-2, -4, -5, -5, -2, -4, -5, -6, -5, 6,
|
||||
-2, -3, -5, -5, -2, -3, -4, -5, -4, 2, 6,
|
||||
-1, 3, 0, -1, -5, 2, 1, -2, -1, -4, -4, 7,
|
||||
-1, -2, -3, -5, -2, -1, -3, -4, -2, 2, 3, -2, 8,
|
||||
-3, -4, -4, -5, -4, -5, -5, -5, -2, 0, 1, -5, 0, 9,
|
||||
-1, -3, -3, -2, -4, -2, -2, -3, -3, -4, -4, -2, -4, -5, 11,
|
||||
2, -1, 1, 0, -1, 0, 0, 0, -1, -4, -4, 0, -2, -4, -1, 6,
|
||||
0, -2, 0, -2, -1, -1, -1, -2, -3, -1, -2, -1, -1, -3, -2, 2, 7,
|
||||
-4, -4, -6, -6, -3, -3, -4, -4, -4, -4, -2, -4, -2, 1, -5, -4, -4, 16,
|
||||
-3, -3, -3, -5, -4, -2, -3, -5, 3, -2, -2, -3, -1, 4, -4, -3, -2, 3, 10,
|
||||
0, -4, -4, -5, -1, -3, -4, -5, -5, 4, 1, -3, 1, -1, -4, -2, 0, -4, -2, 6,
|
||||
};
|
||||
#else
|
||||
double tmpmtx62[] =
|
||||
{ 5.893685,
|
||||
-2.120252, 8.210189,
|
||||
-2.296072, -0.659672, 8.479856,
|
||||
-2.630151, -2.408668, 1.907550, 8.661363,
|
||||
-0.612761, -5.083814, -3.989626, -5.189966, 12.873172,
|
||||
-1.206025, 1.474162, 0.002529, -0.470069, -4.352838, 7.927704,
|
||||
-1.295821, -0.173087, -0.402015, 2.265459, -5.418729, 2.781955, 7.354247,
|
||||
0.239392, -3.456163, -0.634136, -1.970281, -3.750621, -2.677743, -3.165266, 8.344902,
|
||||
-2.437724, -0.374792, 0.867735, -1.678363, -4.481724, 0.672051, -0.176497, -3.061315, 11.266586,
|
||||
-1.982718, -4.485360, -4.825558, -4.681732, -1.841495, -4.154454, -4.791538, -5.587336, -4.847345, 5.997760,
|
||||
-2.196882, -3.231860, -5.068375, -5.408471, -1.916207, -3.200863, -4.269723, -5.440437, -4.180099, 2.282412, 5.774148,
|
||||
-1.101017, 3.163105, -0.268534, -1.052724, -4.554510, 1.908859, 1.163010, -2.291924, -1.081539, -4.005209, -3.670219, 6.756827,
|
||||
-1.402897, -2.050705, -3.226290, -4.587785, -2.129758, -0.631437, -2.997038, -4.014898, -2.326896, 1.690191, 2.987638, -2.032119, 8.088951,
|
||||
-3.315080, -4.179521, -4.491005, -5.225795, -3.563219, -4.746598, -4.788639, -4.661029, -1.851231, -0.241317, 0.622170, -4.618016, 0.018880, 9.069126,
|
||||
-1.221394, -3.162863, -3.000581, -2.220163, -4.192770, -1.922917, -1.674258, -3.200320, -3.241363, -4.135001, -4.290107, -1.520445, -3.714633, -5.395930, 11.046892,
|
||||
1.673639, -1.147170, 0.901353, -0.391548, -1.312485, -0.151708, -0.220375, -0.438748, -1.322366, -3.522266, -3.663923, -0.305170, -2.221304, -3.553533, -1.213470, 5.826527,
|
||||
-0.068042, -1.683495, -0.069138, -1.576054, -1.299983, -1.012997, -1.294878, -2.363065, -2.528844, -1.076382, -1.796229, -1.004336, -0.999449, -3.161436, -1.612919, 2.071710, 6.817956,
|
||||
-3.790328, -4.019108, -5.543911, -6.321502, -3.456164, -2.919725, -4.253197, -3.737232, -3.513238, -3.870811, -2.447829, -4.434676, -2.137255, 1.376341, -5.481260, -4.127804, -3.643382, 15.756041,
|
||||
-2.646022, -2.540799, -3.122641, -4.597428, -3.610671, -2.131601, -3.030688, -4.559647, 2.538948, -1.997058, -1.593097, -2.730047, -1.492308, 4.408690, -4.379667, -2.528713, -2.408996, 3.231335, 9.892544,
|
||||
-0.284140, -3.753871, -4.314525, -4.713963, -1.211518, -3.297575, -3.663425, -4.708118, -4.676220, 3.820569, 1.182672, -3.393535, 1.030861, -1.273542, -3.523054, -2.469318, -0.083276, -4.251392, -1.811267, 5.653391,
|
||||
};
|
||||
#endif
|
||||
double tmpmtx80[] =
|
||||
{
|
||||
7,
|
||||
-3, 9,
|
||||
-3, -1, 9,
|
||||
-3, -3, 2, 10,
|
||||
-1, -6, -5, -7, 13,
|
||||
-2, 1, 0, -1, -5, 9,
|
||||
-2, -1, -1, 2, -7, 3, 8,
|
||||
0, -4, -1, -3, -6, -4, -4, 9,
|
||||
-3, 0, 1, -2, -7, 1, 0, -4, 12,
|
||||
-3, -5, -6, -7, -2, -5, -6, -7, -6, 7,
|
||||
-3, -4, -6, -7, -3, -4, -6, -7, -5, 2, 6,
|
||||
-1, 3, 0, -2, -6, 2, 1, -3, -1, -5, -4, 8,
|
||||
-2, -3, -4, -6, -3, -1, -4, -5, -4, 2, 3, -3, 9,
|
||||
-4, -5, -6, -6, -4, -5, -6, -6, -2, -1, 0, -5, 0, 10,
|
||||
-1, -3, -4, -3, -6, -3, -2, -5, -4, -5, -5, -2, -4, -6, 12,
|
||||
2, -2, 1, -1, -2, -1, -1, -1, -2, -4, -4, -1, -3, -4, -2, 7,
|
||||
0, -2, 0, -2, -2, -1, -2, -3, -3, -2, -3, -1, -1, -4, -3, 2, 8,
|
||||
-5, -5, -7, -8, -5, -4, -6, -6, -4, -5, -4, -6, -3, 0, -7, -6, -5, 16,
|
||||
-4, -4, -4, -6, -5, -3, -5, -6, 3, -3, -2, -4, -3, 4, -6, -3, -3, 3, 11,
|
||||
-1, -4, -5, -6, -2, -4, -4, -6, -5, 4, 1, -4, 1, -2, -4, -3, 0, -5, -3, 7,
|
||||
};
|
||||
double tmpmtx90[] =
|
||||
{
|
||||
5,
|
||||
-2, 6,
|
||||
-2, -1, 7,
|
||||
-3, -3, 1, 7,
|
||||
-1, -5, -4, -5, 9,
|
||||
-1, 1, 0, -1, -4, 7,
|
||||
-1, -1, -1, 1, -6, 2, 6,
|
||||
0, -3, -1, -2, -4, -3, -3, 6,
|
||||
-2, 0, 0, -2, -5, 1, -1, -3, 8,
|
||||
-2, -4, -4, -5, -2, -4, -4, -5, -4, 5,
|
||||
-2, -3, -4, -5, -2, -3, -4, -5, -4, 1, 5,
|
||||
-1, 2, 0, -1, -4, 1, 0, -2, -1, -4, -3, 6,
|
||||
-2, -2, -3, -4, -2, 0, -3, -4, -3, 1, 2, -2, 7,
|
||||
-3, -4, -4, -5, -3, -4, -5, -5, -2, -1, 0, -4, -1, 7,
|
||||
-1, -3, -3, -3, -4, -2, -2, -3, -3, -4, -4, -2, -3, -4, 8,
|
||||
1, -1, 0, -1, -2, -1, -1, -1, -2, -3, -3, -1, -2, -3, -2, 5,
|
||||
0, -2, 0, -2, -2, -1, -1, -3, -2, -1, -2, -1, -1, -3, -2, 1, 6,
|
||||
-4, -4, -5, -6, -4, -3, -5, -4, -3, -4, -3, -5, -2, 0, -5, -4, -4, 11,
|
||||
-3, -3, -3, -4, -4, -3, -4, -5, 1, -2, -2, -3, -2, 3, -4, -3, -2, 2, 8,
|
||||
-1, -3, -4, -5, -2, -3, -3, -5, -4, 3, 0, -3, 0, -2, -3, -2, -1, -3, -3, 5,
|
||||
};
|
||||
double tmpmtx100[] =
|
||||
{
|
||||
8,
|
||||
-3,10,
|
||||
-4,-2,11,
|
||||
-5,-5, 1,10,
|
||||
-2,-8,-5,-8,14,
|
||||
-2, 0,-1,-2,-7,11,
|
||||
-3,-2,-2, 2,-9, 2,10,
|
||||
-1,-6,-2,-4,-7,-5,-6, 9,
|
||||
-4,-1, 0,-3,-8, 1,-2,-6,13,
|
||||
-4,-7,-7,-8,-3,-6,-7,-9,-7, 8,
|
||||
-4,-6,-7,-8,-5,-5,-7,-8,-6, 2, 8,
|
||||
-2, 3,-1,-3,-8, 2, 0,-5,-3,-6,-6,10,
|
||||
-3,-4,-5,-8,-4,-2,-5,-7,-5, 1, 3,-4,12,
|
||||
-5,-6,-7,-8,-4,-6,-8,-8,-4,-2, 0,-6,-1,11,
|
||||
-2,-5,-5,-5,-8,-4,-4,-6,-5,-7,-7,-3,-5,-7,12,
|
||||
1,-3, 0,-2,-3,-2,-2,-2,-3,-5,-6,-2,-4,-5,-3, 9,
|
||||
-1,-3,-1,-4,-3,-3,-3,-5,-4,-3,-4,-3,-2,-5,-4, 2, 9,
|
||||
-6,-7,-8,-10,-7,-5,-8,-7,-5,-6,-5,-8,-4, 0,-8,-7,-7,17,
|
||||
-5,-5,-5,-7,-6,-4,-7,-8, 1,-4,-4,-5,-5, 4,-7,-5,-5, 2,12,
|
||||
-2,-6,-7,-8,-3,-5,-5,-8,-7, 4, 0,-5, 0,-3,-6,-4,-1,-5,-5, 8,
|
||||
};
|
||||
double tmpmtx0[] =
|
||||
{
|
||||
2.4,
|
||||
-0.6, 4.7,
|
||||
-0.3, 0.3, 3.8,
|
||||
-0.3, -0.3, 2.2, 4.7,
|
||||
0.5, -2.2, -1.8, -3.2, 11.5,
|
||||
-0.2, 1.5, 0.7, 0.9, -2.4, 2.7,
|
||||
0.0, 0.4, 0.9, 2.7, -3.0, 1.7, 3.6,
|
||||
0.5, -1.0, 0.4, 0.1, -2.0, -1.0, -0.8, 6.6,
|
||||
-0.8, 0.6, 1.2, 0.4, -1.3, 1.2, 0.4, -1.4, 6.0,
|
||||
-0.8, -2.4, -2.8, -3.8, -1.1, -1.9, -2.7, -4.5, -2.2, 4.0,
|
||||
-1.2, -2.2, -3.0, -4.0, -1.5, -1.6, -2.8, -4.4, -1.9, 2.8, 4.0,
|
||||
-0.4, 2.7, 0.8, 0.5, -2.8, 1.5, 1.2, -1.1, 0.6, -2.1, -2.1, 3.2,
|
||||
-0.7, -1.7, -2.2, -3.0, -0.9, -1.0, -2.0, -3.5, -1.3, 2.5, 2.8, -1.4, 4.3,
|
||||
-2.3, -3.2, -3.1, -4.5, -0.8, -2.6, -3.9, -5.2, -0.1, 1.0, 2.0, -3.3, 1.6, 7.0,
|
||||
0.3, -0.9, -0.9, -0.7, -3.1, -0.2, -0.5, -1.6, -1.1, -2.6, -2.3, -0.6, -2.4, -3.8, 7.6,
|
||||
1.1, -0.2, 0.9, 0.5, 0.1, 0.2, 0.2, 0.4, -0.2, -1.8, -2.1, 0.1, -1.4, -2.8, 0.4, 2.2,
|
||||
0.6, -0.2, 0.5, 0.0, -0.5, 0.0, -0.1, -1.1, -0.3, -0.6, -1.3, 0.1, -0.6, -2.2, 0.1, 1.5, 2.5,
|
||||
-3.6, -1.6, -3.6, -5.2, -1.0, -2.7, -4.3, -4.0, -0.8, -1.8, -0.7, -3.5, -1.0, 3.6, -5.0, -3.3, -3.5, 14.2,
|
||||
-2.2, -1.8, -1.4, -2.8, -0.5, -1.7, -2.7, -4.0, 2.2, -0.7, 0.0, -2.1, -0.2, 5.1, -3.1, -1.9, -1.9, 4.1, 7.8,
|
||||
0.1, -2.0, -2.2, -2.9, 0.0, -1.5, -1.9, -3.3, -2.0, 3.1, 1.8, -1.7, 1.6, 0.1, -1.8, -1.0, 0.0, -2.6, -1.1, 3.4,
|
||||
};
|
||||
|
||||
int i, j, count;
|
||||
double av;
|
||||
double *tmpmtx;
|
||||
|
||||
if( n == 30 ) tmpmtx = tmpmtx30;
|
||||
else if( n == 45 ) tmpmtx = tmpmtx45;
|
||||
else if( n == 50 ) tmpmtx = tmpmtx50;
|
||||
else if( n == 62 ) tmpmtx = tmpmtx62;
|
||||
else if( n == 80 ) tmpmtx = tmpmtx80;
|
||||
else if( n == 90 ) tmpmtx = tmpmtx90;
|
||||
else if( n == 100 ) tmpmtx = tmpmtx100;
|
||||
else if( n == 0 ) tmpmtx = tmpmtx0;
|
||||
else if( n == -1 ) tmpmtx = loadaamtx( rescalept );
|
||||
else
|
||||
{
|
||||
fprintf( stderr, "blosum %d ?\n", n );
|
||||
exit( 1 );
|
||||
}
|
||||
|
||||
count = 0;
|
||||
for( i=0; i<20; i++ )
|
||||
{
|
||||
for( j=0; j<=i; j++ )
|
||||
{
|
||||
matrix[i][j] = matrix[j][i] = (double)tmpmtx[count++];
|
||||
}
|
||||
}
|
||||
if( n == -1 && tmpmtx[400] != -1.0 )
|
||||
{
|
||||
for( i=0; i<20; i++ ) freq[i] = tmpmtx[400+i];
|
||||
av = 0.0;
|
||||
for( i=0; i<20; i++ ) av += freq[i];
|
||||
for( i=0; i<20; i++ ) freq[i] /= av;
|
||||
}
|
||||
else
|
||||
for( i=0; i<20; i++ ) freq[i] = freqd[i];
|
||||
|
||||
if( n == -1 ) free( tmpmtx );
|
||||
#if 0
|
||||
av = 0.0;
|
||||
for( i=0; i<20; i++ )
|
||||
av += matrix[i][i];
|
||||
av /= 20;
|
||||
fprintf( stdout, "av = %f\n", av );
|
||||
|
||||
for( i=0; i<20; i++ ) for( j=0; j<20; j++ )
|
||||
matrix[i][j] /= av;
|
||||
|
||||
av = wav = 0;
|
||||
count = 0;
|
||||
wcount = 0.0;
|
||||
tmptmp = 0.0;
|
||||
for( i=0; i<20; i++ )
|
||||
{
|
||||
fprintf( stdout, "freq[%d] = %f\n", i, freq[i] );
|
||||
tmptmp += freq[i];
|
||||
for( j=0; j<20; j++ )
|
||||
{
|
||||
av += matrix[i][j];
|
||||
wav += freq[i] * freq[j] * matrix[i][j];
|
||||
count++;
|
||||
wcount += freq[i] * freq[j];
|
||||
}
|
||||
}
|
||||
|
||||
av /= count;
|
||||
wav /= wcount;
|
||||
fprintf( stdout, "av = %f\n", av );
|
||||
fprintf( stdout, "wav = %f\n", wav );
|
||||
fprintf( stdout, "wcount = %f\n", wcount );
|
||||
fprintf( stdout, "tmptmp = %f\n", tmptmp );
|
||||
|
||||
for( i=0; i<20; i++ )
|
||||
{
|
||||
for( j=0; j<=i; j++ )
|
||||
{
|
||||
fprintf( stderr, "## %d-%d, %f\n", i, j, matrix[i][j] );
|
||||
}
|
||||
}
|
||||
|
||||
exit( 1 );
|
||||
#endif
|
||||
|
||||
for( i=0; i<26; i++ ) amino[i] = locaminod[i];
|
||||
for( i=0; i<26; i++ ) amino_grp[(int)amino[i]] = locgrpd[i];
|
||||
}
|
||||
|
||||
static int checkchar( int i )
|
||||
{
|
||||
if( i > 0xff || i <= 0x00 || i == 0x3E || i == 0x3D || i == 0x3C || i == 0x2D || i == 0x20 || i == 0x0d || i == 0x0a )
|
||||
return( 1 );
|
||||
return( 0 );
|
||||
}
|
||||
|
||||
static void overridematrix( double **matrix )
|
||||
{
|
||||
char buf[500];
|
||||
FILE *fp;
|
||||
unsigned int i1, i2;
|
||||
double v;
|
||||
char *bpt;
|
||||
int nread;
|
||||
|
||||
fp = fopen( "_aamtx", "r" );
|
||||
if( fp == NULL )
|
||||
{
|
||||
fprintf( stderr, "warning: cannot open scorematrix. Use the default one.\n" );
|
||||
// f2cl.c de tomaranai youni
|
||||
// exit( 1 );
|
||||
return;
|
||||
}
|
||||
|
||||
while( 1 )
|
||||
{
|
||||
fgets( buf, 499, fp );
|
||||
if( feof( fp ) ) break;
|
||||
|
||||
if( ( bpt = strchr( buf, '#' ) ) ) *bpt = 0;
|
||||
|
||||
i1 = i2 = 0;
|
||||
nread = sscanf( buf, "%x %x %lf", &i1, &i2, &v );
|
||||
if( nread == EOF ) continue;
|
||||
if( nread != 3 )
|
||||
{
|
||||
reporterr( "Format error in this line?\n" );
|
||||
reporterr( "%s\n", buf );
|
||||
// reporterr( "To set a score, 100, for a match of 0x41 and 0x42, \n" );
|
||||
// reporterr( "0x41 0x42 100 \n" );
|
||||
exit( 1 );
|
||||
}
|
||||
if( checkchar( i1 ) )
|
||||
{
|
||||
reporterr( "%c=0x%x cannot be used (1)\n", i1, i1 );
|
||||
exit( 1 );
|
||||
}
|
||||
if( checkchar( i2 ) )
|
||||
{
|
||||
reporterr( "%c=0x%x cannot be used (2)\n", i2, i2 );
|
||||
exit( 1 );
|
||||
}
|
||||
reporterr( "Score(%c=0x%x,%c=0x%x)=%f\n", i1, i1, i2, i2, v );
|
||||
matrix[i1][i2] = v;
|
||||
matrix[i2][i1] = v; // 2018/May/11
|
||||
}
|
||||
fclose( fp );
|
||||
}
|
||||
|
||||
void extendedmtx( double **matrix, double *freq, unsigned char *amino, char *amino_grp )
|
||||
{
|
||||
int i;
|
||||
int j;
|
||||
|
||||
for( i=0; i<nalphabets; i++ )
|
||||
{
|
||||
// fprintf( stderr, "i=%d, i=%c\n", i, i );
|
||||
amino[i] = (unsigned char)i;
|
||||
}
|
||||
for( i=0; i<nalphabets; i++ ) amino_grp[(int)amino[i]] = i % 6;
|
||||
for( i=0; i<nalphabets; i++ ) freq[i] = 1.0/nalphabets;
|
||||
|
||||
for( i=0; i<nalphabets; i++ )
|
||||
{
|
||||
for( j=0; j<=i; j++ )
|
||||
{
|
||||
matrix[i][j] = matrix[j][i] = (double)-1.0;
|
||||
}
|
||||
}
|
||||
for( i=0; i<nalphabets; i++ )
|
||||
matrix[i][i] = matrix[i][i] = (double)1.0;
|
||||
|
||||
overridematrix( matrix );
|
||||
#if 0 // user-defined matrix + user-defined freqency ga aru toki fukkatsu saseru.
|
||||
if( tmpmtx[400] != -1.0 )
|
||||
{
|
||||
for( i=0; i<20; i++ ) freq[i] = tmpmtx[400+i];
|
||||
av = 0.0;
|
||||
for( i=0; i<20; i++ ) av += freq[i];
|
||||
for( i=0; i<20; i++ ) freq[i] /= av;
|
||||
}
|
||||
else
|
||||
for( i=0; i<20; i++ ) freq[i] = freqd[i];
|
||||
#endif
|
||||
#if 0
|
||||
for( i=0; i<nalphabets; i++ )
|
||||
{
|
||||
fprintf( stderr, "%d: %c, %d, %f\n", i, amino[i], amino_grp[amino[i]], freq[i] );
|
||||
}
|
||||
#endif
|
||||
}
|
11
mafft/src/mafft-7.487-with-extensions/core/blosum.h
Normal file
11
mafft/src/mafft-7.487-with-extensions/core/blosum.h
Normal file
|
@ -0,0 +1,11 @@
|
|||
/*
|
||||
int locpenaltyd = -2400;
|
||||
int locoffsetd = -60;
|
||||
char locaminod[26] = "GASTPLIMVDNEQFYWKRHCXXX.-U";
|
||||
char locaminod[] = "ARNDCQEGHILKMFPSTWYVBZX.-U";
|
||||
char locgrpd[] =
|
||||
{
|
||||
0, 3, 2, 2, 5, 2, 2, 0, 3, 1, 1, 3, 1, 4, 0, 0, 0, 4, 4, 1, 2, 2,
|
||||
6, 6, 6, 6,
|
||||
};
|
||||
*/
|
13
mafft/src/mafft-7.487-with-extensions/core/compileoncygwin
Normal file
13
mafft/src/mafft-7.487-with-extensions/core/compileoncygwin
Normal file
|
@ -0,0 +1,13 @@
|
|||
rm -rf binaries64-cygwin/
|
||||
mkdir binaries64-cygwin/
|
||||
make clean
|
||||
rm -f ../binaries/*
|
||||
make CC=x86_64-w64-mingw32-gcc CFLAGS="-static -O3 -Dmingw"
|
||||
mv ../binaries/* binaries64-cygwin/
|
||||
|
||||
rm -rf binaries32-cygwin/
|
||||
mkdir binaries32-cygwin/
|
||||
make clean
|
||||
rm -f ../binaries/*
|
||||
make CC=i686-w64-mingw32-gcc CFLAGS="-static -O3 -Dmingw"
|
||||
mv ../binaries/* binaries32-cygwin/
|
38
mafft/src/mafft-7.487-with-extensions/core/compileonmsys
Normal file
38
mafft/src/mafft-7.487-with-extensions/core/compileonmsys
Normal file
|
@ -0,0 +1,38 @@
|
|||
#!/usr/bin/env bash
|
||||
export PATH=/home/mingw32/mingw32/bin:$PATH
|
||||
export C_INCLUDE_PATH=/home/mingw32/mingw32/include
|
||||
export LIBRARY_PATH=/home/mingw32/mingw32/lib
|
||||
make clean
|
||||
make ENABLE_MULTITHREAD="" CFLAGS="-Dmingw -O3"
|
||||
rm -rf binaries32
|
||||
mkdir binaries32
|
||||
mv ../binaries/* binaries32/
|
||||
|
||||
export PATH=/home/mingw64/mingw64/bin:$PATH
|
||||
export C_INCLUDE_PATH=/home/mingw64/mingw64/include
|
||||
export LIBRARY_PATH=/home/mingw64/mingw64/lib
|
||||
make clean
|
||||
make ENABLE_MULTITHREAD="" CFLAGS="-Dmingw -O3"
|
||||
rm -rf binaries64
|
||||
mkdir binaries64
|
||||
mv ../binaries/* binaries64/
|
||||
|
||||
|
||||
|
||||
export PATH=/home/mingw32/mingw32/bin:$PATH
|
||||
export C_INCLUDE_PATH=/home/mingw32/mingw32/include
|
||||
export LIBRARY_PATH=/home/mingw32/mingw32/lib
|
||||
make clean
|
||||
make LIBS="-static -lm -lpthread" CFLAGS="-Dmingw -O3"
|
||||
rm -rf binaries32-multithread
|
||||
mkdir binaries32-multithread
|
||||
mv ../binaries/* binaries32-multithread/
|
||||
|
||||
export PATH=/home/mingw64/mingw64/bin:$PATH
|
||||
export C_INCLUDE_PATH=/home/mingw64/mingw64/include
|
||||
export LIBRARY_PATH=/home/mingw64/mingw64/lib
|
||||
make clean
|
||||
make LIBS="-static -lm -lpthread" CFLAGS="-Dmingw -O3"
|
||||
rm -rf binaries64-multithread
|
||||
mkdir binaries64-multithread
|
||||
mv ../binaries/* binaries64-multithread/
|
1487
mafft/src/mafft-7.487-with-extensions/core/constants.c
Normal file
1487
mafft/src/mafft-7.487-with-extensions/core/constants.c
Normal file
File diff suppressed because it is too large
Load diff
312
mafft/src/mafft-7.487-with-extensions/core/contrafoldwrap.c
Normal file
312
mafft/src/mafft-7.487-with-extensions/core/contrafoldwrap.c
Normal file
|
@ -0,0 +1,312 @@
|
|||
#include "mltaln.h"
|
||||
|
||||
#define DEBUG 0
|
||||
|
||||
static char *whereiscontrafold;
|
||||
|
||||
void unknown_n( char *out, char *in )
|
||||
{
|
||||
while( *in )
|
||||
{
|
||||
if( *in == 'a' || *in == 'A' )
|
||||
*out = 'A';
|
||||
else if( *in == 't' || *in == 'T' || *in == 'u' || *in == 'U' )
|
||||
*out = 'U';
|
||||
else if( *in == 'g' || *in == 'G' )
|
||||
*out = 'G';
|
||||
else if( *in == 'c' || *in == 'C' )
|
||||
*out = 'C';
|
||||
else if( *in == '-' )
|
||||
*out = '-';
|
||||
else
|
||||
*out = 'N';
|
||||
|
||||
out++;
|
||||
in++;
|
||||
}
|
||||
*out = 0;
|
||||
}
|
||||
|
||||
void outcontrafold( FILE *fp, RNApair **pairprob, int length )
|
||||
{
|
||||
int i;
|
||||
RNApair *pt;
|
||||
for( i=0; i<length; i++ ) for( pt=pairprob[i]; pt->bestpos!=-1; pt++ )
|
||||
{
|
||||
if( pt->bestpos > i )
|
||||
fprintf( fp, "%d %d %f\n", i, pt->bestpos, pt->bestscore );
|
||||
}
|
||||
}
|
||||
|
||||
#if 1
|
||||
static void readcontrafold( FILE *fp, RNApair **pairprob, int length )
|
||||
{
|
||||
char gett[10000];
|
||||
int *pairnum;
|
||||
char *pt;
|
||||
int i;
|
||||
int left, right;
|
||||
double prob;
|
||||
|
||||
pairnum = (int *)calloc( length, sizeof( int ) );
|
||||
for( i=0; i<length; i++ ) pairnum[i] = 0;
|
||||
|
||||
while( 1 )
|
||||
{
|
||||
if( feof( fp ) ) break;
|
||||
fgets( gett, 9999, fp );
|
||||
|
||||
// fprintf( stderr, "gett=%s\n", gett );
|
||||
|
||||
pt = gett;
|
||||
|
||||
sscanf( gett, "%d ", &left );
|
||||
left--;
|
||||
|
||||
// fprintf( stderr, "left=%d\n", left );
|
||||
pt = strchr( pt, ' ' ) + 1;
|
||||
// fprintf( stderr, "pt=%s\n", pt );
|
||||
|
||||
while( (pt = strchr( pt, ' ' ) ) )
|
||||
{
|
||||
pt++;
|
||||
// fprintf( stderr, "pt=%s\n", pt );
|
||||
sscanf( pt, "%d:%lf", &right, &prob );
|
||||
right--;
|
||||
|
||||
// fprintf( stderr, "%d-%d, %f\n", left, right, prob );
|
||||
|
||||
pairprob[left] = (RNApair *)realloc( pairprob[left], (pairnum[left]+2) * sizeof( RNApair ) );
|
||||
pairprob[left][pairnum[left]].bestscore = prob;
|
||||
pairprob[left][pairnum[left]].bestpos = right;
|
||||
pairnum[left]++;
|
||||
pairprob[left][pairnum[left]].bestscore = -1.0;
|
||||
pairprob[left][pairnum[left]].bestpos = -1;
|
||||
// fprintf( stderr, "%d-%d, %f\n", left, right, prob );
|
||||
|
||||
pairprob[right] = (RNApair *)realloc( pairprob[right], (pairnum[right]+2) * sizeof( RNApair ) );
|
||||
pairprob[right][pairnum[right]].bestscore = prob;
|
||||
pairprob[right][pairnum[right]].bestpos = left;
|
||||
pairnum[right]++;
|
||||
pairprob[right][pairnum[right]].bestscore = -1.0;
|
||||
pairprob[right][pairnum[right]].bestpos = -1;
|
||||
// fprintf( stderr, "%d-%d, %f\n", right, left, prob );
|
||||
}
|
||||
}
|
||||
free( pairnum );
|
||||
}
|
||||
#endif
|
||||
|
||||
void arguments( int argc, char *argv[] )
|
||||
{
|
||||
int c;
|
||||
inputfile = NULL;
|
||||
dorp = NOTSPECIFIED;
|
||||
kimuraR = NOTSPECIFIED;
|
||||
pamN = NOTSPECIFIED;
|
||||
whereiscontrafold = NULL;
|
||||
|
||||
while( --argc > 0 && (*++argv)[0] == '-' )
|
||||
{
|
||||
while ( (c = *++argv[0]) )
|
||||
{
|
||||
switch( c )
|
||||
{
|
||||
case 'i':
|
||||
inputfile = *++argv;
|
||||
fprintf( stderr, "inputfile = %s\n", inputfile );
|
||||
--argc;
|
||||
goto nextoption;
|
||||
case 'd':
|
||||
whereiscontrafold = *++argv;
|
||||
fprintf( stderr, "whereiscontrafold = %s\n", whereiscontrafold );
|
||||
--argc;
|
||||
goto nextoption;
|
||||
default:
|
||||
fprintf( stderr, "illegal option %c\n", c );
|
||||
argc = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
nextoption:
|
||||
;
|
||||
}
|
||||
if( argc != 0 )
|
||||
{
|
||||
fprintf( stderr, "options: Check source file !\n" );
|
||||
exit( 1 );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int main( int argc, char *argv[] )
|
||||
{
|
||||
static char com[10000];
|
||||
static int *nlen;
|
||||
int left, right;
|
||||
int res;
|
||||
static char **name, **seq, **nogap;
|
||||
static int **gapmap;
|
||||
static int *order;
|
||||
int i, j;
|
||||
FILE *infp;
|
||||
RNApair ***pairprob;
|
||||
RNApair **alnpairprob;
|
||||
RNApair *pairprobpt;
|
||||
RNApair *pt;
|
||||
int *alnpairnum;
|
||||
double prob;
|
||||
int adpos;
|
||||
|
||||
arguments( argc, argv );
|
||||
|
||||
if( inputfile )
|
||||
{
|
||||
infp = fopen( inputfile, "r" );
|
||||
if( !infp )
|
||||
{
|
||||
fprintf( stderr, "Cannot open %s\n", inputfile );
|
||||
exit( 1 );
|
||||
}
|
||||
}
|
||||
else
|
||||
infp = stdin;
|
||||
|
||||
if( !whereiscontrafold )
|
||||
whereiscontrafold = "";
|
||||
|
||||
getnumlen( infp );
|
||||
rewind( infp );
|
||||
|
||||
if( dorp != 'd' )
|
||||
{
|
||||
fprintf( stderr, "nuc only\n" );
|
||||
exit( 1 );
|
||||
}
|
||||
|
||||
seq = AllocateCharMtx( njob, nlenmax*2+1 );
|
||||
nogap = AllocateCharMtx( njob, nlenmax*2+1 );
|
||||
gapmap = AllocateIntMtx( njob, nlenmax*2+1 );
|
||||
order = AllocateIntVec( njob );
|
||||
name = AllocateCharMtx( njob, B+1 );
|
||||
nlen = AllocateIntVec( njob );
|
||||
pairprob = (RNApair ***)calloc( njob, sizeof( RNApair ** ) );
|
||||
alnpairprob = (RNApair **)calloc( nlenmax, sizeof( RNApair * ) );
|
||||
alnpairnum = AllocateIntVec( nlenmax );
|
||||
|
||||
for( i=0; i<nlenmax; i++ ) alnpairnum[i] = 0;
|
||||
|
||||
readData_pointer( infp, name, nlen, seq );
|
||||
fclose( infp );
|
||||
|
||||
for( i=0; i<njob; i++ )
|
||||
{
|
||||
pairprob[i] = (RNApair **)calloc( nlenmax, sizeof( RNApair * ) );
|
||||
for( j=0; j<nlenmax; j++ )
|
||||
{
|
||||
pairprob[i][j] = (RNApair *)calloc( 1, sizeof( RNApair ) );
|
||||
pairprob[i][j][0].bestpos = -1;
|
||||
pairprob[i][j][0].bestscore = -1.0;
|
||||
}
|
||||
unknown_n( nogap[i], seq[i] );
|
||||
order[i] = i;
|
||||
}
|
||||
for( j=0; j<nlenmax; j++ )
|
||||
{
|
||||
alnpairprob[j] = (RNApair *)calloc( 1, sizeof( RNApair ) );
|
||||
alnpairprob[j][0].bestpos = -1;
|
||||
alnpairprob[j][0].bestscore = -1.0;
|
||||
}
|
||||
|
||||
|
||||
constants( njob, seq );
|
||||
|
||||
fprintf( stderr, "running contrafold\n" );
|
||||
for( i=0; i<njob; i++ )
|
||||
{
|
||||
fprintf( stderr, "%d / %d\n", i+1, njob );
|
||||
commongappick_record( 1, nogap+i, gapmap[i] );
|
||||
infp = fopen( "_contrafoldin", "w" );
|
||||
fprintf( infp, ">in\n%s\n", nogap[i] );
|
||||
fclose( infp );
|
||||
#if 0 // contrafold v1
|
||||
sprintf( com, "env PATH=%s contrafold predict _contrafoldin --posteriors 0.01 > _contrafoldout", whereiscontrafold );
|
||||
#else // contrafold v2
|
||||
sprintf( com, "env PATH=%s contrafold predict _contrafoldin --posteriors 0.01 _contrafoldout", whereiscontrafold );
|
||||
#endif
|
||||
res = system( com );
|
||||
if( res )
|
||||
{
|
||||
fprintf( stderr, "error in contrafold\n" );
|
||||
fprintf( stderr, "=================================================================\n" );
|
||||
fprintf( stderr, "=================================================================\n" );
|
||||
fprintf( stderr, "==\n" );
|
||||
fprintf( stderr, "== This version of MAFFT supports CONTRAfold v2.02.\n" );
|
||||
fprintf( stderr, "== If you have a lower version of CONTRAfold installed in the\n" );
|
||||
fprintf( stderr, "== %s directory,\n", whereiscontrafold );
|
||||
fprintf( stderr, "== please update it!\n" );
|
||||
fprintf( stderr, "==\n" );
|
||||
fprintf( stderr, "=================================================================\n" );
|
||||
fprintf( stderr, "=================================================================\n" );
|
||||
exit( 1 );
|
||||
}
|
||||
|
||||
|
||||
infp = fopen( "_contrafoldout", "r" );
|
||||
readcontrafold( infp, pairprob[i], nlenmax );
|
||||
fclose( infp );
|
||||
fprintf( stdout, ">%d\n", i );
|
||||
outcontrafold( stdout, pairprob[i], nlenmax );
|
||||
}
|
||||
|
||||
for( i=0; i<njob; i++ )
|
||||
{
|
||||
for( j=0; j<nlen[i]; j++ ) for( pairprobpt=pairprob[i][j]; pairprobpt->bestpos!=-1; pairprobpt++ )
|
||||
{
|
||||
left = gapmap[i][j];
|
||||
right = gapmap[i][pairprobpt->bestpos];
|
||||
prob = pairprobpt->bestscore;
|
||||
|
||||
for( pt=alnpairprob[left]; pt->bestpos!=-1; pt++ )
|
||||
if( pt->bestpos == right ) break;
|
||||
|
||||
if( pt->bestpos == -1 )
|
||||
{
|
||||
alnpairprob[left] = (RNApair *)realloc( alnpairprob[left], (alnpairnum[left]+2) * sizeof( RNApair ) );
|
||||
adpos = alnpairnum[left];
|
||||
alnpairnum[left]++;
|
||||
alnpairprob[left][adpos].bestscore = 0.0;
|
||||
alnpairprob[left][adpos].bestpos = right;
|
||||
alnpairprob[left][adpos+1].bestscore = -1.0;
|
||||
alnpairprob[left][adpos+1].bestpos = -1;
|
||||
pt = alnpairprob[left]+adpos;
|
||||
}
|
||||
else
|
||||
adpos = pt-alnpairprob[left];
|
||||
|
||||
pt->bestscore += prob;
|
||||
if( pt->bestpos != right )
|
||||
{
|
||||
fprintf( stderr, "okashii!\n" );
|
||||
exit( 1 );
|
||||
}
|
||||
// fprintf( stderr, "adding %d-%d, %f\n", left, right, prob );
|
||||
}
|
||||
}
|
||||
return( 0 );
|
||||
|
||||
#if 0
|
||||
fprintf( stdout, "result=\n" );
|
||||
|
||||
for( i=0; i<nlenmax; i++ ) for( pairprobpt=alnpairprob[i]; pairprobpt->bestpos!=-1; pairprobpt++ )
|
||||
{
|
||||
pairprobpt->bestscore /= (double)njob;
|
||||
left = i;
|
||||
right = pairprobpt->bestpos;
|
||||
prob = pairprobpt->bestscore;
|
||||
fprintf( stdout, "%d-%d, %f\n", left, right, prob );
|
||||
}
|
||||
|
||||
return( 0 );
|
||||
#endif
|
||||
}
|
64
mafft/src/mafft-7.487-with-extensions/core/countlen.c
Normal file
64
mafft/src/mafft-7.487-with-extensions/core/countlen.c
Normal file
|
@ -0,0 +1,64 @@
|
|||
#include "mltaln.h"
|
||||
|
||||
#define DEBUG 0
|
||||
|
||||
void arguments( int argc, char *argv[] )
|
||||
{
|
||||
int c;
|
||||
|
||||
while( --argc > 0 && (*++argv)[0] == '-' )
|
||||
{
|
||||
while ( (c = *++argv[0]) )
|
||||
{
|
||||
switch( c )
|
||||
{
|
||||
case 'i':
|
||||
inputfile = *++argv;
|
||||
// fprintf( stderr, "inputfile = %s\n", inputfile );
|
||||
--argc;
|
||||
goto nextoption;
|
||||
default:
|
||||
fprintf( stderr, "illegal option %c\n", c );
|
||||
argc = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
nextoption:
|
||||
;
|
||||
}
|
||||
if( argc != 0 )
|
||||
{
|
||||
fprintf( stderr, "options: Check source file !\n" );
|
||||
exit( 1 );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int main( int argc, char *argv[] )
|
||||
{
|
||||
FILE *infp;
|
||||
int nlenmin;
|
||||
double nfreq;
|
||||
|
||||
arguments( argc, argv );
|
||||
|
||||
if( inputfile )
|
||||
{
|
||||
infp = fopen( inputfile, "r" );
|
||||
if( !infp )
|
||||
{
|
||||
fprintf( stderr, "Cannot open %s\n", inputfile );
|
||||
exit( 1 );
|
||||
}
|
||||
}
|
||||
else
|
||||
infp = stdin;
|
||||
|
||||
dorp = NOTSPECIFIED;
|
||||
getnumlen_nogap_countn( infp, &nlenmin, &nfreq );
|
||||
|
||||
fprintf( stdout, "%d x %d - %d %c nfreq=%f\n", njob, nlenmax, nlenmin, dorp, nfreq );
|
||||
|
||||
fclose( infp );
|
||||
return( 0 );
|
||||
}
|
1366
mafft/src/mafft-7.487-with-extensions/core/dash_client.go
Normal file
1366
mafft/src/mafft-7.487-with-extensions/core/dash_client.go
Normal file
File diff suppressed because it is too large
Load diff
175
mafft/src/mafft-7.487-with-extensions/core/defs.c
Normal file
175
mafft/src/mafft-7.487-with-extensions/core/defs.c
Normal file
|
@ -0,0 +1,175 @@
|
|||
#include "mltaln.h"
|
||||
#include "dp.h"
|
||||
|
||||
TLS int commonAlloc1 = 0;
|
||||
TLS int commonAlloc2 = 0;
|
||||
TLS int **commonIP = NULL;
|
||||
TLS int **commonJP = NULL;
|
||||
int nthread = 1;
|
||||
int nthreadpair = 1;
|
||||
int randomseed = 0;
|
||||
int parallelizationstrategy = BAATARI1;
|
||||
|
||||
|
||||
char modelname[500];
|
||||
int njob, nlenmax;
|
||||
int amino_n[0x100];
|
||||
char amino_grp[0x100];
|
||||
//int amino_dis[0x100][0x100];
|
||||
int **amino_dis = NULL;
|
||||
double **n_disLN = NULL;
|
||||
//double amino_dis_consweight_multi[0x100][0x100];
|
||||
double **amino_dis_consweight_multi = NULL;
|
||||
int **n_dis = NULL;
|
||||
int **n_disFFT = NULL;
|
||||
double **n_dis_consweight_multi = NULL;
|
||||
unsigned char amino[0x100];
|
||||
double polarity[0x100];
|
||||
double volume[0x100];
|
||||
int ribosumdis[37][37];
|
||||
|
||||
int ppid;
|
||||
double thrinter;
|
||||
double fastathreshold;
|
||||
int pslocal, ppslocal;
|
||||
int constraint;
|
||||
int divpairscore;
|
||||
int fmodel; // 1-> fmodel 0->default -1->raw
|
||||
int nblosum; // 45, 50, 62, 80
|
||||
int kobetsubunkatsu;
|
||||
int bunkatsu;
|
||||
int dorp = NOTSPECIFIED; // arguments de shitei suruto, tbfast -> pairlocalalign no yobidashi de futsugou
|
||||
int niter;
|
||||
int contin;
|
||||
int calledByXced;
|
||||
int devide;
|
||||
int scmtd;
|
||||
int weight;
|
||||
int utree;
|
||||
int tbutree;
|
||||
int refine;
|
||||
int check;
|
||||
double cut;
|
||||
int cooling;
|
||||
int trywarp = 0;
|
||||
int penalty, ppenalty, penaltyLN;
|
||||
int penalty_dist, ppenalty_dist;
|
||||
int RNApenalty, RNAppenalty;
|
||||
int RNApenalty_ex, RNAppenalty_ex;
|
||||
int penalty_ex, ppenalty_ex, penalty_exLN;
|
||||
int penalty_EX, ppenalty_EX;
|
||||
int penalty_OP, ppenalty_OP;
|
||||
int penalty_shift, ppenalty_shift;
|
||||
double penalty_shift_factor = 100.0;
|
||||
int RNAthr, RNApthr;
|
||||
int offset, poffset, offsetLN, offsetFFT;
|
||||
int scoremtx;
|
||||
int TMorJTT;
|
||||
char use_fft;
|
||||
char force_fft;
|
||||
int nevermemsave;
|
||||
int fftscore;
|
||||
int fftWinSize;
|
||||
int fftThreshold;
|
||||
int fftRepeatStop;
|
||||
int fftNoAnchStop;
|
||||
int divWinSize;
|
||||
int divThreshold;
|
||||
int disp;
|
||||
int outgap = 1;
|
||||
char alg;
|
||||
int cnst;
|
||||
int mix;
|
||||
int tbitr;
|
||||
int tbweight;
|
||||
int tbrweight;
|
||||
int disopt;
|
||||
int pamN;
|
||||
int checkC;
|
||||
double geta2;
|
||||
int treemethod;
|
||||
int kimuraR;
|
||||
char *swopt;
|
||||
int fftkeika;
|
||||
int score_check;
|
||||
int makedistmtx;
|
||||
char *inputfile;
|
||||
char *addfile;
|
||||
int addprofile = 1;
|
||||
int rnakozo;
|
||||
char rnaprediction;
|
||||
int scoreout = 0;
|
||||
int spscoreout = 0;
|
||||
int outnumber = 0;
|
||||
int legacygapcost = 0;
|
||||
double minimumweight = 0.0005;
|
||||
int nwildcard = 0;
|
||||
|
||||
char *signalSM;
|
||||
FILE *prep_g;
|
||||
FILE *trap_g;
|
||||
char **seq_g;
|
||||
char **res_g;
|
||||
|
||||
double consweight_multi = 1.0;
|
||||
double consweight_rna = 0.0;
|
||||
char RNAscoremtx = 'n';
|
||||
|
||||
TLS char *newgapstr = "-";
|
||||
|
||||
int nalphabets = 26;
|
||||
int nscoredalphabets = 20;
|
||||
|
||||
double specificityconsideration = 0.0;
|
||||
int ndistclass = 10;
|
||||
int maxdistclass = -1;
|
||||
|
||||
int gmsg = 0;
|
||||
|
||||
double sueff_global = SUEFF;
|
||||
|
||||
double lenfaca, lenfacb, lenfacc, lenfacd;
|
||||
int maxl, tsize;
|
||||
|
||||
|
||||
|
||||
void initglobalvariables()
|
||||
{
|
||||
commonAlloc1 = 0;
|
||||
commonAlloc2 = 0;
|
||||
commonIP = NULL;
|
||||
commonJP = NULL;
|
||||
nthread = 1;
|
||||
randomseed = 0;
|
||||
parallelizationstrategy = BAATARI1;
|
||||
|
||||
trywarp = 0;
|
||||
penalty_shift_factor = 100.0;
|
||||
outgap = 1;
|
||||
addprofile = 1;
|
||||
scoreout = 0;
|
||||
outnumber = 0;
|
||||
legacygapcost = 0;
|
||||
consweight_multi = 1.0;
|
||||
consweight_rna = 0.0;
|
||||
RNAscoremtx = 'n';
|
||||
|
||||
newgapstr = "-";
|
||||
|
||||
nalphabets = 26;
|
||||
nscoredalphabets = 20;
|
||||
|
||||
specificityconsideration = 0.0;
|
||||
ndistclass = 10;
|
||||
maxdistclass = -1;
|
||||
|
||||
gmsg = 0;
|
||||
}
|
||||
|
||||
// for usetmpfile
|
||||
int compacttree = 0;
|
||||
int lhlimit = INT_MAX;
|
||||
int specifictarget = 0;
|
||||
int nadd = 0; // <- static in tbfast.c, pairlocalalign.c
|
||||
int usenaivescoreinsteadofalignmentscore = 0;
|
||||
int nthreadreadlh = 1;
|
5254
mafft/src/mafft-7.487-with-extensions/core/disttbfast.c
Normal file
5254
mafft/src/mafft-7.487-with-extensions/core/disttbfast.c
Normal file
File diff suppressed because it is too large
Load diff
396
mafft/src/mafft-7.487-with-extensions/core/dndblast.c
Normal file
396
mafft/src/mafft-7.487-with-extensions/core/dndblast.c
Normal file
|
@ -0,0 +1,396 @@
|
|||
#include "mltaln.h"
|
||||
#define DEBUG 0
|
||||
#define TEST 0
|
||||
|
||||
|
||||
int howmanyx( char *s )
|
||||
{
|
||||
int val = 0;
|
||||
if( scoremtx == -1 )
|
||||
{
|
||||
do
|
||||
{
|
||||
if( !strchr( "atgcuATGCU", *s ) ) val++;
|
||||
} while( *++s );
|
||||
}
|
||||
else
|
||||
{
|
||||
do
|
||||
{
|
||||
if( !strchr( "ARNDCQEGHILKMFPSTWYV", *s ) ) val++;
|
||||
} while( *++s );
|
||||
}
|
||||
return( val );
|
||||
}
|
||||
|
||||
void arguments( int argc, char *argv[] )
|
||||
{
|
||||
int c;
|
||||
|
||||
inputfile = NULL;
|
||||
disopt = 0;
|
||||
divpairscore = 0;
|
||||
|
||||
while( --argc > 0 && (*++argv)[0] == '-' )
|
||||
{
|
||||
while ( (c = *++argv[0]) )
|
||||
{
|
||||
switch( c )
|
||||
{
|
||||
case 'i':
|
||||
inputfile = *++argv;
|
||||
fprintf( stderr, "inputfile = %s\n", inputfile );
|
||||
--argc;
|
||||
goto nextoption;
|
||||
case 'I':
|
||||
disopt = 1;
|
||||
break;
|
||||
default:
|
||||
fprintf( stderr, "illegal option %c\n", c );
|
||||
argc = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
nextoption:
|
||||
;
|
||||
|
||||
}
|
||||
if( argc != 0 )
|
||||
{
|
||||
fprintf( stderr, "options: -i\n" );
|
||||
exit( 1 );
|
||||
}
|
||||
}
|
||||
|
||||
int main( int argc, char *argv[] )
|
||||
{
|
||||
int ktuple;
|
||||
int i, j;
|
||||
FILE *infp;
|
||||
FILE *hat2p;
|
||||
FILE *hat3p;
|
||||
char **seq = NULL; // by D.Mathog
|
||||
char **seq1;
|
||||
static char **name;
|
||||
static char **name1;
|
||||
static int nlen1[M];
|
||||
double **mtx;
|
||||
double **mtx2;
|
||||
static int nlen[M];
|
||||
char b[B];
|
||||
double max;
|
||||
char com[1000];
|
||||
int opt[M];
|
||||
int res;
|
||||
char *home;
|
||||
char queryfile[B];
|
||||
char datafile[B];
|
||||
char fastafile[B];
|
||||
char hat2file[B];
|
||||
int pid = (int)getpid();
|
||||
LocalHom **localhomtable, *tmpptr;
|
||||
#if 1
|
||||
home = getenv( "HOME" );
|
||||
#else /* $HOME wo tsukau to fasta ni watasu hikisuu ga afureru */
|
||||
home = NULL;
|
||||
#endif
|
||||
|
||||
#if DEBUG
|
||||
if( home ) fprintf( stderr, "home = %s\n", home );
|
||||
#endif
|
||||
if( !home ) home = "";
|
||||
sprintf( queryfile, "%s/tmp/query-%d", home, pid );
|
||||
sprintf( datafile, "%s/tmp/data-%d", home, pid );
|
||||
sprintf( fastafile, "%s/tmp/fasta-%d", home, pid );
|
||||
sprintf( hat2file, "hat2-%d", pid );
|
||||
|
||||
|
||||
arguments( argc, argv );
|
||||
|
||||
if( inputfile )
|
||||
{
|
||||
infp = fopen( inputfile, "r" );
|
||||
if( !infp )
|
||||
{
|
||||
fprintf( stderr, "Cannot open %s\n", inputfile );
|
||||
exit( 1 );
|
||||
}
|
||||
}
|
||||
else
|
||||
infp = stdin;
|
||||
#if 0
|
||||
PreRead( infp, &njob, &nlenmax );
|
||||
#else
|
||||
dorp = NOTSPECIFIED;
|
||||
getnumlen( infp );
|
||||
#endif
|
||||
|
||||
if( dorp == 'd' )
|
||||
{
|
||||
scoremtx = -1;
|
||||
pamN = NOTSPECIFIED;
|
||||
}
|
||||
else
|
||||
{
|
||||
nblosum = 62;
|
||||
scoremtx = 1;
|
||||
}
|
||||
constants( njob, seq );
|
||||
|
||||
rewind( infp );
|
||||
|
||||
name = AllocateCharMtx( njob, B+1 );
|
||||
name1 = AllocateCharMtx( njob, B+1 );
|
||||
seq = AllocateCharMtx( njob, nlenmax+1 );
|
||||
seq1 = AllocateCharMtx( 2, nlenmax+1 );
|
||||
mtx = AllocateDoubleMtx( njob, njob );
|
||||
mtx2 = AllocateDoubleMtx( njob, njob );
|
||||
localhomtable = (LocalHom **)calloc( njob, sizeof( LocalHom *) );
|
||||
for( i=0; i<njob; i++)
|
||||
{
|
||||
localhomtable[i] = (LocalHom *)calloc( njob, sizeof( LocalHom ) );
|
||||
for( j=0; j<njob; j++)
|
||||
{
|
||||
localhomtable[i][j].start1 = -1;
|
||||
localhomtable[i][j].end1 = -1;
|
||||
localhomtable[i][j].start2 = -1;
|
||||
localhomtable[i][j].end2 = -1;
|
||||
localhomtable[i][j].opt = -1.0;
|
||||
localhomtable[i][j].next = NULL;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#if 0
|
||||
FRead( infp, name, nlen, seq );
|
||||
#else
|
||||
readData_pointer( infp, name, nlen, seq );
|
||||
#endif
|
||||
fclose( infp );
|
||||
|
||||
if( scoremtx == -1 ) ktuple = 6;
|
||||
else ktuple = 1;
|
||||
|
||||
for( i=0; i<njob; i++ )
|
||||
{
|
||||
gappick0( seq1[0], seq[i] );
|
||||
strcpy( seq[i], seq1[0] );
|
||||
}
|
||||
for( j=0; j<njob; j++ )
|
||||
{
|
||||
sprintf( name1[j], "+==========+%d ", j );
|
||||
nlen1[j] = nlen[j];
|
||||
}
|
||||
|
||||
for( i=0; i<njob; i++ )
|
||||
{
|
||||
// fprintf( stderr, "### i = %d\n", i );
|
||||
|
||||
if( i % 10 == 0 )
|
||||
{
|
||||
fprintf( stderr, "formatting .. " );
|
||||
hat2p = fopen( datafile, "w" );
|
||||
if( !hat2p ) ErrorExit( "Cannot open datafile." );
|
||||
WriteForFasta( hat2p, njob-i, name1+i, nlen1+i, seq+i );
|
||||
fclose( hat2p );
|
||||
|
||||
if( scoremtx == -1 )
|
||||
sprintf( com, "formatdb -p f -i %s -o F", datafile );
|
||||
else
|
||||
sprintf( com, "formatdb -i %s -o F", datafile );
|
||||
system( com );
|
||||
fprintf( stderr, "done.\n" );
|
||||
}
|
||||
|
||||
hat2p = fopen( queryfile, "w" );
|
||||
if( !hat2p ) ErrorExit( "Cannot open queryfile." );
|
||||
WriteForFasta( hat2p, 1, name1+i, nlen+i, seq+i );
|
||||
fclose( hat2p );
|
||||
|
||||
|
||||
if( scoremtx == -1 )
|
||||
sprintf( com, "blastall -e 1e10 -p blastn -m 7 -i %s -d %s > %s", queryfile, datafile, fastafile );
|
||||
else
|
||||
sprintf( com, "blastall -G 10 -E 1 -e 1e10 -p blastp -m 7 -i %s -d %s > %s", queryfile, datafile, fastafile );
|
||||
res = system( com );
|
||||
if( res ) ErrorExit( "error in fasta" );
|
||||
|
||||
|
||||
hat2p = fopen( fastafile, "r" );
|
||||
if( hat2p == NULL )
|
||||
ErrorExit( "file 'fasta.$$' does not exist\n" );
|
||||
res = ReadBlastm7( hat2p, mtx[i], i, name1, localhomtable[i] );
|
||||
fclose( hat2p );
|
||||
|
||||
#if 0
|
||||
for( j=0; j<njob; j++ )
|
||||
{
|
||||
for( tmpptr=localhomtable[i]+j; tmpptr; tmpptr=tmpptr->next )
|
||||
{
|
||||
if( tmpptr->opt == -1.0 ) continue;
|
||||
// fprintf( stderr, "%d %d %d %6.3f %d %d %d %d %p\n", i, j, tmpptr->overlapaa, tmpptr->opt, tmpptr->start1, tmpptr->end1, tmpptr->start2, tmpptr->end2, tmpptr->next );
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if( res < njob-i+i%10 )
|
||||
{
|
||||
fprintf( stderr, "WARNING: count (blast) = %d < %d\n", res, njob-i+i%10 );
|
||||
}
|
||||
|
||||
|
||||
#if 0
|
||||
{
|
||||
int ii, jj;
|
||||
if( i < njob-1 ) for( jj=i; jj<i+5; jj++ )
|
||||
fprintf( stdout, "mtx[%d][%d] = %f\n", i+1, jj+1, mtx[i][jj] );
|
||||
}
|
||||
#endif
|
||||
fprintf( stderr, "query : %4d / %d\n", i+1, njob );
|
||||
}
|
||||
|
||||
#if 1
|
||||
fprintf( stderr, "##### writing hat3\n" );
|
||||
hat3p = fopen( "hat3", "w" );
|
||||
if( !hat3p ) ErrorExit( "Cannot open hat3." );
|
||||
for( i=0; i<njob; i++ ) for( j=0; j<njob; j++ )
|
||||
{
|
||||
// fprintf( stderr, "mtx[%d][%d] = %f, mtx[%d][%d] = %f\n", i, j, mtx[i][j], j, i, mtx[j][i] );
|
||||
if( i == j ) continue;
|
||||
if( mtx[i][j] == mtx[j][i] && i > j ) continue;
|
||||
if( mtx[j][i] > mtx[i][j] ) continue;
|
||||
for( tmpptr=localhomtable[i]+j; tmpptr; tmpptr=tmpptr->next )
|
||||
{
|
||||
if( tmpptr->opt == -1.0 ) continue;
|
||||
fprintf( hat3p, "%d %d %d %6.3f %d %d %d %d %p\n", i, j, tmpptr->overlapaa, tmpptr->opt, tmpptr->start1, tmpptr->end1, tmpptr->start2, tmpptr->end2, (void *)tmpptr->next );
|
||||
}
|
||||
}
|
||||
fclose( hat3p );
|
||||
#endif
|
||||
|
||||
for( i=0; i<njob; i++ )
|
||||
{
|
||||
// fprintf( stderr, "### i = %d\n", i );
|
||||
hat2p = fopen( datafile, "w" );
|
||||
if( !hat2p ) ErrorExit( "Cannot open datafile." );
|
||||
WriteForFasta( hat2p, njob-i, name1+i, nlen1+i, seq+i );
|
||||
fclose( hat2p );
|
||||
|
||||
// seq1[0] = seq[i];
|
||||
// nlen1[0] = nlen[i];
|
||||
|
||||
hat2p = fopen( queryfile, "w" );
|
||||
if( !hat2p ) ErrorExit( "Cannot open queryfile." );
|
||||
WriteForFasta( hat2p, 1, name1+i, nlen+i, seq+i );
|
||||
fclose( hat2p );
|
||||
|
||||
|
||||
if( scoremtx == -1 )
|
||||
sprintf( com, "fasta34 -z3 -m10 -n -Q -b%d -E%d -d%d %s %s %d > %s", M, M, 0, queryfile, datafile, ktuple, fastafile );
|
||||
else
|
||||
sprintf( com, "fasta34 -z3 -m10 -Q -b%d -E%d -d%d %s %s %d > %s", M, M, 0, queryfile, datafile, ktuple, fastafile );
|
||||
res = system( com );
|
||||
if( res ) ErrorExit( "error in fasta" );
|
||||
|
||||
|
||||
hat2p = fopen( fastafile, "r" );
|
||||
if( hat2p == NULL )
|
||||
ErrorExit( "file 'fasta.$$' does not exist\n" );
|
||||
res = ReadFasta34noalign( hat2p, mtx[i], i, name1, localhomtable[i] );
|
||||
fclose( hat2p );
|
||||
if( res < njob - i )
|
||||
{
|
||||
fprintf( stderr, "count (fasta34 -z 3) = %d\n", res );
|
||||
exit( 1 );
|
||||
}
|
||||
|
||||
|
||||
if( i == 0 )
|
||||
for( j=0; j<njob; j++ ) opt[j] = (int)mtx[0][j];
|
||||
|
||||
|
||||
#if 0
|
||||
{
|
||||
int ii, jj;
|
||||
if( i < njob-1 ) for( jj=i; jj<i+5; jj++ )
|
||||
fprintf( stdout, "mtx[%d][%d] = %f\n", i+1, jj+1, mtx[i][jj] );
|
||||
}
|
||||
#endif
|
||||
fprintf( stderr, "query : %4d\r", i+1 );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
for( i=0; i<njob; i++ )
|
||||
{
|
||||
max = mtx[i][i];
|
||||
if( max == 0.0 )
|
||||
{
|
||||
for( j=0; j<njob; j++ )
|
||||
mtx2[i][j] = 2.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
for( j=0; j<njob; j++ )
|
||||
{
|
||||
mtx2[i][j] = ( max - mtx[MIN(i,j)][MAX(i,j)] ) / max * 2.0;
|
||||
// fprintf( stdout, "max = %f, mtx[%d][%d] = %f -> %f\n", max, i+1, j+1, mtx[i][j], mtx2[i][j] );
|
||||
}
|
||||
}
|
||||
}
|
||||
for( i=0; i<njob-1; i++ ) for( j=i+1; j<njob; j++ )
|
||||
{
|
||||
// fprintf( stdout, "mtx2[%d][%d] = %f, %f\n", i+1, j+1, mtx2[i][j], mtx2[j][i] );
|
||||
mtx2[i][j] = MIN( mtx2[i][j], mtx2[j][i] );
|
||||
}
|
||||
|
||||
#if 0
|
||||
{
|
||||
int ii, jj;
|
||||
if( i < njob-1 ) for( jj=i+1; jj<njob; jj++ )
|
||||
fprintf( stderr, "mtx2[][] = %f\n", mtx2[i][jj] );
|
||||
}
|
||||
#endif
|
||||
|
||||
for( i=0; i<njob; i++ ) name[i][0] = '=';
|
||||
|
||||
if( disopt )
|
||||
{
|
||||
strcpy( b, name[0] );
|
||||
sprintf( name[0], "=query====lgth=%04d-%04d %.*s", nlen[0], howmanyx( seq[0] ), B-30, b );
|
||||
#if 0
|
||||
strins( b, name[0] );
|
||||
#endif
|
||||
for( i=1; i<njob; i++ )
|
||||
{
|
||||
strcpy( b, name[i] );
|
||||
sprintf( name[i], "=opt=%04d=lgth=%04d-%04d %.*s", opt[i], nlen[i], howmanyx( seq[i] ), B-30, b );
|
||||
#if 0
|
||||
strins( b, name[i] );
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
hat2p = fopen( hat2file, "w" );
|
||||
if( !hat2p ) ErrorExit( "Cannot open hat2." );
|
||||
WriteHat2_pointer( hat2p, njob, name, mtx2 );
|
||||
fclose( hat2p );
|
||||
|
||||
|
||||
sprintf( com, "/bin/rm %s %s %s", queryfile, datafile, fastafile );
|
||||
system( com );
|
||||
|
||||
#if 0
|
||||
sprintf( com, ALNDIR "/supgsdl < %s", hat2file );
|
||||
res = system( com );
|
||||
if( res ) ErrorExit( "error in spgsdl" );
|
||||
#endif
|
||||
|
||||
sprintf( com, "mv %s hat2", hat2file );
|
||||
res = system( com );
|
||||
if( res ) ErrorExit( "error in mv" );
|
||||
|
||||
SHOWVERSION;
|
||||
exit( 0 );
|
||||
}
|
241
mafft/src/mafft-7.487-with-extensions/core/dndfast4.c
Normal file
241
mafft/src/mafft-7.487-with-extensions/core/dndfast4.c
Normal file
|
@ -0,0 +1,241 @@
|
|||
#include "mltaln.h"
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
#define DEBUG 0
|
||||
#define TEST 0
|
||||
|
||||
|
||||
int howmanyx( char *s )
|
||||
{
|
||||
int val = 0;
|
||||
if( scoremtx == -1 )
|
||||
{
|
||||
do
|
||||
{
|
||||
if( !strchr( "atgcuATGCU", *s ) ) val++;
|
||||
} while( *++s );
|
||||
}
|
||||
else
|
||||
{
|
||||
do
|
||||
{
|
||||
if( !strchr( "ARNDCQEGHILKMFPSTWYV", *s ) ) val++;
|
||||
} while( *++s );
|
||||
}
|
||||
return( val );
|
||||
}
|
||||
|
||||
void arguments( int argc, char *argv[] )
|
||||
{
|
||||
int c;
|
||||
|
||||
disopt = 0;
|
||||
|
||||
while( --argc > 0 && (*++argv)[0] == '-' )
|
||||
while ( c = *++argv[0] )
|
||||
switch( c )
|
||||
{
|
||||
case 'i':
|
||||
disopt = 1;
|
||||
break;
|
||||
default:
|
||||
fprintf( stderr, "illegal option %c\n", c );
|
||||
argc = 0;
|
||||
break;
|
||||
}
|
||||
if( argc != 0 )
|
||||
{
|
||||
fprintf( stderr, "options: -i\n" );
|
||||
exit( 1 );
|
||||
}
|
||||
}
|
||||
|
||||
int main( int argc, char *argv[] )
|
||||
{
|
||||
int ktuple;
|
||||
int i, j;
|
||||
FILE *hat2p;
|
||||
char **seq;
|
||||
char **seq1;
|
||||
static char name[M][B];
|
||||
static char name1[M][B];
|
||||
static int nlen1[M];
|
||||
double **mtx;
|
||||
double **mtx2;
|
||||
static int nlen[M];
|
||||
char b[B];
|
||||
double max;
|
||||
char com[B];
|
||||
int opt[M];
|
||||
int res;
|
||||
char *home;
|
||||
char queryfile[B];
|
||||
char datafile[B];
|
||||
char fastafile[B];
|
||||
char hat2file[B];
|
||||
int pid = (int)getpid();
|
||||
#if 0
|
||||
home = getenv( "HOME" );
|
||||
#else /* $HOME wo tsukau to fasta ni watasu hikisuu ga afureru */
|
||||
home = NULL;
|
||||
#endif
|
||||
|
||||
#if DEBUG
|
||||
if( home ) fprintf( stderr, "home = %s\n", home );
|
||||
#endif
|
||||
if( !home ) home = "";
|
||||
sprintf( queryfile, "%s/tmp/query-%d\0", home, pid );
|
||||
sprintf( datafile, "%s/tmp/data-%d\0", home, pid );
|
||||
sprintf( fastafile, "%s/tmp/fasta-%d\0", home, pid );
|
||||
sprintf( hat2file, "hat2-%d\0", pid );
|
||||
|
||||
arguments( argc, argv );
|
||||
#if 0
|
||||
PreRead( stdin, &njob, &nlenmax );
|
||||
#else
|
||||
getnumlen( stdin );
|
||||
#endif
|
||||
rewind( stdin );
|
||||
|
||||
seq = AllocateCharMtx( njob, nlenmax+1 );
|
||||
seq1 = AllocateCharMtx( 2, nlenmax+1 );
|
||||
mtx = AllocateDoubleMtx( njob, njob );
|
||||
mtx2 = AllocateDoubleMtx( njob, njob );
|
||||
|
||||
#if 0
|
||||
FRead( stdin, name, nlen, seq );
|
||||
#else
|
||||
readData( stdin, name, nlen, seq );
|
||||
#endif
|
||||
if( scoremtx == -1 ) ktuple = 6;
|
||||
else ktuple = 1;
|
||||
|
||||
for( i=0; i<njob; i++ )
|
||||
{
|
||||
gappick0( seq1[0], seq[i] );
|
||||
strcpy( seq[i], seq1[0] );
|
||||
}
|
||||
for( j=0; j<njob; j++ )
|
||||
{
|
||||
sprintf( name1[j], "+==========+%d \0", j );
|
||||
nlen1[j] = nlen[j];
|
||||
}
|
||||
hat2p = fopen( datafile, "w" );
|
||||
if( !hat2p ) ErrorExit( "Cannot open datafile." );
|
||||
WriteForFasta( hat2p, njob, name1, nlen1, seq );
|
||||
fclose( hat2p );
|
||||
|
||||
for( i=0; i<njob; i++ )
|
||||
{
|
||||
|
||||
hat2p = fopen( datafile, "w" );
|
||||
if( !hat2p ) ErrorExit( "Cannot open datafile." );
|
||||
WriteForFasta( hat2p, njob-i, name1+i, nlen1+i, seq+i );
|
||||
fclose( hat2p );
|
||||
|
||||
|
||||
seq1[0] = seq[i];
|
||||
nlen1[0] = nlen[i];
|
||||
|
||||
hat2p = fopen( queryfile, "w" );
|
||||
if( !hat2p ) ErrorExit( "Cannot open queryfile." );
|
||||
WriteForFasta( hat2p, 1, name1+i, nlen1, seq1 );
|
||||
fclose( hat2p );
|
||||
|
||||
if( scoremtx == -1 )
|
||||
sprintf( com, "fasta3 -n -Q -h -b%d -E%d -d%d %s %s %d > %s\0", M, M, 0, queryfile, datafile, ktuple, fastafile );
|
||||
else
|
||||
sprintf( com, "fasta3 -Q -h -b%d -E%d -d%d %s %s %d > %s\0", M, M, 0, queryfile, datafile, ktuple, fastafile );
|
||||
res = system( com );
|
||||
if( res ) ErrorExit( "error in fasta" );
|
||||
|
||||
hat2p = fopen( fastafile, "r" );
|
||||
if( hat2p == NULL )
|
||||
ErrorExit( "file 'fasta.$$' does not exist\n" );
|
||||
ReadFasta3( hat2p, mtx[i], njob-i, name1 );
|
||||
|
||||
if( i == 0 )
|
||||
for( j=0; j<njob; j++ ) opt[j] = (int)mtx[0][j];
|
||||
|
||||
fclose( hat2p );
|
||||
|
||||
#if 1
|
||||
{
|
||||
int ii, jj;
|
||||
if( i < njob-1 ) for( jj=i; jj<i+5; jj++ )
|
||||
fprintf( stdout, "mtx[%d][%d] = %f\n", i+1, jj+1, mtx[i][jj] );
|
||||
}
|
||||
#endif
|
||||
fprintf( stderr, "query : %#4d\n", i+1 );
|
||||
}
|
||||
|
||||
for( i=0; i<njob; i++ )
|
||||
{
|
||||
max = mtx[i][i];
|
||||
if( max == 0.0 )
|
||||
{
|
||||
for( j=0; j<njob; j++ )
|
||||
mtx2[i][j] = 2.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
for( j=0; j<njob; j++ )
|
||||
{
|
||||
mtx2[i][j] = ( max - mtx[MIN(i,j)][MAX(i,j)] ) / max * 2.0;
|
||||
// fprintf( stdout, "max = %f, mtx[%d][%d] = %f -> %f\n", max, i+1, j+1, mtx[i][j], mtx2[i][j] );
|
||||
}
|
||||
}
|
||||
}
|
||||
for( i=0; i<njob-1; i++ ) for( j=i+1; j<njob; j++ )
|
||||
{
|
||||
// fprintf( stdout, "mtx2[%d][%d] = %f, %f\n", i+1, j+1, mtx2[i][j], mtx2[j][i] );
|
||||
mtx2[i][j] = MIN( mtx2[i][j], mtx2[j][i] );
|
||||
}
|
||||
#if 0
|
||||
{
|
||||
int ii, jj;
|
||||
if( i < njob-1 ) for( jj=i+1; jj<njob; jj++ )
|
||||
fprintf( stderr, "mtx2[][] = %f\n", mtx2[i][jj] );
|
||||
}
|
||||
#endif
|
||||
|
||||
for( i=0; i<njob; i++ ) name[i][0] = '=';
|
||||
|
||||
if( disopt )
|
||||
{
|
||||
strcpy( b, name[0] );
|
||||
sprintf( name[0], "=query====lgth=%#04d-%04d %.*s\0", nlen[0], howmanyx( seq[0] ), B-30, b );
|
||||
#if 0
|
||||
strins( b, name[0] );
|
||||
#endif
|
||||
for( i=1; i<njob; i++ )
|
||||
{
|
||||
strcpy( b, name[i] );
|
||||
sprintf( name[i], "=opt=%#04d=lgth=%#04d-%04d %.*s\0", opt[i], nlen[i], howmanyx( seq[i] ), B-30, b );
|
||||
#if 0
|
||||
strins( b, name[i] );
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
hat2p = fopen( hat2file, "w" );
|
||||
if( !hat2p ) ErrorExit( "Cannot open hat2." );
|
||||
WriteHat2( hat2p, njob, name, mtx2 );
|
||||
fclose( hat2p );
|
||||
|
||||
sprintf( com, "/bin/rm %s %s %s", queryfile, datafile, fastafile );
|
||||
system( com );
|
||||
|
||||
#if 0
|
||||
sprintf( com, ALNDIR "/supgsdl < %s\0", hat2file );
|
||||
res = system( com );
|
||||
if( res ) ErrorExit( "error in spgsdl" );
|
||||
#endif
|
||||
|
||||
sprintf( com, "mv %s hat2", hat2file );
|
||||
res = system( com );
|
||||
if( res ) ErrorExit( "error in mv" );
|
||||
|
||||
SHOWVERSION;
|
||||
exit( 0 );
|
||||
}
|
340
mafft/src/mafft-7.487-with-extensions/core/dndfast7.c
Normal file
340
mafft/src/mafft-7.487-with-extensions/core/dndfast7.c
Normal file
|
@ -0,0 +1,340 @@
|
|||
#include "mltaln.h"
|
||||
#define DEBUG 0
|
||||
#define TEST 0
|
||||
|
||||
|
||||
int howmanyx( char *s )
|
||||
{
|
||||
int val = 0;
|
||||
if( scoremtx == -1 )
|
||||
{
|
||||
do
|
||||
{
|
||||
if( !strchr( "atgcuATGCU", *s ) ) val++;
|
||||
} while( *++s );
|
||||
}
|
||||
else
|
||||
{
|
||||
do
|
||||
{
|
||||
if( !strchr( "ARNDCQEGHILKMFPSTWYV", *s ) ) val++;
|
||||
} while( *++s );
|
||||
}
|
||||
return( val );
|
||||
}
|
||||
|
||||
void arguments( int argc, char *argv[] )
|
||||
{
|
||||
int c;
|
||||
|
||||
inputfile = NULL;
|
||||
disopt = 0;
|
||||
divpairscore = 0;
|
||||
swopt = "";
|
||||
|
||||
while( --argc > 0 && (*++argv)[0] == '-' )
|
||||
{
|
||||
while ( (c = *++argv[0]) )
|
||||
{
|
||||
switch( c )
|
||||
{
|
||||
case 'i':
|
||||
inputfile = *++argv;
|
||||
fprintf( stderr, "inputfile = %s\n", inputfile );
|
||||
--argc;
|
||||
goto nextoption;
|
||||
case 'I':
|
||||
disopt = 1;
|
||||
break;
|
||||
case 'A':
|
||||
swopt = "-A";
|
||||
break;
|
||||
default:
|
||||
fprintf( stderr, "illegal option %c\n", c );
|
||||
argc = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
nextoption:
|
||||
;
|
||||
}
|
||||
if( argc != 0 )
|
||||
{
|
||||
fprintf( stderr, "options: -i\n" );
|
||||
exit( 1 );
|
||||
}
|
||||
}
|
||||
|
||||
int main( int argc, char *argv[] )
|
||||
{
|
||||
int ktuple;
|
||||
int i, j;
|
||||
FILE *hat2p;
|
||||
FILE *hat3p;
|
||||
FILE *infp;
|
||||
char **seq = NULL; // by D.Mathog
|
||||
char **seq1;
|
||||
char **name;
|
||||
char **name1;
|
||||
static int nlen1[M];
|
||||
double **mtx;
|
||||
double **mtx2;
|
||||
static int nlen[M];
|
||||
static char b[B];
|
||||
double max;
|
||||
char com[1000];
|
||||
int opt[M];
|
||||
int res;
|
||||
char *home;
|
||||
char *fastapath;
|
||||
char queryfile[B];
|
||||
char datafile[B];
|
||||
char fastafile[B];
|
||||
char hat2file[B];
|
||||
int pid = (int)getpid();
|
||||
LocalHom **localhomtable, *tmpptr;
|
||||
#if 0
|
||||
home = getenv( "HOME" );
|
||||
#else /* $HOME wo tsukau to fasta ni watasu hikisuu ga afureru */
|
||||
home = NULL;
|
||||
#endif
|
||||
fastapath = getenv( "FASTA_4_MAFFT" );
|
||||
if( !fastapath )
|
||||
fastapath = "fasta34";
|
||||
|
||||
#if DEBUG
|
||||
if( home ) fprintf( stderr, "home = %s\n", home );
|
||||
#endif
|
||||
if( !home ) home = "";
|
||||
sprintf( queryfile, "%s/tmp/query-%d", home, pid );
|
||||
sprintf( datafile, "%s/tmp/data-%d", home, pid );
|
||||
sprintf( fastafile, "%s/tmp/fasta-%d", home, pid );
|
||||
sprintf( hat2file, "hat2-%d", pid );
|
||||
|
||||
|
||||
arguments( argc, argv );
|
||||
|
||||
if( inputfile )
|
||||
{
|
||||
infp = fopen( inputfile, "r" );
|
||||
if( !infp )
|
||||
{
|
||||
fprintf( stderr, "Cannot open %s\n", inputfile );
|
||||
exit( 1 );
|
||||
}
|
||||
}
|
||||
else
|
||||
infp = stdin;
|
||||
|
||||
|
||||
|
||||
#if 0
|
||||
PreRead( stdin, &njob, &nlenmax );
|
||||
#else
|
||||
dorp = NOTSPECIFIED;
|
||||
getnumlen( infp );
|
||||
#endif
|
||||
|
||||
if( dorp == 'd' )
|
||||
{
|
||||
scoremtx = -1;
|
||||
pamN = NOTSPECIFIED;
|
||||
}
|
||||
else
|
||||
{
|
||||
nblosum = 62;
|
||||
scoremtx = 1;
|
||||
}
|
||||
constants( njob, seq );
|
||||
|
||||
rewind( infp );
|
||||
|
||||
name = AllocateCharMtx( njob, B+1 );
|
||||
name1 = AllocateCharMtx( njob, B+1 );
|
||||
seq = AllocateCharMtx( njob, nlenmax+1 );
|
||||
seq1 = AllocateCharMtx( 2, nlenmax+1 );
|
||||
mtx = AllocateDoubleMtx( njob, njob );
|
||||
mtx2 = AllocateDoubleMtx( njob, njob );
|
||||
localhomtable = (LocalHom **)calloc( njob, sizeof( LocalHom *) );
|
||||
for( i=0; i<njob; i++)
|
||||
{
|
||||
localhomtable[i] = (LocalHom *)calloc( njob, sizeof( LocalHom ) );
|
||||
for( j=0; j<njob; j++)
|
||||
{
|
||||
localhomtable[i][j].start1 = -1;
|
||||
localhomtable[i][j].end1 = -1;
|
||||
localhomtable[i][j].start2 = -1;
|
||||
localhomtable[i][j].end2 = -1;
|
||||
localhomtable[i][j].opt = -1.0;
|
||||
localhomtable[i][j].next = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
#if 0
|
||||
FRead( infp, name, nlen, seq );
|
||||
#else
|
||||
readData_pointer( infp, name, nlen, seq );
|
||||
#endif
|
||||
fclose( infp );
|
||||
|
||||
if( scoremtx == -1 ) ktuple = 6;
|
||||
else ktuple = 1;
|
||||
|
||||
for( i=0; i<njob; i++ )
|
||||
{
|
||||
gappick0( seq1[0], seq[i] );
|
||||
strcpy( seq[i], seq1[0] );
|
||||
}
|
||||
for( j=0; j<njob; j++ )
|
||||
{
|
||||
sprintf( name1[j], "+==========+%d ", j );
|
||||
nlen1[j] = nlen[j];
|
||||
}
|
||||
hat2p = fopen( datafile, "w" );
|
||||
if( !hat2p ) ErrorExit( "Cannot open datafile." );
|
||||
WriteForFasta( hat2p, njob, name1, nlen1, seq );
|
||||
fclose( hat2p );
|
||||
|
||||
for( i=0; i<njob; i++ )
|
||||
{
|
||||
// fprintf( stderr, "### i = %d\n", i );
|
||||
hat2p = fopen( datafile, "w" );
|
||||
if( !hat2p ) ErrorExit( "Cannot open datafile." );
|
||||
WriteForFasta( hat2p, njob-i, name1+i, nlen1+i, seq+i );
|
||||
fclose( hat2p );
|
||||
|
||||
seq1[0] = seq[i];
|
||||
nlen1[0] = nlen[i];
|
||||
|
||||
hat2p = fopen( queryfile, "w" );
|
||||
if( !hat2p ) ErrorExit( "Cannot open queryfile." );
|
||||
WriteForFasta( hat2p, 1, name1+i, nlen1, seq1 );
|
||||
fclose( hat2p );
|
||||
|
||||
|
||||
if( scoremtx == -1 )
|
||||
sprintf( com, "%s %s -z3 -m10 -n -Q -b%d -E%d -d%d %s %s %d > %s", fastapath, swopt, M, M, M, queryfile, datafile, ktuple, fastafile );
|
||||
else
|
||||
sprintf( com, "%s %s -z3 -m10 -Q -b%d -E%d -d%d %s %s %d > %s", fastapath, swopt, M, M, M, queryfile, datafile, ktuple, fastafile );
|
||||
res = system( com );
|
||||
if( res ) ErrorExit( "error in fasta" );
|
||||
|
||||
|
||||
|
||||
hat2p = fopen( fastafile, "r" );
|
||||
if( hat2p == NULL )
|
||||
ErrorExit( "file 'fasta.$$' does not exist\n" );
|
||||
if( scoremtx == -1 )
|
||||
res = ReadFasta34m10_nuc( hat2p, mtx[i], i, name1, localhomtable[i] );
|
||||
else
|
||||
res = ReadFasta34m10( hat2p, mtx[i], i, name1, localhomtable[i] );
|
||||
fclose( hat2p );
|
||||
|
||||
if( res < njob - i )
|
||||
{
|
||||
fprintf( stderr, "count (fasta34 -z 3) = %d\n", res );
|
||||
exit( 1 );
|
||||
}
|
||||
|
||||
|
||||
if( i == 0 )
|
||||
for( j=0; j<njob; j++ ) opt[j] = (int)mtx[0][j];
|
||||
|
||||
|
||||
#if 0
|
||||
{
|
||||
int ii, jj;
|
||||
if( i < njob-1 ) for( jj=i; jj<i+5; jj++ )
|
||||
fprintf( stdout, "mtx[%d][%d] = %f\n", i+1, jj+1, mtx[i][jj] );
|
||||
}
|
||||
#endif
|
||||
fprintf( stderr, "query : %4d / %5d\r", i+1, njob );
|
||||
}
|
||||
|
||||
for( i=0; i<njob; i++ )
|
||||
{
|
||||
max = mtx[i][i];
|
||||
if( max == 0.0 )
|
||||
{
|
||||
for( j=0; j<njob; j++ )
|
||||
mtx2[i][j] = 2.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
for( j=0; j<njob; j++ )
|
||||
{
|
||||
// fprintf( stderr, "##### mtx[%d][%d] = %f\n", i, j, mtx[i][j] );
|
||||
mtx2[i][j] = ( max - mtx[MIN(i,j)][MAX(i,j)] ) / max * 2.0;
|
||||
// fprintf( stdout, "max = %f, mtx[%d][%d] = %f -> %f\n", max, i+1, j+1, mtx[i][j], mtx2[i][j] );
|
||||
}
|
||||
}
|
||||
}
|
||||
for( i=0; i<njob-1; i++ ) for( j=i+1; j<njob; j++ )
|
||||
{
|
||||
// fprintf( stdout, "mtx2[%d][%d] = %f, %f\n", i+1, j+1, mtx2[i][j], mtx2[j][i] );
|
||||
mtx2[i][j] = MIN( mtx2[i][j], mtx2[j][i] );
|
||||
}
|
||||
|
||||
#if 0
|
||||
{
|
||||
int ii, jj;
|
||||
if( i < njob-1 ) for( jj=i+1; jj<njob; jj++ )
|
||||
fprintf( stderr, "mtx2[][] = %f\n", mtx2[i][jj] );
|
||||
}
|
||||
#endif
|
||||
|
||||
for( i=0; i<njob; i++ ) name[i][0] = '=';
|
||||
|
||||
if( disopt )
|
||||
{
|
||||
strcpy( b, name[0] );
|
||||
sprintf( name[0], "=query====lgth=%04d-%04d %.*s", nlen[0], howmanyx( seq[0] ), B-30, b );
|
||||
#if 0
|
||||
strins( b, name[0] );
|
||||
#endif
|
||||
for( i=1; i<njob; i++ )
|
||||
{
|
||||
strcpy( b, name[i] );
|
||||
sprintf( name[i], "=opt=%04d=lgth=%04d-%04d %.*s", opt[i], nlen[i], howmanyx( seq[i] ), B-30, b );
|
||||
#if 0
|
||||
strins( b, name[i] );
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
hat2p = fopen( hat2file, "w" );
|
||||
if( !hat2p ) ErrorExit( "Cannot open hat2." );
|
||||
WriteHat2_pointer( hat2p, njob, name, mtx2 );
|
||||
fclose( hat2p );
|
||||
|
||||
#if 1
|
||||
fprintf( stderr, "##### writing hat3\n" );
|
||||
hat3p = fopen( "hat3", "w" );
|
||||
if( !hat3p ) ErrorExit( "Cannot open hat3." );
|
||||
for( i=0; i<njob-1; i++ ) for( j=i+1; j<njob; j++ )
|
||||
{
|
||||
for( tmpptr=localhomtable[i]+j; tmpptr; tmpptr=tmpptr->next )
|
||||
{
|
||||
if( tmpptr->opt == -1.0 ) continue;
|
||||
fprintf( hat3p, "%d %d %d %6.3f %d %d %d %d %p\n", i, j, tmpptr->overlapaa, tmpptr->opt, tmpptr->start1, tmpptr->end1, tmpptr->start2, tmpptr->end2, (void *)tmpptr->next );
|
||||
}
|
||||
}
|
||||
fclose( hat3p );
|
||||
#endif
|
||||
|
||||
sprintf( com, "/bin/rm %s %s %s", queryfile, datafile, fastafile );
|
||||
system( com );
|
||||
|
||||
#if 0
|
||||
sprintf( com, ALNDIR "/supgsdl < %s", hat2file );
|
||||
res = system( com );
|
||||
if( res ) ErrorExit( "error in spgsdl" );
|
||||
#endif
|
||||
|
||||
sprintf( com, "mv %s hat2", hat2file );
|
||||
res = system( com );
|
||||
if( res ) ErrorExit( "error in mv" );
|
||||
|
||||
SHOWVERSION;
|
||||
exit( 0 );
|
||||
}
|
525
mafft/src/mafft-7.487-with-extensions/core/dndpre.c
Normal file
525
mafft/src/mafft-7.487-with-extensions/core/dndpre.c
Normal file
|
@ -0,0 +1,525 @@
|
|||
#include "mltaln.h"
|
||||
|
||||
#define TEST 0
|
||||
|
||||
static int treeout = 0;
|
||||
static int maxdist = 1;
|
||||
|
||||
#ifdef enablemultithread
|
||||
typedef struct _jobtable
|
||||
{
|
||||
int i;
|
||||
int j;
|
||||
} Jobtable;
|
||||
|
||||
typedef struct _thread_arg
|
||||
{
|
||||
int njob;
|
||||
int thread_no;
|
||||
double *selfscore;
|
||||
double **mtx;
|
||||
char **seq;
|
||||
int **skiptable;
|
||||
Jobtable *jobpospt;
|
||||
pthread_mutex_t *mutex;
|
||||
} thread_arg_t;
|
||||
|
||||
#if 0
|
||||
void *athread( void *arg )
|
||||
{
|
||||
thread_arg_t *targ = (thread_arg_t *)arg;
|
||||
int njob = targ->njob;
|
||||
int thread_no = targ->thread_no;
|
||||
double *selfscore = targ->selfscore;
|
||||
double **mtx = targ->mtx;
|
||||
char **seq = targ->seq;
|
||||
int **skiptable = targ->skiptable;
|
||||
Jobtable *jobpospt = targ->jobpospt;
|
||||
|
||||
int i, j;
|
||||
double ssi, ssj, bunbo;
|
||||
double mtxv;
|
||||
|
||||
if( njob == 1 ) return( NULL );
|
||||
|
||||
while( 1 )
|
||||
{
|
||||
pthread_mutex_lock( targ->mutex );
|
||||
j = jobpospt->j;
|
||||
i = jobpospt->i;
|
||||
j++;
|
||||
// fprintf( stderr, "\n i=%d, j=%d before check\n", i, j );
|
||||
if( j == njob )
|
||||
{
|
||||
// fprintf( stderr, "\n j = %d, i = %d, njob = %d\n", j, i, njob );
|
||||
fprintf( stderr, "%4d/%4d (thread %4d), dndpre\r", i+1, njob, thread_no );
|
||||
i++;
|
||||
j = i + 1;
|
||||
if( i == njob-1 )
|
||||
{
|
||||
// fprintf( stderr, "\n i=%d, njob-1=%d\n", i, njob-1 );
|
||||
pthread_mutex_unlock( targ->mutex );
|
||||
return( NULL );
|
||||
}
|
||||
}
|
||||
// fprintf( stderr, "\n i=%d, j=%d after check\n", i, j );
|
||||
jobpospt->j = j;
|
||||
jobpospt->i = i;
|
||||
pthread_mutex_unlock( targ->mutex );
|
||||
|
||||
ssi = selfscore[i];
|
||||
ssj = selfscore[j];
|
||||
|
||||
bunbo = MIN( ssi, ssj );
|
||||
if( bunbo == 0.0 )
|
||||
mtxv = maxdist;
|
||||
else
|
||||
{
|
||||
// mtxv = maxdist * ( 1.0 - (double)naivepairscore11( seq[i], seq[j], penalty ) / bunbo );
|
||||
if( usenaivescoreinsteadofalignmentscore )
|
||||
mtxv = maxdist * ( 1.0 - (double)naivepairscorefast( seq[i], seq[j], skiptable[i], skiptable[j], 0.0 ) / bunbo );
|
||||
else
|
||||
mtxv = maxdist * ( 1.0 - (double)naivepairscorefast( seq[i], seq[j], skiptable[i], skiptable[j], penalty ) / bunbo );
|
||||
}
|
||||
#if 1
|
||||
if( mtxv < 0.0 )
|
||||
{
|
||||
reporterr( "WARNING: negative distance, mtxv = %f\n", mtxv );
|
||||
mtxv = 0.0;
|
||||
}
|
||||
|
||||
if( mtxv > 9.0 )
|
||||
{
|
||||
fprintf( stderr, "Distance %d-%d is strange, %f.\n", i, j, mtxv );
|
||||
exit( 1 );
|
||||
}
|
||||
#else // CHUUI!!! 2012/05/16
|
||||
if( mtxv > 2.0 )
|
||||
{
|
||||
mtxv = 2.0;
|
||||
}
|
||||
if( mtxv < 0.0 )
|
||||
{
|
||||
fprintf( stderr, "Distance %d-%d is strange, %f.\n", i, j, mtxv );
|
||||
exit( 1 );
|
||||
}
|
||||
#endif
|
||||
mtx[i][j] = mtxv;
|
||||
}
|
||||
}
|
||||
#else
|
||||
void *athread( void *arg )
|
||||
{
|
||||
thread_arg_t *targ = (thread_arg_t *)arg;
|
||||
int njob = targ->njob;
|
||||
int thread_no = targ->thread_no;
|
||||
double *selfscore = targ->selfscore;
|
||||
double **mtx = targ->mtx;
|
||||
char **seq = targ->seq;
|
||||
int **skiptable = targ->skiptable;
|
||||
Jobtable *jobpospt = targ->jobpospt;
|
||||
|
||||
int i, j;
|
||||
double ssi, ssj, bunbo;
|
||||
double mtxv;
|
||||
|
||||
if( njob == 1 ) return( NULL );
|
||||
|
||||
while( 1 )
|
||||
{
|
||||
pthread_mutex_lock( targ->mutex );
|
||||
i = jobpospt->i;
|
||||
if( i == njob-1 )
|
||||
{
|
||||
pthread_mutex_unlock( targ->mutex );
|
||||
return( NULL );
|
||||
}
|
||||
jobpospt->i += 1;
|
||||
pthread_mutex_unlock( targ->mutex );
|
||||
if( i % 100 == 0 ) fprintf( stderr, "\r% 5d / %d (thread %4d)", i, njob, thread_no );
|
||||
|
||||
|
||||
ssi = selfscore[i];
|
||||
for( j=i+1; j<njob; j++ )
|
||||
{
|
||||
ssj = selfscore[j];
|
||||
|
||||
bunbo = MIN( ssi, ssj );
|
||||
if( bunbo == 0.0 )
|
||||
mtxv = maxdist;
|
||||
else
|
||||
{
|
||||
// mtxv = maxdist * ( 1.0 - (double)naivepairscore11( seq[i], seq[j], penalty ) / bunbo );
|
||||
if( usenaivescoreinsteadofalignmentscore )
|
||||
mtxv = maxdist * ( 1.0 - (double)naivepairscorefast( seq[i], seq[j], skiptable[i], skiptable[j], 0.0 ) / bunbo );
|
||||
else
|
||||
mtxv = maxdist * ( 1.0 - (double)naivepairscorefast( seq[i], seq[j], skiptable[i], skiptable[j], penalty ) / bunbo );
|
||||
}
|
||||
#if 1
|
||||
|
||||
if( mtxv < 0.0 )
|
||||
{
|
||||
reporterr( "WARNING: negative distance, mtxv = %f\n", mtxv );
|
||||
mtxv = 0.0;
|
||||
}
|
||||
|
||||
if( mtxv > 9.9 )
|
||||
{
|
||||
fprintf( stderr, "WARNING: distance %d-%d is strange, %f.\n", i, j, mtxv );
|
||||
mtxv = 9.9;
|
||||
// exit( 1 ); // 2016/Aug/3
|
||||
}
|
||||
#else // CHUUI!!! 2012/05/16
|
||||
if( mtxv > 2.0 )
|
||||
{
|
||||
mtxv = 2.0;
|
||||
}
|
||||
if( mtxv < 0.0 )
|
||||
{
|
||||
fprintf( stderr, "Distance %d-%d is strange, %f.\n", i, j, mtxv );
|
||||
exit( 1 );
|
||||
}
|
||||
#endif
|
||||
mtx[i][j] = mtxv;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
void arguments( int argc, char *argv[] )
|
||||
{
|
||||
int c;
|
||||
|
||||
nadd = 0;
|
||||
nthread = 1;
|
||||
alg = 'X';
|
||||
fmodel = 0;
|
||||
treeout = 0;
|
||||
scoremtx = 1;
|
||||
nblosum = 62;
|
||||
dorp = NOTSPECIFIED;
|
||||
inputfile = NULL;
|
||||
ppenalty = NOTSPECIFIED; //?
|
||||
ppenalty_ex = NOTSPECIFIED; //?
|
||||
poffset = NOTSPECIFIED; //?
|
||||
kimuraR = NOTSPECIFIED;
|
||||
pamN = NOTSPECIFIED;
|
||||
usenaivescoreinsteadofalignmentscore = 0;
|
||||
nwildcard = 0;
|
||||
|
||||
while( --argc > 0 && (*++argv)[0] == '-' )
|
||||
{
|
||||
while ( (c = *++argv[0]) )
|
||||
{
|
||||
switch( c )
|
||||
{
|
||||
case 'Z':
|
||||
usenaivescoreinsteadofalignmentscore = 1;
|
||||
break;
|
||||
case 't':
|
||||
treeout = '1';
|
||||
break;
|
||||
case 'D':
|
||||
dorp = 'd';
|
||||
break;
|
||||
case 'a':
|
||||
fmodel = 1;
|
||||
break;
|
||||
case 'P':
|
||||
dorp = 'p';
|
||||
break;
|
||||
case ':':
|
||||
nwildcard = 1;
|
||||
break;
|
||||
case 'K': // Hontou ha iranai. disttbfast.c, tbfast.c to awaserutame.
|
||||
break;
|
||||
case 'I':
|
||||
nadd = myatoi( *++argv );
|
||||
fprintf( stderr, "nadd = %d\n", nadd );
|
||||
--argc;
|
||||
goto nextoption;
|
||||
case 'f':
|
||||
ppenalty = (int)( atof( *++argv ) * 1000 - 0.5 );
|
||||
--argc;
|
||||
goto nextoption;
|
||||
case 'g':
|
||||
ppenalty_ex = (int)( atof( *++argv ) * 1000 - 0.5 );
|
||||
--argc;
|
||||
goto nextoption;
|
||||
case 'h':
|
||||
poffset = (int)( atof( *++argv ) * 1000 - 0.5 );
|
||||
--argc;
|
||||
goto nextoption;
|
||||
case 'k':
|
||||
kimuraR = myatoi( *++argv );
|
||||
// fprintf( stderr, "kimuraR = %d\n", kimuraR );
|
||||
--argc;
|
||||
goto nextoption;
|
||||
case 'b':
|
||||
nblosum = myatoi( *++argv );
|
||||
scoremtx = 1;
|
||||
// fprintf( stderr, "blosum %d\n", nblosum );
|
||||
--argc;
|
||||
goto nextoption;
|
||||
case 'j':
|
||||
pamN = myatoi( *++argv );
|
||||
scoremtx = 0;
|
||||
TMorJTT = JTT;
|
||||
// fprintf( stderr, "jtt %d\n", pamN );
|
||||
--argc;
|
||||
goto nextoption;
|
||||
case 'm':
|
||||
pamN = myatoi( *++argv );
|
||||
scoremtx = 0;
|
||||
TMorJTT = TM;
|
||||
// fprintf( stderr, "TM %d\n", pamN );
|
||||
--argc;
|
||||
goto nextoption;
|
||||
case 'i':
|
||||
inputfile = *++argv;
|
||||
// fprintf( stderr, "inputfile = %s\n", inputfile );
|
||||
--argc;
|
||||
goto nextoption;
|
||||
case 'M':
|
||||
maxdist = myatoi( *++argv );
|
||||
// fprintf( stderr, "maxdist = %d\n", maxdist );
|
||||
--argc;
|
||||
goto nextoption;
|
||||
case 'C':
|
||||
nthread = myatoi( *++argv );
|
||||
// fprintf( stderr, "nthread = %d\n", nthread );
|
||||
--argc;
|
||||
goto nextoption;
|
||||
break;
|
||||
}
|
||||
}
|
||||
nextoption:
|
||||
;
|
||||
}
|
||||
if( argc != 0 )
|
||||
{
|
||||
fprintf( stderr, "options: Check source file !\n" );
|
||||
exit( 1 );
|
||||
}
|
||||
}
|
||||
|
||||
int main( int argc, char **argv )
|
||||
{
|
||||
int i, j, ilim;
|
||||
char **seq;
|
||||
static char **name;
|
||||
int *nlen;
|
||||
double *selfscore;
|
||||
double **mtx;
|
||||
double mtxv;
|
||||
FILE *fp;
|
||||
FILE *infp;
|
||||
double ssi, ssj, bunbo;
|
||||
int **skiptable = NULL;
|
||||
char c;
|
||||
|
||||
|
||||
arguments( argc, argv );
|
||||
#ifndef enablemultithread
|
||||
nthread = 0;
|
||||
#endif
|
||||
|
||||
if( inputfile )
|
||||
{
|
||||
infp = fopen( inputfile, "r" );
|
||||
if( !infp )
|
||||
{
|
||||
fprintf( stderr, "Cannot open %s\n", inputfile );
|
||||
exit( 1 );
|
||||
}
|
||||
}
|
||||
else
|
||||
infp = stdin;
|
||||
|
||||
#if 0
|
||||
PreRead( stdin, &njob, &nlenmax );
|
||||
#else
|
||||
getnumlen( infp );
|
||||
#endif
|
||||
|
||||
if( njob < 2 )
|
||||
{
|
||||
fprintf( stderr, "At least 2 sequences should be input!\n"
|
||||
"Only %d sequence found.\n", njob );
|
||||
exit( 1 );
|
||||
}
|
||||
|
||||
rewind( infp );
|
||||
|
||||
njob -= nadd; // atarashii hairetsu ha mushi
|
||||
|
||||
seq = AllocateCharMtx( njob, nlenmax+1 );
|
||||
name = AllocateCharMtx( njob, B+1 );
|
||||
mtx = AllocateDoubleMtx( njob, njob );
|
||||
selfscore = AllocateFloatVec( njob );
|
||||
nlen = AllocateIntVec( njob );
|
||||
|
||||
|
||||
#if 0
|
||||
FRead( stdin, name, nlen, seq );
|
||||
#else
|
||||
readData_pointer( infp, name, nlen, seq );
|
||||
#endif
|
||||
fclose( infp );
|
||||
|
||||
|
||||
for( i=1; i<njob; i++ )
|
||||
{
|
||||
if( nlen[i] != nlen[0] )
|
||||
{
|
||||
reporterr( "Not aligned!\n" );
|
||||
exit( 1 );
|
||||
}
|
||||
}
|
||||
|
||||
constants( njob, seq );
|
||||
|
||||
c = seqcheck( seq );
|
||||
if( c )
|
||||
{
|
||||
reporterr( "Illegal character %c\n", c );
|
||||
exit( 1 );
|
||||
}
|
||||
|
||||
#if 0
|
||||
for( i=0; i<njob-1; i++ )
|
||||
{
|
||||
fprintf( stderr, "%4d/%4d\r", i+1, njob );
|
||||
for( j=i+1; j<njob; j++ )
|
||||
mtx[i][j] = (double)substitution_hosei( seq[i], seq[j] );
|
||||
// fprintf( stderr, "i=%d,j=%d, l=%d &&& %f\n", i, j, nlen[0], mtx[i][j] );
|
||||
}
|
||||
#else // 061003
|
||||
for( i=0; i<njob; i++ )
|
||||
{
|
||||
selfscore[i] = (double)naivepairscore11( seq[i], seq[i], penalty );
|
||||
}
|
||||
|
||||
skiptable = AllocateIntMtx( njob, 0 );
|
||||
makeskiptable( njob, skiptable, seq ); // allocate suru.
|
||||
|
||||
#ifdef enablemultithread
|
||||
if( nthread > 0 )
|
||||
{
|
||||
thread_arg_t *targ;
|
||||
Jobtable jobpos;
|
||||
pthread_t *handle;
|
||||
pthread_mutex_t mutex;
|
||||
|
||||
jobpos.i = 0;
|
||||
jobpos.j = 0;
|
||||
|
||||
targ = calloc( nthread, sizeof( thread_arg_t ) );
|
||||
handle = calloc( nthread, sizeof( pthread_t ) );
|
||||
pthread_mutex_init( &mutex, NULL );
|
||||
|
||||
for( i=0; i<nthread; i++ )
|
||||
{
|
||||
targ[i].thread_no = i;
|
||||
targ[i].njob = njob;
|
||||
targ[i].selfscore = selfscore;
|
||||
targ[i].mtx = mtx;
|
||||
targ[i].seq = seq;
|
||||
targ[i].skiptable = skiptable;
|
||||
targ[i].jobpospt = &jobpos;
|
||||
targ[i].mutex = &mutex;
|
||||
|
||||
pthread_create( handle+i, NULL, athread, (void *)(targ+i) );
|
||||
}
|
||||
|
||||
for( i=0; i<nthread; i++ )
|
||||
{
|
||||
pthread_join( handle[i], NULL );
|
||||
}
|
||||
pthread_mutex_destroy( &mutex );
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
ilim = njob-1;
|
||||
for( i=0; i<ilim; i++ )
|
||||
{
|
||||
ssi = selfscore[i];
|
||||
fprintf( stderr, "%4d/%4d\r", i+1, njob );
|
||||
for( j=i+1; j<njob; j++ )
|
||||
{
|
||||
ssj = selfscore[j];
|
||||
bunbo = MIN( ssi, ssj );
|
||||
if( bunbo == 0.0 )
|
||||
mtxv = maxdist;
|
||||
else
|
||||
{
|
||||
// reporterr( "usenaivescoreinsteadofalignmentscore = %d\n", usenaivescoreinsteadofalignmentscore );
|
||||
if( usenaivescoreinsteadofalignmentscore ) // osoi.
|
||||
mtxv = maxdist * ( 1.0 - (double)naivepairscorefast( seq[i], seq[j], skiptable[i], skiptable[j], 0.0 ) / bunbo );
|
||||
else
|
||||
mtxv = maxdist * ( 1.0 - (double)naivepairscorefast( seq[i], seq[j], skiptable[i], skiptable[j], penalty ) / bunbo );
|
||||
// mtxv = maxdist * ( 1.0 - (double)naivepairscore11( seq[i], seq[j], penalty ) / bunbo );
|
||||
// mtxv = 1.0 - (double)naivepairscore11( seq[i], seq[j], penalty ) / MIN( selfscore[i], selfscore[j] );
|
||||
// fprintf( stderr, "i=%d,j=%d, l=%d### %f, score = %f, %f, %f\n", i, j, nlen[0], mtxv, naivepairscore11( seq[i], seq[j], penalty ), ssi, ssj );
|
||||
|
||||
}
|
||||
#if 1
|
||||
if( mtxv < 0.0 )
|
||||
{
|
||||
reporterr( "WARNING: negative distance, mtxv = %f\n", mtxv );
|
||||
mtxv = 0.0;
|
||||
}
|
||||
if( mtxv > 9.0 )
|
||||
{
|
||||
fprintf( stderr, "WARNING: Distance %d-%d is strange, %f.\n", i, j, mtxv );
|
||||
mtxv = 9.9;
|
||||
// exit( 1 ); // 2016/Aug/3
|
||||
}
|
||||
#else // CHUUI!!! 2012/05/16
|
||||
if( mtxv > 2.0 )
|
||||
{
|
||||
mtxv = 2.0;
|
||||
}
|
||||
if( mtxv < 0.0 )
|
||||
{
|
||||
fprintf( stderr, "Distance %d-%d is strange, %f.\n", i, j, mtxv );
|
||||
exit( 1 );
|
||||
}
|
||||
#endif
|
||||
mtx[i][j] = mtxv;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if TEST
|
||||
for( i=0; i<njob-1; i++ ) for( j=i+1; j<njob; j++ )
|
||||
fprintf( stdout, "i=%d, j=%d, mtx[][] = %f\n", i, j, mtx[i][j] );
|
||||
#endif
|
||||
|
||||
fp = fopen( "hat2", "w" );
|
||||
WriteHat2_pointer( fp, njob, name, mtx );
|
||||
fclose( fp );
|
||||
#if 0
|
||||
if( treeout )
|
||||
{
|
||||
int ***topol;
|
||||
double **len;
|
||||
|
||||
topol = AllocateIntCub( njob, 2, njob );
|
||||
len = AllocateDoubleMtx( njob, njob );
|
||||
veryfastsupg_double_outtree( njob, mtx, topol, len );
|
||||
}
|
||||
#endif
|
||||
if( skiptable ) FreeIntMtx( skiptable ); skiptable = NULL;
|
||||
SHOWVERSION;
|
||||
exit( 0 );
|
||||
/*
|
||||
res = system( ALNDIR "/spgsdl < hat2" );
|
||||
if( res ) exit( 1 );
|
||||
else exit( 0 );
|
||||
*/
|
||||
}
|
54
mafft/src/mafft-7.487-with-extensions/core/dndpre_score.c
Normal file
54
mafft/src/mafft-7.487-with-extensions/core/dndpre_score.c
Normal file
|
@ -0,0 +1,54 @@
|
|||
#include "mltaln.h"
|
||||
|
||||
#define TEST 0
|
||||
|
||||
int main()
|
||||
{
|
||||
int i, j;
|
||||
char **seq;
|
||||
static char name[M][B];
|
||||
static int nlen[M];
|
||||
double **mtx;
|
||||
FILE *fp;
|
||||
int res;
|
||||
|
||||
scoremtx = NOTSPECIFIED;
|
||||
|
||||
#if 0
|
||||
PreRead( stdin, &njob, &nlenmax );
|
||||
#else
|
||||
getnumlen( stdin );
|
||||
#endif
|
||||
rewind( stdin );
|
||||
|
||||
seq = AllocateCharMtx( njob, nlenmax+1 );
|
||||
mtx = AllocateDoubleMtx( njob, njob );
|
||||
|
||||
#if 0
|
||||
FRead( stdin, name, nlen, seq );
|
||||
#else
|
||||
readData( stdin, name, nlen, seq );
|
||||
#endif
|
||||
|
||||
for( i=0; i<njob-1; i++ )
|
||||
{
|
||||
fprintf( stderr, "%4d/%4d\r", i+1, njob );
|
||||
for( j=i+1; j<njob; j++ )
|
||||
mtx[i][j] = (double)substitution_score( seq[i], seq[j] );
|
||||
}
|
||||
|
||||
#if TEST
|
||||
for( i=0; i<njob-1; i++ ) for( j=i+1; j<njob; j++ )
|
||||
fprintf( stdout, "i=%d, j=%d, mtx[][] = %f\n", i, j, mtx[i][j] );
|
||||
#endif
|
||||
|
||||
fp = fopen( "hat2", "w" );
|
||||
WriteHat2( fp, njob, name, mtx );
|
||||
fclose( fp );
|
||||
exit( 0 );
|
||||
/*
|
||||
res = system( ALNDIR "/spgsdl < hat2" );
|
||||
if( res ) exit( 1 );
|
||||
else exit( 0 );
|
||||
*/
|
||||
}
|
16
mafft/src/mafft-7.487-with-extensions/core/dp.h
Normal file
16
mafft/src/mafft-7.487-with-extensions/core/dp.h
Normal file
|
@ -0,0 +1,16 @@
|
|||
#ifdef enablemultithread
|
||||
#define TLS __thread
|
||||
#else
|
||||
#define TLS
|
||||
#endif
|
||||
|
||||
#ifdef enableatomic
|
||||
#define ATOMICINT atomic_int
|
||||
#else
|
||||
#define ATOMICINT int
|
||||
#endif
|
||||
|
||||
extern TLS int commonAlloc1;
|
||||
extern TLS int commonAlloc2;
|
||||
extern TLS int **commonIP;
|
||||
extern TLS int **commonJP;
|
1202
mafft/src/mafft-7.487-with-extensions/core/dvtditr.c
Normal file
1202
mafft/src/mafft-7.487-with-extensions/core/dvtditr.c
Normal file
File diff suppressed because it is too large
Load diff
383
mafft/src/mafft-7.487-with-extensions/core/f2cl.c
Normal file
383
mafft/src/mafft-7.487-with-extensions/core/f2cl.c
Normal file
|
@ -0,0 +1,383 @@
|
|||
#include "mltaln.h"
|
||||
|
||||
#define DEBUG 0
|
||||
|
||||
|
||||
static char *comment;
|
||||
static char *orderfile;
|
||||
static int format;
|
||||
static int namelen;
|
||||
static int excludedashseq;
|
||||
static int extendedalphabet;
|
||||
|
||||
static void fillspace( char *seq, int lenmax )
|
||||
{
|
||||
int len = strlen( seq );
|
||||
seq += len;
|
||||
lenmax -= len;
|
||||
while( lenmax-- ) *seq++ = ' ';
|
||||
*seq = 0;
|
||||
}
|
||||
|
||||
void setmark_clustal( int nlen, int nseq, char **seq, char *mark )
|
||||
{
|
||||
int i, j, k, nalpha;
|
||||
char firstletter;
|
||||
char *strong[9];
|
||||
char *weaker[11];
|
||||
int nstrong, nweaker;
|
||||
char s;
|
||||
|
||||
if( dorp == 'd' )
|
||||
{
|
||||
strong[0] = "TU";
|
||||
nstrong = 1;
|
||||
weaker[0] = "AG";
|
||||
weaker[1] = "CT";
|
||||
weaker[2] = "CU";
|
||||
nweaker = 2;
|
||||
nalpha = 10;
|
||||
}
|
||||
else
|
||||
{
|
||||
strong[0] = "STA";
|
||||
strong[1] = "NEQK";
|
||||
strong[2] = "NHQK";
|
||||
strong[3] = "NDEQ";
|
||||
strong[4] = "QHRK";
|
||||
strong[5] = "MILV";
|
||||
strong[6] = "MILF";
|
||||
strong[7] = "HY";
|
||||
strong[8] = "FYW";
|
||||
nstrong = 9;
|
||||
weaker[0] = "CSA";
|
||||
weaker[1] = "ATV";
|
||||
weaker[2] = "SAG";
|
||||
weaker[3] = "STNK";
|
||||
weaker[4] = "STPA";
|
||||
weaker[5] = "SGND";
|
||||
weaker[6] = "SNDEQK";
|
||||
weaker[7] = "NDEQHK";
|
||||
weaker[8] = "NEQHRK";
|
||||
weaker[9] = "FVLIM";
|
||||
weaker[10] = "HFY";
|
||||
nweaker = 11;
|
||||
nalpha = 20;
|
||||
}
|
||||
|
||||
for( i=0; i<nlen; i++ )
|
||||
{
|
||||
mark[i] = ' ';
|
||||
for( j=0; j<nseq; j++ )
|
||||
{
|
||||
s = seq[j][i];
|
||||
if( '-' == s || ' ' == s ) break;
|
||||
}
|
||||
if( j != nseq )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if( extendedalphabet )
|
||||
{
|
||||
firstletter = seq[0][i];
|
||||
if( amino_n[(unsigned char)firstletter] < 0 ) continue;
|
||||
|
||||
for( j=0; j<nseq; j++ )
|
||||
if( seq[j][i] != firstletter ) break;
|
||||
if( j == nseq )
|
||||
{
|
||||
mark[i] = '*';
|
||||
continue;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
firstletter = toupper( seq[0][i] );
|
||||
if( amino_n[(unsigned char)firstletter] >= nalpha || amino_n[(unsigned char)firstletter] < 0 ) continue;
|
||||
|
||||
for( j=0; j<nseq; j++ )
|
||||
if( toupper( seq[j][i] ) != firstletter ) break;
|
||||
if( j == nseq )
|
||||
{
|
||||
mark[i] = '*';
|
||||
continue;
|
||||
}
|
||||
for( k=0; k<nstrong; k++ )
|
||||
{
|
||||
for( j=0; j<nseq; j++ )
|
||||
{
|
||||
if( !strchr( strong[k], toupper( seq[j][i] ) ) ) break;
|
||||
}
|
||||
if( j == nseq ) break;
|
||||
}
|
||||
if( k < nstrong )
|
||||
{
|
||||
mark[i] = ':';
|
||||
continue;
|
||||
}
|
||||
for( k=0; k<nweaker; k++ )
|
||||
{
|
||||
for( j=0; j<nseq; j++ )
|
||||
{
|
||||
if( !strchr( weaker[k], toupper( seq[j][i] ) ) ) break;
|
||||
}
|
||||
if( j == nseq ) break;
|
||||
}
|
||||
if( k < nweaker )
|
||||
{
|
||||
mark[i] = '.';
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
mark[nlen] = 0;
|
||||
}
|
||||
|
||||
void setmark( int nlen, int nseq, char **seq, char *mark )
|
||||
{
|
||||
int i, j;
|
||||
|
||||
for( i=0; i<nlen; i++ )
|
||||
{
|
||||
mark[i] = ' ';
|
||||
for( j=0; j<nseq; j++ )
|
||||
if( '-' == seq[j][i] ) break;
|
||||
if( j != nseq )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
for( j=0; j<nseq; j++ )
|
||||
if( seq[0][i] != seq[j][i] ) break;
|
||||
if( j == nseq )
|
||||
{
|
||||
mark[i] = '*';
|
||||
continue;
|
||||
}
|
||||
for( j=0; j<nseq; j++ )
|
||||
if( amino_grp[(unsigned char)seq[0][i]] != amino_grp[(unsigned char)seq[j][i]] ) break;
|
||||
if( j == nseq )
|
||||
{
|
||||
mark[i] = '.';
|
||||
continue;
|
||||
}
|
||||
}
|
||||
mark[nlen] = 0;
|
||||
}
|
||||
|
||||
void arguments( int argc, char *argv[] )
|
||||
{
|
||||
int c;
|
||||
excludedashseq = 0;
|
||||
namelen = -1;
|
||||
scoremtx = 1;
|
||||
nblosum = 62;
|
||||
dorp = NOTSPECIFIED;
|
||||
kimuraR = NOTSPECIFIED;
|
||||
pamN = NOTSPECIFIED;
|
||||
inputfile = NULL;
|
||||
comment = NULL;
|
||||
orderfile = NULL;
|
||||
format = 'c';
|
||||
extendedalphabet = 0;
|
||||
|
||||
while( --argc > 0 && (*++argv)[0] == '-' )
|
||||
{
|
||||
while ( (c = *++argv[0]) )
|
||||
{
|
||||
switch( c )
|
||||
{
|
||||
case 'i':
|
||||
inputfile = *++argv;
|
||||
fprintf( stderr, "inputfile = %s\n", inputfile );
|
||||
--argc;
|
||||
goto nextoption;
|
||||
case 'c':
|
||||
comment = *++argv;
|
||||
fprintf( stderr, "comment = %s\n", comment );
|
||||
--argc;
|
||||
goto nextoption;
|
||||
case 'r':
|
||||
orderfile = *++argv;
|
||||
fprintf( stderr, "orderfile = %s\n", orderfile );
|
||||
--argc;
|
||||
goto nextoption;
|
||||
case 'n':
|
||||
namelen = myatoi( *++argv );
|
||||
fprintf( stderr, "namelen = %d\n", namelen );
|
||||
--argc;
|
||||
goto nextoption;
|
||||
case 'f':
|
||||
format = 'f';
|
||||
break;
|
||||
case 'd':
|
||||
excludedashseq = 1;
|
||||
break;
|
||||
case 'y':
|
||||
format = 'y';
|
||||
break;
|
||||
case 'E':
|
||||
extendedalphabet = 1;
|
||||
nblosum = -2;
|
||||
break;
|
||||
case 'N':
|
||||
extendedalphabet = 0;
|
||||
break;
|
||||
default:
|
||||
fprintf( stderr, "illegal option %c\n", c );
|
||||
argc = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
nextoption:
|
||||
;
|
||||
}
|
||||
if( argc != 0 )
|
||||
{
|
||||
fprintf( stderr, "options: Check source file !\n" );
|
||||
exit( 1 );
|
||||
}
|
||||
}
|
||||
|
||||
int main( int argc, char *argv[] )
|
||||
{
|
||||
static int *nlen, *onlen;
|
||||
static char **name, **oname, **seq, **oseq, *mark;
|
||||
static int *order, *oorder;
|
||||
int i, j;
|
||||
FILE *infp;
|
||||
FILE *orderfp;
|
||||
char gett[B];
|
||||
int nlenmin;
|
||||
int nout;
|
||||
|
||||
arguments( argc, argv );
|
||||
|
||||
|
||||
if( inputfile )
|
||||
{
|
||||
infp = fopen( inputfile, "rb" );
|
||||
if( !infp )
|
||||
{
|
||||
fprintf( stderr, "Cannot open %s\n", inputfile );
|
||||
exit( 1 );
|
||||
}
|
||||
}
|
||||
else
|
||||
infp = stdin;
|
||||
|
||||
getnumlen_casepreserve( infp, &nlenmin );
|
||||
rewind( infp );
|
||||
|
||||
seq = AllocateCharMtx( njob, nlenmax*2+1 );
|
||||
mark = AllocateCharVec( nlenmax*2+1 );
|
||||
order = AllocateIntVec( njob );
|
||||
name = AllocateCharMtx( njob, B+1 );
|
||||
nlen = AllocateIntVec( njob );
|
||||
|
||||
if( orderfile )
|
||||
{
|
||||
orderfp = fopen( orderfile, "r" );
|
||||
if( !orderfp )
|
||||
{
|
||||
fprintf( stderr, "Cannot open %s\n", orderfile );
|
||||
exit( 1 );
|
||||
}
|
||||
for( i=0; i<njob; i++ )
|
||||
{
|
||||
fgets( gett, B-1, orderfp );
|
||||
order[i] = atoi( gett );
|
||||
}
|
||||
fclose( orderfp );
|
||||
}
|
||||
else
|
||||
{
|
||||
for( i=0; i<njob; i++ ) order[i] = i;
|
||||
}
|
||||
|
||||
|
||||
readData_pointer_casepreserve( infp, name, nlen, seq );
|
||||
fclose( infp );
|
||||
|
||||
if( format == 'c' || format == 'y' ) for( i=0; i<njob; i++ ) fillspace( seq[i], nlenmax );
|
||||
constants( njob, seq );
|
||||
|
||||
// initSignalSM();
|
||||
|
||||
// initFiles();
|
||||
|
||||
if( excludedashseq )
|
||||
{
|
||||
nout = 0;
|
||||
for( i=0; i<njob; i++ )
|
||||
{
|
||||
if( !strncmp( name[order[i]]+1, "DASH|", 5 ) || strstr( name[order[i]]+1, "_numo_e_DASH|" ) ) continue;
|
||||
nout++;
|
||||
}
|
||||
|
||||
reporterr( "nout=%d\n", nout );
|
||||
|
||||
oseq = calloc( sizeof( char * ), nout );
|
||||
oname = calloc( sizeof( char * ), nout );
|
||||
onlen = AllocateIntVec( nout );
|
||||
oorder = AllocateIntVec( nout );
|
||||
|
||||
|
||||
for( i=0,j=0; i<njob; i++ )
|
||||
{
|
||||
if( !strncmp( name[order[i]]+1, "DASH|", 5 ) || strstr( name[order[i]]+1, "_numo_e_DASH|" ) ) continue;
|
||||
oname[j] = name[order[i]];
|
||||
oseq[j] = seq[order[i]];
|
||||
onlen[j] = nlen[order[i]];
|
||||
oorder[j] = j;
|
||||
j++;
|
||||
}
|
||||
commongappick( nout, oseq );
|
||||
}
|
||||
else
|
||||
{
|
||||
oseq = seq;
|
||||
oname = name;
|
||||
onlen = nlen;
|
||||
oorder = order;
|
||||
nout = njob;
|
||||
}
|
||||
|
||||
reporterr( "seq = %p, oseq=%p\n", seq, oseq );
|
||||
|
||||
|
||||
|
||||
// setmark( nlenmax, njob, seq, mark );
|
||||
setmark_clustal( nlenmax, nout, oseq, mark );
|
||||
|
||||
#if mingw
|
||||
setmode( fileno( stdout ), O_TEXT ); // windows deha saishuu tekina output nomi text mode
|
||||
#endif
|
||||
|
||||
if( format == 'f' )
|
||||
writeData_reorder_pointer( stdout, nout, oname, onlen, oseq, oorder );
|
||||
else if( format == 'c' )
|
||||
clustalout_pointer( stdout, nout, nlenmax, oseq, oname, mark, comment, oorder, namelen );
|
||||
else if( format == 'y' )
|
||||
phylipout_pointer( stdout, nout, nlenmax, oseq, oname, oorder, namelen );
|
||||
else
|
||||
fprintf( stderr, "Unknown format\n" );
|
||||
|
||||
FreeCharMtx( seq ); seq = NULL;
|
||||
FreeCharMtx( name ); name = NULL;
|
||||
free( nlen ); nlen = NULL;
|
||||
free( order ); order = NULL;
|
||||
|
||||
if( excludedashseq )
|
||||
{
|
||||
free( oseq ); oseq = NULL;
|
||||
free( oname ); oname = NULL;
|
||||
free( onlen ); onlen = NULL;
|
||||
free( oorder ); oorder = NULL;
|
||||
}
|
||||
|
||||
free( mark ); mark = NULL;
|
||||
freeconstants();
|
||||
|
||||
// SHOWVERSION;
|
||||
return( 0 );
|
||||
}
|
126
mafft/src/mafft-7.487-with-extensions/core/fft.c
Normal file
126
mafft/src/mafft-7.487-with-extensions/core/fft.c
Normal file
|
@ -0,0 +1,126 @@
|
|||
#include "mltaln.h"
|
||||
#include "mtxutl.h"
|
||||
|
||||
/*
|
||||
from "C gengo niyoru saishin algorithm jiten" ISBN4-87408-414-1 Haruhiko Okumura
|
||||
*/
|
||||
static void make_sintbl(int n, double sintbl[])
|
||||
{
|
||||
int i, n2, n4, n8;
|
||||
double c, s, dc, ds, t;
|
||||
|
||||
n2 = n / 2; n4 = n / 4; n8 = n / 8;
|
||||
t = sin(PI / n);
|
||||
dc = 2 * t * t; ds = sqrt(dc * (2 - dc));
|
||||
t = 2 * dc; c = sintbl[n4] = 1; s = sintbl[0] = 0;
|
||||
for (i = 1; i < n8; i++) {
|
||||
c -= dc; dc += t * c;
|
||||
s += ds; ds -= t * s;
|
||||
sintbl[i] = s; sintbl[n4 - i] = c;
|
||||
}
|
||||
if (n8 != 0) sintbl[n8] = sqrt(0.5);
|
||||
for (i = 0; i < n4; i++)
|
||||
sintbl[n2 - i] = sintbl[i];
|
||||
for (i = 0; i < n2 + n4; i++)
|
||||
sintbl[i + n2] = - sintbl[i];
|
||||
}
|
||||
/*
|
||||
{\tt fft()}.
|
||||
*/
|
||||
static void make_bitrev(int n, int bitrev[])
|
||||
{
|
||||
int i, j, k, n2;
|
||||
|
||||
n2 = n / 2; i = j = 0;
|
||||
for ( ; ; ) {
|
||||
bitrev[i] = j;
|
||||
if (++i >= n) break;
|
||||
k = n2;
|
||||
while (k <= j) { j -= k; k /= 2; }
|
||||
j += k;
|
||||
}
|
||||
}
|
||||
/*
|
||||
*/
|
||||
int fft(int n, Fukusosuu *x, int freeflag)
|
||||
{
|
||||
static TLS int last_n = 0; /* {\tt n} */
|
||||
static TLS int *bitrev = NULL; /* */
|
||||
static TLS double *sintbl = NULL; /* */
|
||||
int i, j, k, ik, h, d, k2, n4, inverse;
|
||||
double t, s, c, dR, dI;
|
||||
|
||||
if (freeflag)
|
||||
{
|
||||
if (bitrev) free(bitrev); bitrev = NULL;
|
||||
if (sintbl) free(sintbl); sintbl = NULL;
|
||||
last_n = 0;
|
||||
return( 0 );
|
||||
}
|
||||
|
||||
/* */
|
||||
if (n < 0) {
|
||||
n = -n; inverse = 1; /* */
|
||||
} else inverse = 0;
|
||||
n4 = n / 4;
|
||||
if (n != last_n || n == 0) {
|
||||
last_n = n;
|
||||
#if 0
|
||||
if (sintbl != NULL) {
|
||||
free(sintbl);
|
||||
sintbl = NULL;
|
||||
}
|
||||
if (bitrev != NULL) {
|
||||
free(bitrev);
|
||||
bitrev = NULL;
|
||||
}
|
||||
if (n == 0) return 0; /* */
|
||||
sintbl = (double *)malloc((n + n4) * sizeof(double));
|
||||
bitrev = (int *)malloc(n * sizeof(int));
|
||||
#else /* by T. Nishiyama */
|
||||
sintbl = realloc(sintbl, (n + n4) * sizeof(double));
|
||||
bitrev = realloc(bitrev, n * sizeof(int));
|
||||
#endif
|
||||
if (sintbl == NULL || bitrev == NULL) {
|
||||
fprintf(stderr, "\n"); return 1;
|
||||
}
|
||||
make_sintbl(n, sintbl);
|
||||
make_bitrev(n, bitrev);
|
||||
}
|
||||
for (i = 0; i < n; i++) { /* */
|
||||
j = bitrev[i];
|
||||
if (i < j) {
|
||||
t = x[i].R; x[i].R = x[j].R; x[j].R = t;
|
||||
t = x[i].I; x[i].I = x[j].I; x[j].I = t;
|
||||
}
|
||||
}
|
||||
for (k = 1; k < n; k = k2) { /* */
|
||||
#if 0
|
||||
fprintf( stderr, "%d / %d\n", k, n );
|
||||
#endif
|
||||
h = 0; k2 = k + k; d = n / k2;
|
||||
for (j = 0; j < k; j++) {
|
||||
#if 0
|
||||
if( j % 1 == 0 )
|
||||
fprintf( stderr, "%d / %d\r", j, k );
|
||||
#endif
|
||||
c = sintbl[h + n4];
|
||||
if (inverse) s = - sintbl[h];
|
||||
else s = sintbl[h];
|
||||
for (i = j; i < n; i += k2) {
|
||||
#if 0
|
||||
if( k>=4194000 ) fprintf( stderr, "in loop %d - %d < %d, k2=%d\r", j, i, n, k2 );
|
||||
#endif
|
||||
ik = i + k;
|
||||
dR = s * x[ik].I + c * x[ik].R;
|
||||
dI = c * x[ik].I - s * x[ik].R;
|
||||
x[ik].R = x[i].R - dR; x[i].R += dR;
|
||||
x[ik].I = x[i].I - dI; x[i].I += dI;
|
||||
}
|
||||
h += d;
|
||||
}
|
||||
}
|
||||
if (! inverse) /* n */
|
||||
for (i = 0; i < n; i++) { x[i].R /= n; x[i].I /= n; }
|
||||
return 0; /* */
|
||||
}
|
15
mafft/src/mafft-7.487-with-extensions/core/fft.h
Normal file
15
mafft/src/mafft-7.487-with-extensions/core/fft.h
Normal file
|
@ -0,0 +1,15 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stddef.h>
|
||||
#include <math.h>
|
||||
#include "mtxutl.h"
|
||||
|
||||
#define PI 3.14159265358979323846
|
||||
#define END_OF_VEC -1
|
||||
|
||||
#define NKOUHO 20
|
||||
#define NKOUHO_LONG 500
|
||||
|
||||
#define MAX(X,Y) ( ((X)>(Y))?(X):(Y) )
|
||||
#define MIN(X,Y) ( ((X)<(Y))?(X):(Y) )
|
||||
|
762
mafft/src/mafft-7.487-with-extensions/core/fftFunctions.c
Normal file
762
mafft/src/mafft-7.487-with-extensions/core/fftFunctions.c
Normal file
|
@ -0,0 +1,762 @@
|
|||
#include "mltaln.h"
|
||||
|
||||
#define SEGMENTSIZE 150
|
||||
#define TMPTMPTMP 0
|
||||
|
||||
#define DEBUG 0
|
||||
|
||||
void keika( char *str, int current, int all )
|
||||
{
|
||||
if( current == 0 )
|
||||
fprintf( stderr, "%s : ", str );
|
||||
|
||||
fprintf( stderr, "\b\b\b\b\b\b\b\b" );
|
||||
fprintf( stderr, "%3d /%3d", current+1, all+1 );
|
||||
|
||||
if( current+1 == all )
|
||||
fprintf( stderr, "\b\b\b\b\b\b\b\bdone. \n" );
|
||||
}
|
||||
|
||||
double maxItch( double *soukan, int size )
|
||||
{
|
||||
int i;
|
||||
double value = 0.0;
|
||||
double cand;
|
||||
for( i=0; i<size; i++ )
|
||||
if( ( cand = soukan[i] ) > value ) value = cand;
|
||||
return( value );
|
||||
}
|
||||
|
||||
void calcNaiseki( Fukusosuu *value, Fukusosuu *x, Fukusosuu *y )
|
||||
{
|
||||
value->R = x->R * y->R + x->I * y->I;
|
||||
value->I = -x->R * y->I + x->I * y->R;
|
||||
}
|
||||
|
||||
Fukusosuu *AllocateFukusosuuVec( int l1 )
|
||||
{
|
||||
Fukusosuu *value;
|
||||
value = (Fukusosuu *)calloc( l1, sizeof( Fukusosuu ) );
|
||||
if( !value )
|
||||
{
|
||||
fprintf( stderr, "Cannot allocate %d FukusosuuVec\n", l1 );
|
||||
return( NULL );
|
||||
}
|
||||
return( value );
|
||||
}
|
||||
|
||||
Fukusosuu **AllocateFukusosuuMtx( int l1, int l2 )
|
||||
{
|
||||
Fukusosuu **value;
|
||||
int j;
|
||||
// fprintf( stderr, "allocating %d x %d FukusosuuMtx\n", l1, l2 );
|
||||
value = (Fukusosuu **)calloc( l1+1, sizeof( Fukusosuu * ) );
|
||||
if( !value )
|
||||
{
|
||||
fprintf( stderr, "Cannot allocate %d x %d FukusosuuVecMtx\n", l1, l2 );
|
||||
exit( 1 );
|
||||
}
|
||||
for( j=0; j<l1; j++ )
|
||||
{
|
||||
value[j] = AllocateFukusosuuVec( l2 );
|
||||
if( !value[j] )
|
||||
{
|
||||
fprintf( stderr, "Cannot allocate %d x %d FukusosuuVecMtx\n", l1, l2 );
|
||||
exit( 1 );
|
||||
}
|
||||
}
|
||||
value[l1] = NULL;
|
||||
return( value );
|
||||
}
|
||||
|
||||
Fukusosuu ***AllocateFukusosuuCub( int l1, int l2, int l3 )
|
||||
{
|
||||
Fukusosuu ***value;
|
||||
int i;
|
||||
value = calloc( l1+1, sizeof( Fukusosuu ** ) );
|
||||
if( !value ) ErrorExit( "Cannot allocate Fukusosuu" );
|
||||
for( i=0; i<l1; i++ ) value[i] = AllocateFukusosuuMtx( l2, l3 );
|
||||
value[l1] = NULL;
|
||||
return( value );
|
||||
}
|
||||
|
||||
void FreeFukusosuuVec( Fukusosuu *vec )
|
||||
{
|
||||
free( (void *)vec );
|
||||
}
|
||||
|
||||
void FreeFukusosuuMtx( Fukusosuu **mtx )
|
||||
{
|
||||
int i;
|
||||
|
||||
for( i=0; mtx[i]; i++ )
|
||||
free( (void *)mtx[i] );
|
||||
free( (void *)mtx );
|
||||
}
|
||||
|
||||
int getKouho( int *kouho, int nkouho, double *soukan, int nlen2 )
|
||||
{
|
||||
int i, j;
|
||||
int nlen4 = nlen2 / 2;
|
||||
double max;
|
||||
double tmp;
|
||||
int ikouho = 0; // by D.Mathog, iinoka?
|
||||
for( j=0; j<nkouho; j++ )
|
||||
{
|
||||
max = -9999.9;
|
||||
for( i=0; i<nlen2; i++ )
|
||||
{
|
||||
if( ( tmp = soukan[i] ) > max )
|
||||
{
|
||||
ikouho = i;
|
||||
max = tmp;
|
||||
}
|
||||
}
|
||||
#if 0
|
||||
if( max < 0.15 )
|
||||
{
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
#if 0
|
||||
fprintf( stderr, "Kouho No.%d, pos=%d, score=%f, lag=%d\n", j, ikouho, soukan[ikouho], ikouho-nlen4 );
|
||||
#endif
|
||||
soukan[ikouho] = -9999.9;
|
||||
kouho[j] = ( ikouho - nlen4 );
|
||||
}
|
||||
return( j );
|
||||
}
|
||||
|
||||
void zurasu2( int lag, int clus1, int clus2,
|
||||
char **seq1, char **seq2,
|
||||
char **aseq1, char **aseq2 )
|
||||
{
|
||||
int i;
|
||||
#if 0
|
||||
fprintf( stderr, "### lag = %d\n", lag );
|
||||
#endif
|
||||
if( lag > 0 )
|
||||
{
|
||||
for( i=0; i<clus1; i++ ) aseq1[i] = seq1[i];
|
||||
for( i=0; i<clus2; i++ ) aseq2[i] = seq2[i]+lag;
|
||||
}
|
||||
else
|
||||
{
|
||||
for( i=0; i<clus1; i++ ) aseq1[i] = seq1[i]-lag;
|
||||
for( i=0; i<clus2; i++ ) aseq2[i] = seq2[i];
|
||||
}
|
||||
}
|
||||
|
||||
void zurasu( int lag, int clus1, int clus2,
|
||||
char **seq1, char **seq2,
|
||||
char **aseq1, char **aseq2 )
|
||||
{
|
||||
int i;
|
||||
#if DEBUG
|
||||
fprintf( stderr, "lag = %d\n", lag );
|
||||
#endif
|
||||
if( lag > 0 )
|
||||
{
|
||||
for( i=0; i<clus1; i++ ) strcpy( aseq1[i], seq1[i] );
|
||||
for( i=0; i<clus2; i++ ) strcpy( aseq2[i], seq2[i]+lag );
|
||||
}
|
||||
else
|
||||
{
|
||||
for( i=0; i<clus1; i++ ) strcpy( aseq1[i], seq1[i]-lag );
|
||||
for( i=0; i<clus2; i++ ) strcpy( aseq2[i], seq2[i] );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int alignableReagion( int clus1, int clus2,
|
||||
char **seq1, char **seq2,
|
||||
double *eff1, double *eff2,
|
||||
Segment *seg )
|
||||
{
|
||||
int i, j, k;
|
||||
int status, starttmp = 0; // by D.Mathog, a gess
|
||||
double score;
|
||||
int value = 0;
|
||||
int len, maxlen;
|
||||
int length = 0; // by D.Mathog, a gess
|
||||
static TLS double *stra = NULL;
|
||||
static TLS int alloclen = 0;
|
||||
double totaleff;
|
||||
double cumscore;
|
||||
static TLS double threshold;
|
||||
static TLS double *prf1 = NULL;
|
||||
static TLS double *prf2 = NULL;
|
||||
static TLS int *hat1 = NULL;
|
||||
static TLS int *hat2 = NULL;
|
||||
int pre1, pre2;
|
||||
#if 0
|
||||
char **seq1pt;
|
||||
char **seq2pt;
|
||||
double *eff1pt;
|
||||
double *eff2pt;
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
fprintf( stderr, "### In alignableRegion, clus1=%d, clus2=%d \n", clus1, clus2 );
|
||||
fprintf( stderr, "seq1[0] = %s\n", seq1[0] );
|
||||
fprintf( stderr, "seq2[0] = %s\n", seq2[0] );
|
||||
fprintf( stderr, "eff1[0] = %f\n", eff1[0] );
|
||||
fprintf( stderr, "eff2[0] = %f\n", eff2[0] );
|
||||
#endif
|
||||
|
||||
if( clus1 == 0 )
|
||||
{
|
||||
if( stra ) FreeDoubleVec( stra ); stra = NULL;
|
||||
if( prf1 ) FreeDoubleVec( prf1 ); prf1 = NULL;
|
||||
if( prf2 ) FreeDoubleVec( prf2 ); prf2 = NULL;
|
||||
if( hat1 ) FreeIntVec( hat1 ); hat1 = NULL;
|
||||
if( hat2 ) FreeIntVec( hat2 ); hat2 = NULL;
|
||||
alloclen = 0;
|
||||
return( 0 );
|
||||
}
|
||||
|
||||
if( prf1 == NULL )
|
||||
{
|
||||
prf1 = AllocateDoubleVec( nalphabets );
|
||||
prf2 = AllocateDoubleVec( nalphabets );
|
||||
hat1 = AllocateIntVec( nalphabets+1 );
|
||||
hat2 = AllocateIntVec( nalphabets+1 );
|
||||
}
|
||||
|
||||
len = MIN( strlen( seq1[0] ), strlen( seq2[0] ) );
|
||||
maxlen = MAX( strlen( seq1[0] ), strlen( seq2[0] ) ) + fftWinSize;
|
||||
if( alloclen < maxlen )
|
||||
{
|
||||
if( alloclen )
|
||||
{
|
||||
FreeDoubleVec( stra );
|
||||
}
|
||||
else
|
||||
{
|
||||
threshold = (int)fftThreshold / 100.0 * 600.0 * fftWinSize;
|
||||
}
|
||||
stra = AllocateDoubleVec( maxlen );
|
||||
alloclen = maxlen;
|
||||
}
|
||||
|
||||
|
||||
totaleff = 0.0;
|
||||
for( i=0; i<clus1; i++ ) for( j=0; j<clus2; j++ ) totaleff += eff1[i] * eff2[j];
|
||||
for( i=0; i<len; i++ )
|
||||
{
|
||||
/* make prfs */
|
||||
for( j=0; j<nalphabets; j++ )
|
||||
{
|
||||
prf1[j] = 0.0;
|
||||
prf2[j] = 0.0;
|
||||
}
|
||||
#if 0
|
||||
seq1pt = seq1;
|
||||
eff1pt = eff1;
|
||||
j = clus1;
|
||||
while( j-- ) prf1[amino_n[(*seq1pt++)[i]]] += *eff1pt++;
|
||||
#else
|
||||
for( j=0; j<clus1; j++ ) prf1[amino_n[(unsigned char)seq1[j][i]]] += eff1[j];
|
||||
#endif
|
||||
for( j=0; j<clus2; j++ ) prf2[amino_n[(unsigned char)seq2[j][i]]] += eff2[j];
|
||||
|
||||
/* make hats */
|
||||
pre1 = pre2 = nalphabets;
|
||||
for( j=25; j>=0; j-- )
|
||||
{
|
||||
if( prf1[j] )
|
||||
{
|
||||
hat1[pre1] = j;
|
||||
pre1 = j;
|
||||
}
|
||||
if( prf2[j] )
|
||||
{
|
||||
hat2[pre2] = j;
|
||||
pre2 = j;
|
||||
}
|
||||
}
|
||||
hat1[pre1] = -1;
|
||||
hat2[pre2] = -1;
|
||||
|
||||
/* make site score */
|
||||
stra[i] = 0.0;
|
||||
for( k=hat1[nalphabets]; k!=-1; k=hat1[k] )
|
||||
for( j=hat2[nalphabets]; j!=-1; j=hat2[j] )
|
||||
// stra[i] += n_dis[k][j] * prf1[k] * prf2[j];
|
||||
stra[i] += n_disFFT[k][j] * prf1[k] * prf2[j];
|
||||
stra[i] /= totaleff;
|
||||
}
|
||||
|
||||
(seg+0)->skipForeward = 0;
|
||||
(seg+1)->skipBackward = 0;
|
||||
status = 0;
|
||||
cumscore = 0.0;
|
||||
score = 0.0;
|
||||
for( j=0; j<fftWinSize; j++ ) score += stra[j];
|
||||
|
||||
for( i=1; i<len-fftWinSize; i++ )
|
||||
{
|
||||
score = score - stra[i-1] + stra[i+fftWinSize-1];
|
||||
#if TMPTMPTMP
|
||||
fprintf( stderr, "%d %10.0f ? %10.0f\n", i, score, threshold );
|
||||
#endif
|
||||
|
||||
if( score > threshold )
|
||||
{
|
||||
#if 0
|
||||
seg->start = i;
|
||||
seg->end = i;
|
||||
seg->center = ( seg->start + seg->end + fftWinSize ) / 2 ;
|
||||
seg->score = score;
|
||||
status = 0;
|
||||
value++;
|
||||
#else
|
||||
if( !status )
|
||||
{
|
||||
status = 1;
|
||||
starttmp = i;
|
||||
length = 0;
|
||||
cumscore = 0.0;
|
||||
}
|
||||
length++;
|
||||
cumscore += score;
|
||||
#endif
|
||||
}
|
||||
if( score <= threshold || length > SEGMENTSIZE )
|
||||
{
|
||||
if( status )
|
||||
{
|
||||
if( length > fftWinSize )
|
||||
{
|
||||
seg->start = starttmp;
|
||||
seg->end = i;
|
||||
seg->center = ( seg->start + seg->end + fftWinSize ) / 2 ;
|
||||
seg->score = cumscore;
|
||||
#if 0
|
||||
fprintf( stderr, "%d-%d length = %d, score = %f, value = %d\n", seg->start, seg->end, length, cumscore, value );
|
||||
#endif
|
||||
if( length > SEGMENTSIZE )
|
||||
{
|
||||
(seg+0)->skipForeward = 1;
|
||||
(seg+1)->skipBackward = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
(seg+0)->skipForeward = 0;
|
||||
(seg+1)->skipBackward = 0;
|
||||
}
|
||||
value++;
|
||||
seg++;
|
||||
}
|
||||
length = 0;
|
||||
cumscore = 0.0;
|
||||
status = 0;
|
||||
starttmp = i;
|
||||
if( value > MAXSEG - 3 ) ErrorExit( "TOO MANY SEGMENTS!");
|
||||
}
|
||||
}
|
||||
}
|
||||
if( status && length > fftWinSize )
|
||||
{
|
||||
seg->end = i;
|
||||
seg->start = starttmp;
|
||||
seg->center = ( starttmp + i + fftWinSize ) / 2 ;
|
||||
seg->score = cumscore;
|
||||
#if 0
|
||||
fprintf( stderr, "%d-%d length = %d\n", seg->start, seg->end, length );
|
||||
#endif
|
||||
value++;
|
||||
}
|
||||
#if TMPTMPTMP
|
||||
exit( 0 );
|
||||
#endif
|
||||
// fprintf( stderr, "returning %d\n", value );
|
||||
return( value );
|
||||
}
|
||||
|
||||
|
||||
static int permit( Segment *seg1, Segment *seg2 )
|
||||
{
|
||||
return( 0 );
|
||||
if( seg1->end >= seg2->start ) return( 0 );
|
||||
if( seg1->pair->end >= seg2->pair->start ) return( 0 );
|
||||
else return( 1 );
|
||||
}
|
||||
|
||||
void blockAlign2( int *cut1, int *cut2, Segment **seg1, Segment **seg2, double **ocrossscore, int *ncut )
|
||||
{
|
||||
int i, j, k, shift, cur1, cur2, count, klim;
|
||||
static TLS int crossscoresize = 0;
|
||||
static TLS int *result1 = NULL;
|
||||
static TLS int *result2 = NULL;
|
||||
static TLS int *ocut1 = NULL;
|
||||
static TLS int *ocut2 = NULL;
|
||||
double maximum;
|
||||
static TLS double **crossscore = NULL;
|
||||
static TLS int **track = NULL;
|
||||
static TLS double maxj, maxi;
|
||||
static TLS int pointj, pointi;
|
||||
|
||||
if( cut1 == NULL)
|
||||
{
|
||||
if( result1 )
|
||||
{
|
||||
if( result1 ) free( result1 ); result1 = NULL;
|
||||
if( result2 ) free( result2 ); result2 = NULL;
|
||||
if( ocut1 ) free( ocut1 ); ocut1 = NULL;
|
||||
if( ocut2 ) free( ocut2 ); ocut2 = NULL;
|
||||
if( track ) FreeIntMtx( track ); track = NULL;
|
||||
if( crossscore ) FreeDoubleMtx( crossscore ); crossscore = NULL;
|
||||
}
|
||||
crossscoresize = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
if( result1 == NULL )
|
||||
{
|
||||
result1 = AllocateIntVec( MAXSEG );
|
||||
result2 = AllocateIntVec( MAXSEG );
|
||||
ocut1 = AllocateIntVec( MAXSEG );
|
||||
ocut2 = AllocateIntVec( MAXSEG );
|
||||
}
|
||||
|
||||
if( crossscoresize < *ncut+2 )
|
||||
{
|
||||
crossscoresize = *ncut+2;
|
||||
if( fftkeika ) fprintf( stderr, "allocating crossscore and track, size = %d\n", crossscoresize );
|
||||
if( track ) FreeIntMtx( track );
|
||||
if( crossscore ) FreeDoubleMtx( crossscore );
|
||||
track = AllocateIntMtx( crossscoresize, crossscoresize );
|
||||
crossscore = AllocateDoubleMtx( crossscoresize, crossscoresize );
|
||||
}
|
||||
|
||||
#if 0
|
||||
for( i=0; i<*ncut-2; i++ )
|
||||
fprintf( stderr, "%d.start = %d, score = %f\n", i, seg1[i]->start, seg1[i]->score );
|
||||
|
||||
for( i=0; i<*ncut; i++ )
|
||||
fprintf( stderr, "i=%d, cut1 = %d, cut2 = %d\n", i, cut1[i], cut2[i] );
|
||||
for( i=0; i<*ncut; i++ )
|
||||
{
|
||||
for( j=0; j<*ncut; j++ )
|
||||
fprintf( stderr, "%#4.0f ", ocrossscore[i][j] );
|
||||
fprintf( stderr, "\n" );
|
||||
}
|
||||
#endif
|
||||
|
||||
for( i=0; i<*ncut; i++ ) for( j=0; j<*ncut; j++ ) /* mudadanaa */
|
||||
crossscore[i][j] = ocrossscore[i][j];
|
||||
for( i=0; i<*ncut; i++ )
|
||||
{
|
||||
ocut1[i] = cut1[i];
|
||||
ocut2[i] = cut2[i];
|
||||
}
|
||||
|
||||
for( i=1; i<*ncut; i++ )
|
||||
{
|
||||
#if 0
|
||||
fprintf( stderr, "### i=%d/%d\n", i,*ncut );
|
||||
#endif
|
||||
for( j=1; j<*ncut; j++ )
|
||||
{
|
||||
pointi = 0; maxi = 0.0;
|
||||
klim = j-2;
|
||||
for( k=0; k<klim; k++ )
|
||||
{
|
||||
/*
|
||||
fprintf( stderr, "k=%d, i=%d\n", k, i );
|
||||
*/
|
||||
if( k && k<*ncut-1 && j<*ncut-1 && !permit( seg1[k-1], seg1[j-1] ) ) continue;
|
||||
if( crossscore[i-1][k] > maxj )
|
||||
{
|
||||
pointi = k;
|
||||
maxi = crossscore[i-1][k];
|
||||
}
|
||||
}
|
||||
|
||||
pointj = 0; maxj = 0.0;
|
||||
klim = i-2;
|
||||
for( k=0; k<klim; k++ )
|
||||
{
|
||||
if( k && k<*ncut-1 && i<*ncut-1 && !permit( seg2[k-1], seg2[i-1] ) ) continue;
|
||||
if( crossscore[k][j-1] > maxj )
|
||||
{
|
||||
pointj = k;
|
||||
maxj = crossscore[k][j-1];
|
||||
}
|
||||
}
|
||||
|
||||
maxi += penalty;
|
||||
maxj += penalty;
|
||||
|
||||
maximum = crossscore[i-1][j-1];
|
||||
track[i][j] = 0;
|
||||
|
||||
if( maximum < maxi )
|
||||
{
|
||||
maximum = maxi ;
|
||||
track[i][j] = j - pointi;
|
||||
}
|
||||
|
||||
if( maximum < maxj )
|
||||
{
|
||||
maximum = maxj ;
|
||||
track[i][j] = pointj - i;
|
||||
}
|
||||
|
||||
crossscore[i][j] += maximum;
|
||||
}
|
||||
}
|
||||
#if 0
|
||||
for( i=0; i<*ncut; i++ )
|
||||
{
|
||||
for( j=0; j<*ncut; j++ )
|
||||
fprintf( stderr, "%3d ", track[i][j] );
|
||||
fprintf( stderr, "\n" );
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
result1[MAXSEG-1] = *ncut-1;
|
||||
result2[MAXSEG-1] = *ncut-1;
|
||||
|
||||
for( i=MAXSEG-1; i>=1; i-- )
|
||||
{
|
||||
cur1 = result1[i];
|
||||
cur2 = result2[i];
|
||||
if( cur1 == 0 || cur2 == 0 ) break;
|
||||
shift = track[cur1][cur2];
|
||||
if( shift == 0 )
|
||||
{
|
||||
result1[i-1] = cur1 - 1;
|
||||
result2[i-1] = cur2 - 1;
|
||||
continue;
|
||||
}
|
||||
else if( shift > 0 )
|
||||
{
|
||||
result1[i-1] = cur1 - 1;
|
||||
result2[i-1] = cur2 - shift;
|
||||
}
|
||||
else if( shift < 0 )
|
||||
{
|
||||
result1[i-1] = cur1 + shift;
|
||||
result2[i-1] = cur2 - 1;
|
||||
}
|
||||
}
|
||||
|
||||
count = 0;
|
||||
for( j=i; j<MAXSEG; j++ )
|
||||
{
|
||||
if( ocrossscore[result1[j]][result2[j]] == 0.0 ) continue;
|
||||
|
||||
if( result1[j] == result1[j-1] || result2[j] == result2[j-1] )
|
||||
if( ocrossscore[result1[j]][result2[j]] > ocrossscore[result1[j-1]][result2[j-1]] )
|
||||
count--;
|
||||
|
||||
cut1[count] = ocut1[result1[j]];
|
||||
cut2[count] = ocut2[result2[j]];
|
||||
|
||||
count++;
|
||||
}
|
||||
|
||||
*ncut = count;
|
||||
#if 0
|
||||
for( i=0; i<*ncut; i++ )
|
||||
fprintf( stderr, "i=%d, cut1 = %d, cut2 = %d\n", i, cut1[i], cut2[i] );
|
||||
#endif
|
||||
}
|
||||
|
||||
void blockAlign3( int *cut1, int *cut2, Segment **seg1, Segment **seg2, double **ocrossscore, int *ncut )
|
||||
// memory complexity = O(n^3), time complexity = O(n^2)
|
||||
{
|
||||
int i, j, shift, cur1, cur2, count;
|
||||
static TLS int crossscoresize = 0;
|
||||
static TLS int jumpposi, *jumppos;
|
||||
static TLS double jumpscorei, *jumpscore;
|
||||
static TLS int *result1 = NULL;
|
||||
static TLS int *result2 = NULL;
|
||||
static TLS int *ocut1 = NULL;
|
||||
static TLS int *ocut2 = NULL;
|
||||
double maximum;
|
||||
static TLS double **crossscore = NULL;
|
||||
static TLS int **track = NULL;
|
||||
|
||||
if( result1 == NULL )
|
||||
{
|
||||
result1 = AllocateIntVec( MAXSEG );
|
||||
result2 = AllocateIntVec( MAXSEG );
|
||||
ocut1 = AllocateIntVec( MAXSEG );
|
||||
ocut2 = AllocateIntVec( MAXSEG );
|
||||
}
|
||||
if( crossscoresize < *ncut+2 )
|
||||
{
|
||||
crossscoresize = *ncut+2;
|
||||
if( fftkeika ) fprintf( stderr, "allocating crossscore and track, size = %d\n", crossscoresize );
|
||||
if( track ) FreeIntMtx( track );
|
||||
if( crossscore ) FreeDoubleMtx( crossscore );
|
||||
if( jumppos ) FreeIntVec( jumppos );
|
||||
if( jumpscore ) FreeDoubleVec( jumpscore );
|
||||
track = AllocateIntMtx( crossscoresize, crossscoresize );
|
||||
crossscore = AllocateDoubleMtx( crossscoresize, crossscoresize );
|
||||
jumppos = AllocateIntVec( crossscoresize );
|
||||
jumpscore = AllocateDoubleVec( crossscoresize );
|
||||
}
|
||||
|
||||
#if 0
|
||||
for( i=0; i<*ncut-2; i++ )
|
||||
fprintf( stderr, "%d.start = %d, score = %f\n", i, seg1[i]->start, seg1[i]->score );
|
||||
|
||||
for( i=0; i<*ncut; i++ )
|
||||
fprintf( stderr, "i=%d, cut1 = %d, cut2 = %d\n", i, cut1[i], cut2[i] );
|
||||
for( i=0; i<*ncut; i++ )
|
||||
{
|
||||
for( j=0; j<*ncut; j++ )
|
||||
fprintf( stderr, "%#4.0f ", ocrossscore[i][j] );
|
||||
fprintf( stderr, "\n" );
|
||||
}
|
||||
#endif
|
||||
|
||||
for( i=0; i<*ncut; i++ ) for( j=0; j<*ncut; j++ ) /* mudadanaa */
|
||||
crossscore[i][j] = ocrossscore[i][j];
|
||||
for( i=0; i<*ncut; i++ )
|
||||
{
|
||||
ocut1[i] = cut1[i];
|
||||
ocut2[i] = cut2[i];
|
||||
}
|
||||
for( j=0; j<*ncut; j++ )
|
||||
{
|
||||
jumpscore[j] = -999.999;
|
||||
jumppos[j] = -1;
|
||||
}
|
||||
|
||||
for( i=1; i<*ncut; i++ )
|
||||
{
|
||||
|
||||
jumpscorei = -999.999;
|
||||
jumpposi = -1;
|
||||
|
||||
for( j=1; j<*ncut; j++ )
|
||||
{
|
||||
#if 1
|
||||
fprintf( stderr, "in blockalign3, ### i=%d, j=%d\n", i, j );
|
||||
#endif
|
||||
|
||||
|
||||
#if 0
|
||||
for( k=0; k<j-2; k++ )
|
||||
{
|
||||
/*
|
||||
fprintf( stderr, "k=%d, i=%d\n", k, i );
|
||||
*/
|
||||
if( k && k<*ncut-1 && j<*ncut-1 && !permit( seg1[k-1], seg1[j-1] ) ) continue;
|
||||
if( crossscore[i-1][k] > maxj )
|
||||
{
|
||||
pointi = k;
|
||||
maxi = crossscore[i-1][k];
|
||||
}
|
||||
}
|
||||
|
||||
pointj = 0; maxj = 0.0;
|
||||
for( k=0; k<i-2; k++ )
|
||||
{
|
||||
if( k && k<*ncut-1 && i<*ncut-1 && !permit( seg2[k-1], seg2[i-1] ) ) continue;
|
||||
if( crossscore[k][j-1] > maxj )
|
||||
{
|
||||
pointj = k;
|
||||
maxj = crossscore[k][j-1];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
maxi += penalty;
|
||||
maxj += penalty;
|
||||
#endif
|
||||
maximum = crossscore[i-1][j-1];
|
||||
track[i][j] = 0;
|
||||
|
||||
if( maximum < jumpscorei && permit( seg1[jumpposi], seg1[i] ) )
|
||||
{
|
||||
maximum = jumpscorei;
|
||||
track[i][j] = j - jumpposi;
|
||||
}
|
||||
|
||||
if( maximum < jumpscore[j] && permit( seg2[jumppos[j]], seg2[j] ) )
|
||||
{
|
||||
maximum = jumpscore[j];
|
||||
track[i][j] = jumpscore[j] - i;
|
||||
}
|
||||
|
||||
crossscore[i][j] += maximum;
|
||||
|
||||
if( jumpscorei < crossscore[i-1][j] )
|
||||
{
|
||||
jumpscorei = crossscore[i-1][j];
|
||||
jumpposi = j;
|
||||
}
|
||||
|
||||
if( jumpscore[j] < crossscore[i][j-1] )
|
||||
{
|
||||
jumpscore[j] = crossscore[i][j-1];
|
||||
jumppos[j] = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
#if 0
|
||||
for( i=0; i<*ncut; i++ )
|
||||
{
|
||||
for( j=0; j<*ncut; j++ )
|
||||
fprintf( stderr, "%3d ", track[i][j] );
|
||||
fprintf( stderr, "\n" );
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
result1[MAXSEG-1] = *ncut-1;
|
||||
result2[MAXSEG-1] = *ncut-1;
|
||||
|
||||
for( i=MAXSEG-1; i>=1; i-- )
|
||||
{
|
||||
cur1 = result1[i];
|
||||
cur2 = result2[i];
|
||||
if( cur1 == 0 || cur2 == 0 ) break;
|
||||
shift = track[cur1][cur2];
|
||||
if( shift == 0 )
|
||||
{
|
||||
result1[i-1] = cur1 - 1;
|
||||
result2[i-1] = cur2 - 1;
|
||||
continue;
|
||||
}
|
||||
else if( shift > 0 )
|
||||
{
|
||||
result1[i-1] = cur1 - 1;
|
||||
result2[i-1] = cur2 - shift;
|
||||
}
|
||||
else if( shift < 0 )
|
||||
{
|
||||
result1[i-1] = cur1 + shift;
|
||||
result2[i-1] = cur2 - 1;
|
||||
}
|
||||
}
|
||||
|
||||
count = 0;
|
||||
for( j=i; j<MAXSEG; j++ )
|
||||
{
|
||||
if( ocrossscore[result1[j]][result2[j]] == 0.0 ) continue;
|
||||
|
||||
if( result1[j] == result1[j-1] || result2[j] == result2[j-1] )
|
||||
if( ocrossscore[result1[j]][result2[j]] > ocrossscore[result1[j-1]][result2[j-1]] )
|
||||
count--;
|
||||
|
||||
cut1[count] = ocut1[result1[j]];
|
||||
cut2[count] = ocut2[result2[j]];
|
||||
|
||||
count++;
|
||||
}
|
||||
|
||||
*ncut = count;
|
||||
#if 0
|
||||
for( i=0; i<*ncut; i++ )
|
||||
fprintf( stderr, "i=%d, cut1 = %d, cut2 = %d\n", i, cut1[i], cut2[i] );
|
||||
#endif
|
||||
}
|
||||
|
164
mafft/src/mafft-7.487-with-extensions/core/filter.c
Normal file
164
mafft/src/mafft-7.487-with-extensions/core/filter.c
Normal file
|
@ -0,0 +1,164 @@
|
|||
#include "mltaln.h"
|
||||
|
||||
#define DEBUG 0
|
||||
|
||||
double maxunusual;
|
||||
|
||||
static double count_unusual( char *seq, char *usual )
|
||||
{
|
||||
int i;
|
||||
char *pt;
|
||||
int count, len;
|
||||
count = 0;
|
||||
pt = seq;
|
||||
while( *pt )
|
||||
{
|
||||
if( !strchr( usual, *pt ) )
|
||||
count++;
|
||||
pt++;
|
||||
}
|
||||
// reporterr( "%d/%d=%f\n", count, pt-seq, ((double)count/(pt-seq)) );
|
||||
return( (double)count / (pt-seq) );
|
||||
}
|
||||
|
||||
|
||||
void arguments( int argc, char *argv[] )
|
||||
{
|
||||
int c;
|
||||
|
||||
maxunusual = 0.05;
|
||||
inputfile = NULL;
|
||||
dorp = NOTSPECIFIED;
|
||||
|
||||
while( --argc > 0 && (*++argv)[0] == '-' )
|
||||
{
|
||||
while ( (c = *++argv[0]) )
|
||||
{
|
||||
switch( c )
|
||||
{
|
||||
case 'm':
|
||||
maxunusual = myatof( *++argv );
|
||||
fprintf( stderr, "maxunusual = %f\n", maxunusual );
|
||||
--argc;
|
||||
goto nextoption;
|
||||
case 'i':
|
||||
inputfile = *++argv;
|
||||
// fprintf( stderr, "inputfile = %s\n", inputfile );
|
||||
--argc;
|
||||
goto nextoption;
|
||||
case 'D':
|
||||
dorp = 'd';
|
||||
break;
|
||||
case 'P':
|
||||
dorp = 'p';
|
||||
break;
|
||||
default:
|
||||
fprintf( stderr, "illegal option %c\n", c );
|
||||
argc = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
nextoption:
|
||||
;
|
||||
}
|
||||
if( argc != 0 )
|
||||
{
|
||||
fprintf( stderr, "options: Check source file !\n" );
|
||||
exit( 1 );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
int main( int argc, char *argv[] )
|
||||
{
|
||||
FILE *infp;
|
||||
int nlenmin;
|
||||
char **name;
|
||||
char **seq;
|
||||
int *nlen;
|
||||
int i;
|
||||
char *usual;
|
||||
int nout;
|
||||
char *tmpseq;
|
||||
|
||||
arguments( argc, argv );
|
||||
|
||||
if( inputfile )
|
||||
{
|
||||
infp = fopen( inputfile, "r" );
|
||||
if( !infp )
|
||||
{
|
||||
fprintf( stderr, "Cannot open %s\n", inputfile );
|
||||
exit( 1 );
|
||||
}
|
||||
}
|
||||
else
|
||||
infp = stdin;
|
||||
|
||||
|
||||
// dorp = NOTSPECIFIED;
|
||||
getnumlen_casepreserve( infp, &nlenmin );
|
||||
|
||||
// fprintf( stderr, "%d x %d - %d %c\n", njob, nlenmax, nlenmin, dorp );
|
||||
|
||||
seq = AllocateCharMtx( njob, nlenmax+1 );
|
||||
name = AllocateCharMtx( njob, B+1 );
|
||||
nlen = AllocateIntVec( njob );
|
||||
tmpseq = AllocateCharVec( nlenmax+1 );
|
||||
|
||||
// readData_pointer( infp, name, nlen, seq );
|
||||
readData_pointer_casepreserve( infp, name, nlen, seq );
|
||||
fclose( infp );
|
||||
|
||||
// for( i=0; i<njob; i++ ) gappick_samestring( seq[i] );
|
||||
|
||||
#if 0
|
||||
FILE *origfp;
|
||||
origfp = fopen( "_original", "w" );
|
||||
if( !origfp )
|
||||
{
|
||||
fprintf( stderr, "Cannot open _original\n" );
|
||||
exit( 1 );
|
||||
}
|
||||
for( i=0; i<njob; i++ )
|
||||
{
|
||||
nlen[i] = strlen( seq[i] );
|
||||
fprintf( origfp, ">%s\n", name[i]+1 );
|
||||
if( seq[i][nlen[i]-1] == '\n' ) seq[i][nlen[i]-1] = 0;
|
||||
fprintf( origfp, "%s\n", seq[i] );
|
||||
}
|
||||
fclose( origfp );
|
||||
#endif
|
||||
|
||||
if( dorp == 'p' )
|
||||
usual = "ARNDCQEGHILKMFPSTWYVarndcqeghilkmfpstwyv-";
|
||||
else
|
||||
usual = "ATGCUatgcu-";
|
||||
nout = 0;
|
||||
for( i=0; i<njob; i++ )
|
||||
{
|
||||
gappick0( tmpseq, seq[i] );
|
||||
if( count_unusual( tmpseq, usual ) <= maxunusual )
|
||||
{
|
||||
fprintf( stdout, ">%s\n", name[i]+1 );
|
||||
fprintf( stdout, "%s\n", seq[i] );
|
||||
nout++;
|
||||
}
|
||||
}
|
||||
|
||||
if( nout < njob )
|
||||
{
|
||||
if( dorp == 'p' )
|
||||
fprintf( stderr, "\n\nRemoved %d sequence(s) where the frequency of ambiguous amino acids > %5.3f\n\n\n", njob-nout, maxunusual );
|
||||
else
|
||||
fprintf( stderr, "\n\nRemoved %d sequence(s) where the frequency of ambiguous bases > %5.3f\n\n\n", njob-nout, maxunusual );
|
||||
}
|
||||
|
||||
free( nlen );
|
||||
free( tmpseq );
|
||||
FreeCharMtx( seq );
|
||||
FreeCharMtx( name );
|
||||
|
||||
return( 0 );
|
||||
}
|
427
mafft/src/mafft-7.487-with-extensions/core/functions.h
Normal file
427
mafft/src/mafft-7.487-with-extensions/core/functions.h
Normal file
|
@ -0,0 +1,427 @@
|
|||
extern int intlen( int *num );
|
||||
extern char seqcheck( char **seq );
|
||||
extern void scmx_calc( int icyc, char **aseq, double *effarr, double **scmx );
|
||||
extern void exitall( char arr[] );
|
||||
extern void display( char **seq, int nseq );
|
||||
extern void intergroup_score( char **seq1, char **seq2, double *eff1, double *eff2, int clus1, int clus2, int len, double *value );
|
||||
//extern void intergroup_score_dynmtx( double **pairoffset, int mtx[0x80][0x80], char **seq1, char **seq2, double *eff1, double *eff2, int clus1, int clus2, int len, double *value );
|
||||
extern void intergroup_score_multimtx( int **whichmtx, double ***matrices, char **seq1, char **seq2, double *eff1, double *eff2, int clus1, int clus2, int len, double *value );
|
||||
extern void intergroup_score_gapnomi( char **seq1, char **seq2, double *eff1, double *eff2, int clus1, int clus2, int len, double *value );
|
||||
extern void intergroup_score_new( char **seq1, char **seq2, double *eff1, double *eff2, int clus1, int clus2, int len, double *value );
|
||||
extern double score_calc5( char **seq, int s, double **eff, int ex );
|
||||
extern double score_calc4( char **seq, int s, double **eff, int ex );
|
||||
extern void upg2( int nseq, double **eff, int ***topol, double **len );
|
||||
//extern void veryfastsupg_double_realloc_nobk_halfmtx( int njob, double **mtx, int ***topol, double **len );
|
||||
//extern void veryfastsupg_double_realloc_nobk( int njob, double **mtx, int ***topol, double **len );
|
||||
extern void veryfastsupg_int_realloc_nobk( int njob, int **mtx, int ***topol, double **len );
|
||||
extern void veryfastsupg( int nseq, double **oeff, int ***topol, double **len );
|
||||
extern void veryfastsupg_double( int nseq, double **oeff, int ***topol, double **len );
|
||||
extern void veryfastsupg_double_loadtree( int nseq, double **oeff, int ***topol, double **len, char **name );
|
||||
//extern void veryfastsupg_double_loadtop( int nseq, double **oeff, int ***topol, double **len );
|
||||
extern void veryfastsupg_int( int nseq, int **oeff, int ***topol, double **len );
|
||||
extern void fastsupg( int nseq, double **oeff, int ***topol, double **len );
|
||||
extern void supg( int nseq, double **oeff, int ***topol, double **len );
|
||||
extern void spg( int nseq, double **oeff, int ***topol, double **len );
|
||||
extern double ipower( double x, int n );
|
||||
extern void countnode( int nseq, int ***topol, double **node );
|
||||
extern void countnode_int( int nseq, int ***topol, int **node );
|
||||
extern void counteff_simple( int nseq, int ***topol, double **len, double *node );
|
||||
extern void counteff_simple_double( int nseq, int ***topol, double **len, double *node );
|
||||
extern void counteff_simple_double_nostatic( int nseq, int ***topol, double **len, double *node );
|
||||
extern void counteff_simple_double_nostatic_memsave( int nseq, int ***topol, double **len, Treedep *dep, double *node );
|
||||
extern void counteff( int nseq, int ***topol, double **len, double **node );
|
||||
extern double score_calc1( char *seq1, char *seq2 );
|
||||
extern double score_calcp( char *seq1, char *seq2, int len );
|
||||
extern double substitution_nid( char *seq1, char *seq2 );
|
||||
extern double substitution_score( char *seq1, char *seq2 );
|
||||
extern double substitution_hosei( char *seq1, char *seq2 );
|
||||
extern double substitution( char *seq1, char *seq2 );
|
||||
extern void treeconstruction( char **seq, int nseq, int ***topol, double **len, double **eff );
|
||||
extern double bscore_calc( char **seq, int s, double **eff );
|
||||
extern void AllocateTmpSeqs( char ***mseq2pt, char **mseq1pt, int locnlenmax );
|
||||
extern void FreeTmpSeqs( char **mseq2, char *mseq1 );
|
||||
extern void gappick_samestring( char *aseq );
|
||||
extern void gappick0( char *aseq, char *seq );
|
||||
extern void gappick( int nseq, int s, char **aseq, char **mseq2,
|
||||
double **eff, double *effarr );
|
||||
extern void commongappick_record( int nseq, char **seq, int *map );
|
||||
extern void commongappick( int nseq, char **seq );
|
||||
extern int commongapcount( int , int, char **, char ** );
|
||||
//extern void commongaprecord( int nseq, char **seq, char *originallygapped );
|
||||
extern double score_calc0( char **seq, int s, double **eff, int ex );
|
||||
extern void strins( char *str1, char *str2 );
|
||||
extern int isaligned( int nseq, char **seq );
|
||||
extern double score_calc_for_score( int nseq, char **seq );
|
||||
extern void doublencpy( double *vec1, double *vec2, int len );
|
||||
extern double score_calc_a( char **seq, int s, double **eff );
|
||||
extern double score_calc_s( char **seq, int s, double **eff );
|
||||
extern double score_calc_for_score_s( int s, char **seq );
|
||||
extern double SSPscore( int s, char **seq );
|
||||
extern double DSPscore( int s, char **seq );
|
||||
extern int searchAnchors( int nseq, char **seq, Segment *seg );
|
||||
extern char *progName( char *str );
|
||||
extern void dontcalcimportance( int nseq, double *eff, char **seq, LocalHom **localhom );
|
||||
extern void dontcalcimportance_target( int nseq, double *eff, char **seq, LocalHom **localhom, int ntarget );
|
||||
extern void calcimportance_target( int nseq, int ntarget, double *eff, char **seq, LocalHom **localhom, int *targetmap, int *targetmapr, int alloclen );
|
||||
extern void dontcalcimportance_lastone( int nseq, double *eff, char **seq, LocalHom **localhom );
|
||||
extern void dontcalcimportance_firstone( int nseq, double *eff, char **seq, LocalHom **localhom );
|
||||
extern void dontcalcimportance_half( int nseq, double *eff, char **seq, LocalHom **localhom );
|
||||
extern void calcimportance( int nseq, double *eff, char **seq, LocalHom **localhom );
|
||||
extern void calcimportance_half( int nseq, double *eff, char **seq, LocalHom **localhom, int alloclen );
|
||||
extern void weightimportance2( int nseq, double *eff, LocalHom **localhom );
|
||||
extern void weightimportance4( int clus1, int clus2, double *eff1, double *eff2, LocalHom ***localhom );
|
||||
extern void extendlocalhom( int nseq, LocalHom **localhom );
|
||||
extern void extendlocalhom2( int nseq, LocalHom **localhom, double **mtx );
|
||||
extern int makelocal( char *s1, char *s2, int thr );
|
||||
extern void mdfymtx( char **pair, int s1, double **partialmtx, double **mtx );
|
||||
extern double score_calc( char **seq, int s );
|
||||
extern void cpmx_calc( char **seq, double **cpmx, double *eff, int lgth, int clus );
|
||||
extern void cpmx_calc_new( char **seq, double **cpmx, double *eff, int lgth, int clus );
|
||||
extern void cpmx_calc_add( char **seq, double **cpmx, double *eff, int lgth, int clus );
|
||||
extern void MScpmx_calc_new( char **seq, double **cpmx, double *eff, int lgth, int clus );
|
||||
extern void mseqcat( char **seq1, char **seq2, double **eff, double *effarr1, double *effarr2, char name1[M][B], char name2[M][B], int clus1, int clus2 );
|
||||
extern void strnbcat( char *s1, char *s2, int m );
|
||||
extern int conjuctionforgaln( int s0, int s1, char **seq, char **aseq, double *peff, double *eff, char **name, char **aname, char *d );
|
||||
extern int fastconjuction( int *memlist, char **seq, char **aseq, double *peff, double *eff, char name[M][B], char aname[M][B], char *d );
|
||||
extern int fastconjuction_noname_kozo( int *memlist, char **seq, char **aseq, double *peff, double *eff, double *peff_kozo, double *eff_kozo, char *d );
|
||||
extern int fastconjuction_noname( int *memlist, char **seq, char **aseq, double *peff, double *eff, char *d, double mineff, double *oritotal );
|
||||
extern int fastconjuction_target( int *memlist, char **seq, char **aseq, double *peff, double *eff, char *d, double mineff, int *targetmap );
|
||||
extern int fastconjuction_noweight( int *memlist, char **seq, char **aseq, double *peff, char *d );
|
||||
extern int conjuctionfortbfast_old( char **pair, int s, char **seq, char **aseq, double *peff, double *eff, char *d );
|
||||
extern int conjuction( char **pair, int s, char **seq, char **aseq, double *peff, double *eff, char **name, char **aname, char *d );
|
||||
extern void doubledelete( double **cpmx, int d, int len );
|
||||
extern void chardelete( char *seq, int d );
|
||||
extern int RootBranchNode( int nseq, int ***topol, int step, int branch );
|
||||
extern void BranchLeafNode( int nseq, int ***topol, int *node, int step, int branch );
|
||||
extern void RootLeafNode( int nseq, int ***topol, int *node );
|
||||
extern void nodeFromABranch( int nseq, int *result, int **pairwisenode, int ***topol, double **len, int step, int num );
|
||||
//extern void OneClusterAndTheOther( int locnjob, char **pair, int *s1, int *s2, int ***topol, int step, int branch );
|
||||
extern void OneClusterAndTheOther_fast( int locnjob, int *memlist1, int *memlist2, int *s1, int *s2, char *pairbuf, int ***topol, int step, int branch, double **smalldistmtx, double **distmtx, double *distontree );
|
||||
extern void makeEffMtx( int nseq, double **mtx, double *vec );
|
||||
extern void node_eff( int nseq, double *eff, int *node );
|
||||
extern int shrinklocalhom( char **pair, int s1, int s2, LocalHom **localhom, LocalHom ***localhomshrink );
|
||||
extern int msshrinklocalhom_fast( int *memlist1, int *memlist2, LocalHom **localhom, LocalHom ***localhomshrink );
|
||||
extern int msshrinklocalhom_fast_half( int *memlist1, int *memlist2, LocalHom **localhom, LocalHom ***localhomshrink );
|
||||
extern int msshrinklocalhom_fast_target( int *memlist1, int *memlist2, LocalHom **localhom, LocalHom ***localhomshrink, char *swaplist, int *targetmap );
|
||||
extern int fastshrinklocalhom( int *mem1, int *mem2, LocalHom **localhom, LocalHom ***localhomshrink );
|
||||
extern int fastshrinklocalhom_half( int *mem1, int *mem2, LocalHom **localhom, LocalHom ***localhomshrink );
|
||||
extern int fastshrinklocalhom_target( int *mem1, int *mem2, LocalHom **localhom, LocalHom ***localhomshrink, char *swaplist, int *targetmap );
|
||||
extern int fastshrinklocalhom_one( int *mem1, int *mem2, int norg, LocalHom **localhom, LocalHom ***localhomshrink );
|
||||
extern int msfastshrinklocalhom( int *mem1, int *mem2, LocalHom **localhom, LocalHom ***localhomshrink );
|
||||
extern int fastshrinklocalhom_half_seed( int *mem1, int *mem2, int nseed, int *posinlsh1, int *posinlsh2, LocalHom **localhom, LocalHom ***localhomshrink );
|
||||
extern int TreeDependentIteration( int locnjob, char **name, int nlen[M], char **aseq, char **bseq, int ***topol, double **len, double **eff, int **skipthisbranch, int alloclen, LocalHom **localhomtable, RNApair ***single, int nkozo, char *kozoarivec, int ntarget, int *targetmap, int *targetmapr );
|
||||
extern void checkMinusLength( int nseq, double **len );
|
||||
extern void negativeMember2( int *mem, int *query, int locnseq );
|
||||
extern int *negativeMember( int *query, int locnseq );
|
||||
extern int IntExistsInVec( int query, int *vector );
|
||||
extern NodeInCub searchParent( int top, int ***topol, int Start, int End );
|
||||
extern void stopolInit( int n, Node *stopol );
|
||||
extern void treeCnv( Node *stopol, int locnseq, int ***topol, double **len, double **bw );
|
||||
extern int isLeaf( Node node );
|
||||
extern double syntheticLength( Node *ob, Node *oppositeNode );
|
||||
extern double calcW( Node *ob, Node *op );
|
||||
extern void calcBranchWeight( double **bw, int locnseq, Node *stopol, int ***topol, double **len );
|
||||
extern void branchWeightToPairWeight( int locnseq, int ***topol, double **pw, double **bw );
|
||||
extern void weightFromABranch( int nseq, double *result, Node *stopol, int ***topol, int step, int LorR );
|
||||
extern void distFromABranch( int nseq, double *result, Node *stopol, int ***topol, double **len, int step, int LorR );
|
||||
extern void keika( char *str, int current, int all );
|
||||
extern double maxItch( double *soukan, int size );
|
||||
extern void calcNaiseki( Fukusosuu *value, Fukusosuu *x, Fukusosuu *y );
|
||||
extern Fukusosuu *AllocateFukusosuuVec( int l1 );
|
||||
extern Fukusosuu **AllocateFukusosuuMtx( int l1, int l2 );
|
||||
extern Fukusosuu ***AllocateFukusosuuCub( int l1, int l2, int l3 );
|
||||
extern void FreeFukusosuuVec( Fukusosuu *vec );
|
||||
extern void FreeFukusosuuMtx( Fukusosuu **mtx );
|
||||
extern int getKouho( int *kouho, int nkouho, double *soukan, int nlen2 );
|
||||
extern void zurasu2( int lag, int clus1, int clus2, char **seq1, char **seq2, char **aseq1, char **aseq2 );
|
||||
extern void zurasu( int lag, int clus1, int clus2, char **seq1, char **seq2, char **aseq1, char **aseq2 );
|
||||
extern int alignableReagion( int clus1, int clus2, char **seq1, char **seq2, double *eff1, double *eff2, Segment *seg );
|
||||
extern void blockAlign( int *cut1, int *cut2, double **ocrossscore, int *ncut );
|
||||
extern void blockAlign2( int *cut1, int *cut2, Segment **seg1, Segment **seg2, double **ocrossscore, int *ncut );
|
||||
extern void blockAlign3( int *cut1, int *cut2, Segment **seg1, Segment **seg2, double **ocrossscore, int *ncut );
|
||||
extern double imp_match_out_scD( int i1, int j1 );
|
||||
extern void imp_match_init_strictD( double *imp, int clus1, int clus2, int lgth1, int lgth2, char **seq1, char **seq2, double *eff1, double *eff2, double *eff1kozo, double*eff2kozo, LocalHom ***localhom, char *swaplist, int forscore, int *memlist1, int *memlist2, int *uselh, int *seedinlh1, int *seedinlh2, int nodeid, int nfiles );
|
||||
extern double MSalignmm( double **n_dynamicmtx, char **seq1, char **seq2, double *eff1, double *eff2, int icyc, int jcyc, int alloclen, char *, char *, char *, char *, int *, int, int *, int headgp, int tailgp, double ***cpmxchild0, double ***cpmxchild1, double ***cpmxresult, double orieff1, double orieff2 );
|
||||
extern double MSalignmm_variousdist( double **pairoffset, double ***matrices, double **dummtx, char **seq1, char **seq2, double *eff1, double *eff2, double **eff1s, double **eff2s, int icyc, int jcyc, int alloclen, char *, char *, char *, char *, int *, int, int *, int headgp, int tailgp );
|
||||
extern double Lalignmm_hmout( char **seq1, char **seq2, double *eff1, double *eff2, int icyc, int jcyc, int alloclen, char *, char *, char *, char *, double **map );
|
||||
extern double Lalign2m2m_hmout( char **seq1, char **seq2, char **seq1r, char **seq2r, char *dir1, char *dir2, double *eff1, double *eff2, int icyc, int jcyc, int alloclen, char *, char *, char *, char *, double **map );
|
||||
extern double MSalign11( char **seq1, char **seq2, int alloclen );
|
||||
//extern double rnalocal( char **seq1, char **seq2, double *eff1, double *eff2, int icyc, int jcyc, int alloclen, RNApair **pair );
|
||||
extern double A__align( double **scoringmtx, int penalty, int penalty_ex, char **seq1, char **seq2, double *eff1, double *eff2, int icyc, int jcyc, int alloclen, int constraint, double *impmatch, char *gs1, char *gs2, char *ge1, char *ge2, int *, int, int *, int headgp, int tailgp, int firstmem, int calledby, double ***cpmxchild0, double ***cpmxchild1, double ***cpmxresult, double orieff1, double orieff2 );
|
||||
extern double A__align_variousdist( int **which, double ***scoringmatrices, double **dummtx, int penalty, int penalty_ex, char **seq1, char **seq2, double *eff1, double *eff2, double **eff1s, double **eff2s, int icyc, int jcyc, int alloclen, int constraint, double *impmatch, char *gs1, char *gs2, char *ge1, char *ge2, int *, int, int *, int headgp, int tailgp );
|
||||
extern double A__align_gapmap( char **seq1, char **seq2, double *eff1, double *eff2, int icyc, int jcyc, int alloclen, int constraint, double *impmatch, int *gapmap1, int *gapmap2 );
|
||||
extern double translate_and_Calign( char **mseq1, char **mseq2, double *effarr1, double *effarr2, int clus1, int clus2, int alloclen );
|
||||
extern double Fgetlag( double **scoringmtx, char **seq1, char **seq2, double *eff1, double *eff2, int clus1, int clus2, int alloclen );
|
||||
extern double Falign( int **whichmtx, double ***scoringmatrices, double **scoreingmtx, char **seq1, char **seq2, double *eff1, double *eff2, double **eff1s, double **eff2s, int clus1, int clus2, int alloclen, int *fftlog, int *, int, int * );
|
||||
extern double Falign_udpari_long( int **whichmtx, double ***scoringmatrices, double **scoringmtx, char **seq1, char **seq2, double *eff1, double *eff2, double **eff1s, double **eff2s, int clus1, int clus2, int alloclen, int *fftlog );
|
||||
extern double Falign_givenanchors( ExtAnch *extanch, int **whichmtx, double ***scoringmatrices, double **scoringmtx, char **seq1, char **seq2, double *eff1, double *eff2, double **eff1s, double **eff2s, int clus1, int clus2, int alloclen, int *fftlog );
|
||||
double Falign_localhom( int **which, double ***scoringmatrices, double **scoreingmtx, char **seq1, char **seq2, double *eff1, double *eff2, double **eff1s, double **eff2s, int clus1, int clus2, int alloclen, int constraint, double *totalimpmatch, int *gapmap1, int *gapmap2, int *chudanpt, int chudanref, int *chudanres );
|
||||
extern double part_imp_match_out_sc( int i1, int j1 );
|
||||
extern void part_imp_match_init_strict( double *imp, int clus1, int clus2, int lgth1, int lgth2, char **seq1, char **seq2, double *eff1, double *eff2, double *eff1_kozo, double *eff2_kozo, LocalHom ***localhom, char *swaplist, int forscore, int *memlist1, int *memlist2 );
|
||||
extern void part_imp_match_init( double *imp, int clus1, int clus2, int lgth1, int lgth2, char **seq1, char **seq2, double *eff1, double *eff2, LocalHom ***localhom );
|
||||
extern double partA__align( char **seq1, char **seq2, double *eff1, double *eff2, int icyc, int jcyc, int alloclen, int constraint, double *impmatch, int start1, int end1, int start2, int end2, int *gapmap1, int *gapmap2, char *, char *, char *, char *, int *, int, int * );
|
||||
extern double partA__align_variousdist( int **which, double ***scoringmatrices, double **dummtx, char **seq1, char **seq2, double *eff1, double *eff2, double **eff1s, double **eff2s, int icyc, int jcyc, int alloclen, int constraint, double *impmatch, int start1, int end1, int start2, int end2, int *gapmap1, int *gapmap2, char *, char *, char *, char *, int *, int, int * );
|
||||
extern double G__align11( double **scoringmtx, char **seq1, char **seq2, int alloclen, int headgp, int tailgp );
|
||||
extern double G__align11_noalign( double **scoringmtx, int penal, int penal_ex, char **seq1, char **seq2, int alloclen );
|
||||
extern double L__align11( double **scoringmtx, double scoreoffset, char **seq1, char **seq2, int alloclen, int *off1pt, int *off2pt );
|
||||
extern double L__align11_noalign( double **scoringmtx, char **seq1, char **seq2 );
|
||||
extern double genL__align11( double **scoringmtx, char **seq1, char **seq2, int alloclen, int *off1pt, int *off2pt );
|
||||
extern double genG__align11( char **seq1, char **seq2, int alloclen );
|
||||
extern double VAalign11( char **seq1, char **seq2, int alloclen, int *off1pt, int *off2pt, LocalHom *lhmpt );
|
||||
extern double suboptalign11( char **seq1, char **seq2, int alloclen, int *off1pt, int *off2pt, LocalHom *lhmpt )
|
||||
;
|
||||
extern int fft(int n, Fukusosuu *x, int dum);
|
||||
extern void topolcpy( int s1[], int s2[], int *mpt1, int *mpt2 );
|
||||
extern void topolcat( int s1[], int s2[], int *mpt1, int *mpt2 );
|
||||
extern void topolsort( int m, int s[] );
|
||||
extern void topolswap( int s1[], int s2[], int *mpt1, int *mpt2 );
|
||||
extern void reduc( double **mtx, int nseq, int im, int jm );
|
||||
extern void nj( int nseq, double **omtx, int ***topol, double **dis );
|
||||
extern void JTTmtx( double **rsr, double *freq, unsigned char locamino[0x80], char locgrp[0x80], int isTM );
|
||||
extern void BLOSUMmtx( int n, double **matrix, double *freq, unsigned char *amino, char *amino_grp, int *rescale );
|
||||
extern void extendedmtx( double **matrix, double *freq, unsigned char *amino, char *amino_grp );
|
||||
extern void putlocalhom2( char *al1, char *al2, LocalHom *localhompt, int off1, int off2, int opt, int overlapaa, char korh );
|
||||
extern void putlocalhom_str( char *al1, char *al2, double *equiv, double scale, LocalHom *localhompt, int off1, int off2, int opt, int overlapaa, char korh );
|
||||
extern void putlocalhom_ext( char *al1, char *al2, LocalHom *localhompt, int off1, int off2, int opt, int overlapaa, char korh );
|
||||
extern void putlocalhom3( char *al1, char *al2, LocalHom *localhompt, int off1, int off2, int opt, int overlapaa, char korh );
|
||||
extern void putlocalhom( char *al1, char *al2, LocalHom *localhompt, int off1, int off2, int opt, int overlapaa, char korh );
|
||||
extern char *cutal( char *al, int al_display_start, int start, int end );
|
||||
extern void ErrorExit( char *message );
|
||||
extern void strncpy_caseC( char *str1, char *str2, int len );
|
||||
extern void seqUpper( int nseq, char **seq );
|
||||
extern void seqLower( int nseq, char **seq );
|
||||
extern int getaline_fp_eof( char *s, int l, FILE *fp );
|
||||
extern int getaline_fp_eof_new(char s[], int l, FILE *fp);
|
||||
extern int myfgets(char s[], int l, FILE *fp);
|
||||
extern double input_new( FILE *fp, int d );
|
||||
extern void PreRead( FILE *fp, int *locnjob, int *locnlenmax );
|
||||
extern int allSpace( char *str );
|
||||
extern void Read( char name[M][B], int nlen[M], char **seq );
|
||||
extern void FRead( FILE *fp, char name[][B], int nlen[], char **seq );
|
||||
extern void kake2hiku( char *str );
|
||||
extern int copydatafromgui( char **namegui, char **seqgui, char **name, int *nlen, char **seq );
|
||||
extern void readDataforgaln( FILE *fp, char **name, int *nlen, char **seq );
|
||||
extern void readData( FILE *fp, char name[][B], int nlen[], char **seq );
|
||||
extern void readData_pointer_casepreserve( FILE *fp, char **name, int *nlen, char **seq );
|
||||
extern void readData_pointer( FILE *fp, char **name, int *nlen, char **seq );
|
||||
extern void readData_pointer2( FILE *fp, int nseq, char **name, int *nlen, char **seq );
|
||||
extern void readData_varlen( FILE *fp, char **name, int *nlen, char **seq );
|
||||
extern int countATGC( char *s, int *total );
|
||||
extern void getnumlen( FILE *fp );
|
||||
extern void getnumlen_casepreserve( FILE *fp, int *nlenmin );
|
||||
extern void getnumlen_nogap( FILE *fp, int *nlenmin );
|
||||
extern void getnumlen_nogap_countn( FILE *fp, int *nlenmin, double *nfreq );
|
||||
extern void WriteGapFill( FILE *fp, int locnjob, char name[][B], int nlen[M], char **aseq );
|
||||
extern void writeDataforgaln( FILE *fp, int locnjob, char **name, int *nlen, char **aseq );
|
||||
extern void writeData( FILE *fp, int locnjob, char name[][B], int nlen[], char **aseq );
|
||||
extern void writeData_pointer( FILE *fp, int locnjob, char **name, int *nlen, char **aseq );
|
||||
extern void readhat2_doublehalf( FILE *fp, int nseq, char name[M][B], double **mtx );
|
||||
extern void readhat2_doublehalf_pointer( FILE *fp, int nseq, char **name, double **mtx );
|
||||
extern void readhat2_doublehalf_part_pointer( FILE *fp, int nseq, int nadd, char **name, double **mtx );
|
||||
extern void readhat2_double( FILE *fp, int nseq, char name[M][B], double **mtx );
|
||||
extern void readhat2_int( FILE *fp, int nseq, char name[M][B], int **mtx );
|
||||
extern void readhat2_pointer( FILE *fp, int nseq, char **name, double **mtx );
|
||||
extern void readhat2( FILE *fp, int nseq, char name[M][B], double **mtx );
|
||||
extern void WriteFloatHat2_pointer_halfmtx( FILE *hat2p, int locnjob, char **name, double **mtx );
|
||||
extern void WriteFloatHat2( FILE *hat2p, int locnjob, char name[M][B], double **mtx );
|
||||
extern void WriteHat2_int( FILE *hat2p, int locnjob, char name[M][B], int **mtx );
|
||||
extern void WriteHat2( FILE *hat2p, int locnjob, char name[M][B], double **mtx );
|
||||
extern void WriteHat2_pointer( FILE *hat2p, int locnjob, char **name, double **mtx );
|
||||
extern void WriteHat2_part_pointer( FILE *hat2p, int locnjob, int nadd, char **name, double **mtx );
|
||||
extern int ReadFasta_sub( FILE *fp, double *dis, int nseq, char name[M][B] );
|
||||
extern int ReadSsearch( FILE *fp, double *dis, int nseq, char name[M][B] );
|
||||
extern int ReadBlastm7( FILE *fp, double *dis, int qmem, char **name, LocalHom *localhomlist );
|
||||
extern int ReadBlastm7_scoreonly( FILE *fp, double *dis, int nin );
|
||||
extern int ReadBlastm7_avscore( FILE *fp, double *dis, int nin );
|
||||
extern int ReadFasta34noalign( FILE *fp, double *dis, int qmem, char **name, LocalHom *localhomlist );
|
||||
extern int ReadFasta34m10_nuc( FILE *fp, double *dis, int qmem, char **name, LocalHom *localhomlist );
|
||||
extern int ReadFasta34m10( FILE *fp, double *dis, int qmem, char **name, LocalHom *localhomlist );
|
||||
extern int ReadFasta34m10_scoreonly_nuc( FILE *fp, double *dis, int nin );
|
||||
extern int ReadFasta34m10_scoreonly( FILE *fp, double *dis, int nin );
|
||||
extern int ReadFasta34( FILE *fp, double *dis, int nseq, char name[M][B], LocalHom *localhomlist );
|
||||
extern int ReadFasta3( FILE *fp, double *dis, int nseq, char name[M][B] );
|
||||
extern int ReadFasta( FILE *fp, double *dis, int nseq, char name[M][B] );
|
||||
extern int ReadOpt( FILE *fp, int opt[M], int nseq, char name[M][B] );
|
||||
extern int ReadOpt2( FILE *fp, int opt[M], int nseq, char name[M][B] );
|
||||
extern int writePre( int nseq, char **name, int nlen[M], char **aseq, int force );
|
||||
extern void readOtherOptions( int *ppidptr, int *fftThresholdptr, int *fftWinSizeptr );
|
||||
extern void initSignalSM( void );
|
||||
extern void initFiles( void );
|
||||
extern void WriteForFasta( FILE *fp, int locnjob, char **name, int nlen[M], char **aseq );
|
||||
extern void readlocalhomtable( FILE*fp, int njob, LocalHom **localhomtable, char *kozoarivec );
|
||||
extern void readlocalhomtable_half( FILE*fp, int njob, LocalHom **localhomtable, char *kozoarivec );
|
||||
extern void readlocalhomtable_target( FILE*fp, int nt, int njob, LocalHom **localhomtable, char *kozoarivec, int *targetmap );
|
||||
extern void readlocalhomtable2( FILE*fp, int njob, LocalHom **localhomtable, char *kozoarivec );
|
||||
extern void readlocalhomtable2_half( FILE*fp, int njob, LocalHom **localhomtable, char *kozoarivec );
|
||||
extern void readlocalhomtable2_target( FILE*fp, int njob, LocalHom **localhomtable, char *kozoarivec, int *targetmap );
|
||||
extern void readlocalhomtable_part( FILE*fp, int njob, int nadd, LocalHom **localhomtable, char *kozoarivec );
|
||||
extern void readlocalhomtable_two( FILE*fp, int njob, int nadd, LocalHom **localhomtable, LocalHom **localhomtablex, char *kozoarivec );
|
||||
extern void readlocalhomtable_one( FILE*fp, int njob, int nadd, LocalHom **localhomtable, char *kozoarivec );
|
||||
extern void outlocalhom( LocalHom **localhom, int nseq );
|
||||
extern void outlocalhom_part( LocalHom **localhom, int norg, int nadd );
|
||||
extern void outlocalhompt( LocalHom ***localhom, int n1, int n2 );
|
||||
extern void FreeLocalHomTable_half( LocalHom **localhomtable, int n ) ;
|
||||
extern void FreeLocalHomTable( LocalHom **localhomtable, int n ) ;
|
||||
extern void FreeLocalHomTable_part( LocalHom **localhomtable, int n, int m ) ;
|
||||
extern void FreeLocalHomTable_two( LocalHom **localhomtable, int n, int m ) ;
|
||||
extern void FreeLocalHomTable_one( LocalHom **localhomtable, int n, int m ) ;
|
||||
extern void freelocalhom1( LocalHom *lh );
|
||||
extern void initlocalhom1( LocalHom *lh );
|
||||
extern void constants( int nseq, char **seq );
|
||||
extern void clustalout_pointer( FILE *fp, int nseq, int maxlen, char **seq, char **name, char *mark, char *comment, int *order, int namelen );
|
||||
extern void phylipout_pointer( FILE *fp, int nseq, int maxlen, char **seq, char **name, int *order, int namelen );
|
||||
extern void writeData_reorder( FILE *fp, int locnjob, char name[][B], int nlen[], char **aseq, int *order );
|
||||
extern void writeData_reorder_pointer( FILE *fp, int locnjob, char **name, int *nlen, char **aseq, int *order );
|
||||
|
||||
extern void resetlocalhom( int, LocalHom ** );
|
||||
extern int load1SeqWithoutName_new( FILE *fpp, char *cbuf );
|
||||
extern char *load1SeqWithoutName_realloc( FILE *fpp );
|
||||
extern char *load1SeqWithoutName_realloc_casepreserve( FILE *fpp );
|
||||
extern void searchKUorWA( FILE *fp );
|
||||
extern void gapireru( char *res, char *ori, char *gt );
|
||||
extern int seqlen( char *seq );
|
||||
extern void st_FinalGapCount( double *fgcp, int clus, char **seq, double *eff, int len );
|
||||
extern void st_FinalGapAdd( double *fgcp, int clus, char **seq, double *eff, int len );
|
||||
extern void st_OpeningGapCount( double *ogcp, int clus, char **seq, double *eff, int len );
|
||||
extern void st_OpeningGapAdd( double *ogcp, int clus, char **seq, double *eff, int len );
|
||||
extern void st_FinalGapCount_zure( double *fgcp, int clus, char **seq, double *eff, int len );
|
||||
extern void getdiaminofreq_x( double *freq, int clus, char **seq, double *eff, int len );
|
||||
extern void new_FinalGapCount_zure( double *fgcp, int clus, char **seq, double *eff, int len, char *s, char *e );
|
||||
extern void new_FinalGapCount( double *fgcp, int clus, char **seq, double *eff, int len, char *g );
|
||||
extern void new_OpeningGapCount( double *ogcp, int clus, char **seq, double *eff, int len, char *g );
|
||||
extern void new_OpeningGapCount_zure( double *ogcp, int clus, char **seq, double *eff, int len, char *s, char *e );
|
||||
extern void getGapPattern( double *fgcp, int clus, char **seq, double *eff, int len, char *g );
|
||||
extern void getgapfreq( double *freq, int clus, char **seq, double *eff, int len );
|
||||
extern void getgapfreq_zure( double *freq, int clus, char **seq, double *eff, int len );
|
||||
//extern void getgapfreq_zure_part( double *freq, int clus, char **seq, double *eff, int len, char *s );
|
||||
extern void getgapfreq_zure_part( double *freq, int clus, char **seq, double *eff, int len, char *s );
|
||||
extern void getdiaminofreq_part( double *freq, int clus, char **seq, double *eff, int len, char *s, char *e );
|
||||
extern void getdigapfreq_part( double *freq, int clus, char **seq, double *eff, int len, char *s, char *e );
|
||||
extern void getdiaminofreq_st( double *freq, int clus, char **seq, double *eff, int len );
|
||||
extern void getdigapfreq_st( double *freq, int clus, char **seq, double *eff, int len );
|
||||
extern void st_getGapPattern( Gappat **gpat, int clus, char **seq, double *eff, int len );
|
||||
extern void getkyokaigap( char *g, char **s, int pos, int n );
|
||||
extern double *loadaamtx( int *rescalept );
|
||||
extern double naivepairscore( int nseq1, int nseq2, char **seq1, char **seq2, double *eff1, double *eff2, int penal );
|
||||
extern double naivepairscore11( char *seq1, char *seq2, int penal );
|
||||
extern double naivepairscore11_dynmtx( double **, char *seq1, char *seq2, int penal );
|
||||
extern double naivepairscorefast( char *seq1, char *seq2, int *skip1, int *skip2, int penal );
|
||||
extern double naiveQpairscore( int nseq1, int nseq2, char **seq1, char **seq2, double *eff1, double *eff2, int penal );
|
||||
extern double naiveRpairscore( int nseq1, int nseq2, char **seq1, char **seq2, double *eff1, double *eff2, int penal );
|
||||
extern double naiveHpairscore( int nseq1, int nseq2, char **seq1, char **seq2, double *eff1, double *eff2, int penal );
|
||||
extern void foldrna( int nseq1, int nseq2, char **seq1, char **seq2, double *eff1, double *eff2, RNApair ***gr1, RNApair ***gr2, double **impmtx, int *gapmap1, int *gapmap2, RNApair *pair );
|
||||
extern void foldrna_gappick( int nseq1, int nseq2, char **seq1, char **seq2, double *eff1, double *eff2, RNApair ***gr1, RNApair ***gr2, double **impmtx, int *gapmap1, int *gapmap2, RNApair *pair );
|
||||
extern void imp_rna( int nseq1, int nseq2, char **seq1, char **seq2, double *eff1, double *eff2, RNApair ***gr1, RNApair ***gr2, int *gapmap1, int *gapmap2, RNApair *pair );
|
||||
extern void imp_rnaD( int nseq1, int nseq2, char **seq1, char **seq2, double *eff1, double *eff2, RNApair ***gr1, RNApair ***gr2, int *gapmap1, int *gapmap2, RNApair *pair );
|
||||
extern void part_imp_rna( int nseq1, int nseq2, char **seq1, char **seq2, double *eff1, double *eff2, RNApair ***gr1, RNApair ***gr2, int *gapmap1, int *gapmap2, RNApair *pair );
|
||||
extern void foldalignedrna( int clus1, int clus2, char **mseq1, char **mseq2, double *effarr1, double *effarr2, RNApair *rnapairboth );
|
||||
void readmccaskill( FILE *fp, RNApair **pairprob, int length );
|
||||
void makegrouprna( RNApair ***group, RNApair ***all, int *memlist );
|
||||
void makegrouprnait( RNApair ***group, RNApair ***all, char *pair, int s );
|
||||
extern void fixed_musclesupg_double_realloc_nobk_halfmtx( int nseq, double **eff, int ***topol, double **len, Treedep *, int progressout, int efffree );
|
||||
extern void fixed_musclesupg_double_realloc_nobk_halfmtx_memsave( int nseq, double **eff, int ***topol, double **len, Treedep *, int progressout, int efffree );
|
||||
extern void loadtop( int nseq, double **mtx, int ***topol, double **len, char **name, int *nlen, Treedep * );
|
||||
extern void loadtree( int nseq, int ***topol, double **len, char **name, int *nlen, Treedep *, int treeout );
|
||||
extern int check_guidetreefile( int *seed, int *npick, double *limitram );
|
||||
extern void createchain( int nseq, int ***topol, double **len, char **name, int *nlen, Treedep *dep, int treeout, int shuffle, int seed );
|
||||
//extern void loadtop( int nseq, double **eff, int ***topol, double **len );
|
||||
extern void fixed_musclesupg_double_realloc_nobk_halfmtx_treeout( int nseq, double **eff, int ***topol, double **len, char **name, int *nlen, Treedep *, int efffree ); // KESU
|
||||
extern void fixed_musclesupg_double_realloc_nobk_halfmtx_treeout_memsave( int nseq, double **eff, int ***topol, double **len, char **name, int *nlen, Treedep *, int efffree, int treeout );
|
||||
extern void fixed_supg_double_realloc_nobk_halfmtx_treeout_constrained( int nseq, double **eff, int ***topol, double **len, char **name, int *nlen, Treedep *, int ncons, int **constraints, int efffree );
|
||||
extern void fixed_musclesupg_double_treeout( int nseq, double **eff, int ***topol, double **len, char **name );
|
||||
extern void fixed_supg_double_treeout_constrained( int nseq, double **eff, int ***topol, double **len, char **name, int ncons, int **constraints );
|
||||
extern void imp_match_init_strict( double *imp, int clus1, int clus2, int lgth1, int lgth2, char **seq1, char **seq2, double *eff1, double *eff2, double *eff1kozo, double*eff2kozo, LocalHom ***localhom, char *swaplist, int forscore, int *memlist1, int *memlist2, int *uselh, int *seedinlh1, int *seedinlh2, int nodeid, int nfiles );
|
||||
extern void miyataout_reorder_pointer( FILE *fp, int locnjob, int nlenmax, char **name, int *nlen, char **aseq, int *order );
|
||||
extern void veryfastsupg_double_outtree( int nseq, double **eff, int ***topol, double **len, char **name );
|
||||
extern void cpmx_ribosum( char **seq, char **seqr, char *dir, double **cpmx, double *eff, int lgth, int clus );
|
||||
extern void rnaalifoldcall( char **seq, int nseq, RNApair **pairprob );
|
||||
extern void readpairfoldalign( FILE *fp, char *seq1, char *seq2, char *aln1, char *aln2, int q1, int q2, int *of1, int *of2, int sumlen );
|
||||
extern void write1seq( FILE *fp, char *aseq );
|
||||
extern void assignstrweight( int nseq, double *strweight, Node *stopol, int ***topol, int step, int LorR, char *kozoari, double *seqweight );
|
||||
extern void cutData( FILE *, int **, char **, int * );
|
||||
extern void cutAlignment( FILE *, int **, char **, int *, char **, char ** );
|
||||
extern void catData( FILE * );
|
||||
extern void getnumlen_nogap_outallreg_web( FILE *fp, FILE *ofp, int *nlenminpt, int *isalignedpt );
|
||||
extern void getnumlen_nogap_outallreg( FILE *fp, int *nlenminpt );
|
||||
extern double plainscore( int nseq, char **seq );
|
||||
extern void eq2dash( char *s );
|
||||
extern void eq2dashmatometehayaku( char **s, int n );
|
||||
extern void findnewgaps( int n, int rep, char **seq, int *gaplen );
|
||||
extern void findcommongaps( int, char **, int * );
|
||||
extern void adjustgapmap( int, int *, char * );
|
||||
extern void insertnewgaps_bothorders( int njob, int *alreadyaligned, char **seq, int *ex1, int *ex2, int *gaplen, int *gapmap, int gapmaplen, int alloclen, char alg, char gapchar );
|
||||
extern void insertnewgaps( int njob, int *alreadyaligned, char **seq, int *ex1, int *ex2, int *gaplen, int *gapmap, int alloclen, char alg, char gapchar );
|
||||
extern void restorecommongaps( int n, int n0, char **seq, int *top0, int *top1, int *gaplen, int alloclen, char gapchar );
|
||||
extern void restorecommongapssmoothly( int n, int n0, char **seq, int *top0, int *top1, int *gaplen, int alloclen, char gapchar );
|
||||
extern int samemember( int *mem, int *cand );
|
||||
extern int samemembern( int *mem, int *cand, int candn );
|
||||
extern int includemember( int *mem, int *cand );
|
||||
extern int overlapmember( int *mem1, int *mem2 );
|
||||
//extern void profilealignment( int n0, int n1, int n2, char **aln0, char **aln1, char **aln2, int alloclen, char alg );
|
||||
extern void profilealignment2( int n0, int n2, char **aln0, char **aln2, int alloclen, char alg );
|
||||
extern void sreverse( char *r, char *s );
|
||||
extern int addonetip( int njobc, int ***topolc, double **lenc, double **iscorec, int ***topol, double **len, Treedep *dep, int treeout, Addtree *addtree, int iadd, char **name, int *alnleninnode, int *nogaplen, int noalign );
|
||||
extern void intcpy( int *s1, int *s2 );
|
||||
extern void intncpy( int *s1, int *s2, int n );
|
||||
extern void fltncpy( double *s1, double *s2, int n );
|
||||
extern void intcat( int *s1, int *s2 );
|
||||
extern void readsubalignmentstable( int n, int **table, int *preservegaps, int *nsubpt, int *maxmempt );
|
||||
extern int myatoi( char * );
|
||||
extern unsigned long long myatoll( char * );
|
||||
extern double myatof( char * );
|
||||
extern void gapcount( double *freq, char **seq, int nseq, double *eff, int lgth );
|
||||
extern void gapcountf( double *freq, char **seq, int nseq, double *eff, int lgth );
|
||||
extern void gapcountadd( double *freq, char **seq, int nseq, double *eff, int lgth );
|
||||
extern void outgapcount( double *freq, int nseq, char *gappat, double *eff );
|
||||
extern void makedynamicmtx( double **out, double **in, double offset );
|
||||
extern double dist2offset( double dist );
|
||||
extern void reporterr( const char *str, ... );
|
||||
extern void freeconstants();
|
||||
extern void closeFiles();
|
||||
extern void FreeCommonIP();
|
||||
extern void initglobalvariables();
|
||||
extern void makeskiptable( int n, int **skip, char **seq );
|
||||
extern int generatesubalignmentstable( int nseq, int ***tablept, int *nsubpt, int *maxmempt, int ***topol, double **len, double threshold );
|
||||
extern double sumofpairsscore( int nseq, char **seq );
|
||||
//extern int maskoriginalgaps( char *repseq, char *originallygapped );
|
||||
|
||||
//extern void restoregaponlysites( char *originallygapped, int n1, int n2, char **s1, char **s2, int rep );
|
||||
extern int isallgap( char * );
|
||||
extern int deletenewinsertions_whole( int on, int an, char **oseq, char **aseq, int **deletelist );
|
||||
extern int deletenewinsertions_whole_eq( int on, int an, char **oseq, char **aseq, int **deletelist );
|
||||
extern int recordoriginalgaps( char *originallygapped, int n, char **s );
|
||||
extern void restoreoriginalgaps( int n, char **seq, char *originalgaps );
|
||||
extern void reconstructdeletemap( int nadd, char ** addbk, int **deletelist, char **realn, FILE *fp, char **name );
|
||||
extern double D__align( double **n_dynamicmtx, char **seq1, char **seq2, double *eff1, double *eff2, int icyc, int jcyc, int alloclen, int constraint, double *impmatch, char *sgap1, char *sgap2, char *egap1, char *egap2, int *chudanpt, int chudanref, int *chudanres, int headgp, int tailgp );
|
||||
extern double D__align_ls( double **n_dynamicmtx, char **seq1, char **seq2, double *eff1, double *eff2, int icyc, int jcyc, int alloclen, int constraint, double *impmatch, char *sgap1, char *sgap2, char *egap1, char *egap2, int *chudanpt, int chudanref, int *chudanres, int headgp, int tailgp );
|
||||
extern double D__align_variousdist( int **whichmtx, double ***matrices, double **n_dynamicmtx, char **seq1, char **seq2, double *eff1, double *eff2, double **eff1s, double **eff2s, int icyc, int jcyc, int alloclen, int constraint, double *impmatch, char *sgap1, char *sgap2, char *egap1, char *egap2, int *chudanpt, int chudanref, int *chudanres, int headgp, int tailgp );
|
||||
extern double D__align_gapmap( char **seq1, char **seq2, double *eff1, double *eff2, int icyc, int jcyc, int alloclen, int constraint, double *impmatch, int *gapmap1, int *gapmap2 );
|
||||
extern void stringshuffle( int *ary, int size );
|
||||
extern void topolorder( int *order, int *posinorder, int ***topol, Treedep *dep, int pos, int child );
|
||||
extern int *topolorderz( int *order, int ***topol, Treedep *dep, int pos, int nchild );
|
||||
extern int *topolordery( int *order, int ***topol, Treedep *dep, int pos, int nchild );
|
||||
extern int commonsextet_p( int *table, int *pointt );
|
||||
extern void compacttree_memsaveselectable( int nseq, double **partmtx, int *nearest, double *mindist, int **pointt, int *selfscore, char **seq, int **skiptable, int ***topol, double **len, char **name, int *nlen, Treedep *dep, int treeout, int howcompact, int memsave );
|
||||
extern void compacttreedpdist( int njob, char **seq, char **dseq, double *selfscore, int ***topol, double **len, char **name, Treedep *dep, int treeout, int alloclen, int *uselh, int *nfilesfornode, int treegiven );
|
||||
extern void compacttreegivendist( int njob, double *mindists, int *neighbors, int ***topol, double **len, char **name, Treedep *dep, int treeout );
|
||||
extern double distcompact( int len1, int len2, int *table1, int *point2, int ss1, int ss2 );
|
||||
extern double distcompact_msa( char *seq1, char *seq2, int *skiptable1, int *skiptable2, int ss1, int ss2 );
|
||||
extern void fillimp( double **impmtx, double *imp, int clus1, int clus2, int lgth1, int lgth2, char **seq1, char **seq2, double *eff1, double *eff2, double *eff1_kozo, double *eff2_kozo, LocalHom ***localhom, char *swaplist, int forscore, int *orinum1, int *orinum2 );
|
||||
extern void fillimp_file( double **impmtx, double *imp, int clus1, int clus2, int lgth1, int lgth2, char **seq1, char **seq2, double *eff1, double *eff2, double *eff1_kozo, double *eff2_kozo, LocalHom ***localhom, char *swaplist, int forscore, int *orinum1, int *orinum2, int *uselh, int *seedinlh1, int *seedinlh2, int nodeid, int nfiles );
|
||||
extern int pairlocalalign( int ngui, int lgui, char **namegui, char **seqgui, double **distancemtx, LocalHom **localhomtable, int argc, char **argv, double **expdist );
|
||||
extern char creverse( char f );
|
||||
#ifndef mingw
|
||||
extern void setstacksize( rlim_t );
|
||||
extern void use_getrusage(void);
|
||||
#endif
|
||||
extern void treeout_bin( FILE *treefp, int n, int ***topol, double **len, Treedep *dep, int *nfilesfornode );
|
||||
extern void treein_bin( FILE *treefp, int n, int ***topol, double **len, Treedep *dep, int *nfilesfornode );
|
||||
extern void uselhout( FILE *, int n, int * );
|
||||
extern int uselhin( FILE *, int n, int * );
|
||||
extern void pairalign_node( int njob, int nlenmax, char **name, char **seq, int ***topol, double **len, Treedep *dep, int treegiven, int treeout );
|
||||
extern void sortbylength( int *uselh, Lennum *in, int size, unsigned long long numpairs );
|
||||
extern void limitlh( int *uselh, Lennum *in, int size, int limit );
|
||||
|
||||
extern double distdp_noalign( char *s1, char *s2, double selfscore1, double selfscore2, int alloclen ); // tbfast.c kara yobareru
|
||||
extern void getweightfromname( int n, double *w, char **name );
|
||||
extern void readexternalanchors( ExtAnch **extanch, int nseq, int *nogaplen );
|
609
mafft/src/mafft-7.487-with-extensions/core/genalign11.c
Normal file
609
mafft/src/mafft-7.487-with-extensions/core/genalign11.c
Normal file
|
@ -0,0 +1,609 @@
|
|||
#include "mltaln.h"
|
||||
#include "dp.h"
|
||||
|
||||
#define DEBUG 0
|
||||
#define DEBUG2 0
|
||||
#define XXXXXXX 0
|
||||
#define USE_PENALTY_EX 1
|
||||
|
||||
static TLS int localstop;
|
||||
|
||||
#if 1
|
||||
static void match_calc_mtx( double **mtx, double *match, char **s1, char **s2, int i1, int lgth2 )
|
||||
{
|
||||
char *seq2 = s2[0];
|
||||
double *doubleptr = mtx[(unsigned char)s1[0][i1]];
|
||||
|
||||
while( lgth2-- )
|
||||
*match++ = doubleptr[(unsigned char)*seq2++];
|
||||
}
|
||||
#else
|
||||
static void match_calc( double *match, char **s1, char **s2, int i1, int lgth2 )
|
||||
{
|
||||
int j;
|
||||
|
||||
for( j=0; j<lgth2; j++ )
|
||||
match[j] = amino_dis[(*s1)[i1]][(*s2)[j]];
|
||||
}
|
||||
#endif
|
||||
|
||||
static double gentracking( double *lasthorizontalw, double *lastverticalw,
|
||||
char **seq1, char **seq2,
|
||||
char **mseq1, char **mseq2,
|
||||
double **cpmx1, double **cpmx2,
|
||||
int **ijpi, int **ijpj, int *off1pt, int *off2pt, int endi, int endj )
|
||||
{
|
||||
int i, j, l, iin, jin, lgth1, lgth2, k, limk;
|
||||
int ifi=0, jfi=0; // by D.Mathog
|
||||
// char gap[] = "-";
|
||||
char *gap;
|
||||
gap = newgapstr;
|
||||
lgth1 = strlen( seq1[0] );
|
||||
lgth2 = strlen( seq2[0] );
|
||||
|
||||
#if 0
|
||||
for( i=0; i<lgth1; i++ )
|
||||
{
|
||||
fprintf( stderr, "lastverticalw[%d] = %f\n", i, lastverticalw[i] );
|
||||
}
|
||||
#endif
|
||||
|
||||
for( i=0; i<lgth1+1; i++ )
|
||||
{
|
||||
ijpi[i][0] = localstop;
|
||||
ijpj[i][0] = localstop;
|
||||
}
|
||||
for( j=0; j<lgth2+1; j++ )
|
||||
{
|
||||
ijpi[0][j] = localstop;
|
||||
ijpj[0][j] = localstop;
|
||||
}
|
||||
|
||||
mseq1[0] += lgth1+lgth2;
|
||||
*mseq1[0] = 0;
|
||||
mseq2[0] += lgth1+lgth2;
|
||||
*mseq2[0] = 0;
|
||||
iin = endi; jin = endj;
|
||||
limk = lgth1+lgth2;
|
||||
for( k=0; k<=limk; k++ )
|
||||
{
|
||||
|
||||
ifi = ( ijpi[iin][jin] );
|
||||
jfi = ( ijpj[iin][jin] );
|
||||
l = iin - ifi;
|
||||
// if( ijpi[iin][jin] < 0 || ijpj[iin][jin] < 0 )
|
||||
// {
|
||||
// fprintf( stderr, "skip! %d-%d\n", ijpi[iin][jin], ijpj[iin][jin] );
|
||||
// fprintf( stderr, "1: %c-%c\n", seq1[0][iin], seq1[0][ifi] );
|
||||
// fprintf( stderr, "2: %c-%c\n", seq2[0][jin], seq2[0][jfi] );
|
||||
// }
|
||||
while( --l )
|
||||
{
|
||||
*--mseq1[0] = seq1[0][ifi+l];
|
||||
*--mseq2[0] = *gap;
|
||||
k++;
|
||||
}
|
||||
l= jin - jfi;
|
||||
while( --l )
|
||||
{
|
||||
*--mseq1[0] = *gap;
|
||||
*--mseq2[0] = seq2[0][jfi+l];
|
||||
k++;
|
||||
}
|
||||
|
||||
if( iin <= 0 || jin <= 0 ) break;
|
||||
*--mseq1[0] = seq1[0][ifi];
|
||||
*--mseq2[0] = seq2[0][jfi];
|
||||
|
||||
if( ijpi[ifi][jfi] == localstop ) break;
|
||||
if( ijpj[ifi][jfi] == localstop ) break;
|
||||
k++;
|
||||
iin = ifi; jin = jfi;
|
||||
}
|
||||
if( ifi == -1 ) *off1pt = 0; else *off1pt = ifi;
|
||||
if( jfi == -1 ) *off2pt = 0; else *off2pt = jfi;
|
||||
|
||||
// fprintf( stderr, "ifn = %d, jfn = %d\n", ifi, jfi );
|
||||
|
||||
|
||||
return( 0.0 );
|
||||
}
|
||||
|
||||
|
||||
double genL__align11( double **n_dynamicmtx, char **seq1, char **seq2, int alloclen, int *off1pt, int *off2pt )
|
||||
/* score no keisan no sai motokaraaru gap no atukai ni mondai ga aru */
|
||||
{
|
||||
// int k;
|
||||
register int i, j;
|
||||
int lasti, lastj;
|
||||
int lgth1, lgth2;
|
||||
int resultlen;
|
||||
double wm = 0.0; /* int ?????? */
|
||||
double g;
|
||||
double *currentw, *previousw;
|
||||
#if 1
|
||||
double *wtmp;
|
||||
int *ijpipt;
|
||||
int *ijpjpt;
|
||||
double *mjpt, *Mjpt, *prept, *curpt;
|
||||
int *mpjpt, *Mpjpt;
|
||||
#endif
|
||||
static TLS double mi, *m;
|
||||
static TLS double Mi, *largeM;
|
||||
static TLS int **ijpi;
|
||||
static TLS int **ijpj;
|
||||
static TLS int mpi, *mp;
|
||||
static TLS int Mpi, *Mp;
|
||||
static TLS double *w1, *w2;
|
||||
static TLS double *match;
|
||||
static TLS double *initverticalw; /* kufuu sureba iranai */
|
||||
static TLS double *lastverticalw; /* kufuu sureba iranai */
|
||||
static TLS char **mseq1;
|
||||
static TLS char **mseq2;
|
||||
static TLS char **mseq;
|
||||
static TLS double **cpmx1;
|
||||
static TLS double **cpmx2;
|
||||
static TLS int **intwork;
|
||||
static TLS double **doublework;
|
||||
static TLS int orlgth1 = 0, orlgth2 = 0;
|
||||
static TLS double **amino_dynamicmtx = NULL; // ??
|
||||
double maxwm;
|
||||
double tbk;
|
||||
int tbki, tbkj;
|
||||
int endali, endalj;
|
||||
// double localthr = 0.0;
|
||||
// double localthr2 = 0.0;
|
||||
double fpenalty = (double)penalty;
|
||||
double fpenalty_OP = (double)penalty_OP;
|
||||
double fpenalty_ex = (double)penalty_ex;
|
||||
// double fpenalty_EX = (double)penalty_EX;
|
||||
double foffset = (double)offset;
|
||||
double localthr = -foffset;
|
||||
double localthr2 = -foffset;
|
||||
|
||||
if( seq1 == NULL )
|
||||
{
|
||||
if( orlgth1 > 0 && orlgth2 > 0 )
|
||||
{
|
||||
orlgth1 = 0;
|
||||
orlgth2 = 0;
|
||||
free( mseq1 );
|
||||
free( mseq2 );
|
||||
FreeFloatVec( w1 );
|
||||
FreeFloatVec( w2 );
|
||||
FreeFloatVec( match );
|
||||
FreeFloatVec( initverticalw );
|
||||
FreeFloatVec( lastverticalw );
|
||||
|
||||
FreeFloatVec( m );
|
||||
FreeIntVec( mp );
|
||||
free( largeM );
|
||||
free( Mp );
|
||||
|
||||
FreeCharMtx( mseq );
|
||||
|
||||
FreeFloatMtx( cpmx1 );
|
||||
FreeFloatMtx( cpmx2 );
|
||||
|
||||
FreeFloatMtx( doublework );
|
||||
FreeIntMtx( intwork );
|
||||
if( amino_dynamicmtx ) FreeDoubleMtx( amino_dynamicmtx ); amino_dynamicmtx = NULL;
|
||||
|
||||
}
|
||||
return( 0.0 );
|
||||
}
|
||||
|
||||
|
||||
|
||||
// fprintf( stderr, "@@@@@@@@@@@@@ penalty_OP = %f, penalty_EX = %f, pelanty = %f\n", fpenalty_OP, fpenalty_EX, fpenalty );
|
||||
|
||||
if( orlgth1 == 0 )
|
||||
{
|
||||
mseq1 = AllocateCharMtx( njob, 0 );
|
||||
mseq2 = AllocateCharMtx( njob, 0 );
|
||||
}
|
||||
|
||||
|
||||
lgth1 = strlen( seq1[0] );
|
||||
lgth2 = strlen( seq2[0] );
|
||||
|
||||
if( lgth1 > orlgth1 || lgth2 > orlgth2 )
|
||||
{
|
||||
int ll1, ll2;
|
||||
|
||||
if( orlgth1 > 0 && orlgth2 > 0 )
|
||||
{
|
||||
FreeFloatVec( w1 );
|
||||
FreeFloatVec( w2 );
|
||||
FreeFloatVec( match );
|
||||
FreeFloatVec( initverticalw );
|
||||
FreeFloatVec( lastverticalw );
|
||||
|
||||
FreeFloatVec( m );
|
||||
FreeIntVec( mp );
|
||||
FreeFloatVec( largeM );
|
||||
FreeIntVec( Mp );
|
||||
|
||||
FreeCharMtx( mseq );
|
||||
|
||||
FreeFloatMtx( cpmx1 );
|
||||
FreeFloatMtx( cpmx2 );
|
||||
|
||||
FreeFloatMtx( doublework );
|
||||
FreeIntMtx( intwork );
|
||||
if( amino_dynamicmtx ) FreeDoubleMtx( amino_dynamicmtx ); amino_dynamicmtx = NULL;
|
||||
}
|
||||
|
||||
ll1 = MAX( (int)(1.3*lgth1), orlgth1 ) + 100;
|
||||
ll2 = MAX( (int)(1.3*lgth2), orlgth2 ) + 100;
|
||||
|
||||
#if DEBUG
|
||||
fprintf( stderr, "\ntrying to allocate (%d+%d)xn matrices ... ", ll1, ll2 );
|
||||
#endif
|
||||
|
||||
w1 = AllocateFloatVec( ll2+2 );
|
||||
w2 = AllocateFloatVec( ll2+2 );
|
||||
match = AllocateFloatVec( ll2+2 );
|
||||
|
||||
initverticalw = AllocateFloatVec( ll1+2 );
|
||||
lastverticalw = AllocateFloatVec( ll1+2 );
|
||||
|
||||
m = AllocateFloatVec( ll2+2 );
|
||||
mp = AllocateIntVec( ll2+2 );
|
||||
largeM = AllocateFloatVec( ll2+2 );
|
||||
Mp = AllocateIntVec( ll2+2 );
|
||||
|
||||
mseq = AllocateCharMtx( njob, ll1+ll2 );
|
||||
|
||||
cpmx1 = AllocateFloatMtx( nalphabets, ll1+2 );
|
||||
cpmx2 = AllocateFloatMtx( nalphabets, ll2+2 );
|
||||
|
||||
doublework = AllocateFloatMtx( nalphabets, MAX( ll1, ll2 )+2 );
|
||||
intwork = AllocateIntMtx( nalphabets, MAX( ll1, ll2 )+2 );
|
||||
|
||||
amino_dynamicmtx = AllocateDoubleMtx( 0x100, 0x100 );
|
||||
|
||||
#if DEBUG
|
||||
fprintf( stderr, "succeeded\n" );
|
||||
#endif
|
||||
|
||||
orlgth1 = ll1 - 100;
|
||||
orlgth2 = ll2 - 100;
|
||||
}
|
||||
|
||||
for( i=0; i<nalphabets; i++) for( j=0; j<nalphabets; j++ )
|
||||
amino_dynamicmtx[(unsigned char)amino[i]][(unsigned char)amino[j]] = (double)n_dynamicmtx[i][j];
|
||||
|
||||
mseq1[0] = mseq[0];
|
||||
mseq2[0] = mseq[1];
|
||||
|
||||
|
||||
if( orlgth1 > commonAlloc1 || orlgth2 > commonAlloc2 )
|
||||
{
|
||||
int ll1, ll2;
|
||||
|
||||
if( commonAlloc1 && commonAlloc2 )
|
||||
{
|
||||
FreeIntMtx( commonIP );
|
||||
FreeIntMtx( commonJP );
|
||||
}
|
||||
|
||||
ll1 = MAX( orlgth1, commonAlloc1 );
|
||||
ll2 = MAX( orlgth2, commonAlloc2 );
|
||||
|
||||
#if DEBUG
|
||||
fprintf( stderr, "\n\ntrying to allocate %dx%d matrices ... ", ll1+1, ll2+1 );
|
||||
#endif
|
||||
|
||||
commonIP = AllocateIntMtx( ll1+10, ll2+10 );
|
||||
commonJP = AllocateIntMtx( ll1+10, ll2+10 );
|
||||
|
||||
#if DEBUG
|
||||
fprintf( stderr, "succeeded\n\n" );
|
||||
#endif
|
||||
|
||||
commonAlloc1 = ll1;
|
||||
commonAlloc2 = ll2;
|
||||
}
|
||||
ijpi = commonIP;
|
||||
ijpj = commonJP;
|
||||
|
||||
|
||||
#if 0
|
||||
for( i=0; i<lgth1; i++ )
|
||||
fprintf( stderr, "ogcp1[%d]=%f\n", i, ogcp1[i] );
|
||||
#endif
|
||||
|
||||
currentw = w1;
|
||||
previousw = w2;
|
||||
|
||||
match_calc_mtx( amino_dynamicmtx, initverticalw, seq2, seq1, 0, lgth1 );
|
||||
|
||||
match_calc_mtx( amino_dynamicmtx, currentw, seq1, seq2, 0, lgth2 );
|
||||
|
||||
|
||||
lasti = lgth2+1;
|
||||
for( j=1; j<lasti; ++j )
|
||||
{
|
||||
m[j] = currentw[j-1]; mp[j] = 0;
|
||||
largeM[j] = currentw[j-1]; Mp[j] = 0;
|
||||
}
|
||||
|
||||
lastverticalw[0] = currentw[lgth2-1];
|
||||
|
||||
|
||||
#if 0
|
||||
fprintf( stderr, "currentw = \n" );
|
||||
for( i=0; i<lgth1+1; i++ )
|
||||
{
|
||||
fprintf( stderr, "%5.2f ", currentw[i] );
|
||||
}
|
||||
fprintf( stderr, "\n" );
|
||||
fprintf( stderr, "initverticalw = \n" );
|
||||
for( i=0; i<lgth2+1; i++ )
|
||||
{
|
||||
fprintf( stderr, "%5.2f ", initverticalw[i] );
|
||||
}
|
||||
fprintf( stderr, "\n" );
|
||||
#endif
|
||||
#if DEBUG2
|
||||
fprintf( stderr, "\n" );
|
||||
fprintf( stderr, " " );
|
||||
for( j=0; j<lgth2+1; j++ )
|
||||
fprintf( stderr, "%c ", seq2[0][j] );
|
||||
fprintf( stderr, "\n" );
|
||||
#endif
|
||||
|
||||
localstop = lgth1+lgth2+1;
|
||||
maxwm = -999999999.9;
|
||||
endali = endalj = 0;
|
||||
#if DEBUG2
|
||||
fprintf( stderr, "\n" );
|
||||
fprintf( stderr, "%c ", seq1[0][0] );
|
||||
|
||||
for( j=0; j<lgth2+1; j++ )
|
||||
fprintf( stderr, "%5.0f ", currentw[j] );
|
||||
fprintf( stderr, "\n" );
|
||||
#endif
|
||||
|
||||
lasti = lgth1+1;
|
||||
for( i=1; i<lasti; i++ )
|
||||
{
|
||||
wtmp = previousw;
|
||||
previousw = currentw;
|
||||
currentw = wtmp;
|
||||
|
||||
previousw[0] = initverticalw[i-1];
|
||||
|
||||
match_calc_mtx( amino_dynamicmtx, currentw, seq1, seq2, i, lgth2 );
|
||||
#if DEBUG2
|
||||
fprintf( stderr, "%c ", seq1[0][i] );
|
||||
fprintf( stderr, "%5.0f ", currentw[0] );
|
||||
#endif
|
||||
|
||||
#if XXXXXXX
|
||||
fprintf( stderr, "\n" );
|
||||
fprintf( stderr, "i=%d\n", i );
|
||||
fprintf( stderr, "currentw = \n" );
|
||||
for( j=0; j<lgth2; j++ )
|
||||
{
|
||||
fprintf( stderr, "%5.2f ", currentw[j] );
|
||||
}
|
||||
fprintf( stderr, "\n" );
|
||||
#endif
|
||||
#if XXXXXXX
|
||||
fprintf( stderr, "\n" );
|
||||
fprintf( stderr, "i=%d\n", i );
|
||||
fprintf( stderr, "currentw = \n" );
|
||||
for( j=0; j<lgth2; j++ )
|
||||
{
|
||||
fprintf( stderr, "%5.2f ", currentw[j] );
|
||||
}
|
||||
fprintf( stderr, "\n" );
|
||||
#endif
|
||||
currentw[0] = initverticalw[i];
|
||||
|
||||
mi = previousw[0]; mpi = 0;
|
||||
Mi = previousw[0]; Mpi = 0;
|
||||
|
||||
#if 0
|
||||
if( mi < localthr ) mi = localthr2;
|
||||
#endif
|
||||
|
||||
ijpipt = ijpi[i] + 1;
|
||||
ijpjpt = ijpj[i] + 1;
|
||||
mjpt = m + 1;
|
||||
Mjpt = largeM + 1;
|
||||
prept = previousw;
|
||||
curpt = currentw + 1;
|
||||
mpjpt = mp + 1;
|
||||
Mpjpt = Mp + 1;
|
||||
tbk = -999999.9;
|
||||
tbki = 0;
|
||||
tbkj = 0;
|
||||
lastj = lgth2+1;
|
||||
for( j=1; j<lastj; j++ )
|
||||
{
|
||||
wm = *prept;
|
||||
*ijpipt = i-1;
|
||||
*ijpjpt = j-1;
|
||||
|
||||
|
||||
// fprintf( stderr, "i,j=%d,%d %c-%c\n", i, j, seq1[0][i], seq2[0][j] );
|
||||
// fprintf( stderr, "wm=%f\n", wm );
|
||||
#if 0
|
||||
fprintf( stderr, "%5.0f->", wm );
|
||||
#endif
|
||||
g = mi + fpenalty;
|
||||
#if 0
|
||||
fprintf( stderr, "%5.0f?", g );
|
||||
#endif
|
||||
if( g > wm )
|
||||
{
|
||||
wm = g;
|
||||
// *ijpipt = i - 1;
|
||||
*ijpjpt = mpi;
|
||||
}
|
||||
g = *prept;
|
||||
if( g > mi )
|
||||
{
|
||||
mi = g;
|
||||
mpi = j-1;
|
||||
}
|
||||
|
||||
#if USE_PENALTY_EX
|
||||
mi += fpenalty_ex;
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
fprintf( stderr, "%5.0f->", wm );
|
||||
#endif
|
||||
g = *mjpt + fpenalty;
|
||||
#if 0
|
||||
fprintf( stderr, "m%5.0f?", g );
|
||||
#endif
|
||||
if( g > wm )
|
||||
{
|
||||
wm = g;
|
||||
*ijpipt = *mpjpt;
|
||||
*ijpjpt = j - 1; //IRU!
|
||||
}
|
||||
g = *prept;
|
||||
if( g > *mjpt )
|
||||
{
|
||||
*mjpt = g;
|
||||
*mpjpt = i-1;
|
||||
}
|
||||
#if USE_PENALTY_EX
|
||||
*mjpt += fpenalty_ex;
|
||||
#endif
|
||||
|
||||
|
||||
g = tbk + fpenalty_OP;
|
||||
// g = tbk;
|
||||
if( g > wm )
|
||||
{
|
||||
wm = g;
|
||||
*ijpipt = tbki;
|
||||
*ijpjpt = tbkj;
|
||||
// fprintf( stderr, "hit! i%d, j%d, ijpi = %d, ijpj = %d\n", i, j, *ijpipt, *ijpjpt );
|
||||
}
|
||||
// g = Mi;
|
||||
if( Mi > tbk )
|
||||
{
|
||||
tbk = Mi; //error desu.
|
||||
tbki = i-1;
|
||||
tbkj = Mpi;
|
||||
}
|
||||
// g = *Mjpt;
|
||||
if( *Mjpt > tbk )
|
||||
{
|
||||
tbk = *Mjpt;
|
||||
tbki = *Mpjpt;
|
||||
tbkj = j-1;
|
||||
}
|
||||
// tbk += fpenalty_EX;// + foffset;
|
||||
|
||||
// g = *prept;
|
||||
if( *prept > *Mjpt )
|
||||
{
|
||||
*Mjpt = *prept;
|
||||
*Mpjpt = i-1;
|
||||
}
|
||||
// *Mjpt += fpenalty_EX;// + foffset;
|
||||
|
||||
// g = *prept;
|
||||
if( *prept > Mi )
|
||||
{
|
||||
Mi = *prept;
|
||||
Mpi = j-1;
|
||||
}
|
||||
// Mi += fpenalty_EX;// + foffset;
|
||||
|
||||
|
||||
// fprintf( stderr, "wm=%f, tbk=%f(%c-%c), mi=%f, *mjpt=%f\n", wm, tbk, seq1[0][tbki], seq2[0][tbkj], mi, *mjpt );
|
||||
// fprintf( stderr, "ijp = %c,%c\n", seq1[0][abs(*ijpipt)], seq2[0][abs(*ijpjpt)] );
|
||||
|
||||
|
||||
if( maxwm < wm )
|
||||
{
|
||||
maxwm = wm;
|
||||
endali = i;
|
||||
endalj = j;
|
||||
}
|
||||
#if 1
|
||||
if( wm < localthr )
|
||||
{
|
||||
// fprintf( stderr, "stop i=%d, j=%d, curpt=%f\n", i, j, *curpt );
|
||||
*ijpipt = localstop;
|
||||
// *ijpjpt = localstop;
|
||||
wm = localthr2;
|
||||
}
|
||||
#endif
|
||||
#if 0
|
||||
fprintf( stderr, "%5.0f ", *curpt );
|
||||
#endif
|
||||
#if DEBUG2
|
||||
fprintf( stderr, "%5.0f ", wm );
|
||||
// fprintf( stderr, "%c-%c *ijppt = %d, localstop = %d\n", seq1[0][i], seq2[0][j], *ijppt, localstop );
|
||||
#endif
|
||||
|
||||
*curpt += wm;
|
||||
ijpipt++;
|
||||
ijpjpt++;
|
||||
mjpt++;
|
||||
Mjpt++;
|
||||
prept++;
|
||||
mpjpt++;
|
||||
Mpjpt++;
|
||||
curpt++;
|
||||
}
|
||||
#if DEBUG2
|
||||
fprintf( stderr, "\n" );
|
||||
#endif
|
||||
|
||||
lastverticalw[i] = currentw[lgth2-1];
|
||||
}
|
||||
|
||||
|
||||
#if DEBUG2
|
||||
fprintf( stderr, "maxwm = %f\n", maxwm );
|
||||
fprintf( stderr, "endali = %d\n", endali );
|
||||
fprintf( stderr, "endalj = %d\n", endalj );
|
||||
#endif
|
||||
|
||||
if( ijpi[endali][endalj] == localstop ) // && ijpj[endali][endalj] == localstop )
|
||||
{
|
||||
strcpy( seq1[0], "" );
|
||||
strcpy( seq2[0], "" );
|
||||
*off1pt = *off2pt = 0;
|
||||
return( 0.0 );
|
||||
}
|
||||
|
||||
|
||||
gentracking( currentw, lastverticalw, seq1, seq2, mseq1, mseq2, cpmx1, cpmx2, ijpi, ijpj, off1pt, off2pt, endali, endalj );
|
||||
|
||||
// fprintf( stderr, "### impmatch = %f\n", *impmatch );
|
||||
|
||||
resultlen = strlen( mseq1[0] );
|
||||
if( alloclen < resultlen || resultlen > N )
|
||||
{
|
||||
fprintf( stderr, "alloclen=%d, resultlen=%d, N=%d\n", alloclen, resultlen, N );
|
||||
ErrorExit( "LENGTH OVER!\n" );
|
||||
}
|
||||
|
||||
|
||||
strcpy( seq1[0], mseq1[0] );
|
||||
strcpy( seq2[0], mseq2[0] );
|
||||
|
||||
#if 0
|
||||
fprintf( stderr, "\n" );
|
||||
fprintf( stderr, ">\n%s\n", mseq1[0] );
|
||||
fprintf( stderr, ">\n%s\n", mseq2[0] );
|
||||
#endif
|
||||
|
||||
|
||||
return( maxwm );
|
||||
}
|
||||
|
||||
|
461
mafft/src/mafft-7.487-with-extensions/core/getlag.c
Normal file
461
mafft/src/mafft-7.487-with-extensions/core/getlag.c
Normal file
|
@ -0,0 +1,461 @@
|
|||
#include "mltaln.h"
|
||||
|
||||
#define DEBUG 0
|
||||
#define IODEBUG 0
|
||||
|
||||
void arguments( int argc, char *argv[] )
|
||||
{
|
||||
int c;
|
||||
|
||||
calledByXced = 0;
|
||||
devide = 0;
|
||||
use_fft = 0;
|
||||
fftscore = 1;
|
||||
fftRepeatStop = 0;
|
||||
fftNoAnchStop = 0;
|
||||
weight = 3;
|
||||
utree = 1;
|
||||
tbutree = 1;
|
||||
refine = 0;
|
||||
check = 1;
|
||||
cut = 0.0;
|
||||
disp = 0;
|
||||
outgap = 1;
|
||||
alg = 'C';
|
||||
mix = 0;
|
||||
tbitr = 0;
|
||||
scmtd = 5;
|
||||
tbweight = 0;
|
||||
tbrweight = 3;
|
||||
checkC = 0;
|
||||
treemethod = 'x';
|
||||
contin = 0;
|
||||
ppenalty = NOTSPECIFIED;
|
||||
ppenalty_ex = NOTSPECIFIED;
|
||||
poffset = NOTSPECIFIED;
|
||||
kimuraR = NOTSPECIFIED;
|
||||
pamN = NOTSPECIFIED;
|
||||
geta2 = GETA2;
|
||||
scoremtx = NOTSPECIFIED;
|
||||
|
||||
while( --argc > 0 && (*++argv)[0] == '-' )
|
||||
{
|
||||
while ( (c = *++argv[0]) )
|
||||
{
|
||||
switch( c )
|
||||
{
|
||||
case 'f':
|
||||
ppenalty = (int)( atof( *++argv ) * 1000 - 0.5 );
|
||||
fprintf( stderr, "ppenalty = %d\n", ppenalty );
|
||||
--argc;
|
||||
goto nextoption;
|
||||
case 'g':
|
||||
ppenalty_ex = (int)( atof( *++argv ) * 1000 - 0.5 );
|
||||
fprintf( stderr, "ppenalty_ex = %d\n", ppenalty_ex );
|
||||
--argc;
|
||||
goto nextoption;
|
||||
case 'h':
|
||||
poffset = (int)( atof( *++argv ) * 1000 - 0.5 );
|
||||
fprintf( stderr, "poffset = %d\n", poffset );
|
||||
--argc;
|
||||
goto nextoption;
|
||||
case 'D':
|
||||
scoremtx = -1;
|
||||
break;
|
||||
case 'P':
|
||||
scoremtx = 0;
|
||||
break;
|
||||
case 'i':
|
||||
contin = 1;
|
||||
break;
|
||||
case 'e':
|
||||
fftscore = 0;
|
||||
break;
|
||||
case 'O':
|
||||
fftNoAnchStop = 1;
|
||||
break;
|
||||
case 'R':
|
||||
fftRepeatStop = 1;
|
||||
break;
|
||||
case 'Q':
|
||||
calledByXced = 1;
|
||||
break;
|
||||
case 's':
|
||||
treemethod = 's';
|
||||
break;
|
||||
case 'x':
|
||||
treemethod = 'x';
|
||||
break;
|
||||
case 'p':
|
||||
treemethod = 'p';
|
||||
break;
|
||||
case 'a':
|
||||
alg = 'a';
|
||||
break;
|
||||
case 'A':
|
||||
alg = 'A';
|
||||
break;
|
||||
case 'S':
|
||||
alg = 'S';
|
||||
break;
|
||||
case 'C':
|
||||
alg = 'C';
|
||||
break;
|
||||
case 'F':
|
||||
use_fft = 1;
|
||||
break;
|
||||
case 'v':
|
||||
tbrweight = 3;
|
||||
break;
|
||||
case 'd':
|
||||
disp = 1;
|
||||
break;
|
||||
case 'o':
|
||||
outgap = 0;
|
||||
break;
|
||||
/* Modified 01/08/27, default: user tree */
|
||||
case 'J':
|
||||
tbutree = 0;
|
||||
break;
|
||||
/* modification end. */
|
||||
case 'Z':
|
||||
checkC = 1;
|
||||
break;
|
||||
default:
|
||||
fprintf( stderr, "illegal option %c\n", c );
|
||||
argc = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
nextoption:
|
||||
;
|
||||
}
|
||||
if( argc == 1 )
|
||||
{
|
||||
cut = atof( (*argv) );
|
||||
argc--;
|
||||
}
|
||||
if( argc != 0 )
|
||||
{
|
||||
fprintf( stderr, "options: Check source file !\n" );
|
||||
exit( 1 );
|
||||
}
|
||||
if( tbitr == 1 && outgap == 0 )
|
||||
{
|
||||
fprintf( stderr, "conflicting options : o, m or u\n" );
|
||||
exit( 1 );
|
||||
}
|
||||
if( alg == 'C' && outgap == 0 )
|
||||
{
|
||||
fprintf( stderr, "conflicting options : C, o\n" );
|
||||
exit( 1 );
|
||||
}
|
||||
readOtherOptions( &ppid, &fftThreshold, &fftWinSize );
|
||||
}
|
||||
|
||||
|
||||
void treebase( char **name, int nlen[M], char **seq, char **aseq, char **mseq1, char **mseq2, double **mtx, int ***topol, double **len, double **eff, int alloclen )
|
||||
{
|
||||
int i, j, l;
|
||||
int clus1, clus2;
|
||||
int s1, s2, r1, r2;
|
||||
double pscore;
|
||||
static char *indication1, *indication2;
|
||||
static char **name1, **name2;
|
||||
static double **partialmtx = NULL;
|
||||
static int ***partialtopol = NULL;
|
||||
static double **partiallen = NULL;
|
||||
static double **partialeff = NULL;
|
||||
static double *effarr = NULL;
|
||||
static double *effarr1 = NULL;
|
||||
static double *effarr2 = NULL;
|
||||
#if 0
|
||||
char pair[njob][njob];
|
||||
#else
|
||||
static char **pair;
|
||||
#endif
|
||||
if( partialtopol == NULL )
|
||||
{
|
||||
partialmtx = AllocateDoubleMtx( njob, njob );
|
||||
partialtopol = AllocateIntCub( njob, 2, njob );
|
||||
partialeff = AllocateDoubleMtx( njob, njob );
|
||||
partiallen = AllocateDoubleMtx( njob, 2 );
|
||||
effarr = AllocateDoubleVec( njob );
|
||||
effarr1 = AllocateDoubleVec( njob );
|
||||
effarr2 = AllocateDoubleVec( njob );
|
||||
indication1 = AllocateCharVec( njob*3+100 );
|
||||
indication2 = AllocateCharVec( njob*3+100 );
|
||||
name1 = AllocateCharMtx( njob, B+1 );
|
||||
name2 = AllocateCharMtx( njob, B+1 );
|
||||
#if 0
|
||||
#else
|
||||
pair = AllocateCharMtx( njob, njob );
|
||||
#endif
|
||||
}
|
||||
|
||||
if( checkC )
|
||||
for( i=0; i<njob; i++ ) fprintf( stderr, "eff in tb-%d %f\n", i, eff[i][i] );
|
||||
|
||||
for( i=0; i<njob; i++ ) effarr[i] = eff[i][i];
|
||||
for( i=0; i<njob; i++ ) strcpy( aseq[i], seq[i] );
|
||||
|
||||
if( checkC )
|
||||
for( i=0; i<njob; i++ ) fprintf( stderr, "effarr for aseq-%d %f\n", i, effarr[i] );
|
||||
|
||||
writePre( njob, name, nlen, aseq, 0 );
|
||||
|
||||
for( i=0; i<njob; i++ ) for( j=0; j<njob; j++ ) pair[i][j] = 0;
|
||||
for( i=0; i<njob; i++ ) pair[i][i] = 1;
|
||||
for( l=0; l<njob-1; l++ )
|
||||
{
|
||||
s1 = topol[l][0][0];
|
||||
for( i=0; (r1=topol[l][0][i])>-1; i++ )
|
||||
if( pair[s1][r1] != 1 ) exit( 1 );
|
||||
s2 = topol[l][1][0];
|
||||
for( i=0; (r2=topol[l][1][i])>-1; i++ )
|
||||
if( pair[s2][r2] != 1 ) exit( 1 );
|
||||
|
||||
clus1 = conjuction( pair, s1, aseq, mseq1, effarr1, effarr, name, name1, indication1 );
|
||||
clus2 = conjuction( pair, s2, aseq, mseq2, effarr2, effarr, name, name2, indication2 );
|
||||
fprintf( trap_g, "\nSTEP-%d\n", l );
|
||||
fprintf( trap_g, "group1 = %s\n", indication1 );
|
||||
fprintf( trap_g, "group2 = %s\n", indication2 );
|
||||
|
||||
fprintf( stderr, "STEP %d /%d\n", l+1, njob-1 );
|
||||
fprintf( stderr, "group1 = %.66s", indication1 );
|
||||
if( strlen( indication1 ) > 66 ) fprintf( stderr, "..." );
|
||||
fprintf( stderr, "\n" );
|
||||
fprintf( stderr, "group2 = %.66s", indication2 );
|
||||
if( strlen( indication2 ) > 66 ) fprintf( stderr, "..." );
|
||||
fprintf( stderr, "\n" );
|
||||
|
||||
if( checkC )
|
||||
for( i=0; i<clus1; i++ ) fprintf( stderr, "STEP%d-eff for mseq1-%d %f\n", l+1, i, effarr1[i] );
|
||||
/*
|
||||
fprintf( stderr, "before align all\n" );
|
||||
display( aseq, njob );
|
||||
fprintf( stderr, "\n" );
|
||||
fprintf( stderr, "before align 1 %s \n", indication1 );
|
||||
display( mseq1, clus1 );
|
||||
fprintf( stderr, "\n" );
|
||||
fprintf( stderr, "before align 2 %s \n", indication2 );
|
||||
display( mseq2, clus2 );
|
||||
fprintf( stderr, "\n" );
|
||||
*/
|
||||
|
||||
pscore = Fgetlag( n_dis_consweight_multi, mseq1, mseq2, effarr1, effarr2, clus1, clus2, alloclen );
|
||||
|
||||
for( i=0; (r2=topol[l][1][i])>-1; i++ )
|
||||
{
|
||||
pair[s1][r2] = 1;
|
||||
pair[s2][r2] = 0;
|
||||
}
|
||||
|
||||
writePre( njob, name, nlen, aseq, 0 );
|
||||
|
||||
if( disp ) display( aseq, njob );
|
||||
fprintf( stderr, "\n" );
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
static void WriteOptions( FILE *fp )
|
||||
{
|
||||
fprintf( fp, "tree-base method\n" );
|
||||
if( tbrweight == 0 ) fprintf( fp, "unweighted\n" );
|
||||
else if( tbrweight == 3 ) fprintf( fp, "clustalw-like weighting\n" );
|
||||
if( tbitr || tbweight )
|
||||
{
|
||||
fprintf( fp, "iterate at each step\n" );
|
||||
if( tbitr && tbrweight == 0 ) fprintf( fp, " unweighted\n" );
|
||||
if( tbitr && tbrweight == 3 ) fprintf( fp, " reversely weighted\n" );
|
||||
if( tbweight ) fprintf( fp, " weighted\n" );
|
||||
fprintf( fp, "\n" );
|
||||
}
|
||||
if ( scoremtx == 0 ) fprintf( fp, "JTT %dPAM\n", pamN );
|
||||
else if( scoremtx == 1 ) fprintf( fp, "Dayhoff( machigai ga aru )\n" );
|
||||
else if( scoremtx == 2 ) fprintf( fp, "M-Y\n" );
|
||||
else if( scoremtx == -1 ) fprintf( fp, "DNA\n" );
|
||||
|
||||
if( scoremtx == 0 || scoremtx == -1 )
|
||||
fprintf( fp, "Gap Penalty = %+5.2f, %+5.2f, %+5.2f\n", (double)ppenalty/1000, (double)ppenalty_ex/1000, (double)poffset/1000 );
|
||||
else
|
||||
fprintf( fp, "Gap Penalty = %+5.2f\n", (double)ppenalty/1000 );
|
||||
|
||||
if( alg == 'a' )
|
||||
fprintf( fp, "Algorithm A\n" );
|
||||
else if( alg == 'A' )
|
||||
fprintf( fp, "Apgorithm A+\n" );
|
||||
else if( alg == 'S' )
|
||||
fprintf( fp, "Apgorithm S\n" );
|
||||
else if( alg == 'C' )
|
||||
fprintf( fp, "Apgorithm A+/C\n" );
|
||||
else
|
||||
fprintf( fp, "Unknown algorithm\n" );
|
||||
|
||||
if( treemethod == 'x' )
|
||||
fprintf( fp, "Tree = UPGMA (3).\n" );
|
||||
else if( treemethod == 's' )
|
||||
fprintf( fp, "Tree = UPGMA (2).\n" );
|
||||
else if( treemethod == 'p' )
|
||||
fprintf( fp, "Tree = UPGMA (1).\n" );
|
||||
else
|
||||
fprintf( fp, "Unknown tree.\n" );
|
||||
|
||||
if( use_fft )
|
||||
{
|
||||
fprintf( fp, "FFT on\n" );
|
||||
if( scoremtx == -1 )
|
||||
fprintf( fp, "Basis : 4 nucleotides\n" );
|
||||
else
|
||||
{
|
||||
if( fftscore )
|
||||
fprintf( fp, "Basis : Polarity and Volume\n" );
|
||||
else
|
||||
fprintf( fp, "Basis : 20 amino acids\n" );
|
||||
}
|
||||
fprintf( fp, "Threshold of anchors = %d%%\n", fftThreshold );
|
||||
fprintf( fp, "window size of anchors = %dsites\n", fftWinSize );
|
||||
}
|
||||
else
|
||||
fprintf( fp, "FFT off\n" );
|
||||
fflush( fp );
|
||||
}
|
||||
|
||||
|
||||
int main( int argc, char *argv[] )
|
||||
{
|
||||
static int nlen[M];
|
||||
static char **name, **seq;
|
||||
static char **mseq1, **mseq2;
|
||||
static char **aseq;
|
||||
static char **bseq;
|
||||
static double **pscore;
|
||||
static double **eff;
|
||||
static double **node0, **node1;
|
||||
int i, j;
|
||||
static int ***topol;
|
||||
static double **len;
|
||||
FILE *prep;
|
||||
char c;
|
||||
int alloclen;
|
||||
|
||||
arguments( argc, argv );
|
||||
getnumlen( stdin );
|
||||
rewind( stdin );
|
||||
|
||||
name = AllocateCharMtx( njob, B+1 );
|
||||
seq = AllocateCharMtx( njob, nlenmax*5+1 );
|
||||
aseq = AllocateCharMtx( njob, nlenmax*5+1 );
|
||||
bseq = AllocateCharMtx( njob, nlenmax*5+1 );
|
||||
mseq1 = AllocateCharMtx( njob, 0 );
|
||||
mseq2 = AllocateCharMtx( njob, 0 );
|
||||
alloclen = nlenmax*5;
|
||||
|
||||
topol = AllocateIntCub( njob, 2, njob );
|
||||
len = AllocateDoubleMtx( njob, 2 );
|
||||
pscore = AllocateDoubleMtx( njob, njob );
|
||||
eff = AllocateDoubleMtx( njob, njob );
|
||||
node0 = AllocateDoubleMtx( njob, njob );
|
||||
node1 = AllocateDoubleMtx( njob, njob );
|
||||
|
||||
#if 0
|
||||
Read( name, nlen, seq );
|
||||
#else
|
||||
readData_pointer( stdin, name, nlen, seq );
|
||||
#endif
|
||||
|
||||
constants( njob, seq );
|
||||
|
||||
#if 0
|
||||
fprintf( stderr, "params = %d, %d, %d\n", penalty, penalty_ex, offset );
|
||||
#endif
|
||||
|
||||
initSignalSM();
|
||||
|
||||
initFiles();
|
||||
|
||||
WriteOptions( trap_g );
|
||||
|
||||
c = seqcheck( seq );
|
||||
if( c )
|
||||
{
|
||||
fprintf( stderr, "Illeagal character %c\n", c );
|
||||
exit( 1 );
|
||||
}
|
||||
|
||||
writePre( njob, name, nlen, seq, 0 );
|
||||
|
||||
if( tbutree == 0 )
|
||||
{
|
||||
for( i=1; i<njob; i++ )
|
||||
{
|
||||
if( nlen[i] != nlen[0] )
|
||||
{
|
||||
fprintf( stderr, "Input pre-aligned seqences or make hat2.\n" );
|
||||
exit( 1 );
|
||||
}
|
||||
}
|
||||
for( i=0; i<njob-1; i++ ) for( j=i+1; j<njob; j++ )
|
||||
{
|
||||
/*
|
||||
pscore[i][j] = (double)score_calc1( seq[i], seq[j] );
|
||||
*/
|
||||
pscore[i][j] = (double)substitution_hosei( seq[i], seq[j] );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf( stderr, "Loading 'hat2' ... " );
|
||||
prep = fopen( "hat2", "r" );
|
||||
if( prep == NULL ) ErrorExit( "Make hat2." );
|
||||
readhat2_pointer( prep, njob, name, pscore );
|
||||
fclose( prep );
|
||||
fprintf( stderr, "done.\n" );
|
||||
|
||||
#if 0
|
||||
prep = fopen( "hat2_check", "w" );
|
||||
WriteHat2( prep, njob, name, pscore );
|
||||
fclose( prep );
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
fprintf( stderr, "Constructing dendrogram ... " );
|
||||
if( treemethod == 'x' )
|
||||
supg( njob, pscore, topol, len );
|
||||
else if( treemethod == 's' )
|
||||
spg( njob, pscore, topol, len );
|
||||
else if( treemethod == 'p' )
|
||||
upg2( njob, pscore, topol, len );
|
||||
else
|
||||
ErrorExit( "Incorrect tree\n" );
|
||||
fprintf( stderr, "done.\n" );
|
||||
|
||||
countnode( njob, topol, node0 );
|
||||
if( tbrweight )
|
||||
{
|
||||
weight = 3;
|
||||
utree = 0; counteff( njob, topol, len, eff ); utree = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
for( i=0; i<njob; i++ ) eff[i][i] = 1.0;
|
||||
}
|
||||
|
||||
|
||||
for( i=0; i<njob; i++ ) gappick0( bseq[i], seq[i] );
|
||||
|
||||
treebase( name, nlen, bseq, aseq, mseq1, mseq2, pscore, topol, len, eff, alloclen );
|
||||
|
||||
fprintf( trap_g, "done\n" );
|
||||
fclose( trap_g );
|
||||
|
||||
writePre( njob, name, nlen, aseq, !contin );
|
||||
writeData_pointer( stdout, njob, name, nlen, aseq );
|
||||
#if IODEBUG
|
||||
fprintf( stderr, "OSHIMAI\n" );
|
||||
#endif
|
||||
SHOWVERSION;
|
||||
return( 0 );
|
||||
}
|
127
mafft/src/mafft-7.487-with-extensions/core/hex2maffttext.c
Normal file
127
mafft/src/mafft-7.487-with-extensions/core/hex2maffttext.c
Normal file
|
@ -0,0 +1,127 @@
|
|||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
static void fgetstilspace( unsigned char *b, FILE *fp )
|
||||
{
|
||||
unsigned int c;
|
||||
int alreadyread = 0;
|
||||
while( 1 )
|
||||
{
|
||||
c = fgetc( fp );
|
||||
if( c == ' ' && alreadyread == 0 ) continue;
|
||||
alreadyread = 1;
|
||||
if( c == ' ' || c == '\n' || c == '\r' || c == EOF )
|
||||
{
|
||||
ungetc( c, fp );
|
||||
break;
|
||||
}
|
||||
*b++ = (unsigned char)c;
|
||||
}
|
||||
*b = 0;
|
||||
}
|
||||
|
||||
int main( int ac, char **av )
|
||||
{
|
||||
unsigned int c;
|
||||
unsigned char buf[100];
|
||||
FILE *fp;
|
||||
int res;
|
||||
|
||||
if( ac == 1 || ( ac == 2 && av[1][0] == '-' ) )
|
||||
{
|
||||
fp = stdin;
|
||||
}
|
||||
else if( ac == 2 )
|
||||
{
|
||||
fp = fopen( av[1], "rb" );
|
||||
if( fp == NULL )
|
||||
{
|
||||
fprintf( stderr, "%s: Cannot open %s.\n", av[0], av[1] );
|
||||
exit( 1 );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf( stderr, "Usage %s input > output\n", av[0] );
|
||||
exit( 1 );
|
||||
}
|
||||
{
|
||||
while( 1 )
|
||||
{
|
||||
c = fgetc( fp );
|
||||
if( c == EOF ) break;
|
||||
else if( c == '\n' ) printf( "\n" );
|
||||
else if( c == '\r' ) printf( "\r" );
|
||||
#if 0
|
||||
else if( c == '-' )
|
||||
{
|
||||
printf( "-" );
|
||||
fprintf( stderr, "Warning: '-' will be removed\n" );
|
||||
}
|
||||
else if( c == '=' )
|
||||
{
|
||||
printf( "=" );
|
||||
fprintf( stderr, "Warning: '=' will be removed\n" );
|
||||
}
|
||||
// else if( c == ' ' ) printf( " " ); // nai
|
||||
#endif
|
||||
else if( c == '>' || c == '<' )
|
||||
{
|
||||
printf( "%c", c );
|
||||
while( 1 )
|
||||
{
|
||||
c = fgetc( fp );
|
||||
printf( "%c", c );
|
||||
if( c == '\n' ) break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
buf[0] = (unsigned char)c;
|
||||
fgetstilspace( buf+1, fp );
|
||||
//fprintf( stderr, "buf=%s\n", buf );
|
||||
if( strchr( (const char *)buf, '-' ) ) // added cast, 2019/Jan/25
|
||||
{
|
||||
printf( "-" );
|
||||
continue;
|
||||
}
|
||||
//res = sscanf( buf, " %x ", &c );
|
||||
res = sscanf( (const char *)buf, " %x ", &c ); // added cast, 2019/Jan/25
|
||||
if( res == EOF )
|
||||
{
|
||||
//fprintf( stderr, "%s was ignored.\n", buf );
|
||||
}
|
||||
else if( res != 1 )
|
||||
{
|
||||
fprintf( stderr, "Error in reading %s\n", buf );
|
||||
exit( 1 );
|
||||
}
|
||||
else if( c <= 0 || c > 0xff )
|
||||
{
|
||||
fprintf( stderr, "Out of range: 0x%x\n", c );
|
||||
//exit( 1 );
|
||||
}
|
||||
else if( c == 0x0d || c == 0x0a )
|
||||
{
|
||||
fprintf( stderr, "Warning: skipped 0x%x (CR or LF) that cannot be used in mafft --text.\n", c );
|
||||
//printf( "%c", c );
|
||||
}
|
||||
else if( c == 0x20 || c == 0x3E || c == 0x3C || c == 0x3D )
|
||||
{
|
||||
fprintf( stderr, "Warning: skipped 0x%x (%c) that cannot be used in mafft --text.\n", c, c );
|
||||
//printf( "%c", c );
|
||||
}
|
||||
else if( c == 0x2D )
|
||||
{
|
||||
fprintf( stderr, "Warning: put 0x%x (%c) that is interpreted as gap in mafft --text.\n", c, c );
|
||||
printf( "%c", c );
|
||||
}
|
||||
else
|
||||
printf( "%c", c );
|
||||
}
|
||||
}
|
||||
}
|
||||
fclose( fp );
|
||||
return( 0 );
|
||||
}
|
144
mafft/src/mafft-7.487-with-extensions/core/interface.c
Normal file
144
mafft/src/mafft-7.487-with-extensions/core/interface.c
Normal file
|
@ -0,0 +1,144 @@
|
|||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include "mafft.h"
|
||||
|
||||
int report( int status, int progress, char *message )
|
||||
{
|
||||
fprintf( stderr, "status = %d\n", status );
|
||||
fprintf( stderr, "progress = %d / 100\n", progress );
|
||||
fprintf( stderr, "message = %s\n", message );
|
||||
return( 0 );
|
||||
}
|
||||
|
||||
int chudan( int status, int progress, char *message )
|
||||
{
|
||||
fprintf( stderr, "status = %d\n", status );
|
||||
fprintf( stderr, "progress = %d / 100\n", progress );
|
||||
fprintf( stderr, "message = %s\n", message );
|
||||
return( 2 );
|
||||
}
|
||||
int main( void )
|
||||
{
|
||||
int i;
|
||||
int argc;
|
||||
char **argv;
|
||||
char **seq;
|
||||
char **name;
|
||||
char *message;
|
||||
int res;
|
||||
int n, l, mlen;
|
||||
|
||||
// printf( "This is interface.\n" );
|
||||
|
||||
|
||||
l = 10000;
|
||||
n = 130;
|
||||
seq = (char **)calloc( n, sizeof( char * ) );
|
||||
name = (char **)calloc( n, sizeof( char * ) );
|
||||
for( i=0; i<n; i++ ) seq[i] = calloc( l+1, sizeof( char ) );
|
||||
for( i=0; i<n; i++ ) name[i] = calloc( 100, sizeof( char ) );
|
||||
|
||||
for( i=0; i<10; i++ )
|
||||
{
|
||||
strcpy( name[i*13+0], "name0" );
|
||||
strcpy( name[i*13+1], "name1" );
|
||||
strcpy( name[i*13+2], "name2" );
|
||||
strcpy( name[i*13+3], "name3" );
|
||||
strcpy( name[i*13+4], "name4" );
|
||||
strcpy( name[i*13+5], "name5" );
|
||||
strcpy( name[i*13+6], "name6" );
|
||||
strcpy( name[i*13+7], "name7" );
|
||||
strcpy( name[i*13+8], "name8" );
|
||||
strcpy( name[i*13+9], "name9" );
|
||||
strcpy( name[i*13+10], "name10" );
|
||||
strcpy( name[i*13+11], "name11" );
|
||||
strcpy( name[i*13+12], "name12" );
|
||||
|
||||
|
||||
strcpy( seq[i*13+0], "TAATTAAAGGGCCGTGGTATACTGACCATGCGAAGGTAGCATAATCATTAGCCTTTTGATTTGAGGCTGGAATGAATGGTTTGACGAGAGATGGTCTGTCTCTTCGATTAAATTGAAGTTAATCTTTAAGTGAAAAAGCTTAAATGTACTTGGAGGGCGATAAGACCCTATAGATCTTTACATTTAATTCTTTTGTCTTGCGGTAGGTAATTAGACAGAGTAAAACAATGTTCGGTTGGGGCGACGGTAAGAACAGAATAAACACTTACAACATAAACACATCAATAAATGACCATTGATCCTTAGATGAATAAAGACCAAGTTACCTTAGGGATAACAGCGTAATTCTTTTTTGAGAGTTCAAATCGACAAAAGAGTTTGCGAGCCTCGATG-------------------" );
|
||||
strcpy( seq[i*13+1], "GTGTTGAAGGGCCGCGGTATTTTTGACCGTGCGAAGGTAGCATAATCATTAGTCTTTTAATTGAAGGCTCGAATGAATGGTTGGACGAAAAACACACTGTTTCAGACAAAGAATTTGAATTTAACTTTTAAGTGAAAAGGCTTAAATGAATTAAAAAGACGATAAGACCCTATAAATCTTTACATTATGTTTTGTATTTTTAAAGTTGTTGTGTATTAAAAAGAAATATAAAGTAGATGTTGTGTTGGGGCAACGATAATATAATAAGATTAGCTGTTGGTAAAATTAAACAAATGTGTTTGTTAGGAGTAGTTAGATCCTTTTTAGAGATTTAAAGATTAAGTTACTTTAGGGATAACAGCGTTATTTTTTCTGAGAGTTCTTATCGAAGAAAAAGATTGCGACCTCGATG" );
|
||||
strcpy( seq[i*13+2], "ATATTGAAGGGCCGCGGTATTTCTGACCGTGCGAAGGTAGCATAATCATTAGTCTTTTAATTGGAGGCTCGTATGAAAGGTCGAACGAGTGATAGACTGTCTCAGCAAAAAAAAAATTGAACTTAACTTTAAAGTGAAAAGGCTTTAATATTTCAGAAAGACGATAAGACCCTATAAATCTTCACACCACCTTTTATACTAAGCCAATCTGTTTGTATAAGGAGAAGTATAAAAAACGTGTTTTGTTGGGGCAACAAAGATATAATTAAATAACTGTTTTAATTTTAAAACAAAAATTTTTGAAAATAAATTGATCCTCTCTAAAGATTAAAAGATCAAGTTACTTTAGGGATAACAGCGTCATTTTTCTTGAGAGTTCCCATCGAAAGAAAAGTTTGCGACCTCGATG---" );
|
||||
strcpy( seq[i*13+3], "AAATTAAAGAGCCGCAGTATTTTGACTGTGCGAAGGTAGCATAATAAATTGTCTTTTAAATAAAGGCTTGAATGAAAGGTTGGACAAAGTATCATCTGTTTCTTAAATATTTATTGAATTTGACTTTTAAGTGAAAAGGCTTAAATAAATCAAAAAGACGATAAGACCCTATAAATCTTTACAATAAATATATTTTATATTTTAGTTTATAAGTGAATGATATATAAAAATATAGGTTTGTTGCGCTGGGGCGGCGTAGATATATAAATAAACTGTCTATAGTTTAAATACAATAATCATTGCTTAATATAAATTGATCCTTAAATAGATTAAAAGATTAAGATACTTTAGGGATAACAGCGTTATTTTTTTTGAGAGTTCAAATCGACAAAAGAGTTTGCGAGCCTCGATG" );
|
||||
strcpy( seq[i*13+4], "AAATTAAAGAGCCGCAGTATTTTGACTGTGCGAAGGTAGCATAATAAATTGTCTTTTAAATAAAGGCTTGAATGAAAGGTTGGACAAAGTATCATCTGTTTCTTAAATATTTATTGAATTTGACTTTTAAGTGAAAAGGCTTAAATAAATCAAAAAGACGATAAGACCCTATAAATCTTTACAATAAATATATTTTATATTTTAGCTTATAAGTGTATAAGAAATAAAAATATAGGTTTGTTGCGCTGGGGCGGCGTAGATATATAAATAAACTGTCTATAATTTAAATACAATAATCATTGCTTAATACAAATTGATCCTTAAATAGATTAAAAGATTAAGATACTTTAGGGATAACAGCGTTATTTTTTTTGAGAGTTCAAATCGACAAAAGAGTTTGCGAGCCTCGATG" );
|
||||
strcpy( seq[i*13+5], "ATATTAAAGAGCCGCAGTATTCTGACTGTGCGAAGGTAGCATAATAAATTGTCTTTTAAATGAAGGCTTGAATGAAAGGTTGGACAAAGTATCATCTGTTTCTTAAATATTTATTGAATTTGACTTTCAAGTGAAAAGGCTTGAATAAATTAAAAAGACGATAAGACCCTATAAATCTTTACAATAAACATGTTCTATATTTTAATTTATAATTGTATAAAATATTAAATTTGTAATTGTTTCGCTGGGGCGGCGTAGATATATAAATAAACTGTCTATTTATTAAATCCAGTAATTATTGATTAATAAAATTGATCCTTGAATAGATTAAAAGATTAAGATACTTTAGGGATAACAGCGTTATTTTTTTTGAGAGTTCAAATCGACAAAAGAGTTTGCGAGCCTCGATG--" );
|
||||
strcpy( seq[i*13+6], "ATATTAAAGAGCCGCAGTATTTTGACTGTGCGAAGGTAGCATAATAAATTGTCTTTTAAATGAAGGCTTGAATGAAAGGTTGGACAAAGAATCATCTGTTTCTTAAATATTTATTGAATTTGACTTTTAAGTGAAAAGGCTTAAATAAATTAAAAAGACGATAAGACCCTATAAATCTTAACAATAAATAGACTTTATATTTTAATTTATAAGTGTGTAAGGTATAAATTTTATAATTGTTTCGCTGGGGCGGCGTAGATATATAAATAAACTGTCTATATATTATATCCAATAATTGTTGATTAATAAAATTGATCCTTAAATAGATTAAAAGATTAAGATACTTTAGGGATAACAGCGTTATTTTTTTTGAGAGTTCAAATCGACAAAAGAGTTTGCGAGCCTCGATG--" );
|
||||
strcpy( seq[i*13+7], "GTATTAAAGAGCCGCAGTATTCTGACTGTGCGAAGGTAGCATAATAAATTGTCTTTTAAATGGAGGCTTGAATGAAAGGTTGGACAAAGTATCATCTGTTTCTTAAATATTTATTGAATTTGACTTTCAAGTGAAAAGGCTTGAATAAATTAAAAAGACGATAAGACCCTATAAATCTTTACAATAAACATGTTCTATATTTTAATTTATAAGTATATAAAATATTAAATTTGTATTTGTTTCGCTGGGGCGGCGTGGATATATAAATAAACTGTCTATGTGTTAAATCCAATAATTATTGATTAGTAAAATTGATCCTTAAATAGATTAAAAGATTAAGATACTTTAGGGATAACAGCGTTATTTTTTTTGAGAGTTCAAATCGACAAAAGAGTTTGCGAGCCTCGATG--" );
|
||||
strcpy( seq[i*13+8], "GTATTAAAGAGCCGCAGTATTCTGACTGTGCGAAGGTAGCATAATAAATTGTCTTTTAAATGGAGGCTTGAATGAAAGGTTGGACAAAGTATCATCTGTTTCTTAAATATTTATTGAATTTGACTTTCAAGTGAAAAGGCTTGAATAAATTAAAAAGACGATAAGACCCTATAAATCTTTACAATAAACATGTTCTATATTTTAATTTATAAGTGTATAAAGTATTAAATTTGTATTTGTTTCGCTGGGGCGGCGTGGATATATAAATAAACTGTCTATGTGTTAAATCCAATAATTATTGATTAATAAAATTGATCCTTAAATAGATTAAAAGATTAAGATACTTTAGGGATAACAGCGTTATTTTTTTTGAGAGTTCAAATCGACAAAAGAGTTTGCGAGCCTCGATG--" );
|
||||
strcpy( seq[i*13+9], "TGATTAAAGAGCCGCAGTATTTTGACTGTGCGAAGGTAGCATAATAGATTGTCTTTTAAATGGGGGCTAGAATGAATGGTTGGACAAAGTATCGTCTGTTTCTTAAATAAATATTGAATTTGACTTTTAAGTTAAAAGGCTTAAATAAAATAAAAAGACGATAAGACCCTATAAATCTTTACATAAATTATATTTTAAATTTTAAGTTATAATTTTATAAAATATAAAAGTATAGTTTTGTTGTGCTGGGGCGGCATAGATATATAAATAAACTGTCTATAAATTTGAATCAATGATTGTTGATTAATGTGGTTGATCCTTTAAGAGATTAGAAGATTAAGTTACTTTAGGGATAACAGCGTTATTTTTTCTGAGAGTTCAAATCGACAAAAGAGTTTGCGAGCCTCGATG-" );
|
||||
strcpy( seq[i*13+10], "TGATTAAAGAGCCGCAGTATTTTGACTGTGCGAAGGTAGCATAATAGATTGTCTTTTAAATGGGGGCTAGAATGAATGGTTGGACAAAGTATCATCTGTTTCTTAAATAAATATTGAATTTGACTTTTAAGTTAAAAGGCTTAAATAAAATAAAAAGACGATAAGACCCTATAAATCTTTACATAAATTATATTTTAAATTTTAATTTATAATTTTATAAAATATAAAAGTATAGTTTTGTTGTGCTGGGGCGGCATAGATATATAAATAAACTGTCTATAAATTTAAATCAATAGTTGTTGATTAATATAGTTGATCCTTTAAAAGATTAGAAGATTAAGTTACTTTAGGGATAACAGCGTTATTTTTTCTGAGAGTTCAAATCGACAAAAGAGTTTGCGAGCCTCGATG-" );
|
||||
strcpy( seq[i*13+11], "TAATTAAAGAGCCGCAGTATTTTGACTGTGCGAAGGTAGCATAATAGATTGGCTTTTAAATGGAGGCTGGAATGAATGGTTGGACAAAGTATCATCTGTTTCTTAAATAAATATTGAATTTGACTTTTAAGTTAAAAGGCTTAAATAAAATAAAAAGACGATAAGACCCTATAAATCTTTACATAAATTATATTTTAAATTTTAACTTATAATTTTATAAAATATAAAAGTATAATTTTGTTGTGCTGGGGCGGCGTAGATATATAAATGAACTGTCTATGAAATTAAATCAATAATAGTTGATTATTAATATTGATCCTTTAATAGATTAAAAGATTAAGATACTTTAGGGATAACAGCGTTATTTTTTCTGAGAGTTCAAATCGACAAAAGAGTTTGCGAGCCTCGATG-" );
|
||||
strcpy( seq[i*13+12], "TAATTAAAGAGCCGCAGTATTTTGACTGTGCGAAGGTAGCATAATAGATTGGCTTTTAAATGGAGGCTGGAATGAATGGTTGGACAAAGTATCATCTGTTTCTTAAATAAATATTGAATTTGACTTTTAAGTTAAAAGGCTTAAATAAAATAAAAAGACGATAAGACCCTATAAATCTTTACATAAATTATATTTTAAATTTTAATTTATAATTTTATAAAATATAAAAGTATAATTTTGTTGTGCTGGGGCGGCGTAGATATATAAATGAACTGTCTATGAAATTAAATCAATAATAGTTGATTATTAATATTGATCCTTTAATAGATTAAAAGATTAAGATACTTTAGGGATAACAGCGTTATTTTTTCTGAGAGTTCAAATCGACAAAAGAGTTTGCGAGCCTCGATG-" );
|
||||
|
||||
}
|
||||
|
||||
argc = 20;
|
||||
argv = (char **)calloc( argc, sizeof( char * ) );
|
||||
for( i=0; i<argc; i++ ) argv[i] = calloc( 100, sizeof( char ) );
|
||||
strcpy( argv[0], "disttbfast" );
|
||||
strcpy( argv[1], "-W" );
|
||||
strcpy( argv[2], "6" );
|
||||
strcpy( argv[3], "-b" );
|
||||
strcpy( argv[4], "62" );
|
||||
strcpy( argv[5], "-Q" );
|
||||
strcpy( argv[6], "100" );
|
||||
strcpy( argv[7], "-h" );
|
||||
strcpy( argv[8], "0" );
|
||||
strcpy( argv[9], "-F" );
|
||||
strcpy( argv[10], "-X" );
|
||||
strcpy( argv[11], "-s" );
|
||||
strcpy( argv[12], "0.0" );
|
||||
strcpy( argv[13], "-f" );
|
||||
strcpy( argv[14], "-1.53" );
|
||||
strcpy( argv[15], "-C" );
|
||||
strcpy( argv[16], "0" );
|
||||
strcpy( argv[17], "-D" ); // Necessary. DNA -> -D; Protein -> -P
|
||||
strcpy( argv[18], "-I" ); // --add
|
||||
strcpy( argv[19], "2" ); // --add
|
||||
|
||||
#if 0
|
||||
mlen = 5000;
|
||||
message = (char *)calloc( mlen+1, sizeof( char ) );
|
||||
|
||||
fprintf( stderr, "first run\n" );
|
||||
res = disttbfast( n, l, mlen, name, seq, &message, argc, argv, report );
|
||||
fprintf( stderr, "second run\n" );
|
||||
res = disttbfast( n, l, mlen, name, seq, &message, argc, argv, report );
|
||||
fprintf( stderr, "third run\n" );
|
||||
res = disttbfast( n, l, mlen, name, seq, &message, argc, argv, report );
|
||||
|
||||
fprintf( stderr, "\n\n\nmessage in interface = :%s:\n", message );
|
||||
free( message );
|
||||
#else
|
||||
fprintf( stderr, "first run\n" );
|
||||
res = disttbfast( n, l, name, seq, argc, argv, report );
|
||||
fprintf( stderr, "second run\n" );
|
||||
res = disttbfast( n, l, name, seq, argc, argv, chudan );
|
||||
// fprintf( stderr, "third run\n" );
|
||||
// res = disttbfast( n, l, name, seq, argc, argv, report );
|
||||
#endif
|
||||
|
||||
if( res == GUI_LENGTHOVER )
|
||||
{
|
||||
fprintf( stderr, "length over!" );
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf( stderr, "res = %d\n", res );
|
||||
fprintf( stdout, "Output:\n" );
|
||||
for( i=0; i<n; i++ )
|
||||
fprintf( stdout, "%s\n", seq[i] );
|
||||
}
|
||||
fprintf( stderr, "argv = \n" );
|
||||
for( i=0; i<argc; i++ )
|
||||
fprintf( stderr, "%s ", argv[i] );
|
||||
fprintf( stderr, "\n" );
|
||||
|
||||
for( i=0; i<n; i++ ) free( seq[i] );
|
||||
free( seq );
|
||||
for( i=0; i<n; i++ ) free( name[i] );
|
||||
free( name );
|
||||
for( i=0; i<argc; i++ ) free( argv[i] );
|
||||
free( argv );
|
||||
|
||||
}
|
6372
mafft/src/mafft-7.487-with-extensions/core/io.c
Normal file
6372
mafft/src/mafft-7.487-with-extensions/core/io.c
Normal file
File diff suppressed because it is too large
Load diff
412
mafft/src/mafft-7.487-with-extensions/core/iteration.c
Normal file
412
mafft/src/mafft-7.487-with-extensions/core/iteration.c
Normal file
|
@ -0,0 +1,412 @@
|
|||
/* iteration ( algorithm C ) */
|
||||
#include "mltaln.h"
|
||||
|
||||
#define DEBUG 0
|
||||
|
||||
static void Writeoptions( FILE *fp )
|
||||
{
|
||||
if( scoremtx == 1 )
|
||||
fprintf( fp, "Dayhoff( ... )\n" );
|
||||
else if( scoremtx == -1 )
|
||||
fprintf( fp, "DNA\n" );
|
||||
else if( scoremtx == 2 )
|
||||
fprintf( fp, "Miyata-Yasunaga\n" );
|
||||
else
|
||||
fprintf( fp, "JTT %dPAM\n", pamN );
|
||||
|
||||
if( scoremtx == 0 )
|
||||
fprintf( fp, "Gap Penalty = %+d, %+d\n", penalty, offset );
|
||||
else
|
||||
fprintf( fp, "Gap Penalty = %+d\n", penalty );
|
||||
|
||||
fprintf( fp, "marginal score to search : best - %f\n", cut );
|
||||
if( scmtd == 3 )
|
||||
fprintf( fp, "score of rnd or sco\n" );
|
||||
else if( scmtd == 4 )
|
||||
fprintf( fp, "score = sigma( score for a pair of homologous amino acids ) / ( number of amino acids pairs )\n" );
|
||||
else if( scmtd == 5 )
|
||||
fprintf( fp, "score : SP\n" );
|
||||
if( mix )
|
||||
fprintf( fp, "?\n" );
|
||||
else
|
||||
{
|
||||
if( weight == 2 )
|
||||
fprintf( fp, "weighted, geta2 = %f\n", geta2 );
|
||||
else if( weight == 3 )
|
||||
{
|
||||
if( scmtd == 4 )
|
||||
fprintf( fp, "reversely weighted in function 'align', unweighted in function 'score_calc'\n" );
|
||||
else
|
||||
fprintf( fp, "weighted like ClustalW," );
|
||||
}
|
||||
else
|
||||
fprintf( fp, "unweighted\n" );
|
||||
}
|
||||
if( weight && utree )
|
||||
{
|
||||
fprintf( fp, "using tree defined by the file hat2 with simplified UPG method\n" );
|
||||
}
|
||||
if( weight && !utree )
|
||||
fprintf( fp, "using temporary tree by simplified UPG method\n" );
|
||||
fprintf( fp, "Algorithm %c\n", alg );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
char **align0( double *wm, char **aseq, char *seq, double effarr[M], int icyc, int ex )
|
||||
{
|
||||
char **result;
|
||||
|
||||
if( alg == 'B' )
|
||||
{
|
||||
ErrorExit( "Sorry!" );
|
||||
/*
|
||||
if( outgap == 0 )
|
||||
{
|
||||
result = alignm1_o( wm, aseq, seq, scmx, effarr, icyc, ex );
|
||||
}
|
||||
if( outgap == 1 )
|
||||
{
|
||||
result = alignm1( wm, aseq, seq, scmx, effarr, icyc, ex );
|
||||
}
|
||||
*/
|
||||
}
|
||||
else if( alg == 'C' )
|
||||
{
|
||||
result = Calignm1( wm, aseq, seq, effarr, icyc, ex );
|
||||
}
|
||||
return( result );
|
||||
}
|
||||
|
||||
|
||||
double score_m_1_0( char **aseq, int locnjob, int s, double **eff, double effarr[M] )
|
||||
{
|
||||
double x;
|
||||
|
||||
if( alg == 'B' )
|
||||
{
|
||||
ErrorExit( "Sorry!" );
|
||||
}
|
||||
if( alg == 'C' )
|
||||
{
|
||||
x = Cscore_m_1( aseq, locnjob, s, eff );
|
||||
}
|
||||
fprintf( stderr, "in score_m_1_0 %f\n", x );
|
||||
return( x );
|
||||
}
|
||||
|
||||
int iteration( int locnjob, char name[M][B], int nlen[M], char **aseq, char **bseq, int ***topol, double **len, double **eff )
|
||||
{
|
||||
double tscore, mscore;
|
||||
int identity;
|
||||
static char *mseq1, **mseq2 = NULL;
|
||||
static char **result;
|
||||
int i, l;
|
||||
static double effarr[M];
|
||||
int s;
|
||||
int sss[2];
|
||||
char ou;
|
||||
int alloclen;
|
||||
int resultlen;
|
||||
int nlenmax0 = nlenmax;
|
||||
FILE *prep;
|
||||
char sai[M];
|
||||
char sai1[M];
|
||||
char sai2[M];
|
||||
#if 0
|
||||
double his[2][M][MAXITERATION/locnjob+1];
|
||||
#else
|
||||
double ***his;
|
||||
#endif
|
||||
int cyc[2];
|
||||
char shindou = 0;
|
||||
double wm;
|
||||
int returnvalue;
|
||||
|
||||
for( i=0; i<locnjob; i++ )
|
||||
{
|
||||
sai[i] = 1;
|
||||
sai1[i] = 1;
|
||||
sai2[i] = 2;
|
||||
}
|
||||
sai[locnjob] = sai1[locnjob] = sai2[locnjob] = 0;
|
||||
|
||||
|
||||
Writeoptions( trap_g );
|
||||
|
||||
his = AllocateDoubleCub( 2, M, MAXITERATION/locnjob+1 );
|
||||
|
||||
if( mseq2 == NULL )
|
||||
{
|
||||
alloclen = nlenmax * 2.0;
|
||||
AllocateTmpSeqs( &mseq2, &mseq1, alloclen );
|
||||
}
|
||||
|
||||
if( !tbitr && !tbweight )
|
||||
{
|
||||
writePre( locnjob, name, nlen, aseq, 0 );
|
||||
|
||||
#if 0
|
||||
prep = fopen( "best", "w" );
|
||||
Write( prep, locnjob, name, nlen, aseq );
|
||||
fclose( prep );
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
treeconstruction( aseq, locnjob, topol, len, eff );
|
||||
tscore = score_calc0( aseq, locnjob, eff, 0 );
|
||||
|
||||
#if DEBUG
|
||||
fprintf( stderr, "eff mtx in iteration\n" );
|
||||
for( i=0; i<locnjob; i++ )
|
||||
{
|
||||
for( j=0; j<locnjob; j++ )
|
||||
{
|
||||
fprintf( stderr, "%5.3f ", eff[i][j] );
|
||||
}
|
||||
fprintf( stderr, "\n" );
|
||||
}
|
||||
#endif
|
||||
|
||||
fprintf( stderr, "\n" );
|
||||
if( disp )
|
||||
{
|
||||
fprintf( stderr, "aseq(initial)\n" );
|
||||
display( aseq, locnjob );
|
||||
}
|
||||
fprintf( stderr, "initial score = %f \n", tscore );
|
||||
fprintf( stderr, "\n" );
|
||||
for( i=0; i<locnjob; i++ ) strcpy( bseq[i], aseq[i] );
|
||||
mscore = tscore;
|
||||
srand( time(NULL) );
|
||||
|
||||
sss[1] = 0;
|
||||
sss[0] = locnjob-1;
|
||||
/*
|
||||
sss[0] = (int)( (double)locnjob/2.0 );
|
||||
*/
|
||||
ou = 1;
|
||||
cyc[0] = 0; cyc[1] = 0;
|
||||
|
||||
for( s=-1, l=0; l<MAXITERATION; l++ )
|
||||
{
|
||||
int ss;
|
||||
double tmpscore, tmpscore1;
|
||||
|
||||
if( strlen( aseq[0] ) > nlenmax )
|
||||
nlenmax = strlen( aseq[0] );
|
||||
|
||||
/*
|
||||
s = ( int )( rnd() * locnjob );
|
||||
s++;
|
||||
if( s == locnjob ) s = 0;
|
||||
ou = 0;
|
||||
*/
|
||||
if( ou == 0 )
|
||||
{
|
||||
ou = 1;
|
||||
s = sss[0];
|
||||
/*
|
||||
sss[0]++;
|
||||
if( sss[0] == locnjob )
|
||||
{
|
||||
sss[0] = 0;
|
||||
cyc[0]++;
|
||||
}
|
||||
*/
|
||||
sss[0]--;
|
||||
if( sss[0] == -1 )
|
||||
{
|
||||
sss[0] = locnjob-1;
|
||||
cyc[0]++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ou = 0;
|
||||
s = sss[1];
|
||||
sss[1]++;
|
||||
if( sss[1] == locnjob )
|
||||
{
|
||||
sss[1] = 0;
|
||||
cyc[1]++;
|
||||
}
|
||||
}
|
||||
fprintf( trap_g, "%d ", weight );
|
||||
|
||||
/*
|
||||
for( i=0, count=0; i<strlen( aseq[s] ); i++ )
|
||||
{
|
||||
if( aseq[s][i] != '-' )
|
||||
{
|
||||
mseq1[count] = aseq[s][i];
|
||||
count++;
|
||||
}
|
||||
}
|
||||
mseq1[count] = 0;
|
||||
*/
|
||||
gappick0( mseq1, aseq[s] );
|
||||
|
||||
if( checkC )
|
||||
tmpscore = score_m_1_0( aseq, locnjob, s, eff, effarr );
|
||||
|
||||
gappick( locnjob, s, aseq, mseq2, eff, effarr );
|
||||
|
||||
result = align0( &wm, mseq2, mseq1, effarr, locnjob-2, s );
|
||||
resultlen = strlen( result[0] );
|
||||
if( resultlen > alloclen )
|
||||
{
|
||||
if( resultlen > nlenmax0*3 || resultlen > N )
|
||||
{
|
||||
fprintf(stderr, "Error in main1\n");
|
||||
exit( 1 );
|
||||
}
|
||||
FreeTmpSeqs( mseq2, mseq1 );
|
||||
alloclen = strlen( result[0] ) * 2.0;
|
||||
fprintf( stderr, "\n\ntrying to allocate TmpSeqs\n\n" );
|
||||
AllocateTmpSeqs( &mseq2, &mseq1, alloclen );
|
||||
}
|
||||
for( i=0; i<locnjob; i++ ) strcpy( mseq2[i], result[i] );
|
||||
|
||||
if( checkC )
|
||||
fprintf( stderr, "wm in iteration == %f\n", wm );
|
||||
|
||||
strcpy( mseq1, mseq2[locnjob-1] );
|
||||
/*
|
||||
Write( stdout, locnjob, name, nlen, mseq2 );
|
||||
*/
|
||||
for( i=locnjob-2; i>=s; i-- ) strcpy( mseq2[i+1], mseq2[i] );
|
||||
strcpy( mseq2[s], mseq1 );
|
||||
if( checkC )
|
||||
{
|
||||
tmpscore1= score_m_1_0( mseq2, locnjob, s, eff, effarr );
|
||||
fprintf( stderr, "pick up %d, before ALIGNM1 score_m_1_0 = %f\n", s+1, tmpscore );
|
||||
fprintf( stderr, "pick up %d, after ALIGNM1 score_m_1_0 = %f\n", s+1, tmpscore1 );
|
||||
if( tmpscore1 < tmpscore )
|
||||
{
|
||||
fprintf( stderr, "\7" );
|
||||
fprintf( trap_g, ">>>>>>>n\n" );
|
||||
}
|
||||
if( fabs( wm - tmpscore1 ) / wm > 0.001 )
|
||||
{
|
||||
fprintf( stderr, "\7sorry\n" );
|
||||
exit( 1 );
|
||||
}
|
||||
}
|
||||
|
||||
identity = !strcmp( mseq2[s], aseq[s] );
|
||||
if( s == locnjob - 1 ) ss = 0; else ss=s+1;
|
||||
|
||||
identity *= !strcmp( mseq2[ss], aseq[ss] );
|
||||
|
||||
if( !identity )
|
||||
{
|
||||
tmpscore = score_calc0( mseq2, locnjob, eff, s );
|
||||
}
|
||||
else tmpscore = tscore;
|
||||
|
||||
if( disp )
|
||||
{
|
||||
fprintf( stderr, "% 3d % 3d / the rest \n", l+1, s+1 );
|
||||
display( mseq2, locnjob );
|
||||
}
|
||||
fprintf( stderr, "% 3d % 3d / the rest \n", l+1, s+1 );
|
||||
fprintf( stderr, "score = %f mscore = %f ", tmpscore, mscore );
|
||||
|
||||
fprintf( trap_g, "%#4d %#4d / the rest ", l+1, s+1 );
|
||||
fprintf( trap_g, "score = %f mscore = %f ", tmpscore, mscore );
|
||||
|
||||
if( identity )
|
||||
{
|
||||
fprintf( stderr, "( identical )\n" );
|
||||
fprintf( trap_g, "( identical )\n" );
|
||||
sai[s] = 2;
|
||||
}
|
||||
|
||||
else if( tmpscore > mscore - cut )
|
||||
{
|
||||
fprintf( stderr, "accepted\n" );
|
||||
fprintf( trap_g, "accepted\n" );
|
||||
for( i=0; i<locnjob; i++ ) strcpy( aseq[i], mseq2[i] );
|
||||
strcpy( sai, sai1 ); /* kokoka ? */
|
||||
if( !tbitr && !tbweight )
|
||||
{
|
||||
writePre( locnjob, name, nlen, aseq, 0 );
|
||||
}
|
||||
strcpy( sai, sai1 );
|
||||
tscore = tmpscore;
|
||||
/*
|
||||
tscore = tmpscore = score_calc0( aseq, locnjob, eff, s ); * ? *
|
||||
*/
|
||||
if( tmpscore > mscore )
|
||||
{
|
||||
for( i=0; i<locnjob; i++ ) strcpy( bseq[i], mseq2[i] );
|
||||
treeconstruction( bseq, locnjob, topol, len, eff );
|
||||
tscore = mscore = score_calc0( bseq, locnjob, eff, s );
|
||||
fprintf( trap_g, " -> %f\n", mscore );
|
||||
strcpy( sai, sai1 ); /* kokoka ? */
|
||||
#if 0
|
||||
if( !tbitr && !tbweight )
|
||||
{ prep = fopen( "best", "w" );
|
||||
Write( prep, locnjob, name, nlen, bseq );
|
||||
fclose( prep );
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
if( tmpscore == tscore )
|
||||
{
|
||||
fprintf( stderr, "occational coincidence \n" );
|
||||
fprintf( trap_g, "occational coincidence\n" );
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf( stderr, "rejected\n" );
|
||||
fprintf( trap_g, "rejected\n" );
|
||||
}
|
||||
for( i=0; i<locnjob; i++ ) strcpy( aseq[i], bseq[i] );
|
||||
tscore = mscore;
|
||||
sai[s] = 2;
|
||||
}
|
||||
|
||||
/*
|
||||
prep = fopen( "cur", "w" );
|
||||
Write( prep, locnjob, name, nlen, mseq2 );
|
||||
fclose( prep );
|
||||
*/
|
||||
|
||||
his[ou][s][cyc[ou]] = tmpscore;
|
||||
if( !strcmp( sai, sai2 ) )
|
||||
{
|
||||
returnvalue = 0;
|
||||
fprintf( trap_g, "converged\n" );
|
||||
break;
|
||||
}
|
||||
for( i=cyc[ou]-1; i>0; i-- )
|
||||
{
|
||||
if( tmpscore == his[ou][s][i] )
|
||||
{
|
||||
shindou = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
fprintf( stderr, "\n" );
|
||||
if( shindou == 1 )
|
||||
{
|
||||
returnvalue = -1;
|
||||
fprintf( trap_g, "oscillating\n" );
|
||||
break;
|
||||
}
|
||||
}
|
||||
if( l == MAXITERATION ) returnvalue = -2;
|
||||
FreeDoubleCub( his );
|
||||
return( returnvalue );
|
||||
}
|
||||
|
421
mafft/src/mafft-7.487-with-extensions/core/mafft-distance.c
Normal file
421
mafft/src/mafft-7.487-with-extensions/core/mafft-distance.c
Normal file
|
@ -0,0 +1,421 @@
|
|||
#include "mltaln.h"
|
||||
#include "mtxutl.h"
|
||||
|
||||
#define DEBUG 0
|
||||
#define TEST 0
|
||||
|
||||
#define END_OF_VEC -1
|
||||
|
||||
static char outputformat;
|
||||
#define PLENFACA 0.01
|
||||
#define PLENFACB 10000
|
||||
#define PLENFACC 10000
|
||||
#define PLENFACD 0.1
|
||||
#define DLENFACA 0.01
|
||||
#define DLENFACB 2500
|
||||
#define DLENFACC 2500
|
||||
#define DLENFACD 0.1
|
||||
|
||||
void arguments( int argc, char *argv[] )
|
||||
{
|
||||
int c;
|
||||
|
||||
inputfile = NULL;
|
||||
outputformat = 's';
|
||||
scoremtx = 1;
|
||||
nblosum = 62;
|
||||
dorp = NOTSPECIFIED;
|
||||
nadd = 0;
|
||||
alg = 'X';
|
||||
|
||||
while( --argc > 0 && (*++argv)[0] == '-' )
|
||||
{
|
||||
while ( (c = *++argv[0]) )
|
||||
{
|
||||
switch( c )
|
||||
{
|
||||
case 'i':
|
||||
inputfile = *++argv;
|
||||
fprintf( stderr, "inputfile = %s\n", inputfile );
|
||||
--argc;
|
||||
goto nextoption;
|
||||
case 'I':
|
||||
nadd = myatoi(*++argv);
|
||||
if( nadd == 0 )
|
||||
{
|
||||
fprintf( stderr, "nadd = %d?\n", nadd );
|
||||
exit( 1 );
|
||||
}
|
||||
--argc;
|
||||
goto nextoption;
|
||||
case 'p':
|
||||
outputformat = 'p';
|
||||
break;
|
||||
case 'D':
|
||||
dorp = 'd';
|
||||
break;
|
||||
case 'P':
|
||||
dorp = 'p';
|
||||
break;
|
||||
default:
|
||||
fprintf( stderr, "illegal option %c\n", c );
|
||||
argc = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
nextoption:
|
||||
;
|
||||
}
|
||||
if( inputfile == NULL )
|
||||
{
|
||||
argc--;
|
||||
inputfile = *argv;
|
||||
fprintf( stderr, "inputfile = %s\n", inputfile );
|
||||
}
|
||||
if( argc != 0 )
|
||||
{
|
||||
fprintf( stderr, "Usage: mafft-distance [-PD] [-i inputfile] inputfile > outputfile\n" );
|
||||
exit( 1 );
|
||||
}
|
||||
}
|
||||
|
||||
void seq_grp_nuc( int *grp, char *seq )
|
||||
{
|
||||
int tmp;
|
||||
int *grpbk = grp;
|
||||
while( *seq )
|
||||
{
|
||||
tmp = amino_grp[(int)*seq++];
|
||||
if( tmp < 4 )
|
||||
*grp++ = tmp;
|
||||
else
|
||||
fprintf( stderr, "WARNING : Unknown character %c\r", *(seq-1) );
|
||||
}
|
||||
*grp = END_OF_VEC;
|
||||
if( grp - grpbk < 6 )
|
||||
{
|
||||
fprintf( stderr, "\n\nWARNING: Too short.\nPlease also consider use mafft-ginsi, mafft-linsi or mafft-ginsi.\n\n\n" );
|
||||
// exit( 1 );
|
||||
*grpbk = -1;
|
||||
}
|
||||
}
|
||||
|
||||
void seq_grp( int *grp, char *seq )
|
||||
{
|
||||
int tmp;
|
||||
int *grpbk = grp;
|
||||
while( *seq )
|
||||
{
|
||||
tmp = amino_grp[(int)*seq++];
|
||||
if( tmp < 6 )
|
||||
*grp++ = tmp;
|
||||
else
|
||||
fprintf( stderr, "WARNING : Unknown character %c\r", *(seq-1) );
|
||||
}
|
||||
*grp = END_OF_VEC;
|
||||
if( grp - grpbk < 6 )
|
||||
{
|
||||
fprintf( stderr, "\n\nWARNING: Too short.\nPlease also consider use mafft-ginsi, mafft-linsi or mafft-ginsi.\n\n\n" );
|
||||
// exit( 1 );
|
||||
*grpbk = -1;
|
||||
}
|
||||
}
|
||||
|
||||
void makecompositiontable_p( short *table, int *pointt )
|
||||
{
|
||||
int point;
|
||||
|
||||
while( ( point = *pointt++ ) != END_OF_VEC )
|
||||
table[point]++;
|
||||
}
|
||||
|
||||
static int localcommonsextet_p( short *table, int *pointt )
|
||||
{
|
||||
int value = 0;
|
||||
short tmp;
|
||||
int point;
|
||||
static short *memo = NULL;
|
||||
static int *ct = NULL;
|
||||
static int *cp;
|
||||
|
||||
if( *pointt == -1 )
|
||||
return( 0 );
|
||||
|
||||
if( !memo )
|
||||
{
|
||||
memo = (short *)calloc( tsize, sizeof( short ) );
|
||||
if( !memo ) ErrorExit( "Cannot allocate memo\n" );
|
||||
ct = (int *)calloc( MIN( maxl, tsize)+1, sizeof( int ) );
|
||||
if( !ct ) ErrorExit( "Cannot allocate memo\n" );
|
||||
}
|
||||
|
||||
cp = ct;
|
||||
while( ( point = *pointt++ ) != END_OF_VEC )
|
||||
{
|
||||
tmp = memo[point]++;
|
||||
if( tmp < table[point] )
|
||||
value++;
|
||||
if( tmp == 0 ) *cp++ = point;
|
||||
// fprintf( stderr, "cp - ct = %d (tsize = %d)\n", cp - ct, tsize );
|
||||
}
|
||||
*cp = END_OF_VEC;
|
||||
|
||||
cp = ct;
|
||||
while( *cp != END_OF_VEC )
|
||||
memo[*cp++] = 0;
|
||||
|
||||
return( value );
|
||||
}
|
||||
|
||||
void makepointtable_nuc( int *pointt, int *n )
|
||||
{
|
||||
int point;
|
||||
register int *p;
|
||||
|
||||
if( *n == -1 )
|
||||
{
|
||||
*pointt = -1;
|
||||
return;
|
||||
}
|
||||
|
||||
p = n;
|
||||
point = *n++ * 1024;
|
||||
point += *n++ * 256;
|
||||
point += *n++ * 64;
|
||||
point += *n++ * 16;
|
||||
point += *n++ * 4;
|
||||
point += *n++;
|
||||
*pointt++ = point;
|
||||
|
||||
while( *n != END_OF_VEC )
|
||||
{
|
||||
point -= *p++ * 1024;
|
||||
point *= 4;
|
||||
point += *n++;
|
||||
*pointt++ = point;
|
||||
}
|
||||
*pointt = END_OF_VEC;
|
||||
}
|
||||
|
||||
void makepointtable( int *pointt, int *n )
|
||||
{
|
||||
int point;
|
||||
register int *p;
|
||||
|
||||
if( *n == -1 )
|
||||
{
|
||||
*pointt = -1;
|
||||
return;
|
||||
}
|
||||
|
||||
p = n;
|
||||
point = *n++ * 7776;
|
||||
point += *n++ * 1296;
|
||||
point += *n++ * 216;
|
||||
point += *n++ * 36;
|
||||
point += *n++ * 6;
|
||||
point += *n++;
|
||||
*pointt++ = point;
|
||||
|
||||
while( *n != END_OF_VEC )
|
||||
{
|
||||
point -= *p++ * 7776;
|
||||
point *= 6;
|
||||
point += *n++;
|
||||
*pointt++ = point;
|
||||
}
|
||||
*pointt = END_OF_VEC;
|
||||
}
|
||||
|
||||
int main( int argc, char **argv )
|
||||
{
|
||||
int i, j, initj;
|
||||
FILE *infp;
|
||||
char **seq;
|
||||
int *grpseq;
|
||||
char *tmpseq;
|
||||
int **pointt;
|
||||
static char **name;
|
||||
static int *nlen;
|
||||
double *mtxself;
|
||||
double score;
|
||||
static short *table1;
|
||||
double longer, shorter;
|
||||
double lenfac;
|
||||
double bunbo;
|
||||
int norg;
|
||||
|
||||
arguments( argc, argv );
|
||||
|
||||
|
||||
if( inputfile )
|
||||
{
|
||||
infp = fopen( inputfile, "r" );
|
||||
if( !infp )
|
||||
{
|
||||
fprintf( stderr, "Cannot open %s\n", inputfile );
|
||||
exit( 1 );
|
||||
}
|
||||
}
|
||||
else
|
||||
infp = stdin;
|
||||
|
||||
#if 0
|
||||
PreRead( stdin, &njob, &nlenmax );
|
||||
#else
|
||||
getnumlen( infp );
|
||||
#endif
|
||||
rewind( infp );
|
||||
if( njob < 2 )
|
||||
{
|
||||
fprintf( stderr, "At least 2 sequences should be input!\n"
|
||||
"Only %d sequence found.\n", njob );
|
||||
exit( 1 );
|
||||
}
|
||||
|
||||
tmpseq = AllocateCharVec( nlenmax+1 );
|
||||
seq = AllocateCharMtx( njob, nlenmax+1 );
|
||||
grpseq = AllocateIntVec( nlenmax+1 );
|
||||
pointt = AllocateIntMtx( njob, nlenmax+1 );
|
||||
mtxself = AllocateDoubleVec( njob );
|
||||
pamN = NOTSPECIFIED;
|
||||
name = AllocateCharMtx( njob, B );
|
||||
nlen = AllocateIntVec( njob );
|
||||
|
||||
#if 0
|
||||
FRead( infp, name, nlen, seq );
|
||||
#else
|
||||
readData_pointer( infp, name, nlen, seq );
|
||||
#endif
|
||||
|
||||
fclose( infp );
|
||||
|
||||
constants( njob, seq );
|
||||
|
||||
|
||||
if( nadd ) outputformat = 's';
|
||||
norg = njob - nadd;
|
||||
|
||||
if( dorp == 'd' ) tsize = (int)pow( 4, 6 );
|
||||
else tsize = (int)pow( 6, 6 );
|
||||
|
||||
if( dorp == 'd' )
|
||||
{
|
||||
lenfaca = DLENFACA;
|
||||
lenfacb = DLENFACB;
|
||||
lenfacc = DLENFACC;
|
||||
lenfacd = DLENFACD;
|
||||
}
|
||||
else
|
||||
{
|
||||
lenfaca = PLENFACA;
|
||||
lenfacb = PLENFACB;
|
||||
lenfacc = PLENFACC;
|
||||
lenfacd = PLENFACD;
|
||||
}
|
||||
|
||||
maxl = 0;
|
||||
for( i=0; i<njob; i++ )
|
||||
{
|
||||
gappick0( tmpseq, seq[i] );
|
||||
nlen[i] = strlen( tmpseq );
|
||||
// if( nlen[i] < 6 )
|
||||
// {
|
||||
// fprintf( stderr, "Seq %d, too short, %d characters\n", i+1, nlen[i] );
|
||||
// exit( 1 );
|
||||
// }
|
||||
if( nlen[i] > maxl ) maxl = nlen[i];
|
||||
if( dorp == 'd' ) /* nuc */
|
||||
{
|
||||
seq_grp_nuc( grpseq, tmpseq );
|
||||
makepointtable_nuc( pointt[i], grpseq );
|
||||
}
|
||||
else /* amino */
|
||||
{
|
||||
seq_grp( grpseq, tmpseq );
|
||||
makepointtable( pointt[i], grpseq );
|
||||
}
|
||||
}
|
||||
fprintf( stderr, "\nCalculating i-i scores ... " );
|
||||
for( i=0; i<njob; i++ )
|
||||
{
|
||||
table1 = (short *)calloc( tsize, sizeof( short ) );
|
||||
if( !table1 ) ErrorExit( "Cannot allocate table1\n" );
|
||||
makecompositiontable_p( table1, pointt[i] );
|
||||
|
||||
score = localcommonsextet_p( table1, pointt[i] );
|
||||
mtxself[i] = score;
|
||||
free( table1 );
|
||||
}
|
||||
|
||||
fprintf( stderr, "done.\n" );
|
||||
fprintf( stderr, "\nCalculating i-j scores ... \n" );
|
||||
if( outputformat == 'p' ) fprintf( stdout, "%-5d", njob );
|
||||
for( i=0; i<norg; i++ )
|
||||
{
|
||||
if( outputformat == 'p' ) fprintf( stdout, "\n%-9d ", i+1 );
|
||||
table1 = (short *)calloc( tsize, sizeof( short ) );
|
||||
if( !table1 ) ErrorExit( "Cannot allocate table1\n" );
|
||||
if( i % 10 == 0 )
|
||||
{
|
||||
fprintf( stderr, "%4d / %4d\r", i+1, njob );
|
||||
}
|
||||
makecompositiontable_p( table1, pointt[i] );
|
||||
|
||||
|
||||
if( nadd == 0 )
|
||||
{
|
||||
if( outputformat == 'p' ) initj = 0;
|
||||
else initj = i+1;
|
||||
}
|
||||
else
|
||||
{
|
||||
initj = norg;
|
||||
}
|
||||
for( j=initj; j<njob; j++ )
|
||||
{
|
||||
if( nlen[i] > nlen[j] )
|
||||
{
|
||||
longer=(double)nlen[i];
|
||||
shorter=(double)nlen[j];
|
||||
}
|
||||
else
|
||||
{
|
||||
longer=(double)nlen[j];
|
||||
shorter=(double)nlen[i];
|
||||
}
|
||||
// lenfac = 3.0 / ( LENFACA + LENFACB / ( longer + LENFACC ) + shorter / longer * LENFACD );
|
||||
lenfac = 1.0 / ( shorter / longer * lenfacd + lenfacb / ( longer + lenfacc ) + lenfaca );
|
||||
// lenfac = 1.0;
|
||||
// fprintf( stderr, "lenfac = %f (%.0f,%.0f)\n", lenfac, longer, shorter );
|
||||
score = localcommonsextet_p( table1, pointt[j] );
|
||||
bunbo = MIN( mtxself[i], mtxself[j] );
|
||||
if( outputformat == 'p' )
|
||||
{
|
||||
if( bunbo == 0.0 )
|
||||
fprintf( stdout, " %8.6f", 1.0 );
|
||||
else
|
||||
fprintf( stdout, " %8.6f", ( 1.0 - score / bunbo ) * lenfac );
|
||||
if( j % 7 == 6 ) fprintf( stdout, "\n" );
|
||||
}
|
||||
else
|
||||
{
|
||||
if( bunbo == 0.0 )
|
||||
fprintf( stdout, "%d-%d d=%4.2f l=%d,%d\n", i+1, j+1, 1.0, nlen[i], nlen[j] );
|
||||
else
|
||||
fprintf( stdout, "%d-%d d=%4.2f l=%d,%d\n", i+1, j+1, ( 1.0 - score / bunbo ) * lenfac, nlen[i], nlen[j] );
|
||||
}
|
||||
// fprintf( stderr, "##### mtx = %f, mtx[i][0]=%f, mtx[j][0]=%f, bunbo=%f\n", mtx[i][j-i], mtx[i][0], mtx[j][0], bunbo );
|
||||
// score = (double)localcommonsextet_p( table1, pointt[j] );
|
||||
// fprintf( stdout, "%d-%d d=%4.2f l=%d,%d\n", i+1, j+1, ( 1.0 - score / MIN( mtxself[i], mtxself[j] ) ) * 3, nlen[i], nlen[j] );
|
||||
|
||||
|
||||
}
|
||||
free( table1 );
|
||||
}
|
||||
|
||||
fprintf( stderr, "\n" );
|
||||
if( outputformat == 'p' ) fprintf( stdout, "\n" );
|
||||
SHOWVERSION;
|
||||
exit( 0 );
|
||||
}
|
131
mafft/src/mafft-7.487-with-extensions/core/mafft-homologs.1
Normal file
131
mafft/src/mafft-7.487-with-extensions/core/mafft-homologs.1
Normal file
|
@ -0,0 +1,131 @@
|
|||
.\" Title: MAFFT-HOMOLOGS
|
||||
.\" Author: Kazutaka Katoh <katoh_at_bioreg.kyushu-u.ac.jp.>
|
||||
.\" Generator: DocBook XSL Stylesheets v1.72.0 <http://docbook.sf.net/>
|
||||
.\" Date: 2007-08-14
|
||||
.\" Manual: Mafft Manual
|
||||
.\" Source: mafft-homologs 2.1
|
||||
.\"
|
||||
.TH "MAFFT\-HOMOLOGS" "1" "2007\-06\-09" "mafft\-homologs 2.1" "Mafft Manual"
|
||||
.\" disable hyphenation
|
||||
.nh
|
||||
.\" disable justification (adjust text to left margin only)
|
||||
.ad l
|
||||
.SH "NAME"
|
||||
.RS 0
|
||||
mafft\-homologs \- aligns sequences together with homologues automatically collected from SwissProt via NCBI BLAST
|
||||
.RE
|
||||
.SH "SYNOPSIS"
|
||||
.RS 0
|
||||
\fBmafft\-homologs\fR [\fBoptions\fR] \fIinput\fR [>\ \fIoutput\fR]
|
||||
.RE
|
||||
.SH "DESCRIPTION"
|
||||
.RS 0
|
||||
The accuracy of an alignment of a few distantly related sequences is considerably improved when being aligned together with their close homologs. The reason for the improvement is probably the same as that for PSI\-BLAST. That is, the positions of highly conserved residues, those with many gaps and other additional information is brought by close homologs. According to Katoh et al. (2005), the improvement by adding close homologs is 10% or so, which is comparable to the improvement by incorporating structural information of a pair of sequences. Mafft\-homologs in a mafft server works like this:
|
||||
.sp
|
||||
.RS 4
|
||||
\h'-04' 1.\h'+02'Collect a number (50 by default) of close homologs (E=1e\-10 by default) of the input sequences.
|
||||
.RE
|
||||
.sp
|
||||
.RS 4
|
||||
\h'-04' 2.\h'+02'Align the input sequences and homologs all together using the L\-INS\-i strategy.
|
||||
.RE
|
||||
.sp
|
||||
.RS 4
|
||||
\h'-04' 3.\h'+02'Remove the homologs.
|
||||
.RE
|
||||
.RE
|
||||
.SH "OPTIONS"
|
||||
.RS 0
|
||||
.PP
|
||||
\fB\-a\fR \fI\fIn\fR\fR
|
||||
.RS 4
|
||||
The number of collected sequences (default: 50).
|
||||
.RE
|
||||
.PP
|
||||
\fB\-e\fR \fI\fIn\fR\fR
|
||||
.RS 4
|
||||
Threshold value (default: 1e\-10).
|
||||
.RE
|
||||
.PP
|
||||
\fB\-o\fR \fI\fIxxx\fR\fR
|
||||
.RS 4
|
||||
Options for mafft (default: " \-\-op 1.53 \-\-ep 0.123 \-\-maxiterate 1000 --localpair --reorder").
|
||||
.RE
|
||||
.PP
|
||||
\fB\-l\fR
|
||||
.RS 4
|
||||
Locally carries out BLAST searches instead of NCBI BLAST (requires locally installed BLAST and a database).
|
||||
.RE
|
||||
.PP
|
||||
\fB\-f\fR
|
||||
.RS 4
|
||||
Outputs collected homologues also (default: off).
|
||||
.RE
|
||||
.PP
|
||||
\fB\-w\fR
|
||||
.RS 4
|
||||
entire sequences are subjected to BLAST search (default: well\-aligned region only)
|
||||
.RE
|
||||
.RE
|
||||
.SH "REQUIREMENTS"
|
||||
.RS 0
|
||||
.PP
|
||||
MAFFT version > 5.58.
|
||||
.PP
|
||||
Either of
|
||||
.RS 4
|
||||
.PP
|
||||
lynx (when remote BLAST server is used)
|
||||
.PP
|
||||
BLAST and a protein sequence database (when local BLAST is used)
|
||||
.RE
|
||||
.RE
|
||||
.SH "REFERENCES"
|
||||
.RS 0
|
||||
.PP
|
||||
Katoh, Kuma, Toh and Miyata (Nucleic Acids Res. 33:511\-518, 2005) MAFFT version 5: improvement in accuracy of multiple sequence alignment.
|
||||
.RE
|
||||
.SH "SEE ALSO"
|
||||
.RS 0
|
||||
.PP
|
||||
\fBmafft\fR(1)
|
||||
.RE
|
||||
.SH "AUTHORS"
|
||||
.RS 0
|
||||
.PP
|
||||
\fBKazutaka Katoh\fR <\&katoh_at_bioreg.kyushu\-u.ac.jp.\&>
|
||||
.sp -1n
|
||||
.IP "" 4
|
||||
Wrote Mafft.
|
||||
.PP
|
||||
\fBCharles Plessy\fR <\&charles\-debian\-nospam@plessy.org\&>
|
||||
.sp -1n
|
||||
.IP "" 4
|
||||
Wrote this manpage in DocBook XML for the Debian distribution, using Mafft's homepage as a template.
|
||||
.RE
|
||||
.SH "COPYRIGHT"
|
||||
.RS 0
|
||||
Copyright \(co 2002\-2007 Kazutaka Katoh (mafft)
|
||||
.br
|
||||
Copyright \(co 2007 Charles Plessy (this manpage)
|
||||
.br
|
||||
.PP
|
||||
Mafft and its manpage are offered under the following conditions:
|
||||
.PP
|
||||
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
||||
.sp
|
||||
.RS 4
|
||||
\h'-04' 1.\h'+02'Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
||||
.RE
|
||||
.sp
|
||||
.RS 4
|
||||
\h'-04' 2.\h'+02'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.
|
||||
.RE
|
||||
.sp
|
||||
.RS 4
|
||||
\h'-04' 3.\h'+02'The name of the author may not be used to endorse or promote products derived from this software without specific prior written permission.
|
||||
.RE
|
||||
.PP
|
||||
THIS SOFTWARE IS PROVIDED BY THE AUTHOR "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 AUTHOR 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.
|
||||
.br
|
||||
.RE
|
505
mafft/src/mafft-7.487-with-extensions/core/mafft-homologs.tmpl
Normal file
505
mafft/src/mafft-7.487-with-extensions/core/mafft-homologs.tmpl
Normal file
|
@ -0,0 +1,505 @@
|
|||
#!/usr/bin/env ruby
|
||||
|
||||
localdb = "sp"
|
||||
# database name from which homologues are collected
|
||||
# by locally installed blast. Leave this if you do
|
||||
# not use the '-l' option.
|
||||
|
||||
mafftpath = "_BINDIR/mafft"
|
||||
# path of mafft. "/usr/local/bin/mafft"
|
||||
# if mafft is in your command path, "mafft" is ok.
|
||||
|
||||
blastpath = "psiblast"
|
||||
# path of blastall.
|
||||
# if blastall is in your command path, "blastall" is ok.
|
||||
|
||||
# mafft-homologs.rb v. 2.1 aligns sequences together with homologues
|
||||
# automatically collected from SwissProt via NCBI BLAST.
|
||||
#
|
||||
# mafft > 5.58 is required
|
||||
#
|
||||
# Usage:
|
||||
# mafft-homologs.rb [options] input > output
|
||||
# Options:
|
||||
# -a # the number of collected sequences (default: 50)
|
||||
# -e # threshold value (default: 1e-10)
|
||||
# -o "xxx" options for mafft
|
||||
# (default: " --op 1.53 --ep 0.123 --maxiterate 1000")
|
||||
# -l locally carries out blast searches instead of NCBI blast
|
||||
# (requires locally installed blast and a database)
|
||||
# -f outputs collected homologues also (default: off)
|
||||
# -w entire sequences are subjected to BLAST search
|
||||
# (default: well-aligned region only)
|
||||
|
||||
#require 'getopts'
|
||||
require 'optparse'
|
||||
require 'tempfile'
|
||||
|
||||
if ENV["MAFFT_BLAST"] && ENV["MAFFT_BLAST"] != "" then
|
||||
blastpath = ENV["MAFFT_BLAST"]
|
||||
end
|
||||
|
||||
if ENV["MAFFT_HOMOLOGS_MAFFT"] && ENV["MAFFT_HOMOLOGS_MAFFT"] != "" then
|
||||
mafftpath = ENV["MAFFT_HOMOLOGS_MAFFT"]
|
||||
end
|
||||
|
||||
# mktemp
|
||||
GC.disable
|
||||
temp_vf = Tempfile.new("_vf").path
|
||||
temp_if = Tempfile.new("_if").path
|
||||
temp_pf = Tempfile.new("_pf").path
|
||||
temp_af = Tempfile.new("_af").path
|
||||
temp_qf = Tempfile.new("_qf").path
|
||||
temp_bf = Tempfile.new("_bf").path
|
||||
temp_rid = Tempfile.new("_rid").path
|
||||
temp_res = Tempfile.new("_res").path
|
||||
|
||||
|
||||
system( mafftpath + " --help > #{temp_vf} 2>&1" )
|
||||
pfp = File.open( "#{temp_vf}", 'r' )
|
||||
while pfp.gets
|
||||
break if $_ =~ /MAFFT v/
|
||||
end
|
||||
pfp.close
|
||||
|
||||
if( $_ ) then
|
||||
mafftversion = $_.sub( /^\D*/, "" ).split(" ").slice(0).strip.to_s
|
||||
else
|
||||
mafftversion = "0"
|
||||
end
|
||||
if( mafftversion < "5.58" ) then
|
||||
STDERR.puts ""
|
||||
STDERR.puts "======================================================"
|
||||
STDERR.puts "Install new mafft (v. >= 5.58)"
|
||||
STDERR.puts "======================================================"
|
||||
STDERR.puts ""
|
||||
exit
|
||||
end
|
||||
|
||||
srand ( 0 )
|
||||
|
||||
def readfasta( fp, name, seq )
|
||||
nseq = 0
|
||||
tmpseq = ""
|
||||
while fp.gets
|
||||
if $_ =~ /^>/ then
|
||||
name.push( $_.sub(/>/,"").strip )
|
||||
seq.push( tmpseq ) if nseq > 0
|
||||
nseq += 1
|
||||
tmpseq = ""
|
||||
else
|
||||
tmpseq += $_.strip
|
||||
end
|
||||
end
|
||||
seq.push( tmpseq )
|
||||
return nseq
|
||||
end
|
||||
|
||||
nadd = 600
|
||||
num_alignments = 600
|
||||
num_threads_blast = 4
|
||||
eval = 1e-1
|
||||
local = 0
|
||||
fullout = 0
|
||||
entiresearch = 1
|
||||
corewin = 50
|
||||
corethr = 0.3
|
||||
#mafftopt = " --op 1.53 --ep 0.123 --localpair --maxiterate 1000 --reorder "
|
||||
mafftopt = " --op 1.53 --ep 0.0 --globalpair --maxiterate 1000 --reorder "
|
||||
|
||||
|
||||
#if getopts( "s", "f", "w", "l", "h", "e:", "a:", "o:", "c:", "d:" ) == nil || ARGV.length == 0 || $OPT_h then
|
||||
# puts "Usage: #{$0} [-h -l -e# -a# -o\"[options for mafft]\"] input_file"
|
||||
# exit
|
||||
#end
|
||||
params = ARGV.getopts( "sfwlhe:a:o:c:d:n:N:" )
|
||||
|
||||
|
||||
#if $OPT_c then
|
||||
if params["c"] != nil then
|
||||
corewin = params["c"].to_i
|
||||
end
|
||||
|
||||
#if $OPT_d then
|
||||
#if params["d"] != nil then
|
||||
# corethr = params["d"].to_f
|
||||
#end
|
||||
#
|
||||
if params["d"] != nil then
|
||||
localdb = params["d"].to_s
|
||||
end
|
||||
|
||||
if params["n"] != nil then
|
||||
num_alignments = params["n"].to_s
|
||||
end
|
||||
|
||||
if params["N"] != nil then
|
||||
num_threads_blast = params["N"].to_s
|
||||
end
|
||||
|
||||
#if $OPT_w
|
||||
if params["w"] == true then
|
||||
entiresearch = 1
|
||||
end
|
||||
|
||||
#if $OPT_f
|
||||
if params["f"] == true then
|
||||
fullout = 1
|
||||
end
|
||||
|
||||
#if $OPT_s
|
||||
if params["s"] == true then
|
||||
fullout = 0
|
||||
end
|
||||
|
||||
#if $OPT_l
|
||||
if params["l"] == true then
|
||||
local = 1
|
||||
end
|
||||
|
||||
#if $OPT_e then
|
||||
if params["e"] != nil then
|
||||
# eval = $OPT_e.to_f
|
||||
eval = params["e"].to_f
|
||||
end
|
||||
|
||||
#if $OPT_a then
|
||||
if params["a"] != nil then
|
||||
nadd = params["a"].to_i
|
||||
end
|
||||
|
||||
#if $OPT_o then
|
||||
if params["o"] != nil then
|
||||
mafftopt += " " + params["o"] + " "
|
||||
end
|
||||
|
||||
infn = ARGV[0].to_s.strip
|
||||
|
||||
system "cat " + infn + " > #{temp_if}"
|
||||
ar = mafftopt.split(" ")
|
||||
nar = ar.length
|
||||
for i in 0..(nar-1)
|
||||
if ar[i] == "--seed" then
|
||||
system "cat #{ar[i+1]} >> #{temp_if}"
|
||||
end
|
||||
end
|
||||
|
||||
if fullout == 0 then
|
||||
mafftopt += " --excludehomologs "
|
||||
end
|
||||
|
||||
nseq = 0
|
||||
ifp = File.open( "#{temp_if}", 'r' )
|
||||
while ifp.gets
|
||||
nseq += 1 if $_ =~ /^>/
|
||||
end
|
||||
ifp.close
|
||||
|
||||
if nseq >= 10000 then
|
||||
STDERR.puts "The number of input sequences must be <10000."
|
||||
exit
|
||||
elsif nseq == 1 then
|
||||
system( "cp #{temp_if}" + " #{temp_pf}" )
|
||||
else
|
||||
STDERR.puts "Performing preliminary alignment .. "
|
||||
if entiresearch == 1 then
|
||||
# system( mafftpath + " --maxiterate 1000 --localpair #{temp_if} > #{temp_pf}" )
|
||||
system( mafftpath + " --maxiterate 0 --retree 2 #{temp_if} > #{temp_pf}" )
|
||||
else
|
||||
system( mafftpath + " --maxiterate 1000 --localpair --core --coreext --corethr #{corethr.to_s} --corewin #{corewin.to_s} #{temp_if} > #{temp_pf}" )
|
||||
end
|
||||
end
|
||||
|
||||
pfp = File.open( "#{temp_pf}", 'r' )
|
||||
inname = []
|
||||
inseq = []
|
||||
slen = []
|
||||
act = []
|
||||
nin = 0
|
||||
nin = readfasta( pfp, inname, inseq )
|
||||
for i in 0..(nin-1)
|
||||
slen.push( inseq[i].gsub(/-/,"").length )
|
||||
act.push( 1 )
|
||||
end
|
||||
pfp.close
|
||||
|
||||
pfp = File.open( "#{temp_if}", 'r' )
|
||||
orname = []
|
||||
orseq = []
|
||||
nin = 0
|
||||
nin = readfasta( pfp, orname, orseq )
|
||||
pfp.close
|
||||
|
||||
allen = inseq[0].length
|
||||
for i in 0..(nin-2)
|
||||
for j in (i+1)..(nin-1)
|
||||
next if act[i] == 0
|
||||
next if act[j] == 0
|
||||
pid = 0.0
|
||||
total = 0
|
||||
for a in 0..(allen-1)
|
||||
next if inseq[i][a,1] == "-" || inseq[j][a,1] == "-"
|
||||
total += 1
|
||||
pid += 1.0 if inseq[i][a,1] == inseq[j][a,1]
|
||||
end
|
||||
pid /= total
|
||||
# puts "#{i.to_s}, #{j.to_s}, #{pid.to_s}"
|
||||
if pid > 0.5 then
|
||||
if slen[i] < slen[j]
|
||||
act[i] = 0
|
||||
else
|
||||
act[j] = 0
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
#p act
|
||||
|
||||
|
||||
afp = File.open( "#{temp_af}", 'w' )
|
||||
|
||||
STDERR.puts "Searching .. \n"
|
||||
ids = []
|
||||
add = []
|
||||
sco = []
|
||||
nblast = 0 # ato de tsukau kamo
|
||||
for i in 0..(nin-1)
|
||||
singleids = []
|
||||
singleadd = []
|
||||
|
||||
inseq[i].gsub!(/-/,"")
|
||||
afp.puts ">" + orname[i]
|
||||
afp.puts orseq[i]
|
||||
|
||||
# afp.puts ">" + inname[i]
|
||||
# afp.puts inseq[i]
|
||||
|
||||
STDERR.puts "Query (#{i+1}/#{nin})\n" + inname[i]
|
||||
if act[i] == 0 then
|
||||
STDERR.puts "Skip.\n\n"
|
||||
next
|
||||
end
|
||||
|
||||
if local == 0 then
|
||||
command = "lynx -source 'https://www.ncbi.nlm.nih.gov/blast/Blast.cgi?QUERY=" + inseq[i] + "&DATABASE=swissprot&HITLIST_SIZE=" + nadd.to_s + "&FILTER=L&EXPECT='" + eval.to_s + "'&FORMAT_TYPE=TEXT&PROGRAM=blastp&SERVICE=plain&NCBI_GI=on&PAGE=Proteins&CMD=Put' > #{temp_rid}"
|
||||
system command
|
||||
|
||||
ridp = File.open( "#{temp_rid}", 'r' )
|
||||
while ridp.gets
|
||||
break if $_ =~ / RID = (.*)/
|
||||
end
|
||||
ridp.close
|
||||
rid = $1.strip
|
||||
STDERR.puts "Submitted to NCBI. rid = " + rid
|
||||
|
||||
STDERR.printf "Waiting "
|
||||
while 1
|
||||
STDERR.printf "."
|
||||
sleep 10
|
||||
command = "lynx -source 'https://www.ncbi.nlm.nih.gov/blast/Blast.cgi?RID=" + rid + "&DESCRIPTIONS=500&ALIGNMENTS=" + nadd.to_s + "&ALIGNMENT_TYPE=Pairwise&OVERVIEW=no&CMD=Get&FORMAT_TYPE=XML' > #{temp_res}"
|
||||
system command
|
||||
resp = File.open( "#{temp_res}", 'r' )
|
||||
# resp.gets
|
||||
# if $_ =~ /WAITING/ then
|
||||
# resp.close
|
||||
# next
|
||||
# end
|
||||
while( resp.gets )
|
||||
break if $_ =~ /QBlastInfoBegin/
|
||||
end
|
||||
resp.gets
|
||||
if $_ =~ /WAITING/ then
|
||||
resp.close
|
||||
next
|
||||
else
|
||||
resp.close
|
||||
break
|
||||
end
|
||||
end
|
||||
else
|
||||
# puts "Not supported"
|
||||
# exit
|
||||
qfp = File.open( "#{temp_qf}", 'w' )
|
||||
qfp.puts "> "
|
||||
qfp.puts inseq[i]
|
||||
qfp.close
|
||||
command = blastpath + " -num_iterations 2 -num_threads #{num_threads_blast} -evalue #{eval} -num_alignments #{num_alignments} -outfmt 5 -query #{temp_qf} -db #{localdb} > #{temp_res}"
|
||||
system command
|
||||
# system "cp #{temp_res} _res"
|
||||
end
|
||||
STDERR.puts " Done.\n\n"
|
||||
|
||||
resp = File.open( "#{temp_res}", 'r' )
|
||||
hitnum = 0
|
||||
lasteval = "nohit"
|
||||
|
||||
while resp.gets
|
||||
break if $_ =~ /<Iteration_iter-num>2<\/Iteration_iter-num>/
|
||||
end
|
||||
|
||||
if $_ == nil then
|
||||
STDERR.puts "no hit"
|
||||
else
|
||||
while 1
|
||||
while resp.gets
|
||||
break if $_ =~ /<Hit_id>(.*)<\/Hit_id>/ || $_ =~ /(<Iteration_stat>)/
|
||||
end
|
||||
id = $1
|
||||
break if $_ =~ /<Iteration_stat>/
|
||||
# p id
|
||||
|
||||
starthit = 9999999
|
||||
endhit = -1
|
||||
startquery = 9999999
|
||||
endquery = -1
|
||||
target = ""
|
||||
score = 0.0
|
||||
|
||||
while line = resp.gets
|
||||
if line =~ /<Hsp_hit-from>(.*)<\/Hsp_hit-from>/
|
||||
starthitcand=$1.to_i
|
||||
elsif line =~ /<Hsp_hit-to>(.*)<\/Hsp_hit-to>/
|
||||
endhitcand=$1.to_i
|
||||
elsif line =~ /<Hsp_query-from>(.*)<\/Hsp_query-from>/
|
||||
startquerycand=$1.to_i
|
||||
elsif line =~ /<Hsp_query-to>(.*)<\/Hsp_query-to>/
|
||||
endquerycand=$1.to_i
|
||||
elsif $_ =~ /<Hsp_hseq>(.*)<\/Hsp_hseq>/
|
||||
targetcand = $1.sub( /-/, "" ).sub( /U/, "X" )
|
||||
elsif line =~ /<Hsp_bit-score>(.*)<\/Hsp_bit-score>/
|
||||
scorecand=$1.to_f
|
||||
elsif line =~ /<Hsp_evalue>(.*)<\/Hsp_evalue>/
|
||||
evalcand=$1.to_s
|
||||
elsif line =~ /<\/Hsp>/
|
||||
if endhit == -1 then
|
||||
starthit = starthitcand
|
||||
endhit= endhitcand
|
||||
startquery = startquerycand
|
||||
endquery= endquerycand
|
||||
target = targetcand
|
||||
score = scorecand
|
||||
lasteval = evalcand
|
||||
else
|
||||
# if endhit <= endhitcand && endquery <= endquerycand then
|
||||
if endhit <= starthitcand && endquery <= startquerycand then
|
||||
endhit = endhitcand
|
||||
endquery = endquerycand
|
||||
target = target + "XX" + targetcand
|
||||
score = score + scorecand
|
||||
end
|
||||
# if starthitcand <= starthit && startquerycand <= startquery then
|
||||
if endhitcand <= starthit && endquerycand <= startquery then
|
||||
starthit = starthitcand
|
||||
startquery = startquerycand
|
||||
target = targetcand + "XX" + target
|
||||
score = score + scorecand
|
||||
end
|
||||
end
|
||||
elsif line =~ /<\/Hit>/
|
||||
hitnum = hitnum + 1
|
||||
break;
|
||||
end
|
||||
end
|
||||
|
||||
singleids.push( id )
|
||||
singleadd.push( target )
|
||||
|
||||
known = ids.index( id )
|
||||
if known != nil then
|
||||
if sco[known] >= score then
|
||||
next
|
||||
else
|
||||
ids.delete_at( known )
|
||||
add.delete_at( known )
|
||||
sco.delete_at( known )
|
||||
end
|
||||
end
|
||||
ids.push( id )
|
||||
sco.push( score )
|
||||
add.push( target )
|
||||
|
||||
end
|
||||
resp.close
|
||||
end
|
||||
|
||||
n = singleids.length
|
||||
outnum = 0
|
||||
|
||||
totalprob = 0
|
||||
prob = []
|
||||
for m in 0..(n-1)
|
||||
# prob[m] = 1.0 / population[eclass[m]]
|
||||
prob[m] = 1.0
|
||||
totalprob += prob[m]
|
||||
end
|
||||
# puts ""
|
||||
for m in 0..(n-1)
|
||||
prob[m] /= (totalprob)
|
||||
prob[m] *= (nadd.to_f / nin.to_f)
|
||||
prob[m] = 1 if prob[m] > 1
|
||||
end
|
||||
|
||||
|
||||
for m in 0..(n-1)
|
||||
if rand( 1000000 ).to_f/1000000 < prob[m] then
|
||||
# STDERR.puts "hit in " + m.to_s
|
||||
afp.puts ">_addedbymaffte_" + singleids[m]
|
||||
afp.puts singleadd[m]
|
||||
end
|
||||
end
|
||||
end
|
||||
afp.close
|
||||
|
||||
STDERR.puts "Aligning .. "
|
||||
system( mafftpath + mafftopt + "#{temp_af} > #{temp_bf}" )
|
||||
STDERR.puts "done."
|
||||
|
||||
bfp = File.open( "#{temp_bf}", 'r' )
|
||||
outseq = []
|
||||
outnam = []
|
||||
readfasta( bfp, outnam, outseq )
|
||||
bfp.close
|
||||
|
||||
outseq2 = []
|
||||
outnam2 = []
|
||||
|
||||
len = outseq.length
|
||||
for i in 0..(len-1)
|
||||
# p outnam[i]
|
||||
if fullout == 0 && outnam[i] =~ /_addedbymaffte_/ then
|
||||
next
|
||||
end
|
||||
outseq2.push( outseq[i] )
|
||||
outnam2.push( outnam[i].sub( /_addedbymaffte_/, "_ho_" ) )
|
||||
end
|
||||
|
||||
nout = outseq2.length
|
||||
len = outseq[0].length
|
||||
p = len
|
||||
while p>0
|
||||
p -= 1
|
||||
allgap = 1
|
||||
for j in 0..(nout-1)
|
||||
if outseq2[j][p,1] != "-" then
|
||||
allgap = 0
|
||||
break
|
||||
end
|
||||
end
|
||||
if allgap == 1 then
|
||||
for j in 0..(nout-1)
|
||||
outseq2[j][p,1] = ""
|
||||
end
|
||||
end
|
||||
end
|
||||
for i in 0..(nout-1)
|
||||
puts ">" + outnam2[i]
|
||||
puts outseq2[i].gsub( /.{1,60}/, "\\0\n" )
|
||||
end
|
||||
|
||||
|
||||
system( "rm -rf #{temp_if} #{temp_vf} #{temp_af} #{temp_bf} #{temp_pf} #{temp_qf} #{temp_res} #{temp_rid}" )
|
||||
#system( "cp #{temp_if} #{temp_vf} #{temp_af} #{temp_bf} #{temp_pf} #{temp_qf} #{temp_res} #{temp_rid} ." )
|
||||
if File.exist?( "#{temp_af}.tree" ) then
|
||||
system( "sed 's/_addedbymaffte_/_ho_/' #{temp_af}.tree > #{ARGV[0].to_s}.tree" )
|
||||
system( "rm #{temp_af}.tree" )
|
||||
end
|
510
mafft/src/mafft-7.487-with-extensions/core/mafft-profile.c
Normal file
510
mafft/src/mafft-7.487-with-extensions/core/mafft-profile.c
Normal file
|
@ -0,0 +1,510 @@
|
|||
#include "mltaln.h"
|
||||
|
||||
#define DEBUG 0
|
||||
|
||||
#if DEBUG
|
||||
#include <time.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/resource.h>
|
||||
double getrusage_sec()
|
||||
{
|
||||
struct rusage t;
|
||||
struct timeval tv;
|
||||
getrusage(RUSAGE_SELF, &t);
|
||||
tv = t.ru_utime;
|
||||
return tv.tv_sec + (double)tv.tv_usec*1e-6;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
int intcmp( int *str1, int *str2 )
|
||||
{
|
||||
while( *str1 != -1 && *str2 != -1 )
|
||||
if( *str1++ != *str2++ ) return( 1 );
|
||||
if( *str1 != *str2 ) return( 1 );
|
||||
return( 0 );
|
||||
}
|
||||
|
||||
char **arguments( int argc, char *argv[] )
|
||||
{
|
||||
int c = 0;
|
||||
|
||||
fmodel = 0;
|
||||
nblosum = 62;
|
||||
calledByXced = 0;
|
||||
devide = 0;
|
||||
fftscore = 1;
|
||||
use_fft = 1;
|
||||
nevermemsave = 0;
|
||||
alg = 'A';
|
||||
weight = 0;
|
||||
utree = 1;
|
||||
tbutree = 0;
|
||||
refine = 0;
|
||||
check = 1;
|
||||
cut = 0.0;
|
||||
disp = 0;
|
||||
outgap = 0;
|
||||
mix = 0;
|
||||
tbitr = 0;
|
||||
scmtd = 5;
|
||||
tbweight = 0;
|
||||
tbrweight = 3;
|
||||
checkC = 0;
|
||||
scoremtx = 1;
|
||||
dorp = NOTSPECIFIED;
|
||||
ppenalty = NOTSPECIFIED;
|
||||
ppenalty_ex = NOTSPECIFIED;
|
||||
poffset = 0; // chokusetsu yobareru kara
|
||||
kimuraR = NOTSPECIFIED;
|
||||
pamN = NOTSPECIFIED;
|
||||
fftWinSize = NOTSPECIFIED;
|
||||
fftThreshold = NOTSPECIFIED;
|
||||
TMorJTT = JTT;
|
||||
treemethod = 'x';
|
||||
|
||||
|
||||
while( --argc > 0 && (*++argv)[0] == '-' )
|
||||
{
|
||||
while ( ( c = *++argv[0] ) )
|
||||
{
|
||||
switch( c )
|
||||
{
|
||||
case 'P':
|
||||
dorp = 'p';
|
||||
break;
|
||||
case 'D':
|
||||
dorp = 'd';
|
||||
break;
|
||||
case 'F':
|
||||
use_fft = 1;
|
||||
break;
|
||||
case 'N':
|
||||
use_fft = 0;
|
||||
break;
|
||||
case 'n':
|
||||
nevermemsave = 1;
|
||||
break;
|
||||
case 'e':
|
||||
fftscore = 0;
|
||||
break;
|
||||
case 'Q':
|
||||
alg = 'Q';
|
||||
break;
|
||||
case 'A':
|
||||
alg = 'A';
|
||||
break;
|
||||
case 'M':
|
||||
alg = 'M';
|
||||
break;
|
||||
case 'd':
|
||||
disp = 1;
|
||||
break;
|
||||
case 'O':
|
||||
outgap = 0;
|
||||
break;
|
||||
case 'a':
|
||||
fmodel = 1;
|
||||
break;
|
||||
case 'u':
|
||||
tbrweight = 0;
|
||||
break;
|
||||
case 'U':
|
||||
tbrweight = -1;
|
||||
break;
|
||||
case 'z':
|
||||
fftThreshold = myatoi( *++argv );
|
||||
--argc;
|
||||
goto nextoption;
|
||||
case 'w':
|
||||
fftWinSize = myatoi( *++argv );
|
||||
--argc;
|
||||
goto nextoption;
|
||||
case 'Z':
|
||||
checkC = 1;
|
||||
break;
|
||||
case 'f':
|
||||
ppenalty = (int)( atof( *++argv ) * 1000 - 0.5 );
|
||||
fprintf( stderr, "ppenalty = %d\n", ppenalty );
|
||||
--argc;
|
||||
goto nextoption;
|
||||
case 'g':
|
||||
ppenalty_ex = (int)( atof( *++argv ) * 1000 - 0.5 );
|
||||
fprintf( stderr, "ppenalty_ex = %d\n", ppenalty_ex );
|
||||
--argc;
|
||||
goto nextoption;
|
||||
case 'h':
|
||||
poffset = (int)( atof( *++argv ) * 1000 - 0.5 );
|
||||
fprintf( stderr, "poffset = %d\n", poffset );
|
||||
--argc;
|
||||
goto nextoption;
|
||||
case 'k':
|
||||
kimuraR = myatoi( *++argv );
|
||||
fprintf( stderr, "kappa = %d\n", kimuraR );
|
||||
--argc;
|
||||
goto nextoption;
|
||||
case 'b':
|
||||
nblosum = myatoi( *++argv );
|
||||
scoremtx = 1;
|
||||
fprintf( stderr, "blosum %d\n", nblosum );
|
||||
--argc;
|
||||
goto nextoption;
|
||||
case 'j':
|
||||
pamN = myatoi( *++argv );
|
||||
scoremtx = 0;
|
||||
TMorJTT = JTT;
|
||||
fprintf( stderr, "jtt %d\n", pamN );
|
||||
--argc;
|
||||
goto nextoption;
|
||||
case 'm':
|
||||
pamN = myatoi( *++argv );
|
||||
scoremtx = 0;
|
||||
TMorJTT = TM;
|
||||
fprintf( stderr, "tm %d\n", pamN );
|
||||
--argc;
|
||||
goto nextoption;
|
||||
default:
|
||||
fprintf( stderr, "illegal option %c\n", c );
|
||||
argc = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
nextoption:
|
||||
;
|
||||
}
|
||||
if( argc != 2 )
|
||||
{
|
||||
fprintf( stderr, "options: Check source file ! %c ?\n", c );
|
||||
exit( 1 );
|
||||
}
|
||||
fprintf( stderr, "tbitr = %d, tbrweight = %d, tbweight = %d\n", tbitr, tbrweight, tbweight );
|
||||
// readOtherOptions( &ppid, &fftThreshold, &fftWinSize );
|
||||
return( argv );
|
||||
|
||||
}
|
||||
|
||||
void GroupAlign( int nseq1, int nseq2, char **name, int *nlen, char **seq, char **aseq, char **mseq1, char **mseq2, int ***topol, double **len, double *eff, int alloclen )
|
||||
{
|
||||
int i;
|
||||
int clus1, clus2;
|
||||
int s1, s2;
|
||||
double pscore;
|
||||
static char **name1, **name2;
|
||||
double *effarr = eff;
|
||||
double *effarr1 = NULL;
|
||||
double *effarr2 = NULL;
|
||||
static char *indication1, *indication2;
|
||||
// double dumfl = 0.0;
|
||||
double dumdb = 0.0;
|
||||
int intdum;
|
||||
#if DEBUG
|
||||
double time1, time2;
|
||||
#endif
|
||||
|
||||
|
||||
// fprintf( stderr, "in GroupAlign fftWinSize = %d\n", fftWinSize );
|
||||
// fprintf( stderr, "in GroupAlign fftThreshold = %d\n", fftThreshold );
|
||||
|
||||
if( effarr1 == NULL )
|
||||
{
|
||||
name1 = AllocateCharMtx( nseq1, B );
|
||||
name2 = AllocateCharMtx( nseq2, B );
|
||||
indication1 = AllocateCharVec( 150 );
|
||||
indication2 = AllocateCharVec( 150 );
|
||||
effarr1 = AllocateDoubleVec( njob );
|
||||
effarr2 = AllocateDoubleVec( njob );
|
||||
#if 0
|
||||
#else
|
||||
#endif
|
||||
}
|
||||
|
||||
for( i=0; i<njob; i++ ) strcpy( aseq[i], seq[i] );
|
||||
|
||||
|
||||
|
||||
s1 = 0;
|
||||
s2 = nseq1;
|
||||
// fprintf( stdout, "nseq1 = %d\n", nseq1 );
|
||||
|
||||
|
||||
|
||||
clus1 = conjuctionforgaln( 0, nseq1, aseq, mseq1, effarr1, effarr, name, name1, indication1 );
|
||||
clus2 = conjuctionforgaln( nseq1, njob, aseq, mseq2, effarr2, effarr, name, name2, indication2 );
|
||||
/*
|
||||
fprintf( stderr, "before align all\n" );
|
||||
display( aseq, njob );
|
||||
fprintf( stderr, "\n" );
|
||||
fprintf( stderr, "before align 1 %s \n", indication1 );
|
||||
display( mseq1, clus1 );
|
||||
fprintf( stderr, "\n" );
|
||||
fprintf( stderr, "before align 2 %s \n", indication2 );
|
||||
display( mseq2, clus2 );
|
||||
fprintf( stderr, "\n" );
|
||||
*/
|
||||
|
||||
commongappick( nseq1, mseq1 );
|
||||
commongappick( nseq2, mseq2 );
|
||||
|
||||
|
||||
#if DEBUG
|
||||
time1 = getrusage_sec();
|
||||
fprintf( stderr, "entering Falign\n" );
|
||||
#endif
|
||||
if( use_fft )
|
||||
{
|
||||
if( alg == 'M' )
|
||||
pscore = Falign_udpari_long( NULL, NULL, n_dis_consweight_multi, mseq1, mseq2, effarr1, effarr2, NULL, NULL, clus1, clus2, alloclen, &intdum );
|
||||
else
|
||||
pscore = Falign( NULL, NULL, n_dis_consweight_multi, mseq1, mseq2, effarr1, effarr2, NULL, NULL, clus1, clus2, alloclen, &intdum, NULL, 0, NULL );
|
||||
}
|
||||
else
|
||||
{
|
||||
if( alg == 'M' )
|
||||
pscore = MSalignmm( n_dis_consweight_multi, mseq1, mseq2, effarr1, effarr2, clus1, clus2, alloclen, NULL, NULL, NULL, NULL, NULL, 0, NULL, outgap, outgap, NULL, NULL, NULL, 0.0, 0.0 );
|
||||
else
|
||||
pscore = A__align( n_dis_consweight_multi, penalty, penalty_ex, mseq1, mseq2, effarr1, effarr2, clus1, clus2, alloclen, 0, &dumdb, NULL, NULL, NULL, NULL, NULL, 0, NULL, outgap, outgap, -1, -1, NULL, NULL, NULL, 0.0, 0.0 );
|
||||
}
|
||||
#if DEBUG
|
||||
time2 = getrusage_sec();
|
||||
fprintf( stdout, "### %d - %d, %f\n", clus1, clus2, time2-time1 );
|
||||
fflush( stdout );
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
fprintf( stderr, "after align 1 %s \n", indication1 );
|
||||
display( mseq1, clus1 );
|
||||
fprintf( stderr, "\n" );
|
||||
fprintf( stderr, "after align 2 %s \n", indication2 );
|
||||
display( mseq2, clus2 );
|
||||
fprintf( stderr, "\n" );
|
||||
*/
|
||||
|
||||
fprintf( stderr, "group-to-group %s /%s %f\n", indication1, indication2, pscore );
|
||||
if( disp ) display( aseq, njob );
|
||||
fprintf( stderr, "\n" );
|
||||
|
||||
/*
|
||||
trap = fopen( "pre", "r+" );
|
||||
if( !trap ) ErrorExit( 1 );
|
||||
WriteGapFill( trap, njob, name, nlen, aseq );
|
||||
fclose( trap );
|
||||
fprintf( stdout, "nseq1 = %d\n", nseq1 );
|
||||
*/
|
||||
}
|
||||
|
||||
static void WriteOptions( FILE *fp )
|
||||
{
|
||||
fprintf( fp, "tree-base method\n" );
|
||||
if( tbweight == 0 ) fprintf( fp, "unweighted\n" );
|
||||
else if( tbweight == 3 ) fprintf( fp, "reversely weighted\n" );
|
||||
if ( scoremtx == 0 ) fprintf( fp, "JTT %dPAM\n", pamN );
|
||||
else if( scoremtx == 1 ) fprintf( fp, "Dayhoff( machigai ga aru )\n" );
|
||||
else if( scoremtx == 2 ) fprintf( fp, "M-Y\n" );
|
||||
else if( scoremtx == -1 ) fprintf( fp, "DNA\n" );
|
||||
|
||||
if( scoremtx )
|
||||
fprintf( fp, "Gap Penalty = %d, %d\n", penalty, offset );
|
||||
else
|
||||
fprintf( fp, "Gap Penalty = %d\n", penalty );
|
||||
}
|
||||
|
||||
|
||||
int main( int argc, char *argv[] )
|
||||
{
|
||||
char **argv2;
|
||||
static int *nlen;
|
||||
static char **name, **seq;
|
||||
static char **seq1, **seq2;
|
||||
static char **mseq1, **mseq2;
|
||||
static char **aseq;
|
||||
static char **bseq;
|
||||
static double **pscore;
|
||||
static double *eff;
|
||||
int i, j, len1, len2;
|
||||
static int ***topol;
|
||||
static double **len;
|
||||
FILE *gp1, *gp2;
|
||||
char c;
|
||||
int nlenmax1, nlenmax2, nseq1, nseq2;
|
||||
int alloclen;
|
||||
|
||||
argv2 = arguments( argc, argv );
|
||||
|
||||
fprintf( stderr, "####### in galn\n" );
|
||||
|
||||
initFiles();
|
||||
|
||||
fprintf( stderr, "file1 = %s\n", argv2[0] );
|
||||
fprintf( stderr, "file2 = %s\n", argv2[1] );
|
||||
|
||||
gp1 = fopen( argv2[0], "r" ); if( !gp1 ) ErrorExit( "cannot open file1" );
|
||||
gp2 = fopen( argv2[1], "r" ); if( !gp2 ) ErrorExit( "cannot open file2" );
|
||||
|
||||
#if 0
|
||||
PreRead( gp1, &nseq1, &nlenmax1 );
|
||||
PreRead( gp2, &nseq2, &nlenmax2 );
|
||||
#else
|
||||
getnumlen( gp1 );
|
||||
nseq1 = njob; nlenmax1 = nlenmax;
|
||||
getnumlen( gp2 );
|
||||
nseq2 = njob; nlenmax2 = nlenmax;
|
||||
#endif
|
||||
|
||||
njob = nseq1 + nseq2;
|
||||
nlenmax = MAX( nlenmax1, nlenmax2 );
|
||||
|
||||
rewind( gp1 );
|
||||
rewind( gp2 );
|
||||
|
||||
|
||||
name = AllocateCharMtx( njob, B );
|
||||
nlen = AllocateIntVec( njob );
|
||||
seq1 = AllocateCharMtx( nseq1, nlenmax*3 );
|
||||
seq2 = AllocateCharMtx( nseq2, nlenmax*3 );
|
||||
seq = AllocateCharMtx( njob, 1 );
|
||||
aseq = AllocateCharMtx( njob, nlenmax*3 );
|
||||
bseq = AllocateCharMtx( njob, nlenmax*3 );
|
||||
mseq1 = AllocateCharMtx( njob, 1 );
|
||||
mseq2 = AllocateCharMtx( njob, 1 );
|
||||
alloclen = nlenmax * 3;
|
||||
|
||||
topol = AllocateIntCub( njob, 2, njob );
|
||||
len = AllocateDoubleMtx( njob, 2 );
|
||||
if( tbrweight > 0 ) pscore = AllocateDoubleMtx( njob, njob );
|
||||
eff = AllocateDoubleVec( njob );
|
||||
|
||||
#if 0
|
||||
njob=nseq2; FRead( gp2, name+nseq1, nlen+nseq1, seq2 );
|
||||
njob=nseq1; FRead( gp1, name, nlen, seq1 );
|
||||
#else
|
||||
njob=nseq2; readDataforgaln( gp2, name+nseq1, nlen+nseq1, seq2 );
|
||||
njob=nseq1; readDataforgaln( gp1, name, nlen, seq1 );
|
||||
#endif
|
||||
njob = nseq1 + nseq2;
|
||||
|
||||
|
||||
#if 0 // CHUUI
|
||||
commongappick( nseq1, seq1 );
|
||||
commongappick( nseq2, seq2 );
|
||||
#endif
|
||||
|
||||
for( i=0; i<nseq1; i++ ) seq[i] = seq1[i];
|
||||
for( i=nseq1; i<njob; i++ ) seq[i] = seq2[i-nseq1];
|
||||
/*
|
||||
Write( stdout, njob, name, nlen, seq );
|
||||
*/
|
||||
|
||||
constants( njob, seq );
|
||||
|
||||
WriteOptions( trap_g );
|
||||
|
||||
c = seqcheck( seq );
|
||||
if( c )
|
||||
{
|
||||
fprintf( stderr, "Illeagal character %c\n", c );
|
||||
exit( 1 );
|
||||
}
|
||||
for( i=1; i<nseq1; i++ )
|
||||
{
|
||||
if( nlen[i] != nlen[0] )
|
||||
ErrorExit( "group1 is not aligned." );
|
||||
}
|
||||
for( i=nseq1+1; i<njob; i++ )
|
||||
{
|
||||
if( nlen[i] != nlen[nseq1] )
|
||||
ErrorExit( "group2 is not aligned." );
|
||||
}
|
||||
|
||||
|
||||
if( tbutree == 0 )
|
||||
{
|
||||
if( tbrweight > 0 )
|
||||
{
|
||||
for( i=0; i<nseq1; i++ )
|
||||
{
|
||||
for( j=i+1; j<nseq1; j++ )
|
||||
{
|
||||
pscore[i][j] = (double)substitution_hosei( seq[i], seq[j] );
|
||||
// fprintf( stderr, "%d-%d, %5.1f \n", i, j, pscore[i][j] );
|
||||
}
|
||||
for( j=nseq1; j<njob; j++ )
|
||||
{
|
||||
pscore[i][j] = 3.0;
|
||||
// fprintf( stderr, "%d-%d, %5.1f \n", i, j, pscore[i][j] );
|
||||
}
|
||||
}
|
||||
for( i=nseq1; i<njob-1; i++ )
|
||||
{
|
||||
for( j=i+1; j<njob; j++ )
|
||||
{
|
||||
pscore[i][j] = (double)substitution_hosei( seq[i], seq[j] );
|
||||
// fprintf( stderr, "%d-%d, %5.1f \n", i, j, pscore[i][j] );
|
||||
}
|
||||
}
|
||||
// fprintf( stderr, "\n" );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf( stderr, "Not supported\n" );
|
||||
exit( 1 );
|
||||
#if 0
|
||||
prep = fopen( "hat2", "r" );
|
||||
if( prep == NULL ) ErrorExit( "Make hat2." );
|
||||
readhat2( prep, njob, name, pscore );
|
||||
fclose( prep );
|
||||
#endif
|
||||
}
|
||||
|
||||
if( tbrweight > 0 )
|
||||
{
|
||||
fprintf( stderr, "Constructing dendrogram ... " );
|
||||
if( treemethod == 'x' )
|
||||
veryfastsupg( njob, pscore, topol, len );
|
||||
else
|
||||
ErrorExit( "Incorrect tree\n" );
|
||||
fprintf( stderr, "done.\n" );
|
||||
|
||||
weight = 3;
|
||||
counteff_simple( njob, topol, len, eff );
|
||||
// for( i=0; i<njob; i++ ) fprintf( stderr, "eff[%d] = %f\n", i, eff[i] );
|
||||
}
|
||||
else if ( tbrweight == 0 )
|
||||
{
|
||||
for( i=0; i<njob; i++ ) eff[i] = 1.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
getweightfromname( njob, eff, name );
|
||||
}
|
||||
|
||||
//for( i=0; i<njob; i++ ) reporterr( "weight[%d] = %f\n", i, eff[i] );
|
||||
//exit( 1 );
|
||||
|
||||
len1 = strlen( seq[0] );
|
||||
len2 = strlen( seq[nseq1] );
|
||||
if( !nevermemsave && ( alg != 'M' && ( len1 > 30000 || len2 > 30000 ) ) )
|
||||
// if( len1 > 30000 || len2 > 30000 )
|
||||
{
|
||||
fprintf( stderr, "\nlen1=%d, len2=%d, Switching to the memsave mode.\n", len1, len2 );
|
||||
alg = 'M';
|
||||
}
|
||||
|
||||
|
||||
|
||||
reporterr( "GroupAglin..\n" );
|
||||
|
||||
GroupAlign( nseq1, nseq2, name, nlen, seq, aseq, mseq1, mseq2, topol, len, eff, alloclen );
|
||||
|
||||
#if 0
|
||||
writePre( njob, name, nlen, aseq, 1 );
|
||||
#else
|
||||
writeDataforgaln( stdout, njob, name, nlen, aseq );
|
||||
#endif
|
||||
|
||||
SHOWVERSION;
|
||||
return( 0 );
|
||||
}
|
358
mafft/src/mafft-7.487-with-extensions/core/mafft-sparsecore.tmpl
Normal file
358
mafft/src/mafft-7.487-with-extensions/core/mafft-sparsecore.tmpl
Normal file
|
@ -0,0 +1,358 @@
|
|||
#! /usr/bin/env ruby
|
||||
require 'optparse'
|
||||
|
||||
mafftpath = "_BINDIR/mafft"
|
||||
|
||||
def cleartempfiles( filenames )
|
||||
for f in filenames
|
||||
system( "rm -rf #{f}" )
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
seed = 0
|
||||
scand = "50%"
|
||||
npick = 500
|
||||
infn = ""
|
||||
reorderoption = "--reorder"
|
||||
pickoptions = " --retree 1 "
|
||||
coreoptions = " --globalpair --maxiterate 100 "
|
||||
corelastarg = " "
|
||||
addoptions = " "
|
||||
directionoptions = " --retree 0 --pileup "
|
||||
markcore = ""
|
||||
randompickup = true
|
||||
outnum = false
|
||||
|
||||
begin
|
||||
params = ARGV.getopts('m:s:n:p:i:C:L:A:o:MhuD:')
|
||||
rescue => e
|
||||
STDERR.puts e
|
||||
STDERR.puts "See #{$0} -h"
|
||||
exit 1
|
||||
end
|
||||
|
||||
#p params
|
||||
|
||||
mafftpath = params["m"] if params["m"]
|
||||
seed = params["s"].to_i if params["s"]
|
||||
scand = params["n"].to_s if params["n"]
|
||||
npick = params["p"].to_i if params["p"]
|
||||
infn = params["i"] if params["i"]
|
||||
#pickoptions += params["P"] if params["P"]
|
||||
coreoptions += params["C"] if params["C"] # tsuikagaki!
|
||||
corelastarg += params["L"] if params["L"] # tsuikagaki!
|
||||
addoptions += params["A"] if params["A"]
|
||||
directionoptions += params["D"] if params["D"] # tsuikagaki
|
||||
markcore = "*" if params["M"]
|
||||
#randompickup = false if params["S"]
|
||||
reorderoption = "" if params["o"] =~ /^i/
|
||||
outnum = true if params["u"]
|
||||
|
||||
if params["h"] then
|
||||
STDERR.puts "Usage: #{$0} -i inputfile [options]"
|
||||
STDERR.puts "Options:"
|
||||
STDERR.puts " -i string Input file."
|
||||
STDERR.puts " -m string Mafft command. Default: mafft"
|
||||
STDERR.puts " -s int Seed. Default:0"
|
||||
STDERR.puts " -n int Number of candidates for core sequences. Default: upper 50% in length"
|
||||
STDERR.puts " -p int Number of core sequences. Default: 500"
|
||||
# STDERR.puts " -P \"string\" Mafft options for the PICKUP stage."
|
||||
# STDERR.puts " Default: \"--retree 1\""
|
||||
# STDERR.puts " -S Tree-based pickup. Default: off"
|
||||
STDERR.puts " -C \"string\" Mafft options for the CORE stage."
|
||||
STDERR.puts " Default: \"--globalpair --maxiterate 100\""
|
||||
STDERR.puts " -A \"string\" Mafft options for the ADD stage."
|
||||
STDERR.puts " Default: \"\""
|
||||
STDERR.puts " -D \"string\" Mafft options for inferring the direction of nucleotide sequences."
|
||||
STDERR.puts " Default: \"\""
|
||||
STDERR.puts " -o r or i r: Reorder the sequences based on similarity. Default"
|
||||
STDERR.puts " i: Same as input."
|
||||
exit 1
|
||||
end
|
||||
|
||||
if infn == "" then
|
||||
STDERR.puts "Give input file with -i."
|
||||
exit 1
|
||||
end
|
||||
|
||||
|
||||
|
||||
pid = $$.to_s
|
||||
tmpdir = ENV["TMPDIR"]
|
||||
tmpdir = "/tmp" if tmpdir == nil
|
||||
tempfiles = []
|
||||
tempfiles.push( temp_pf = tmpdir + "/_pf" + pid )
|
||||
tempfiles.push( temp_nf = tmpdir + "/_nf" + pid )
|
||||
tempfiles.push( temp_cf = tmpdir + "/_cf" + pid )
|
||||
tempfiles.push( temp_of = tmpdir + "/_of" + pid )
|
||||
|
||||
Signal.trap(:INT){cleartempfiles( tempfiles ); exit 1}
|
||||
at_exit{ cleartempfiles( tempfiles )}
|
||||
|
||||
system "#{mafftpath} --version > #{temp_of} 2>&1"
|
||||
|
||||
fp = File.open( temp_of, "r" )
|
||||
line = fp.gets
|
||||
fp.close
|
||||
|
||||
|
||||
versionnum = line.split(' ')[0].sub(/v/,"").to_f
|
||||
|
||||
if versionnum < 7.210 then
|
||||
STDERR.puts "\n"
|
||||
STDERR.puts "Please use mafft version >= 7.210\n"
|
||||
STDERR.puts "\n"
|
||||
exit
|
||||
end
|
||||
|
||||
srand( seed )
|
||||
|
||||
def readfasta( fp, name, seq )
|
||||
nseq = 0
|
||||
tmpseq = ""
|
||||
while fp.gets
|
||||
if $_ =~ /^>/ then
|
||||
name.push( $_.sub(/>/,"").chop )
|
||||
seq.push( tmpseq ) if nseq > 0
|
||||
nseq += 1
|
||||
tmpseq = ""
|
||||
else
|
||||
tmpseq += $_.strip
|
||||
end
|
||||
end
|
||||
seq.push( tmpseq )
|
||||
return nseq
|
||||
end
|
||||
|
||||
|
||||
|
||||
begin
|
||||
infp = File.open( infn, "r" )
|
||||
rescue => e
|
||||
STDERR.puts e
|
||||
exit 1
|
||||
end
|
||||
infp.close
|
||||
|
||||
if directionoptions =~ /--adjustdirection/ then
|
||||
system( mafftpath + "#{directionoptions} #{infn} > #{temp_of}" )
|
||||
else
|
||||
system( "cp #{infn} #{temp_of}" )
|
||||
end
|
||||
|
||||
tname = []
|
||||
tseq = []
|
||||
infp = File.open( temp_of, "r" )
|
||||
tin = readfasta( infp, tname, tseq )
|
||||
infp.close
|
||||
lenhash = {}
|
||||
|
||||
if outnum then
|
||||
for i in 1..(tin)
|
||||
tname[i-1] = "_numo_s_0#{i}_numo_e_" + tname[i-1]
|
||||
end
|
||||
end
|
||||
|
||||
npick = 0 if npick == 1
|
||||
npick = tin if npick > tin
|
||||
|
||||
|
||||
if scand =~ /%$/ then
|
||||
ncand = (tin * scand.to_f * 0.01 ).to_i
|
||||
else
|
||||
ncand = scand.to_i
|
||||
end
|
||||
|
||||
if ncand < 0 || ncand > tin then
|
||||
STDERR.puts "Error. -n #{scand}?"
|
||||
exit 1
|
||||
end
|
||||
|
||||
ncand = npick if ncand < npick
|
||||
ncand = tin if ncand > tin
|
||||
|
||||
STDERR.puts "ncand = #{ncand}, npick = #{npick}"
|
||||
|
||||
|
||||
sai = []
|
||||
for i in 0..(tin-1)
|
||||
lenhash[i] = tseq[i].gsub(/-/,"").length
|
||||
end
|
||||
|
||||
i = 0
|
||||
sorted = lenhash.sort_by{|key, value| [-value, i+=1]}
|
||||
#for i in 0..(ncand-1)
|
||||
# sai[sorted[i][0]] = 1
|
||||
#end
|
||||
#for i in ncand..(tin-1)
|
||||
# sai[sorted[i][0]] = 0
|
||||
#end
|
||||
|
||||
ncandres = 0
|
||||
ntsukau = 0
|
||||
for i in 0..(tin-1)
|
||||
cand = sorted[i][0]
|
||||
if tname[cand] =~ /^_focus_/ then
|
||||
sai[cand] = 0
|
||||
ntsukau += 1
|
||||
elsif ncandres < ncand then
|
||||
unless tname[cand] =~ /^_tsukawanai_/ then
|
||||
sai[cand] = 1
|
||||
ncandres += 1
|
||||
else
|
||||
sai[cand] = 0
|
||||
end
|
||||
else
|
||||
sai[cand] = 0
|
||||
end
|
||||
end
|
||||
|
||||
if ncandres+ntsukau < npick
|
||||
STDERR.puts "ncandres = #{ncandres}"
|
||||
STDERR.puts "ncand = #{ncand}"
|
||||
STDERR.puts "ntsukau = #{ntsukau}"
|
||||
STDERR.puts "npick = #{npick}"
|
||||
STDERR.puts "Too many _tsukawanai_ sequences."
|
||||
exit 1
|
||||
end
|
||||
|
||||
if ntsukau > npick
|
||||
STDERR.puts "ntsukau = #{ntsukau}"
|
||||
STDERR.puts "npick = #{npick}"
|
||||
STDERR.puts "Too many _focus_ sequences."
|
||||
exit 1
|
||||
end
|
||||
|
||||
#p sai
|
||||
#for i in 0..(tin-1)
|
||||
# puts sai[i].to_s + " " + tname[i]
|
||||
#end
|
||||
|
||||
npickrand = npick - ntsukau
|
||||
|
||||
if randompickup
|
||||
pick = []
|
||||
for i in 0..(npickrand-1)
|
||||
pick[i] = 1
|
||||
end
|
||||
for i in npickrand..(ncandres-1)
|
||||
pick[i] = 0
|
||||
end
|
||||
pick2 = pick.sort_by{rand}
|
||||
pick = pick2
|
||||
# p pick
|
||||
# p sai
|
||||
|
||||
ipick = 0
|
||||
for i in 0..(tin-1)
|
||||
if sai[i] == 1 then
|
||||
if pick[ipick] == 0 then
|
||||
sai[i] = 0
|
||||
end
|
||||
ipick += 1
|
||||
end
|
||||
end
|
||||
# p sai
|
||||
|
||||
for i in 0..(tin-1)
|
||||
if tname[i] =~ /^_focus_/ then
|
||||
sai[i] = 1
|
||||
end
|
||||
end
|
||||
# p sai
|
||||
|
||||
pfp = File.open( temp_pf, 'w' )
|
||||
nfp = File.open( temp_nf, 'w' )
|
||||
|
||||
i = 0
|
||||
while i < tin
|
||||
if sai[i] == 1 then
|
||||
pfp.puts ">" + i.to_s + " " + ">" + markcore + tname[i]
|
||||
pfp.puts tseq[i]
|
||||
else
|
||||
nfp.puts ">" + i.to_s + " " + ">" + tname[i]
|
||||
nfp.puts tseq[i]
|
||||
end
|
||||
i += 1
|
||||
end
|
||||
|
||||
nfp.close
|
||||
pfp.close
|
||||
|
||||
else # yamerukamo
|
||||
STDERR.puts "Not supported in this version"
|
||||
exit 1
|
||||
end
|
||||
|
||||
if npick > 1 then
|
||||
if npick < tin then
|
||||
system( mafftpath + " #{coreoptions} #{temp_pf} #{corelastarg} > #{temp_cf}" ) # add de sort
|
||||
else
|
||||
system( mafftpath + " #{coreoptions} #{reorderoption} #{temp_pf} #{corelastarg} > #{temp_cf}" ) # ima sort
|
||||
end
|
||||
res = ( File::stat(temp_cf).size == 0 )
|
||||
else
|
||||
system( "cat /dev/null > #{temp_cf}" )
|
||||
res = false
|
||||
end
|
||||
|
||||
if res == true then
|
||||
STDERR.puts "\n\nError in the core alignment stage.\n\n"
|
||||
exit 1
|
||||
end
|
||||
|
||||
|
||||
if npick < tin
|
||||
system( mafftpath + " #{addoptions} #{reorderoption} --add #{temp_nf} #{temp_cf} > #{temp_of}" )
|
||||
res = ( File::stat(temp_of).size == 0 )
|
||||
else
|
||||
system( "cp #{temp_cf} #{temp_of}" )
|
||||
res = false
|
||||
end
|
||||
|
||||
if res == true then
|
||||
STDERR.puts "\n\nError in the add stage.\n\n"
|
||||
exit 1
|
||||
end
|
||||
|
||||
resname = []
|
||||
resseq = []
|
||||
resfp = File.open( temp_of, "r" )
|
||||
nres = readfasta( resfp, resname, resseq )
|
||||
resfp.close
|
||||
|
||||
if reorderoption =~ /--reorder/ then
|
||||
for i in 0..(nres-1)
|
||||
puts ">" + resname[i].sub(/^[0-9]* >/,"")
|
||||
puts resseq[i]
|
||||
end
|
||||
else
|
||||
seqhash = {}
|
||||
namehash = {}
|
||||
seqlast = []
|
||||
namelast = []
|
||||
nlast = 0
|
||||
for i in 0..(nres-1)
|
||||
if resname[i] =~ /^[0-9]* >/
|
||||
key = resname[i].split(' ')[0]
|
||||
seqhash[key] = resseq[i]
|
||||
namehash[key] = resname[i]
|
||||
else
|
||||
seqlast.push( resseq[i] )
|
||||
namelast.push( resname[i] )
|
||||
nlast += 1
|
||||
end
|
||||
end
|
||||
for i in 0..(nlast-1)
|
||||
puts ">" + namelast[i]
|
||||
puts seqlast[i]
|
||||
end
|
||||
for i in 0..(nres-nlast-1)
|
||||
key = i.to_s
|
||||
puts ">" + namehash[key].sub(/^[0-9]* >/,"")
|
||||
puts seqhash[key]
|
||||
end
|
||||
end
|
||||
|
||||
|
479
mafft/src/mafft-7.487-with-extensions/core/mafft.1
Normal file
479
mafft/src/mafft-7.487-with-extensions/core/mafft.1
Normal file
|
@ -0,0 +1,479 @@
|
|||
.\" Title: MAFFT
|
||||
.\" Author: Kazutaka Katoh <kazutaka.katoh@aist.go.jp>
|
||||
.\" Generator: DocBook XSL Stylesheets v1.72.0 <http://docbook.sf.net/>
|
||||
.\" Date: 2007-08-14
|
||||
.\" Manual: Mafft Manual
|
||||
.\" Source: mafft 6.240
|
||||
.\"
|
||||
.TH "MAFFT" "1" "2007\-06\-09" "mafft 6.240" "Mafft Manual"
|
||||
.\" disable hyphenation
|
||||
.nh
|
||||
.\" disable justification (adjust text to left margin only)
|
||||
.ad l
|
||||
.SH "THIS MANUAL IS FOR V6.2XX (2007)"
|
||||
Recent versions (v7.1xx; 2013 Jan.) have more features than those described below.
|
||||
See also the tips page at
|
||||
http://mafft.cbrc.jp/alignment/software/tips0.html
|
||||
.SH "NAME"
|
||||
.RS 0
|
||||
.sp
|
||||
mafft \- Multiple alignment program for amino acid or nucleotide sequences
|
||||
.RE
|
||||
.SH "SYNOPSIS"
|
||||
.RS 0
|
||||
.HP 6
|
||||
\fBmafft\fR [\fBoptions\fR] \fIinput\fR [>\ \fIoutput\fR]
|
||||
.HP 6
|
||||
\fBlinsi\fR \fIinput\fR [>\ \fIoutput\fR]
|
||||
.HP 6
|
||||
\fBginsi\fR \fIinput\fR [>\ \fIoutput\fR]
|
||||
.HP 6
|
||||
\fBeinsi\fR \fIinput\fR [>\ \fIoutput\fR]
|
||||
.HP 7
|
||||
\fBfftnsi\fR \fIinput\fR [>\ \fIoutput\fR]
|
||||
.HP 6
|
||||
\fBfftns\fR \fIinput\fR [>\ \fIoutput\fR]
|
||||
.HP 5
|
||||
\fBnwns\fR \fIinput\fR [>\ \fIoutput\fR]
|
||||
.HP 6
|
||||
\fBnwnsi\fR \fIinput\fR [>\ \fIoutput\fR]
|
||||
.HP 14
|
||||
\fBmafft\-profile\fR \fIgroup1\fR \fIgroup2\fR [>\ \fIoutput\fR]
|
||||
.HP
|
||||
.sp
|
||||
\fIinput\fR, \fIgroup1\fR and \fIgroup2\fR must be in FASTA format.
|
||||
.RE
|
||||
.SH "DESCRIPTION"
|
||||
.RS 0
|
||||
\fBMAFFT\fR is a multiple sequence alignment program for unix\-like operating systems. It offers a range of multiple alignment methods.
|
||||
.SS "Accuracy\-oriented methods:"
|
||||
.sp
|
||||
.RS 4
|
||||
\h'-04'\(bu\h'+03'L\-INS\-i (probably most accurate; recommended for <200 sequences; iterative refinement method incorporating local pairwise alignment information):
|
||||
.HP 6
|
||||
\fBmafft\fR \fB\-\-localpair\fR \fB\-\-maxiterate\fR\ \fI1000\fR \fIinput\fR [>\ \fIoutput\fR]
|
||||
.HP 6
|
||||
\fBlinsi\fR \fIinput\fR [>\ \fIoutput\fR]
|
||||
.RE
|
||||
.sp
|
||||
.RS 4
|
||||
\h'-04'\(bu\h'+03'G\-INS\-i (suitable for sequences of similar lengths; recommended for <200 sequences; iterative refinement method incorporating global pairwise alignment information):
|
||||
.HP 6
|
||||
\fBmafft\fR \fB\-\-globalpair\fR \fB\-\-maxiterate\fR\ \fI1000\fR \fIinput\fR [>\ \fIoutput\fR]
|
||||
.HP 6
|
||||
\fBginsi\fR \fIinput\fR [>\ \fIoutput\fR]
|
||||
.RE
|
||||
.sp
|
||||
.RS 4
|
||||
\h'-04'\(bu\h'+03'E\-INS\-i (suitable for sequences containing large unalignable regions; recommended for <200 sequences):
|
||||
.HP 6
|
||||
\fBmafft\fR \fB\-\-ep\fR\ \fI0\fR \fB\-\-genafpair\fR \fB\-\-maxiterate\fR\ \fI1000\fR \fIinput\fR [>\ \fIoutput\fR]
|
||||
.HP 6
|
||||
\fBeinsi\fR \fIinput\fR [>\ \fIoutput\fR]
|
||||
.br
|
||||
|
||||
For E\-INS\-i, the
|
||||
\fB\-\-ep\fR
|
||||
\fI0\fR
|
||||
option is recommended to allow large gaps.
|
||||
.RE
|
||||
.SS "Speed\-oriented methods:"
|
||||
.sp
|
||||
.RS 4
|
||||
\h'-04'\(bu\h'+03'FFT\-NS\-i (iterative refinement method; two cycles only):
|
||||
.HP 6
|
||||
\fBmafft\fR \fB\-\-retree\fR\ \fI2\fR \fB\-\-maxiterate\fR\ \fI2\fR \fIinput\fR [>\ \fIoutput\fR]
|
||||
.HP 7
|
||||
\fBfftnsi\fR \fIinput\fR [>\ \fIoutput\fR]
|
||||
.RE
|
||||
.sp
|
||||
.RS 4
|
||||
\h'-04'\(bu\h'+03'FFT\-NS\-i (iterative refinement method; max. 1000 iterations):
|
||||
.HP 6
|
||||
\fBmafft\fR \fB\-\-retree\fR\ \fI2\fR \fB\-\-maxiterate\fR\ \fI1000\fR \fIinput\fR [>\ \fIoutput\fR]
|
||||
.RE
|
||||
.sp
|
||||
.RS 4
|
||||
\h'-04'\(bu\h'+03'FFT\-NS\-2 (fast; progressive method):
|
||||
.HP 6
|
||||
\fBmafft\fR \fB\-\-retree\fR\ \fI2\fR \fB\-\-maxiterate\fR\ \fI0\fR \fIinput\fR [>\ \fIoutput\fR]
|
||||
.HP 6
|
||||
\fBfftns\fR \fIinput\fR [>\ \fIoutput\fR]
|
||||
.RE
|
||||
.sp
|
||||
.RS 4
|
||||
\h'-04'\(bu\h'+03'FFT\-NS\-1 (very fast; recommended for >2000 sequences; progressive method with a rough guide tree):
|
||||
.HP 6
|
||||
\fBmafft\fR \fB\-\-retree\fR\ \fI1\fR \fB\-\-maxiterate\fR\ \fI0\fR \fIinput\fR [>\ \fIoutput\fR]
|
||||
.RE
|
||||
.sp
|
||||
.RS 4
|
||||
\h'-04'\(bu\h'+03'NW\-NS\-i (iterative refinement method without FFT approximation; two cycles only):
|
||||
.HP 6
|
||||
\fBmafft\fR \fB\-\-retree\fR\ \fI2\fR \fB\-\-maxiterate\fR\ \fI2\fR \fB\-\-nofft\fR\ \fIinput\fR [>\ \fIoutput\fR]
|
||||
.HP 7
|
||||
\fBnwnsi\fR \fIinput\fR [>\ \fIoutput\fR]
|
||||
.RE
|
||||
.sp
|
||||
.RS 4
|
||||
\h'-04'\(bu\h'+03'NW\-NS\-2 (fast; progressive method without the FFT approximation):
|
||||
.HP 6
|
||||
\fBmafft\fR \fB\-\-retree\fR\ \fI2\fR \fB\-\-maxiterate\fR\ \fI0\fR \fB\-\-nofft\fR\ \fIinput\fR [>\ \fIoutput\fR]
|
||||
.HP 6
|
||||
\fBnwns\fR \fIinput\fR [>\ \fIoutput\fR]
|
||||
.RE
|
||||
.sp
|
||||
.RS 4
|
||||
\h'-04'\(bu\h'+03'NW\-NS\-PartTree\-1 (recommended for ~10,000 to ~50,000 sequences; progressive method with the PartTree algorithm):
|
||||
.HP 6
|
||||
\fBmafft\fR \fB\-\-retree\fR\ \fI1\fR \fB\-\-maxiterate\fR\ \fI0\fR \fB\-\-nofft\fR\ \fB\-\-parttree\fR \fIinput\fR [>\ \fIoutput\fR]
|
||||
.RE
|
||||
.SS "Group\-to\-group alignments"
|
||||
.HP 6
|
||||
.RS 4
|
||||
\fBmafft\-profile\fR \fIgroup1\fR \fIgroup2\fR [>\ \fIoutput\fR]
|
||||
.sp
|
||||
or:
|
||||
.sp
|
||||
\fBmafft\fR \fB\-\-maxiterate\fR\ \fI1000\fR \fB\-\-seed\fR\ \fIgroup1\fR \fB\-\-seed\fR\ \fIgroup2\fR /dev/null [>\ \fIoutput\fR]
|
||||
.RE
|
||||
.RE
|
||||
.RE
|
||||
.SH "OPTIONS"
|
||||
.SS "Algorithm"
|
||||
.RS 0
|
||||
.PP
|
||||
\fB\-\-auto\fR
|
||||
.RS 4
|
||||
Automatically selects an appropriate strategy from L\-INS\-i, FFT\-NS\-i and FFT\-NS\-2, according to data
|
||||
size. Default: off (always FFT\-NS\-2)
|
||||
.RE
|
||||
.PP
|
||||
\fB\-\-6merpair\fR
|
||||
.RS 4
|
||||
Distance is calculated based on the number of shared 6mers. Default: on
|
||||
.RE
|
||||
.PP
|
||||
\fB\-\-globalpair\fR
|
||||
.RS 4
|
||||
All pairwise alignments are computed with the Needleman\-Wunsch
|
||||
algorithm. More accurate but slower
|
||||
than \-\-6merpair. Suitable for a set of
|
||||
globally alignable sequences. Applicable to
|
||||
up to ~200 sequences. A combination with \-\-maxiterate 1000 is recommended (G\-INS\-i). Default: off (6mer distance is used)
|
||||
.RE
|
||||
.PP
|
||||
\fB\-\-localpair\fR
|
||||
.RS 4
|
||||
All pairwise alignments are computed with the Smith\-Waterman
|
||||
algorithm. More accurate but slower
|
||||
than \-\-6merpair. Suitable for a set of
|
||||
locally alignable sequences. Applicable to
|
||||
up to ~200 sequences. A combination with \-\-maxiterate 1000 is recommended (L\-INS\-i). Default: off (6mer distance is used)
|
||||
.RE
|
||||
.PP
|
||||
\fB\-\-genafpair\fR
|
||||
.RS 4
|
||||
All pairwise alignments are computed with a local
|
||||
algorithm with the generalized affine gap cost
|
||||
(Altschul 1998). More accurate but slower
|
||||
than \-\-6merpair. Suitable when large internal gaps
|
||||
are expected. Applicable to
|
||||
up to ~200 sequences. A combination with \-\-maxiterate 1000 is recommended (E\-INS\-i). Default: off (6mer distance is used)
|
||||
.RE
|
||||
.\".PP
|
||||
.\"\fB\-\-fastswpair\fR
|
||||
.\".RS 4
|
||||
.\"Distance is calculated based on a FASTA alignment.
|
||||
.\"FASTA is required. Default: off (6mer distance is used)
|
||||
.\".RE
|
||||
.PP
|
||||
\fB\-\-fastapair\fR
|
||||
.RS 4
|
||||
All pairwise alignments are computed with FASTA (Pearson and Lipman 1988).
|
||||
FASTA is required. Default: off (6mer distance is used)
|
||||
.RE
|
||||
.\".PP
|
||||
.\"\fB\-\-blastpair\fR
|
||||
.\".RS 4
|
||||
.\"Distance is calculated based on a BLAST alignment. BLAST is
|
||||
.\"required. Default: off (6mer distance is used)
|
||||
.\".RE
|
||||
.PP
|
||||
\fB\-\-weighti\fR \fInumber\fR
|
||||
.RS 4
|
||||
Weighting factor for the consistency term calculated from pairwise alignments. Valid when
|
||||
either of \-\-globalpair, \-\-localpair, \-\-genafpair, \-\-fastapair or
|
||||
\-\-blastpair is selected. Default: 2.7
|
||||
.RE
|
||||
.PP
|
||||
\fB\-\-retree\fR \fInumber\fR
|
||||
.RS 4
|
||||
Guide tree is built \fInumber\fR times in the
|
||||
progressive stage. Valid with 6mer distance. Default: 2
|
||||
.RE
|
||||
.PP
|
||||
\fB\-\-maxiterate\fR \fInumber\fR
|
||||
.RS 4
|
||||
\fInumber\fR cycles of iterative refinement are performed. Default: 0
|
||||
.RE
|
||||
.PP
|
||||
\fB\-\-fft\fR
|
||||
.RS 4
|
||||
Use FFT approximation in group\-to\-group alignment. Default: on
|
||||
.RE
|
||||
.PP
|
||||
\fB\-\-nofft\fR
|
||||
.RS 4
|
||||
Do not use FFT approximation in group\-to\-group alignment. Default: off
|
||||
.RE
|
||||
.PP
|
||||
\fB\-\-noscore\fR
|
||||
.RS 4
|
||||
Alignment score is not checked in the iterative refinement stage. Default: off (score is checked)
|
||||
.RE
|
||||
.PP
|
||||
\fB\-\-memsave\fR
|
||||
.RS 4
|
||||
Use the Myers\-Miller (1988) algorithm. Default: automatically turned on when the alignment length exceeds 10,000 (aa/nt).
|
||||
.RE
|
||||
.PP
|
||||
\fB\-\-parttree\fR
|
||||
.RS 4
|
||||
Use a fast tree\-building method (PartTree, Katoh and Toh 2007) with
|
||||
the 6mer distance. Recommended for a large number (> ~10,000)
|
||||
of sequences are input. Default: off
|
||||
.RE
|
||||
.PP
|
||||
\fB\-\-dpparttree\fR
|
||||
.RS 4
|
||||
The PartTree algorithm is used with distances based on DP. Slightly
|
||||
more accurate and slower than \-\-parttree. Recommended for a large
|
||||
number (> ~10,000) of sequences are input. Default: off
|
||||
.RE
|
||||
.PP
|
||||
\fB\-\-fastaparttree\fR
|
||||
.RS 4
|
||||
The PartTree algorithm is used with distances based on FASTA. Slightly more accurate and slower than \-\-parttree. Recommended for a large number (> ~10,000) of sequences are input. FASTA is required. Default: off
|
||||
.RE
|
||||
.PP
|
||||
\fB\-\-partsize\fR \fInumber\fR
|
||||
.RS 4
|
||||
The number of partitions in the PartTree algorithm. Default: 50
|
||||
.RE
|
||||
.PP
|
||||
\fB\-\-groupsize\fR \fInumber\fR
|
||||
.RS 4
|
||||
Do not make alignment larger than \fInumber\fR sequences. Valid only with the \-\-*parttree options. Default: the number of input sequences
|
||||
.RE
|
||||
.RE
|
||||
.SS "Parameter"
|
||||
.RS 0
|
||||
.PP
|
||||
\fB\-\-op\fR \fInumber\fR
|
||||
.RS 4
|
||||
Gap opening penalty at group\-to\-group alignment. Default: 1.53
|
||||
.RE
|
||||
.PP
|
||||
\fB\-\-ep\fR \fInumber\fR
|
||||
.RS 4
|
||||
Offset value, which works like gap extension penalty, for
|
||||
group\-to\-group alignment. Default: 0.123
|
||||
.RE
|
||||
.PP
|
||||
\fB\-\-lop\fR \fInumber\fR
|
||||
.RS 4
|
||||
Gap opening penalty at local pairwise
|
||||
alignment. Valid when
|
||||
the \-\-localpair or \-\-genafpair option is selected. Default: \-2.00
|
||||
.RE
|
||||
.PP
|
||||
\fB\-\-lep\fR \fInumber\fR
|
||||
.RS 4
|
||||
Offset value at local pairwise alignment. Valid when
|
||||
the \-\-localpair or \-\-genafpair option is selected. Default: 0.1
|
||||
.RE
|
||||
.PP
|
||||
\fB\-\-lexp\fR \fInumber\fR
|
||||
.RS 4
|
||||
Gap extension penalty at local pairwise alignment. Valid when
|
||||
the \-\-localpair or \-\-genafpair option is selected. Default: \-0.1
|
||||
.RE
|
||||
.PP
|
||||
\fB\-\-LOP\fR \fInumber\fR
|
||||
.RS 4
|
||||
Gap opening penalty to skip the alignment. Valid when the
|
||||
\-\-genafpair option is selected. Default: \-6.00
|
||||
.RE
|
||||
.PP
|
||||
\fB\-\-LEXP\fR \fInumber\fR
|
||||
.RS 4
|
||||
Gap extension penalty to skip the alignment. Valid when the
|
||||
\-\-genafpair option is selected. Default: 0.00
|
||||
.RE
|
||||
.PP
|
||||
\fB\-\-bl\fR \fInumber\fR
|
||||
.RS 4
|
||||
BLOSUM \fInumber\fR matrix (Henikoff and Henikoff 1992) is used. \fInumber\fR=30, 45, 62 or 80. Default: 62
|
||||
.RE
|
||||
.PP
|
||||
\fB\-\-jtt\fR \fInumber\fR
|
||||
.RS 4
|
||||
JTT PAM \fInumber\fR (Jones et al. 1992) matrix is used. \fInumber\fR>0. Default: BLOSUM62
|
||||
.RE
|
||||
.PP
|
||||
\fB\-\-tm\fR \fInumber\fR
|
||||
.RS 4
|
||||
Transmembrane PAM \fInumber\fR (Jones et al. 1994) matrix is used. \fInumber\fR>0. Default: BLOSUM62
|
||||
.RE
|
||||
.PP
|
||||
\fB\-\-aamatrix\fR \fImatrixfile\fR
|
||||
.RS 4
|
||||
Use a user\-defined AA scoring matrix. The format of \fImatrixfile\fR is
|
||||
the same to that of BLAST. Ignored when nucleotide sequences are input. Default: BLOSUM62
|
||||
.RE
|
||||
.PP
|
||||
\fB\-\-fmodel\fR
|
||||
.RS 4
|
||||
Incorporate the AA/nuc composition information into
|
||||
the scoring matrix. Default: off
|
||||
.RE
|
||||
.RE
|
||||
.SS "Output"
|
||||
.RS 0
|
||||
.PP
|
||||
\fB\-\-clustalout\fR
|
||||
.RS 4
|
||||
Output format: clustal format. Default: off (fasta format)
|
||||
.RE
|
||||
.PP
|
||||
\fB\-\-inputorder\fR
|
||||
.RS 4
|
||||
Output order: same as input. Default: on
|
||||
.RE
|
||||
.PP
|
||||
\fB\-\-reorder\fR
|
||||
.RS 4
|
||||
Output order: aligned. Default: off (inputorder)
|
||||
.RE
|
||||
.PP
|
||||
\fB\-\-treeout\fR
|
||||
.RS 4
|
||||
Guide tree is output to the \fIinput\fR.tree file. Default: off
|
||||
.RE
|
||||
.PP
|
||||
\fB\-\-quiet\fR
|
||||
.RS 4
|
||||
Do not report progress. Default: off
|
||||
.RE
|
||||
.RE
|
||||
.SS "Input"
|
||||
.RS 0
|
||||
.PP
|
||||
\fB\-\-nuc\fR
|
||||
.RS 4
|
||||
Assume the sequences are nucleotide. Default: auto
|
||||
.RE
|
||||
.PP
|
||||
\fB\-\-amino\fR
|
||||
.RS 4
|
||||
Assume the sequences are amino acid. Default: auto
|
||||
.RE
|
||||
.PP
|
||||
\fB\-\-seed\fR \fIalignment1\fR [\fB--seed\fR \fIalignment2\fR \fB--seed\fR \fIalignment3\fR ...]
|
||||
.RS 4
|
||||
Seed alignments given in \fIalignment_n\fR (fasta format) are aligned with
|
||||
sequences in \fIinput\fR. The alignment within every seed is preserved.
|
||||
.RE
|
||||
.RE
|
||||
.SH "FILES"
|
||||
.RS 0
|
||||
.PP
|
||||
Mafft stores the input sequences and other files in a temporary directory, which by default is located in
|
||||
\fI/tmp\fR.
|
||||
.RE
|
||||
.SH "ENVIONMENT"
|
||||
.RS 0
|
||||
.PP
|
||||
\fBMAFFT_BINARIES\fR
|
||||
.RS 4
|
||||
Indicates the location of the binary files used by mafft. By default, they are searched in
|
||||
\fI/usr/local/lib/mafft\fR, but on Debian systems, they are searched in
|
||||
\fI/usr/lib/mafft\fR.
|
||||
.RE
|
||||
.PP
|
||||
\fBFASTA_4_MAFFT\fR
|
||||
.RS 4
|
||||
This variable can be set to indicate to mafft the location to the fasta34 program if it is not in the PATH.
|
||||
.RE
|
||||
.RE
|
||||
.SH "SEE ALSO"
|
||||
.RS 0
|
||||
.PP
|
||||
|
||||
\fBmafft\-homologs\fR(1)
|
||||
.RE
|
||||
.SH "REFERENCES"
|
||||
.RS 0
|
||||
.SS "In English"
|
||||
.sp
|
||||
.RS 4
|
||||
\h'-04'\(bu\h'+03'Katoh and Toh (Bioinformatics 23:372\-374, 2007) PartTree: an algorithm to build an approximate tree from a large number of unaligned sequences (describes the PartTree algorithm).
|
||||
.RE
|
||||
.sp
|
||||
.RS 4
|
||||
\h'-04'\(bu\h'+03'Katoh, Kuma, Toh and Miyata (Nucleic Acids Res. 33:511\-518, 2005) MAFFT version 5: improvement in accuracy of multiple sequence alignment (describes [ancestral versions of] the G\-INS\-i, L\-INS\-i and E\-INS\-i strategies)
|
||||
.RE
|
||||
.sp
|
||||
.RS 4
|
||||
\h'-04'\(bu\h'+03'Katoh, Misawa, Kuma and Miyata (Nucleic Acids Res. 30:3059\-3066, 2002) MAFFT: a novel method for rapid multiple sequence alignment based on fast Fourier transform (describes the FFT\-NS\-1, FFT\-NS\-2 and FFT\-NS\-i strategies)
|
||||
.RE
|
||||
.SS "In Japanese"
|
||||
.sp
|
||||
.RS 4
|
||||
\h'-04'\(bu\h'+03'Katoh and Misawa (Seibutsubutsuri 46:312\-317, 2006) Multiple Sequence Alignments: the Next Generation
|
||||
.RE
|
||||
.sp
|
||||
.RS 4
|
||||
\h'-04'\(bu\h'+03'Katoh and Kuma (Kagaku to Seibutsu 44:102\-108, 2006) Jissen\-teki Multiple Alignment
|
||||
.RE
|
||||
.RE
|
||||
.SH "AUTHORS"
|
||||
.RS 0
|
||||
.PP
|
||||
\fBKazutaka Katoh\fR <\&kazutaka.katoh_at_aist.go.jp\&>
|
||||
.sp -1n
|
||||
.IP "" 4
|
||||
Wrote Mafft.
|
||||
.PP
|
||||
\fBCharles Plessy\fR <\&charles\-debian\-nospam_at_plessy.org\&>
|
||||
.sp -1n
|
||||
.IP "" 4
|
||||
Wrote this manpage in DocBook XML for the Debian distribution, using Mafft's homepage as a template.
|
||||
.RE
|
||||
.SH "COPYRIGHT"
|
||||
.RS 0
|
||||
Copyright \(co 2002\-2007 Kazutaka Katoh (mafft)
|
||||
.br
|
||||
Copyright \(co 2007 Charles Plessy (this manpage)
|
||||
.br
|
||||
.PP
|
||||
Mafft and its manpage are offered under the following conditions:
|
||||
.PP
|
||||
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
||||
.sp
|
||||
.RS 4
|
||||
\h'-04' 1.\h'+02'Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
||||
.RE
|
||||
.sp
|
||||
.RS 4
|
||||
\h'-04' 2.\h'+02'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.
|
||||
.RE
|
||||
.sp
|
||||
.RS 4
|
||||
\h'-04' 3.\h'+02'The name of the author may not be used to endorse or promote products derived from this software without specific prior written permission.
|
||||
.RE
|
||||
.PP
|
||||
THIS SOFTWARE IS PROVIDED BY THE AUTHOR "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 AUTHOR 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.
|
||||
.br
|
||||
.RE
|
33
mafft/src/mafft-7.487-with-extensions/core/mafft.bat
Normal file
33
mafft/src/mafft-7.487-with-extensions/core/mafft.bat
Normal file
|
@ -0,0 +1,33 @@
|
|||
@echo off
|
||||
setlocal enabledelayedexpansion
|
||||
cls; 1>&2
|
||||
chcp 65001 1>&2
|
||||
for /f "usebackq tokens=*" %%i IN (`cd`) DO @set current_dir=%%i
|
||||
if /i "%current_dir%" == "%systemroot%" (
|
||||
set mafft_working_dir="%~dp0"
|
||||
) else (
|
||||
set mafft_working_dir="%current_dir%"
|
||||
)
|
||||
pushd "%mafft_working_dir%"
|
||||
|
||||
echo; 1>&2
|
||||
echo Preparing environment to run MAFFT on Windows. 1>&2
|
||||
echo This may take a while, if real-time scanning by anti-virus software is on. 1>&2
|
||||
|
||||
set ROOTDIR=%~d0%~p0
|
||||
set PATH=/usr/bin/:%PATH%
|
||||
set MAFFT_BINARIES=/usr/lib/mafft
|
||||
set TMPDIR=%TMP%
|
||||
set MAFFT_TMPDIR=%TMPDIR%
|
||||
|
||||
REM set TMPDIR=%ROOTDIR%/tmp
|
||||
REM set MAFFT_TMPDIR=%TMPDIR%
|
||||
REM If you do not have write permission for Windows temporary folder
|
||||
REM (typically C:\Users\username\AppData\Local\Temp\), then
|
||||
REM uncomment (remove REM) the above two lines to use an alternative
|
||||
REM temporary folder.
|
||||
|
||||
"%ROOTDIR%\usr\bin\bash" "/usr/bin/mafft" %*
|
||||
|
||||
popd
|
||||
exit /b
|
12
mafft/src/mafft-7.487-with-extensions/core/mafft.bat.win10
Normal file
12
mafft/src/mafft-7.487-with-extensions/core/mafft.bat.win10
Normal file
|
@ -0,0 +1,12 @@
|
|||
@echo off
|
||||
|
||||
setlocal
|
||||
|
||||
set ROOTDIR="%~d0%~p0\ms"
|
||||
set PATH=/bin/:%PATH%
|
||||
set MAFFT_BINARIES=/lib/mafft
|
||||
set TMPDIR=%~d0%~p0/ms/tmp
|
||||
|
||||
%ROOTDIR%\bin\sh %ROOTDIR%\bin\mafft %*
|
||||
|
||||
:EOF
|
4
mafft/src/mafft-7.487-with-extensions/core/mafft.h
Normal file
4
mafft/src/mafft-7.487-with-extensions/core/mafft.h
Normal file
|
@ -0,0 +1,4 @@
|
|||
extern int disttbfast( int ngui, int lgui, char **namegui, char **seqgui, int argc, char **argv, int (*callback)(int, int, char*));
|
||||
#define GUI_ERROR 1
|
||||
#define GUI_LENGTHOVER 2
|
||||
#define GUI_CANCEL 3
|
21
mafft/src/mafft-7.487-with-extensions/core/mafft.ps1
Normal file
21
mafft/src/mafft-7.487-with-extensions/core/mafft.ps1
Normal file
|
@ -0,0 +1,21 @@
|
|||
Write-Host;
|
||||
Write-Host Preparing environment to run MAFFT on Windows.
|
||||
Write-Host This may take a while, if real-time scanning by anti-virus software is on.
|
||||
|
||||
Set-Item Env:Path "/usr/bin;$Env:Path"
|
||||
Set-Item Env:MAFFT_BINARIES "/usr/lib/mafft"
|
||||
Set-Item Env:TMPDIR "$Env:TMP"
|
||||
Set-Item Env:MAFFT_TMPDIR "$Env:TMP"
|
||||
Set-Item Env:mafft_working_dir "$PWD"
|
||||
|
||||
#Set-Item Env:TMPDIR "/tmp"
|
||||
#Set-Item Env:MAFFT_TMPDIR "/tmp"
|
||||
# If you do not have write permission for standard temporary folder
|
||||
# (typically C:\Users\username\AppData\Local\Temp\), then
|
||||
# uncomment (remove #) the above two lines to use an alternative
|
||||
# temporary folder.
|
||||
|
||||
#$ROOTDIR=$PSScriptRoot # not supported by powershell versions <= 2
|
||||
$ROOTDIR=Split-Path -Parent $MyInvocation.MyCommand.Path
|
||||
$proc = Start-Process -Wait -NoNewWindow -PassThru -FilePath "$ROOTDIR\usr\bin\bash.exe" -ArgumentList "'/usr/bin/mafft' $args"
|
||||
exit $proc.ExitCode
|
2978
mafft/src/mafft-7.487-with-extensions/core/mafft.tmpl
Normal file
2978
mafft/src/mafft-7.487-with-extensions/core/mafft.tmpl
Normal file
File diff suppressed because it is too large
Load diff
|
@ -0,0 +1,464 @@
|
|||
#!/usr/bin/perl
|
||||
|
||||
#####################################################################
|
||||
# Author: KM Amada (kmamada@ifrec.osaka-u.ac.jp)
|
||||
#
|
||||
# Ver. Date Changelog
|
||||
#####################################################################
|
||||
# 1.0 07.26.13 Initial release
|
||||
# 2.0 09.03.13 Added extensive warnings and error messages
|
||||
# 3.0 10.28.13 Fix for retrieving large files. Added STDERR logs
|
||||
# 3.1 11.08.13 Added LWP failsafe. Made hat3 not a required output
|
||||
# 3.2 12.08.14 Removed 5-char restriction for own structure files
|
||||
#
|
||||
#####################################################################
|
||||
|
||||
use strict;
|
||||
use Getopt::Long;
|
||||
use File::Path qw(make_path remove_tree);
|
||||
use LWP::Simple;
|
||||
use LWP::UserAgent;
|
||||
|
||||
# to prevent error 'Header line too long (limit is 8192)' [v3.1]
|
||||
use LWP::Protocol::http;
|
||||
push(@LWP::Protocol::http::EXTRA_SOCK_OPTS, MaxLineLength => 0);
|
||||
|
||||
|
||||
|
||||
my $BASEURL = "http://sysimm.ifrec.osaka-u.ac.jp/MAFFTash/REST/service.cgi/premafft";
|
||||
|
||||
my ( $WORKDIR, $PDBLIST, $OWNLIST, $HAT3FILE, $INSTRFILE );
|
||||
|
||||
GetOptions
|
||||
(
|
||||
'd=s' => \$WORKDIR,
|
||||
'p=s' => \$PDBLIST,
|
||||
'o=s' => \$OWNLIST,
|
||||
'h=s' => \$HAT3FILE,
|
||||
'i=s' => \$INSTRFILE,
|
||||
);
|
||||
|
||||
print STDERR "[MAFFTash-premafft]\n";
|
||||
|
||||
# set temp directory
|
||||
my $TMP = "/tmp/mapremafft$$";
|
||||
make_path($TMP) unless -d $TMP;
|
||||
|
||||
|
||||
|
||||
######
|
||||
# validation
|
||||
&help("Required parameter : atleast one of either '-p' or '-o'") unless ( defined $PDBLIST || defined $OWNLIST);
|
||||
&help("Required parameter : '-d'") if defined $OWNLIST && ! defined $WORKDIR;
|
||||
|
||||
$HAT3FILE = "hat3" unless defined $HAT3FILE;
|
||||
$INSTRFILE = "instr" unless defined $INSTRFILE;
|
||||
chop $WORKDIR if defined $WORKDIR && $WORKDIR =~ m/\/$/g;
|
||||
|
||||
|
||||
######
|
||||
# prepare inputs
|
||||
print STDERR "Preparing inputs for service request...\n";
|
||||
|
||||
my @files = ();
|
||||
push(@files, "strweight" => "0.5");
|
||||
push(@files, "premafft" => "1");
|
||||
|
||||
|
||||
# pdb entries
|
||||
if ( defined $PDBLIST )
|
||||
{
|
||||
print STDERR "PDB List defined!\n";
|
||||
&bail("Error: Input file $PDBLIST does not exists!") unless -e $PDBLIST;
|
||||
my $listfile = "$TMP/pdblist.inp";
|
||||
|
||||
|
||||
open(INPF,"<$PDBLIST") or &bail("Error: Cannot open file $PDBLIST for reading!");
|
||||
open(OUTF,">$listfile") or &bail("Error: Cannot open temporary file $listfile for writing!");
|
||||
|
||||
while(<INPF>)
|
||||
{
|
||||
chomp;
|
||||
if ( /^(\w{5})$/ )
|
||||
{
|
||||
print OUTF ">PDBID\n$1\n";
|
||||
}
|
||||
}
|
||||
|
||||
close OUTF;
|
||||
close INPF;
|
||||
|
||||
push(@files, "inputfile" => ["$listfile"]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
# upload own structures
|
||||
my %ownids = ();
|
||||
|
||||
if ( defined $OWNLIST )
|
||||
{
|
||||
print STDERR "OWN List defined!\n";
|
||||
&bail("Error: Input file $OWNLIST does not exists!") unless -e $OWNLIST;
|
||||
|
||||
|
||||
open(OWNINPF,"<$OWNLIST") or &bail("Error: Cannot open file $OWNLIST for reading!");
|
||||
|
||||
while(<OWNINPF>)
|
||||
{
|
||||
chomp;
|
||||
|
||||
if ( /^(\S+)$/ )
|
||||
{
|
||||
my $fileref = "$WORKDIR/$1.pdb";
|
||||
|
||||
unless (-e $fileref)
|
||||
{
|
||||
close OWNINPF;
|
||||
&bail("Error: File $fileref does not exists!");
|
||||
}
|
||||
|
||||
push(@files, "inputownfile[]" => ["$fileref"]);
|
||||
$ownids{$1} = 1;
|
||||
}
|
||||
}
|
||||
|
||||
close OWNINPF;
|
||||
}
|
||||
|
||||
|
||||
|
||||
######
|
||||
# start rest service
|
||||
print STDERR "Sending service request...\n";
|
||||
|
||||
my $browser = LWP::UserAgent->new;
|
||||
$browser->timeout(0);
|
||||
|
||||
|
||||
# post: running a mafftash job
|
||||
my $postResponse = $browser->post( $BASEURL, \@files, 'Content_Type' => 'form-data' );
|
||||
&bail(sprintf("[%d] %s\n", $postResponse->code, &parseError($postResponse->content))) unless($postResponse->is_success);
|
||||
|
||||
|
||||
# get response from post request
|
||||
my ($status, $mafftashid) = &parseResponse($postResponse->content);
|
||||
|
||||
|
||||
|
||||
my $MAXTRIES = 3;
|
||||
my $STIMER = 4;
|
||||
my $longtimer = 0;
|
||||
|
||||
print STDERR "Request sent! Waiting for response...[$mafftashid]\n";
|
||||
|
||||
|
||||
# wait for results until it becomes available
|
||||
while(1)
|
||||
{
|
||||
$longtimer = $longtimer <= ($STIMER*3) ? $longtimer+$STIMER : $STIMER;
|
||||
sleep $longtimer;
|
||||
|
||||
|
||||
# get: get results for mafftash job
|
||||
my $getResponse = $browser->get("$BASEURL/$mafftashid");
|
||||
|
||||
if ( $getResponse->is_success )
|
||||
{
|
||||
|
||||
# get response from get request
|
||||
($status, $mafftashid) = &parseResponse($getResponse->content);
|
||||
next unless ( $status eq "done" );
|
||||
|
||||
|
||||
# if job is finished and ready
|
||||
print STDERR "Results found!\n";
|
||||
my $csfile = "$TMP/checksum.tar.gz";
|
||||
my $try1 = 1;
|
||||
|
||||
|
||||
while(1)
|
||||
{
|
||||
print STDERR "Fetching Results... [Trial $try1]\n";
|
||||
|
||||
if ( is_success(getstore("$BASEURL/getmdlist/$mafftashid", $csfile)) && -e $csfile && -s $csfile )
|
||||
{
|
||||
# get response from get request
|
||||
my $checklist = &extractchecksum($csfile);
|
||||
&bail("Error retrieving list of compressed files!") unless ( scalar %$checklist > 0 );
|
||||
|
||||
|
||||
foreach my $id ( keys %$checklist )
|
||||
{
|
||||
my $checkfile = "$TMP/$id";
|
||||
my $checkid = $checklist->{$id};
|
||||
my $try2 = 1;
|
||||
|
||||
while(1)
|
||||
{
|
||||
unlink $checkfile if -e $checkfile;
|
||||
|
||||
if ( is_success(getstore("$BASEURL/get/$mafftashid/$id", $checkfile)) && -e $checkfile && -s $checkfile )
|
||||
{
|
||||
my $hashid = &getchecksum($checkfile);
|
||||
#print STDERR "[hashid]$hashid [checkid]$checkid\n";
|
||||
|
||||
if ($hashid ne "" && $hashid ne $checkid )
|
||||
{
|
||||
unlink $checkfile if -e $checkfile;
|
||||
&bail("Error retrieving compressed file from server! [Checksum Failed]") if $try2 >= $MAXTRIES;
|
||||
$try2++;
|
||||
sleep $STIMER;
|
||||
}
|
||||
else
|
||||
{
|
||||
last;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
&bail("Error retrieving compressed file from server!") if $try2 >= $MAXTRIES;
|
||||
$try2++;
|
||||
sleep $STIMER;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
last;
|
||||
}
|
||||
else
|
||||
{
|
||||
&bail("Error retrieving list of compressed files from server!") if $try1 >= $MAXTRIES;
|
||||
$try1++;
|
||||
sleep $STIMER;
|
||||
}
|
||||
}
|
||||
|
||||
last;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
&bail(sprintf("[%d] %s\n", $getResponse->code, &parseError($getResponse->content)));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
# make sure outputs were generated
|
||||
# decompress
|
||||
print STDERR "Assembling final results...\n";
|
||||
|
||||
&backticks("cat $TMP/archive.tar.gz* | tar -zxf - -C $TMP/");
|
||||
&backticks("mv -f $TMP/instr $INSTRFILE") if -e "$TMP/instr";
|
||||
&backticks("mv -f $TMP/hat3 $HAT3FILE") if -e "$TMP/hat3";
|
||||
|
||||
# sometimes no hat3 file is generated [v3.1]
|
||||
#&bail("Error: Output file $HAT3FILE not found!") unless -e $HAT3FILE;
|
||||
&bail("Error: Output file $INSTRFILE not found!") unless -e $INSTRFILE;
|
||||
|
||||
|
||||
# warn if some ownids were ommitted
|
||||
if ( scalar keys(%ownids) > 0 )
|
||||
{
|
||||
my %instrids = ();
|
||||
|
||||
open(INSTRF,"<$INSTRFILE") or &bail("Error: Cannot open file $INSTRFILE for reading!");
|
||||
|
||||
while(<INSTRF>)
|
||||
{
|
||||
chomp;
|
||||
|
||||
if ( /^>\d+_(\S+)$/ )
|
||||
{
|
||||
$instrids{$1} = 1;
|
||||
}
|
||||
}
|
||||
|
||||
close INSTRF;
|
||||
|
||||
foreach my $id ( keys %ownids )
|
||||
{
|
||||
warn "Warning: Own structure $id was excluded from instr/hat3.\n" unless $instrids{$id};
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
&cleanup();
|
||||
|
||||
|
||||
|
||||
####################
|
||||
####################
|
||||
|
||||
|
||||
|
||||
sub parseResponse
|
||||
{
|
||||
my $response = shift;
|
||||
|
||||
#"status":"wait","mafftashid":"Ma8211432R"
|
||||
|
||||
my $status = "";
|
||||
my $mafftashid = "";
|
||||
|
||||
if ( $response =~ /^([^\s:]+):([^\s:]+)$/ )
|
||||
{
|
||||
$mafftashid = $1;
|
||||
$status = $2;
|
||||
}
|
||||
|
||||
return ($status, $mafftashid);
|
||||
|
||||
}
|
||||
|
||||
|
||||
sub extractchecksum
|
||||
{
|
||||
my $infile = shift;
|
||||
my %dataset = ();
|
||||
|
||||
open CSUM, "tar -zxf $infile -O|" or return \%dataset;
|
||||
|
||||
while(<CSUM>)
|
||||
{
|
||||
chomp;
|
||||
if ( /^(\S+)\s+(\S+)$/ )
|
||||
{
|
||||
$dataset{$2} = $1;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
close CSUM;
|
||||
|
||||
return \%dataset;
|
||||
|
||||
}
|
||||
|
||||
|
||||
sub parseError
|
||||
{
|
||||
my $response = shift;
|
||||
|
||||
#"error":"Invalid number of inputs found."
|
||||
my $errorstr = ( $response =~ /\"error\"\s*:\s*\"([^\"]+)\"/ ) ? $1 : "";
|
||||
return $errorstr;
|
||||
}
|
||||
|
||||
|
||||
sub getchecksum
|
||||
{
|
||||
my $infile = shift;
|
||||
|
||||
# md5 binary check
|
||||
my $MD5BIN = "";
|
||||
|
||||
if ( -x "/usr/bin/md5sum" )
|
||||
{
|
||||
$MD5BIN = "/usr/bin/md5sum";
|
||||
}
|
||||
elsif ( -x "/sbin/md5" )
|
||||
{
|
||||
$MD5BIN = "/sbin/md5 -q";
|
||||
}
|
||||
|
||||
return "" if $MD5BIN eq "";
|
||||
|
||||
|
||||
my $checksum = "";
|
||||
open MD5EXE, "$MD5BIN $infile|" or return "";
|
||||
|
||||
while(<MD5EXE>)
|
||||
{
|
||||
if (/^(\S+)\s+(\S+)$/)
|
||||
{
|
||||
$checksum = $1;
|
||||
last;
|
||||
}
|
||||
elsif (/^(\S+)$/)
|
||||
{
|
||||
$checksum = $1;
|
||||
last;
|
||||
}
|
||||
}
|
||||
|
||||
close MD5EXE;
|
||||
|
||||
return $checksum;
|
||||
|
||||
}
|
||||
|
||||
|
||||
sub backticks
|
||||
{
|
||||
my $command = shift;
|
||||
|
||||
`$command`;
|
||||
return ($? == -1) ? 0 : 1;
|
||||
}
|
||||
|
||||
|
||||
sub bail
|
||||
{
|
||||
my $str = shift;
|
||||
print STDERR "$str\n" if defined $str;
|
||||
|
||||
&cleanup();
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
||||
sub cleanup
|
||||
{
|
||||
return if ($TMP eq "" || !-d $TMP);
|
||||
|
||||
opendir(MAINDIR, $TMP);
|
||||
my @files = readdir(MAINDIR);
|
||||
closedir(MAINDIR);
|
||||
|
||||
foreach my $file (@files)
|
||||
{
|
||||
unlink "$TMP/$file" if -e "$TMP/$file";
|
||||
}
|
||||
|
||||
remove_tree($TMP);
|
||||
|
||||
}
|
||||
|
||||
|
||||
sub help
|
||||
{
|
||||
my $str = shift;
|
||||
|
||||
print <<'HELPME';
|
||||
|
||||
USAGE
|
||||
./mafftash_premafft.pl -p [FILE]
|
||||
./mafftash_premafft.pl -o [FILE] -d [DIRECTORY]
|
||||
./mafftash_premafft.pl -p [FILE] -o [FILE] -d [DIRECTORY]
|
||||
|
||||
|
||||
PARAMETERS
|
||||
-p [FILE]
|
||||
FILE contains a list of PDBIDs (one entry per line); make sure that the PDBIDs are in the standard 5-character pdbid+chain naming format
|
||||
|
||||
-o [FILE] -d [DIRECTORY]
|
||||
FILE contains a list of IDs from your own structure/pdb files (one entry per line)
|
||||
for each ID in the list make sure that a corresponding structure file (same ID with .pdb extension) is stored in DIRECTORY
|
||||
|
||||
-h [HATFILE]
|
||||
save the output hat3 file in HATFILE; if not set, the output is written to a file named 'hat3' in your current directory
|
||||
|
||||
-i [INSTRFILE]
|
||||
save the output instr file in INSTRFILE; if not set, the output is written to a file named 'instr' in your current directory
|
||||
|
||||
HELPME
|
||||
|
||||
&bail($str);
|
||||
}
|
||||
|
||||
|
||||
|
120
mafft/src/mafft-7.487-with-extensions/core/maffttext2hex.c
Normal file
120
mafft/src/mafft-7.487-with-extensions/core/maffttext2hex.c
Normal file
|
@ -0,0 +1,120 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
int main( int ac, char **av )
|
||||
{
|
||||
unsigned int c;
|
||||
FILE *fp;
|
||||
unsigned char buf[10000];
|
||||
unsigned char *bpt;
|
||||
char format;
|
||||
|
||||
if( ac == 1 || ( ac == 2 && av[1][0] == '-' ) )
|
||||
{
|
||||
fp = stdin;
|
||||
}
|
||||
else if( ac == 2 )
|
||||
{
|
||||
fp = fopen( av[1], "rb" );
|
||||
if( fp == NULL )
|
||||
{
|
||||
fprintf( stderr, "%s: Cannot open %s.\n", av[0], av[1] );
|
||||
exit( 1 );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf( stderr, "Usage %s input > output\n", av[0] );
|
||||
exit( 1 );
|
||||
}
|
||||
|
||||
#if mingw
|
||||
setmode( fileno( fp ), O_BINARY );
|
||||
#endif
|
||||
|
||||
#if 1
|
||||
format = 'f';
|
||||
c = fgetc( fp );
|
||||
if( c == 'C' ) format = 'c';
|
||||
ungetc( c, fp );
|
||||
#else
|
||||
fgets( (char *)buf, 999, fp );
|
||||
rewind( fp );
|
||||
if( !strncmp( (char *)buf, "CLUSTAL", 7 ) ) format = 'c';
|
||||
else format = 'f';
|
||||
#endif
|
||||
|
||||
if( format == 'c' ) // clustal
|
||||
{
|
||||
int ln = 0;
|
||||
int titlelen = -1;
|
||||
while( 1 )
|
||||
{
|
||||
fgets( (char *)buf, 999, fp );
|
||||
if( feof( fp ) ) break;
|
||||
if( ln == 0 )
|
||||
{
|
||||
ln = 1;
|
||||
printf( "%s", buf );
|
||||
continue;
|
||||
}
|
||||
|
||||
bpt = (unsigned char *)strchr( (char *)buf, ' ' );
|
||||
if( bpt == NULL )
|
||||
{
|
||||
printf( "\n" );
|
||||
continue;
|
||||
}
|
||||
if( titlelen == -1 )
|
||||
{
|
||||
while( *++bpt == ' ' )
|
||||
;
|
||||
titlelen = bpt - buf;
|
||||
}
|
||||
else
|
||||
{
|
||||
bpt = buf + titlelen;
|
||||
}
|
||||
*(bpt-1) = 0;
|
||||
printf( "%s ", buf );
|
||||
|
||||
while( (c=(unsigned int)*bpt++)!='\n' )
|
||||
{
|
||||
if( c == '-' ) printf( "-- " );
|
||||
else if( c == '=' ) printf( "== " );
|
||||
else if( c == '*' ) printf( "** " );
|
||||
else if( c == ' ' ) printf( " " );
|
||||
else printf( "%02x ", c );
|
||||
}
|
||||
printf( "\n" );
|
||||
}
|
||||
}
|
||||
else // fasta
|
||||
{
|
||||
while( 1 )
|
||||
{
|
||||
c = fgetc( fp );
|
||||
if( c == EOF ) break;
|
||||
else if( c == '\n' ) printf( "\n" );
|
||||
else if( c == '\r' ) printf( "\r" ); // nai
|
||||
else if( c == '-' ) printf( "-- " );
|
||||
else if( c == '=' ) printf( "== " ); // nai
|
||||
else if( c == ' ' ) printf( " " ); // nai
|
||||
else if( c == '>' || c == '<' )
|
||||
{
|
||||
printf( "%c", c );
|
||||
while( 1 )
|
||||
{
|
||||
c = fgetc( fp );
|
||||
printf( "%c", c );
|
||||
if( c == '\n' ) break;
|
||||
}
|
||||
}
|
||||
else printf( "%02x ", c );
|
||||
}
|
||||
}
|
||||
fclose( fp );
|
||||
return( 0 );
|
||||
}
|
1300
mafft/src/mafft-7.487-with-extensions/core/makedirectionlist.c
Normal file
1300
mafft/src/mafft-7.487-with-extensions/core/makedirectionlist.c
Normal file
File diff suppressed because it is too large
Load diff
32
mafft/src/mafft-7.487-with-extensions/core/makemergetable.rb
Normal file
32
mafft/src/mafft-7.487-with-extensions/core/makemergetable.rb
Normal file
|
@ -0,0 +1,32 @@
|
|||
#!/bin/env ruby
|
||||
require 'getopts'
|
||||
|
||||
seedoffset = 0
|
||||
|
||||
if getopts( "s:" ) == nil || ARGV.length == 0 || $OPT_h then
|
||||
puts "Usage: #{$0} [-s number_of_seeds] input_files"
|
||||
exit
|
||||
end
|
||||
|
||||
if $OPT_s
|
||||
seedoffset = $OPT_s.to_i
|
||||
end
|
||||
|
||||
|
||||
files = ARGV
|
||||
|
||||
|
||||
num = seedoffset + 1
|
||||
for file in files
|
||||
output = ""
|
||||
STDERR.puts file
|
||||
fp = File.open( file, "r" )
|
||||
while line = fp.gets
|
||||
if line =~ /^>/ then
|
||||
output += " " + num.to_s
|
||||
num += 1
|
||||
end
|
||||
end
|
||||
fp.close
|
||||
puts output + " # " + file
|
||||
end
|
461
mafft/src/mafft-7.487-with-extensions/core/mccaskillwrap.c
Normal file
461
mafft/src/mafft-7.487-with-extensions/core/mccaskillwrap.c
Normal file
|
@ -0,0 +1,461 @@
|
|||
#include "mltaln.h"
|
||||
|
||||
#define DEBUG 0
|
||||
|
||||
static char *whereismccaskillmea;
|
||||
|
||||
#ifdef enablemultithread
|
||||
typedef struct _thread_arg
|
||||
{
|
||||
int thread_no;
|
||||
int njob;
|
||||
int *jobpospt;
|
||||
int **gapmap;
|
||||
char **nogap;
|
||||
int nlenmax;
|
||||
RNApair ***pairprob;
|
||||
pthread_mutex_t *mutex;
|
||||
} thread_arg_t;
|
||||
#endif
|
||||
|
||||
void outmccaskill( FILE *fp, RNApair **pairprob, int length )
|
||||
{
|
||||
int i;
|
||||
RNApair *pt;
|
||||
for( i=0; i<length; i++ ) for( pt=pairprob[i]; pt->bestpos!=-1; pt++ )
|
||||
{
|
||||
if( pt->bestpos > i )
|
||||
fprintf( fp, "%d %d %50.40f\n", i, pt->bestpos, pt->bestscore );
|
||||
}
|
||||
}
|
||||
|
||||
#if 1
|
||||
static void readrawmccaskill( FILE *fp, RNApair **pairprob, int length )
|
||||
{
|
||||
char gett[1000];
|
||||
int *pairnum;
|
||||
int i;
|
||||
int left, right;
|
||||
double prob;
|
||||
|
||||
pairnum = (int *)calloc( length, sizeof( int ) );
|
||||
for( i=0; i<length; i++ ) pairnum[i] = 0;
|
||||
|
||||
while( 1 )
|
||||
{
|
||||
fgets( gett, 999, fp );
|
||||
if( feof( fp ) ) break;
|
||||
if( gett[0] == '>' ) continue;
|
||||
sscanf( gett, "%d %d %lf", &left, &right, &prob );
|
||||
if( prob < 0.01 ) continue; // mxscarna to mafft ryoho ni eikyou
|
||||
//fprintf( stderr, "gett = %s\n", gett );
|
||||
|
||||
if( left != right && prob > 0.0 )
|
||||
{
|
||||
pairprob[left] = (RNApair *)realloc( pairprob[left], (pairnum[left]+2) * sizeof( RNApair ) );
|
||||
pairprob[left][pairnum[left]].bestscore = prob;
|
||||
pairprob[left][pairnum[left]].bestpos = right;
|
||||
pairnum[left]++;
|
||||
pairprob[left][pairnum[left]].bestscore = -1.0;
|
||||
pairprob[left][pairnum[left]].bestpos = -1;
|
||||
// fprintf( stderr, "%d-%d, %f\n", left, right, prob );
|
||||
|
||||
pairprob[right] = (RNApair *)realloc( pairprob[right], (pairnum[right]+2) * sizeof( RNApair ) );
|
||||
pairprob[right][pairnum[right]].bestscore = prob;
|
||||
pairprob[right][pairnum[right]].bestpos = left;
|
||||
pairnum[right]++;
|
||||
pairprob[right][pairnum[right]].bestscore = -1.0;
|
||||
pairprob[right][pairnum[right]].bestpos = -1;
|
||||
// fprintf( stderr, "%d-%d, %f\n", right, left, prob );
|
||||
}
|
||||
}
|
||||
free( pairnum );
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef enablemultithread
|
||||
static void *athread( void *arg )
|
||||
{
|
||||
thread_arg_t *targ = (thread_arg_t *)arg;
|
||||
int thread_no = targ->thread_no;
|
||||
int njob = targ->njob;
|
||||
int *jobpospt = targ->jobpospt;
|
||||
int **gapmap = targ->gapmap;
|
||||
char **nogap = targ->nogap;
|
||||
int nlenmax = targ->nlenmax;
|
||||
RNApair ***pairprob = targ->pairprob;
|
||||
|
||||
int i, res;
|
||||
FILE *infp;
|
||||
char *com;
|
||||
char *dirname;
|
||||
|
||||
dirname = calloc( 100, sizeof( char ) );
|
||||
com = calloc( 1000, sizeof( char ) );
|
||||
|
||||
|
||||
while( 1 )
|
||||
{
|
||||
pthread_mutex_lock( targ->mutex );
|
||||
i = *jobpospt;
|
||||
if( i == njob )
|
||||
{
|
||||
pthread_mutex_unlock( targ->mutex );
|
||||
// return( NULL );
|
||||
break;
|
||||
}
|
||||
*jobpospt = i+1;
|
||||
pthread_mutex_unlock( targ->mutex );
|
||||
|
||||
commongappick_record( 1, nogap+i, gapmap[i] );
|
||||
if( strlen( nogap[i] ) == 0 ) continue;
|
||||
|
||||
sprintf( dirname, "_%d", i );
|
||||
sprintf( com, "rm -rf %s", dirname );
|
||||
system( com );
|
||||
sprintf( com, "mkdir %s", dirname );
|
||||
system( com );
|
||||
|
||||
fprintf( stderr, "%d / %d (by thread %4d)\n", i+1, njob, thread_no );
|
||||
sprintf( com, "%s/_mccaskillinorg", dirname );
|
||||
infp = fopen( com, "w" );
|
||||
// fprintf( infp, ">in\n%s\n", nogap[i] );
|
||||
fprintf( infp, ">in\n" );
|
||||
write1seq( infp, nogap[i] );
|
||||
fclose( infp );
|
||||
|
||||
// sprintf( com, "tr -d '\\r' < %s/_mccaskillinorg > %s/_mccaskillin", dirname, dirname );
|
||||
sprintf( com, "cd %s && tr -d '\\r' < _mccaskillinorg > _mccaskillin && cd ..", dirname );
|
||||
system( com ); // for cygwin, wakaran
|
||||
if( alg == 'G' )
|
||||
sprintf( com, "cd %s; %s/dafs --mafft-out _mccaskillout _mccaskillin > _dum1 2>_dum", dirname, whereismccaskillmea );
|
||||
else
|
||||
// sprintf( com, "cd %s; %s/mxscarnamod -m -writebpp _mccaskillin > _mccaskillout 2>_dum", dirname, whereismccaskillmea );
|
||||
sprintf( com, "cd %s && env PATH=%s mxscarnamod -m -writebpp _mccaskillin > _mccaskillout 2>_dum", dirname, whereismccaskillmea ); // mingw no tame, dirname/bin no kawari ni env PATH
|
||||
res = system( com );
|
||||
|
||||
if( res )
|
||||
{
|
||||
fprintf( stderr, "ERROR IN mccaskill_mea\n" );
|
||||
exit( 1 );
|
||||
}
|
||||
|
||||
sprintf( com, "%s/_mccaskillout", dirname );
|
||||
infp = fopen( com, "r" );
|
||||
readrawmccaskill( infp, pairprob[i], nlenmax );
|
||||
fclose( infp );
|
||||
|
||||
// sprintf( com, "rm -rf \"%s\" > \"/dev/null\" 2>&1", dirname );
|
||||
sprintf( com, "rm -rf \"%s\"", dirname ); // for windows, not use /dev/null
|
||||
if( system( com ) )
|
||||
{
|
||||
fprintf( stderr, "retrying to rmdir\n" );
|
||||
// nanosleep( 100000 );
|
||||
sleep( 1 );
|
||||
system( com );
|
||||
}
|
||||
}
|
||||
free( dirname );
|
||||
free( com );
|
||||
return( NULL );
|
||||
}
|
||||
#endif
|
||||
|
||||
void arguments( int argc, char *argv[] )
|
||||
{
|
||||
int c;
|
||||
nthread = 1;
|
||||
inputfile = NULL;
|
||||
dorp = NOTSPECIFIED;
|
||||
kimuraR = NOTSPECIFIED;
|
||||
pamN = NOTSPECIFIED;
|
||||
whereismccaskillmea = NULL;
|
||||
alg = 's';
|
||||
|
||||
while( --argc > 0 && (*++argv)[0] == '-' )
|
||||
{
|
||||
while ( (c = *++argv[0]) )
|
||||
{
|
||||
switch( c )
|
||||
{
|
||||
case 'i':
|
||||
inputfile = *++argv;
|
||||
fprintf( stderr, "inputfile = %s\n", inputfile );
|
||||
--argc;
|
||||
goto nextoption;
|
||||
case 'd':
|
||||
whereismccaskillmea = *++argv;
|
||||
fprintf( stderr, "whereismccaskillmea = %s\n", whereismccaskillmea );
|
||||
--argc;
|
||||
goto nextoption;
|
||||
case 'C':
|
||||
nthread = myatoi( *++argv );
|
||||
fprintf( stderr, "nthread = %d\n", nthread );
|
||||
--argc;
|
||||
goto nextoption;
|
||||
case 's':
|
||||
alg = 's'; // use scarna; default
|
||||
break;
|
||||
case 'G':
|
||||
alg = 'G'; // use dafs, instead of scarna
|
||||
break;
|
||||
default:
|
||||
fprintf( stderr, "illegal option %c\n", c );
|
||||
argc = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
nextoption:
|
||||
;
|
||||
}
|
||||
if( argc != 0 )
|
||||
{
|
||||
fprintf( stderr, "options: Check source file !\n" );
|
||||
exit( 1 );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int main( int argc, char *argv[] )
|
||||
{
|
||||
static char com[10000];
|
||||
static int *nlen;
|
||||
int left, right;
|
||||
int res;
|
||||
static char **name, **seq, **nogap;
|
||||
static int **gapmap;
|
||||
static int *order;
|
||||
int i, j;
|
||||
FILE *infp;
|
||||
RNApair ***pairprob;
|
||||
RNApair **alnpairprob;
|
||||
RNApair *pairprobpt;
|
||||
RNApair *pt;
|
||||
int *alnpairnum;
|
||||
double prob;
|
||||
int adpos;
|
||||
|
||||
arguments( argc, argv );
|
||||
#ifndef enablemultithread
|
||||
nthread = 0;
|
||||
#endif
|
||||
|
||||
if( inputfile )
|
||||
{
|
||||
infp = fopen( inputfile, "r" );
|
||||
if( !infp )
|
||||
{
|
||||
fprintf( stderr, "Cannot open %s\n", inputfile );
|
||||
exit( 1 );
|
||||
}
|
||||
}
|
||||
else
|
||||
infp = stdin;
|
||||
|
||||
if( !whereismccaskillmea )
|
||||
whereismccaskillmea = "";
|
||||
|
||||
getnumlen( infp );
|
||||
rewind( infp );
|
||||
|
||||
if( dorp != 'd' )
|
||||
{
|
||||
fprintf( stderr, "nuc only\n" );
|
||||
exit( 1 );
|
||||
}
|
||||
|
||||
seq = AllocateCharMtx( njob, nlenmax*2+1 );
|
||||
nogap = AllocateCharMtx( njob, nlenmax*2+1 );
|
||||
gapmap = AllocateIntMtx( njob, nlenmax*2+1 );
|
||||
order = AllocateIntVec( njob );
|
||||
name = AllocateCharMtx( njob, B+1 );
|
||||
nlen = AllocateIntVec( njob );
|
||||
pairprob = (RNApair ***)calloc( njob, sizeof( RNApair ** ) );
|
||||
alnpairprob = (RNApair **)calloc( nlenmax, sizeof( RNApair * ) );
|
||||
alnpairnum = AllocateIntVec( nlenmax );
|
||||
|
||||
for( i=0; i<nlenmax; i++ ) alnpairnum[i] = 0;
|
||||
|
||||
readData_pointer( infp, name, nlen, seq );
|
||||
fclose( infp );
|
||||
|
||||
for( i=0; i<njob; i++ )
|
||||
{
|
||||
pairprob[i] = (RNApair **)calloc( nlenmax, sizeof( RNApair * ) );
|
||||
for( j=0; j<nlenmax; j++ )
|
||||
{
|
||||
pairprob[i][j] = (RNApair *)calloc( 1, sizeof( RNApair ) );
|
||||
pairprob[i][j][0].bestpos = -1;
|
||||
pairprob[i][j][0].bestscore = -1.0;
|
||||
}
|
||||
strcpy( nogap[i], seq[i] );
|
||||
order[i] = i;
|
||||
}
|
||||
for( j=0; j<nlenmax; j++ )
|
||||
{
|
||||
alnpairprob[j] = (RNApair *)calloc( 1, sizeof( RNApair ) );
|
||||
alnpairprob[j][0].bestpos = -1;
|
||||
alnpairprob[j][0].bestscore = -1.0;
|
||||
}
|
||||
|
||||
|
||||
constants( njob, seq );
|
||||
|
||||
if( alg == 'G' )
|
||||
fprintf( stderr, "Running DAFS (Sato et al. 2012; http://www.ncrna.org/).\n" );
|
||||
else
|
||||
fprintf( stderr, "Running mxscarna with the mccaskill_mea mode.\n" );
|
||||
#ifdef enablemultithread
|
||||
if( nthread > 0 )
|
||||
{
|
||||
int jobpos;
|
||||
pthread_t *handle;
|
||||
pthread_mutex_t mutex;
|
||||
thread_arg_t *targ;
|
||||
jobpos = 0;
|
||||
|
||||
targ = calloc( nthread, sizeof( thread_arg_t ) );
|
||||
handle = calloc( nthread, sizeof( pthread_t ) );
|
||||
pthread_mutex_init( &mutex, NULL );
|
||||
|
||||
for( i=0; i<nthread; i++ )
|
||||
{
|
||||
targ[i].thread_no = i;
|
||||
targ[i].njob = njob;
|
||||
targ[i].jobpospt = &jobpos;
|
||||
targ[i].gapmap = gapmap;
|
||||
targ[i].nogap = nogap;
|
||||
targ[i].nlenmax = nlenmax;
|
||||
targ[i].pairprob = pairprob;
|
||||
targ[i].mutex = &mutex;
|
||||
|
||||
// athread( targ );
|
||||
pthread_create( handle+i, NULL, athread, (void *)(targ+i) );
|
||||
|
||||
}
|
||||
|
||||
for( i=0; i<nthread; i++ )
|
||||
{
|
||||
pthread_join( handle[i], NULL );
|
||||
}
|
||||
pthread_mutex_destroy( &mutex );
|
||||
|
||||
free( handle );
|
||||
free( targ );
|
||||
|
||||
|
||||
for( i=0; i<njob; i++ )
|
||||
{
|
||||
fprintf( stdout, ">%d\n", i );
|
||||
outmccaskill( stdout, pairprob[i], nlenmax );
|
||||
}
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
for( i=0; i<njob; i++ )
|
||||
{
|
||||
fprintf( stderr, "%d / %d\n", i+1, njob );
|
||||
commongappick_record( 1, nogap+i, gapmap[i] );
|
||||
if( strlen( nogap[i] ) == 0 )
|
||||
{
|
||||
fprintf( stdout, ">%d\n", i );
|
||||
continue;
|
||||
}
|
||||
|
||||
infp = fopen( "_mccaskillinorg", "w" );
|
||||
// fprintf( infp, ">in\n%s\n", nogap[i] );
|
||||
fprintf( infp, ">in\n" );
|
||||
write1seq( infp, nogap[i] );
|
||||
fclose( infp );
|
||||
|
||||
system( "tr -d '\\r' < _mccaskillinorg > _mccaskillin" ); // for cygwin, wakaran
|
||||
if( alg == 'G' )
|
||||
sprintf( com, "env PATH=%s dafs --mafft-out _mccaskillout _mccaskillin > _dum1 2>_dum", whereismccaskillmea );
|
||||
else
|
||||
sprintf( com, "env PATH=%s mxscarnamod -m -writebpp _mccaskillin > _mccaskillout 2>_dum", whereismccaskillmea );
|
||||
res = system( com );
|
||||
|
||||
if( res )
|
||||
{
|
||||
fprintf( stderr, "ERROR IN mccaskill_mea\n" );
|
||||
exit( 1 );
|
||||
}
|
||||
|
||||
infp = fopen( "_mccaskillout", "r" );
|
||||
readrawmccaskill( infp, pairprob[i], nlenmax );
|
||||
fclose( infp );
|
||||
fprintf( stdout, ">%d\n", i );
|
||||
outmccaskill( stdout, pairprob[i], nlenmax );
|
||||
}
|
||||
}
|
||||
|
||||
for( i=0; i<njob; i++ )
|
||||
{
|
||||
for( j=0; j<nlen[i]; j++ ) for( pairprobpt=pairprob[i][j]; pairprobpt->bestpos!=-1; pairprobpt++ )
|
||||
{
|
||||
left = gapmap[i][j];
|
||||
right = gapmap[i][pairprobpt->bestpos];
|
||||
prob = pairprobpt->bestscore;
|
||||
|
||||
for( pt=alnpairprob[left]; pt->bestpos!=-1; pt++ )
|
||||
if( pt->bestpos == right ) break;
|
||||
|
||||
if( pt->bestpos == -1 )
|
||||
{
|
||||
alnpairprob[left] = (RNApair *)realloc( alnpairprob[left], (alnpairnum[left]+2) * sizeof( RNApair ) );
|
||||
adpos = alnpairnum[left];
|
||||
alnpairnum[left]++;
|
||||
alnpairprob[left][adpos].bestscore = 0.0;
|
||||
alnpairprob[left][adpos].bestpos = right;
|
||||
alnpairprob[left][adpos+1].bestscore = -1.0;
|
||||
alnpairprob[left][adpos+1].bestpos = -1;
|
||||
pt = alnpairprob[left]+adpos;
|
||||
}
|
||||
else
|
||||
adpos = pt-alnpairprob[left];
|
||||
|
||||
pt->bestscore += prob;
|
||||
if( pt->bestpos != right )
|
||||
{
|
||||
fprintf( stderr, "okashii!\n" );
|
||||
exit( 1 );
|
||||
}
|
||||
// fprintf( stderr, "adding %d-%d, %f\n", left, right, prob );
|
||||
}
|
||||
}
|
||||
|
||||
for( i=0; i<njob; i++ )
|
||||
{
|
||||
for( j=0; j<nlenmax; j++ ) free( pairprob[i][j] );
|
||||
free( pairprob[i] );
|
||||
}
|
||||
free( pairprob );
|
||||
for( j=0; j<nlenmax; j++ ) free( alnpairprob[j] );
|
||||
free( alnpairprob );
|
||||
free( alnpairnum );
|
||||
free( order );
|
||||
free( nlen );
|
||||
FreeCharMtx( seq );
|
||||
FreeCharMtx( nogap );
|
||||
FreeCharMtx( name );
|
||||
FreeIntMtx( gapmap );
|
||||
freeconstants();
|
||||
fprintf( stderr, "%d thread(s)\n", nthread );
|
||||
return( 0 );
|
||||
|
||||
#if 0
|
||||
fprintf( stdout, "result=\n" );
|
||||
|
||||
for( i=0; i<nlenmax; i++ ) for( pairprobpt=alnpairprob[i]; pairprobpt->bestpos!=-1; pairprobpt++ )
|
||||
{
|
||||
pairprobpt->bestscore /= (double)njob;
|
||||
left = i;
|
||||
right = pairprobpt->bestpos;
|
||||
prob = pairprobpt->bestscore;
|
||||
fprintf( stdout, "%d-%d, %f\n", left, right, prob );
|
||||
}
|
||||
|
||||
return( 0 );
|
||||
#endif
|
||||
}
|
18
mafft/src/mafft-7.487-with-extensions/core/mingw64mingw32dll
Normal file
18
mafft/src/mafft-7.487-with-extensions/core/mingw64mingw32dll
Normal file
|
@ -0,0 +1,18 @@
|
|||
#!/usr/bin/env bash
|
||||
export PATH=/home/mingw32/mingw32/bin:$PATH
|
||||
export C_INCLUDE_PATH=/home/mingw32/mingw32/include
|
||||
export LIBRARY_PATH=/home/mingw32/mingw32/lib
|
||||
make clean
|
||||
make ENABLE_MULTITHREAD="" dlls
|
||||
rm -rf dll32
|
||||
mkdir dll32
|
||||
mv *.dll dll32/
|
||||
|
||||
export PATH=/home/mingw64/mingw64/bin:$PATH
|
||||
export C_INCLUDE_PATH=/home/mingw64/mingw64/include
|
||||
export LIBRARY_PATH=/home/mingw64/mingw64/lib
|
||||
make clean
|
||||
make ENABLE_MULTITHREAD="" dlls
|
||||
rm -rf dll64
|
||||
mkdir dll64
|
||||
mv *.dll dll64/
|
47
mafft/src/mafft-7.487-with-extensions/core/miyata.h
Normal file
47
mafft/src/mafft-7.487-with-extensions/core/miyata.h
Normal file
|
@ -0,0 +1,47 @@
|
|||
double polarity_[] =
|
||||
{
|
||||
8.1, /* A */
|
||||
10.5, /* R */
|
||||
11.6, /* N */
|
||||
13.0, /* D */
|
||||
5.5, /* C */
|
||||
10.5, /* Q */
|
||||
12.3, /* E */
|
||||
9.0, /* G */
|
||||
10.4, /* H */
|
||||
5.2, /* I */
|
||||
4.9, /* L */
|
||||
11.3, /* K */
|
||||
5.7, /* M */
|
||||
5.2, /* F */
|
||||
8.0, /* P */
|
||||
9.2, /* S */
|
||||
8.6, /* T */
|
||||
5.4, /* W */
|
||||
6.2, /* Y */
|
||||
5.9, /* V */
|
||||
};
|
||||
|
||||
double volume_[] =
|
||||
{
|
||||
31.0, /* A */
|
||||
124.0, /* R */
|
||||
56.0, /* N */
|
||||
54.0, /* D */
|
||||
55.0, /* C */
|
||||
85.0, /* Q */
|
||||
83.0, /* E */
|
||||
3.0, /* G */
|
||||
96.0, /* H */
|
||||
111.0, /* I */
|
||||
111.0, /* L */
|
||||
119.0, /* K */
|
||||
105.0, /* M */
|
||||
132.0, /* F */
|
||||
32.5, /* P */
|
||||
32.0, /* S */
|
||||
61.0, /* T */
|
||||
170.0, /* W */
|
||||
136.0, /* Y */
|
||||
84.0, /* V */
|
||||
};
|
166
mafft/src/mafft-7.487-with-extensions/core/miyata5.h
Normal file
166
mafft/src/mafft-7.487-with-extensions/core/miyata5.h
Normal file
|
@ -0,0 +1,166 @@
|
|||
int locpenaltym = -1440;
|
||||
int exgpm = +0; /* != 0 nisuruto kowareru. exgp ha constants.c de kurikomu */
|
||||
char locaminom[] = "ARNDCQEGHILKMFPSTWYVBZX.-J";
|
||||
char locgrpm[] =
|
||||
{
|
||||
0, 3, 2, 2, 5, 2, 2, 0, 3, 1, 1, 3, 1, 4, 0, 0, 0, 4, 4, 1, 2, 2,
|
||||
6, 6, 6, 1,
|
||||
};
|
||||
int locn_dism[26][26] =
|
||||
{
|
||||
{
|
||||
600, -235, 91, -78, 202, 51, -103, 340, -21, -169,
|
||||
-189, -246, -92, -323, 582, 454, 342, -400, -309, 71,
|
||||
7, -26, -15, -400, 0,-1400,
|
||||
},
|
||||
|
||||
{
|
||||
-235, 600, 17, -69, -275, 277, 185, -400, 365, -112,
|
||||
-149, 485, -55, -106, -229, -183, 20, -178, 22, -95,
|
||||
-26, 231, -15, -400, 0,-1400,
|
||||
},
|
||||
|
||||
{
|
||||
91, 17, 600, 414, -209, 317, 357, 39, 231, -363,
|
||||
-398, 74, -280, -400, 85, 225, 200, -400, -378, -189,
|
||||
507, 337, -15, -400, 0,-1400,
|
||||
},
|
||||
|
||||
{
|
||||
-78, -69, 414, 600, -395, 179, 342, -78, 108, -400,
|
||||
-400, 14, -400, -400, -86, 65, 14, -400, -400, -372,
|
||||
507, 261, -15, -400, 0,-1400,
|
||||
},
|
||||
|
||||
{
|
||||
202, -275, -209, -395, 600, -109, -332, -35, -132, 134,
|
||||
128, -335, 182, -40, 220, 74, 185, -355, -81, 354,
|
||||
-302, -220, -15, -400, 0,-1400,
|
||||
},
|
||||
|
||||
{
|
||||
51, 277, 317, 179, -109, 600, 360, -109, 508, -135,
|
||||
-172, 297, -58, -203, 51, 128, 280, -378, -109, -9,
|
||||
248, 480, -15, -400, 0,-1400,
|
||||
},
|
||||
|
||||
{
|
||||
-103, 185, 357, 342, -332, 360, 600, -195, 325, -369,
|
||||
-400, 274, -295, -400, -109, 11, 77, -400, -321, -249,
|
||||
350, 480, -15, -400, 0,-1400,
|
||||
},
|
||||
|
||||
{
|
||||
340, -400, 39, -78, -35, -109, -195, 600, -195, -400,
|
||||
-400, -400, -355, -400, 322, 357, 114, -400, -400, -189,
|
||||
-19, -152, -15, -400, 0,-1400,
|
||||
},
|
||||
|
||||
{
|
||||
-21, 365, 231, 108, -132, 508, 325, -195, 600, -100,
|
||||
-141, 374, -26, -152, -15, 45, 222, -303, -49, -3,
|
||||
169, 417, -15, -400, 0,-1400,
|
||||
},
|
||||
|
||||
{
|
||||
-169, -112, -363, -400, 134, -135, -369, -400, -100, 600,
|
||||
560, -212, 517, 425, -149, -243, -12, 108, 354, 357,
|
||||
-400, -252, -15, -400, 0,-1400,
|
||||
},
|
||||
|
||||
{
|
||||
-189, -149, -398, -400, 128, -172, -400, -400, -141, 560,
|
||||
600, -252, 482, 420, -172, -269, -43, 105, 331, 340,
|
||||
-400, -290, -15, -400, 0,-1400,
|
||||
},
|
||||
|
||||
{
|
||||
-246, 485, 74, 14, -335, 297, 274, -400, 374, -212,
|
||||
-252, 600, -152, -215, -240, -175, -1, -289, -92, -172,
|
||||
44, 285, -15, -400, 0,-1400,
|
||||
},
|
||||
|
||||
{
|
||||
-92, -55, -280, -400, 182, -58, -295, -355, -26, 517,
|
||||
482, -152, 600, 365, -75, -163, 68, 59, 334, 422,
|
||||
-368, -176, -15, -400, 0,-1400,
|
||||
},
|
||||
|
||||
{
|
||||
-323, -106, -400, -400, -40, -203, -400, -400, -152, 425,
|
||||
420, -215, 365, 600, -306, -386, -143, 282, 462, 191,
|
||||
-400, -315, -15, -400, 0,-1400,
|
||||
},
|
||||
|
||||
{
|
||||
582, -229, 85, -86, 220, 51, -109, 322, -15, -149,
|
||||
-172, -240, -75, -306, 600, 440, 351, -400, -292, 88,
|
||||
0, -29, -15, -400, 0,-1400,
|
||||
},
|
||||
|
||||
{
|
||||
454, -183, 225, 65, 74, 128, 11, 357, 45, -243,
|
||||
-269, -175, -163, -386, 440, 600, 345, -400, -352, -15,
|
||||
145, 70, -15, -400, 0,-1400,
|
||||
},
|
||||
|
||||
{
|
||||
342, 20, 200, 14, 185, 280, 77, 114, 222, -12,
|
||||
-43, -1, 68, -143, 351, 345, 600, -400, -100, 194,
|
||||
107, 178, -15, -400, 0,-1400,
|
||||
},
|
||||
|
||||
{
|
||||
-400, -178, -400, -400, -355, -378, -400, -400, -303, 108,
|
||||
105, -289, 59, 282, -400, -400, -400, 600, 297, -118,
|
||||
-400, -400, -15, -400, 0,-1400,
|
||||
},
|
||||
|
||||
{
|
||||
-309, 22, -378, -400, -81, -109, -321, -400, -49, 354,
|
||||
331, -92, 334, 462, -292, -352, -100, 297, 600, 165,
|
||||
-400, -215, -15, -400, 0,-1400,
|
||||
},
|
||||
|
||||
{
|
||||
71, -95, -189, -372, 354, -9, -249, -189, -3, 357,
|
||||
340, -172, 422, 191, 88, -15, 194, -118, 165, 600,
|
||||
-280, -129, -15, -400, 0,-1400,
|
||||
},
|
||||
|
||||
{
|
||||
7, -26, 507, 507, -302, 248, 350, -19, 169, -400,
|
||||
-400, 44, -368, -400, 0, 145, 107, -400, -400, -280,
|
||||
507, 299, -400, -400, 0,-1400,
|
||||
},
|
||||
|
||||
{
|
||||
-26, 231, 337, 261, -220, 480, 480, -152, 417, -252,
|
||||
-290, 285, -176, -315, -29, 70, 178, -400, -215, -129,
|
||||
299, 480, -400, -400, 0,-1400,
|
||||
},
|
||||
|
||||
{
|
||||
-15, -15, -15, -15, -15, -15, -15, -15, -15, -15,
|
||||
-15, -15, -15, -15, -15, -15, -15, -15, -15, -15,
|
||||
-400, -400, -400, -400, 0,-1400,
|
||||
},
|
||||
|
||||
{
|
||||
-400, -400, -400, -400, -400, -400, -400, -400, -400, -400,
|
||||
-400, -400, -400, -400, -400, -400, -400, -400, -400, -400,
|
||||
-400, -400, -400, -400, 0,-1400,
|
||||
},
|
||||
|
||||
{
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0,
|
||||
},
|
||||
|
||||
{
|
||||
-1400,-1400,-1400,-1400,-1400,-1400,-1400,-1400,-1400,-1400,
|
||||
-1400,-1400,-1400,-1400,-1400,-1400,-1400,-1400,-1400,-1400,
|
||||
-1400,-1400,-1400,-1400, 0, 1600,
|
||||
},
|
||||
};
|
387
mafft/src/mafft-7.487-with-extensions/core/mltaln.h
Normal file
387
mafft/src/mafft-7.487-with-extensions/core/mltaln.h
Normal file
|
@ -0,0 +1,387 @@
|
|||
#define USE_XCED 0
|
||||
|
||||
#define _XOPEN_SOURCE
|
||||
|
||||
#if USE_XCED
|
||||
#include "config.h"
|
||||
#include "share.h"
|
||||
#else
|
||||
#endif
|
||||
|
||||
#include "mafft.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stddef.h>
|
||||
#include <sys/types.h>
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
#include <ctype.h>
|
||||
#include "mtxutl.h"
|
||||
//#include <double.h>
|
||||
#include <limits.h>
|
||||
#include <stdarg.h>
|
||||
#ifdef enablemultithread
|
||||
#include <pthread.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
#endif
|
||||
#ifndef _MSC_VER
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
#if !defined(mingw) && !defined(_MSC_VER)
|
||||
#include <sys/resource.h> // for setstacksize, 2016/Jun
|
||||
#include <sys/shm.h> // shared memory
|
||||
#include <sys/mman.h> // shm_open
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#define VERSION "7.487"
|
||||
#define SHOWVERSION reporterr( "%s (%s) Version " VERSION "\nalg=%c, model=%s, amax=%3.1f\n%d thread(s)\n\n", progName( argv[0] ), (dorp=='d')?"nuc":((nblosum==-2)?"text":"aa"), alg, modelname, specificityconsideration, nthread )
|
||||
|
||||
#define FFT_THRESHOLD 80
|
||||
#define FFT_WINSIZE_P 20
|
||||
#define FFT_WINSIZE_D 100
|
||||
#define DISPSEQF 60
|
||||
#define DISPSITEI 0
|
||||
#define MAXITERATION 500
|
||||
#define M 500000 /* njob no saidaiti */
|
||||
#define N 5000000 /* nlen no saidaiti */
|
||||
#define MAXSEG 100000
|
||||
#define B 256
|
||||
#define C 60 /* 1 gyou no mojisuu */
|
||||
#define D 6
|
||||
#define DFORMAT "%#6.3f"
|
||||
#define rnd() ( ( 1.0 / ( RAND_MAX + 1.0 ) ) * rand() )
|
||||
#define MAX(X,Y) ( ((X)>(Y))?(X):(Y) )
|
||||
#define MIN(X,Y) ( ((X)<(Y))?(X):(Y) )
|
||||
#define G(X) ( ((X)>(0))?(X):(0) )
|
||||
#define BEFF 1.0 /* 0.6 ni suruto zureru */
|
||||
#define WIN 3
|
||||
#define SGAPP -1000
|
||||
#define GETA2 0.001
|
||||
#define GETA3 0.001
|
||||
#define NOTSPECIFIED 100009
|
||||
#define SUEFF 0.1 /* upg/(spg+upg) -> sueff.sed */
|
||||
#define DIVLOCAL 0
|
||||
#define INTMTXSCALE 1000000.0
|
||||
#define JTT 201
|
||||
#define TM 202
|
||||
|
||||
extern char modelname[500];
|
||||
extern int njob, nlenmax;
|
||||
extern int amino_n[0x100];
|
||||
extern char amino_grp[0x100];
|
||||
//extern int amino_dis[0x100][0x100];
|
||||
extern int **amino_dis;
|
||||
extern double **n_disLN;
|
||||
//extern double amino_dis_consweight_multi[0x100][0x100];
|
||||
extern double **amino_dis_consweight_multi;
|
||||
extern int **n_dis;
|
||||
extern int **n_disFFT;
|
||||
extern double **n_dis_consweight_multi;
|
||||
extern unsigned char amino[0x100];
|
||||
extern double polarity[0x100];
|
||||
extern double volume[0x100];
|
||||
extern int ribosumdis[37][37];
|
||||
|
||||
extern int ppid;
|
||||
extern double thrinter;
|
||||
extern double fastathreshold;
|
||||
extern int pslocal, ppslocal;
|
||||
extern int constraint;
|
||||
extern int divpairscore;
|
||||
extern int fmodel; // 1-> fmodel 0->default -1->raw
|
||||
extern int nblosum; // 45, 50, 62, 80
|
||||
extern int kobetsubunkatsu;
|
||||
extern int bunkatsu;
|
||||
extern int dorp;
|
||||
extern int niter;
|
||||
extern int contin;
|
||||
extern int calledByXced;
|
||||
extern int devide;
|
||||
extern int scmtd;
|
||||
extern int weight;
|
||||
extern int utree;
|
||||
extern int tbutree;
|
||||
extern int refine;
|
||||
extern int check;
|
||||
extern double cut;
|
||||
extern int cooling;
|
||||
extern int trywarp;
|
||||
extern int penalty, ppenalty, penaltyLN;
|
||||
extern int penalty_dist, ppenalty_dist;
|
||||
extern int RNApenalty, RNAppenalty;
|
||||
extern int RNApenalty_ex, RNAppenalty_ex;
|
||||
extern int penalty_ex, ppenalty_ex, penalty_exLN;
|
||||
extern int penalty_EX, ppenalty_EX;
|
||||
extern int penalty_OP, ppenalty_OP;
|
||||
extern int penalty_shift;
|
||||
extern double penalty_shift_factor;
|
||||
extern int offset, poffset, offsetLN, offsetFFT;
|
||||
extern int RNAthr, RNApthr;
|
||||
extern int scoremtx;
|
||||
extern int TMorJTT;
|
||||
extern char use_fft;
|
||||
extern char force_fft;
|
||||
extern int nevermemsave;
|
||||
extern int fftscore;
|
||||
extern int fftWinSize;
|
||||
extern int fftThreshold;
|
||||
extern int fftRepeatStop;
|
||||
extern int fftNoAnchStop;
|
||||
extern int divWinSize;
|
||||
extern int divThreshold;
|
||||
extern int disp;
|
||||
extern int outgap;
|
||||
extern char alg;
|
||||
extern int cnst;
|
||||
extern int mix;
|
||||
extern int tbitr;
|
||||
extern int tbweight;
|
||||
extern int tbrweight;
|
||||
extern int disopt;
|
||||
extern int pamN;
|
||||
extern int checkC;
|
||||
extern double geta2;
|
||||
extern int treemethod;
|
||||
extern int kimuraR;
|
||||
extern char *swopt;
|
||||
extern int fftkeika;
|
||||
extern int score_check;
|
||||
extern char *inputfile;
|
||||
extern char *addfile;
|
||||
extern int addprofile;
|
||||
extern double consweight_multi;
|
||||
extern double consweight_rna;
|
||||
extern char RNAscoremtx;
|
||||
|
||||
extern char *signalSM;
|
||||
extern FILE *prep_g;
|
||||
extern FILE *trap_g;
|
||||
extern char **seq_g;
|
||||
extern char **res_g;
|
||||
extern int rnakozo;
|
||||
extern char rnaprediction;
|
||||
|
||||
/* sengen no ichi ha koko dake de ha nai */
|
||||
extern void constants();
|
||||
extern char **Calignm1();
|
||||
extern char **Dalignm1();
|
||||
extern char **align0();
|
||||
extern double Cscore_m_1( char **, int, int, double ** );
|
||||
extern double score_m_1( char **, int, int, double ** );
|
||||
extern double score_calc0( char **, int, double **, int );
|
||||
extern char seqcheck( char ** );
|
||||
extern double substitution( char *, char * );
|
||||
extern double substitution_score( char *, char * );
|
||||
extern double substitution_nid( char *, char * );
|
||||
extern double substitution_hosei( char *, char * );
|
||||
extern double ipower( double, int );
|
||||
extern double translate_and_Calign();
|
||||
extern double A__align();
|
||||
extern double A__align11();
|
||||
extern double A__align_gapmap();
|
||||
extern double partA__align();
|
||||
extern double L__align11( double **scoringmtx, double scoreoffset, char **seq1, char **seq2, int alloclen, int *off1pt, int *off2pt );
|
||||
extern double G__align11();
|
||||
extern double Falign();
|
||||
extern double Falign_localhom();
|
||||
extern double Conalign();
|
||||
extern double Aalign();
|
||||
extern double imp_match_out_sc( int, int );
|
||||
extern double part_imp_match_out_sc( int, int );
|
||||
extern void ErrorExit();
|
||||
extern void cpmx_calc();
|
||||
extern void intergroup_score( char **, char **, double *, double *, int, int, int, double * );
|
||||
extern int conjuctionfortbfast();
|
||||
extern int fastconjuction();
|
||||
extern char seqcheck( char ** );
|
||||
|
||||
typedef struct _LocalHom
|
||||
{
|
||||
struct _LocalHom *next;
|
||||
struct _LocalHom *last;
|
||||
int start1;
|
||||
int end1;
|
||||
int start2;
|
||||
int end2;
|
||||
double opt;
|
||||
int overlapaa;
|
||||
int extended;
|
||||
double importance;
|
||||
double rimportance;
|
||||
// double fimportance;
|
||||
// double wimportance;
|
||||
char korh;
|
||||
int nokori;
|
||||
} LocalHom;
|
||||
|
||||
typedef struct _NodeInCub
|
||||
{
|
||||
int step;
|
||||
int LorR;
|
||||
} NodeInCub;
|
||||
|
||||
typedef struct _Node
|
||||
{
|
||||
struct _Node *children[3];
|
||||
int tmpChildren[3];
|
||||
double length[3];
|
||||
double *weightptr[3];
|
||||
int top[3];
|
||||
int *members[3];
|
||||
} Node;
|
||||
|
||||
typedef struct _Segment
|
||||
{
|
||||
int start;
|
||||
int end;
|
||||
int center;
|
||||
double score;
|
||||
int skipForeward;
|
||||
int skipBackward;
|
||||
struct _Segment *pair;
|
||||
int number;
|
||||
} Segment;
|
||||
|
||||
typedef struct _Segments
|
||||
{
|
||||
Segment group1;
|
||||
Segment group2;
|
||||
int number1;
|
||||
int number2;
|
||||
} Segments;
|
||||
|
||||
typedef struct _Bchain
|
||||
{
|
||||
struct _Bchain *next;
|
||||
struct _Bchain *prev;
|
||||
int pos;
|
||||
} Bchain;
|
||||
|
||||
typedef struct _Achain
|
||||
{
|
||||
int next;
|
||||
int prev;
|
||||
// int curr;
|
||||
} Achain;
|
||||
|
||||
|
||||
typedef struct _Fukusosuu
|
||||
{
|
||||
double R;
|
||||
double I;
|
||||
} Fukusosuu;
|
||||
|
||||
typedef struct _Gappattern
|
||||
{
|
||||
int len;
|
||||
double freq;
|
||||
} Gappat;
|
||||
|
||||
typedef struct _RNApair
|
||||
{
|
||||
int uppos;
|
||||
double upscore;
|
||||
int downpos;
|
||||
double downscore;
|
||||
int bestpos;
|
||||
double bestscore;
|
||||
} RNApair;
|
||||
|
||||
typedef struct _Treedep
|
||||
{
|
||||
int child0;
|
||||
int child1;
|
||||
int done;
|
||||
double distfromtip;
|
||||
} Treedep;
|
||||
|
||||
typedef struct _Addtree
|
||||
{
|
||||
int nearest;
|
||||
double dist1;
|
||||
char *neighbors;
|
||||
double dist2;
|
||||
} Addtree;
|
||||
|
||||
typedef struct _lennum
|
||||
{
|
||||
int len;
|
||||
int num;
|
||||
} Lennum;
|
||||
|
||||
typedef struct _pairnum
|
||||
{
|
||||
unsigned long long npairs;
|
||||
int num;
|
||||
int n0;
|
||||
int n1;
|
||||
} Pairnum;
|
||||
|
||||
typedef struct _extanch
|
||||
{
|
||||
int i;
|
||||
int j;
|
||||
int starti;
|
||||
int endi;
|
||||
int startj;
|
||||
int endj;
|
||||
int score;
|
||||
} ExtAnch;
|
||||
|
||||
#include "fft.h"
|
||||
#include "dp.h"
|
||||
#include "functions.h"
|
||||
|
||||
#ifdef enablemultithread
|
||||
#define TLS __thread
|
||||
#else
|
||||
#define TLS
|
||||
#endif
|
||||
|
||||
extern TLS int commonAlloc1;
|
||||
extern TLS int commonAlloc2;
|
||||
extern TLS int **commonIP;
|
||||
extern TLS int **commonJP;
|
||||
extern int nthread;
|
||||
extern int nthreadreadlh;
|
||||
extern int nthreadpair;
|
||||
extern int randomseed;
|
||||
extern int parallelizationstrategy;
|
||||
#define BESTFIRST 0
|
||||
#define BAATARI0 1
|
||||
#define BAATARI1 2
|
||||
#define BAATARI2 3
|
||||
|
||||
extern int scoreout;
|
||||
extern int spscoreout;
|
||||
extern int outnumber;
|
||||
|
||||
extern int legacygapcost;
|
||||
extern double minimumweight;
|
||||
extern int nwildcard;
|
||||
|
||||
extern TLS char *newgapstr;
|
||||
|
||||
extern int nalphabets;
|
||||
extern int nscoredalphabets;
|
||||
extern double specificityconsideration;
|
||||
extern int ndistclass, maxdistclass;
|
||||
|
||||
extern int gmsg;
|
||||
|
||||
extern double sueff_global;
|
||||
extern double lenfaca, lenfacb, lenfacc, lenfacd;
|
||||
extern int maxl, tsize;
|
||||
|
||||
|
||||
/* for --large */
|
||||
extern int compacttree;
|
||||
extern int lhlimit;
|
||||
extern int specifictarget;
|
||||
#define HAT3NODEBLOCK 500
|
||||
extern int nadd;
|
||||
extern int usenaivescoreinsteadofalignmentscore;
|
||||
#define MYBUFSIZE 1000 * 1000 * 100 // 100MB
|
15764
mafft/src/mafft-7.487-with-extensions/core/mltaln9.c
Normal file
15764
mafft/src/mafft-7.487-with-extensions/core/mltaln9.c
Normal file
File diff suppressed because it is too large
Load diff
637
mafft/src/mafft-7.487-with-extensions/core/mtxutl.c
Normal file
637
mafft/src/mafft-7.487-with-extensions/core/mtxutl.c
Normal file
|
@ -0,0 +1,637 @@
|
|||
#include <stdio.h>
|
||||
#include <stddef.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "mtxutl.h"
|
||||
|
||||
void MtxuntDouble( double **mtx, int n )
|
||||
{
|
||||
int i, j;
|
||||
for( i=0; i<n; i++ ) for( j=0; j<n; j++ ) mtx[i][j] = 0.0;
|
||||
for( i=0; i<n; i++ ) mtx[i][i] = 1.0;
|
||||
}
|
||||
|
||||
void MtxmltDouble( double **mtx1, double **mtx2, int n )
|
||||
{
|
||||
int i, j, k;
|
||||
double s, *tmp;
|
||||
|
||||
tmp = (double *)calloc( n, sizeof( double ) );
|
||||
for( i=0; i<n; i++ )
|
||||
{
|
||||
for( k=0; k<n; k++ ) tmp[k] = mtx1[i][k];
|
||||
for( j=0; j<n; j++ )
|
||||
{
|
||||
s = 0.0;
|
||||
for( k=0; k<n; k++ ) s += tmp[k] * mtx2[k][j];
|
||||
mtx1[i][j] = s;
|
||||
}
|
||||
}
|
||||
free( tmp );
|
||||
}
|
||||
|
||||
char *AllocateCharVec( int l1 )
|
||||
{
|
||||
char *cvec;
|
||||
|
||||
cvec = (char *)calloc( l1, sizeof( char ) );
|
||||
if( cvec == NULL )
|
||||
{
|
||||
fprintf( stderr, "Cannot allocate %d character vector.\n", l1 );
|
||||
exit( 1 );
|
||||
}
|
||||
return( cvec );
|
||||
}
|
||||
|
||||
#if 0
|
||||
void ReallocateCharMtx( char **mtx, int l1, int l2 )
|
||||
{
|
||||
int i;
|
||||
char *bk = (char *)malloc( l2+1 ); // hontou ha iranai
|
||||
if( bk == NULL )
|
||||
{
|
||||
fprintf( stderr, "Cannot allocate bk in ReallocateCharMtx\n" );
|
||||
exit( 1 );
|
||||
}
|
||||
for( i=0; i<l1; i++ )
|
||||
{
|
||||
#if 1
|
||||
strcpy( bk, mtx[i] );
|
||||
mtx[i] = (char *)realloc( mtx[i], (l2+1) * sizeof( char ) );
|
||||
if( mtx[i] == NULL )
|
||||
{
|
||||
fprintf( stderr, "Cannot reallocate %d x %d character matrix.\n", l1, l2 );
|
||||
}
|
||||
if( strcmp( bk, mtx[i] ) ) // hontou ha iranai
|
||||
{
|
||||
fprintf( stderr, "changed!! \n%s\n \nto\n%s\n in realloc..\n", bk, mtx[i] );
|
||||
strcpy( mtx[i], bk );
|
||||
}
|
||||
#else
|
||||
strcpy( bk, mtx[i] );
|
||||
free( mtx[i] );
|
||||
mtx[i] = (char *)calloc( (l2+1), sizeof( char ) );
|
||||
strcpy( mtx[i], bk );
|
||||
#endif
|
||||
}
|
||||
free( bk ); // hontou ha iranai
|
||||
}
|
||||
#else
|
||||
void ReallocateCharMtx( char **mtx, int l1, int l2 )
|
||||
{
|
||||
int i;
|
||||
for( i=0; i<l1; i++ )
|
||||
{
|
||||
mtx[i] = (char *)realloc( mtx[i], (l2+1) * sizeof( char ) );
|
||||
if( mtx[i] == NULL )
|
||||
{
|
||||
fprintf( stderr, "Cannot reallocate %d x %d character matrix.\n", l1, l2 );
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
char **AllocateCharMtx( int l1, int l2 )
|
||||
{
|
||||
int i;
|
||||
char **cmtx;
|
||||
|
||||
cmtx = (char **)calloc( l1+1, sizeof( char * ) );
|
||||
if( cmtx == NULL )
|
||||
{
|
||||
fprintf( stderr, "Cannot allocate %d x %d character matrix.\n", l1, l2 );
|
||||
exit( 1 );
|
||||
}
|
||||
if( l2 )
|
||||
{
|
||||
for( i=0; i<l1; i++ )
|
||||
{
|
||||
cmtx[i] = AllocateCharVec( l2 );
|
||||
}
|
||||
}
|
||||
cmtx[l1] = NULL;
|
||||
return( cmtx );
|
||||
}
|
||||
|
||||
void FreeCharMtx( char **mtx )
|
||||
{
|
||||
/*
|
||||
char **x;
|
||||
x = mtx;
|
||||
while( *x != NULL ) free( *x++ );
|
||||
free( mtx );
|
||||
*/
|
||||
int i;
|
||||
for( i=0; mtx[i]; i++ )
|
||||
{
|
||||
free( mtx[i] );
|
||||
}
|
||||
free( mtx );
|
||||
}
|
||||
|
||||
double *AllocateFloatVec( int l1 )
|
||||
{
|
||||
double *vec;
|
||||
|
||||
vec = (double *)calloc( (unsigned int)l1, sizeof( double ) );
|
||||
if( vec == NULL )
|
||||
{
|
||||
fprintf( stderr, "Allocation error ( %d fload vec )\n", l1 );
|
||||
exit( 1 );
|
||||
}
|
||||
return( vec );
|
||||
}
|
||||
|
||||
void FreeFloatVec( double *vec )
|
||||
{
|
||||
free( (char *)vec );
|
||||
}
|
||||
|
||||
double **AllocateFloatHalfMtx( int ll1 )
|
||||
{
|
||||
double **mtx;
|
||||
int i;
|
||||
|
||||
mtx = (double **)calloc( (unsigned int)ll1+1, sizeof( double * ) );
|
||||
if( mtx == NULL )
|
||||
{
|
||||
fprintf( stderr, "Allocation error ( %d fload halfmtx )\n", ll1 );
|
||||
exit( 1 );
|
||||
}
|
||||
for( i=0; i<ll1; i++ )
|
||||
{
|
||||
mtx[i] = (double *)calloc( ll1-i, sizeof( double ) );
|
||||
if( !mtx[i] )
|
||||
{
|
||||
fprintf( stderr, "Allocation error( %d doublehalfmtx )\n", ll1 );
|
||||
exit( 1 );
|
||||
}
|
||||
}
|
||||
mtx[ll1] = NULL;
|
||||
return( mtx );
|
||||
}
|
||||
|
||||
double **AllocateFloatMtx( int ll1, int ll2 )
|
||||
{
|
||||
double **mtx;
|
||||
int i;
|
||||
|
||||
mtx = (double **)calloc( (unsigned int)ll1+1, sizeof( double * ) );
|
||||
if( mtx == NULL )
|
||||
{
|
||||
fprintf( stderr, "Allocation error ( %d x %d fload mtx )\n", ll1, ll2 );
|
||||
exit( 1 );
|
||||
}
|
||||
if( ll2 )
|
||||
{
|
||||
for( i=0; i<ll1; i++ )
|
||||
{
|
||||
mtx[i] = (double *)calloc( ll2, sizeof( double ) );
|
||||
if( !mtx[i] )
|
||||
{
|
||||
fprintf( stderr, "Allocation error( %d x %d doublemtx )\n", ll1, ll2 );
|
||||
exit( 1 );
|
||||
}
|
||||
}
|
||||
}
|
||||
mtx[ll1] = NULL;
|
||||
return( mtx );
|
||||
}
|
||||
|
||||
void FreeFloatHalfMtx( double **mtx, int n )
|
||||
{
|
||||
int i;
|
||||
|
||||
for( i=0; i<n; i++ )
|
||||
{
|
||||
if( mtx[i] ) FreeFloatVec( mtx[i] ); mtx[i] = NULL;
|
||||
}
|
||||
free( mtx );
|
||||
}
|
||||
void FreeFloatMtx( double **mtx )
|
||||
{
|
||||
int i;
|
||||
|
||||
for( i=0; mtx[i]; i++ )
|
||||
{
|
||||
if( mtx[i] ) FreeFloatVec( mtx[i] ); mtx[i] = NULL;
|
||||
}
|
||||
free( mtx );
|
||||
}
|
||||
|
||||
int *AllocateIntVecLarge( unsigned long long ll1 )
|
||||
{
|
||||
int *vec;
|
||||
|
||||
vec = (int *)calloc( ll1, sizeof( int ) );
|
||||
if( vec == NULL )
|
||||
{
|
||||
fprintf( stderr, "Allocation error( %lld int vec )\n", ll1 );
|
||||
exit( 1 );
|
||||
}
|
||||
return( vec );
|
||||
}
|
||||
|
||||
int *AllocateIntVec( int ll1 )
|
||||
{
|
||||
int *vec;
|
||||
|
||||
vec = (int *)calloc( ll1, sizeof( int ) );
|
||||
if( vec == NULL )
|
||||
{
|
||||
fprintf( stderr, "Allocation error( %d int vec )\n", ll1 );
|
||||
exit( 1 );
|
||||
}
|
||||
return( vec );
|
||||
}
|
||||
|
||||
void FreeIntVec( int *vec )
|
||||
{
|
||||
free( (char *)vec );
|
||||
}
|
||||
|
||||
double **AllocateFloatTri( int ll1 )
|
||||
{
|
||||
double **tri;
|
||||
int i;
|
||||
|
||||
tri = (double **)calloc( (unsigned int)ll1+1, sizeof( double * ) );
|
||||
if( !tri )
|
||||
{
|
||||
fprintf( stderr, "Allocation error ( double tri )\n" );
|
||||
exit( 1 );
|
||||
}
|
||||
for( i=0; i<ll1; i++ )
|
||||
{
|
||||
tri[i] = AllocateFloatVec( i+3 );
|
||||
}
|
||||
tri[ll1] = NULL;
|
||||
|
||||
return( tri );
|
||||
}
|
||||
|
||||
void FreeFloatTri( double **tri )
|
||||
{
|
||||
/*
|
||||
double **x;
|
||||
x = tri;
|
||||
while( *tri != NULL ) free( *tri++ );
|
||||
free( x );
|
||||
*/
|
||||
int i;
|
||||
for( i=0; tri[i]; i++ )
|
||||
free( tri[i] );
|
||||
free( tri );
|
||||
}
|
||||
|
||||
int **AllocateIntMtx( int ll1, int ll2 )
|
||||
{
|
||||
int i;
|
||||
int **mtx;
|
||||
|
||||
mtx = (int **)calloc( ll1+1, sizeof( int * ) );
|
||||
if( !mtx )
|
||||
{
|
||||
fprintf( stderr, "Allocation error( %d x %d int mtx )\n", ll1, ll2 );
|
||||
exit( 1 );
|
||||
}
|
||||
if( ll2 )
|
||||
{
|
||||
for( i=0; i<ll1; i++ ) mtx[i] = AllocateIntVec( ll2 );
|
||||
}
|
||||
else
|
||||
{
|
||||
for( i=0; i<ll1; i++ ) mtx[i] = NULL;
|
||||
}
|
||||
mtx[ll1] = NULL;
|
||||
return( mtx );
|
||||
}
|
||||
|
||||
int **AllocateIntMtxLarge( unsigned long long ll1, unsigned long long ll2 )
|
||||
{
|
||||
unsigned long long i;
|
||||
int **mtx;
|
||||
|
||||
mtx = (int **)calloc( ll1+1, sizeof( int * ) );
|
||||
if( !mtx )
|
||||
{
|
||||
fprintf( stderr, "Allocation error( %lld x %lld int mtx )\n", ll1, ll2 );
|
||||
exit( 1 );
|
||||
}
|
||||
if( ll2 )
|
||||
{
|
||||
for( i=0; i<ll1; i++ ) mtx[i] = AllocateIntVecLarge( ll2 );
|
||||
}
|
||||
else
|
||||
{
|
||||
for( i=0; i<ll1; i++ ) mtx[i] = NULL;
|
||||
}
|
||||
mtx[ll1] = NULL;
|
||||
return( mtx );
|
||||
}
|
||||
|
||||
/*
|
||||
void FreeIntMtx( int **mtx )
|
||||
{
|
||||
*
|
||||
int **x;
|
||||
x = mtx;
|
||||
while( !*mtx ) free( *mtx++ );
|
||||
free( x );
|
||||
*
|
||||
int i;
|
||||
for( i=0; mtx[i] != NULL; i++ )
|
||||
free( (char *)mtx[i] );
|
||||
free( (char *)mtx );
|
||||
}
|
||||
*/
|
||||
|
||||
char ***AllocateCharCub( int ll1, int ll2, int ll3 )
|
||||
{
|
||||
int i;
|
||||
char ***cub;
|
||||
|
||||
cub = (char ***)calloc( ll1+1, sizeof( char ** ) );
|
||||
if( !cub )
|
||||
{
|
||||
fprintf( stderr, "Allocation error( %d x %d x %d char cube\n", ll1, ll2, ll3 );
|
||||
exit( 1 );
|
||||
}
|
||||
if( ll2 )
|
||||
{
|
||||
for( i=0; i<ll1; i++ )
|
||||
{
|
||||
cub[i] = AllocateCharMtx( ll2, ll3 );
|
||||
}
|
||||
}
|
||||
cub[ll1] = NULL;
|
||||
return( cub );
|
||||
}
|
||||
|
||||
void FreeCharCub( char ***cub )
|
||||
{
|
||||
int i;
|
||||
|
||||
for( i=0; cub[i]; i++ )
|
||||
{
|
||||
FreeCharMtx( cub[i] );
|
||||
}
|
||||
free( cub );
|
||||
}
|
||||
|
||||
void freeintmtx( int **mtx, int ll1 )
|
||||
{
|
||||
int i;
|
||||
|
||||
for( i=0; i<ll1; i++ ) free( (char *)mtx[i] );
|
||||
free( (char *)mtx );
|
||||
}
|
||||
|
||||
void FreeIntMtx( int **mtx )
|
||||
{
|
||||
int i;
|
||||
|
||||
for( i=0; mtx[i]; i++ )
|
||||
{
|
||||
if( mtx[i] ) free( (char *)mtx[i] ); mtx[i] = NULL;
|
||||
}
|
||||
free( (char *)mtx );
|
||||
}
|
||||
|
||||
char ****AllocateCharHcu( int ll1, int ll2, int ll3, int ll4 )
|
||||
{
|
||||
int i;
|
||||
char ****hcu;
|
||||
|
||||
hcu = (char ****)calloc( ll1+1, sizeof( char *** ) );
|
||||
if( hcu == NULL ) exit( 1 );
|
||||
for( i=0; i<ll1; i++ )
|
||||
hcu[i] = AllocateCharCub( ll2, ll3, ll4 );
|
||||
hcu[ll1] = NULL;
|
||||
return( hcu );
|
||||
}
|
||||
|
||||
void FreeCharHcu( char ****hcu )
|
||||
{
|
||||
int i;
|
||||
for( i=0; hcu[i]; i++ )
|
||||
{
|
||||
FreeCharCub( hcu[i] );
|
||||
}
|
||||
free ( (char *)hcu );
|
||||
}
|
||||
|
||||
double *AllocateDoubleVec( int ll1 )
|
||||
{
|
||||
double *vec;
|
||||
|
||||
vec = (double *)calloc( ll1, sizeof( double ) ); // filled with 0.0
|
||||
return( vec );
|
||||
}
|
||||
|
||||
void FreeDoubleVec( double *vec )
|
||||
{
|
||||
free( vec );
|
||||
}
|
||||
|
||||
int ***AllocateIntCub( int ll1, int ll2, int ll3 )
|
||||
{
|
||||
int i;
|
||||
int ***cub;
|
||||
|
||||
cub = (int ***)calloc( ll1+1, sizeof( int ** ) );
|
||||
if( cub == NULL )
|
||||
{
|
||||
fprintf( stderr, "cannot allocate IntCub\n" );
|
||||
exit( 1 );
|
||||
}
|
||||
for( i=0; i<ll1; i++ )
|
||||
cub[i] = AllocateIntMtx( ll2, ll3 );
|
||||
cub[ll1] = NULL;
|
||||
|
||||
return cub;
|
||||
}
|
||||
|
||||
void FreeIntCub( int ***cub )
|
||||
{
|
||||
int i;
|
||||
for( i=0; cub[i]; i++ )
|
||||
{
|
||||
if( cub[i] ) FreeIntMtx( cub[i] ); cub[i] = NULL;
|
||||
}
|
||||
free( cub );
|
||||
}
|
||||
|
||||
double **AllocateDoubleHalfMtx( int ll1 )
|
||||
{
|
||||
double **mtx;
|
||||
int i;
|
||||
|
||||
mtx = (double **)calloc( (unsigned int)ll1+1, sizeof( double * ) );
|
||||
if( mtx == NULL )
|
||||
{
|
||||
fprintf( stderr, "Allocation error ( %d double halfmtx )\n", ll1 );
|
||||
exit( 1 );
|
||||
}
|
||||
for( i=0; i<ll1; i++ )
|
||||
{
|
||||
mtx[i] = (double *)calloc( ll1-i, sizeof( double ) );
|
||||
if( !mtx[i] )
|
||||
{
|
||||
fprintf( stderr, "Allocation error( %d double halfmtx )\n", ll1 );
|
||||
exit( 1 );
|
||||
}
|
||||
}
|
||||
mtx[ll1] = NULL;
|
||||
return( mtx );
|
||||
}
|
||||
|
||||
double **AllocateDoubleMtx( int ll1, int ll2 )
|
||||
{
|
||||
int i;
|
||||
double **mtx;
|
||||
mtx = (double **)calloc( ll1+1, sizeof( double * ) );
|
||||
if( !mtx )
|
||||
{
|
||||
fprintf( stderr, "cannot allocate DoubleMtx\n" );
|
||||
exit( 1 );
|
||||
}
|
||||
if( ll2 )
|
||||
{
|
||||
for( i=0; i<ll1; i++ )
|
||||
mtx[i] = AllocateDoubleVec( ll2 );
|
||||
}
|
||||
mtx[ll1] = NULL;
|
||||
|
||||
return mtx;
|
||||
}
|
||||
|
||||
void FreeDoubleHalfMtx( double **mtx, int n )
|
||||
{
|
||||
int i;
|
||||
|
||||
for( i=0; i<n; i++ )
|
||||
{
|
||||
if( mtx[i] ) FreeFloatVec( mtx[i] ); mtx[i] = NULL;
|
||||
}
|
||||
free( mtx );
|
||||
}
|
||||
void FreeDoubleMtx( double **mtx )
|
||||
{
|
||||
int i;
|
||||
for( i=0; mtx[i]; i++ )
|
||||
{
|
||||
FreeDoubleVec( mtx[i] );
|
||||
mtx[i] = NULL;
|
||||
}
|
||||
free( mtx );
|
||||
}
|
||||
|
||||
double ***AllocateFloatCub( int ll1, int ll2, int ll3 )
|
||||
{
|
||||
int i;
|
||||
double ***cub;
|
||||
|
||||
cub = (double ***)calloc( ll1+1, sizeof( double ** ) );
|
||||
if( !cub )
|
||||
{
|
||||
fprintf( stderr, "cannot allocate double cube.\n" );
|
||||
exit( 1 );
|
||||
}
|
||||
for( i=0; i<ll1; i++ )
|
||||
{
|
||||
cub[i] = AllocateFloatMtx( ll2, ll3 );
|
||||
}
|
||||
cub[ll1] = NULL;
|
||||
return( cub );
|
||||
}
|
||||
|
||||
void FreeFloatCub( double ***cub )
|
||||
{
|
||||
int i;
|
||||
|
||||
for( i=0; cub[i]; i++ )
|
||||
{
|
||||
FreeFloatMtx( cub[i] );
|
||||
}
|
||||
free( cub );
|
||||
}
|
||||
|
||||
double ***AllocateDoubleCub( int ll1, int ll2, int ll3 )
|
||||
{
|
||||
int i;
|
||||
double ***cub;
|
||||
|
||||
cub = (double ***)calloc( ll1+1, sizeof( double ** ) );
|
||||
if( !cub )
|
||||
{
|
||||
fprintf( stderr, "cannot allocate double cube.\n" );
|
||||
exit( 1 );
|
||||
}
|
||||
for( i=0; i<ll1; i++ )
|
||||
{
|
||||
cub[i] = AllocateDoubleMtx( ll2, ll3 );
|
||||
}
|
||||
cub[ll1] = NULL;
|
||||
return( cub );
|
||||
}
|
||||
|
||||
void FreeDoubleCub( double ***cub )
|
||||
{
|
||||
int i;
|
||||
|
||||
for( i=0; cub[i]; i++ )
|
||||
{
|
||||
FreeDoubleMtx( cub[i] );
|
||||
}
|
||||
free( cub );
|
||||
}
|
||||
|
||||
|
||||
short *AllocateShortVec( int ll1 )
|
||||
{
|
||||
short *vec;
|
||||
|
||||
vec = (short *)calloc( ll1, sizeof( short ) );
|
||||
if( vec == NULL )
|
||||
{
|
||||
fprintf( stderr, "Allocation error( %d short vec )\n", ll1 );
|
||||
exit( 1 );
|
||||
}
|
||||
return( vec );
|
||||
}
|
||||
|
||||
void FreeShortVec( short *vec )
|
||||
{
|
||||
free( (char *)vec );
|
||||
}
|
||||
|
||||
short **AllocateShortMtx( int ll1, int ll2 )
|
||||
{
|
||||
int i;
|
||||
short **mtx;
|
||||
|
||||
|
||||
mtx = (short **)calloc( ll1+1, sizeof( short * ) );
|
||||
if( !mtx )
|
||||
{
|
||||
fprintf( stderr, "Allocation error( %d x %d short mtx ) \n", ll1, ll2 );
|
||||
exit( 1 );
|
||||
}
|
||||
for( i=0; i<ll1; i++ )
|
||||
{
|
||||
mtx[i] = AllocateShortVec( ll2 );
|
||||
}
|
||||
mtx[ll1] = NULL;
|
||||
return( mtx );
|
||||
}
|
||||
|
||||
void FreeShortMtx( short **mtx )
|
||||
{
|
||||
int i;
|
||||
|
||||
for( i=0; mtx[i]; i++ )
|
||||
free( (char *)mtx[i] );
|
||||
free( (char *)mtx );
|
||||
}
|
||||
|
56
mafft/src/mafft-7.487-with-extensions/core/mtxutl.h
Normal file
56
mafft/src/mafft-7.487-with-extensions/core/mtxutl.h
Normal file
|
@ -0,0 +1,56 @@
|
|||
void MtxuntDouble( double **, int );
|
||||
void MtxmltDouble( double **, double **, int );
|
||||
|
||||
char *AllocateCharVec( int );
|
||||
void FreeCharVec( char * );
|
||||
|
||||
char **AllocateCharMtx( int, int);
|
||||
void ReallocateCharMtx( char **, int, int);
|
||||
void FreeCharMtx( char ** );
|
||||
|
||||
double *AllocateFloatVec( int );
|
||||
void FreeFloatVec( double * );
|
||||
|
||||
double **AllocateFloatHalfMtx( int );
|
||||
double **AllocateFloatMtx( int, int );
|
||||
void FreeFloatHalfMtx( double **, int );
|
||||
void FreeFloatMtx( double ** );
|
||||
|
||||
double **AlocateFloatTri( int );
|
||||
void FreeFloatTri( double ** );
|
||||
|
||||
int *AllocateIntVec( int );
|
||||
int *AllocateIntVecLarge( unsigned long long );
|
||||
void FreeIntVec( int * );
|
||||
|
||||
int **AllocateIntMtx( int, int );
|
||||
int **AllocateIntMtxLarge( unsigned long long, unsigned long long );
|
||||
void FreeIntMtx( int ** );
|
||||
|
||||
char ***AllocateCharCub( int, int, int );
|
||||
void FreeCharCub( char *** );
|
||||
|
||||
int ***AllocateIntCub( int, int, int );
|
||||
void FreeIntCub( int *** );
|
||||
|
||||
double *AllocateDoubleVec( int );
|
||||
void FreeDoubleVec( double * );
|
||||
|
||||
double **AllocateDoubleHalfMtx( int );
|
||||
double **AllocateDoubleMtx( int, int );
|
||||
void FreeDoubleHalfMtx( double **, int );
|
||||
void FreeDoubleMtx( double ** );
|
||||
|
||||
double ***AllocateDoubleCub( int, int, int );
|
||||
void FreeDoubleCub( double *** );
|
||||
|
||||
double ***AllocateFloatCub( int, int, int );
|
||||
void FreeFloatCub( double *** );
|
||||
|
||||
short *AllocateShortVec( int );
|
||||
void FreeShortVec( short * );
|
||||
|
||||
short **AllocateShortMtx( int, int );
|
||||
void FreeShortMtx( short ** );
|
||||
|
||||
void freeintmtx( int **, int );
|
390
mafft/src/mafft-7.487-with-extensions/core/multi2hat3s.c
Normal file
390
mafft/src/mafft-7.487-with-extensions/core/multi2hat3s.c
Normal file
|
@ -0,0 +1,390 @@
|
|||
#include "mltaln.h"
|
||||
|
||||
#define DEBUG 0
|
||||
#define IODEBUG 0
|
||||
#define SCOREOUT 1
|
||||
#define TSUYOSAFACTOR 100
|
||||
|
||||
|
||||
static int nhomologs;
|
||||
static int seedoffset;
|
||||
|
||||
void strip( char *s )
|
||||
{
|
||||
char *pt = s;
|
||||
while( *++pt )
|
||||
if( *pt == '\n' ) *pt = 0;
|
||||
}
|
||||
|
||||
|
||||
void arguments( int argc, char *argv[] )
|
||||
{
|
||||
int c;
|
||||
|
||||
seedoffset = 0;
|
||||
nhomologs = 1;
|
||||
inputfile = NULL;
|
||||
fftkeika = 0;
|
||||
pslocal = -1000.0;
|
||||
constraint = 0;
|
||||
nblosum = 62;
|
||||
fmodel = 0;
|
||||
calledByXced = 0;
|
||||
devide = 0;
|
||||
use_fft = 0;
|
||||
fftscore = 1;
|
||||
fftRepeatStop = 0;
|
||||
fftNoAnchStop = 0;
|
||||
weight = 3;
|
||||
utree = 1;
|
||||
tbutree = 1;
|
||||
refine = 0;
|
||||
check = 1;
|
||||
cut = 0.0;
|
||||
disp = 0;
|
||||
outgap = 1;
|
||||
alg = 'A';
|
||||
mix = 0;
|
||||
tbitr = 0;
|
||||
scmtd = 5;
|
||||
tbweight = 0;
|
||||
tbrweight = 3;
|
||||
checkC = 0;
|
||||
treemethod = 'x';
|
||||
contin = 0;
|
||||
scoremtx = 1;
|
||||
kobetsubunkatsu = 0;
|
||||
divpairscore = 0;
|
||||
dorp = NOTSPECIFIED;
|
||||
ppenalty = NOTSPECIFIED;
|
||||
ppenalty_OP = NOTSPECIFIED;
|
||||
ppenalty_ex = NOTSPECIFIED;
|
||||
ppenalty_EX = NOTSPECIFIED;
|
||||
poffset = NOTSPECIFIED;
|
||||
kimuraR = NOTSPECIFIED;
|
||||
pamN = NOTSPECIFIED;
|
||||
geta2 = GETA2;
|
||||
fftWinSize = NOTSPECIFIED;
|
||||
fftThreshold = NOTSPECIFIED;
|
||||
|
||||
while( --argc > 0 && (*++argv)[0] == '-' )
|
||||
{
|
||||
while ( ( c = *++argv[0] ) )
|
||||
{
|
||||
switch( c )
|
||||
{
|
||||
case 'i':
|
||||
inputfile = *++argv;
|
||||
fprintf( stderr, "seed = %s\n", inputfile );
|
||||
--argc;
|
||||
goto nextoption;
|
||||
case 't':
|
||||
nhomologs = myatoi( *++argv );
|
||||
fprintf( stderr, "nhomologs = %d\n", nhomologs );
|
||||
--argc;
|
||||
goto nextoption;
|
||||
case 'o':
|
||||
seedoffset = myatoi( *++argv );
|
||||
fprintf( stderr, "seedoffset = %d\n", seedoffset );
|
||||
--argc;
|
||||
goto nextoption;
|
||||
case 'D':
|
||||
dorp = 'd';
|
||||
break;
|
||||
case 'P':
|
||||
dorp = 'p';
|
||||
break;
|
||||
default:
|
||||
fprintf( stderr, "illegal option %c\n", c );
|
||||
argc = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
nextoption:
|
||||
;
|
||||
}
|
||||
if( argc == 1 )
|
||||
{
|
||||
cut = atof( (*argv) );
|
||||
argc--;
|
||||
}
|
||||
if( argc != 0 )
|
||||
{
|
||||
fprintf( stderr, "options: Check source file !\n" );
|
||||
exit( 1 );
|
||||
}
|
||||
if( tbitr == 1 && outgap == 0 )
|
||||
{
|
||||
fprintf( stderr, "conflicting options : o, m or u\n" );
|
||||
exit( 1 );
|
||||
}
|
||||
if( alg == 'C' && outgap == 0 )
|
||||
{
|
||||
fprintf( stderr, "conflicting options : C, o\n" );
|
||||
exit( 1 );
|
||||
}
|
||||
}
|
||||
|
||||
int countamino( char *s, int end )
|
||||
{
|
||||
int val = 0;
|
||||
while( end-- )
|
||||
if( *s++ != '-' ) val++;
|
||||
return( val );
|
||||
}
|
||||
|
||||
static void pairalign( char **name, int nlen[M], char **seq, double *effarr, int alloclen )
|
||||
{
|
||||
int i, j;
|
||||
FILE *hat3p;
|
||||
double pscore = 0.0; // by D.Mathog
|
||||
static double *effarr1 = NULL;
|
||||
static double *effarr2 = NULL;
|
||||
char *aseq;
|
||||
static char **pseq;
|
||||
LocalHom **localhomtable, *tmpptr;
|
||||
double tsuyosa;
|
||||
|
||||
if( nhomologs < 1 ) nhomologs = 1; // tsuyosa=0.0 wo sakeru
|
||||
tsuyosa = (double)nhomologs * nhomologs * TSUYOSAFACTOR;
|
||||
fprintf( stderr, "tsuyosa = %f\n", tsuyosa );
|
||||
localhomtable = (LocalHom **)calloc( njob, sizeof( LocalHom *) );
|
||||
for( i=0; i<njob; i++)
|
||||
{
|
||||
localhomtable[i] = (LocalHom *)calloc( njob, sizeof( LocalHom ) );
|
||||
for( j=0; j<njob; j++)
|
||||
{
|
||||
localhomtable[i][j].start1 = -1;
|
||||
localhomtable[i][j].end1 = -1;
|
||||
localhomtable[i][j].start2 = -1;
|
||||
localhomtable[i][j].end2 = -1;
|
||||
localhomtable[i][j].opt = -1.0;
|
||||
localhomtable[i][j].next = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
if( effarr1 == NULL )
|
||||
{
|
||||
effarr1 = AllocateDoubleVec( njob );
|
||||
effarr2 = AllocateDoubleVec( njob );
|
||||
pseq = AllocateCharMtx( 2, 0 );
|
||||
aseq = AllocateCharVec( nlenmax*9+1 );
|
||||
#if 0
|
||||
#else
|
||||
#endif
|
||||
}
|
||||
|
||||
#if 0
|
||||
fprintf( stderr, "##### fftwinsize = %d, fftthreshold = %d\n", fftWinSize, fftThreshold );
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
for( i=0; i<njob; i++ )
|
||||
fprintf( stderr, "TBFAST effarr[%d] = %f\n", i, effarr[i] );
|
||||
#endif
|
||||
|
||||
|
||||
// writePre( njob, name, nlen, aseq, 0 );
|
||||
|
||||
hat3p = fopen( "hat3", "w" );
|
||||
if( !hat3p ) ErrorExit( "Cannot open hat3." );
|
||||
fprintf( stderr, "\n" );
|
||||
for( i=0; i<njob-1; i++ )
|
||||
{
|
||||
for( j=i+1; j<njob; j++ )
|
||||
{
|
||||
pseq[0] = seq[i];
|
||||
pseq[1] = seq[j];
|
||||
|
||||
if( strlen( pseq[0] ) != strlen( pseq[1] ) )
|
||||
{
|
||||
fprintf( stderr, "## ERROR ###\n" );
|
||||
fprintf( stderr, "Not aligned, %s - %s\n", name[i], name[j] );
|
||||
fprintf( stderr, "## ERROR ###\n" );
|
||||
exit( 1 );
|
||||
}
|
||||
|
||||
|
||||
fprintf( stderr, "adding %d-%d\r", i, j );
|
||||
putlocalhom2( pseq[0], pseq[1], localhomtable[i]+j, 0, 0, (int)pscore, strlen( pseq[0] ), 'k' );
|
||||
for( tmpptr=localhomtable[i]+j; tmpptr; tmpptr=tmpptr->next )
|
||||
{
|
||||
if( tmpptr->opt == -1.0 ) continue;
|
||||
if( tmpptr->start1 == -1 ) continue;
|
||||
fprintf( hat3p, "%d %d %d %6.3f %d %d %d %d k\n", i+seedoffset, j+seedoffset, tmpptr->overlapaa, tmpptr->opt * tsuyosa, tmpptr->start1, tmpptr->end1, tmpptr->start2, tmpptr->end2 );
|
||||
}
|
||||
}
|
||||
}
|
||||
fprintf( stderr, "\n" );
|
||||
fclose( hat3p );
|
||||
|
||||
#if DEBUG
|
||||
fprintf( stderr, "calling FreeLocalHomTable\n" );
|
||||
#endif
|
||||
FreeLocalHomTable( localhomtable, njob );
|
||||
#if DEBUG
|
||||
fprintf( stderr, "done. FreeLocalHomTable\n" );
|
||||
#endif
|
||||
}
|
||||
|
||||
static void WriteOptions( FILE *fp )
|
||||
{
|
||||
|
||||
if( dorp == 'd' ) fprintf( fp, "DNA\n" );
|
||||
else
|
||||
{
|
||||
if ( scoremtx == 0 ) fprintf( fp, "JTT %dPAM\n", pamN );
|
||||
else if( scoremtx == 1 ) fprintf( fp, "BLOSUM %d\n", nblosum );
|
||||
else if( scoremtx == 2 ) fprintf( fp, "M-Y\n" );
|
||||
}
|
||||
fprintf( stderr, "Gap Penalty = %+5.2f, %+5.2f, %+5.2f\n", (double)ppenalty/1000, (double)ppenalty_ex/1000, (double)poffset/1000 );
|
||||
if( use_fft ) fprintf( fp, "FFT on\n" );
|
||||
|
||||
fprintf( fp, "tree-base method\n" );
|
||||
if( tbrweight == 0 ) fprintf( fp, "unweighted\n" );
|
||||
else if( tbrweight == 3 ) fprintf( fp, "clustalw-like weighting\n" );
|
||||
if( tbitr || tbweight )
|
||||
{
|
||||
fprintf( fp, "iterate at each step\n" );
|
||||
if( tbitr && tbrweight == 0 ) fprintf( fp, " unweighted\n" );
|
||||
if( tbitr && tbrweight == 3 ) fprintf( fp, " reversely weighted\n" );
|
||||
if( tbweight ) fprintf( fp, " weighted\n" );
|
||||
fprintf( fp, "\n" );
|
||||
}
|
||||
|
||||
fprintf( fp, "Gap Penalty = %+5.2f, %+5.2f, %+5.2f\n", (double)ppenalty/1000, (double)ppenalty_ex/1000, (double)poffset/1000 );
|
||||
|
||||
if( alg == 'a' )
|
||||
fprintf( fp, "Algorithm A\n" );
|
||||
else if( alg == 'A' )
|
||||
fprintf( fp, "Algorithm A+\n" );
|
||||
else if( alg == 'S' )
|
||||
fprintf( fp, "Apgorithm S\n" );
|
||||
else if( alg == 'C' )
|
||||
fprintf( fp, "Apgorithm A+/C\n" );
|
||||
else
|
||||
fprintf( fp, "Unknown algorithm\n" );
|
||||
|
||||
if( treemethod == 'x' )
|
||||
fprintf( fp, "Tree = UPGMA (3).\n" );
|
||||
else if( treemethod == 's' )
|
||||
fprintf( fp, "Tree = UPGMA (2).\n" );
|
||||
else if( treemethod == 'p' )
|
||||
fprintf( fp, "Tree = UPGMA (1).\n" );
|
||||
else
|
||||
fprintf( fp, "Unknown tree.\n" );
|
||||
|
||||
if( use_fft )
|
||||
{
|
||||
fprintf( fp, "FFT on\n" );
|
||||
if( dorp == 'd' )
|
||||
fprintf( fp, "Basis : 4 nucleotides\n" );
|
||||
else
|
||||
{
|
||||
if( fftscore )
|
||||
fprintf( fp, "Basis : Polarity and Volume\n" );
|
||||
else
|
||||
fprintf( fp, "Basis : 20 amino acids\n" );
|
||||
}
|
||||
fprintf( fp, "Threshold of anchors = %d%%\n", fftThreshold );
|
||||
fprintf( fp, "window size of anchors = %dsites\n", fftWinSize );
|
||||
}
|
||||
else
|
||||
fprintf( fp, "FFT off\n" );
|
||||
fflush( fp );
|
||||
}
|
||||
|
||||
|
||||
int main( int argc, char *argv[] )
|
||||
{
|
||||
static int nlen[M];
|
||||
static char **name, **seq;
|
||||
static char **bseq;
|
||||
static double *eff;
|
||||
int i;
|
||||
char c;
|
||||
int alloclen;
|
||||
FILE *infp;
|
||||
|
||||
arguments( argc, argv );
|
||||
|
||||
if( inputfile )
|
||||
{
|
||||
infp = fopen( inputfile, "r" );
|
||||
if( !infp )
|
||||
{
|
||||
fprintf( stderr, "Cannot open %s\n", inputfile );
|
||||
exit( 1 );
|
||||
}
|
||||
}
|
||||
else
|
||||
infp = stdin;
|
||||
|
||||
getnumlen( infp );
|
||||
rewind( infp );
|
||||
|
||||
if( njob < 2 )
|
||||
{
|
||||
fprintf( stderr, "At least 2 sequences should be input!\n"
|
||||
"Only %d sequence found.\n", njob );
|
||||
exit( 1 );
|
||||
}
|
||||
|
||||
name = AllocateCharMtx( njob, B+1 );
|
||||
seq = AllocateCharMtx( njob, nlenmax*9+1 );
|
||||
bseq = AllocateCharMtx( njob, nlenmax*9+1 );
|
||||
alloclen = nlenmax*9;
|
||||
|
||||
eff = AllocateDoubleVec( njob );
|
||||
|
||||
#if 0
|
||||
Read( name, nlen, seq );
|
||||
#else
|
||||
readData_pointer( infp, name, nlen, seq );
|
||||
#endif
|
||||
fclose( infp );
|
||||
|
||||
constants( njob, seq );
|
||||
|
||||
#if 0
|
||||
fprintf( stderr, "params = %d, %d, %d\n", penalty, penalty_ex, offset );
|
||||
#endif
|
||||
|
||||
initSignalSM();
|
||||
|
||||
initFiles();
|
||||
|
||||
WriteOptions( trap_g );
|
||||
|
||||
c = seqcheck( seq );
|
||||
if( c )
|
||||
{
|
||||
fprintf( stderr, "Illeagal character %c\n", c );
|
||||
exit( 1 );
|
||||
}
|
||||
|
||||
// writePre( njob, name, nlen, seq, 0 );
|
||||
|
||||
for( i=0; i<njob; i++ ) eff[i] = 1.0;
|
||||
|
||||
|
||||
for( i=0; i<njob; i++ ) gappick0( bseq[i], seq[i] );
|
||||
|
||||
|
||||
// for( i=0; i<njob; i++ ) fprintf( stdout, ">_seed_%s\n%s\n", name[i]+1, bseq[i] ); // CHUUI!!
|
||||
for( i=0; i<njob; i++ ) fprintf( stdout, ">_seed_%s\n%s\n", name[i]+1, seq[i] );
|
||||
|
||||
pairalign( name, nlen, seq, eff, alloclen );
|
||||
|
||||
fprintf( trap_g, "done.\n" );
|
||||
#if DEBUG
|
||||
fprintf( stderr, "closing trap_g\n" );
|
||||
#endif
|
||||
fclose( trap_g );
|
||||
|
||||
#if IODEBUG
|
||||
fprintf( stderr, "OSHIMAI\n" );
|
||||
#endif
|
||||
SHOWVERSION;
|
||||
return( 0 );
|
||||
}
|
134
mafft/src/mafft-7.487-with-extensions/core/newick2mafft.rb
Normal file
134
mafft/src/mafft-7.487-with-extensions/core/newick2mafft.rb
Normal file
|
@ -0,0 +1,134 @@
|
|||
#! /usr/bin/env ruby
|
||||
|
||||
#version 2, 2009/Jan/24
|
||||
#version 3, 2015/Dec/8
|
||||
|
||||
|
||||
if ARGV.length == 1
|
||||
scale = 1.0
|
||||
elsif ARGV.length == 2
|
||||
scale = ARGV.shift.to_f
|
||||
else
|
||||
STDERR.puts "USAGE: newick2mafft.rb scale input_tree > output"
|
||||
exit
|
||||
end
|
||||
|
||||
if scale <= 0.0 then
|
||||
STDERR.puts "Inappropriate scale, #{scale.to_s}"
|
||||
exit
|
||||
end
|
||||
|
||||
STDERR.puts "scale = " + scale.to_s
|
||||
|
||||
infp = File.open( ARGV.shift, "r" )
|
||||
|
||||
tree = ""
|
||||
while line = infp.gets
|
||||
tree += line.strip
|
||||
break if tree =~ /;$/
|
||||
end
|
||||
infp.close
|
||||
|
||||
|
||||
#tree = tree.gsub( /_.*?:/, ":" ).gsub(/[0-9]\.[0-9]*e-[0-9][0-9]/, "0").gsub(/\[.*?\]/,"").gsub(/ /, "").gsub(/:\-[0-9\.]+/, ":0.0" )
|
||||
#tree = tree.gsub( /_.*?:/, ":" ).gsub(/[0-9]\.[0-9]*e-[0-9][0-9]/, "0").gsub(/\[.*?\]/,"").gsub(/ /, "")
|
||||
tree = tree.gsub( /_.*?:/, ":" ).gsub(/[0-9\.]*[eE]-[0-9]*/, "0").gsub(/\[.*?\]/,"").gsub(/ /, "")
|
||||
|
||||
|
||||
STDERR.puts "Initial tree = " + tree
|
||||
|
||||
def resolve( tree )
|
||||
|
||||
|
||||
while 1
|
||||
# p tree
|
||||
tree.sub!( /\,([0-9]+):(\-?[0-9\.]+)\,([0-9]+):(\-?[0-9\.]+)/, ",XXX" )
|
||||
hit1 = $1
|
||||
hit2 = $2
|
||||
hit3 = $3
|
||||
hit4 = $4
|
||||
|
||||
# p hit1
|
||||
# p hit2
|
||||
# p hit3
|
||||
# p hit4
|
||||
|
||||
# puts "introduce XXX"
|
||||
# p tree
|
||||
|
||||
break unless tree.index(/XXX/)
|
||||
|
||||
poshit = tree.index(/XXX/)
|
||||
# puts "poshit=" + poshit.to_s
|
||||
|
||||
i = poshit
|
||||
height = 0
|
||||
while i >= 0
|
||||
break if height == 0 && tree[i..i] == '('
|
||||
if tree[i..i] == ')' then
|
||||
height += 1
|
||||
elsif tree[i..i] == '(' then
|
||||
height -= 1
|
||||
end
|
||||
i -= 1
|
||||
end
|
||||
|
||||
poskakko = i
|
||||
# puts "poskakko = " + poskakko.to_s
|
||||
zenhan = tree[0..poskakko]
|
||||
zenhan = "" if poskakko == -1
|
||||
# puts "zenhan = " + zenhan
|
||||
|
||||
treelen = tree.length
|
||||
tree = zenhan + "(" + tree[poskakko+1..treelen]
|
||||
# puts "add ("
|
||||
# p tree
|
||||
tree.sub!( /XXX/, "#{hit1}:#{hit2}):0,#{hit3}:#{hit4}" )
|
||||
|
||||
# p tree
|
||||
end
|
||||
|
||||
|
||||
return tree
|
||||
|
||||
end
|
||||
|
||||
memi = [-1,-1]
|
||||
leni = [-1,-1]
|
||||
|
||||
while tree.index( /\(/ )
|
||||
|
||||
tree = resolve( tree )
|
||||
|
||||
tree.sub!( /\(([0-9]+):(\-?[0-9\.]+),([0-9]+):(\-?[0-9\.]+)\)/, "XXX" )
|
||||
memi[0] = $1.to_i
|
||||
leni[0] = $2.to_f * scale
|
||||
memi[1] = $3.to_i
|
||||
leni[1] = $4.to_f * scale
|
||||
|
||||
if leni[0] > 10 || leni[1] > 10 then
|
||||
STDERR.puts ""
|
||||
STDERR.puts "Please check the scale of branch length!"
|
||||
STDERR.puts "The unit of branch lengths must be 'substitution/site'"
|
||||
STDERR.puts "If the unit is 'substition' in your tree, please"
|
||||
STDERR.puts "use the scale argument,"
|
||||
STDERR.puts "% newick2mafft scale in > out"
|
||||
STDERR.puts "where scale = 1/(alignment length)"
|
||||
STDERR.puts ""
|
||||
exit 1
|
||||
end
|
||||
|
||||
# STDERR.puts "subtree = " + $&
|
||||
|
||||
if memi[1] < memi[0] then
|
||||
memi.reverse!
|
||||
leni.reverse!
|
||||
end
|
||||
|
||||
tree.sub!( /XXX/, memi[0].to_s )
|
||||
|
||||
# STDERR.puts "Tree = " + tree
|
||||
|
||||
printf( "%5d %5d %10.5f %10.5f\n", memi[0], memi[1], leni[0], leni[1] )
|
||||
|
||||
end
|
195
mafft/src/mafft-7.487-with-extensions/core/nj.c
Normal file
195
mafft/src/mafft-7.487-with-extensions/core/nj.c
Normal file
|
@ -0,0 +1,195 @@
|
|||
#include "mltaln.h"
|
||||
#define DEBUG 0
|
||||
|
||||
|
||||
void topolcpy( int s1[], int s2[], int *mpt1, int *mpt2 )
|
||||
{
|
||||
int i;
|
||||
|
||||
*mpt1 = *mpt2;
|
||||
for( i=0; i<*mpt2; i++ )
|
||||
{
|
||||
s1[i] = s2[i];
|
||||
}
|
||||
}
|
||||
|
||||
void topolcat( int s1[], int s2[], int *mpt1, int *mpt2 )
|
||||
{
|
||||
int i;
|
||||
|
||||
for( i=*mpt1; i<*mpt1+*mpt2; i++ )
|
||||
{
|
||||
s1[i] = s2[i-*mpt1];
|
||||
}
|
||||
*mpt1 += *mpt2;
|
||||
}
|
||||
|
||||
void topolsort( int m, int s[] )
|
||||
{
|
||||
int i, j, im;
|
||||
int sm;
|
||||
|
||||
for( j=0; j<m-1; j++ )
|
||||
{
|
||||
sm = s[j]; im = j;
|
||||
for( i=j+1; i<m; i++ )
|
||||
{
|
||||
if( s[i] < sm )
|
||||
{
|
||||
sm = s[i];
|
||||
im = i;
|
||||
}
|
||||
}
|
||||
s[im] = s[j]; s[j] = sm;
|
||||
}
|
||||
}
|
||||
|
||||
void topolswap( int s1[], int s2[], int *mpt1, int *mpt2 )
|
||||
{
|
||||
int i;
|
||||
int im;
|
||||
int b;
|
||||
b = *mpt1; *mpt1 = *mpt2; *mpt2 = b;
|
||||
im = MAX(*mpt1,*mpt2);
|
||||
for( i=0; i<im; i++ )
|
||||
{
|
||||
b = s1[i]; s1[i] = s2[i]; s2[i] = b;
|
||||
/*
|
||||
printf( "s1[%d]=%d\ns2[%d]=%d\n", i, s1[i], i, s2[i] );
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
void reduc( double **mtx, int nseq, int im, int jm )
|
||||
{
|
||||
int i;
|
||||
for( i=0; i<nseq; i++ )
|
||||
{
|
||||
if( i==im || i==jm
|
||||
|| mtx[MIN(i,im)][MAX(i,im)] == 9999.9
|
||||
|| mtx[MIN(i,jm)][MAX(i,jm)] == 9999.9
|
||||
) continue;
|
||||
mtx[MIN(i,im)][MAX(i,im)]
|
||||
= 0.5 * ( mtx[MIN(i,im)][MAX(i,im)] + mtx[MIN(i,jm)][MAX(i,jm)]
|
||||
- mtx[MIN(im,jm)][MAX(im,jm)] );
|
||||
mtx[MIN(i,jm)][MAX(i,jm)] = 9999.9;
|
||||
}
|
||||
mtx[MIN(im,jm)][MAX(im,jm)] = 9999.9;
|
||||
}
|
||||
|
||||
|
||||
void nj( int nseq, double **omtx, int ***topol, double **dis )
|
||||
{
|
||||
int i, j, l, n, m;
|
||||
int count;
|
||||
double r[M];
|
||||
double t;
|
||||
double s, sm;
|
||||
double totallen = 0.0;
|
||||
int im=0, jm=0;
|
||||
double len1, len2;
|
||||
#if 1
|
||||
static char **par = NULL;
|
||||
static double **mtx = NULL;
|
||||
static int **mem = NULL;
|
||||
if( par == NULL )
|
||||
{
|
||||
par = AllocateCharMtx( njob, njob );
|
||||
mtx = AllocateDoubleMtx( njob, njob );
|
||||
mem = AllocateIntMtx( njob, 2 );
|
||||
}
|
||||
#else
|
||||
char par[njob][njob];
|
||||
double mtx[njob][njob];
|
||||
int mem[njob][2];
|
||||
#endif
|
||||
for( i=0; i<nseq; i++ ) for( j=0; j<nseq; j++ ) mtx[i][j] = omtx[i][j];
|
||||
for( i=0; i<nseq; i++ ) for( j=0; j<nseq; j++ ) par[i][j] = 0;
|
||||
for( i=0; i<nseq; i++ ) par[i][i] = 1;
|
||||
// for( i=0; i<nseq; i++ ) for( j=0; j<2; j++ ) for( l=0; l<nseq+1; l++ ) topol[i][j][l] = -1;
|
||||
for( i=0; i<nseq; i++ ) for( j=0; j<2; j++ ) for( l=0; l<nseq; l++ ) topol[i][j][l] = -1;
|
||||
for( n=nseq, m=0; n>2; n--, m=nseq-n )
|
||||
{
|
||||
t = 0.0;
|
||||
for( i=0; i<nseq-1; i++ ) for( j=0; j<nseq; j++ ) if( mtx[i][j] < 9999.9 )
|
||||
t += mtx[i][j];
|
||||
for( i=0; i<nseq; i++ )
|
||||
{
|
||||
r[i] = 0.0;
|
||||
for( l=0; l<nseq; l++ )
|
||||
if( ( l != i ) && ( mtx[MIN(i,l)][MAX(i,l)] < 9999.9 ) )
|
||||
r[i] += mtx[MIN(i,l)][MAX(i,l)];
|
||||
}
|
||||
sm = 9999.9;
|
||||
for( i=0; i<nseq-1; i++ ) for( j=i+1; j<nseq; j++ ) if( mtx[i][j] < 9999.9)
|
||||
{
|
||||
s = ( ( 2.0 * t - r[i] - r[j] + (n-2.0)*mtx[i][j] ) ) / ( 2.0*(n-2.0) );
|
||||
if ( s < sm )
|
||||
{
|
||||
sm = s;
|
||||
im = i; jm = j;
|
||||
}
|
||||
}
|
||||
len1 = ( (n-2)*mtx[im][jm] + r[im] - r[jm] ) / (2*(n-2));
|
||||
len2 = ( (n-2)*mtx[im][jm] - r[im] + r[jm] ) / (2*(n-2));
|
||||
|
||||
#if DEBUG
|
||||
fprintf( stderr, "STEP-%3d %3d: L = %5.5f\n", m+1, im+1, len1 );
|
||||
fprintf( stderr, " %3d: L = %5.5f\n", jm+1, len2 );
|
||||
#endif
|
||||
|
||||
totallen += len1;
|
||||
totallen += len2;
|
||||
|
||||
dis[m][0] = len1;
|
||||
dis[m][1] = len2;
|
||||
|
||||
for( l=0, count=0; l<nseq; l++ )
|
||||
if( par[im][l] > 0 )
|
||||
{
|
||||
topol[m][0][count] = l;
|
||||
count++;
|
||||
}
|
||||
mem[m][0] = count;
|
||||
for( l=0, count=0; l<nseq; l++ )
|
||||
if( par[jm][l] > 0 )
|
||||
{
|
||||
topol[m][1][count] = l;
|
||||
count++;
|
||||
}
|
||||
mem[m][1] = count;
|
||||
for( l=0; l<nseq; l++ )
|
||||
par[im][l] += ( par[jm][l] > 0 );
|
||||
if( n > 3 ) reduc( mtx, nseq, im, jm );
|
||||
}
|
||||
for( i=0; i<nseq; i++ )
|
||||
if( i!=im && i!=jm && mtx[MIN(i,im)][MAX(i,im)]<9999.9 )
|
||||
break;
|
||||
len2 = ( mtx[MIN(i,im)][MAX(i,im)] - r[im] + r[i] ) / 2;
|
||||
|
||||
/*
|
||||
printf(" %3d: L = %5.5f\n", i+1, len2 );
|
||||
*/
|
||||
totallen += len2;
|
||||
|
||||
dis[m][0] = len2;
|
||||
dis[m][1] = 0.0;
|
||||
for( l=0, count=0; l<nseq; l++ )
|
||||
if( par[i][l] > 0 )
|
||||
{
|
||||
topol[m][0][count] = l;
|
||||
count++;
|
||||
}
|
||||
mem[m][0] = count;
|
||||
/*
|
||||
printf( " total length == %f\n", totallen );
|
||||
*/
|
||||
|
||||
topolcpy( topol[nseq-2][1], topol[nseq-3][0], mem[nseq-2]+1, mem[nseq-3] );
|
||||
topolcat( topol[nseq-2][1], topol[nseq-3][1], mem[nseq-2]+1, mem[nseq-3]+1 );
|
||||
topolsort( mem[nseq-2][1], topol[nseq-2][1] );
|
||||
|
||||
if( topol[nseq-2][0][0] > topol[nseq-2][1][0] )
|
||||
topolswap( topol[nseq-2][0], topol[nseq-2][1], mem[nseq-2], mem[nseq-2]+1 );
|
||||
|
||||
}
|
504
mafft/src/mafft-7.487-with-extensions/core/nodepair.c
Normal file
504
mafft/src/mafft-7.487-with-extensions/core/nodepair.c
Normal file
|
@ -0,0 +1,504 @@
|
|||
#include "mltaln.h"
|
||||
#include <errno.h>
|
||||
|
||||
#define DEBUG 0
|
||||
#define IODEBUG 0
|
||||
#define SCOREOUT 0
|
||||
#define SHISHAGONYU 0 // for debug
|
||||
|
||||
|
||||
// from tbfast
|
||||
static int treein;
|
||||
static int treeout;
|
||||
|
||||
|
||||
// from pairlocalalign
|
||||
static int stdout_dist;
|
||||
|
||||
|
||||
static void arguments( int argc, char *argv[] )
|
||||
{
|
||||
int c;
|
||||
|
||||
nthread = 1;
|
||||
nadd = 0;
|
||||
inputfile = NULL;
|
||||
fftkeika = 0;
|
||||
pslocal = -1000.0;
|
||||
nblosum = 62;
|
||||
fmodel = 0;
|
||||
calledByXced = 0;
|
||||
devide = 0;
|
||||
use_fft = 0;
|
||||
fftscore = 1;
|
||||
fftRepeatStop = 0;
|
||||
fftNoAnchStop = 0;
|
||||
weight = 3;
|
||||
utree = 1;
|
||||
tbutree = 1;
|
||||
refine = 0;
|
||||
check = 1;
|
||||
cut = 0.0;
|
||||
disp = 0;
|
||||
outgap = 1;
|
||||
alg = 'A';
|
||||
mix = 0;
|
||||
tbitr = 0;
|
||||
scmtd = 5;
|
||||
tbweight = 0;
|
||||
tbrweight = 3;
|
||||
checkC = 0;
|
||||
treemethod = 'x';
|
||||
contin = 0;
|
||||
scoremtx = 1;
|
||||
kobetsubunkatsu = 0;
|
||||
divpairscore = 0;
|
||||
stdout_dist = 0;
|
||||
// dorp = NOTSPECIFIED;
|
||||
ppenalty = NOTSPECIFIED;
|
||||
ppenalty_OP = NOTSPECIFIED;
|
||||
ppenalty_ex = NOTSPECIFIED;
|
||||
ppenalty_EX = NOTSPECIFIED;
|
||||
penalty_shift_factor = 1000.0;
|
||||
poffset = NOTSPECIFIED;
|
||||
kimuraR = NOTSPECIFIED;
|
||||
pamN = NOTSPECIFIED;
|
||||
geta2 = GETA2;
|
||||
fftWinSize = NOTSPECIFIED;
|
||||
fftThreshold = NOTSPECIFIED;
|
||||
RNAppenalty = NOTSPECIFIED;
|
||||
RNApthr = NOTSPECIFIED;
|
||||
specificityconsideration = 0.0;
|
||||
usenaivescoreinsteadofalignmentscore = 0;
|
||||
specifictarget = 0;
|
||||
nwildcard = 0;
|
||||
compacttree = 2; // tsuneni!
|
||||
treein = 0;
|
||||
treeout = 0;
|
||||
fastathreshold = 2.7;
|
||||
constraint = 2;
|
||||
|
||||
// localhomfile = 0; // tbfast.c no wo tsukaunode comment out
|
||||
|
||||
// reporterr( "argc=%d\n", argc );
|
||||
// reporterr( "*argv=%s\n", *argv );
|
||||
// reporterr( "(*argv)[0]=%c\n", (*argv)[0] );
|
||||
while( --argc > 0 && (*++argv)[0] == '-' )
|
||||
{
|
||||
// reporterr( "(*argv)[0] in while loop = %s\n", (*argv) );
|
||||
while ( ( c = *++argv[0] ) )
|
||||
{
|
||||
switch( c )
|
||||
{
|
||||
case 'i':
|
||||
inputfile = *++argv;
|
||||
// fprintf( stderr, "inputfile = %s\n", inputfile );
|
||||
--argc;
|
||||
goto nextoption;
|
||||
case 'f':
|
||||
ppenalty = (int)( atof( *++argv ) * 1000 - 0.5 );
|
||||
--argc;
|
||||
goto nextoption;
|
||||
case 'g':
|
||||
ppenalty_ex = (int)( atof( *++argv ) * 1000 - 0.5 );
|
||||
--argc;
|
||||
goto nextoption;
|
||||
case 'O':
|
||||
ppenalty_OP = (int)( atof( *++argv ) * 1000 - 0.5 );
|
||||
--argc;
|
||||
goto nextoption;
|
||||
case 'E':
|
||||
ppenalty_EX = (int)( atof( *++argv ) * 1000 - 0.5 );
|
||||
--argc;
|
||||
goto nextoption;
|
||||
case 'Q':
|
||||
penalty_shift_factor = atof( *++argv );
|
||||
--argc;
|
||||
goto nextoption;
|
||||
case 'h':
|
||||
poffset = (int)( atof( *++argv ) * 1000 - 0.5 );
|
||||
--argc;
|
||||
goto nextoption;
|
||||
case 'k':
|
||||
kimuraR = myatoi( *++argv );
|
||||
// fprintf( stderr, "kimuraR = %d\n", kimuraR );
|
||||
--argc;
|
||||
goto nextoption;
|
||||
case 'b':
|
||||
nblosum = myatoi( *++argv );
|
||||
scoremtx = 1;
|
||||
// fprintf( stderr, "blosum %d\n", nblosum );
|
||||
--argc;
|
||||
goto nextoption;
|
||||
case 'j':
|
||||
pamN = myatoi( *++argv );
|
||||
scoremtx = 0;
|
||||
TMorJTT = JTT;
|
||||
// fprintf( stderr, "jtt %d\n", pamN );
|
||||
--argc;
|
||||
goto nextoption;
|
||||
case 'm':
|
||||
pamN = myatoi( *++argv );
|
||||
scoremtx = 0;
|
||||
TMorJTT = TM;
|
||||
// fprintf( stderr, "TM %d\n", pamN );
|
||||
--argc;
|
||||
goto nextoption;
|
||||
case 'l':
|
||||
fastathreshold = atof( *++argv );
|
||||
constraint = 2;
|
||||
--argc;
|
||||
goto nextoption;
|
||||
#if 0
|
||||
case 'l':
|
||||
ppslocal = (int)( atof( *++argv ) * 1000 + 0.5 );
|
||||
pslocal = (int)( 600.0 / 1000.0 * ppslocal + 0.5);
|
||||
// fprintf( stderr, "ppslocal = %d\n", ppslocal );
|
||||
// fprintf( stderr, "pslocal = %d\n", pslocal );
|
||||
--argc;
|
||||
goto nextoption;
|
||||
#else
|
||||
#endif
|
||||
case 'C':
|
||||
nthread = myatoi( *++argv );
|
||||
if( nthread == 0 ) nthread = 1;
|
||||
// fprintf( stderr, "nthread = %d\n", nthread );
|
||||
--argc;
|
||||
#ifndef enablemultithread
|
||||
nthread = 1;
|
||||
#endif
|
||||
goto nextoption;
|
||||
case 'I':
|
||||
nadd = myatoi( *++argv );
|
||||
// fprintf( stderr, "nadd = %d\n", nadd );
|
||||
--argc;
|
||||
goto nextoption;
|
||||
case 'u':
|
||||
specificityconsideration = (double)myatof( *++argv );
|
||||
// fprintf( stderr, "specificityconsideration = %f\n", specificityconsideration );
|
||||
--argc;
|
||||
goto nextoption;
|
||||
case 'c':
|
||||
stdout_dist = 1;
|
||||
break;
|
||||
#if 1
|
||||
case 'a':
|
||||
fmodel = 1;
|
||||
break;
|
||||
#endif
|
||||
case 'K':
|
||||
addprofile = 0;
|
||||
break;
|
||||
#if 0
|
||||
case 'r':
|
||||
fmodel = -1;
|
||||
break;
|
||||
#endif
|
||||
case 'D':
|
||||
dorp = 'd';
|
||||
break;
|
||||
case 'P':
|
||||
dorp = 'p';
|
||||
break;
|
||||
#if 0
|
||||
case 'e':
|
||||
fftscore = 0;
|
||||
break;
|
||||
case 'O':
|
||||
fftNoAnchStop = 1;
|
||||
break;
|
||||
#endif
|
||||
#if 0
|
||||
case 'Q':
|
||||
calledByXced = 1;
|
||||
break;
|
||||
case 'x':
|
||||
disp = 1;
|
||||
break;
|
||||
case 'a':
|
||||
alg = 'a';
|
||||
break;
|
||||
case 'S':
|
||||
alg = 'S';
|
||||
break;
|
||||
#endif
|
||||
case 'N':
|
||||
alg = 'N';
|
||||
break;
|
||||
case 'A':
|
||||
alg = 'A';
|
||||
break;
|
||||
case 'L':
|
||||
alg = 'L';
|
||||
break;
|
||||
case 'Z':
|
||||
usenaivescoreinsteadofalignmentscore = 1;
|
||||
break;
|
||||
case 'B': // hitsuyou! memopt -M -B no tame
|
||||
break;
|
||||
#if 0
|
||||
case 'Y':
|
||||
alg = 'Y'; // nadd>0 no toki nomi. moto no hairetsu to atarashii hairetsuno alignmnt -> L;
|
||||
break;
|
||||
case 's':
|
||||
alg = 's';
|
||||
break;
|
||||
case 'G':
|
||||
alg = 'G';
|
||||
break;
|
||||
case 'B': // hitsuyou! memopt -M -B no tame
|
||||
break;
|
||||
case 'T':
|
||||
alg = 'T';
|
||||
break;
|
||||
case 'H':
|
||||
alg = 'H';
|
||||
break;
|
||||
case 'M':
|
||||
alg = 'M';
|
||||
break;
|
||||
case 'R':
|
||||
alg = 'R';
|
||||
break;
|
||||
case 'r':
|
||||
alg = 'r'; // nadd>0 no toki nomi. moto no hairetsu to atarashii hairetsuno alignmnt -> R, last
|
||||
break;
|
||||
case 'V':
|
||||
alg = 'V';
|
||||
break;
|
||||
#endif
|
||||
case 'T': // tbfast.c no noalign ni taiou
|
||||
break;
|
||||
|
||||
case 'F':
|
||||
use_fft = 1;
|
||||
break;
|
||||
case 'U':
|
||||
treein = 1;
|
||||
break;
|
||||
case 't':
|
||||
treeout = 1;
|
||||
break;
|
||||
case 'y':
|
||||
divpairscore = 1;
|
||||
break;
|
||||
case '=':
|
||||
specifictarget = 1;
|
||||
break;
|
||||
case ':':
|
||||
nwildcard = 1;
|
||||
break;
|
||||
case 'q':
|
||||
lhlimit = myatoi( *++argv );
|
||||
--argc;
|
||||
goto nextoption;
|
||||
/* Modified 01/08/27, default: user tree */
|
||||
case 'J':
|
||||
tbutree = 0;
|
||||
break;
|
||||
/* modification end. */
|
||||
default:
|
||||
fprintf( stderr, "illegal option %c\n", c );
|
||||
argc = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
nextoption:
|
||||
;
|
||||
}
|
||||
if( argc == 1 )
|
||||
{
|
||||
cut = atof( (*argv) );
|
||||
argc--;
|
||||
}
|
||||
if( argc != 0 )
|
||||
{
|
||||
fprintf( stderr, "pairlocalalign options: Check source file !\n" );
|
||||
exit( 1 );
|
||||
}
|
||||
if( tbitr == 1 && outgap == 0 )
|
||||
{
|
||||
fprintf( stderr, "conflicting options : o, m or u\n" );
|
||||
exit( 1 );
|
||||
}
|
||||
}
|
||||
|
||||
int main( int argc, char *argv[] )
|
||||
{
|
||||
static int *nlen = NULL;
|
||||
static int *selfscore = NULL;
|
||||
static char **name = NULL, **seq = NULL;
|
||||
static double *eff = NULL;
|
||||
int i;
|
||||
static int ***topol = NULL;
|
||||
static Treedep *dep = NULL;
|
||||
static double **len = NULL;
|
||||
FILE *infp = NULL;
|
||||
|
||||
char c;
|
||||
|
||||
arguments( argc, argv );
|
||||
|
||||
if( alg != 'A' && alg != 'L' && alg != 'N' )
|
||||
{
|
||||
reporterr( "alg %c is not yet supported\n", alg );
|
||||
exit( 1 );
|
||||
}
|
||||
if( alg != 'N' && usenaivescoreinsteadofalignmentscore == 1 )
|
||||
{
|
||||
reporterr( "The combination of usenaivescoreinsteadofalignmentscore and alg %c is not yet supported\n", alg );
|
||||
exit( 1 );
|
||||
}
|
||||
|
||||
if( fastathreshold < 0.0001 )
|
||||
{
|
||||
constraint = 0;
|
||||
lhlimit = 0;
|
||||
}
|
||||
|
||||
if( inputfile )
|
||||
{
|
||||
infp = fopen( inputfile, "r" );
|
||||
if( !infp )
|
||||
{
|
||||
fprintf( stderr, "Cannot open %s\n", inputfile );
|
||||
exit( 1 );
|
||||
}
|
||||
}
|
||||
else
|
||||
infp = stdin;
|
||||
|
||||
getnumlen( infp );
|
||||
rewind( infp );
|
||||
|
||||
|
||||
if( njob < 2 )
|
||||
{
|
||||
fprintf( stderr, "At least 2 sequences should be input!\n"
|
||||
"Only %d sequence found.\n", njob );
|
||||
exit( 1 );
|
||||
}
|
||||
|
||||
|
||||
#if !defined(mingw) && !defined(_MSC_VER)
|
||||
setstacksize( 200 * njob ); // topolorder() de ookime no stack wo shiyou.
|
||||
#endif
|
||||
|
||||
|
||||
seq = AllocateCharMtx( njob, nlenmax+1 );
|
||||
|
||||
name = AllocateCharMtx( njob, B+1 );
|
||||
nlen = AllocateIntVec( njob );
|
||||
selfscore = AllocateIntVec( njob );
|
||||
|
||||
topol = AllocateIntCub( njob, 2, 0 );
|
||||
len = AllocateFloatMtx( njob, 2 );
|
||||
eff = AllocateDoubleVec( njob );
|
||||
|
||||
|
||||
dep = (Treedep *)calloc( njob, sizeof( Treedep ) );
|
||||
|
||||
|
||||
#if 0
|
||||
readData( infp, name, nlen, seq );
|
||||
#else
|
||||
readData_pointer( infp, name, nlen, seq );
|
||||
fclose( infp );
|
||||
#endif
|
||||
|
||||
constants( njob, seq );
|
||||
|
||||
#if 0
|
||||
fprintf( stderr, "params = %d, %d, %d\n", penalty, penalty_ex, offset );
|
||||
#endif
|
||||
|
||||
initSignalSM();
|
||||
initFiles();
|
||||
|
||||
// WriteOptions( trap_g );
|
||||
|
||||
c = seqcheck( seq );
|
||||
if( c )
|
||||
{
|
||||
fprintf( stderr, "Illegal character %c\n", c );
|
||||
exit( 1 );
|
||||
}
|
||||
|
||||
// writePre( njob, name, nlen, seq, 0 );
|
||||
|
||||
if( treein ) loadtree( njob, topol, len, name, nlen, dep, treeout );
|
||||
pairalign_node( njob, nlenmax, name, seq, topol, len, dep, treein, treeout );
|
||||
|
||||
|
||||
FreeCharMtx( seq ); seq = NULL;
|
||||
|
||||
FreeCharMtx( name ); name = NULL;
|
||||
free( nlen ); nlen = NULL;
|
||||
free( selfscore ); selfscore = NULL;
|
||||
|
||||
for( i=0; i<njob; i++ )
|
||||
{
|
||||
free( topol[i][0] ); topol[i][0] = NULL;
|
||||
free( topol[i][1] ); topol[i][1] = NULL;
|
||||
free( topol[i] ); topol[i] = NULL;
|
||||
free( len[i] ); len[i] = NULL;
|
||||
}
|
||||
free( topol ); topol = NULL;
|
||||
free( len ); len = NULL;
|
||||
free( eff ); eff = NULL;
|
||||
free( dep ); dep = NULL;
|
||||
|
||||
|
||||
freeconstants();
|
||||
closeFiles();
|
||||
FreeCommonIP();
|
||||
|
||||
SHOWVERSION; // koko?
|
||||
|
||||
return( 0 );
|
||||
|
||||
#if 0 // gui mitaiou
|
||||
chudan:
|
||||
if( seq ) FreeCharMtx( seq ); seq = NULL;
|
||||
|
||||
if( name ) FreeCharMtx( name ); name = NULL;
|
||||
if( nlen ) free( nlen ); nlen = NULL;
|
||||
if( selfscore ) free( selfscore ); selfscore = NULL;
|
||||
|
||||
|
||||
|
||||
if( topol ) FreeIntCub( topol ); topol = NULL;
|
||||
if( dep ) free( dep ); dep = NULL;
|
||||
|
||||
freeconstants();
|
||||
closeFiles();
|
||||
FreeCommonIP();
|
||||
|
||||
if( topol )
|
||||
{
|
||||
for( i=0; i<njob; i++ )
|
||||
{
|
||||
if( topol[i] )
|
||||
{
|
||||
if( topol[i][0] ) free( topol[i][0] ); topol[i][0] = NULL;
|
||||
if( topol[i][1] ) free( topol[i][1] ); topol[i][1] = NULL;
|
||||
}
|
||||
free( topol[i] ); topol[i] = NULL;
|
||||
}
|
||||
free( topol ); topol = NULL;
|
||||
}
|
||||
if( len )
|
||||
{
|
||||
for( i=0; i<njob; i++ )
|
||||
{
|
||||
if( len[i] ) free( len[i] ); len[i] = 0;
|
||||
}
|
||||
free( len ); len = NULL;
|
||||
}
|
||||
if( eff ) free( eff ); eff = NULL;
|
||||
if( dep ) free( dep ); dep = NULL;
|
||||
|
||||
return( 0 );
|
||||
#endif
|
||||
|
||||
}
|
1442
mafft/src/mafft-7.487-with-extensions/core/pairash.c
Normal file
1442
mafft/src/mafft-7.487-with-extensions/core/pairash.c
Normal file
File diff suppressed because it is too large
Load diff
3550
mafft/src/mafft-7.487-with-extensions/core/pairlocalalign.c
Normal file
3550
mafft/src/mafft-7.487-with-extensions/core/pairlocalalign.c
Normal file
File diff suppressed because it is too large
Load diff
|
@ -0,0 +1,7 @@
|
|||
#include "mltaln.h"
|
||||
int main( int argc, char **argv )
|
||||
{
|
||||
int res = pairlocalalign( 0, 0, NULL, NULL, NULL, NULL, argc, argv, NULL );
|
||||
if( res == GUI_CANCEL ) res = 0; // treeout de goto chudan wo riyousuru
|
||||
return res;
|
||||
}
|
2119
mafft/src/mafft-7.487-with-extensions/core/partSalignmm.c
Normal file
2119
mafft/src/mafft-7.487-with-extensions/core/partSalignmm.c
Normal file
File diff suppressed because it is too large
Load diff
|
@ -0,0 +1,387 @@
|
|||
#! /usr/bin/env ruby
|
||||
|
||||
$MAFFTCOMMAND = '"/usr/local/bin/mafft"'
|
||||
# Edit the above line to specify the location of mafft.
|
||||
# $MAFFTCOMMAND = '"C:\folder name\mafft.bat"' # windows
|
||||
# $MAFFTCOMMAND = '"/usr/local/bin/mafft"' # mac or cygwin
|
||||
# $MAFFTCOMMAND = '"/usr/bin/mafft"' # linux (rpm)
|
||||
# $MAFFTCOMMAND = '"/somewhere/mafft.bat"' # all-in-one version for linux or mac
|
||||
|
||||
#####################################################################
|
||||
#
|
||||
# regionalrealignment.rb version 0.2 (2013/Sep/21)
|
||||
# ruby regionalrealignment.rb setting input > output
|
||||
# See http://mafft.cbrc.jp/alignment/software/regionalrealignment.html
|
||||
#
|
||||
# v0.2, 2013/Sep/21, Fixed a windows-specific bug.
|
||||
#
|
||||
#####################################################################
|
||||
|
||||
|
||||
def readfasta( fp, name, seq )
|
||||
nseq = 0
|
||||
tmpseq = ""
|
||||
while fp.gets
|
||||
if $_ =~ /^>/ then
|
||||
name.push( $_.sub(/>/,"").strip )
|
||||
seq.push( tmpseq ) if nseq > 0
|
||||
nseq += 1
|
||||
tmpseq = ""
|
||||
else
|
||||
tmpseq += $_.strip
|
||||
end
|
||||
end
|
||||
seq.push( tmpseq )
|
||||
return nseq
|
||||
end
|
||||
|
||||
def resolve( tree )
|
||||
while 1
|
||||
# p tree
|
||||
tree.sub!( /\,([0-9]+):(\-?[0-9\.]+)\,([0-9]+):(\-?[0-9\.]+)/, ",XXX" )
|
||||
hit1 = $1
|
||||
hit2 = $2
|
||||
hit3 = $3
|
||||
hit4 = $4
|
||||
|
||||
# p hit1
|
||||
# p hit2
|
||||
# p hit3
|
||||
# p hit4
|
||||
|
||||
# puts "introduce XXX"
|
||||
# p tree
|
||||
|
||||
break unless tree.index(/XXX/)
|
||||
|
||||
poshit = tree.index(/XXX/)
|
||||
# puts "poshit=" + poshit.to_s
|
||||
|
||||
i = poshit
|
||||
height = 0
|
||||
while i >= 0
|
||||
break if height == 0 && tree[i..i] == '('
|
||||
if tree[i..i] == ')' then
|
||||
height += 1
|
||||
elsif tree[i..i] == '(' then
|
||||
height -= 1
|
||||
end
|
||||
i -= 1
|
||||
end
|
||||
|
||||
poskakko = i
|
||||
# puts "poskakko = " + poskakko.to_s
|
||||
zenhan = tree[0..poskakko]
|
||||
zenhan = "" if poskakko == -1
|
||||
# puts "zenhan = " + zenhan
|
||||
|
||||
treelen = tree.length
|
||||
tree = zenhan + "(" + tree[poskakko+1..treelen]
|
||||
# puts "add ("
|
||||
# p tree
|
||||
tree.sub!( /XXX/, "#{hit1}:#{hit2}):0,#{hit3}:#{hit4}" )
|
||||
|
||||
# p tree
|
||||
end
|
||||
|
||||
|
||||
return tree
|
||||
|
||||
end
|
||||
|
||||
if ARGV.length != 2 then
|
||||
STDERR.puts ""
|
||||
STDERR.puts "Usage: ruby #{$0} setingfile inputfile > output"
|
||||
STDERR.puts ""
|
||||
exit 1
|
||||
end
|
||||
|
||||
infilename = ARGV[1]
|
||||
tname = []
|
||||
tseq = []
|
||||
infp = File.open( infilename, "r" )
|
||||
tin = readfasta( infp, tname, tseq )
|
||||
infp.close
|
||||
|
||||
if tin == 0 then
|
||||
STDERR.puts ""
|
||||
STDERR.puts "Error in the '#{infilename}' file. Is this FASTA format?\n"
|
||||
STDERR.puts ""
|
||||
exit 1
|
||||
end
|
||||
|
||||
alnlen = tseq[0].length
|
||||
if alnlen == 0 then
|
||||
STDERR.puts ""
|
||||
STDERR.puts "Error in the '#{infilename}' file. Is this FASTA format?\n"
|
||||
STDERR.puts ""
|
||||
exit 1
|
||||
end
|
||||
|
||||
|
||||
for i in 0..(tin-1)
|
||||
if alnlen != tseq[i].length then
|
||||
STDERR.puts ""
|
||||
STDERR.puts "Please insert gaps such that all the input sequences have the same length.\n"
|
||||
STDERR.puts ""
|
||||
exit 1
|
||||
end
|
||||
end
|
||||
|
||||
checkmap = []
|
||||
for i in 0..(alnlen-1)
|
||||
checkmap.push(0)
|
||||
end
|
||||
|
||||
outputseq = []
|
||||
for i in 0..(tin-1)
|
||||
outputseq.push("")
|
||||
end
|
||||
|
||||
|
||||
settingfile = ARGV[0].to_s
|
||||
reg = []
|
||||
startpos = []
|
||||
endpos = []
|
||||
realign = []
|
||||
options = []
|
||||
treeoption = ""
|
||||
revwarn = 0
|
||||
sfp = File.open( settingfile, "r" )
|
||||
while line = sfp.gets
|
||||
line.sub!(/#.*/,"")
|
||||
next if line.length < 2
|
||||
if line.strip =~ /^treeoption / then
|
||||
treeoption = line.strip.sub(/.*treeoption/,"")
|
||||
break
|
||||
end
|
||||
end
|
||||
sfp.close
|
||||
sfp = File.open( settingfile, "r" )
|
||||
while line = sfp.gets
|
||||
line.sub!(/#.*/,"")
|
||||
next if line.length < 2
|
||||
next if line.strip =~ /^treeoption/
|
||||
startposv = line.split(' ')[0].to_i - 1
|
||||
endposv = line.split(' ')[1].to_i - 1
|
||||
if startposv < 0 || endposv < 0 then
|
||||
STDERR.puts "\nError in the '#{settingfile}' file. Please check this line:\n"
|
||||
STDERR.puts line
|
||||
STDERR.puts "Sites must be numbered as 1, 2, ...\n"
|
||||
STDERR.puts "\n"
|
||||
exit 1
|
||||
end
|
||||
if startposv >= alnlen || endposv >= alnlen then
|
||||
STDERR.puts "\nError in the '#{settingfile}' file. Please check this line:\n"
|
||||
STDERR.puts line
|
||||
STDERR.puts "Sites must be numbered as 1, 2, ... #{alnlen}\n"
|
||||
STDERR.puts "\n"
|
||||
exit 1
|
||||
end
|
||||
if startposv > endposv then
|
||||
STDERR.puts "\nWarning. Please check this line:\n"
|
||||
STDERR.puts line
|
||||
STDERR.puts "Start position > End position ?\n"
|
||||
STDERR.puts "\n"
|
||||
revwarn = 1
|
||||
# exit 1
|
||||
end
|
||||
startpos.push( startposv )
|
||||
endpos.push( endposv )
|
||||
if startposv > endposv
|
||||
for k in (endposv)..(startposv)
|
||||
checkmap[k] += 1
|
||||
end
|
||||
else
|
||||
for k in (startposv)..(endposv)
|
||||
checkmap[k] += 1
|
||||
end
|
||||
end
|
||||
if line.split(' ')[2] == "realign" then
|
||||
realign.push( 1 )
|
||||
elsif line.split(' ')[2] == "preserve" then
|
||||
realign.push( 0 )
|
||||
else
|
||||
STDERR.puts "\n"
|
||||
STDERR.puts "The third column must be 'realign' or 'preserve'\n"
|
||||
STDERR.puts "Please check this line:\n"
|
||||
STDERR.puts line
|
||||
STDERR.puts "\n"
|
||||
exit 1
|
||||
end
|
||||
if line =~ / \-\-/ && line =~ /realign/ then
|
||||
options.push( line.sub(/.*realign/,"").strip )
|
||||
else
|
||||
options.push( treeoption )
|
||||
end
|
||||
end
|
||||
sfp.close
|
||||
|
||||
#p startpos
|
||||
#p endpos
|
||||
#p options
|
||||
|
||||
|
||||
#res = system "#{$MAFFTCOMMAND} #{treeoption} --treeout --retree 0 --thread -1 #{infilename} > _dum"
|
||||
res = system "#{$MAFFTCOMMAND} #{treeoption} --treeout --retree 0 #{infilename} > _dum"
|
||||
|
||||
if res == false then
|
||||
STDERR.puts "\n"
|
||||
STDERR.puts "ERROR in building a guide tree"
|
||||
STDERR.puts "\n"
|
||||
exit 1
|
||||
end
|
||||
|
||||
treefp = File.open( "#{infilename}.tree", "r" )
|
||||
|
||||
tree = ""
|
||||
while line = treefp.gets
|
||||
tree += line.strip
|
||||
break if tree =~ /;$/
|
||||
end
|
||||
treefp.close
|
||||
|
||||
tree = tree.gsub( /_.*?:/, ":" ).gsub(/[0-9]\.[0-9]*e-[0-9][0-9]/, "0").gsub(/\[.*?\]/,"").gsub(/ /, "")
|
||||
scale = 1.0
|
||||
mtreefp = File.open("_tree", "w")
|
||||
|
||||
|
||||
#STDERR.puts "Tree = " + tree
|
||||
|
||||
memi = [-1,-1]
|
||||
leni = [-1,-1]
|
||||
|
||||
while tree.index( /\(/ )
|
||||
|
||||
tree = resolve( tree )
|
||||
|
||||
tree.sub!( /\(([0-9]+):(\-?[0-9\.]+),([0-9]+):(\-?[0-9\.]+)\)/, "XXX" )
|
||||
memi[0] = $1.to_i
|
||||
leni[0] = $2.to_f * scale
|
||||
memi[1] = $3.to_i
|
||||
leni[1] = $4.to_f * scale
|
||||
|
||||
if leni[0] > 10 || leni[1] > 10 then
|
||||
STDERR.puts ""
|
||||
STDERR.puts "Please check the scale of branch length!"
|
||||
STDERR.puts "The unit of branch lengths must be 'substitution/site'"
|
||||
STDERR.puts "If the unit is 'substition' in your tree, please"
|
||||
STDERR.puts "use the scale argument,"
|
||||
STDERR.puts "% newick2mafft scale in > out"
|
||||
STDERR.puts "where scale = 1/(alignment length)"
|
||||
STDERR.puts ""
|
||||
exit 1
|
||||
end
|
||||
|
||||
# STDERR.puts "subtree = " + $&
|
||||
|
||||
if memi[1] < memi[0] then
|
||||
memi.reverse!
|
||||
leni.reverse!
|
||||
end
|
||||
|
||||
tree.sub!( /XXX/, memi[0].to_s )
|
||||
|
||||
# STDERR.puts "Tree = " + tree
|
||||
|
||||
mtreefp.printf( "%5d %5d %10.5f %10.5f\n", memi[0], memi[1], leni[0], leni[1] )
|
||||
|
||||
end
|
||||
|
||||
|
||||
mtreefp.close
|
||||
|
||||
numreg = startpos.length
|
||||
|
||||
for i in 0..(numreg-1)
|
||||
|
||||
partfp = File.open( "_part", "w" )
|
||||
for j in 0..(tin-1)
|
||||
partfp.puts ">" + tname[j]
|
||||
if startpos[i] > endpos[i] then
|
||||
partfp.puts tseq[j][endpos[i]..startpos[i]].reverse
|
||||
else
|
||||
partfp.puts tseq[j][startpos[i]..endpos[i]]
|
||||
end
|
||||
end
|
||||
partfp.close
|
||||
|
||||
if( realign[i] == 1 ) then
|
||||
STDERR.puts "Aligning region #{startpos[i]+1} - #{endpos[i]+1}"
|
||||
res = system "#{$MAFFTCOMMAND} #{options[i]} --inputorder --treein _tree _part > _partout"
|
||||
if res == false then
|
||||
STDERR.puts "\n"
|
||||
STDERR.puts "ERROR in aligning region #{startpos[i]+1} - #{endpos[i]+1}"
|
||||
STDERR.puts "Please check the option:"
|
||||
STDERR.puts "#{options[i]}"
|
||||
STDERR.puts "\n"
|
||||
exit 1
|
||||
end
|
||||
|
||||
else
|
||||
STDERR.puts "Copying region #{startpos[i]+1} - #{endpos[i]+1}"
|
||||
# system "cp _part _partout"
|
||||
File.rename( "_part", "_partout" )
|
||||
end
|
||||
|
||||
pname = []
|
||||
pseq = []
|
||||
partfp = File.open( "_partout", "r" )
|
||||
pin = readfasta( partfp, pname, pseq )
|
||||
partfp.close
|
||||
for j in 0..(tin-1)
|
||||
outputseq[j] += pseq[j]
|
||||
end
|
||||
end
|
||||
|
||||
for j in 0..(tin-1)
|
||||
puts ">" + tname[j]
|
||||
puts outputseq[j]
|
||||
end
|
||||
|
||||
STDERR.puts "Done."
|
||||
|
||||
numdupsites = checkmap.select{|x| x>1}.length
|
||||
if numdupsites > 0 then
|
||||
STDERR.puts ""
|
||||
STDERR.puts "#########################################################"
|
||||
STDERR.puts "# Warning: #{numdupsites} sites were duplicatedly selected."
|
||||
STDERR.puts "#########################################################"
|
||||
STDERR.puts ""
|
||||
end
|
||||
|
||||
numunselectedsites = checkmap.select{|x| x==0}.length
|
||||
if numunselectedsites > 0 then
|
||||
STDERR.puts ""
|
||||
STDERR.puts "#########################################################"
|
||||
STDERR.puts "# Warning: #{numunselectedsites} sites were not selected."
|
||||
STDERR.puts "#########################################################"
|
||||
STDERR.puts ""
|
||||
end
|
||||
|
||||
if revwarn == 1 then
|
||||
STDERR.puts ""
|
||||
STDERR.puts "#########################################################"
|
||||
STDERR.puts "# Warning: The order of sites were reversed."
|
||||
STDERR.puts "#########################################################"
|
||||
STDERR.puts ""
|
||||
end
|
||||
|
||||
|
||||
STDERR.puts ""
|
||||
STDERR.puts " Tree: computed with #{treeoption} --treeout "
|
||||
for i in 0..(numreg-1)
|
||||
range = sprintf( "%6d - %6d", startpos[i]+1, endpos[i]+1 )
|
||||
if realign[i] == 1 then
|
||||
STDERR.puts "#{range}: realigned with #{options[i]} --treein (tree)"
|
||||
else
|
||||
STDERR.puts "#{range}: preserved"
|
||||
end
|
||||
end
|
||||
STDERR.puts ""
|
||||
|
||||
File.delete( "_dum" )
|
||||
File.delete( "_tree" )
|
||||
File.delete( "_part" )
|
||||
File.delete( "_partout" )
|
||||
|
216
mafft/src/mafft-7.487-with-extensions/core/regtable2seq.c
Normal file
216
mafft/src/mafft-7.487-with-extensions/core/regtable2seq.c
Normal file
|
@ -0,0 +1,216 @@
|
|||
#include "mltaln.h"
|
||||
|
||||
#define DEBUG 0
|
||||
|
||||
char *regfile;
|
||||
char *eregfile;
|
||||
|
||||
void arguments( int argc, char *argv[] )
|
||||
{
|
||||
int c;
|
||||
|
||||
outnumber = 0;
|
||||
inputfile = NULL;
|
||||
regfile = NULL;
|
||||
eregfile = NULL;
|
||||
|
||||
while( --argc > 0 && (*++argv)[0] == '-' )
|
||||
{
|
||||
while ( (c = *++argv[0]) )
|
||||
{
|
||||
switch( c )
|
||||
{
|
||||
case 'e':
|
||||
eregfile = *++argv;
|
||||
fprintf( stderr, "eregfile = %s\n", eregfile );
|
||||
--argc;
|
||||
goto nextoption;
|
||||
case 'r':
|
||||
regfile = *++argv;
|
||||
fprintf( stderr, "regfile = %s\n", regfile );
|
||||
--argc;
|
||||
goto nextoption;
|
||||
case 'i':
|
||||
inputfile = *++argv;
|
||||
fprintf( stderr, "inputfile = %s\n", inputfile );
|
||||
--argc;
|
||||
goto nextoption;
|
||||
case 'n' :
|
||||
outnumber = 1;
|
||||
break;
|
||||
default:
|
||||
fprintf( stderr, "illegal option %c\n", c );
|
||||
argc = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
nextoption:
|
||||
;
|
||||
}
|
||||
if( argc != 0 )
|
||||
{
|
||||
fprintf( stderr, "options: Check source file !\n" );
|
||||
exit( 1 );
|
||||
}
|
||||
}
|
||||
|
||||
void readereg( FILE *regfp, int **regtable, char **revtable, int *outtable, int *noutpt, int *loutpt )
|
||||
{
|
||||
char gett[1000];
|
||||
int j;
|
||||
int mem;
|
||||
char cmem;
|
||||
char reg[5][100];
|
||||
char out[100];
|
||||
int startpos, endpos;
|
||||
|
||||
*noutpt = 0;
|
||||
*loutpt = 0;
|
||||
fgets( gett, 999, regfp );
|
||||
reg[0][0] = reg[1][0] = reg[2][0] = reg[3][0] = reg[4][0] = 'n';
|
||||
reg[0][1] = reg[1][1] = reg[2][1] = reg[3][1] = reg[4][1] = 0;
|
||||
sscanf( gett, "%c %s %s %s %s %s", &cmem, reg[0], reg[1], reg[2], reg[3], reg[4] );
|
||||
if( cmem != 'e' )
|
||||
{
|
||||
fprintf( stderr, "Format error\n" );
|
||||
exit( 1 );
|
||||
}
|
||||
for( j=0; j<5; j++ )
|
||||
{
|
||||
// reporterr( "reg[j]=%s\n", reg[j] );
|
||||
sscanf( reg[j], "%d-%d-%c", regtable[0]+(j*2), regtable[0]+(j*2)+1, revtable[0]+j );
|
||||
fprintf( stderr, "%d %d-%d\n", 0, regtable[0][j*2], regtable[0][j*2+1] );
|
||||
startpos = regtable[0][j*2];
|
||||
endpos = regtable[0][j*2+1];
|
||||
// reporterr( "startpod=%d, endpos=%d, *loutpt=%d\n", startpos, endpos, *loutpt );
|
||||
if( startpos > endpos )
|
||||
{
|
||||
endpos = regtable[0][j*2];
|
||||
startpos = regtable[0][j*2+1];
|
||||
}
|
||||
if( startpos != -1 && endpos != -1 )
|
||||
*loutpt += endpos - startpos + 1;
|
||||
}
|
||||
|
||||
while( 1 )
|
||||
{
|
||||
fgets( gett, 999, regfp );
|
||||
if( feof( regfp ) ) break;
|
||||
sscanf( gett, "%d o=%s", &mem, out );
|
||||
if( mem >= njob )
|
||||
{
|
||||
fprintf( stderr, "Out of range\n" );
|
||||
exit( 1 );
|
||||
}
|
||||
outtable[mem] = atoi( out );
|
||||
if( outtable[mem] ) *noutpt += 1;
|
||||
}
|
||||
}
|
||||
|
||||
void readreg( FILE *regfp, int **regtable, char **revtable, int *outtable )
|
||||
{
|
||||
char gett[1000];
|
||||
int j;
|
||||
int mem;
|
||||
char reg[5][100];
|
||||
char out[100];
|
||||
|
||||
while( 1 )
|
||||
{
|
||||
fgets( gett, 999, regfp );
|
||||
if( feof( regfp ) ) break;
|
||||
sscanf( gett, "%d %s %s %s %s %s o=%s", &mem, reg[0], reg[1], reg[2], reg[3], reg[4], out );
|
||||
if( mem >= njob )
|
||||
{
|
||||
fprintf( stderr, "Out of range\n" );
|
||||
exit( 1 );
|
||||
}
|
||||
for( j=0; j<5; j++ )
|
||||
{
|
||||
sscanf( reg[j], "%d-%d-%c", regtable[mem]+(j*2), regtable[mem]+(j*2)+1, revtable[mem]+j );
|
||||
fprintf( stderr, "%d %d-%d\n", mem, regtable[mem][j*2], regtable[mem][j*2+1] );
|
||||
}
|
||||
outtable[mem] = atoi( out );
|
||||
}
|
||||
}
|
||||
|
||||
int main( int argc, char *argv[] )
|
||||
{
|
||||
FILE *infp;
|
||||
FILE *regfp;
|
||||
int nlenmin;
|
||||
int **regtable;
|
||||
char **revtable;
|
||||
int *outtable;
|
||||
int i, nout, lout;
|
||||
char **outseq;
|
||||
char **name;
|
||||
|
||||
arguments( argc, argv );
|
||||
|
||||
if( inputfile )
|
||||
{
|
||||
infp = fopen( inputfile, "r" );
|
||||
if( !infp )
|
||||
{
|
||||
fprintf( stderr, "Cannot open %s\n", inputfile );
|
||||
exit( 1 );
|
||||
}
|
||||
}
|
||||
else
|
||||
infp = stdin;
|
||||
|
||||
dorp = NOTSPECIFIED;
|
||||
getnumlen_nogap( infp, &nlenmin );
|
||||
|
||||
if( regfile )
|
||||
{
|
||||
regfp = fopen( regfile, "r" );
|
||||
if( !regfp )
|
||||
{
|
||||
fprintf( stderr, "Cannot open %s\n", regfile );
|
||||
exit( 1 );
|
||||
}
|
||||
regtable = AllocateIntMtx( njob, 5*2 );
|
||||
revtable = AllocateCharMtx( njob, 5 );
|
||||
outtable = AllocateIntVec( njob );
|
||||
readreg( regfp, regtable, revtable, outtable );
|
||||
cutData( infp, regtable, revtable, outtable );
|
||||
}
|
||||
else if( eregfile )
|
||||
{
|
||||
regfp = fopen( eregfile, "r" );
|
||||
if( !regfp )
|
||||
{
|
||||
fprintf( stderr, "Cannot open %s\n", eregfile );
|
||||
exit( 1 );
|
||||
}
|
||||
regtable = AllocateIntMtx( 1, 5*2 );
|
||||
revtable = AllocateCharMtx( 1, 5 );
|
||||
outtable = AllocateIntVec( njob );
|
||||
readereg( regfp, regtable, revtable, outtable, &nout, &lout );
|
||||
fprintf( stderr, "nout = %d, lout = %d\n", nout, lout );
|
||||
|
||||
outseq = AllocateCharMtx( nout, lout+1 );
|
||||
name = AllocateCharMtx( nout, B );
|
||||
|
||||
cutAlignment( infp, regtable, revtable, outtable, name, outseq );
|
||||
fprintf( stderr, "gappick! nout = %d\n", nout );
|
||||
commongappick( nout, outseq );
|
||||
for( i=0; i<nout; i++ )
|
||||
{
|
||||
fprintf( stdout, "%s\n", name[i] );
|
||||
fprintf( stdout, "%s\n", outseq[i] );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
catData( infp );
|
||||
}
|
||||
|
||||
fprintf( stderr, "Strategy:\n" );
|
||||
fprintf( stderr, " Not-Aligned\n" );
|
||||
|
||||
// fprintf( stdout, "%d x %d - %d %c\n", njob, nlenmax, nlenmin, dorp );
|
||||
return( 0 );
|
||||
}
|
153
mafft/src/mafft-7.487-with-extensions/core/replaceu.c
Normal file
153
mafft/src/mafft-7.487-with-extensions/core/replaceu.c
Normal file
|
@ -0,0 +1,153 @@
|
|||
#include "mltaln.h"
|
||||
|
||||
#define DEBUG 0
|
||||
|
||||
static int seedoffset;
|
||||
|
||||
static void replace_unusual( int n, char **seq, char *usual, char unknown, int (*uporlow)( int ) )
|
||||
{
|
||||
int i;
|
||||
char *pt;
|
||||
for( i=0; i<n; i++ )
|
||||
{
|
||||
pt = seq[i];
|
||||
while( *pt )
|
||||
{
|
||||
if( !strchr( usual, *pt ) ) *pt = unknown;
|
||||
else *pt = uporlow( *pt );
|
||||
pt++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void arguments( int argc, char *argv[] )
|
||||
{
|
||||
int c;
|
||||
|
||||
seedoffset = 0;
|
||||
inputfile = NULL;
|
||||
dorp = NOTSPECIFIED;
|
||||
|
||||
while( --argc > 0 && (*++argv)[0] == '-' )
|
||||
{
|
||||
while ( (c = *++argv[0]) )
|
||||
{
|
||||
switch( c )
|
||||
{
|
||||
case 'o':
|
||||
seedoffset = myatoi( *++argv );
|
||||
fprintf( stderr, "seedoffset = %d\n", seedoffset );
|
||||
--argc;
|
||||
goto nextoption;
|
||||
case 'i':
|
||||
inputfile = *++argv;
|
||||
fprintf( stderr, "inputfile = %s\n", inputfile );
|
||||
--argc;
|
||||
goto nextoption;
|
||||
case 'D':
|
||||
dorp = 'd';
|
||||
break;
|
||||
case 'P':
|
||||
dorp = 'p';
|
||||
break;
|
||||
default:
|
||||
fprintf( stderr, "illegal option %c\n", c );
|
||||
argc = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
nextoption:
|
||||
;
|
||||
}
|
||||
if( argc != 0 )
|
||||
{
|
||||
fprintf( stderr, "options: Check source file !\n" );
|
||||
exit( 1 );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
int main( int argc, char *argv[] )
|
||||
{
|
||||
FILE *infp;
|
||||
int nlenmin;
|
||||
char **name;
|
||||
char **seq;
|
||||
int *nlen;
|
||||
int i;
|
||||
char *usual;
|
||||
|
||||
arguments( argc, argv );
|
||||
|
||||
if( inputfile )
|
||||
{
|
||||
infp = fopen( inputfile, "r" );
|
||||
if( !infp )
|
||||
{
|
||||
fprintf( stderr, "Cannot open %s\n", inputfile );
|
||||
exit( 1 );
|
||||
}
|
||||
}
|
||||
else
|
||||
infp = stdin;
|
||||
|
||||
|
||||
// dorp = NOTSPECIFIED;
|
||||
getnumlen_casepreserve( infp, &nlenmin );
|
||||
|
||||
fprintf( stderr, "%d x %d - %d %c\n", njob, nlenmax, nlenmin, dorp );
|
||||
|
||||
seq = AllocateCharMtx( njob, nlenmax+1 );
|
||||
name = AllocateCharMtx( njob, B+1 );
|
||||
nlen = AllocateIntVec( njob );
|
||||
|
||||
readData_pointer_casepreserve( infp, name, nlen, seq );
|
||||
fclose( infp );
|
||||
|
||||
// for( i=0; i<njob; i++ ) gappick_samestring( seq[i] );
|
||||
|
||||
#if 0
|
||||
FILE *origfp;
|
||||
origfp = fopen( "_original", "w" );
|
||||
if( !origfp )
|
||||
{
|
||||
fprintf( stderr, "Cannot open _original\n" );
|
||||
exit( 1 );
|
||||
}
|
||||
for( i=0; i<njob; i++ )
|
||||
{
|
||||
nlen[i] = strlen( seq[i] );
|
||||
fprintf( origfp, ">%s\n", name[i]+1 );
|
||||
if( seq[i][nlen[i]-1] == '\n' ) seq[i][nlen[i]-1] = 0;
|
||||
fprintf( origfp, "%s\n", seq[i] );
|
||||
}
|
||||
fclose( origfp );
|
||||
#endif
|
||||
|
||||
if( dorp == 'p' )
|
||||
{
|
||||
usual = "ARNDCQEGHILKMFPSTWYVarndcqeghilkmfpstwyv-.";
|
||||
replace_unusual( njob, seq, usual, 'X', toupper );
|
||||
}
|
||||
else
|
||||
{
|
||||
usual = "ATGCUatgcuBDHKMNRSVWYXbdhkmnrsvwyx-";
|
||||
replace_unusual( njob, seq, usual, 'n', tolower );
|
||||
}
|
||||
|
||||
|
||||
|
||||
for( i=0; i<njob; i++ )
|
||||
{
|
||||
fprintf( stdout, ">_os_%d_oe_%s\n", i+seedoffset, name[i]+1 );
|
||||
fprintf( stdout, "%s\n", seq[i] );
|
||||
}
|
||||
|
||||
free( nlen );
|
||||
FreeCharMtx( seq );
|
||||
FreeCharMtx( name );
|
||||
|
||||
return( 0 );
|
||||
}
|
319
mafft/src/mafft-7.487-with-extensions/core/restoreu.c
Normal file
319
mafft/src/mafft-7.487-with-extensions/core/restoreu.c
Normal file
|
@ -0,0 +1,319 @@
|
|||
#include "mltaln.h"
|
||||
|
||||
#define DEBUG 0
|
||||
|
||||
char *alignmentfile;
|
||||
int keeplength;
|
||||
|
||||
static void fillorichar( int nseq, int *oripos, char **a, char **s )
|
||||
{
|
||||
int i;
|
||||
char *pta, *pts;
|
||||
for( i=0; i<nseq; i++ )
|
||||
{
|
||||
|
||||
pta = a[i];
|
||||
pts = s[oripos[i]];
|
||||
while( *pta )
|
||||
{
|
||||
if( *pta != '-' ) *pta = *pts++;
|
||||
if( *pta++ == 0 )
|
||||
{
|
||||
fprintf( stderr, "ERROR!!\n" );
|
||||
fprintf( stderr, "alignment is inconsistent with the original sequences (1)\n" );
|
||||
exit( 1 );
|
||||
}
|
||||
}
|
||||
if( *pts != 0 )
|
||||
{
|
||||
fprintf( stderr, "ERROR!!\n" );
|
||||
fprintf( stderr, "alignment is inconsistent with the original sequences (2)\n" );
|
||||
exit( 1 );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void arguments( int argc, char *argv[] )
|
||||
{
|
||||
int c;
|
||||
|
||||
keeplength = 0;
|
||||
|
||||
while( --argc > 0 && (*++argv)[0] == '-' )
|
||||
{
|
||||
while ( (c = *++argv[0]) )
|
||||
{
|
||||
switch( c )
|
||||
{
|
||||
case 'i':
|
||||
inputfile = *++argv;
|
||||
--argc;
|
||||
goto nextoption;
|
||||
case 'a':
|
||||
alignmentfile = *++argv;
|
||||
--argc;
|
||||
goto nextoption;
|
||||
case 'Z': // add2ndharfarg wo tsukau tame.
|
||||
break;
|
||||
case 'p': // add2ndharfarg wo tsukau tame.
|
||||
break;
|
||||
case 'Y':
|
||||
keeplength = 1;
|
||||
break;
|
||||
default:
|
||||
fprintf( stderr, "illegal option %c\n", c );
|
||||
argc = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
nextoption:
|
||||
;
|
||||
}
|
||||
if( argc != 0 )
|
||||
{
|
||||
fprintf( stderr, "options: Check source file !\n" );
|
||||
exit( 1 );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
int main( int argc, char *argv[] )
|
||||
{
|
||||
FILE *infp;
|
||||
FILE *alfp;
|
||||
FILE *dlfp;
|
||||
char **name;
|
||||
char **aname;
|
||||
char **oname;
|
||||
char **seq;
|
||||
char **aseq;
|
||||
int *nlen;
|
||||
int *oripos;
|
||||
char *npt, *npt0, *npt2, *pt, *pt2;
|
||||
int i, o, prelen;
|
||||
int nlenmin;
|
||||
int njobs, njoba;
|
||||
// int **dlist;
|
||||
// int *ndel;
|
||||
char *gett;
|
||||
|
||||
arguments( argc, argv );
|
||||
|
||||
if( inputfile )
|
||||
{
|
||||
infp = fopen( inputfile, "r" );
|
||||
if( !infp )
|
||||
{
|
||||
fprintf( stderr, "Cannot open %s\n", inputfile );
|
||||
exit( 1 );
|
||||
}
|
||||
}
|
||||
else
|
||||
infp = stdin;
|
||||
|
||||
if( alignmentfile )
|
||||
{
|
||||
alfp = fopen( alignmentfile, "r" );
|
||||
if( !alfp )
|
||||
{
|
||||
fprintf( stderr, "Cannot open %s\n", alignmentfile );
|
||||
exit( 1 );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf( stderr, "No alignment is given.\n" );
|
||||
exit( 1 );
|
||||
}
|
||||
|
||||
if( keeplength )
|
||||
{
|
||||
dlfp = fopen( "_deletelist", "r" );
|
||||
if( !dlfp )
|
||||
{
|
||||
fprintf( stderr, "Cannot open _deletefile\n" );
|
||||
exit( 1 );
|
||||
}
|
||||
}
|
||||
|
||||
dorp = NOTSPECIFIED;
|
||||
getnumlen_casepreserve( infp, &nlenmin );
|
||||
njobs = njob;
|
||||
// fprintf( stderr, "in infp, %d x %d - %d %c\n", njob, nlenmin, nlenmax, dorp );
|
||||
|
||||
seq = AllocateCharMtx( njob, nlenmax+1 );
|
||||
name = AllocateCharMtx( njob, B+1 );
|
||||
nlen = AllocateIntVec( njob );
|
||||
oripos = AllocateIntVec( njob );
|
||||
readData_pointer_casepreserve( infp, name, nlen, seq );
|
||||
fclose( infp );
|
||||
|
||||
dorp = NOTSPECIFIED;
|
||||
getnumlen( alfp );
|
||||
njoba = njob;
|
||||
// fprintf( stderr, "in alfp, %d x %d %c\n", njob, nlenmax, dorp );
|
||||
aseq = AllocateCharMtx( njob, nlenmax+1 );
|
||||
aname = AllocateCharMtx( njob, B+1 );
|
||||
oname = AllocateCharMtx( njob, B+1 );
|
||||
readData_pointer( alfp, aname, nlen, aseq );
|
||||
fclose( alfp );
|
||||
|
||||
for( i=0; i<njob; i++ ) gappick_samestring( seq[i] );
|
||||
|
||||
// reporterr( "seq[njob-1] = %s\n", seq[njob-1] );
|
||||
|
||||
if( keeplength )
|
||||
{
|
||||
gett = calloc( 1000, sizeof( char ) );
|
||||
// ndel = (int *)calloc( njob, sizeof( int ) );
|
||||
// for( i=0; i<njob; i++ ) ndel[i] = 0;
|
||||
// dlist = (int **)calloc( njob+1, sizeof( int * ) );
|
||||
// for( i=0; i<njob; i++ ) dlist[i] = NULL;
|
||||
// dlist[njob] = NULL;
|
||||
|
||||
while( 1 )
|
||||
{
|
||||
fgets( gett, 999, dlfp );
|
||||
if( feof( dlfp ) ) break;
|
||||
sscanf( gett, "%d %d", &i, &o );
|
||||
// reporterr( "%d, %d\n", i, o );
|
||||
// dlist[i] = realloc( dlist[i], sizeof( int ) * (ndel[i]+2) );
|
||||
// dlist[i][ndel[i]] = o;
|
||||
// ndel[i]++;
|
||||
|
||||
seq[i][o] = '-';
|
||||
|
||||
}
|
||||
fclose( dlfp );
|
||||
}
|
||||
|
||||
for( i=0; i<njob; i++ )
|
||||
{
|
||||
gappick_samestring( seq[i] );
|
||||
}
|
||||
|
||||
if( njoba != njobs )
|
||||
{
|
||||
fprintf( stderr, "ERROR!!\n" );
|
||||
fprintf( stderr, "In input file,\n" );
|
||||
fprintf( stderr, "njob = %d\n", njobs );
|
||||
fprintf( stderr, "but in alignment file,\n" );
|
||||
fprintf( stderr, "njob = %d\n", njoba );
|
||||
exit( 1 );
|
||||
}
|
||||
|
||||
for( i=0; i<njob; i++ )
|
||||
{
|
||||
#if 0
|
||||
if( strstr( aname[i], "_seed_" ) )
|
||||
{
|
||||
npt2 = aname[i] + 7;
|
||||
strcpy( oname[i], "=_seed_" );
|
||||
}
|
||||
else
|
||||
{
|
||||
npt2 = aname[i] + 1;
|
||||
strcpy( oname[i], "=" );
|
||||
}
|
||||
|
||||
fprintf( stderr, "npt2 = %s\n", npt2 );
|
||||
|
||||
o = oripos[i] = atoi( npt2 );
|
||||
npt = strstr( npt2, "_oe_" );
|
||||
if( npt == NULL )
|
||||
{
|
||||
fprintf( stderr, "Format error!\n" );
|
||||
exit( 1 );
|
||||
}
|
||||
npt += 4;
|
||||
strcat( oname[i], npt+1 );
|
||||
#endif
|
||||
npt0 = strstr( aname[i], "_os_" );
|
||||
if( npt0 == NULL )
|
||||
{
|
||||
fprintf( stderr, "Format error!\n" );
|
||||
exit( 1 );
|
||||
}
|
||||
npt2 = npt0 + 4;
|
||||
o = oripos[i] = atoi( npt2 );
|
||||
|
||||
npt = strstr( aname[i], "_oe_" );
|
||||
if( npt == NULL )
|
||||
{
|
||||
fprintf( stderr, "Format error!\n" );
|
||||
exit( 1 );
|
||||
}
|
||||
npt += 4;
|
||||
|
||||
pt2 = npt;
|
||||
pt = npt2 - 4;
|
||||
while( *pt ) *pt++ = *pt2++; // okashii
|
||||
|
||||
prelen = npt0-aname[i];
|
||||
strncpy( oname[i], aname[i], prelen ); oname[i][prelen] = 0;
|
||||
strcat( oname[i], npt0 );
|
||||
|
||||
#if 0
|
||||
pt = strstr( aname[i], "_numo_e" );
|
||||
if( pt ) pt += 8;
|
||||
else pt = aname[i] + 1;
|
||||
|
||||
if( strstr( pt, "_seed_" ) ) pt += 6;
|
||||
|
||||
fprintf( stderr, "pt = :%s:\n", pt );
|
||||
|
||||
#endif
|
||||
// fprintf( stderr, "npt0 = :%s:\n", npt0 );
|
||||
//
|
||||
// reporterr( "oname[i] = %s\n", oname[i] );
|
||||
// reporterr( "aname[i] = %s\n", aname[i] );
|
||||
// reporterr( " name[i] = %s\n", name[i] );
|
||||
|
||||
// fprintf( stderr, "aname[i] = :%s:\n", aname[i] );
|
||||
// fprintf( stderr, "pt = :%s:\n", pt );
|
||||
// fprintf( stderr, "oname[i] = :%s:\n", oname[i] );
|
||||
// fprintf( stderr, "name[o] = :%s:\n", name[o] );
|
||||
|
||||
if( strncmp( npt0, name[o]+1, 10 ) )
|
||||
{
|
||||
fprintf( stderr, "ERROR!!\n" );
|
||||
fprintf( stderr, "In input file,\n" );
|
||||
fprintf( stderr, "name[%d] = %s\n", o, name[o] );
|
||||
fprintf( stderr, "but in alignment file,\n" );
|
||||
fprintf( stderr, "oname[%d] = %s\n", i, oname[i] );
|
||||
fprintf( stderr, "npt0 = %s\n", npt0 );
|
||||
fprintf( stderr, "prelen = %d\n", prelen );
|
||||
fprintf( stderr, "name[%d] = %s\n", i, aname[i] );
|
||||
exit( 1 );
|
||||
}
|
||||
#if 0
|
||||
else
|
||||
{
|
||||
fprintf( stderr, "OK!!\n" );
|
||||
fprintf( stderr, "In input file,\n" );
|
||||
fprintf( stderr, "name[%d] = %s\n", o, name[o] );
|
||||
fprintf( stderr, "and in alignment file,\n" );
|
||||
fprintf( stderr, "name[%d] = %s\n", i, aname[i] );
|
||||
fprintf( stderr, "\n" );
|
||||
}
|
||||
#endif
|
||||
}
|
||||
// fprintf( stderr, "seq[0] = %s\n", seq[0] );
|
||||
// fprintf( stderr, "aseq[0] = %s\n", aseq[0] );
|
||||
|
||||
fillorichar( njob, oripos, aseq, seq );
|
||||
|
||||
|
||||
writeData_pointer( stdout, njob, oname, nlen, aseq );
|
||||
|
||||
FreeCharMtx( seq );
|
||||
FreeCharMtx( aseq );
|
||||
FreeCharMtx( name );
|
||||
FreeCharMtx( aname );
|
||||
FreeCharMtx( oname );
|
||||
free( nlen );
|
||||
free( oripos );
|
||||
|
||||
return( 0 );
|
||||
}
|
527
mafft/src/mafft-7.487-with-extensions/core/rna.c
Normal file
527
mafft/src/mafft-7.487-with-extensions/core/rna.c
Normal file
|
@ -0,0 +1,527 @@
|
|||
#include "mltaln.h"
|
||||
#include "dp.h"
|
||||
|
||||
#define MEMSAVE 1
|
||||
|
||||
#define DEBUG 1
|
||||
#define USE_PENALTY_EX 1
|
||||
#define STOREWM 1
|
||||
|
||||
|
||||
|
||||
#if 0
|
||||
static double singleribosumscore( int n1, int n2, char **s1, char **s2, double *eff1, double *eff2, int p1, int p2 )
|
||||
{
|
||||
double val;
|
||||
int i, j;
|
||||
int code1, code2;
|
||||
|
||||
val = 0.0;
|
||||
for( i=0; i<n1; i++ ) for( j=0; j<n2; j++ )
|
||||
{
|
||||
code1 = amino_n[(int)s1[i][p1]];
|
||||
if( code1 > 3 ) code1 = 36;
|
||||
code2 = amino_n[(int)s2[j][p2]];
|
||||
if( code2 > 3 ) code2 = 36;
|
||||
|
||||
// fprintf( stderr, "'l'%c-%c: %f\n", s1[i][p1], s2[j][p2], (double)ribosumdis[code1][code2] );
|
||||
|
||||
val += (double)ribosumdis[code1][code2] * eff1[i] * eff2[j];
|
||||
}
|
||||
return( val );
|
||||
}
|
||||
static double pairedribosumscore53( int n1, int n2, char **s1, char **s2, double *eff1, double *eff2, int p1, int p2, int c1, int c2 )
|
||||
{
|
||||
double val;
|
||||
int i, j;
|
||||
int code1o, code1u, code2o, code2u, code1, code2;
|
||||
|
||||
val = 0.0;
|
||||
for( i=0; i<n1; i++ ) for( j=0; j<n2; j++ )
|
||||
{
|
||||
code1o = amino_n[(int)s1[i][p1]];
|
||||
code1u = amino_n[(int)s1[i][c1]];
|
||||
if( code1o > 3 ) code1 = code1o = 36;
|
||||
else if( code1u > 3 ) code1 = 36;
|
||||
else code1 = 4 + code1o * 4 + code1u;
|
||||
|
||||
code2o = amino_n[(int)s2[j][p2]];
|
||||
code2u = amino_n[(int)s2[j][c2]];
|
||||
if( code2o > 3 ) code2 = code1o = 36;
|
||||
else if( code2u > 3 ) code2 = 36;
|
||||
else code2 = 4 + code2o * 4 + code2u;
|
||||
|
||||
|
||||
// fprintf( stderr, "%c%c-%c%c: %f\n", s1[i][p1], s1[i][c1], s2[j][p2], s2[j][c2], (double)ribosumdis[code1][code2] );
|
||||
|
||||
if( code1 == 36 || code2 == 36 )
|
||||
val += (double)n_dis[code1o][code2o] * eff1[i] * eff2[j];
|
||||
else
|
||||
val += (double)ribosumdis[code1][code2] * eff1[i] * eff2[j];
|
||||
}
|
||||
return( val );
|
||||
}
|
||||
|
||||
static double pairedribosumscore35( int n1, int n2, char **s1, char **s2, double *eff1, double *eff2, int p1, int p2, int c1, int c2 )
|
||||
{
|
||||
double val;
|
||||
int i, j;
|
||||
int code1o, code1u, code2o, code2u, code1, code2;
|
||||
|
||||
val = 0.0;
|
||||
for( i=0; i<n1; i++ ) for( j=0; j<n2; j++ )
|
||||
{
|
||||
code1o = amino_n[(int)s1[i][p1]];
|
||||
code1u = amino_n[(int)s1[i][c1]];
|
||||
if( code1o > 3 ) code1 = code1o = 36;
|
||||
else if( code1u > 3 ) code1 = 36;
|
||||
else code1 = 4 + code1u * 4 + code1o;
|
||||
|
||||
code2o = amino_n[(int)s2[j][p2]];
|
||||
code2u = amino_n[(int)s2[j][c2]];
|
||||
if( code2o > 3 ) code2 = code1o = 36;
|
||||
else if( code2u > 3 ) code2 = 36;
|
||||
else code2 = 4 + code2u * 4 + code2o;
|
||||
|
||||
|
||||
// fprintf( stderr, "%c%c-%c%c: %f\n", s1[i][p1], s1[i][c1], s2[j][p2], s2[j][c2], (double)ribosumdis[code1][code2] );
|
||||
|
||||
if( code1 == 36 || code2 == 36 )
|
||||
val += (double)n_dis[code1o][code2o] * eff1[i] * eff2[j];
|
||||
else
|
||||
val += (double)ribosumdis[code1][code2] * eff1[i] * eff2[j];
|
||||
}
|
||||
return( val );
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
static void mccaskillextract( char **seq, char **nogap, int nseq, RNApair **pairprob, RNApair ***single, int **sgapmap, double *eff )
|
||||
{
|
||||
int lgth;
|
||||
int nogaplgth;
|
||||
int i, j;
|
||||
int left, right, adpos;
|
||||
double prob;
|
||||
static TLS int *pairnum;
|
||||
RNApair *pt, *pt2;
|
||||
|
||||
lgth = strlen( seq[0] );
|
||||
pairnum = calloc( lgth, sizeof( int ) );
|
||||
for( i=0; i<lgth; i++ ) pairnum[i] = 0;
|
||||
|
||||
for( i=0; i<nseq; i++ )
|
||||
{
|
||||
nogaplgth = strlen( nogap[i] );
|
||||
for( j=0; j<nogaplgth; j++ ) for( pt=single[i][j]; pt->bestpos!=-1; pt++ )
|
||||
{
|
||||
left = sgapmap[i][j];
|
||||
right = sgapmap[i][pt->bestpos];
|
||||
prob = pt->bestscore;
|
||||
|
||||
|
||||
for( pt2=pairprob[left]; pt2->bestpos!=-1; pt2++ )
|
||||
if( pt2->bestpos == right ) break;
|
||||
|
||||
// fprintf( stderr, "i,j=%d,%d, left=%d, right=%d, pt=%d, pt2->bestpos = %d\n", i, j, left, right, pt-single[i][j], pt2->bestpos );
|
||||
if( pt2->bestpos == -1 )
|
||||
{
|
||||
pairprob[left] = (RNApair *)realloc( pairprob[left], (pairnum[left]+2) * sizeof( RNApair ) );
|
||||
adpos = pairnum[left];
|
||||
pairnum[left]++;
|
||||
pairprob[left][adpos].bestscore = 0.0;
|
||||
pairprob[left][adpos].bestpos = right;
|
||||
pairprob[left][adpos+1].bestscore = -1.0;
|
||||
pairprob[left][adpos+1].bestpos = -1;
|
||||
pt2 = pairprob[left]+adpos;
|
||||
}
|
||||
else
|
||||
adpos = pt2-pairprob[left];
|
||||
|
||||
pt2->bestscore += prob * eff[i];
|
||||
|
||||
if( pt2->bestpos != right )
|
||||
{
|
||||
fprintf( stderr, "okashii!\n" );
|
||||
exit( 1 );
|
||||
}
|
||||
// fprintf( stderr, "adding %d-%d, %f\n", left, right, prob );
|
||||
// fprintf( stderr, "pairprob[0][0].bestpos=%d\n", pairprob[0][0].bestpos );
|
||||
// fprintf( stderr, "pairprob[0][0].bestscore=%f\n", pairprob[0][0].bestscore );
|
||||
}
|
||||
}
|
||||
|
||||
// fprintf( stderr, "before taikakuka\n" );
|
||||
for( i=0; i<lgth; i++ ) for( j=0; j<pairnum[i]; j++ )
|
||||
{
|
||||
if( pairprob[i][j].bestpos > -1 )
|
||||
{
|
||||
// pairprob[i][j].bestscore /= (double)nseq;
|
||||
// fprintf( stderr, "pair of %d = %d (%f) %c:%c\n", i, pairprob[i][j].bestpos, pairprob[i][j].bestscore, seq[0][i], seq[0][pairprob[i][j].bestpos] );
|
||||
}
|
||||
}
|
||||
|
||||
#if 0
|
||||
for( i=0; i<lgth; i++ ) for( j=0; j<pairnum[i]; j++ )
|
||||
{
|
||||
right=pairprob[i][j].bestpos;
|
||||
if( right < i ) continue;
|
||||
fprintf( stderr, "no%d-%d, adding %d -> %d\n", i, j, right, i );
|
||||
pairprob[right] = (RNApair *)realloc( pairprob[right], (pairnum[right]+2) * sizeof( RNApair ) );
|
||||
pairprob[right][pairnum[right]].bestscore = pairprob[i][j].bestscore;
|
||||
pairprob[right][pairnum[right]].bestpos = i;
|
||||
pairnum[right]++;
|
||||
pairprob[right][pairnum[right]].bestscore = -1.0;
|
||||
pairprob[right][pairnum[right]].bestpos = -1;
|
||||
}
|
||||
#endif
|
||||
|
||||
free( pairnum );
|
||||
|
||||
}
|
||||
|
||||
|
||||
void rnaalifoldcall( char **seq, int nseq, RNApair **pairprob )
|
||||
{
|
||||
int lgth;
|
||||
int i;
|
||||
static TLS int *order = NULL;
|
||||
static TLS char **name = NULL;
|
||||
char gett[1000];
|
||||
FILE *fp;
|
||||
int left, right, dumm;
|
||||
double prob;
|
||||
static TLS int pid;
|
||||
static TLS char fnamein[100];
|
||||
static TLS char cmd[1000];
|
||||
static TLS int *pairnum;
|
||||
|
||||
lgth = strlen( seq[0] );
|
||||
if( order == NULL )
|
||||
{
|
||||
pid = (int)getpid();
|
||||
sprintf( fnamein, "/tmp/_rnaalifoldin.%d", pid );
|
||||
order = AllocateIntVec( njob );
|
||||
name = AllocateCharMtx( njob, 10 );
|
||||
for( i=0; i<njob; i++ )
|
||||
{
|
||||
order[i] = i;
|
||||
sprintf( name[i], "seq%d", i );
|
||||
}
|
||||
}
|
||||
pairnum = calloc( lgth, sizeof( int ) );
|
||||
for( i=0; i<lgth; i++ ) pairnum[i] = 0;
|
||||
|
||||
fp = fopen( fnamein, "w" );
|
||||
if( !fp )
|
||||
{
|
||||
fprintf( stderr, "Cannot open /tmp/_rnaalifoldin\n" );
|
||||
exit( 1 );
|
||||
}
|
||||
clustalout_pointer( fp, nseq, lgth, seq, name, NULL, NULL, order, 15 );
|
||||
fclose( fp );
|
||||
|
||||
sprintf( cmd, "RNAalifold -p %s", fnamein );
|
||||
system( cmd );
|
||||
|
||||
fp = fopen( "alifold.out", "r" );
|
||||
if( !fp )
|
||||
{
|
||||
fprintf( stderr, "Cannot open /tmp/_rnaalifoldin\n" );
|
||||
exit( 1 );
|
||||
}
|
||||
|
||||
#if 0
|
||||
for( i=0; i<lgth; i++ ) // atode kesu
|
||||
{
|
||||
pairprob[i] = (RNApair *)realloc( pairprob[i], (2) * sizeof( RNApair ) ); // atode kesu
|
||||
pairprob[i][1].bestscore = -1.0;
|
||||
pairprob[i][1].bestpos = -1;
|
||||
}
|
||||
#endif
|
||||
|
||||
while( 1 )
|
||||
{
|
||||
fgets( gett, 999, fp );
|
||||
if( gett[0] == '(' ) break;
|
||||
if( gett[0] == '{' ) break;
|
||||
if( gett[0] == '.' ) break;
|
||||
if( gett[0] == ',' ) break;
|
||||
if( gett[0] != ' ' ) continue;
|
||||
|
||||
sscanf( gett, "%d %d %d %lf", &left, &right, &dumm, &prob );
|
||||
left--;
|
||||
right--;
|
||||
|
||||
|
||||
#if 0
|
||||
if( prob > 50.0 && prob > pairprob[left][0].bestscore )
|
||||
{
|
||||
pairprob[left][0].bestscore = prob;
|
||||
pairprob[left][0].bestpos = right;
|
||||
#else
|
||||
if( prob > 0.0 )
|
||||
{
|
||||
pairprob[left] = (RNApair *)realloc( pairprob[left], (pairnum[left]+2) * sizeof( RNApair ) );
|
||||
pairprob[left][pairnum[left]].bestscore = prob / 100.0;
|
||||
pairprob[left][pairnum[left]].bestpos = right;
|
||||
pairnum[left]++;
|
||||
pairprob[left][pairnum[left]].bestscore = -1.0;
|
||||
pairprob[left][pairnum[left]].bestpos = -1;
|
||||
fprintf( stderr, "%d-%d, %f\n", left, right, prob );
|
||||
|
||||
pairprob[right] = (RNApair *)realloc( pairprob[right], (pairnum[right]+2) * sizeof( RNApair ) );
|
||||
pairprob[right][pairnum[right]].bestscore = prob / 100.0;
|
||||
pairprob[right][pairnum[right]].bestpos = left;
|
||||
pairnum[right]++;
|
||||
pairprob[right][pairnum[right]].bestscore = -1.0;
|
||||
pairprob[right][pairnum[right]].bestpos = -1;
|
||||
fprintf( stderr, "%d-%d, %f\n", left, right, prob );
|
||||
#endif
|
||||
}
|
||||
}
|
||||
fclose( fp );
|
||||
sprintf( cmd, "rm -f %s", fnamein );
|
||||
system( cmd );
|
||||
|
||||
for( i=0; i<lgth; i++ )
|
||||
{
|
||||
if( (right=pairprob[i][0].bestpos) > -1 )
|
||||
{
|
||||
pairprob[right][0].bestpos = i;
|
||||
pairprob[right][0].bestscore = pairprob[i][0].bestscore;
|
||||
}
|
||||
}
|
||||
|
||||
#if 0
|
||||
for( i=0; i<lgth; i++ ) // atode kesu
|
||||
if( pairprob[i][0].bestscore > -1 ) pairprob[i][0].bestscore = 1.0; // atode kesu
|
||||
#endif
|
||||
|
||||
// fprintf( stderr, "after taikakuka in rnaalifoldcall\n" );
|
||||
// for( i=0; i<lgth; i++ )
|
||||
// {
|
||||
// fprintf( stderr, "pair of %d = %d (%f) %c:%c\n", i, pairprob[i][0].bestpos, pairprob[i][0].bestscore, seq[0][i], seq[0][pairprob[i][0].bestpos] );
|
||||
// }
|
||||
|
||||
free( pairnum );
|
||||
}
|
||||
|
||||
|
||||
static void utot( int n, int l, char **s )
|
||||
{
|
||||
int i, j;
|
||||
for( i=0; i<l; i++ )
|
||||
{
|
||||
for( j=0; j<n; j++ )
|
||||
{
|
||||
if ( s[j][i] == 'a' ) s[j][i] = 'a';
|
||||
else if( s[j][i] == 't' ) s[j][i] = 't';
|
||||
else if( s[j][i] == 'u' ) s[j][i] = 't';
|
||||
else if( s[j][i] == 'g' ) s[j][i] = 'g';
|
||||
else if( s[j][i] == 'c' ) s[j][i] = 'c';
|
||||
else if( s[j][i] == '-' ) s[j][i] = '-';
|
||||
else s[j][i] = 'n';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void foldrna( int nseq1, int nseq2, char **seq1, char **seq2, double *eff1, double *eff2, RNApair ***grouprna1, RNApair ***grouprna2, double **impmtx, int *gapmap1, int *gapmap2, RNApair *additionalpair )
|
||||
{
|
||||
int i, j;
|
||||
// int ui, uj;
|
||||
// int uiup, ujup;
|
||||
int uido, ujdo;
|
||||
static TLS char **useq1, **useq2;
|
||||
static TLS char **oseq1, **oseq2, **oseq1r, **oseq2r, *odir1, *odir2;
|
||||
static TLS RNApair **pairprob1, **pairprob2;
|
||||
static TLS RNApair *pairpt1, *pairpt2;
|
||||
int lgth1 = strlen( seq1[0] );
|
||||
int lgth2 = strlen( seq2[0] );
|
||||
static TLS double **impmtx2;
|
||||
static TLS double **map;
|
||||
// double lenfac;
|
||||
double prob;
|
||||
int **sgapmap1, **sgapmap2;
|
||||
// char *nogapdum;
|
||||
double **tbppmtx;
|
||||
|
||||
|
||||
// fprintf( stderr, "nseq1=%d, lgth1=%d\n", nseq1, lgth1 );
|
||||
useq1 = AllocateCharMtx( nseq1, lgth1+10 );
|
||||
useq2 = AllocateCharMtx( nseq2, lgth2+10 );
|
||||
oseq1 = AllocateCharMtx( nseq1, lgth1+10 );
|
||||
oseq2 = AllocateCharMtx( nseq2, lgth2+10 );
|
||||
oseq1r = AllocateCharMtx( nseq1, lgth1+10 );
|
||||
oseq2r = AllocateCharMtx( nseq2, lgth2+10 );
|
||||
odir1 = AllocateCharVec( lgth1+10 );
|
||||
odir2 = AllocateCharVec( lgth2+10 );
|
||||
sgapmap1 = AllocateIntMtx( nseq1, lgth1+1 );
|
||||
sgapmap2 = AllocateIntMtx( nseq2, lgth2+1 );
|
||||
// nogapdum = AllocateCharVec( MAX( lgth1, lgth2 ) );
|
||||
pairprob1 = (RNApair **)calloc( lgth1, sizeof( RNApair *) );
|
||||
pairprob2 = (RNApair **)calloc( lgth2, sizeof( RNApair *) );
|
||||
map = AllocateFloatMtx( lgth1, lgth2 );
|
||||
impmtx2 = AllocateFloatMtx( lgth1, lgth2 );
|
||||
tbppmtx = AllocateFloatMtx( lgth1, lgth2 );
|
||||
|
||||
for( i=0; i<nseq1; i++ ) strcpy( useq1[i], seq1[i] );
|
||||
for( i=0; i<nseq2; i++ ) strcpy( useq2[i], seq2[i] );
|
||||
for( i=0; i<nseq1; i++ ) strcpy( oseq1[i], seq1[i] );
|
||||
for( i=0; i<nseq2; i++ ) strcpy( oseq2[i], seq2[i] );
|
||||
|
||||
for( i=0; i<nseq1; i++ ) commongappick_record( 1, useq1+i, sgapmap1[i] );
|
||||
for( i=0; i<nseq2; i++ ) commongappick_record( 1, useq2+i, sgapmap2[i] );
|
||||
|
||||
for( i=0; i<lgth1; i++ )
|
||||
{
|
||||
pairprob1[i] = (RNApair *)calloc( 1, sizeof( RNApair ) );
|
||||
pairprob1[i][0].bestpos = -1;
|
||||
pairprob1[i][0].bestscore = -1;
|
||||
}
|
||||
for( i=0; i<lgth2; i++ )
|
||||
{
|
||||
pairprob2[i] = (RNApair *)calloc( 1, sizeof( RNApair ) );
|
||||
pairprob2[i][0].bestpos = -1;
|
||||
pairprob2[i][0].bestscore = -1;
|
||||
}
|
||||
|
||||
utot( nseq1, lgth1, oseq1 );
|
||||
utot( nseq2, lgth2, oseq2 );
|
||||
|
||||
// fprintf( stderr, "folding group1\n" );
|
||||
// rnalocal( oseq1, useq1, eff1, eff1, nseq1, nseq1, lgth1+10, pair1 );
|
||||
|
||||
/* base-pairing probability of group 1 */
|
||||
if( rnaprediction == 'r' )
|
||||
rnaalifoldcall( oseq1, nseq1, pairprob1 );
|
||||
else
|
||||
mccaskillextract( oseq1, useq1, nseq1, pairprob1, grouprna1, sgapmap1, eff1 );
|
||||
|
||||
|
||||
// fprintf( stderr, "folding group2\n" );
|
||||
// rnalocal( oseq2, useq2, eff2, eff2, nseq2, nseq2, lgth2+10, pair2 );
|
||||
|
||||
/* base-pairing probability of group 2 */
|
||||
if( rnaprediction == 'r' )
|
||||
rnaalifoldcall( oseq2, nseq2, pairprob2 );
|
||||
else
|
||||
mccaskillextract( oseq2, useq2, nseq2, pairprob2, grouprna2, sgapmap2, eff2 );
|
||||
|
||||
|
||||
|
||||
#if 0
|
||||
makerseq( oseq1, oseq1r, odir1, pairprob1, nseq1, lgth1 );
|
||||
makerseq( oseq2, oseq2r, odir2, pairprob2, nseq2, lgth2 );
|
||||
|
||||
fprintf( stderr, "%s\n", odir2 );
|
||||
|
||||
for( i=0; i<nseq1; i++ )
|
||||
{
|
||||
fprintf( stdout, ">ori\n%s\n", oseq1[0] );
|
||||
fprintf( stdout, ">rev\n%s\n", oseq1r[0] );
|
||||
}
|
||||
#endif
|
||||
|
||||
/* similarity score */
|
||||
Lalignmm_hmout( oseq1, oseq2, eff1, eff2, nseq1, nseq2, 10000, NULL, NULL, NULL, NULL, map );
|
||||
|
||||
if( 1 )
|
||||
{
|
||||
if( RNAscoremtx == 'n' )
|
||||
{
|
||||
for( i=0; i<lgth1; i++ ) for( j=0; j<lgth2; j++ )
|
||||
{
|
||||
// impmtx2[i][j] = osoiaveragescore( nseq1, nseq2, oseq1, oseq2, eff1, eff2, i, j ) * consweight_multi;
|
||||
impmtx2[i][j] = 0.0;
|
||||
}
|
||||
}
|
||||
else if( RNAscoremtx == 'r' )
|
||||
{
|
||||
fprintf( stderr, "Unexpected error. Please contact katoh@ifrec.osaka-u.ac.jp\n" );
|
||||
}
|
||||
|
||||
|
||||
/* four-way consistency */
|
||||
|
||||
for( i=0; i<lgth1; i++ ) for( pairpt1=pairprob1[i]; pairpt1->bestpos!=-1; pairpt1++ )
|
||||
{
|
||||
|
||||
// if( pairprob1[i] == NULL ) continue;
|
||||
|
||||
for( j=0; j<lgth2; j++ ) for( pairpt2=pairprob2[j]; pairpt2->bestpos!=-1; pairpt2++ )
|
||||
{
|
||||
// fprintf( stderr, "i=%d, j=%d, pn1=%d, pn2=%d\n", i, j, pairpt1-pairprob1[i], pairpt2-pairprob2[j] );
|
||||
// if( pairprob2[j] == NULL ) continue;
|
||||
|
||||
uido = pairpt1->bestpos;
|
||||
ujdo = pairpt2->bestpos;
|
||||
prob = pairpt1->bestscore * pairpt2->bestscore;
|
||||
// prob = 1.0;
|
||||
// fprintf( stderr, "i=%d->uido=%d, j=%d->ujdo=%d\n", i, uido, j, ujdo );
|
||||
|
||||
// fprintf( stderr, "impmtx2[%d][%d] = %f\n", i, j, impmtx2[i][j] );
|
||||
|
||||
// if( i < uido && j > ujdo ) continue;
|
||||
// if( i > uido && j < ujdo ) continue;
|
||||
|
||||
|
||||
// posdistj = abs( ujdo-j );
|
||||
|
||||
// if( uido > -1 && ujdo > -1 )
|
||||
if( uido > -1 && ujdo > -1 && ( ( i > uido && j > ujdo ) || ( i < uido && j < ujdo ) ) )
|
||||
{
|
||||
{
|
||||
impmtx2[i][j] += MAX( 0, map[uido][ujdo] ) * consweight_rna * 600 * prob; // osoi
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
for( i=0; i<lgth1; i++ ) for( j=0; j<lgth2; j++ )
|
||||
{
|
||||
impmtx[i][j] += impmtx2[i][j];
|
||||
// fprintf( stderr, "fastathreshold=%f, consweight_multi=%f, consweight_rna=%f\n", fastathreshold, consweight_multi, consweight_rna );
|
||||
// impmtx[i][j] *= 0.5;
|
||||
}
|
||||
|
||||
// impmtx[0][0] += 10000.0;
|
||||
// impmtx[lgth1-1][lgth2-1] += 10000.0;
|
||||
|
||||
|
||||
|
||||
#if 0
|
||||
fprintf( stdout, "#impmtx2 = \n" );
|
||||
for( i=0; i<lgth1; i++ )
|
||||
{
|
||||
for( j=0; j<lgth2; j++ )
|
||||
{
|
||||
fprintf( stdout, "%d %d %f\n", i, j, impmtx2[i][j] );
|
||||
}
|
||||
fprintf( stdout, "\n" );
|
||||
}
|
||||
exit( 1 );
|
||||
#endif
|
||||
}
|
||||
|
||||
FreeCharMtx( useq1 );
|
||||
FreeCharMtx( useq2 );
|
||||
FreeCharMtx( oseq1 );
|
||||
FreeCharMtx( oseq2 );
|
||||
FreeCharMtx( oseq1r );
|
||||
FreeCharMtx( oseq2r );
|
||||
free( odir1 );
|
||||
free( odir2 );
|
||||
FreeFloatMtx( impmtx2 );
|
||||
FreeFloatMtx( map );
|
||||
FreeIntMtx( sgapmap1 );
|
||||
FreeIntMtx( sgapmap2 );
|
||||
FreeFloatMtx( tbppmtx );
|
||||
|
||||
for( i=0; i<lgth1; i++ ) free( pairprob1[i] );
|
||||
for( i=0; i<lgth2; i++ ) free( pairprob2[i] );
|
||||
free( pairprob1 );
|
||||
free( pairprob2 );
|
||||
}
|
||||
|
460
mafft/src/mafft-7.487-with-extensions/core/rnatest.c
Normal file
460
mafft/src/mafft-7.487-with-extensions/core/rnatest.c
Normal file
|
@ -0,0 +1,460 @@
|
|||
#include "mltaln.h"
|
||||
|
||||
#define DEBUG 0
|
||||
#define IODEBUG 0
|
||||
#define SCOREOUT 0
|
||||
|
||||
|
||||
|
||||
void arguments( int argc, char *argv[] )
|
||||
{
|
||||
int c;
|
||||
|
||||
inputfile = NULL;
|
||||
fftkeika = 0;
|
||||
pslocal = -1000.0;
|
||||
constraint = 0;
|
||||
nblosum = 62;
|
||||
fmodel = 0;
|
||||
calledByXced = 0;
|
||||
devide = 0;
|
||||
use_fft = 0;
|
||||
fftscore = 1;
|
||||
fftRepeatStop = 0;
|
||||
fftNoAnchStop = 0;
|
||||
weight = 3;
|
||||
utree = 1;
|
||||
tbutree = 1;
|
||||
refine = 0;
|
||||
check = 1;
|
||||
cut = 0.0;
|
||||
disp = 0;
|
||||
outgap = 1;
|
||||
alg = 'A';
|
||||
mix = 0;
|
||||
tbitr = 0;
|
||||
scmtd = 5;
|
||||
tbweight = 0;
|
||||
tbrweight = 3;
|
||||
checkC = 0;
|
||||
treemethod = 'x';
|
||||
contin = 0;
|
||||
scoremtx = 1;
|
||||
kobetsubunkatsu = 0;
|
||||
divpairscore = 0;
|
||||
dorp = NOTSPECIFIED;
|
||||
ppenalty = NOTSPECIFIED;
|
||||
ppenalty_OP = NOTSPECIFIED;
|
||||
ppenalty_ex = NOTSPECIFIED;
|
||||
ppenalty_EX = NOTSPECIFIED;
|
||||
poffset = NOTSPECIFIED;
|
||||
kimuraR = NOTSPECIFIED;
|
||||
pamN = NOTSPECIFIED;
|
||||
geta2 = GETA2;
|
||||
fftWinSize = NOTSPECIFIED;
|
||||
fftThreshold = NOTSPECIFIED;
|
||||
RNAppenalty = NOTSPECIFIED;
|
||||
RNApthr = NOTSPECIFIED;
|
||||
|
||||
while( --argc > 0 && (*++argv)[0] == '-' )
|
||||
{
|
||||
while ( ( c = *++argv[0] ) )
|
||||
{
|
||||
switch( c )
|
||||
{
|
||||
case 'i':
|
||||
inputfile = *++argv;
|
||||
fprintf( stderr, "inputfile = %s\n", inputfile );
|
||||
--argc;
|
||||
goto nextoption;
|
||||
case 'o':
|
||||
RNAppenalty = (int)( atof( *++argv ) * 1000 - 0.5 );
|
||||
--argc;
|
||||
goto nextoption;
|
||||
case 'f':
|
||||
ppenalty = (int)( atof( *++argv ) * 1000 - 0.5 );
|
||||
--argc;
|
||||
goto nextoption;
|
||||
case 'g':
|
||||
ppenalty_ex = (int)( atof( *++argv ) * 1000 - 0.5 );
|
||||
--argc;
|
||||
goto nextoption;
|
||||
case 'O':
|
||||
ppenalty_OP = (int)( atof( *++argv ) * 1000 - 0.5 );
|
||||
--argc;
|
||||
goto nextoption;
|
||||
case 'E':
|
||||
ppenalty_EX = (int)( atof( *++argv ) * 1000 - 0.5 );
|
||||
--argc;
|
||||
goto nextoption;
|
||||
case 'h':
|
||||
poffset = (int)( atof( *++argv ) * 1000 - 0.5 );
|
||||
--argc;
|
||||
goto nextoption;
|
||||
case 'k':
|
||||
kimuraR = myatoi( *++argv );
|
||||
// fprintf( stderr, "kimuraR = %d\n", kimuraR );
|
||||
--argc;
|
||||
goto nextoption;
|
||||
case 'b':
|
||||
nblosum = myatoi( *++argv );
|
||||
scoremtx = 1;
|
||||
fprintf( stderr, "blosum %d\n", nblosum );
|
||||
--argc;
|
||||
goto nextoption;
|
||||
case 'j':
|
||||
pamN = myatoi( *++argv );
|
||||
scoremtx = 0;
|
||||
TMorJTT = JTT;
|
||||
fprintf( stderr, "jtt %d\n", pamN );
|
||||
--argc;
|
||||
goto nextoption;
|
||||
case 'm':
|
||||
pamN = myatoi( *++argv );
|
||||
scoremtx = 0;
|
||||
TMorJTT = TM;
|
||||
fprintf( stderr, "TM %d\n", pamN );
|
||||
--argc;
|
||||
goto nextoption;
|
||||
case 'l':
|
||||
ppslocal = (int)( atof( *++argv ) * 1000 + 0.5 );
|
||||
pslocal = (int)( 600.0 / 1000.0 * ppslocal + 0.5);
|
||||
// fprintf( stderr, "ppslocal = %d\n", ppslocal );
|
||||
// fprintf( stderr, "pslocal = %d\n", pslocal );
|
||||
--argc;
|
||||
goto nextoption;
|
||||
#if 1
|
||||
case 'a':
|
||||
fmodel = 1;
|
||||
break;
|
||||
#endif
|
||||
case 'r':
|
||||
fmodel = -1;
|
||||
break;
|
||||
case 'D':
|
||||
dorp = 'd';
|
||||
break;
|
||||
case 'P':
|
||||
dorp = 'p';
|
||||
break;
|
||||
#if 0
|
||||
case 'e':
|
||||
fftscore = 0;
|
||||
break;
|
||||
case 'O':
|
||||
fftNoAnchStop = 1;
|
||||
break;
|
||||
case 'R':
|
||||
fftRepeatStop = 1;
|
||||
break;
|
||||
#endif
|
||||
case 'Q':
|
||||
calledByXced = 1;
|
||||
break;
|
||||
case 's':
|
||||
treemethod = 's';
|
||||
break;
|
||||
case 'x':
|
||||
disp = 1;
|
||||
break;
|
||||
case 'p':
|
||||
treemethod = 'p';
|
||||
break;
|
||||
#if 0
|
||||
case 'a':
|
||||
alg = 'a';
|
||||
break;
|
||||
#endif
|
||||
case 'S':
|
||||
alg = 'S';
|
||||
break;
|
||||
case 'L':
|
||||
alg = 'L';
|
||||
break;
|
||||
case 'M':
|
||||
alg = 'M';
|
||||
break;
|
||||
case 'R':
|
||||
alg = 'R';
|
||||
break;
|
||||
case 'N':
|
||||
alg = 'N';
|
||||
break;
|
||||
case 'A':
|
||||
alg = 'A';
|
||||
break;
|
||||
case 'V':
|
||||
alg = 'V';
|
||||
break;
|
||||
case 'C':
|
||||
alg = 'C';
|
||||
break;
|
||||
case 'F':
|
||||
use_fft = 1;
|
||||
break;
|
||||
case 'v':
|
||||
tbrweight = 3;
|
||||
break;
|
||||
case 'd':
|
||||
divpairscore = 1;
|
||||
break;
|
||||
/* Modified 01/08/27, default: user tree */
|
||||
case 'J':
|
||||
tbutree = 0;
|
||||
break;
|
||||
/* modification end. */
|
||||
case 'z':
|
||||
fftThreshold = myatoi( *++argv );
|
||||
--argc;
|
||||
goto nextoption;
|
||||
case 'w':
|
||||
fftWinSize = myatoi( *++argv );
|
||||
--argc;
|
||||
goto nextoption;
|
||||
case 'Z':
|
||||
checkC = 1;
|
||||
break;
|
||||
default:
|
||||
fprintf( stderr, "illegal option %c\n", c );
|
||||
argc = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
nextoption:
|
||||
;
|
||||
}
|
||||
if( argc == 1 )
|
||||
{
|
||||
cut = atof( (*argv) );
|
||||
argc--;
|
||||
}
|
||||
if( argc != 0 )
|
||||
{
|
||||
fprintf( stderr, "options: Check source file !\n" );
|
||||
exit( 1 );
|
||||
}
|
||||
if( tbitr == 1 && outgap == 0 )
|
||||
{
|
||||
fprintf( stderr, "conflicting options : o, m or u\n" );
|
||||
exit( 1 );
|
||||
}
|
||||
if( alg == 'C' && outgap == 0 )
|
||||
{
|
||||
fprintf( stderr, "conflicting options : C, o\n" );
|
||||
exit( 1 );
|
||||
}
|
||||
}
|
||||
|
||||
int countamino( char *s, int end )
|
||||
{
|
||||
int val = 0;
|
||||
while( end-- )
|
||||
if( *s++ != '-' ) val++;
|
||||
return( val );
|
||||
}
|
||||
|
||||
|
||||
static void WriteOptions( FILE *fp )
|
||||
{
|
||||
|
||||
if( dorp == 'd' ) fprintf( fp, "DNA\n" );
|
||||
else
|
||||
{
|
||||
if ( scoremtx == 0 ) fprintf( fp, "JTT %dPAM\n", pamN );
|
||||
else if( scoremtx == 1 ) fprintf( fp, "BLOSUM %d\n", nblosum );
|
||||
else if( scoremtx == 2 ) fprintf( fp, "M-Y\n" );
|
||||
}
|
||||
fprintf( stderr, "Gap Penalty = %+5.2f, %+5.2f, %+5.2f\n", (double)ppenalty/1000, (double)ppenalty_ex/1000, (double)poffset/1000 );
|
||||
if( use_fft ) fprintf( fp, "FFT on\n" );
|
||||
|
||||
fprintf( fp, "tree-base method\n" );
|
||||
if( tbrweight == 0 ) fprintf( fp, "unweighted\n" );
|
||||
else if( tbrweight == 3 ) fprintf( fp, "clustalw-like weighting\n" );
|
||||
if( tbitr || tbweight )
|
||||
{
|
||||
fprintf( fp, "iterate at each step\n" );
|
||||
if( tbitr && tbrweight == 0 ) fprintf( fp, " unweighted\n" );
|
||||
if( tbitr && tbrweight == 3 ) fprintf( fp, " reversely weighted\n" );
|
||||
if( tbweight ) fprintf( fp, " weighted\n" );
|
||||
fprintf( fp, "\n" );
|
||||
}
|
||||
|
||||
fprintf( fp, "Gap Penalty = %+5.2f, %+5.2f, %+5.2f\n", (double)ppenalty/1000, (double)ppenalty_ex/1000, (double)poffset/1000 );
|
||||
|
||||
if( alg == 'a' )
|
||||
fprintf( fp, "Algorithm A\n" );
|
||||
else if( alg == 'A' )
|
||||
fprintf( fp, "Algorithm A+\n" );
|
||||
else if( alg == 'S' )
|
||||
fprintf( fp, "Apgorithm S\n" );
|
||||
else if( alg == 'C' )
|
||||
fprintf( fp, "Apgorithm A+/C\n" );
|
||||
else
|
||||
fprintf( fp, "Unknown algorithm\n" );
|
||||
|
||||
if( treemethod == 'x' )
|
||||
fprintf( fp, "Tree = UPGMA (3).\n" );
|
||||
else if( treemethod == 's' )
|
||||
fprintf( fp, "Tree = UPGMA (2).\n" );
|
||||
else if( treemethod == 'p' )
|
||||
fprintf( fp, "Tree = UPGMA (1).\n" );
|
||||
else
|
||||
fprintf( fp, "Unknown tree.\n" );
|
||||
|
||||
if( use_fft )
|
||||
{
|
||||
fprintf( fp, "FFT on\n" );
|
||||
if( dorp == 'd' )
|
||||
fprintf( fp, "Basis : 4 nucleotides\n" );
|
||||
else
|
||||
{
|
||||
if( fftscore )
|
||||
fprintf( fp, "Basis : Polarity and Volume\n" );
|
||||
else
|
||||
fprintf( fp, "Basis : 20 amino acids\n" );
|
||||
}
|
||||
fprintf( fp, "Threshold of anchors = %d%%\n", fftThreshold );
|
||||
fprintf( fp, "window size of anchors = %dsites\n", fftWinSize );
|
||||
}
|
||||
else
|
||||
fprintf( fp, "FFT off\n" );
|
||||
fflush( fp );
|
||||
}
|
||||
|
||||
|
||||
int main( int argc, char *argv[] )
|
||||
{
|
||||
static int *nlen;
|
||||
static char **name, **seq, **useq;
|
||||
static char **mseq1, **mseq2;
|
||||
static char **aseq;
|
||||
static char **bseq;
|
||||
static double *eff;
|
||||
int i;
|
||||
FILE *infp;
|
||||
char c;
|
||||
int alloclen;
|
||||
RNApair **pair1;
|
||||
RNApair **pair2;
|
||||
double **map;
|
||||
|
||||
arguments( argc, argv );
|
||||
|
||||
if( inputfile )
|
||||
{
|
||||
infp = fopen( inputfile, "r" );
|
||||
if( !infp )
|
||||
{
|
||||
fprintf( stderr, "Cannot open %s\n", inputfile );
|
||||
exit( 1 );
|
||||
}
|
||||
}
|
||||
else
|
||||
infp = stdin;
|
||||
|
||||
getnumlen( infp );
|
||||
rewind( infp );
|
||||
|
||||
if( njob > M )
|
||||
{
|
||||
fprintf( stderr, "The number of sequences must be < %d\n", M );
|
||||
fprintf( stderr, "Please try the splittbfast program for such large data.\n" );
|
||||
exit( 1 );
|
||||
}
|
||||
|
||||
name = AllocateCharMtx( njob, B+1 );
|
||||
nlen = AllocateIntVec( njob );
|
||||
|
||||
seq = AllocateCharMtx( njob, nlenmax*5+1 );
|
||||
useq = AllocateCharMtx( njob, nlenmax*5+1 );
|
||||
aseq = AllocateCharMtx( njob, nlenmax*5+1 );
|
||||
bseq = AllocateCharMtx( njob, nlenmax*5+1 );
|
||||
mseq1 = AllocateCharMtx( njob, 0 );
|
||||
mseq2 = AllocateCharMtx( njob, 0 );
|
||||
alloclen = nlenmax*5;
|
||||
|
||||
pair1 = calloc( nlenmax*5+1, sizeof( RNApair *) );
|
||||
pair2 = calloc( nlenmax*5+1, sizeof( RNApair *) );
|
||||
map = AllocateFloatMtx( nlenmax+1, nlenmax );
|
||||
|
||||
eff = AllocateDoubleVec( njob );
|
||||
|
||||
readData_pointer( infp, name, nlen, seq );
|
||||
fclose( infp );
|
||||
|
||||
for( i=0; i<njob; i++ ) strcpy( useq[i], seq[i] );
|
||||
|
||||
constants( njob, seq );
|
||||
|
||||
#if 0
|
||||
fprintf( stderr, "params = %d, %d, %d\n", penalty, penalty_ex, offset );
|
||||
#endif
|
||||
|
||||
initSignalSM();
|
||||
|
||||
initFiles();
|
||||
|
||||
WriteOptions( trap_g );
|
||||
|
||||
c = seqcheck( seq );
|
||||
if( c )
|
||||
{
|
||||
fprintf( stderr, "Illeagal character %c\n", c );
|
||||
exit( 1 );
|
||||
}
|
||||
|
||||
// writePre( njob, name, nlen, seq, 0 );
|
||||
|
||||
for( i=0; i<njob; i++ ) eff[i] = 1.0;
|
||||
|
||||
// for( i=0; i<njob; i++ ) gappick0( bseq[i], seq[i] );
|
||||
|
||||
|
||||
fprintf( stderr, "folding group1\n" );
|
||||
// rnalocal( seq, useq, eff, eff, njob, njob, alloclen, pair1 );
|
||||
rnaalifoldcall( seq, njob, pair1 );
|
||||
exit( 1 );
|
||||
|
||||
#if 0
|
||||
fprintf( stderr, "folding group1\n" );
|
||||
rnalocal( seq+1, useq+1, eff+1, eff+1, 1, 1, alloclen, pair2 );
|
||||
fprintf( stderr, "aligning 1 and 2, phase 1\n" );
|
||||
Lalignmm_hmout( seq, seq+1, eff, eff+1, 1, 1, alloclen, NULL, NULL, NULL, NULL, map );
|
||||
|
||||
|
||||
#if 0
|
||||
lgth1 = strlen( seq[0] );
|
||||
for( i=0; i<lgth1; i++ )
|
||||
{
|
||||
fprintf( stderr, "\n" );
|
||||
if( pair1[i].pos == -1 ) continue;
|
||||
fprintf( stderr, "i=%d (%c):%d", i, seq[0][i], pair1[i].pos );
|
||||
if( map12[pair1[i].pos].pos == -1 ) continue;
|
||||
fprintf( stderr, "%c -> %c ", seq[0][pair1[i].pos], seq[1][map12[pair1[i].pos].pos] );
|
||||
if( pair2[map12[pair1[i].pos].pos].pos == -1 ) continue;
|
||||
fprintf( stderr, "%d:%d (%c)", map12[pair1[i].pos].pos, pair2[map12[pair1[i].pos].pos].pos, seq[1][pair2[map12[pair1[i].pos].pos].pos] );
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
exit( 1 );
|
||||
|
||||
|
||||
pairalign( name, nlen, bseq, aseq, mseq1, mseq2, eff, alloclen );
|
||||
fprintf( trap_g, "done.\n" );
|
||||
#if DEBUG
|
||||
fprintf( stderr, "closing trap_g\n" );
|
||||
#endif
|
||||
fclose( trap_g );
|
||||
|
||||
// writePre( njob, name, nlen, aseq, !contin );
|
||||
#if 0
|
||||
writeData( stdout, njob, name, nlen, aseq );
|
||||
#endif
|
||||
#if IODEBUG
|
||||
fprintf( stderr, "OSHIMAI\n" );
|
||||
#endif
|
||||
SHOWVERSION;
|
||||
return( 0 );
|
||||
#endif
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue