Codebase list exonerate / upstream/latest
Imported Upstream version 2.4.0 Andreas Tille 8 years ago
280 changed file(s) with 2572 addition(s) and 625 deletion(s). Raw diff Collapse all Expand all
0
1 2.3.0 -> 2.4.0
2 o Fixed many thread safety bugs
3 o Fixed bugs with large files over 4GB
4 o Modified client to work with multiple servers
5 o Fixed server to handle SIGPIPE
6 o Added support for FOSN input (can be files, directories or servers)
7 o Fixed bug with --wordambiguity and --wordjump (with normal FSM)
8 o Added %pS to --ryo (percent self score over equivalenced regions)
9
10 2.2.0 -> 2.3.0
11 o Fixed several bugs with thread safety for exonerate-server
12 o Fixed bug with custom genetic codes not working
13 o Fixed bug with overflow of seedrepeat horizon in hspset
14 o Added passing of wordlimit params to server
15 o Implemented --cores option for multi-threaded alignment
16 o Added identity and similarity score for GFF genes and exons
17 o Increased default FSM memory limit to 256Mb
18 o Added --revcomp option to disable searching of reverse complement
19 o Fixed bug with compact-FSM (VFSM) based database searching
20 o Added --wordambiguity option for searching ambiguous reference seqs
21 o Fixed bug with esd2esi and .esd files >2Gb
22
023 2.1.0 -> 2.2.0
124 o Fixed bug with esd2esi when softmasking is off
2 o Replaced GMemChunk due to caching problems with glib-2
25 o Removed all GMemChunk usage due to caching problems with glib-2
326 o Fixed various minor memory leaks
427
528 2.0.0 -> 2.1.0
336359 o Converted est2genome model to use PSSM splice site prediction
337360 o Fixed C4_Model_select() to avoid copying redundant calcs
338361
362
363
339364 --
6969 VERSION = @VERSION@
7070 codegen_extra_ldadd = @codegen_extra_ldadd@
7171 codegen_extra_sources = @codegen_extra_sources@
72 custom_guint64_format = @custom_guint64_format@
7273 datarootdir = @datarootdir@
7374 glib_cflags = @glib_cflags@
7475 glib_libs = @glib_libs@
678678 host_cpu
679679 host_vendor
680680 host_os
681 custom_guint64_format
681682 source_root_dir
682683 PKG_CONFIG
683684 GLIB_CONFIG
19391940
19401941 PACKAGE=exonerate
19411942
1942 VERSION=2.2.0
1943 VERSION=2.4.0
19431944
19441945 if test "`cd $srcdir && pwd`" != "`pwd`" && test -f $srcdir/config.status; then
19451946 { { echo "$as_me:$LINENO: error: source directory already configured; run \"make distclean\" there first" >&5
41204121 # AVOID autoconf WARNINGS ABOUT --datarootdir
41214122
41224123
4124 custom_guint64_format="llu"
4125
41234126 # TRY TO GET TO BUILD ON ALL PLATFORMS BY DEFAULT
41244127 echo ""$host
41254128 case $host in
41374140 CC="cc"
41384141 GCC= # No longer true (prevents GCC specific CFLAGS being set)
41394142 CFLAGS="-O3 -arch ev6 -fast"
4140 C4_CC="$CC"
4141 C4_CFLAGS="$CFLAGS"
41424143 ;;
41434144 *-irix*)
41444145 echo "Customising build for IRIX"
41504151 C4_AR_INIT="cq"
41514152 C4_AR_APPEND="q"
41524153 ;;
4154 x86_64-*)
4155 echo "Customising build for X86_64"
4156 custom_guint64_format="lu"
4157 ;;
4158 *)
4159 echo "*** Unknown build platform: $host ***"
4160 ;;
41534161 esac
4162
4163
41544164
41554165 # SET SOURCE_ROOT_DIR (REQUIRED FOR viterbi.h)
41564166 source_root_dir=`pwd`
45204530 # model_extra_programs="bootstrapper"
45214531 codegen_extra_sources=""
45224532 codegen_extra_ldadd="`pwd`/src/c4/viterbi.o \
4523 `pwd`/src/c4/scheduler.o"
4533 `pwd`/src/sdp/scheduler.o"
45244534 else
45254535 echo "error: must be yes or no:"
45264536 echo " --enable-compiledmodels:$enable_compiledmodels"
45684578 if test "$enable_pthreads" = yes; then
45694579 echo "Using PTHREADS"
45704580 CFLAGS="$CFLAGS -DUSE_PTHREADS"
4571 LDFLAGS="$LDFLAGS -lpthread"
4581 # for g_thread_init()
4582 g_thread_init_ldflags=`pkg-config --libs gthread-2.0`
4583 LDFLAGS="$LDFLAGS $g_thread_init_ldflags -lpthread"
45724584 elif test "$enable_pthreads" = no; then
45734585 echo "Not using pthreads"
45744586 else
53005312 host_cpu!$host_cpu$ac_delim
53015313 host_vendor!$host_vendor$ac_delim
53025314 host_os!$host_os$ac_delim
5315 custom_guint64_format!$custom_guint64_format$ac_delim
53035316 source_root_dir!$source_root_dir$ac_delim
53045317 PKG_CONFIG!$PKG_CONFIG$ac_delim
53055318 GLIB_CONFIG!$GLIB_CONFIG$ac_delim
53135326 LTLIBOBJS!$LTLIBOBJS$ac_delim
53145327 _ACEOF
53155328
5316 if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 77; then
5329 if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 78; then
53175330 break
53185331 elif $ac_last_try; then
53195332 { { echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5
44 # ( Borrowed some config tricks from gtk+, gnet, xscreensaver, mutt )
55
66 AC_INIT(src/sequence/sequence.c)
7 AM_INIT_AUTOMAKE(exonerate,2.2.0)
7 AM_INIT_AUTOMAKE(exonerate,2.4.0)
88 AC_PROG_CC
99 AC_PROG_INSTALL
1010 AC_PROG_MAKE_SET
2525
2626 # AVOID autoconf WARNINGS ABOUT --datarootdir
2727 AC_SUBST(datarootdir)
28
29 custom_guint64_format="llu"
2830
2931 # TRY TO GET TO BUILD ON ALL PLATFORMS BY DEFAULT
3032 echo ""$host
4345 CC="cc"
4446 GCC= # No longer true (prevents GCC specific CFLAGS being set)
4547 CFLAGS="-O3 -arch ev6 -fast"
46 C4_CC="$CC"
47 C4_CFLAGS="$CFLAGS"
4848 ;;
4949 *-irix*)
5050 echo "Customising build for IRIX"
5656 C4_AR_INIT="cq"
5757 C4_AR_APPEND="q"
5858 ;;
59 x86_64-*)
60 echo "Customising build for X86_64"
61 custom_guint64_format="lu"
62 ;;
63 *)
64 echo "*** Unknown build platform: $host ***"
65 ;;
5966 esac
67
68 AC_SUBST(custom_guint64_format)
6069
6170 # SET SOURCE_ROOT_DIR (REQUIRED FOR viterbi.h)
6271 source_root_dir=`pwd`
244253 # model_extra_programs="bootstrapper"
245254 codegen_extra_sources=""
246255 codegen_extra_ldadd="`pwd`/src/c4/viterbi.o \
247 `pwd`/src/c4/scheduler.o"
256 `pwd`/src/sdp/scheduler.o"
248257 else
249258 echo "error: must be yes or no:"
250259 echo " --enable-compiledmodels:[$enable_compiledmodels]"
288297 if test "$enable_pthreads" = yes; then
289298 echo "Using PTHREADS"
290299 CFLAGS="$CFLAGS -DUSE_PTHREADS"
291 LDFLAGS="$LDFLAGS -lpthread"
300 # for g_thread_init()
301 g_thread_init_ldflags=`pkg-config --libs gthread-2.0`
302 LDFLAGS="$LDFLAGS $g_thread_init_ldflags -lpthread"
292303 elif test "$enable_pthreads" = no; then
293304 echo "Not using pthreads"
294305 else
6969 VERSION = @VERSION@
7070 codegen_extra_ldadd = @codegen_extra_ldadd@
7171 codegen_extra_sources = @codegen_extra_sources@
72 custom_guint64_format = @custom_guint64_format@
7273 datarootdir = @datarootdir@
7374 glib_cflags = @glib_cflags@
7475 glib_libs = @glib_libs@
6969 VERSION = @VERSION@
7070 codegen_extra_ldadd = @codegen_extra_ldadd@
7171 codegen_extra_sources = @codegen_extra_sources@
72 custom_guint64_format = @custom_guint64_format@
7273 datarootdir = @datarootdir@
7374 glib_cflags = @glib_cflags@
7475 glib_libs = @glib_libs@
6969 VERSION = @VERSION@
7070 codegen_extra_ldadd = @codegen_extra_ldadd@
7171 codegen_extra_sources = @codegen_extra_sources@
72 custom_guint64_format = @custom_guint64_format@
7273 datarootdir = @datarootdir@
7374 glib_cflags = @glib_cflags@
7475 glib_libs = @glib_libs@
135135 Specify the target sequences required. Also, must be in a FASTA
136136 format file. As with the query sequences, single or multiple target
137137 sequences and files may be supplied.
138 .B NEW:
139 the target filename may by replace by a server name and port number
138 The target filename may by replace by a server name and port number
140139 in the form of
141140 .B hostname:port
142141 when using
144143 See the man page for
145144 .B exonerate-server
146145 for more information on running exonerate in client:server mode.
147
146 .B NEW(v2.4.0):
147 multiple servers may now be used. These will be queried in parallel
148 if you have set the
149 .B --cores
150 option.
151 .B NEW(v2.4.0):
152 If an input file is not a FASTA format file,
153 it is assumed to contain a list of other fasta files,
154 directories or servers (one per line).
148155 .\"
149156 .TP
150157 .B "-Q | \--querytype" <dna | protein>
221228 This is very memory efficient and fast when both sequences
222229 are chromosome-sized, but currently does not currently permit the use
223230 of a word neighbourhood (ie. exactly matching seeds only).
231 .\"
232 .TP
233 .B "\--revcomp" <boolean>
234 Include comparison of the reverse complement of the query and target
235 where possible. By default, this option is enabled,
236 but when you know the gene is definitely on the forward strand
237 of the query and target,
238 this option can halve the time taken to compute alignments.
224239 .\"
225240 .TP
226241 .B "\--forcescan" <none | query | target>
245260 .\"
246261 .TP
247262 .B "\--customserver" <command>
248 .B NEW:
249263 When using exonerate in client:server mode with a non-standard
250264 server, this command allows you to send a custom command to the
251265 server. This command is sent by the client (exonerate)
254268 .B exonerate-server
255269 man page for more information on running exonerate in client:server mode.
256270 .\"
257
258 .RE
271 .TP
272 .B "\--cores" <number>
273 The number of cores/CPUs/threads that should be used.
274 On a multi-core or multi-CPU machine, increasing this ammount
275 allows alignment computations to run in parallel on separate CPUs/cores.
276 NB. Generally, it is better to parallelise the analysis
277 by splitting it up into separate jobs, but this option may prove
278 useful for problems such as interactive single-gene queries.
279 .\"
280
259281 .SH FASTA DATABASE OPTIONS
260282 .TP
261283 .B "\--fastasuffix" <extension>
347369 .\"
348370 .TP
349371 .B protein2dna:bestfit
350 .B NEW:
351372 This is a bestfit version of the protein2dna model,
352373 with which the entire protein is included in the alignment.
353374 It is currently only available when using exhaustive alignment.
361382 .\"
362383 .TP
363384 .B protein2genome:bestfit
364 .B NEW:
365385 This is a bestfit version of the protein2genome model,
366386 with which the entire protein is included in the alignment.
367387 It is currently only available when using exhaustive alignment.
599619 Equivalenced {total,id,similarity,mismatches}
600620 (ie. %em == (%et - %ei))
601621 .TP
602 .B %p[is]
603 Percent {id,similarity}
622 .B %p[isS]
623 Percent {id,similarity,Self}
604624 over the equivalenced portions of the alignment.
605 (ie. %pi == 100*(%ei / %et))
625 (ie. %pi == 100*(%ei / %et)).
626 Percent Self is the score over the equivalenced portions
627 of the alignment as a percentage of the self comparison score
628 of the query sequence.
606629 .TP
607630 .B %g
608631 Gene orientation ('+' = forward, '-' = reverse, '.' = unknown)
916939 query sequences, and makes the search run faster, but it also
917940 damages search sensitivity when high values are set.
918941 .\"
942 .TP
943 .B "\--wordambiguity" <limit>
944 This option may be used to allow alignment seeds containing
945 IUPAC ambiguity symbols.
946 The limit is the maximum number of ambiguous words
947 allowed at a single position. If this limit is reached
948 then the position is not used for alignment seeding.
949 Using this option may slow down a search.
950 For large datasets,
951 it is recommended to use
952 .B esd2esi --wordambiguity
953 instead, as then the speed overhead is only incurred
954 during indexing, rather than during the database searching itself.
955 NB. This option only works for IUPAC symbols in the target sequence.
956 Query words containing IUPAC symbols are (currently) excluded from seeding.
957 .\"
919958 .SH AFFINE MODEL OPTIONS
920959 .TP
921960 .B "\-o | \--gapopen" <penalty>
9801019 .SH TRANSLATION OPTIONS
9811020 .TP
9821021 .B "\--geneticcode" <code>
983 .B NEW:
9841022 Specify an alternative genetic code. The default code (1) is the standard
9851023 genetic code. Other genetic codes may be specified by in shorthand or
9861024 longhand form.
10801118 .\"
10811119 .TP
10821120 .B "\--seedrepeat" <count>
1083 .B NEW:
10841121 The seedrepeat parameter sets the number of seeds which must be found
10851122 on the same diagonal or reading frame before HSP extension will occur.
10861123 Increasing the value for
11501187 .\"
11511188 .TP
11521189 .B "\--geneseedrepeat" <count>
1153 .B NEW:
11541190 The geneseedrepeat parameter is like the seedrepeat parameter,
11551191 but is only applied when looking for the geneseed hsps.
11561192 Using a larger value for
11831219 .B "\--splice3" <path>
11841220 .TP
11851221 .B "\--splice5" <path>
1186 .B NEW:
11871222 Provide a file containing a custom PSSM (position specific score matrix)
11881223 for prediction of the intron splice sites.
11891224
6969 VERSION = @VERSION@
7070 codegen_extra_ldadd = @codegen_extra_ldadd@
7171 codegen_extra_sources = @codegen_extra_sources@
72 custom_guint64_format = @custom_guint64_format@
7273 datarootdir = @datarootdir@
7374 glib_cflags = @glib_cflags@
7475 glib_libs = @glib_libs@
2121 $(top_srcdir)/src/sequence/translate.o \
2222 $(top_srcdir)/src/general/argument.o \
2323 $(top_srcdir)/src/general/lineparse.o \
24 $(top_srcdir)/src/general/threadref.o \
2425 -lm
2526
2627 C4_OBJ = $(top_srcdir)/src/c4/c4.o \
5354 hpair_test_LDADD = $(top_srcdir)/src/struct/slist.o \
5455 $(top_srcdir)/src/struct/pqueue.o \
5556 $(top_srcdir)/src/struct/recyclebin.o \
57 $(top_srcdir)/src/struct/rangetree.o \
5658 $(top_srcdir)/src/comparison/hspset.o \
5759 $(top_srcdir)/src/comparison/wordhood.o \
58 $(top_srcdir)/src/struct/rangetree.o \
5960 $(ALIGNMENT_OBJ)
6061
6162 sar_test_SOURCES = sar.test.c sar.c heuristic.c
6969 VERSION = @VERSION@
7070 codegen_extra_ldadd = @codegen_extra_ldadd@
7171 codegen_extra_sources = @codegen_extra_sources@
72 custom_guint64_format = @custom_guint64_format@
7273 datarootdir = @datarootdir@
7374 glib_cflags = @glib_cflags@
7475 glib_libs = @glib_libs@
8687
8788 noinst_HEADERS = heuristic.h bsdp.h hpair.h sar.h
8889
89 SEQUENCE_OBJ = $(top_srcdir)/src/struct/sparsecache.o $(top_srcdir)/src/struct/matrix.o $(top_srcdir)/src/sequence/sequence.o $(top_srcdir)/src/sequence/alphabet.o $(top_srcdir)/src/sequence/splice.o $(top_srcdir)/src/sequence/translate.o $(top_srcdir)/src/general/argument.o $(top_srcdir)/src/general/lineparse.o -lm
90 SEQUENCE_OBJ = $(top_srcdir)/src/struct/sparsecache.o $(top_srcdir)/src/struct/matrix.o $(top_srcdir)/src/sequence/sequence.o $(top_srcdir)/src/sequence/alphabet.o $(top_srcdir)/src/sequence/splice.o $(top_srcdir)/src/sequence/translate.o $(top_srcdir)/src/general/argument.o $(top_srcdir)/src/general/lineparse.o $(top_srcdir)/src/general/threadref.o -lm
9091
9192
9293 C4_OBJ = $(top_srcdir)/src/c4/c4.o $(top_srcdir)/src/c4/alignment.o $(top_srcdir)/src/c4/optimal.o $(top_srcdir)/src/c4/codegen.o $(top_srcdir)/src/c4/region.o $(top_srcdir)/src/c4/layout.o $(top_srcdir)/src/c4/viterbi.o $(top_srcdir)/src/c4/subopt.o $(top_srcdir)/src/c4/cgutil.o
104105
105106
106107 hpair_test_SOURCES = hpair.test.c hpair.c heuristic.c bsdp.c sar.c
107 hpair_test_LDADD = $(top_srcdir)/src/struct/slist.o $(top_srcdir)/src/struct/pqueue.o $(top_srcdir)/src/struct/recyclebin.o $(top_srcdir)/src/comparison/hspset.o $(top_srcdir)/src/comparison/wordhood.o $(top_srcdir)/src/struct/rangetree.o $(ALIGNMENT_OBJ)
108 hpair_test_LDADD = $(top_srcdir)/src/struct/slist.o $(top_srcdir)/src/struct/pqueue.o $(top_srcdir)/src/struct/recyclebin.o $(top_srcdir)/src/struct/rangetree.o $(top_srcdir)/src/comparison/hspset.o $(top_srcdir)/src/comparison/wordhood.o $(ALIGNMENT_OBJ)
108109
109110
110111 sar_test_SOURCES = sar.test.c sar.c heuristic.c
140141 $(top_srcdir)/src/sequence/splice.o \
141142 $(top_srcdir)/src/sequence/translate.o \
142143 $(top_srcdir)/src/general/argument.o \
143 $(top_srcdir)/src/general/lineparse.o
144 $(top_srcdir)/src/general/lineparse.o \
145 $(top_srcdir)/src/general/threadref.o
144146 heuristic_test_LDFLAGS =
145147 bsdp_test_OBJECTS = bsdp.test.o bsdp.o
146148 bsdp_test_DEPENDENCIES = $(top_srcdir)/src/general/argument.o \
149151 hpair_test_OBJECTS = hpair.test.o hpair.o heuristic.o bsdp.o sar.o
150152 hpair_test_DEPENDENCIES = $(top_srcdir)/src/struct/slist.o \
151153 $(top_srcdir)/src/struct/pqueue.o $(top_srcdir)/src/struct/recyclebin.o \
154 $(top_srcdir)/src/struct/rangetree.o \
152155 $(top_srcdir)/src/comparison/hspset.o \
153156 $(top_srcdir)/src/comparison/wordhood.o \
154 $(top_srcdir)/src/struct/rangetree.o \
155157 $(top_srcdir)/src/comparison/match.o \
156158 $(top_srcdir)/src/sequence/codonsubmat.o \
157159 $(top_srcdir)/src/sequence/submat.o $(top_srcdir)/src/c4/c4.o \
165167 $(top_srcdir)/src/sequence/splice.o \
166168 $(top_srcdir)/src/sequence/translate.o \
167169 $(top_srcdir)/src/general/argument.o \
168 $(top_srcdir)/src/general/lineparse.o
170 $(top_srcdir)/src/general/lineparse.o \
171 $(top_srcdir)/src/general/threadref.o
169172 hpair_test_LDFLAGS =
170173 sar_test_OBJECTS = sar.test.o sar.o heuristic.o
171174 sar_test_DEPENDENCIES = $(top_srcdir)/src/struct/slist.o \
184187 $(top_srcdir)/src/sequence/splice.o \
185188 $(top_srcdir)/src/sequence/translate.o \
186189 $(top_srcdir)/src/general/argument.o \
187 $(top_srcdir)/src/general/lineparse.o
190 $(top_srcdir)/src/general/lineparse.o \
191 $(top_srcdir)/src/general/threadref.o
188192 sar_test_LDFLAGS =
189193 CFLAGS = @CFLAGS@
190194 COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
22 * BSDP : Bounded Sparse Dynamic Programming *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
22 * BSDP: Bounded Sparse Dynamic Programming *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
22 * BSDP : Bounded Sparse Dynamic Programming *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
22 * C4 dynamic programming library - code for heuristics *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
22 * C4 dynamic programming library - code for heuristics *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
22 * C4 dynamic programming library - code for heuristics *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
22 * C4 dynamic programming library - code for heuristic pairs *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
22 * C4 dynamic programming library - code for heuristic pairs *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
22 * C4 dynamic programming library - code for heuristic pairs *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
22 * C4 dynamic programming library - sub-alignment regions *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
22 * C4 dynamic programming library - sub-alignment regions *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
22 * C4 dynamic programming library - sub-alignment regions *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
1818 region_test_SOURCES = region.test.c region.c
1919
2020 c4_test_SOURCES = c4.test.c c4.c region.c
21 c4_test_LDADD = $(top_srcdir)/src/struct/matrix.o
21 c4_test_LDADD = $(top_srcdir)/src/struct/matrix.o \
22 $(top_srcdir)/src/general/threadref.o
2223
2324 SEQUENCE_OBJ = $(top_srcdir)/src/struct/sparsecache.o \
2425 $(top_srcdir)/src/struct/matrix.o \
3334 ALIGNMENT_OBJ = $(top_srcdir)/src/comparison/match.o \
3435 $(top_srcdir)/src/sequence/codonsubmat.o \
3536 $(top_srcdir)/src/sequence/submat.o \
37 $(top_srcdir)/src/general/threadref.o \
3638 $(SEQUENCE_OBJ)
3739 alignment_test_SOURCES = alignment.test.c alignment.c c4.c region.c
3840 alignment_test_LDADD = $(ALIGNMENT_OBJ)
4143 codegen_test_LDADD = $(top_srcdir)/src/general/argument.o
4244
4345 cgutil_test_SOURCES = cgutil.test.c cgutil.c codegen.c c4.c region.c
44 cgutil_test_LDADD = $(top_srcdir)/src/general/argument.o \
45 $(top_srcdir)/src/struct/matrix.o
46 cgutil_test_LDADD = $(top_srcdir)/src/general/argument.o \
47 $(top_srcdir)/src/struct/matrix.o \
48 $(top_srcdir)/src/general/threadref.o
4649
4750 viterbi_test_SOURCES = viterbi.test.c viterbi.c c4.c region.c \
4851 alignment.c codegen.c layout.c subopt.c \
6969 VERSION = @VERSION@
7070 codegen_extra_ldadd = @codegen_extra_ldadd@
7171 codegen_extra_sources = @codegen_extra_sources@
72 custom_guint64_format = @custom_guint64_format@
7273 datarootdir = @datarootdir@
7374 glib_cflags = @glib_cflags@
7475 glib_libs = @glib_libs@
9192 region_test_SOURCES = region.test.c region.c
9293
9394 c4_test_SOURCES = c4.test.c c4.c region.c
94 c4_test_LDADD = $(top_srcdir)/src/struct/matrix.o
95 c4_test_LDADD = $(top_srcdir)/src/struct/matrix.o $(top_srcdir)/src/general/threadref.o
96
9597
9698 SEQUENCE_OBJ = $(top_srcdir)/src/struct/sparsecache.o $(top_srcdir)/src/struct/matrix.o $(top_srcdir)/src/sequence/sequence.o $(top_srcdir)/src/sequence/alphabet.o $(top_srcdir)/src/sequence/splice.o $(top_srcdir)/src/sequence/translate.o $(top_srcdir)/src/general/argument.o $(top_srcdir)/src/general/lineparse.o -lm
9799
98100
99 ALIGNMENT_OBJ = $(top_srcdir)/src/comparison/match.o $(top_srcdir)/src/sequence/codonsubmat.o $(top_srcdir)/src/sequence/submat.o $(SEQUENCE_OBJ)
101 ALIGNMENT_OBJ = $(top_srcdir)/src/comparison/match.o $(top_srcdir)/src/sequence/codonsubmat.o $(top_srcdir)/src/sequence/submat.o $(top_srcdir)/src/general/threadref.o $(SEQUENCE_OBJ)
100102
101103 alignment_test_SOURCES = alignment.test.c alignment.c c4.c region.c
102104 alignment_test_LDADD = $(ALIGNMENT_OBJ)
105107 codegen_test_LDADD = $(top_srcdir)/src/general/argument.o
106108
107109 cgutil_test_SOURCES = cgutil.test.c cgutil.c codegen.c c4.c region.c
108 cgutil_test_LDADD = $(top_srcdir)/src/general/argument.o $(top_srcdir)/src/struct/matrix.o
110 cgutil_test_LDADD = $(top_srcdir)/src/general/argument.o $(top_srcdir)/src/struct/matrix.o $(top_srcdir)/src/general/threadref.o
109111
110112
111113 viterbi_test_SOURCES = viterbi.test.c viterbi.c c4.c region.c alignment.c codegen.c layout.c subopt.c cgutil.c
147149 region_test_DEPENDENCIES =
148150 region_test_LDFLAGS =
149151 c4_test_OBJECTS = c4.test.o c4.o region.o
150 c4_test_DEPENDENCIES = $(top_srcdir)/src/struct/matrix.o
152 c4_test_DEPENDENCIES = $(top_srcdir)/src/struct/matrix.o \
153 $(top_srcdir)/src/general/threadref.o
151154 c4_test_LDFLAGS =
152155 alignment_test_OBJECTS = alignment.test.o alignment.o c4.o region.o
153156 alignment_test_DEPENDENCIES = $(top_srcdir)/src/comparison/match.o \
154157 $(top_srcdir)/src/sequence/codonsubmat.o \
155158 $(top_srcdir)/src/sequence/submat.o \
159 $(top_srcdir)/src/general/threadref.o \
156160 $(top_srcdir)/src/struct/sparsecache.o \
157161 $(top_srcdir)/src/struct/matrix.o $(top_srcdir)/src/sequence/sequence.o \
158162 $(top_srcdir)/src/sequence/alphabet.o \
172176 $(top_srcdir)/src/comparison/match.o \
173177 $(top_srcdir)/src/sequence/codonsubmat.o \
174178 $(top_srcdir)/src/sequence/submat.o \
179 $(top_srcdir)/src/general/threadref.o \
175180 $(top_srcdir)/src/struct/sparsecache.o \
176181 $(top_srcdir)/src/struct/matrix.o $(top_srcdir)/src/sequence/sequence.o \
177182 $(top_srcdir)/src/sequence/alphabet.o \
191196 $(top_srcdir)/src/comparison/match.o \
192197 $(top_srcdir)/src/sequence/codonsubmat.o \
193198 $(top_srcdir)/src/sequence/submat.o \
199 $(top_srcdir)/src/general/threadref.o \
194200 $(top_srcdir)/src/struct/sparsecache.o \
195201 $(top_srcdir)/src/struct/matrix.o $(top_srcdir)/src/sequence/sequence.o \
196202 $(top_srcdir)/src/sequence/alphabet.o \
207213 $(top_srcdir)/src/comparison/match.o \
208214 $(top_srcdir)/src/sequence/codonsubmat.o \
209215 $(top_srcdir)/src/sequence/submat.o \
216 $(top_srcdir)/src/general/threadref.o \
210217 $(top_srcdir)/src/struct/sparsecache.o \
211218 $(top_srcdir)/src/struct/matrix.o $(top_srcdir)/src/sequence/sequence.o \
212219 $(top_srcdir)/src/sequence/alphabet.o \
221228 subopt_test_LDFLAGS =
222229 cgutil_test_OBJECTS = cgutil.test.o cgutil.o codegen.o c4.o region.o
223230 cgutil_test_DEPENDENCIES = $(top_srcdir)/src/general/argument.o \
224 $(top_srcdir)/src/struct/matrix.o
231 $(top_srcdir)/src/struct/matrix.o $(top_srcdir)/src/general/threadref.o
225232 cgutil_test_LDFLAGS =
226233 CFLAGS = @CFLAGS@
227234 COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
22 * C4 dynamic programming library - alignment code *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
537537 register gint i, j;
538538 register gint curr_query_pos = query_pos,
539539 curr_target_pos = target_pos;
540 static gchar seq_string[4], match_string[4], gap_string[4];
540 register gchar *seq_string = g_new(gchar, 4),
541 *match_string = g_new(gchar, 4),
542 *gap_string = g_new(gchar, 4);
541543 register Alphabet_Type emitted_alphabet_type;
542544 register gchar tr_codon, *tr_codon_name;
543545 register gboolean is_translating
597599 curr_query_pos += advance_query;
598600 curr_target_pos += advance_target;
599601 }
602 g_free(seq_string);
603 g_free(match_string);
604 g_free(gap_string);
600605 return;
601606 }
602607 /* Display gap:[- N] codon[<-> NNN] frameshift [-*N]
14151420 /* Reports the %id over the equivalenced regions of the alignment
14161421 */
14171422
1423 static gint Alignment_get_equivalenced_matching_region(Alignment *alignment,
1424 Sequence *query, Sequence *target,
1425 Translate *translate, gboolean report_id,
1426 gpointer user_data, gint exon_query_start, gint exon_query_end){
1427 register gint i, j, match = 0;
1428 register AlignmentOperation *ao;
1429 register gint query_pos = alignment->region->query_start,
1430 target_pos = alignment->region->target_start;
1431 register gchar qy_symbol, tg_symbol;
1432 for(i = 0; i < alignment->operation_list->len; i++){
1433 ao = alignment->operation_list->pdata[i];
1434 if(ao->transition->label == C4_Label_MATCH){
1435 for(j = 0; j < ao->length; j++){
1436 if(query_pos > exon_query_end)
1437 return match;
1438 if(query_pos >= exon_query_start){
1439 qy_symbol = Alignment_match_get_symbol(query, query_pos,
1440 ao->transition->advance_query,
1441 translate);
1442 tg_symbol = Alignment_match_get_symbol(target,
1443 target_pos,
1444 ao->transition->advance_target,
1445 translate);
1446 if(report_id){
1447 if(toupper(qy_symbol) == toupper(tg_symbol))
1448 match++;
1449 } else { /* report similarity */
1450 if(C4_Calc_score(ao->transition->calc, query_pos,
1451 target_pos, user_data) > 0)
1452 match++;
1453 }
1454 }
1455 query_pos += ao->transition->advance_query;
1456 target_pos += ao->transition->advance_target;
1457 }
1458 } else {
1459 query_pos += (ao->transition->advance_query
1460 * ao->length);
1461 target_pos += (ao->transition->advance_target
1462 * ao->length);
1463 }
1464 }
1465 return match;
1466 }
1467 /* Reports the %id over the equivalenced regions of the alignment
1468 */
1469
14181470 static gint Alignment_get_equivalenced_total(Alignment *alignment){
14191471 register gint i, total = 0;
14201472 register AlignmentOperation *ao;
14261478 return total;
14271479 }
14281480
1481 static gint Alignment_get_equivalenced_total_region(Alignment *alignment,
1482 gint exon_query_start, gint exon_query_end){
1483 register gint i, j, total = 0;
1484 register gint query_pos = alignment->region->query_start,
1485 target_pos = alignment->region->target_start;
1486 register AlignmentOperation *ao;
1487 for(i = 0; i < alignment->operation_list->len; i++){
1488 ao = alignment->operation_list->pdata[i];
1489 if(ao->transition->label == C4_Label_MATCH){
1490 for(j = 0; j < ao->length; j++){
1491 if(query_pos > exon_query_end)
1492 return total;
1493 if(query_pos >= exon_query_start)
1494 total++;
1495 query_pos += ao->transition->advance_query;
1496 target_pos += ao->transition->advance_target;
1497 }
1498 } else {
1499 query_pos += (ao->transition->advance_query
1500 * ao->length);
1501 target_pos += (ao->transition->advance_target
1502 * ao->length);
1503 }
1504 }
1505 return total;
1506 }
1507 /* FIXME: optimisation: should use gene object to avoid full alignment pass
1508 */
1509
1510 static gfloat Alignment_get_percent_score_region(Alignment *alignment,
1511 Sequence *query, Sequence *target,
1512 Translate *translate, gboolean report_id, gpointer user_data,
1513 gint exon_query_start, gint exon_query_end){
1514 return (((gfloat)Alignment_get_equivalenced_matching_region(alignment,
1515 query, target, translate, report_id, user_data,
1516 exon_query_start, exon_query_end))
1517 / ((gfloat)Alignment_get_equivalenced_total_region(alignment,
1518 exon_query_start, exon_query_end)))*100;
1519 }
1520 /* FIXME: should also count split codons */
1521
14291522 static gfloat Alignment_get_percent_score(Alignment *alignment,
14301523 Sequence *query, Sequence *target,
14311524 Translate *translate, gboolean report_id,
14341527 query, target, translate, report_id, user_data))
14351528 / ((gfloat)Alignment_get_equivalenced_total(alignment)))*100;
14361529 }
1530 /* FIXME: should also count split codons */
1531
1532 static gint Alignment_get_match_score(Alignment *alignment,
1533 Sequence *query, Sequence *target,
1534 gpointer user_data){
1535 register gint i, j;
1536 register AlignmentOperation *ao;
1537 register C4_Score score = 0;
1538 register gint query_pos = alignment->region->query_start,
1539 target_pos = alignment->region->target_start;
1540 for(i = 0; i < alignment->operation_list->len; i++){
1541 ao = alignment->operation_list->pdata[i];
1542 for(j = 0; j < ao->length; j++){
1543 if(ao->transition->label == C4_Label_MATCH){
1544 score += C4_Calc_score(ao->transition->calc, query_pos,
1545 target_pos, user_data);
1546 }
1547 query_pos += ao->transition->advance_query;
1548 target_pos += ao->transition->advance_target;
1549 }
1550 }
1551 g_message("MATCH SCORE [%d]", score);
1552 return score;
1553 }
1554
1555 static gint Alignment_get_self_match_score(Alignment *alignment,
1556 Sequence *query, Sequence *target,
1557 gpointer self_data){
1558 register gint i, j;
1559 register AlignmentOperation *ao;
1560 register C4_Score score = 0;
1561 register gint query_pos = alignment->region->query_start;
1562 for(i = 0; i < alignment->operation_list->len; i++){
1563 ao = alignment->operation_list->pdata[i];
1564 for(j = 0; j < ao->length; j++){
1565 if(ao->transition->label == C4_Label_MATCH){
1566 /* Use self_data to find self-comparison scores */
1567 score += C4_Calc_score(ao->transition->calc, query_pos,
1568 query_pos, self_data);
1569 }
1570 query_pos += ao->transition->advance_query;
1571 }
1572 }
1573 g_message("SELF MATCH SCORE [%d]", score);
1574 return score;
1575 }
1576
1577 static gfloat Alignment_get_percent_self(Alignment *alignment,
1578 Sequence *query, Sequence *target,
1579 Translate *translate, gpointer user_data, gpointer self_data){
1580 return (((gfloat)Alignment_get_match_score(alignment,
1581 query, target, user_data))
1582 / ((gfloat)Alignment_get_self_match_score(alignment, query, target,
1583 self_data)))*100;
1584 }
1585 /* Returns score as a percentage of maximum possible
1586 * over the equivalenced transitions
1587 */
14371588
14381589 /**/
14391590
16111762 Alignment_RYO_TOKEN_RANK,
16121763 Alignment_RYO_TOKEN_PERCENT_ID,
16131764 Alignment_RYO_TOKEN_PERCENT_SIMILARITY,
1765 Alignment_RYO_TOKEN_PERCENT_SELF,
16141766 Alignment_RYO_TOKEN_GENE_ORIENTATION,
16151767 Alignment_RYO_TOKEN_EQUIVALENCED_TOTAL,
16161768 Alignment_RYO_TOKEN_EQUIVALENCED_IDENTCAL,
19022054 case 's':
19032055 Alignment_RYO_add_token(token_list,
19042056 Alignment_RYO_TOKEN_PERCENT_SIMILARITY,
2057 FALSE);
2058 break;
2059 case 'S':
2060 Alignment_RYO_add_token(token_list,
2061 Alignment_RYO_TOKEN_PERCENT_SELF,
19052062 FALSE);
19062063 break;
19072064 default:
19902147 * %s score
19912148 * %m model_name
19922149 * %r rank
1993 * %p[is] percent {id,similarity}
2150 * %p[isS] percent {id,similarity,self}
19942151 * %e[tid] equivalenced {total,identical,similar}
19952152 * %g gene_orientation
19962153 * %S sugar block
22032360
22042361 static void Alignment_RYO_token_list_print(GPtrArray *token_list,
22052362 Alignment *alignment, Sequence *query, Sequence *target,
2206 Translate *translate, gint rank, gpointer user_data, FILE *fp){
2363 Translate *translate, gint rank,
2364 gpointer user_data, gpointer self_data, FILE *fp){
22072365 register gint i, j, pto_start = -1;
22082366 register Alignment_RYO_ComplexToken *rct;
22092367 register Sequence *seq, *subseq;
23222480 fprintf(fp, "%2.2f", Alignment_get_percent_score(
23232481 alignment, query, target,
23242482 translate, FALSE, user_data));
2483 break;
2484 case Alignment_RYO_TOKEN_PERCENT_SELF:
2485 fprintf(fp, "%2.2f", Alignment_get_percent_self(
2486 alignment, query, target,
2487 translate, user_data, self_data));
23252488 break;
23262489 case Alignment_RYO_TOKEN_GENE_ORIENTATION:
23272490 fprintf(fp, "%c",
24452608
24462609 void Alignment_display_ryo(Alignment *alignment,
24472610 Sequence *query, Sequence *target, gchar *format,
2448 Translate *translate, gint rank, gpointer user_data, FILE *fp){
2611 Translate *translate, gint rank,
2612 gpointer user_data, gpointer self_data, FILE *fp){
24492613 register GPtrArray *token_list = Alignment_RYO_tokenise(format);
24502614 Alignment_RYO_token_list_print(token_list, alignment,
24512615 query, target, translate, rank,
2452 user_data, fp);
2616 user_data, self_data, fp);
24532617 Alignment_RYO_token_list_destroy(token_list);
24542618 return;
24552619 }
25902754 static void Alignment_display_gff_exon(Alignment *alignment,
25912755 Sequence *query,
25922756 Sequence *target,
2757 Translate *translate,
25932758 gboolean report_on_query,
25942759 gint query_pos,
25952760 gint target_pos,
25982763 gint exon_query_gap,
25992764 gint exon_target_gap,
26002765 gint exon_query_frameshift,
2601 gint exon_target_frameshift, FILE *fp){
2766 gint exon_target_frameshift,
2767 gpointer user_data, FILE *fp){
26022768 register GPtrArray *attribute_list = g_ptr_array_new();
26032769 g_ptr_array_add(attribute_list,
26042770 g_strdup_printf("insertions %d",
26082774 g_strdup_printf("deletions %d",
26092775 report_on_query?exon_target_gap
26102776 :exon_query_gap));
2777 g_ptr_array_add(attribute_list,
2778 g_strdup_printf("identity %2.2f",
2779 Alignment_get_percent_score_region(alignment,
2780 query, target, translate, TRUE, user_data,
2781 exon_query_start, query_pos)));
2782 g_ptr_array_add(attribute_list,
2783 g_strdup_printf("similarity %2.2f",
2784 Alignment_get_percent_score_region(alignment,
2785 query, target, translate, FALSE, user_data,
2786 exon_query_start, query_pos)));
26112787 if(report_on_query){
26122788 if(exon_query_frameshift)
26132789 g_ptr_array_add(attribute_list,
26662842 }
26672843
26682844 static void Alignment_display_gff_gene(Alignment *alignment,
2669 Sequence *query, Sequence *target, gboolean report_on_query,
2670 gint result_id, FILE *fp){
2845 Sequence *query, Sequence *target, Translate *translate,
2846 gboolean report_on_query,
2847 gint result_id, gpointer user_data, FILE *fp){
26712848 register gint i;
26722849 register gint query_pos = alignment->region->query_start,
26732850 target_pos = alignment->region->target_start;
26912868 report_on_query?target->id:query->id));
26922869 g_ptr_array_add(attribute_list,
26932870 g_strdup_printf("gene_orientation %c", gene_orientation));
2871 g_ptr_array_add(attribute_list,
2872 g_strdup_printf("identity %2.2f",
2873 Alignment_get_percent_score(alignment,
2874 query, target, translate, TRUE, user_data)));
2875 g_ptr_array_add(attribute_list,
2876 g_strdup_printf("similarity %2.2f",
2877 Alignment_get_percent_score(alignment,
2878 query, target, translate, FALSE, user_data)));
26942879 Alignment_display_gff_line(alignment, query, target, report_on_query,
26952880 "gene",
26962881 alignment->region->query_start,
27692954 exon_query_start, exon_target_start,
27702955 query_pos, target_pos, fp);
27712956 Alignment_display_gff_exon(alignment,
2772 query, target, report_on_query,
2957 query, target, translate, report_on_query,
27732958 query_pos, target_pos,
27742959 exon_query_start, exon_target_start,
27752960 exon_query_gap, exon_target_gap,
27762961 exon_query_frameshift,
2777 exon_target_frameshift, fp);
2962 exon_target_frameshift, user_data, fp);
27782963 in_exon = FALSE;
27792964 }
27802965 attribute_list = g_ptr_array_new();
28102995 exon_query_start, exon_target_start,
28112996 query_pos, target_pos, fp);
28122997 Alignment_display_gff_exon(alignment,
2813 query, target, report_on_query,
2998 query, target, translate, report_on_query,
28142999 query_pos, target_pos,
28153000 exon_query_start, exon_target_start,
28163001 exon_query_gap, exon_target_gap,
28173002 exon_query_frameshift,
2818 exon_target_frameshift, fp);
3003 exon_target_frameshift, user_data, fp);
28193004 in_exon = FALSE;
28203005 }
28213006 if(gene_orientation == '+'){
28943079 }
28953080 }
28963081 Alignment_display_gff_exon(alignment,
2897 query, target, report_on_query,
3082 query, target, translate, report_on_query,
28983083 query_pos, target_pos,
28993084 exon_query_start, exon_target_start,
29003085 exon_query_gap, exon_target_gap,
2901 exon_query_frameshift, exon_target_frameshift, fp);
3086 exon_query_frameshift, exon_target_frameshift, user_data, fp);
29023087 }
29033088 return;
29043089 }
29733158
29743159 void Alignment_display_gff(Alignment *alignment,
29753160 Sequence *query, Sequence *target,
3161 Translate *translate,
29763162 gboolean report_on_query,
29773163 gboolean report_on_genomic,
2978 gint result_id, FILE *fp){
3164 gint result_id, gpointer user_data, FILE *fp){
29793165 fprintf(fp, "# --- START OF GFF DUMP ---\n#\n");
29803166 Alignment_display_gff_header(alignment, query, target,
29813167 report_on_query, fp);
29823168 if(report_on_genomic){
2983 Alignment_display_gff_gene(alignment, query, target,
2984 report_on_query, result_id, fp);
3169 Alignment_display_gff_gene(alignment, query, target, translate,
3170 report_on_query, result_id, user_data, fp);
29853171 }
29863172 Alignment_display_gff_similarity(alignment, query, target,
29873173 report_on_query, result_id, fp);
22 * C4 dynamic programming library - alignment code *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
7575
7676 void Alignment_display_gff(Alignment *alignment,
7777 Sequence *query, Sequence *target,
78 Translate *translate,
7879 gboolean report_on_query,
7980 gboolean report_on_genomic,
80 gint result_id, FILE *fp);
81 gint result_id, gpointer user_data, FILE *fp);
8182
8283 void Alignment_display_ryo(Alignment *alignment,
8384 Sequence *query, Sequence *target, gchar *format,
84 Translate *translate, gint rank, gpointer user_data, FILE *fp);
85 Translate *translate, gint rank,
86 gpointer user_data, gpointer self_data, FILE *fp);
8587
8688 /**/
8789
22 * C4 dynamic programming library - alignment code *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
22 * C4 dynamic programming library - code for models *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
519519 model->exit_func = NULL;
520520 model->exit_macro = NULL;
521521 /**/
522 model->ref_count = 1;
522 model->thread_ref = ThreadRef_create();
523523 model->is_open = TRUE;
524524 /**/
525525 model->state_list = g_ptr_array_new();
559559 void C4_Model_destroy(C4_Model *model){
560560 register gint i;
561561 g_assert(model);
562 if(--model->ref_count)
562 if(ThreadRef_destroy(model->thread_ref))
563563 return;
564564 g_free(model->name);
565565 C4_Model_destroy_string_list(model->global_code_list);
596596 C4_Model *C4_Model_share(C4_Model *model){
597597 g_assert(model);
598598 g_assert(!model->is_open);
599 model->ref_count++;
599 ThreadRef_share(model->thread_ref);
600600 return model;
601601 }
602602
22 * C4 dynamic programming library - code for models *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
2222 #include <glib.h>
2323
2424 #include "region.h"
25 #include "threadref.h"
2526
2627 typedef gint C4_Score;
2728 #define C4_IMPOSSIBLY_LOW_SCORE -987654321
176177 gchar *init_macro; /* If NULL, use init_func */
177178 C4_PrepFunc exit_func; /* If NULL, no initialisation */
178179 gchar *exit_macro; /* If NULL, use exit_func */
179 gint ref_count;
180 ThreadRef *thread_ref;
180181 gboolean is_open;
181182 GPtrArray *state_list;
182183 GPtrArray *transition_list;
22 * C4 dynamic programming library - code for models *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
22 * Utilities to facilitate code generation DP implementations *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
22 * Utilities to facilitate code generation DP implementations *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
22 * Utilities to facilitate code generation DP implementations *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
22 * Code generation module for C4 *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
22 * Code generation module for C4 *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
22 * Code generation module for C4 *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
22 * C4 dynamic programming library - DP layout code *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
22 * C4 dynamic programming library - DP layout code *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
22 * C4 dynamic programming library - optimal alignment code *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
22 * C4 dynamic programming library - code for optimal pairs *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
22 * C4 dynamic programming library - code for optimal pairs *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
22 * C4 dynamic programming library - code for optimal pairs *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
22 * C4 dynamic programming library - optimal alignment code *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
22 * C4 dynamic programming library - optimal alignment code *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
22 * C4 dynamic programming library - DP layout code *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
22 * C4 dynamic programming library - code for regions *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
22 * C4 dynamic programming library - code for regions *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
22 * C4 dynamic programming library - code for regions *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
22 * C4 dynamic programming library - suboptimal alignments *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
22 * C4 dynamic programming library - suboptimal alignments *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
22 * C4 dynamic programming library - suboptimal alignments *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
22 * C4 dynamic programming library - the Viterbi implementation *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
22 * C4 dynamic programming library - the Viterbi implementation *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
22 * C4 dynamic programming library - the Viterbi implementation *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
2828 $(top_srcdir)/src/sequence/codonsubmat.o \
2929 $(top_srcdir)/src/struct/pqueue.o \
3030 $(top_srcdir)/src/struct/recyclebin.o \
31 $(top_srcdir)/src/general/threadref.o \
3132 $(SEQUENCE_OBJ)
3233
3334 pcr_test_SOURCES = pcr.test.c pcr.c wordhood.c
4445 $(top_srcdir)/src/sequence/codonsubmat.o \
4546 $(top_srcdir)/src/struct/recyclebin.o \
4647 $(top_srcdir)/src/struct/pqueue.o \
48 $(top_srcdir)/src/general/threadref.o \
4749 $(SEQUENCE_OBJ)
4850
4951 match_test_SOURCES = match.test.c match.c
5961 $(top_srcdir)/src/struct/fsm.o \
6062 $(top_srcdir)/src/struct/vfsm.o \
6163 $(top_srcdir)/src/struct/pqueue.o \
64 $(top_srcdir)/src/general/threadref.o \
6265 $(SEQUENCE_OBJ)
6366
6467 # Files to clear away
6969 VERSION = @VERSION@
7070 codegen_extra_ldadd = @codegen_extra_ldadd@
7171 codegen_extra_sources = @codegen_extra_sources@
72 custom_guint64_format = @custom_guint64_format@
7273 datarootdir = @datarootdir@
7374 glib_cflags = @glib_cflags@
7475 glib_libs = @glib_libs@
9495 wordhood_test_LDADD = $(top_srcdir)/src/sequence/submat.o $(top_srcdir)/src/sequence/codonsubmat.o $(SEQUENCE_OBJ)
9596
9697 hspset_test_SOURCES = hspset.test.c hspset.c match.c wordhood.c
97 hspset_test_LDADD = $(top_srcdir)/src/sequence/submat.o $(top_srcdir)/src/sequence/codonsubmat.o $(top_srcdir)/src/struct/pqueue.o $(top_srcdir)/src/struct/recyclebin.o $(SEQUENCE_OBJ)
98 hspset_test_LDADD = $(top_srcdir)/src/sequence/submat.o $(top_srcdir)/src/sequence/codonsubmat.o $(top_srcdir)/src/struct/pqueue.o $(top_srcdir)/src/struct/recyclebin.o $(top_srcdir)/src/general/threadref.o $(SEQUENCE_OBJ)
9899
99100
100101 pcr_test_SOURCES = pcr.test.c pcr.c wordhood.c
103104
104105 comparison_test_SOURCES = comparison.test.c comparison.c hspset.c match.c wordhood.c
105106
106 comparison_test_LDADD = $(top_srcdir)/src/sequence/submat.o $(top_srcdir)/src/sequence/codonsubmat.o $(top_srcdir)/src/struct/recyclebin.o $(top_srcdir)/src/struct/pqueue.o $(SEQUENCE_OBJ)
107 comparison_test_LDADD = $(top_srcdir)/src/sequence/submat.o $(top_srcdir)/src/sequence/codonsubmat.o $(top_srcdir)/src/struct/recyclebin.o $(top_srcdir)/src/struct/pqueue.o $(top_srcdir)/src/general/threadref.o $(SEQUENCE_OBJ)
107108
108109
109110 match_test_SOURCES = match.test.c match.c
112113
113114 seeder_test_SOURCES = seeder.test.c seeder.c wordhood.c hspset.c match.c comparison.c
114115
115 seeder_test_LDADD = $(top_srcdir)/src/sequence/submat.o $(top_srcdir)/src/sequence/codonsubmat.o $(top_srcdir)/src/struct/recyclebin.o $(top_srcdir)/src/struct/fsm.o $(top_srcdir)/src/struct/vfsm.o $(top_srcdir)/src/struct/pqueue.o $(SEQUENCE_OBJ)
116 seeder_test_LDADD = $(top_srcdir)/src/sequence/submat.o $(top_srcdir)/src/sequence/codonsubmat.o $(top_srcdir)/src/struct/recyclebin.o $(top_srcdir)/src/struct/fsm.o $(top_srcdir)/src/struct/vfsm.o $(top_srcdir)/src/struct/pqueue.o $(top_srcdir)/src/general/threadref.o $(SEQUENCE_OBJ)
116117
117118
118119 # Files to clear away
142143 hspset_test_DEPENDENCIES = $(top_srcdir)/src/sequence/submat.o \
143144 $(top_srcdir)/src/sequence/codonsubmat.o \
144145 $(top_srcdir)/src/struct/pqueue.o $(top_srcdir)/src/struct/recyclebin.o \
146 $(top_srcdir)/src/general/threadref.o \
145147 $(top_srcdir)/src/struct/sparsecache.o \
146148 $(top_srcdir)/src/struct/matrix.o $(top_srcdir)/src/sequence/sequence.o \
147149 $(top_srcdir)/src/sequence/alphabet.o \
167169 comparison_test_DEPENDENCIES = $(top_srcdir)/src/sequence/submat.o \
168170 $(top_srcdir)/src/sequence/codonsubmat.o \
169171 $(top_srcdir)/src/struct/recyclebin.o $(top_srcdir)/src/struct/pqueue.o \
172 $(top_srcdir)/src/general/threadref.o \
170173 $(top_srcdir)/src/struct/sparsecache.o \
171174 $(top_srcdir)/src/struct/matrix.o $(top_srcdir)/src/sequence/sequence.o \
172175 $(top_srcdir)/src/sequence/alphabet.o \
192195 $(top_srcdir)/src/sequence/codonsubmat.o \
193196 $(top_srcdir)/src/struct/recyclebin.o $(top_srcdir)/src/struct/fsm.o \
194197 $(top_srcdir)/src/struct/vfsm.o $(top_srcdir)/src/struct/pqueue.o \
198 $(top_srcdir)/src/general/threadref.o \
195199 $(top_srcdir)/src/struct/sparsecache.o \
196200 $(top_srcdir)/src/struct/matrix.o $(top_srcdir)/src/sequence/sequence.o \
197201 $(top_srcdir)/src/sequence/alphabet.o \
22 * Comparison : A module for pairwise sequence comparisons *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
3535 HSP_Param *codon_hsp_param,
3636 gboolean swap_param){
3737 register Comparison_Param *param = g_new(Comparison_Param, 1);
38 param->ref_count = 1;
38 param->thread_ref = NULL;
3939 param->query_type = query_type;
4040 param->target_type = target_type;
4141 param->dna_hsp_param = Comparison_Param_get_hsp_param(dna_hsp_param,
6363 dna_hsp_param, protein_hsp_param,
6464 codon_hsp_param, TRUE);
6565 param->mirror->mirror = param;
66 param->mirror->thread_ref = param->thread_ref = ThreadRef_create();
6667 return param;
67 }
68
69 static gint Comparison_Param_ref_count(Comparison_Param *param){
70 g_assert(param);
71 g_assert(param->mirror);
72 return param->ref_count + param->mirror->ref_count;
7368 }
7469
7570 static void Comparison_Param_destroy_without_mirror(
8883
8984 void Comparison_Param_destroy(Comparison_Param *param){
9085 g_assert(param);
91 param->ref_count--;
92 if(Comparison_Param_ref_count(param) > 1) /* Allow for mirror */
86 if(ThreadRef_destroy(param->thread_ref))
9387 return;
9488 Comparison_Param_destroy_without_mirror(param->mirror);
9589 Comparison_Param_destroy_without_mirror(param);
9892
9993 Comparison_Param *Comparison_Param_share(Comparison_Param *param){
10094 g_assert(param);
101 param->ref_count++;
95 ThreadRef_share(param->thread_ref);
10296 return param;
10397 }
10498
131125 g_assert(param);
132126 g_assert(query);
133127 g_assert(target);
134 comparison->ref_count = 1;
128 comparison->thread_ref = ThreadRef_create();
135129 comparison->param = Comparison_Param_share(param);
136130 comparison->query = Sequence_share(query);
137131 comparison->target = Sequence_share(target);
138 comparison->dna_hspset = param->dna_hsp_param
132 ThreadRef_lock(comparison->param->thread_ref);
133 comparison->dna_hspset = comparison->param->dna_hsp_param
139134 ? HSPset_create(query, target,
140135 param->dna_hsp_param)
141136 : NULL;
147142 ? HSPset_create(query, target,
148143 param->codon_hsp_param)
149144 : NULL;
145 ThreadRef_unlock(comparison->param->thread_ref);
150146 return comparison;
151147 }
152148
153149 Comparison *Comparison_share(Comparison *comparison){
154 comparison->ref_count++;
150 ThreadRef_share(comparison->thread_ref);
155151 return comparison;
156152 }
157153
158154 void Comparison_destroy(Comparison *comparison){
159155 g_assert(comparison);
160 if(--comparison->ref_count)
156 if(ThreadRef_destroy(comparison->thread_ref))
161157 return;
162158 Comparison_Param_destroy(comparison->param);
163159 Sequence_destroy(comparison->query);
216212
217213 void Comparison_swap(Comparison *comparison){
218214 register Sequence *query;
219 g_assert(comparison->ref_count == 1);
215 g_assert(ThreadRef_get_count(comparison->thread_ref) == 1);
220216 /* Mirror parameters */
221217 comparison->param = Comparison_Param_share(comparison->param->mirror);
222218 Comparison_Param_destroy(comparison->param->mirror);
241237 void Comparison_revcomp(Comparison *comparison){
242238 register Sequence *rc_query = Sequence_revcomp(comparison->query),
243239 *rc_target = Sequence_revcomp(comparison->target);
244 g_assert(comparison->ref_count == 1);
240 g_assert(ThreadRef_get_count(comparison->thread_ref) == 1);
245241 g_assert(comparison->dna_hspset);
246242 g_assert(!comparison->protein_hspset);
247243 g_assert(!comparison->codon_hspset);
22 * Comparison : A module for pairwise sequence comparisons *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
2626 #include "translate.h"
2727 #include "submat.h"
2828 #include "hspset.h"
29 #include "threadref.h"
2930
3031 typedef struct Comparison_Param {
31 gint ref_count;
32 ThreadRef *thread_ref;
3233 Alphabet_Type query_type;
3334 Alphabet_Type target_type;
3435 HSP_Param *dna_hsp_param;
4950 /**/
5051
5152 typedef struct {
52 gint ref_count;
53 ThreadRef *thread_ref;
5354 Comparison_Param *param;
5455 Sequence *query;
5556 Sequence *target;
6364 Comparison *Comparison_share(Comparison *comparison);
6465 void Comparison_destroy(Comparison *comparison);
6566 void Comparison_print(Comparison *comparison);
66 HSPset_ArgumentSet *Comparison_Param_get_HSPSet_Argument_Set(Comparison_Param *param);
67 HSPset_ArgumentSet *Comparison_Param_get_HSPSet_Argument_Set(
68 Comparison_Param *param);
6769
6870 gboolean Comparison_has_hsps(Comparison *comparison);
6971 void Comparison_finalise(Comparison *comparison);
22 * Comparison : A module for pairwise sequence comparisons *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
22 * Library for HSP sets (high-scoring segment pairs) *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
6565 /**/
6666 ArgumentSet_add_option(as, 0, "dnawordlimit", "score",
6767 "Score limit for dna word neighbourhood", "0",
68 Argument_parse_int, &has.dna_wordlimit);
68 Argument_parse_int, &has.dna_word_limit);
6969 ArgumentSet_add_option(as, 0, "proteinwordlimit", "score",
7070 "Score limit for protein word neighbourhood", "4",
71 Argument_parse_int, &has.protein_wordlimit);
71 Argument_parse_int, &has.protein_word_limit);
7272 ArgumentSet_add_option(as, 0, "codonwordlimit", "score",
7373 "Score limit for codon word neighbourhood", "4",
74 Argument_parse_int, &has.codon_wordlimit);
74 Argument_parse_int, &has.codon_word_limit);
7575 /**/
7676 ArgumentSet_add_option(as, '\0', "geneseed", "threshold",
7777 "Geneseed Threshold", "0",
141141
142142 /**/
143143
144 static void HSP_Param_refresh_wordhood(HSP_Param *hsp_param){
145 register WordHood_Alphabet *wha = NULL;
146 register Submat *submat;
147 if(hsp_param->wordhood)
148 WordHood_destroy(hsp_param->wordhood);
149 if(hsp_param->has->use_wordhood_dropoff && (!hsp_param->wordlimit)){
150 hsp_param->wordhood = NULL;
151 } else {
152 submat = (hsp_param->match->type == Match_Type_DNA2DNA)
153 ? hsp_param->match->mas->dna_submat
154 : hsp_param->match->mas->protein_submat;
155 wha = WordHood_Alphabet_create_from_Submat(
156 (gchar*)hsp_param->match->comparison_alphabet->member,
157 (gchar*)hsp_param->match->comparison_alphabet->member,
158 submat, FALSE);
159 g_assert(wha);
160 hsp_param->wordhood = WordHood_create(wha, hsp_param->wordlimit,
161 hsp_param->has->use_wordhood_dropoff);
162 WordHood_Alphabet_destroy(wha);
163 }
164 return;
165 }
166 /* FIXME: optimisation: do not free/recreate wordhood when unnecessary */
167
168 void HSP_Param_set_dna_word_limit(HSP_Param *hsp_param,
169 gint dna_word_limit){
170 if(hsp_param->match->type == Match_Type_DNA2DNA){
171 hsp_param->wordlimit = dna_word_limit;
172 HSP_Param_refresh_wordhood(hsp_param);
173 }
174 return;
175 }
176
177 void HSP_Param_set_protein_word_limit(HSP_Param *hsp_param,
178 gint protein_word_limit){
179 if((hsp_param->match->type == Match_Type_PROTEIN2PROTEIN)
180 || (hsp_param->match->type == Match_Type_PROTEIN2DNA)
181 || (hsp_param->match->type == Match_Type_DNA2PROTEIN)){
182 hsp_param->wordlimit = protein_word_limit;
183 HSP_Param_refresh_wordhood(hsp_param);
184 }
185 return;
186 }
187
188 void HSP_Param_set_codon_word_limit(HSP_Param *hsp_param,
189 gint codon_word_limit){
190 if(hsp_param->match->type == Match_Type_CODON2CODON){
191 hsp_param->threshold = codon_word_limit;
192 HSP_Param_refresh_wordhood(hsp_param);
193 }
194 return;
195 }
196
197 /**/
198
144199 void HSP_Param_set_dna_hsp_dropoff(HSP_Param *hsp_param,
145200 gint dna_hsp_dropoff){
146201 if(hsp_param->match->type == Match_Type_DNA2DNA)
180235
181236 HSP_Param *HSP_Param_create(Match *match, gboolean use_horizon){
182237 register HSP_Param *hsp_param = g_new(HSP_Param, 1);
183 register WordHood_Alphabet *wha = NULL;
184 register Submat *submat;
185 hsp_param->ref_count = 1;
238 hsp_param->thread_ref = ThreadRef_create();
186239 hsp_param->has = HSPset_ArgumentSet_create(NULL);
187240 hsp_param->match = match;
188241 hsp_param->seed_repeat = hsp_param->has->seed_repeat;
191244 hsp_param->dropoff = hsp_param->has->dna_hsp_dropoff;
192245 hsp_param->threshold = hsp_param->has->dna_hsp_threshold;
193246 HSP_Param_set_wordlen(hsp_param, hsp_param->has->dna_wordlen);
194 hsp_param->wordlimit = hsp_param->has->dna_wordlimit;
247 hsp_param->wordlimit = hsp_param->has->dna_word_limit;
195248 break;
196249 case Match_Type_PROTEIN2PROTEIN: /*fallthrough*/
197250 case Match_Type_PROTEIN2DNA: /*fallthrough*/
200253 hsp_param->threshold
201254 = hsp_param->has->protein_hsp_threshold;
202255 HSP_Param_set_wordlen(hsp_param, hsp_param->has->protein_wordlen);
203 hsp_param->wordlimit = hsp_param->has->protein_wordlimit;
256 hsp_param->wordlimit = hsp_param->has->protein_word_limit;
204257 break;
205258 case Match_Type_CODON2CODON:
206259 hsp_param->dropoff = hsp_param->has->codon_hsp_dropoff;
207260 hsp_param->threshold = hsp_param->has->codon_hsp_threshold;
208261 HSP_Param_set_wordlen(hsp_param, hsp_param->has->codon_wordlen);
209 hsp_param->wordlimit = hsp_param->has->codon_wordlimit;
262 hsp_param->wordlimit = hsp_param->has->codon_word_limit;
210263 g_assert(!(hsp_param->wordlen % 3));
211264 break;
212265 default:
214267 break;
215268 }
216269 hsp_param->use_horizon = use_horizon;
217 if(hsp_param->has->use_wordhood_dropoff && (!hsp_param->wordlimit)){
218 hsp_param->wordhood = NULL;
219 } else {
220 submat = (match->type == Match_Type_DNA2DNA)
221 ? match->mas->dna_submat
222 : match->mas->protein_submat;
223 wha = WordHood_Alphabet_create_from_Submat(
224 (gchar*)match->comparison_alphabet->member,
225 (gchar*)match->comparison_alphabet->member, submat, FALSE);
226 g_assert(wha);
227 hsp_param->wordhood = WordHood_create(wha, hsp_param->wordlimit,
228 hsp_param->has->use_wordhood_dropoff);
229 WordHood_Alphabet_destroy(wha);
230 }
270 #ifdef USE_PTHREADS
271 pthread_mutex_init(&hsp_param->hsp_recycle_lock, NULL);
272 #endif /* USE_PTHREADS */
273 hsp_param->hsp_recycle = RecycleBin_create("HSP", sizeof(HSP), 64);
274 hsp_param->wordhood = NULL;
275 HSP_Param_refresh_wordhood(hsp_param);
231276 return hsp_param;
232277 }
233278
234279 void HSP_Param_destroy(HSP_Param *hsp_param){
235280 g_assert(hsp_param);
236 if(--hsp_param->ref_count)
281 if(ThreadRef_destroy(hsp_param->thread_ref))
237282 return;
238283 if(hsp_param->wordhood)
239284 WordHood_destroy(hsp_param->wordhood);
285 #ifdef USE_PTHREADS
286 pthread_mutex_lock(&hsp_param->hsp_recycle_lock);
287 #endif /* USE_PTHREADS */
288 RecycleBin_destroy(hsp_param->hsp_recycle);
289 #ifdef USE_PTHREADS
290 pthread_mutex_unlock(&hsp_param->hsp_recycle_lock);
291 pthread_mutex_destroy(&hsp_param->hsp_recycle_lock);
292 #endif /* USE_PTHREADS */
240293 g_free(hsp_param);
241294 return;
242295 }
243296
244297 HSP_Param *HSP_Param_share(HSP_Param *hsp_param){
245298 g_assert(hsp_param);
246 hsp_param->ref_count++;
299 ThreadRef_share(hsp_param->thread_ref);
247300 return hsp_param;
248301 }
249302
252305 return HSP_Param_create(Match_swap(hsp_param->match),
253306 hsp_param->use_horizon);
254307 }
255
256 static RecycleBin *global_hsp_recycle_bin = NULL;
257308
258309 HSPset *HSPset_create(Sequence *query, Sequence *target,
259310 HSP_Param *hsp_param){
265316 hsp_set->target = Sequence_share(target);
266317 hsp_set->param = HSP_Param_share(hsp_param);
267318 /**/
268 if(global_hsp_recycle_bin){
269 hsp_set->hsp_recycle = RecycleBin_share(global_hsp_recycle_bin);
270 } else {
271 global_hsp_recycle_bin = RecycleBin_create("HSP", sizeof(HSP), 64);
272 hsp_set->hsp_recycle = global_hsp_recycle_bin;
273 }
274319 if(hsp_param->use_horizon){
275320 hsp_set->horizon = (gint****)Matrix4d_create(
276 1 + ((hsp_param->seed_repeat > 1)?1:0),
321 1 + ((hsp_param->seed_repeat > 1)?2:0),
277322 query->len,
278323 hsp_param->match->query->advance,
279324 hsp_param->match->target->advance,
294339 hsp_set->is_empty = TRUE;
295340 return hsp_set;
296341 }
342 /* horizon[score(,repeat_count,diag)]
343 * [query_len]
344 * [query_advance]
345 * [target_advance]
346 */
297347
298348 /**/
299349
321371 HSP_destroy(hsp);
322372 }
323373 g_ptr_array_free(hsp_set->hsp_list, TRUE);
324 if(hsp_set->hsp_recycle->ref_count == 1) /* last active hsp_set */
325 global_hsp_recycle_bin = NULL;
326 RecycleBin_destroy(hsp_set->hsp_recycle);
327374 if(hsp_set->horizon)
328375 g_free(hsp_set->horizon);
329376 g_free(hsp_set);
519566 }
520567 HSP_Display_print_ruler(hd, hd->top->len-pos, pos, TRUE);
521568 g_print(" query:[%.*s]\n [%.*s]\ntarget:[%.*s]\n",
522 hd->top->len-pos, hd->top->str+pos,
523 hd->mid->len-pos, hd->mid->str+pos,
524 hd->low->len-pos, hd->low->str+pos);
569 (gint)(hd->top->len-pos), hd->top->str+pos,
570 (gint)(hd->mid->len-pos), hd->mid->str+pos,
571 (gint)(hd->low->len-pos), hd->low->str+pos);
525572 HSP_Display_print_ruler(hd, hd->top->len-pos, pos, FALSE);
526573 g_print("\n");
527574 return;
765812 return;
766813 }
767814 /* The score cannot be allowed to drop below zero in the HSP,
768 * as this can result in overlapping HSPs in some circurmstances.
815 * as this can result in overlapping HSPs in some circumstances.
769816 */
770817
771818 static HSP *HSP_create(HSP *nh){
772 register HSP *hsp = RecycleBin_alloc(nh->hsp_set->hsp_recycle);
819 register HSP *hsp;
820 #ifdef USE_PTHREADS
821 pthread_mutex_lock(&nh->hsp_set->param->hsp_recycle_lock);
822 #endif /* USE_PTHREADS */
823 hsp = RecycleBin_alloc(nh->hsp_set->param->hsp_recycle);
824 #ifdef USE_PTHREADS
825 pthread_mutex_unlock(&nh->hsp_set->param->hsp_recycle_lock);
826 #endif /* USE_PTHREADS */
773827 hsp->hsp_set = nh->hsp_set;
774828 hsp->query_start = nh->query_start;
775829 hsp->target_start = nh->target_start;
781835
782836 void HSP_destroy(HSP *hsp){
783837 register HSPset *hsp_set = hsp->hsp_set;
784 RecycleBin_recycle(hsp_set->hsp_recycle, hsp);
838 #ifdef USE_PTHREADS
839 pthread_mutex_lock(&hsp_set->param->hsp_recycle_lock);
840 #endif /* USE_PTHREADS */
841 RecycleBin_recycle(hsp_set->param->hsp_recycle, hsp);
842 #ifdef USE_PTHREADS
843 pthread_mutex_unlock(&hsp_set->param->hsp_recycle_lock);
844 #endif /* USE_PTHREADS */
785845 return;
786846 }
787847
884944 /**/
885945 g_assert(section_pos >= 0);
886946 g_assert(section_pos < hsp_set->query->len);
947 /* Clear if diag has changed */
948 if(hsp_set->param->seed_repeat > 1){
949 if(hsp_set->horizon[2][section_pos][query_frame][target_frame]
950 != (diag_pos + hsp_set->query->len)){
951 hsp_set->horizon[0][section_pos][query_frame][target_frame] = 0;
952 hsp_set->horizon[1][section_pos][query_frame][target_frame] = 0;
953 hsp_set->horizon[2][section_pos][query_frame][target_frame]
954 = diag_pos + hsp_set->query->len;
955 }
956 }
887957 /* Check whether we have seen this HSP already */
888958 if(target_start < hsp_set->horizon[0]
889959 [section_pos]
9621032 horizon[0][query_frame][target_frame] = 0;
9631033 horizon[2][query_frame][target_frame] = 0;
9641034 }
1035 /* FIXME: seedrepeat overflow here */
9651036 if(++horizon[2][query_frame][target_frame] < hsp_set->param->seed_repeat)
9661037 return;
9671038 horizon[2][query_frame][target_frame] = 0;
22 * Library for HSP sets (high-scoring segment pairs) *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
3131 #include "matrix.h"
3232 #include "wordhood.h"
3333 #include "recyclebin.h"
34 #include "threadref.h"
3435
3536 typedef struct {
3637 gint filter_threshold;
4950 gint protein_hsp_threshold;
5051 gint codon_hsp_threshold;
5152 /**/
52 gint dna_wordlimit;
53 gint protein_wordlimit;
54 gint codon_wordlimit;
53 gint dna_word_limit;
54 gint protein_word_limit;
55 gint codon_word_limit;
5556 /**/
5657 gint geneseed_threshold;
5758 gint geneseed_repeat;
136137 #define HSPset_is_empty(hspset) ((hspset)->is_empty)
137138
138139 typedef struct HSP_Param {
139 gint ref_count;
140 ThreadRef *thread_ref;
140141 HSPset_ArgumentSet *has;
141142 Match *match;
142143 gint wordlen;
147148 WordHood *wordhood;
148149 gboolean use_horizon;
149150 gint seed_repeat;
151 RecycleBin *hsp_recycle;
152 #ifdef USE_PTHREADS
153 pthread_mutex_t hsp_recycle_lock;
154 #endif /* USE_PTHREADS */
150155 } HSP_Param;
151156
152157 HSP_Param *HSP_Param_create(Match *match, gboolean use_horizon);
159164 void HSP_Param_set_dna_hsp_threshold(HSP_Param *hsp_param,
160165 gint dna_hsp_threshold);
161166 void HSP_Param_set_protein_hsp_threshold(HSP_Param *hsp_param,
162 gint dna_hsp_threshold);
167 gint protein_hsp_threshold);
163168 void HSP_Param_set_codon_hsp_threshold(HSP_Param *hsp_param,
164 gint dna_hsp_threshold);
169 gint protein_hsp_threshold);
170 /**/
171 void HSP_Param_set_dna_word_limit(HSP_Param *hsp_param,
172 gint dna_word_limit);
173 void HSP_Param_set_protein_word_limit(HSP_Param *hsp_param,
174 gint protein_word_limit);
175 void HSP_Param_set_codon_word_limit(HSP_Param *hsp_param,
176 gint codon_word_limit);
165177 /**/
166178 void HSP_Param_set_dna_hsp_dropoff(HSP_Param *hsp_param,
167179 gint dna_hsp_dropoff);
180192 Sequence *query;
181193 Sequence *target;
182194 HSP_Param *param;
183 RecycleBin *hsp_recycle;
184195 gint ****horizon;
185196 GPtrArray *hsp_list;
186197 /**/
22 * Library for HSP sets (high-scoring segment pairs) *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
22 * Match : A module for pairwise symbol comparison *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
3636 Match_ArgumentSet *Match_ArgumentSet_create(Argument *arg){
3737 register ArgumentSet *as;
3838 static Match_ArgumentSet mas = {0};
39 if(!mas.translate){
40 mas.translate = Translate_create(FALSE);
41 /* FIXME this should be freed somewhere */
42 }
4339 if(arg){
4440 as = ArgumentSet_create("Symbol Comparison Options");
4541 ArgumentSet_add_option(as, 0, "softmaskquery", NULL,
5955 Argument_absorb_ArgumentSet(arg, as);
6056 Argument_add_cleanup(arg, Match_Argument_cleanup, NULL);
6157 /**/
58 } else {
59 if(!mas.translate){
60 mas.translate = Translate_create(FALSE);
61 /* FIXME this should be freed somewhere */
62 }
6263 }
6364 return &mas;
6465 }
22 * Match : A module for pairwise symbol comparison *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
22 * Match : A module for pairwise symbol comparison *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
22 * Library for PCR simulation *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
22 * Library for PCR simulation *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
22 * Library for PCR simulation *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
22 * Seeder : A module for seeding pairwise alignments *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
2424 (*(type*)((char*)(instance) + (offset)))
2525 #endif /* OFFSET_ITEM */
2626
27 #ifndef Swap
28 #define Swap(x,y,temp) ((temp)=(x),(x)=(y),(y)=(temp))
29 #endif /* Swap */
30
2731 Seeder_ArgumentSet *Seeder_ArgumentSet_create(Argument *arg){
2832 register ArgumentSet *as;
2933 static Seeder_ArgumentSet sas;
3034 if(arg){
3135 as = ArgumentSet_create("Alignment Seeding Options");
3236 ArgumentSet_add_option(as, 'M', "fsmmemory", "Mb",
33 "Memory limit for FSM scanning", "64",
37 "Memory limit for FSM scanning", "256",
3438 Argument_parse_int, &sas.fsm_memory_limit);
3539 ArgumentSet_add_option(as, '\0', "forcefsm", "fsm type",
3640 "Force FSM type ( normal | compact )", "none",
3842 ArgumentSet_add_option(as, 0, "wordjump", NULL,
3943 "Jump between query words", "1",
4044 Argument_parse_int, &sas.word_jump);
45 ArgumentSet_add_option(as, 0, "wordambiguity", NULL,
46 "Number of ambiguous words to expand", "1",
47 Argument_parse_int, &sas.word_ambiguity);
4148 Argument_absorb_ArgumentSet(arg, as);
4249 }
4350 return &sas;
301308 gpointer user_data){
302309 register Seeder *seeder = g_new0(Seeder, 1);
303310 seeder->sas = Seeder_ArgumentSet_create(NULL);
311 if(seeder->sas->word_ambiguity < 1)
312 g_error("Word ambiguity cannot be less than one.");
313 if(seeder->sas->word_ambiguity > 1){
314 if(comparison_param->protein_hsp_param)
315 g_error("Protein ambuiguity symbols not implemented");
316 g_warning("setting --wordambiguity in exonerate will be SLOW.");
317 g_warning("... use esd2esi --wordambiguity and exonerate-server instead");
318 }
304319 seeder->is_prepared = FALSE;
305320 seeder->verbosity = verbosity;
306321 seeder->report_func = report_func;
412427 }
413428
414429 void Seeder_memory_info(Seeder *seeder){
415 g_message("Seeder Total = %dMb", Seeder_memory_usage(seeder)>>20);
430 g_message("Seeder Total = %dMb", (gint)(Seeder_memory_usage(seeder)>>20));
416431 g_assert(seeder);
417432 if(seeder->seeder_fsm)
418433 g_message(" -> FSM memory = %dMb",
419 Seeder_FSM_memory_usage(seeder->seeder_fsm)>>20);
434 (gint)(Seeder_FSM_memory_usage(seeder->seeder_fsm)>>20));
420435 else
421436 g_message(" -> VFSM memory = %dMb",
422 Seeder_VFSM_memory_usage(seeder->seeder_vfsm)>>20);
437 (gint)(Seeder_VFSM_memory_usage(seeder->seeder_vfsm)>>20));
423438 g_message(" -> QueryInfo memory = %dMb",
424 (seeder->query_info_list->len
439 (gint)(seeder->query_info_list->len
425440 *(sizeof(gpointer)+sizeof(Seeder_QueryInfo)))>>20);
426441 g_message(" -> Recycle_Wordinfo Memory = %dMb",
427 RecycleBin_memory_usage(seeder->recycle_wordinfo)>>20);
442 (gint)(RecycleBin_memory_usage(seeder->recycle_wordinfo)>>20));
428443 g_message(" -> Recycle_Seed Memory = %dMb",
429 RecycleBin_memory_usage(seeder->recycle_seed)>>20);
444 (gint)(RecycleBin_memory_usage(seeder->recycle_seed)>>20));
430445 g_message(" -> Recycle_Neighbour Memory = %dMb",
431 RecycleBin_memory_usage(seeder->recycle_neighbour)>>20);
446 (gint)(RecycleBin_memory_usage(seeder->recycle_neighbour)>>20));
432447 g_message(" -> Recycle_Context Memory = %dMb",
433 RecycleBin_memory_usage(seeder->recycle_context)>>20);
448 (gint)(RecycleBin_memory_usage(seeder->recycle_context)>>20));
434449 return;
435450 }
436451
514529 } else {
515530 leaf = VFSM_state2leaf(vfsm, state);
516531 word_info = seeder->seeder_vfsm->leaf[leaf];
517 if(!word_info)
532 if(!word_info){
518533 word_info = Seeder_WordInfo_create(seeder);
534 seeder->seeder_vfsm->leaf[leaf] = word_info;
535 }
519536 }
520537 g_assert(word_info);
521538 if(frame)
674691 return;
675692 }
676693
677 static void Seeder_VFSM_traverse(Seeder *seeder, gchar *seq,
678 Seeder_TargetInfo *target_info){
694 static void Seeder_VFSM_traverse_single(Seeder *seeder, gchar *seq,
695 Seeder_TargetInfo *target_info){
679696 register gint i, ch;
680697 register VFSM_Int state = 0, leaf;
681698 register VFSM *vfsm = seeder->seeder_vfsm->vfsm;
699716 return;
700717 }
701718
719 static void Seeder_VFSM_traverse_ambig(Seeder *seeder, gchar *seq,
720 Seeder_TargetInfo *target_info){
721 register gint i, j, k, ch;
722 register VFSM_Int state, next_state, leaf;
723 register VFSM *vfsm = seeder->seeder_vfsm->vfsm;
724 register Seeder_WordInfo *word_info;
725 register gchar *ambig;
726 register VFSM_Int *temp_state_list,
727 *curr_state_list = g_new0(VFSM_Int,
728 seeder->sas->word_ambiguity),
729 *next_state_list = g_new0(VFSM_Int,
730 seeder->sas->word_ambiguity);
731 register gint curr_state_list_len = 1, next_state_list_len = 0;
732 g_assert(vfsm);
733 for(i = 0; seq[i]; i++){
734 ch = toupper(seq[i]); /* FIXME: filter properly */
735 if((!(ambig = Alphabet_nt2ambig(ch)))
736 || ((strlen(ambig) * curr_state_list_len)
737 > seeder->sas->word_ambiguity)){
738 next_state_list_len = 0;
739 curr_state_list_len = 1;
740 curr_state_list[0] = 0;
741 continue;
742 }
743 for(j = 0; j < curr_state_list_len; j++){
744 state = curr_state_list[j];
745 for(k = 0; ambig[k]; k++){
746 g_assert(vfsm->index[(guchar)ambig[k]]);
747 next_state = VFSM_change_state_M(vfsm,
748 state, (guchar)ambig[k]);
749 /* FIXME: use POW2 versions where applicable */
750 if(next_state_list_len
751 && ((next_state == next_state_list[0])
752 || (next_state == next_state_list[next_state_list_len-1])))
753 break;
754 next_state_list[next_state_list_len++] = next_state;
755 if(VFSM_state_is_leaf(vfsm, next_state)){
756 leaf = VFSM_state2leaf(vfsm, next_state);
757 word_info = seeder->seeder_vfsm->leaf[leaf];
758 if(word_info)
759 Seeder_FSM_traverse_func(i, word_info, target_info);
760 }
761 }
762 }
763 curr_state_list_len = next_state_list_len;
764 next_state_list_len = 0;
765 Swap(next_state_list, curr_state_list, temp_state_list);
766 }
767 g_free(curr_state_list);
768 g_free(next_state_list);
769 return;
770 }
771
772 static void Seeder_VFSM_traverse(Seeder *seeder, gchar *seq,
773 Seeder_TargetInfo *target_info){
774 if(seeder->sas->word_ambiguity > 1)
775 Seeder_VFSM_traverse_ambig(seeder, seq, target_info);
776 else
777 Seeder_VFSM_traverse_single(seeder, seq, target_info);
778 return;
779 }
780
702781 static void Seeder_prepare(Seeder *seeder){
703782 g_assert(!seeder->is_prepared);
704783 if(seeder->seeder_fsm)
705784 FSM_compile(seeder->seeder_fsm->fsm);
706785 seeder->is_prepared = TRUE;
786 return;
787 }
788
789 static void Seeder_FSM_traverse_ambig(Seeder *seeder, gchar *seq,
790 FSM_Traverse_Func ftf, gpointer user_data){
791 register FSM *f = seeder->seeder_fsm->fsm;
792 register FSM_Node *n, *next_state;
793 register gint c;
794 register gchar *ambig;
795 register gint i, j, k;
796 register FSM_Node **temp_state_list,
797 **curr_state_list = g_new0(FSM_Node*,
798 seeder->sas->word_ambiguity),
799 **next_state_list = g_new0(FSM_Node*,
800 seeder->sas->word_ambiguity);
801 register gint curr_state_list_len = 1, next_state_list_len = 0;
802 g_assert(f->is_compiled);
803 curr_state_list[0] = f->root;
804 for(i = 0; seq[i]; i++){
805 if((!(ambig = Alphabet_nt2ambig(seq[i])))
806 || ((strlen(ambig) * curr_state_list_len)
807 > seeder->sas->word_ambiguity)){
808 next_state_list_len = 0;
809 curr_state_list_len = 1;
810 curr_state_list[0] = f->root;
811 continue;
812 }
813 for(j = 0; j < curr_state_list_len; j++){
814 n = curr_state_list[j];
815 for(k = 0; ambig[k]; k++){
816 c = f->traversal_filter[(guchar)ambig[k]];
817 if(n[c].data)
818 ftf(i, n[c].data, user_data);
819 next_state = n[c].next;
820 if(next_state_list_len
821 && ((next_state == next_state_list[0])
822 || (next_state ==
823 next_state_list[next_state_list_len-1]))){
824 break;
825 }
826 next_state_list[next_state_list_len++] = next_state;
827 }
828 }
829 curr_state_list_len = next_state_list_len;
830 next_state_list_len = 0;
831 /* g_message("set curr [%d]", curr_state_list_len); */
832 Swap(next_state_list, curr_state_list, temp_state_list);
833 }
834 g_free(curr_state_list);
835 g_free(next_state_list);
836 return;
837 }
838 /* Slow (ambiguous) version of FSM_traverse */
839 /* FIXME: optimisation: remove strlen() etc */
840
841 static void Seeder_FSM_traverse(Seeder *seeder, gchar *seq, FSM_Traverse_Func ftf,
842 gpointer user_data){
843 if(seeder->sas->word_ambiguity > 1)
844 Seeder_FSM_traverse_ambig(seeder, seq, ftf, user_data);
845 else
846 FSM_traverse(seeder->seeder_fsm->fsm, seq, ftf, user_data);
707847 return;
708848 }
709849
734874 seq = Sequence_get_str(target_masked);
735875 Sequence_destroy(target_masked);
736876 if(seeder->seeder_fsm)
737 FSM_traverse(seeder->seeder_fsm->fsm, seq,
738 Seeder_FSM_traverse_func, &target_info);
877 Seeder_FSM_traverse(seeder, seq,
878 Seeder_FSM_traverse_func, &target_info);
739879 else
740880 Seeder_VFSM_traverse(seeder, seq, &target_info);
741881 g_free(seq);
746886 seq = Sequence_get_str(target_masked);
747887 Sequence_destroy(target_masked);
748888 if(seeder->seeder_fsm){
749 FSM_traverse(seeder->seeder_fsm->fsm, seq,
750 Seeder_FSM_traverse_func, &target_info);
889 Seeder_FSM_traverse(seeder, seq,
890 Seeder_FSM_traverse_func, &target_info);
751891 } else {
752892 Seeder_VFSM_traverse(seeder, seq, &target_info);
753893 }
22 * Seeder : A module for seeding pairwise alignments *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
3131 gsize fsm_memory_limit;
3232 gchar *force_fsm;
3333 gint word_jump;
34 gint word_ambiguity;
3435 } Seeder_ArgumentSet;
3536
3637 Seeder_ArgumentSet *Seeder_ArgumentSet_create(Argument *arg);
22 * Seeder : A module for seeding pairwise alignments *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
22 * Library for word-neighbourhood generation *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
22 * Library for word-neighbourhood generation *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
22 * Library for word-neighbourhood generation *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
00
11 TESTS = fastadb.test fastapipe.test dataset.test index.test
2 # seqfmi.test
23 noinst_PROGRAMS = $(TESTS)
34
45 INCLUDES = -I$(top_srcdir)/src/sequence \
56 -I$(top_srcdir)/src/struct \
67 -I$(top_srcdir)/src/general \
7 -I$(top_srcdir)/src/comparison
8 -I$(top_srcdir)/src/comparison \
9 -DCUSTOM_GUINT64_FORMAT="\"@custom_guint64_format@\""
810
911 noinst_HEADERS = fastadb.h fastapipe.h dataset.h index.h
12 # seqfmi.h
1013
1114 SEQUENCE_OBJ = $(top_srcdir)/src/struct/sparsecache.o \
1215 $(top_srcdir)/src/struct/matrix.o \
3538 index_test_SOURCES = index.test.c index.c
3639 index_test_LDADD = fastadb.o dataset.o \
3740 $(top_srcdir)/src/general/compoundfile.o \
41 $(top_srcdir)/src/general/threadref.o \
3842 $(top_srcdir)/src/struct/bitarray.o \
3943 $(top_srcdir)/src/struct/vfsm.o \
4044 $(top_srcdir)/src/struct/pqueue.o \
4953 $(top_srcdir)/src/sequence/codonsubmat.o \
5054 $(SEQUENCE_OBJ)
5155
56 # seqfmi_test_SOURCES = seqfmi.test.c seqfmi.c
57 # seqfmi_test_LDADD = fastadb.o \
58 # $(top_srcdir)/src/general/compoundfile.o \
59 # $(top_srcdir)/src/struct/fmindex.o \
60 # $(top_srcdir)/src/struct/bitarray.o \
61 # $(top_srcdir)/src/struct/pqueue.o \
62 # $(top_srcdir)/src/struct/recyclebin.o \
63 # $(top_srcdir)/src/struct/huffman.o \
64 # $(SEQUENCE_OBJ)
65
5266 # Files to clear away
5367
5468 MAINTAINERCLEANFILES = Makefile.in
6969 VERSION = @VERSION@
7070 codegen_extra_ldadd = @codegen_extra_ldadd@
7171 codegen_extra_sources = @codegen_extra_sources@
72 custom_guint64_format = @custom_guint64_format@
7273 datarootdir = @datarootdir@
7374 glib_cflags = @glib_cflags@
7475 glib_libs = @glib_libs@
7879 use_pthreads = @use_pthreads@
7980
8081 TESTS = fastadb.test fastapipe.test dataset.test index.test
82 # seqfmi.test
8183 noinst_PROGRAMS = $(TESTS)
8284
83 INCLUDES = -I$(top_srcdir)/src/sequence -I$(top_srcdir)/src/struct -I$(top_srcdir)/src/general -I$(top_srcdir)/src/comparison
85 INCLUDES = -I$(top_srcdir)/src/sequence -I$(top_srcdir)/src/struct -I$(top_srcdir)/src/general -I$(top_srcdir)/src/comparison -DCUSTOM_GUINT64_FORMAT="\"@custom_guint64_format@\""
8486
8587
8688 noinst_HEADERS = fastadb.h fastapipe.h dataset.h index.h
89 # seqfmi.h
8790
8891 SEQUENCE_OBJ = $(top_srcdir)/src/struct/sparsecache.o $(top_srcdir)/src/struct/matrix.o $(top_srcdir)/src/sequence/sequence.o $(top_srcdir)/src/sequence/alphabet.o $(top_srcdir)/src/sequence/splice.o $(top_srcdir)/src/sequence/translate.o $(top_srcdir)/src/general/argument.o $(top_srcdir)/src/general/lineparse.o -lm
8992
100103
101104
102105 index_test_SOURCES = index.test.c index.c
103 index_test_LDADD = fastadb.o dataset.o $(top_srcdir)/src/general/compoundfile.o $(top_srcdir)/src/struct/bitarray.o $(top_srcdir)/src/struct/vfsm.o $(top_srcdir)/src/struct/pqueue.o $(top_srcdir)/src/struct/recyclebin.o $(top_srcdir)/src/struct/rangetree.o $(top_srcdir)/src/struct/splaytree.o $(top_srcdir)/src/struct/noitree.o $(top_srcdir)/src/comparison/wordhood.o $(top_srcdir)/src/comparison/hspset.o $(top_srcdir)/src/comparison/match.o $(top_srcdir)/src/sequence/submat.o $(top_srcdir)/src/sequence/codonsubmat.o $(SEQUENCE_OBJ)
104
106 index_test_LDADD = fastadb.o dataset.o $(top_srcdir)/src/general/compoundfile.o $(top_srcdir)/src/general/threadref.o $(top_srcdir)/src/struct/bitarray.o $(top_srcdir)/src/struct/vfsm.o $(top_srcdir)/src/struct/pqueue.o $(top_srcdir)/src/struct/recyclebin.o $(top_srcdir)/src/struct/rangetree.o $(top_srcdir)/src/struct/splaytree.o $(top_srcdir)/src/struct/noitree.o $(top_srcdir)/src/comparison/wordhood.o $(top_srcdir)/src/comparison/hspset.o $(top_srcdir)/src/comparison/match.o $(top_srcdir)/src/sequence/submat.o $(top_srcdir)/src/sequence/codonsubmat.o $(SEQUENCE_OBJ)
107
108
109 # seqfmi_test_SOURCES = seqfmi.test.c seqfmi.c
110 # seqfmi_test_LDADD = fastadb.o \
111 # $(top_srcdir)/src/general/compoundfile.o \
112 # $(top_srcdir)/src/struct/fmindex.o \
113 # $(top_srcdir)/src/struct/bitarray.o \
114 # $(top_srcdir)/src/struct/pqueue.o \
115 # $(top_srcdir)/src/struct/recyclebin.o \
116 # $(top_srcdir)/src/struct/huffman.o \
117 # $(SEQUENCE_OBJ)
105118
106119 # Files to clear away
107120
151164 index_test_OBJECTS = index.test.o index.o
152165 index_test_DEPENDENCIES = fastadb.o dataset.o \
153166 $(top_srcdir)/src/general/compoundfile.o \
167 $(top_srcdir)/src/general/threadref.o \
154168 $(top_srcdir)/src/struct/bitarray.o $(top_srcdir)/src/struct/vfsm.o \
155169 $(top_srcdir)/src/struct/pqueue.o $(top_srcdir)/src/struct/recyclebin.o \
156170 $(top_srcdir)/src/struct/rangetree.o \
22 * Library for manipulation of exonerate dataset files *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
2222 /**/
2323
2424 #define DATASET_HEADER_MAGIC (('e' << 16)|('s' << 8)|('d'))
25 #define DATASET_HEADER_VERSION 2
25 #define DATASET_HEADER_VERSION 3
2626
2727 static Dataset_Header *Dataset_Header_create(Alphabet_Type alphabet_type,
2828 gboolean softmask_input){
300300 + dataset_sequence_memory;
301301 }
302302
303 void Dataset_info(Dataset *dataset){
304 g_print("Sequence Dataset:\n"
305 "----------------\n"
306 " version: %d\n"
307 " type: %s, %s\n"
308 " total size: %d Mb\n"
309 " number of sequences: %lld\n"
310 " longest sequence: %lld\n\n",
311 (gint)dataset->header->version,
312 (dataset->header->type & 1)?"DNA":"PROTEIN",
313 (dataset->header->type & 2)?"masked":"unmasked",
314 (gint)(dataset->header->total_db_len >> 20),
315 dataset->header->number_of_seqs,
316 dataset->header->max_seq_len);
317 return;
318 }
319
303320 void Dataset_destroy(Dataset *dataset){
304321 register gint i;
305322 register Dataset_Sequence *seq;
377394 }
378395
379396 static void Dataset_read_seq_data(Dataset *dataset, FILE *fp){
380 register gint i, j = 0, ipos, dpos;
397 register gint64 i, j = 0, ipos, dpos;
381398 register Dataset_Sequence *ds;
382 register gint len = dataset->header->seq_info_offset
383 - dataset->header->seq_data_offset;
399 register guint64 len = dataset->header->seq_info_offset
400 - dataset->header->seq_data_offset;
384401 register gchar *buf = g_new(gchar, len+1);
385402 if(!fread(buf, sizeof(gchar), len, fp))
386403 g_error("Problem reading seq data");
22 * Library for manipulation of exonerate dataset files *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
9696 gboolean softmask_input);
9797 Dataset *Dataset_share(Dataset *dataset);
9898 void Dataset_destroy(Dataset *dataset);
99 void Dataset_info(Dataset *dataset);
99100 gsize Dataset_memory_usage(Dataset *dataset);
100101 gboolean Dataset_check_filetype(gchar *path);
101102 /* Returns TRUE when magic number is correct for this filetype */
22 * Library for manipulation of FASTA format databases *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
22 * Library for manipulation of FASTA format databases *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
201201 return fdb;
202202 }
203203
204 FastaDB *FastaDB_dup(FastaDB *fdb){
205 register FastaDB *nfdb = g_new(FastaDB, 1);
206 nfdb->ref_count = 1;
207 nfdb->alphabet = Alphabet_create(fdb->alphabet->type,
208 fdb->alphabet->is_soft_masked);
209 nfdb->cf = CompoundFile_dup(fdb->cf);
210 nfdb->out_buffer_alloc = FASTADB_OUT_BUFFER_CHUNK_SIZE;
211 nfdb->out_buffer = g_malloc(sizeof(gchar)*nfdb->out_buffer_alloc);
212 nfdb->line_length = -1;
213 FastaDB_rewind(nfdb);
214 return nfdb;
215 }
216
204217 void FastaDB_close(FastaDB *fdb){
205218 g_assert(fdb);
206219 if(--fdb->ref_count)
236249 }
237250 return CompoundFile_ftell(fdb->cf)-1;
238251 }
252
253 gboolean FastaDB_file_is_fasta(gchar *path){
254 register FILE *fp = fopen(path, "r");
255 register gint ch;
256 register gboolean result = FALSE;
257 if(!fp)
258 g_error("Could not open file [%s]", path);
259 while(((ch = getc(fp)) != EOF)){
260 if(isspace(ch))
261 continue;
262 else
263 if(ch == '>'){ /* Assume is fasta format */
264 result = TRUE;
265 break;
266 }
267 else
268 break;
269 }
270 fclose(fp);
271 return result;
272 }
273 /* Assumes a file is fasta format
274 * if the first non-whitespace character is '>'
275 */
239276
240277 gboolean FastaDB_is_finished(FastaDB *fdb){
241278 g_assert(fdb);
22 * Library for manipulation of FASTA format databases *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
7272 Alphabet *alphabet, gint chunk_id, gint chunk_total);
7373 FastaDB *FastaDB_open(gchar *path, Alphabet *alphabet);
7474 FastaDB *FastaDB_share(FastaDB *fdb);
75 FastaDB *FastaDB_dup(FastaDB *fdb); /* For use in a separate thread */
7576 void FastaDB_close(FastaDB *fdb);
7677 void FastaDB_rewind(FastaDB *fdb);
7778 gboolean FastaDB_is_finished(FastaDB *fdb);
8283 FastaDB_Seq *FastaDB_next(FastaDB *fdb, FastaDB_Mask mask);
8384 CompoundFile_Pos FastaDB_find_next_start(FastaDB *fdb,
8485 CompoundFile_Pos pos);
86
87 gboolean FastaDB_file_is_fasta(gchar *path);
88 /* Returns true if first non-whitespace character in file is '>' */
8589
8690 typedef struct {
8791 FastaDB *source;
22 * Library for manipulation of FASTA format databases *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
22 * Library for All-vs-All Fasta Database Comparisons *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
2020 FastaPipe_Boundary_Func term_func,
2121 FastaPipe_NextSeq_Func query_func,
2222 FastaPipe_NextSeq_Func target_func,
23 FastaDB_Mask mask, gboolean translate_both){
23 FastaDB_Mask mask, gboolean translate_both,
24 gboolean use_revcomp){
2425 register FastaPipe *fasta_pipe = g_new(FastaPipe, 1);
2526 g_assert(init_func);
2627 g_assert(prep_func);
3637 fasta_pipe->target_func = target_func;
3738 fasta_pipe->mask = mask;
3839 fasta_pipe->is_full = FALSE;
39 fasta_pipe->revcomp_query
40 = (query_fdb->alphabet->type == Alphabet_Type_DNA);
41 fasta_pipe->revcomp_target
42 = (((query_fdb->alphabet->type == Alphabet_Type_PROTEIN)
43 && (target_fdb->alphabet->type == Alphabet_Type_DNA))
44 || translate_both);
40 if(use_revcomp){
41 fasta_pipe->revcomp_query
42 = (query_fdb->alphabet->type == Alphabet_Type_DNA);
43 fasta_pipe->revcomp_target
44 = (((query_fdb->alphabet->type == Alphabet_Type_PROTEIN)
45 && (target_fdb->alphabet->type == Alphabet_Type_DNA))
46 || translate_both);
47 } else {
48 fasta_pipe->revcomp_query = FALSE;
49 fasta_pipe->revcomp_target = FALSE;
50 }
4551 fasta_pipe->prev_query = NULL;
4652 fasta_pipe->prev_target = NULL;
4753 return fasta_pipe;
22 * Library for All-vs-All Fasta Database Comparisons *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
4949 FastaPipe_Boundary_Func term_func,
5050 FastaPipe_NextSeq_Func query_func,
5151 FastaPipe_NextSeq_Func target_func,
52 FastaDB_Mask mask, gboolean translate_both);
52 FastaDB_Mask mask, gboolean translate_both,
53 gboolean use_revcomp);
5354 /* query_func can return TRUE to finish loading current pipeline
5455 * target_func can return TRUE to finish processing of the pipeline
5556 */
22 * Library for All-vs-All Fasta Database Comparisons *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
6767 fasta_pipe = FastaPipe_create(query_fdb, target_fdb,
6868 test_init_func, test_prep_func, test_term_func,
6969 test_query_func, test_target_func, FastaDB_Mask_ALL,
70 FALSE);
70 FALSE, TRUE);
7171 Alphabet_destroy(alphabet);
7272 while(FastaPipe_process(fasta_pipe, &count)){
7373 g_message("Processing pipeline");
22 * Library for manipulation of exonerate index files *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
2525 #include "noitree.h"
2626
2727 #define INDEX_HEADER_MAGIC (('e' << 16)|('s' << 8)|('i'))
28 #define INDEX_HEADER_VERSION 2
28 #define INDEX_HEADER_VERSION 3
2929
3030 static off_t Index_ftell(FILE *fp){
3131 return ftello(fp);
3737 static off_t Index_fseek(FILE *fp, off_t offset, int whence){
3838 return fseeko(fp, offset, whence);
3939 }
40 /* FIXME: need alternatives in absence of ftello()
40 /* FIXME: need alternatives in absence of fseeko()
4141 * lseek(fileno(fp), offset, whence); ??
4242 */
4343
7777
7878 static Index_Header *Index_Header_create(gint dataset_path_len,
7979 gboolean is_translated,
80 gint word_length, gint word_jump,
80 gint word_length,
81 gint word_jump,
82 gint word_ambiguity,
8183 gint saturate_threshold){
8284 register Index_Header *index_header = g_new0(Index_Header, 1);
8385 index_header->magic = INDEX_HEADER_MAGIC;
8789 /**/
8890 index_header->word_length = word_length;
8991 index_header->word_jump = word_jump;
92 index_header->word_ambiguity = word_ambiguity;
9093 index_header->saturate_threshold = saturate_threshold;
9194 return index_header;
9295 }
99102 #if 0
100103 static void Index_Header_info(Index_Header *index_header){
101104 g_message("Index_Header:\n"
102 " magic [%d]\n"
103 " version [%d]\n"
104 " type [%d]\n"
105 " dataset_path_len [%d]\n"
105 " magic [%lld]\n"
106 " version [%lld]\n"
107 " type [%lld]\n"
108 " dataset_path_len [%lld]\n"
106109 "\n"
107 " word_length [%d]\n"
108 " word_jump [%d]\n"
109 " saturate_threshold [%d]\n",
110 (gint)index_header->magic,
111 (gint)index_header->version,
112 (gint)index_header->type,
113 (gint)index_header->dataset_path_len,
114 (gint)index_header->word_length,
115 (gint)index_header->word_jump,
116 (gint)index_header->saturate_threshold);
110 " word_length [%lld]\n"
111 " word_jump [%lld]\n"
112 " word_ambiguity [%lld]\n"
113 " saturate_threshold [%lld]\n",
114 index_header->magic,
115 index_header->version,
116 index_header->type,
117 index_header->dataset_path_len,
118 index_header->word_length,
119 index_header->word_jump,
120 index_header->word_ambiguity,
121 index_header->saturate_threshold);
117122 return;
118123 }
119124 #endif /* 0 */
127132 /**/
128133 BitArray_write_int(index_header->word_length, fp);
129134 BitArray_write_int(index_header->word_jump, fp);
135 BitArray_write_int(index_header->word_ambiguity, fp);
130136 BitArray_write_int(index_header->saturate_threshold, fp);
131137 /**/
132138 return;
145151 /**/
146152 index_header->word_length = BitArray_read_int(fp);
147153 index_header->word_jump = BitArray_read_int(fp);
154 index_header->word_ambiguity = BitArray_read_int(fp);
148155 index_header->saturate_threshold = BitArray_read_int(fp);
149156 /* Index_Header_info(index_header); */
150157 return index_header;
185192 gint seq_pos, gint leaf_id,
186193 gpointer user_data);
187194
188 static void Index_visit_seq_words(Index *index, Index_Strand *index_strand,
195 static void Index_visit_seq_words_single(Index *index, Index_Strand *index_strand,
189196 gint seq_id, Sequence *seq,
190197 Index_WordVisit_Func iwvf, gint frame,
191198 gpointer user_data){
210217 }
211218 }
212219 g_free(str);
220 return;
221 }
222 /* FIXME: needs to work with softmasked sequences */
223
224 #ifndef Swap
225 #define Swap(x,y,temp) ((temp)=(x),(x)=(y),(y)=(temp))
226 #endif /* Swap */
227
228 static void Index_visit_seq_words_ambig(Index *index, Index_Strand *index_strand,
229 gint seq_id, Sequence *seq,
230 Index_WordVisit_Func iwvf, gint frame,
231 gpointer user_data){
232 register gint i, j, k, jump_ctr = 0, pos;
233 register gchar *ambig, *str = Sequence_get_str(seq);
234 register VFSM_Int state, next_state, leaf;
235 register VFSM_Int *temp_state_list,
236 *curr_state_list = g_new0(VFSM_Int,
237 index->header->word_ambiguity),
238 *next_state_list = g_new0(VFSM_Int,
239 index->header->word_ambiguity);
240 register gint curr_state_list_len = 1, next_state_list_len = 0;
241 for(i = 0; str[i]; i++){
242 if(jump_ctr--)
243 continue;
244 jump_ctr = index->header->word_jump - 1;
245 if((!(ambig = Alphabet_nt2ambig(str[i])))
246 || ((strlen(ambig) * curr_state_list_len)
247 > index->header->word_ambiguity)){
248 next_state_list_len = 0; /* Clear next state list */
249 curr_state_list_len = 1; /* Set single null state */
250 curr_state_list[0] = 0;
251 continue;
252 }
253 for(j = 0; j < curr_state_list_len; j++){
254 state = curr_state_list[j];
255 for(k = 0; ambig[k]; k++){
256 g_assert(index->vfsm->index[(guchar)ambig[k]]);
257 next_state = VFSM_change_state_M(index->vfsm,
258 state, (guchar)ambig[k]);
259 if(next_state_list_len
260 && ((next_state == next_state_list[0])
261 || (next_state == next_state_list[next_state_list_len-1])))
262 break;
263 next_state_list[next_state_list_len++] = next_state;
264 if(VFSM_state_is_leaf(index->vfsm, next_state)){
265 leaf = VFSM_state2leaf(index->vfsm, next_state);
266 pos = i-(index->vfsm->depth-1);
267 if(frame)
268 pos = (pos * 3) + frame - 1;
269 iwvf(index, index_strand, seq_id, pos, leaf, user_data);
270 }
271 }
272 }
273 curr_state_list_len = next_state_list_len;
274 next_state_list_len = 0;
275 Swap(next_state_list, curr_state_list, temp_state_list);
276 }
277 g_free(str);
278 g_free(curr_state_list);
279 g_free(next_state_list);
280 return;
281 }
282 /* FIXME: needs to work with softmasked sequences */
283 /* FIXME: optimisation: remove strlen() call */
284
285 static void Index_visit_seq_words(Index *index, Index_Strand *index_strand,
286 gint seq_id, Sequence *seq,
287 Index_WordVisit_Func iwvf, gint frame,
288 gpointer user_data){
289 if(index->header->word_ambiguity > 1)
290 Index_visit_seq_words_ambig(index, index_strand, seq_id, seq,
291 iwvf, frame, user_data);
292 else
293 Index_visit_seq_words_single(index, index_strand, seq_id, seq,
294 iwvf, frame, user_data);
213295 return;
214296 }
215297 /* FIXME: needs to work with softmasked sequences */
291373 removed_instances += index_strand->word_table[i];
292374 index_strand->word_table[i] = -1;
293375 }
294 g_message("Removed [%lld] words, [%lld] instances",
376 g_message("Removed [%" CUSTOM_GUINT64_FORMAT
377 "] words, [%" CUSTOM_GUINT64_FORMAT "] instances",
295378 removed_words, removed_instances);
296379 return;
297380 }
662745 return;
663746 }
664747
665 Index *Index_create(Dataset *dataset, gboolean is_translated,
666 gint word_length, gint word_jump, gint saturate_threshold,
748 Index *Index_create(Dataset *dataset, gboolean is_translated, gint word_length,
749 gint word_jump, gint word_ambiguity, gint saturate_threshold,
667750 gchar *index_path, gchar *dataset_path, gint memory_limit){
668751 register Index *index = g_new0(Index, 1);
669752 register gchar *member;
683766 index->dataset = Dataset_share(dataset);
684767 index->header = Index_Header_create(strlen(dataset_path),
685768 is_translated, word_length,
686 word_jump, saturate_threshold);
769 word_jump, word_ambiguity,
770 saturate_threshold);
687771 if(is_translated){
688772 alphabet = Alphabet_create(Alphabet_Type_PROTEIN, FALSE);
689773 member = (gchar*)alphabet->member;
777861 pthread_mutex_destroy(&index->index_mutex);
778862 #endif /* USE_PTHREADS */
779863 g_free(index);
864 return;
865 }
866
867 void Index_info(Index *index){
868 g_print("Sequence Index:\n"
869 "--------------\n"
870 " version: %d\n"
871 " type: %s\n"
872 " word length: %d\n"
873 " word jump: %d\n"
874 " word ambiguity: %d\n"
875 " saturate threshold: %d\n\n",
876 (gint)index->header->version,
877 (index->header->type & 1) ? "translated" : "normal",
878 (gint)index->header->word_length,
879 (gint)index->header->word_jump,
880 (gint)index->header->word_ambiguity,
881 (gint)index->header->saturate_threshold);
780882 return;
781883 }
782884
22 * Library for manipulation of exonerate index files *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
5959 /**/
6060 guint64 word_length;
6161 guint64 word_jump;
62 guint64 word_ambiguity;
6263 guint64 saturate_threshold;
6364 } Index_Header;
6465
116117
117118 /**/
118119
119 Index *Index_create(Dataset *dataset, gboolean is_translated,
120 gint word_length, gint word_jump, gint saturate_threshold,
120 Index *Index_create(Dataset *dataset, gboolean is_translated, gint word_length,
121 gint word_jump, gint word_ambiguity, gint saturate_threshold,
121122 gchar *index_path, gchar *dataset_path, gint memory_limit);
122123 Index *Index_share(Index *index);
123124 void Index_destroy(Index *index);
125 void Index_info(Index *index);
124126 Index *Index_open(gchar *path);
125127 guint64 Index_memory_usage(Index *index);
126128 void Index_preload_index(Index *index);
149151 }
150152 #endif /* __cplusplus */
151153
152 #endif /* INCLUDED_DATASET_H */
154 #endif /* INCLUDED_INDEX_H */
153155
22 * Library for manipulation of FASTA format databases *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
00
1 TESTS = argument.test lineparse.test compoundfile.test socket.test
1 TESTS = argument.test lineparse.test compoundfile.test socket.test \
2 jobqueue.test threadref.test
23 noinst_PROGRAMS = $(TESTS)
34
4 noinst_HEADERS = argument.h lineparse.h compoundfile.h socket.h
5 noinst_HEADERS = argument.h lineparse.h compoundfile.h socket.h \
6 jobqueue.h threadref.h
57
6 INCLUDES = -DSOURCE_ROOT_DIR="\"@source_root_dir@\""
8 INCLUDES = -DSOURCE_ROOT_DIR="\"@source_root_dir@\"" \
9 -DCUSTOM_GUINT64_FORMAT="\"@custom_guint64_format@\"" \
10 -I$(top_srcdir)/src/struct
711
812 argument_test_SOURCES = argument.test.c argument.c
913 lineparse_test_SOURCES = lineparse.test.c lineparse.c
1014 compoundfile_test_SOURCES = compoundfile.test.c compoundfile.c
1115 socket_test_SOURCES = socket.test.c socket.c
16 jobqueue_test_SOURCES = jobqueue.test.c jobqueue.c
17 jobqueue_test_LDADD = $(top_srcdir)/src/struct/pqueue.o \
18 $(top_srcdir)/src/struct/recyclebin.o
19 threadref_test_SOURCES = threadref.test.c threadref.c
20 threadref_test_LDADD = -lpthread
1221
1322 # Files to clear away
1423
6969 VERSION = @VERSION@
7070 codegen_extra_ldadd = @codegen_extra_ldadd@
7171 codegen_extra_sources = @codegen_extra_sources@
72 custom_guint64_format = @custom_guint64_format@
7273 datarootdir = @datarootdir@
7374 glib_cflags = @glib_cflags@
7475 glib_libs = @glib_libs@
7778 source_root_dir = @source_root_dir@
7879 use_pthreads = @use_pthreads@
7980
80 TESTS = argument.test lineparse.test compoundfile.test socket.test
81 TESTS = argument.test lineparse.test compoundfile.test socket.test jobqueue.test threadref.test
82
8183 noinst_PROGRAMS = $(TESTS)
8284
83 noinst_HEADERS = argument.h lineparse.h compoundfile.h socket.h
84
85 INCLUDES = -DSOURCE_ROOT_DIR="\"@source_root_dir@\""
85 noinst_HEADERS = argument.h lineparse.h compoundfile.h socket.h jobqueue.h threadref.h
86
87
88 INCLUDES = -DSOURCE_ROOT_DIR="\"@source_root_dir@\"" -DCUSTOM_GUINT64_FORMAT="\"@custom_guint64_format@\"" -I$(top_srcdir)/src/struct
89
8690
8791 argument_test_SOURCES = argument.test.c argument.c
8892 lineparse_test_SOURCES = lineparse.test.c lineparse.c
8993 compoundfile_test_SOURCES = compoundfile.test.c compoundfile.c
9094 socket_test_SOURCES = socket.test.c socket.c
95 jobqueue_test_SOURCES = jobqueue.test.c jobqueue.c
96 jobqueue_test_LDADD = $(top_srcdir)/src/struct/pqueue.o $(top_srcdir)/src/struct/recyclebin.o
97
98 threadref_test_SOURCES = threadref.test.c threadref.c
99 threadref_test_LDADD = -lpthread
91100
92101 # Files to clear away
93102
117126 socket_test_LDADD = $(LDADD)
118127 socket_test_DEPENDENCIES =
119128 socket_test_LDFLAGS =
129 jobqueue_test_OBJECTS = jobqueue.test.o jobqueue.o
130 jobqueue_test_DEPENDENCIES = $(top_srcdir)/src/struct/pqueue.o \
131 $(top_srcdir)/src/struct/recyclebin.o
132 jobqueue_test_LDFLAGS =
133 threadref_test_OBJECTS = threadref.test.o threadref.o
134 threadref_test_DEPENDENCIES =
135 threadref_test_LDFLAGS =
120136 CFLAGS = @CFLAGS@
121137 COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
122138 CCLD = $(CC)
130146
131147 TAR = tar
132148 GZIP_ENV = --best
133 SOURCES = $(argument_test_SOURCES) $(lineparse_test_SOURCES) $(compoundfile_test_SOURCES) $(socket_test_SOURCES)
134 OBJECTS = $(argument_test_OBJECTS) $(lineparse_test_OBJECTS) $(compoundfile_test_OBJECTS) $(socket_test_OBJECTS)
149 SOURCES = $(argument_test_SOURCES) $(lineparse_test_SOURCES) $(compoundfile_test_SOURCES) $(socket_test_SOURCES) $(jobqueue_test_SOURCES) $(threadref_test_SOURCES)
150 OBJECTS = $(argument_test_OBJECTS) $(lineparse_test_OBJECTS) $(compoundfile_test_OBJECTS) $(socket_test_OBJECTS) $(jobqueue_test_OBJECTS) $(threadref_test_OBJECTS)
135151
136152 all: all-redirect
137153 .SUFFIXES:
187203 socket.test: $(socket_test_OBJECTS) $(socket_test_DEPENDENCIES)
188204 @rm -f socket.test
189205 $(LINK) $(socket_test_LDFLAGS) $(socket_test_OBJECTS) $(socket_test_LDADD) $(LIBS)
206
207 jobqueue.test: $(jobqueue_test_OBJECTS) $(jobqueue_test_DEPENDENCIES)
208 @rm -f jobqueue.test
209 $(LINK) $(jobqueue_test_LDFLAGS) $(jobqueue_test_OBJECTS) $(jobqueue_test_LDADD) $(LIBS)
210
211 threadref.test: $(threadref_test_OBJECTS) $(threadref_test_DEPENDENCIES)
212 @rm -f threadref.test
213 $(LINK) $(threadref_test_LDFLAGS) $(threadref_test_OBJECTS) $(threadref_test_LDADD) $(LIBS)
190214
191215 tags: TAGS
192216
22 * Library for command line argument processing *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
172172 g_print("Built on %s\n", __DATE__);
173173 if(strlen(branch) >= 10)
174174 g_print("Branch: %.*s\n", (gint)(strlen(branch)-9), branch+7);
175 else
176 g_print("Branch: unnamed branch\n");
177175 return;
178176 }
179177
301299 */
302300
303301 int main(int argc, char **argv){
304 register Argument *arg = Argument_create(argc, argv);
302 register Argument *arg;
305303 register gint retval;
304 #ifdef USE_PTHREADS
305 if(!g_thread_supported())
306 g_thread_init(NULL);
307 #endif /* USE_PTHREADS */
308 arg = Argument_create(argc, argv);
306309 g_log_set_handler(NULL, G_LOG_LEVEL_ERROR|G_LOG_FLAG_FATAL,
307310 Argument_error_handler, arg);
308311 g_assert(Argument_assertion_warning());
22 * Library for command line argument processing *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
22 * Library for command line argument processing *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
22 * Library for reading large and/or split files. *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
157157 CompoundFile *CompoundFile_share(CompoundFile *cf){
158158 cf->ref_count++;
159159 return cf;
160 }
161
162 static GPtrArray *CompoundFile_get_path_list(CompoundFile *cf){
163 register gint i;
164 register gchar *path;
165 register GPtrArray *path_list = g_ptr_array_new();
166 register CompoundFile_Element *element;
167 for(i = 0; i < cf->element_list->len; i++){
168 element = cf->element_list->pdata[i];
169 path = g_strdup(element->path);
170 g_ptr_array_add(path_list, path);
171 }
172 return path_list;
173 }
174
175 CompoundFile *CompoundFile_dup(CompoundFile *cf){
176 register CompoundFile *ncf;
177 register CompoundFile_Location *nstart = NULL, *nstop = NULL;
178 register gint i;
179 register gchar *path;
180 register GPtrArray *path_list = CompoundFile_get_path_list(cf);
181 g_assert(path_list);
182 ncf = CompoundFile_create(path_list, FALSE);
183 if(cf->start_limit)
184 nstart = CompoundFile_Location_create(ncf,
185 cf->start_limit->pos,
186 cf->start_limit->element_id);
187 if(cf->stop_limit)
188 nstop = CompoundFile_Location_create(ncf,
189 cf->stop_limit->pos,
190 cf->stop_limit->element_id);
191 CompoundFile_set_limits(ncf, nstart, nstop);
192 if(nstart)
193 CompoundFile_Location_destroy(nstart);
194 if(nstop)
195 CompoundFile_Location_destroy(nstop);
196 for(i = 0; i < path_list->len; i++){
197 path = path_list->pdata[i];
198 g_free(path);
199 }
200 g_ptr_array_free(path_list, TRUE);
201 return ncf;
160202 }
161203
162204 gchar *CompoundFile_current_path(CompoundFile *cf){
343385 CompoundFile_Location_destroy(cf->start_limit);
344386 if(cf->stop_limit)
345387 CompoundFile_Location_destroy(cf->stop_limit);
346 cf->start_limit = CompoundFile_Location_share(start);
347 cf->stop_limit = CompoundFile_Location_share(stop);
388 if(start)
389 cf->start_limit = CompoundFile_Location_share(start);
390 if(stop)
391 cf->stop_limit = CompoundFile_Location_share(stop);
348392 CompoundFile_rewind(cf);
349393 return;
350394 }
22 * Library for reading large and/or split files. *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
2424
2525 #include <sys/types.h> /* For lseek() and off_t */
2626 #include <unistd.h> /* For lseek() and off_t */
27 #include <inttypes.h> /* For PRIuPTR */
2728
2829 #ifdef USE_PTHREADS
2930 #include <pthread.h>
4445
4546 typedef off_t CompoundFile_Pos;
4647
47 #if _FILE_OFFSET_BITS==64
48 #define CompoundFile_Pos_format "%lld"
49 #else /* Assume _FILE_OFFSET_BITS==32 */
50 #define CompoundFile_Pos_format "%ld"
51 #endif /* _FILE_OFFSET_BITS */
52
48 #if __STDC_VERSION__ >= 199901L
5349 #define CompoundFile_Pos_print(fp, pos) \
54 CompoundFile_Pragma fprintf((fp), CompoundFile_Pos_format, (pos))
50 CompoundFile_Pragma fprintf((fp), "%jd", (intmax_t)(pos))
51 typedef intmax_t CompoundFile_Pos_scan_type;
5552 #define CompoundFile_Pos_scan(src, dst) \
56 CompoundFile_Pragma sscanf((src), CompoundFile_Pos_format, (dst))
53 CompoundFile_Pragma sscanf((src), "%jd", (intmax_t*)(dst))
54 #else /* __STDC_VERSION__ */
55 #define CompoundFile_Pos_print(fp, pos) \
56 CompoundFile_Pragma fprintf((fp), "%lld", (long long int)(pos))
57 typedef long long int CompoundFile_Pos_scan_type;
58 #define CompoundFile_Pos_scan(src, dst) \
59 CompoundFile_Pragma sscanf((src), "%lld", (dst))
60 #endif /* __STDC_VERSION__ */
5761
5862 typedef struct {
5963 gchar *path;
8084 gboolean sort_on_file_size);
8185 void CompoundFile_destroy(CompoundFile *cf);
8286 CompoundFile *CompoundFile_share(CompoundFile *cf);
87 CompoundFile *CompoundFile_dup(CompoundFile *cf);
8388 gchar *CompoundFile_current_path(CompoundFile *cf);
8489
8590 #define CompoundFile_buffer_is_empty(cf) \
22 * Library for reading large and/or split files *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
0 /****************************************************************\
1 * *
2 * Library for Queueing Multi-Threaded Jobs *
3 * *
4 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
6 * *
7 * This source code is distributed under the terms of the *
8 * GNU General Public License, version 3. See the file COPYING *
9 * or http://www.gnu.org/licenses/gpl.txt for details *
10 * *
11 * If you use this code, please keep this notice intact. *
12 * *
13 \****************************************************************/
14
15 #include "jobqueue.h"
16 #include <unistd.h> /* For usleep() */
17
18 #ifdef USE_PTHREADS
19 static JobQueue_Task *JobQueue_Task_create(JobQueue_Func job_func,
20 gpointer job_data, gint priority){
21 register JobQueue_Task *task = g_new(JobQueue_Task, 1);
22 task->job_func = job_func;
23 task->job_data = job_data;
24 task->priority = priority;
25 return task;
26 }
27
28 static void JobQueue_Task_destroy(JobQueue_Task *task){
29 g_free(task);
30 return;
31 }
32
33 static void *JobQueue_thread_func(void *data){
34 register JobQueue *jq = data;
35 register JobQueue_Task *task;
36 do {
37 pthread_mutex_lock(&jq->queue_lock);
38 task = PQueue_pop(jq->pq);
39 if(task){
40 jq->running_count++;
41 pthread_mutex_unlock(&jq->queue_lock);
42 task->job_func(task->job_data);
43 JobQueue_Task_destroy(task);
44 pthread_mutex_lock(&jq->queue_lock);
45 jq->running_count--;
46 pthread_mutex_unlock(&jq->queue_lock);
47 } else {
48 pthread_mutex_unlock(&jq->queue_lock);
49 usleep(1000); /* wait before checking job queue again */
50 }
51 } while(!jq->is_complete);
52 return NULL;
53 }
54
55 static gboolean JobQueue_Task_compare(gpointer low, gpointer high,
56 gpointer user_data){
57 register JobQueue_Task *low_task = (JobQueue_Task*)low,
58 *high_task = (JobQueue_Task*)high;
59 return low_task->priority < high_task->priority;
60 }
61 #endif /* USE_PTHREADS */
62
63 JobQueue *JobQueue_create(gint thread_total){
64 register JobQueue *jq = g_new(JobQueue, 1);
65 #ifdef USE_PTHREADS
66 register gint i;
67 jq->is_complete = FALSE;
68 jq->thread_total = thread_total;
69 jq->running_count = 0;
70 pthread_mutex_init(&jq->queue_lock, NULL);
71 jq->thread = g_new0(pthread_t, thread_total);
72 jq->pq_set = PQueueSet_create();
73 jq->pq = PQueue_create(jq->pq_set, JobQueue_Task_compare, NULL);
74 for(i = 0; i < thread_total; i++)
75 pthread_create(&jq->thread[i], NULL, JobQueue_thread_func, jq);
76 #endif /* USE_PTHREADS */
77 return jq;
78 }
79
80 static void JobQueue_Task_free_func(gpointer data, gpointer user_data){
81 register JobQueue_Task *task = data;
82 JobQueue_Task_destroy(task);
83 return;
84 }
85
86 void JobQueue_destroy(JobQueue *jq){
87 #ifdef USE_PTHREADS
88 g_assert(!PQueue_total(jq->pq));
89 PQueue_destroy(jq->pq, JobQueue_Task_free_func, NULL);
90 PQueueSet_destroy(jq->pq_set);
91 pthread_mutex_destroy(&jq->queue_lock);
92 g_free(jq->thread);
93 #endif /* USE_PTHREADS */
94 g_free(jq);
95 return;
96 }
97
98 void JobQueue_submit(JobQueue *jq, JobQueue_Func job_func,
99 gpointer job_data, gint priority){
100 #ifdef USE_PTHREADS
101 register JobQueue_Task *task;
102 g_assert(jq);
103 pthread_mutex_lock(&jq->queue_lock);
104 task = JobQueue_Task_create(job_func, job_data, priority);
105 PQueue_push(jq->pq, task);
106 pthread_mutex_unlock(&jq->queue_lock);
107 #else /* USE_PTHREADS */
108 jq->job_func(job_data); /* when no threads available, just run the job */
109 #endif /* USE_PTHREADS */
110 return;
111 }
112 /* waits until less than (thread_total * 2) jobs are queued
113 */
114
115 void JobQueue_complete(JobQueue *jq){
116 #ifdef USE_PTHREADS
117 register gint i, job_total;
118 do { /* wait for job queue to empty */
119 pthread_mutex_lock(&jq->queue_lock);
120 job_total = PQueue_total(jq->pq) + jq->running_count;
121 pthread_mutex_unlock(&jq->queue_lock);
122 usleep(1000); /* wait before checking if queue is empty again */
123 } while(job_total);
124 jq->is_complete = TRUE;
125 /* wait for threads to finish */
126 for(i = 0; i < jq->thread_total; i++)
127 pthread_join(jq->thread[i], NULL);
128 #endif /* USE_PTHREADS */
129 return;
130 }
131 /* waits until the queue is empty and no jobs are running,
132 * to catch any jobs which are added to the queue by runnning jobs
133 */
134
135 /**/
136
0 /****************************************************************\
1 * *
2 * Library for Queueing Multi-Threaded Jobs *
3 * *
4 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
6 * *
7 * This source code is distributed under the terms of the *
8 * GNU General Public License, version 3. See the file COPYING *
9 * or http://www.gnu.org/licenses/gpl.txt for details *
10 * *
11 * If you use this code, please keep this notice intact. *
12 * *
13 \****************************************************************/
14
15 #ifndef INCLUDED_JOBQUEUE_H
16 #define INCLUDED_JOBQUEUE_H
17
18 #ifdef __cplusplus
19 extern "C" {
20 #endif /* __cplusplus */
21
22 #include <glib.h>
23
24 #ifdef USE_PTHREADS
25 #include <pthread.h>
26 #endif /* USE_PTHREADS */
27
28 #include "pqueue.h"
29
30 typedef void (*JobQueue_Func)(gpointer job_data);
31
32 typedef struct JobQueue_Task {
33 JobQueue_Func job_func;
34 gpointer job_data;
35 gint priority;
36 } JobQueue_Task;
37
38 typedef struct {
39 #ifdef USE_PTHREADS
40 gboolean is_complete;
41 gint thread_total;
42 gint running_count;
43 pthread_mutex_t queue_lock;
44 pthread_t *thread;
45 PQueue *pq;
46 PQueueSet *pq_set;
47 #endif /* USE_PTHREADS */
48 } JobQueue;
49
50 JobQueue *JobQueue_create(gint thread_total);
51 void JobQueue_destroy(JobQueue *jq);
52 void JobQueue_submit(JobQueue *jq, JobQueue_Func job_func,
53 gpointer job_data, gint priority);
54 void JobQueue_complete(JobQueue *jq);
55
56 /* Lower priority jobs are run first */
57
58 #ifdef __cplusplus
59 }
60 #endif /* __cplusplus */
61
62 #endif /* INCLUDED_JOBQUEUE_H */
63
64
65 /**/
66
0 /****************************************************************\
1 * *
2 * Library for Queueing Multi-Threaded Jobs *
3 * *
4 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
6 * *
7 * This source code is distributed under the terms of the *
8 * GNU General Public License, version 3. See the file COPYING *
9 * or http://www.gnu.org/licenses/gpl.txt for details *
10 * *
11 * If you use this code, please keep this notice intact. *
12 * *
13 \****************************************************************/
14
15 #include <unistd.h> /* For usleep() */
16 #include "jobqueue.h"
17
18 static void test_run_func(gpointer job_data){
19 register gchar *name = job_data;
20 g_message("running job [%s]", name);
21 usleep(1000000); /* test job length */
22 return;
23 }
24
25 int main(void){
26 register gint i;
27 register JobQueue *jq = JobQueue_create(2);
28 gchar *test_str[10] = {"one", "two", "three", "four", "five",
29 "six", "seven", "eight", "nine", "ten"};
30
31 /* Initialise threads as not using Argument library */
32 #ifdef USE_PTHREADS
33 if(!g_thread_supported())
34 g_thread_init(NULL);
35 #endif /* USE_PTHREADS */
36
37 for(i = 0; i < 10; i++)
38 JobQueue_submit(jq, test_run_func, test_str[i], 0);
39 JobQueue_complete(jq);
40 JobQueue_destroy(jq);
41 return 0;
42 }
43
22 * Library for basic line-by-line parsing of text files. *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
22 * Library for basic line-by-line parsing of text files. *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
22 * Library for basic line-by-line parsing of text files. *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
22 * Simple client-server code library *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
5555 struct sockaddr_in server;
5656 struct hostent *hp = gethostbyname(host);
5757 register gchar *reply;
58 #ifdef USE_PTHREADS
59 pthread_mutex_init(&client->connection_mutex, NULL);
60 #endif /* USE_PTHREADS */
5861 if(!hp){
59 perror("lookup up hostname");
62 perror("looking up hostname");
6063 exit(1);
6164 }
6265 client->connection = SocketConnection_create(host, port);
102105 }
103106
104107 static gchar *SocketConnection_read(gint sock){
105 register gint i, len, line_complete = 0, line_expect = 1;
108 register gint i, len = 0, line_complete = 0, line_expect = 1;
106109 register gchar *reply;
107110 register GString *string = g_string_sized_new(Socket_BUFSIZE);
108111 register gboolean line_count_given = FALSE;
124127 g_error("linecount: must be > 1");
125128 }
126129 if(line_complete > line_expect){
127 if(line_count_given)
130 if(line_count_given){
128131 g_error("Received [%d] socket message lines, but expected [%d]",
129132 line_complete, line_count_given);
130 else
133 } else {
131134 g_error("Multiline socket messages must use linecount:");
135 }
132136 }
133137 g_string_append(string, buffer);
134138 } while(line_complete < line_expect);
170174 }
171175
172176 gchar *SocketClient_send(SocketClient *client, gchar *msg){
177 register gchar *reply;
178 #ifdef USE_PTHREADS
179 pthread_mutex_lock(&client->connection_mutex);
180 #endif /* USE_PTHREADS */
173181 Socket_send(client->connection->sock, msg, "writing client message");
174 return SocketConnection_read(client->connection->sock);
182 reply = SocketConnection_read(client->connection->sock);
183 g_assert(reply);
184 #ifdef USE_PTHREADS
185 pthread_mutex_unlock(&client->connection_mutex);
186 #endif /* USE_PTHREADS */
187 return reply;
175188 }
176189
177190 void SocketClient_destroy(SocketClient *client){
178191 SocketConnection_destroy(client->connection);
192 #ifdef USE_PTHREADS
193 pthread_mutex_destroy(&client->connection_mutex);
194 #endif /* USE_PTHREADS */
179195 g_free(client);
180196 return;
181197 }
195211 static void SocketServer_shutdown(int signum){
196212 g_message("Server shutting down");
197213 exit(0);
214 return;
215 }
216
217 static void SocketServer_broken_pipe(int signum){
218 g_message("Server detected broken pipe - closing thread");
219 pthread_exit(NULL);
198220 return;
199221 }
200222
244266 register gboolean ok = TRUE;
245267 gchar *reply;
246268 do {
269 #ifdef USE_PTHREADS
270 pthread_mutex_lock(&server->connection_mutex);
271 #endif /* USE_PTHREADS */
247272 msg = SocketConnection_read(msgsock);
273 #ifdef USE_PTHREADS
274 pthread_mutex_unlock(&server->connection_mutex);
275 #endif /* USE_PTHREADS */
248276 reply = NULL;
249277 if(!msg)
250278 break;
252280 server->user_data);
253281 g_free(msg);
254282 if(reply){
283 #ifdef USE_PTHREADS
284 pthread_mutex_lock(&server->connection_mutex);
285 #endif /* USE_PTHREADS */
255286 Socket_send(msgsock, reply, "writing reply");
287 #ifdef USE_PTHREADS
288 pthread_mutex_unlock(&server->connection_mutex);
289 #endif /* USE_PTHREADS */
256290 g_free(reply);
291 } else {
292 g_error("no reply from server");
257293 }
258294 } while(ok);
259295 if(server->connection_close_func)
264300 #ifdef USE_PTHREADS
265301 static void *SocketServer_pthread_func(void* data){
266302 register SocketServer_pthread_Data *sspd = (SocketServer_pthread_Data*)data;
303 signal(SIGPIPE, SocketServer_broken_pipe);
267304 SocketServer_process_connection(sspd->server, sspd->msgsock);
268305 pthread_mutex_lock(&sspd->server->connection_mutex);
269306 g_message("cleaning up connection [%d]", global_connection_count);
278315
279316 gboolean SocketServer_listen(SocketServer *server){
280317 register int msgsock;
281 register gint i;
282318 struct sockaddr_in client_addr;
283319 socklen_t client_len = sizeof(struct sockaddr_in);
284320 #ifdef USE_PTHREADS
321 register gint i;
285322 pthread_attr_t pt_attr;
286323 pthread_attr_init(&pt_attr);
287324 pthread_attr_setdetachstate(&pt_attr, PTHREAD_CREATE_DETACHED);
350387 return;
351388 }
352389
390
22 * Simple client-server code library *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
4444
4545 typedef struct {
4646 SocketConnection *connection;
47 #ifdef USE_PTHREADS
48 pthread_mutex_t connection_mutex;
49 #endif /* USE_PTHREADS */
4750 } SocketClient;
4851
4952 #ifdef USE_PTHREADS
22 * Simple client-server code library *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
0 /****************************************************************\
1 * *
2 * Basic library for thread-safe reference counting. *
3 * *
4 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
6 * *
7 * This source code is distributed under the terms of the *
8 * GNU General Public License, version 3. See the file COPYING *
9 * or http://www.gnu.org/licenses/gpl.txt for details *
10 * *
11 * If you use this code, please keep this notice intact. *
12 * *
13 \****************************************************************/
14
15 #include "threadref.h"
16
17 ThreadRef *ThreadRef_create(void){
18 register ThreadRef *threadref = g_new(ThreadRef, 1);
19 threadref->ref_count = 1;
20 #ifdef USE_PTHREADS
21 pthread_mutex_init(&threadref->ref_lock, NULL);
22 #endif /* USE_PTHREADS */
23 return threadref;
24 }
25
26 ThreadRef *ThreadRef_destroy(ThreadRef *threadref){
27 ThreadRef_lock(threadref);
28 if(--threadref->ref_count){
29 ThreadRef_unlock(threadref);
30 return threadref;
31 }
32 ThreadRef_unlock(threadref);
33 #ifdef USE_PTHREADS
34 pthread_mutex_destroy(&threadref->ref_lock);
35 #endif /* USE_PTHREADS */
36 g_free(threadref);
37 return NULL;
38 }
39
40 ThreadRef *ThreadRef_share(ThreadRef *threadref){
41 ThreadRef_lock(threadref);
42 threadref->ref_count++;
43 ThreadRef_unlock(threadref);
44 return threadref;
45 }
46
47 gint ThreadRef_get_count(ThreadRef *threadref){
48 register gint ref_count;
49 ThreadRef_lock(threadref);
50 ref_count = threadref->ref_count;
51 ThreadRef_unlock(threadref);
52 return ref_count;
53 }
54
55 void ThreadRef_lock(ThreadRef *threadref){
56 #ifdef USE_PTHREADS
57 pthread_mutex_lock(&threadref->ref_lock);
58 #endif /* USE_PTHREADS */
59 return;
60 }
61
62 void ThreadRef_unlock(ThreadRef *threadref){
63 #ifdef USE_PTHREADS
64 pthread_mutex_unlock(&threadref->ref_lock);
65 #endif /* USE_PTHREADS */
66 return;
67 }
68
0 /****************************************************************\
1 * *
2 * Basic library for thread-safe reference counting. *
3 * *
4 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
6 * *
7 * This source code is distributed under the terms of the *
8 * GNU General Public License, version 3. See the file COPYING *
9 * or http://www.gnu.org/licenses/gpl.txt for details *
10 * *
11 * If you use this code, please keep this notice intact. *
12 * *
13 \****************************************************************/
14
15 #ifndef INCLUDED_THREADREF_H
16 #define INCLUDED_THREADREF_H
17
18 #ifdef __cplusplus
19 extern "C" {
20 #endif /* __cplusplus */
21
22 #include <glib.h>
23
24 #ifdef USE_PTHREADS
25 #include <pthread.h>
26 #endif /* USE_PTHREADS */
27
28
29 typedef struct {
30 gint ref_count;
31 #ifdef USE_PTHREADS
32 pthread_mutex_t ref_lock;
33 #endif /* USE_PTHREADS */
34 } ThreadRef;
35
36 ThreadRef *ThreadRef_create(void);
37 ThreadRef *ThreadRef_destroy(ThreadRef *threadref);
38 ThreadRef *ThreadRef_share(ThreadRef *threadref);
39 gint ThreadRef_get_count(ThreadRef *threadref);
40 void ThreadRef_lock(ThreadRef *threadref);
41 void ThreadRef_unlock(ThreadRef *threadref);
42
43 #ifdef __cplusplus
44 }
45 #endif /* __cplusplus */
46
47 #endif /* INCLUDED_THREADREF_H */
48
0 /****************************************************************\
1 * *
2 * Basic library for thread-safe reference counting. *
3 * *
4 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
6 * *
7 * This source code is distributed under the terms of the *
8 * GNU General Public License, version 3. See the file COPYING *
9 * or http://www.gnu.org/licenses/gpl.txt for details *
10 * *
11 * If you use this code, please keep this notice intact. *
12 * *
13 \****************************************************************/
14
15 #include <stdio.h>
16 #include "threadref.h"
17
18 int main(void){
19 register ThreadRef *tr = ThreadRef_create(), *tr2;
20 tr2 = ThreadRef_share(tr);
21 ThreadRef_destroy(tr2);
22 ThreadRef_lock(tr);
23 ThreadRef_unlock(tr);
24 ThreadRef_destroy(tr);
25 return 0;
26 }
27
5959 $(top_srcdir)/src/model/modeltype.o \
6060 $(top_srcdir)/src/general/argument.o \
6161 $(top_srcdir)/src/general/lineparse.o \
62 $(top_srcdir)/src/general/jobqueue.o \
6263 $(top_srcdir)/src/comparison/match.o \
6364 $(top_srcdir)/src/sequence/submat.o \
6465 $(top_srcdir)/src/sequence/codonsubmat.o \
7071 $(top_srcdir)/src/comparison/wordhood.o \
7172 $(top_srcdir)/src/struct/sparsecache.o \
7273 $(top_srcdir)/src/general/compoundfile.o \
74 $(top_srcdir)/src/general/threadref.o \
7375 $(C4_OBJECTS)
7476
7577 bsam_test_SOURCES = bsam.test.c bsam.c
7678 bsam_test_LDADD = $(top_srcdir)/src/general/argument.o \
7779 $(top_srcdir)/src/general/lineparse.o \
80 $(top_srcdir)/src/general/threadref.o \
7881 $(top_srcdir)/src/comparison/hspset.o \
7982 $(top_srcdir)/src/comparison/comparison.o \
8083 $(top_srcdir)/src/comparison/match.o \
104107 $(top_srcdir)/src/struct/sparsecache.o \
105108 $(top_srcdir)/src/general/compoundfile.o \
106109 $(top_srcdir)/src/general/socket.o \
110 $(top_srcdir)/src/general/threadref.o \
107111 $(C4_OBJECTS)
108112
109113 # Files to clear away
6969 VERSION = @VERSION@
7070 codegen_extra_ldadd = @codegen_extra_ldadd@
7171 codegen_extra_sources = @codegen_extra_sources@
72 custom_guint64_format = @custom_guint64_format@
7273 datarootdir = @datarootdir@
7374 glib_cflags = @glib_cflags@
7475 glib_libs = @glib_libs@
8586
8687 noinst_HEADERS = gam.h analysis.h bsam.h
8788
88 C4_OBJECTS = $(top_srcdir)/src/c4/c4.o $(top_srcdir)/src/c4/codegen.o $(top_srcdir)/src/c4/cgutil.o $(top_srcdir)/src/c4/opair.o $(top_srcdir)/src/c4/alignment.o $(top_srcdir)/src/c4/optimal.o $(top_srcdir)/src/c4/viterbi.o $(top_srcdir)/src/c4/layout.o $(top_srcdir)/src/c4/region.o $(top_srcdir)/src/c4/subopt.o $(top_srcdir)/src/bsdp/bsdp.o $(top_srcdir)/src/bsdp/sar.o $(top_srcdir)/src/bsdp/heuristic.o $(top_srcdir)/src/bsdp/hpair.o $(top_srcdir)/src/sdp/boundary.o $(top_srcdir)/src/sdp/sdp.o $(top_srcdir)/src/sdp/scheduler.o $(top_srcdir)/src/sdp/straceback.o $(top_srcdir)/src/sdp/lookahead.o $(top_srcdir)/src/struct/matrix.o $(top_srcdir)/src/struct/slist.o $(top_srcdir)/src/struct/pqueue.o $(top_srcdir)/src/struct/recyclebin.o $(top_srcdir)/src/struct/rangetree.o $(top_srcdir)/src/sequence/sequence.o $(top_srcdir)/src/sequence/alphabet.o $(top_srcdir)/src/sequence/translate.o $(top_srcdir)/src/sequence/splice.o $(top_srcdir)/src/model/affine.o $(top_srcdir)/src/model/est2genome.o $(top_srcdir)/src/model/ner.o $(top_srcdir)/src/model/protein2dna.o $(top_srcdir)/src/model/protein2genome.o $(top_srcdir)/src/model/coding2coding.o $(top_srcdir)/src/model/coding2genome.o $(top_srcdir)/src/model/cdna2genome.o $(top_srcdir)/src/model/genome2genome.o $(top_srcdir)/src/model/ungapped.o $(top_srcdir)/src/model/intron.o $(top_srcdir)/src/model/frameshift.o $(top_srcdir)/src/model/phase.o $(top_srcdir)/src/model/modeltype.o $(top_srcdir)/src/general/argument.o $(top_srcdir)/src/general/lineparse.o $(top_srcdir)/src/comparison/match.o $(top_srcdir)/src/sequence/submat.o $(top_srcdir)/src/sequence/codonsubmat.o -lm
89 C4_OBJECTS = $(top_srcdir)/src/c4/c4.o $(top_srcdir)/src/c4/codegen.o $(top_srcdir)/src/c4/cgutil.o $(top_srcdir)/src/c4/opair.o $(top_srcdir)/src/c4/alignment.o $(top_srcdir)/src/c4/optimal.o $(top_srcdir)/src/c4/viterbi.o $(top_srcdir)/src/c4/layout.o $(top_srcdir)/src/c4/region.o $(top_srcdir)/src/c4/subopt.o $(top_srcdir)/src/bsdp/bsdp.o $(top_srcdir)/src/bsdp/sar.o $(top_srcdir)/src/bsdp/heuristic.o $(top_srcdir)/src/bsdp/hpair.o $(top_srcdir)/src/sdp/boundary.o $(top_srcdir)/src/sdp/sdp.o $(top_srcdir)/src/sdp/scheduler.o $(top_srcdir)/src/sdp/straceback.o $(top_srcdir)/src/sdp/lookahead.o $(top_srcdir)/src/struct/matrix.o $(top_srcdir)/src/struct/slist.o $(top_srcdir)/src/struct/pqueue.o $(top_srcdir)/src/struct/recyclebin.o $(top_srcdir)/src/struct/rangetree.o $(top_srcdir)/src/sequence/sequence.o $(top_srcdir)/src/sequence/alphabet.o $(top_srcdir)/src/sequence/translate.o $(top_srcdir)/src/sequence/splice.o $(top_srcdir)/src/model/affine.o $(top_srcdir)/src/model/est2genome.o $(top_srcdir)/src/model/ner.o $(top_srcdir)/src/model/protein2dna.o $(top_srcdir)/src/model/protein2genome.o $(top_srcdir)/src/model/coding2coding.o $(top_srcdir)/src/model/coding2genome.o $(top_srcdir)/src/model/cdna2genome.o $(top_srcdir)/src/model/genome2genome.o $(top_srcdir)/src/model/ungapped.o $(top_srcdir)/src/model/intron.o $(top_srcdir)/src/model/frameshift.o $(top_srcdir)/src/model/phase.o $(top_srcdir)/src/model/modeltype.o $(top_srcdir)/src/general/argument.o $(top_srcdir)/src/general/lineparse.o $(top_srcdir)/src/general/jobqueue.o $(top_srcdir)/src/comparison/match.o $(top_srcdir)/src/sequence/submat.o $(top_srcdir)/src/sequence/codonsubmat.o -lm
8990
9091
9192 gam_test_SOURCES = gam.test.c gam.c
92 gam_test_LDADD = $(top_srcdir)/src/comparison/hspset.o $(top_srcdir)/src/comparison/comparison.o $(top_srcdir)/src/comparison/wordhood.o $(top_srcdir)/src/struct/sparsecache.o $(top_srcdir)/src/general/compoundfile.o $(C4_OBJECTS)
93 gam_test_LDADD = $(top_srcdir)/src/comparison/hspset.o $(top_srcdir)/src/comparison/comparison.o $(top_srcdir)/src/comparison/wordhood.o $(top_srcdir)/src/struct/sparsecache.o $(top_srcdir)/src/general/compoundfile.o $(top_srcdir)/src/general/threadref.o $(C4_OBJECTS)
9394
9495
9596 bsam_test_SOURCES = bsam.test.c bsam.c
96 bsam_test_LDADD = $(top_srcdir)/src/general/argument.o $(top_srcdir)/src/general/lineparse.o $(top_srcdir)/src/comparison/hspset.o $(top_srcdir)/src/comparison/comparison.o $(top_srcdir)/src/comparison/match.o $(top_srcdir)/src/comparison/wordhood.o $(top_srcdir)/src/sequence/sequence.o $(top_srcdir)/src/sequence/alphabet.o $(top_srcdir)/src/sequence/translate.o $(top_srcdir)/src/sequence/submat.o $(top_srcdir)/src/sequence/codonsubmat.o $(top_srcdir)/src/sequence/splice.o $(top_srcdir)/src/struct/dejavu.o $(top_srcdir)/src/struct/pqueue.o $(top_srcdir)/src/struct/sparsecache.o $(top_srcdir)/src/struct/recyclebin.o $(top_srcdir)/src/struct/matrix.o -lm
97 bsam_test_LDADD = $(top_srcdir)/src/general/argument.o $(top_srcdir)/src/general/lineparse.o $(top_srcdir)/src/general/threadref.o $(top_srcdir)/src/comparison/hspset.o $(top_srcdir)/src/comparison/comparison.o $(top_srcdir)/src/comparison/match.o $(top_srcdir)/src/comparison/wordhood.o $(top_srcdir)/src/sequence/sequence.o $(top_srcdir)/src/sequence/alphabet.o $(top_srcdir)/src/sequence/translate.o $(top_srcdir)/src/sequence/submat.o $(top_srcdir)/src/sequence/codonsubmat.o $(top_srcdir)/src/sequence/splice.o $(top_srcdir)/src/struct/dejavu.o $(top_srcdir)/src/struct/pqueue.o $(top_srcdir)/src/struct/sparsecache.o $(top_srcdir)/src/struct/recyclebin.o $(top_srcdir)/src/struct/matrix.o -lm
9798
9899 analysis_test_SOURCES = analysis.test.c analysis.c gam.c bsam.c
99 analysis_test_LDADD = $(top_srcdir)/src/comparison/hspset.o $(top_srcdir)/src/comparison/wordhood.o $(top_srcdir)/src/comparison/seeder.o $(top_srcdir)/src/comparison/comparison.o $(top_srcdir)/src/database/fastapipe.o $(top_srcdir)/src/database/fastadb.o $(top_srcdir)/src/struct/dejavu.o $(top_srcdir)/src/struct/fsm.o $(top_srcdir)/src/struct/vfsm.o $(top_srcdir)/src/struct/sparsecache.o $(top_srcdir)/src/general/compoundfile.o $(top_srcdir)/src/general/socket.o $(C4_OBJECTS)
100 analysis_test_LDADD = $(top_srcdir)/src/comparison/hspset.o $(top_srcdir)/src/comparison/wordhood.o $(top_srcdir)/src/comparison/seeder.o $(top_srcdir)/src/comparison/comparison.o $(top_srcdir)/src/database/fastapipe.o $(top_srcdir)/src/database/fastadb.o $(top_srcdir)/src/struct/dejavu.o $(top_srcdir)/src/struct/fsm.o $(top_srcdir)/src/struct/vfsm.o $(top_srcdir)/src/struct/sparsecache.o $(top_srcdir)/src/general/compoundfile.o $(top_srcdir)/src/general/socket.o $(top_srcdir)/src/general/threadref.o $(C4_OBJECTS)
100101
101102
102103 # Files to clear away
116117 $(top_srcdir)/src/comparison/comparison.o \
117118 $(top_srcdir)/src/comparison/wordhood.o \
118119 $(top_srcdir)/src/struct/sparsecache.o \
119 $(top_srcdir)/src/general/compoundfile.o $(top_srcdir)/src/c4/c4.o \
120 $(top_srcdir)/src/general/compoundfile.o \
121 $(top_srcdir)/src/general/threadref.o $(top_srcdir)/src/c4/c4.o \
120122 $(top_srcdir)/src/c4/codegen.o $(top_srcdir)/src/c4/cgutil.o \
121123 $(top_srcdir)/src/c4/opair.o $(top_srcdir)/src/c4/alignment.o \
122124 $(top_srcdir)/src/c4/optimal.o $(top_srcdir)/src/c4/viterbi.o \
145147 $(top_srcdir)/src/model/modeltype.o \
146148 $(top_srcdir)/src/general/argument.o \
147149 $(top_srcdir)/src/general/lineparse.o \
150 $(top_srcdir)/src/general/jobqueue.o \
148151 $(top_srcdir)/src/comparison/match.o \
149152 $(top_srcdir)/src/sequence/submat.o \
150153 $(top_srcdir)/src/sequence/codonsubmat.o
159162 $(top_srcdir)/src/struct/fsm.o $(top_srcdir)/src/struct/vfsm.o \
160163 $(top_srcdir)/src/struct/sparsecache.o \
161164 $(top_srcdir)/src/general/compoundfile.o \
162 $(top_srcdir)/src/general/socket.o $(top_srcdir)/src/c4/c4.o \
165 $(top_srcdir)/src/general/socket.o \
166 $(top_srcdir)/src/general/threadref.o $(top_srcdir)/src/c4/c4.o \
163167 $(top_srcdir)/src/c4/codegen.o $(top_srcdir)/src/c4/cgutil.o \
164168 $(top_srcdir)/src/c4/opair.o $(top_srcdir)/src/c4/alignment.o \
165169 $(top_srcdir)/src/c4/optimal.o $(top_srcdir)/src/c4/viterbi.o \
188192 $(top_srcdir)/src/model/modeltype.o \
189193 $(top_srcdir)/src/general/argument.o \
190194 $(top_srcdir)/src/general/lineparse.o \
195 $(top_srcdir)/src/general/jobqueue.o \
191196 $(top_srcdir)/src/comparison/match.o \
192197 $(top_srcdir)/src/sequence/submat.o \
193198 $(top_srcdir)/src/sequence/codonsubmat.o
195200 bsam_test_OBJECTS = bsam.test.o bsam.o
196201 bsam_test_DEPENDENCIES = $(top_srcdir)/src/general/argument.o \
197202 $(top_srcdir)/src/general/lineparse.o \
203 $(top_srcdir)/src/general/threadref.o \
198204 $(top_srcdir)/src/comparison/hspset.o \
199205 $(top_srcdir)/src/comparison/comparison.o \
200206 $(top_srcdir)/src/comparison/match.o \
22 * Analysis module for exonerate *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
1616 #include "ungapped.h"
1717 #include "compoundfile.h"
1818 #include "hspset.h"
19 #include "lineparse.h"
1920
2021 #include <stdlib.h> /* For atoi() */
2122 #include <unistd.h> /* For sleep() */
2223 #include <string.h> /* For strcmp() */
2324 #include <ctype.h> /* For isdigit() */
25
26 #include <sys/types.h> /* For stat() */
27 #include <sys/stat.h> /* For stat() */
28 #include <unistd.h> /* For stat() */
2429
2530 Analysis_ArgumentSet *Analysis_ArgumentSet_create(Argument *arg){
2631 register ArgumentSet *as;
3338 ArgumentSet_add_option(as, 'B', "bigseq", NULL,
3439 "Allow rapid comparison between big sequences", "FALSE",
3540 Argument_parse_boolean, &aas.use_bigseq);
41 ArgumentSet_add_option(as, 'r', "revcomp", NULL,
42 "Also search reverse complement of query and target", "TRUE",
43 Argument_parse_boolean, &aas.use_revcomp);
3644 ArgumentSet_add_option(as, '\0', "forcescan", "[q|t]",
3745 "Force FSM scan on query or target sequences", "none",
3846 Argument_parse_string, &aas.force_scan);
4452 ArgumentSet_add_option(as, 0, "customserver", "command",
4553 "Custom command to send non-standard server", "NULL",
4654 Argument_parse_string, &aas.custom_server_command);
55 ArgumentSet_add_option(as, 'c', "cores", "number",
56 "Number of cores/CPUs/threads for alignment computation", "1",
57 Argument_parse_int, &aas.thread_count);
4758 Argument_absorb_ArgumentSet(arg, as);
4859 }
4960 return &aas;
5061 }
5162
5263 /**/
64
65 typedef struct {
66 GAM *gam;
67 Comparison *comparison;
68 } Analysis_HeuristicJob;
69
70 static Analysis_HeuristicJob *Analysis_HeuristicJob_create(GAM *gam,
71 Comparison *comparison){
72 register Analysis_HeuristicJob *ahj = g_new(Analysis_HeuristicJob, 1);
73 ahj->gam = GAM_share(gam);
74 ahj->comparison = Comparison_share(comparison);
75 return ahj;
76 }
77
78 static void Analysis_HeuristicJob_destroy(Analysis_HeuristicJob *ahj){
79 Comparison_destroy(ahj->comparison);
80 GAM_destroy(ahj->gam);
81 g_free(ahj);
82 return;
83 }
84
85 static void Analysis_HeuristicJob_run(gpointer data){
86 register Analysis_HeuristicJob *ahj = data;
87 register GAM_Result *gam_result
88 = GAM_Result_heuristic_create(ahj->gam, ahj->comparison);
89 if(gam_result){
90 GAM_Result_submit(gam_result);
91 GAM_Result_destroy(gam_result);
92 }
93 Analysis_HeuristicJob_destroy(ahj);
94 return;
95 }
5396
5497 static void Analysis_report_func(Comparison *comparison,
5598 gpointer user_data){
5699 register Analysis *analysis = user_data;
57100 register GAM_Result *gam_result;
101 register Analysis_HeuristicJob *ahj;
58102 g_assert(Comparison_has_hsps(comparison));
59103 if(analysis->scan_query){
60104 /* Swap back query and target after a query scan */
69113 Comparison_revcomp(comparison);
70114 }
71115 if(Model_Type_is_gapped(analysis->gam->gas->type)){
72 gam_result = GAM_Result_heuristic_create(analysis->gam,
73 comparison);
116 ahj = Analysis_HeuristicJob_create(analysis->gam, comparison);
117 #ifdef USE_PTHREADS
118 g_assert(analysis->job_queue);
119 /* FIXME: need to use priority here */
120 JobQueue_submit(analysis->job_queue, Analysis_HeuristicJob_run, ahj, 2);
121 #else /* USE_PTHREADS */
122 Analysis_HeuristicJob_run(ahj);
123 #endif /* USE_PTHREADS */
74124 } else {
75125 gam_result = GAM_Result_ungapped_create(analysis->gam,
76126 comparison);
77 }
78 if(gam_result){
79 GAM_Result_submit(gam_result);
80 GAM_Result_destroy(gam_result);
127 if(gam_result){
128 GAM_Result_submit(gam_result);
129 GAM_Result_destroy(gam_result);
130 }
81131 }
82132 return;
83133 }
107157 /* Called after query pipeline analysis */
108158
109159 static gboolean Analysis_FastaPipe_Pair_query_func(FastaDB_Seq *fdbs,
110 gpointer user_data){
160 gpointer user_data){
111161 register Analysis *analysis = user_data;
112162 g_assert(!analysis->curr_query);
113163 /*
138188
139189 /**/
140190
191 typedef struct {
192 GAM *gam;
193 Sequence *query;
194 Sequence *target;
195 } Analysis_ExhaustiveJob;
196
197 static Analysis_ExhaustiveJob *Analysis_ExhaustiveJob_create(GAM *gam,
198 Sequence *query, Sequence *target){
199 register Analysis_ExhaustiveJob *aej = g_new(Analysis_ExhaustiveJob, 1);
200 aej->gam = GAM_share(gam);
201 aej->query = Sequence_share(query);
202 aej->target = Sequence_share(target);
203 return aej;
204 }
205
206 static void Analysis_ExhaustiveJob_destroy(Analysis_ExhaustiveJob *aej){
207 GAM_destroy(aej->gam);
208 Sequence_destroy(aej->query);
209 Sequence_destroy(aej->target);
210 g_free(aej);
211 return;
212 }
213
214 static void Analysis_ExhaustiveJob_run(gpointer data){
215 register Analysis_ExhaustiveJob *aej = data;
216 register GAM_Result *gam_result;
217 gam_result = GAM_Result_exhaustive_create(aej->gam,
218 aej->query, aej->target);
219 if(gam_result){
220 GAM_Result_submit(gam_result);
221 GAM_Result_destroy(gam_result);
222 }
223 Analysis_ExhaustiveJob_destroy(aej);
224 return;
225 }
226
141227 static void Analysis_Pair_compare(Analysis *analysis,
142228 FastaDB_Seq *fdbs){
143 register GAM_Result *gam_result;
229 register Analysis_ExhaustiveJob *aej;
144230 if(analysis->aas->use_exhaustive){
145 gam_result = GAM_Result_exhaustive_create(analysis->gam,
146 analysis->curr_query->seq, fdbs->seq);
147 if(gam_result){
148 GAM_Result_submit(gam_result);
149 GAM_Result_destroy(gam_result);
150 }
231 aej = Analysis_ExhaustiveJob_create(analysis->gam,
232 analysis->curr_query->seq,
233 fdbs->seq);
234 #ifdef USE_PTHREADS
235 g_assert(analysis->job_queue);
236 JobQueue_submit(analysis->job_queue, Analysis_ExhaustiveJob_run, aej, 1);
237 #else /* USE_PTHREADS */
238 Analysis_ExhaustiveJob_run(aej);
239 #endif /* USE_PTHREADS */
151240 } else {
152241 Analysis_BSAM_compare(analysis, analysis->curr_query, fdbs);
153242 }
154243 return;
155244 }
245
246 /**/
156247
157248 static gboolean Analysis_FastaPipe_Pair_target_func(FastaDB_Seq *fdbs,
158249 gpointer user_data){
419510 g_free(msg);
420511 g_free(reply);
421512 /**/
513 msg = g_strdup_printf("set param dnawordlimit %d",
514 has->dna_word_limit);
515 reply = Analysis_Client_send(aclient, msg, "ok:", FALSE);
516 g_free(msg);
517 g_free(reply);
518 /**/
519 msg = g_strdup_printf("set param proteinwordlimit %d",
520 has->protein_word_limit);
521 reply = Analysis_Client_send(aclient, msg, "ok:", FALSE);
522 g_free(msg);
523 g_free(reply);
524 /**/
525 msg = g_strdup_printf("set param codonwordlimit %d",
526 has->codon_word_limit);
527 reply = Analysis_Client_send(aclient, msg, "ok:", FALSE);
528 g_free(msg);
529 g_free(reply);
530 /**/
422531 msg = g_strdup_printf("set param dnahspdropoff %d",
423532 has->dna_hsp_dropoff);
424533 reply = Analysis_Client_send(aclient, msg, "ok:", FALSE);
461570 g_free(msg);
462571 g_free(reply);
463572 /**/
573 return;
574 }
575
576 static void Analysis_Client_info(Analysis_Client *aclient){
464577 return;
465578 }
466579
472585 if(!sc)
473586 return NULL;
474587 aclient = g_new(Analysis_Client, 1);
588 aclient->ref_count = 1;
475589 aclient->sc = sc;
476590 aclient->verbosity = verbosity;
477591 aclient->probe_fdb = NULL;
507621 g_free(dbinfo);
508622 aclient->curr_query = NULL;
509623 aclient->seq_cache = g_new0(Sequence*, aclient->num_seqs);
624 Analysis_Client_info(aclient);
625 return aclient;
626 }
627
628 static Analysis_Client *Analysis_Client_share(Analysis_Client *aclient){
629 aclient->ref_count++;
510630 return aclient;
511631 }
512632
513633 static void Analysis_Client_destroy(Analysis_Client *aclient){
514634 register gint i;
515635 register Sequence *seq;
636 if(--aclient->ref_count)
637 return;
516638 if(aclient->curr_query)
517639 Sequence_destroy(aclient->curr_query);
518640 for(i = 0; i < aclient->num_seqs; i++){
532654 static void Analysis_Client_set_probe_fdb(Analysis_Client *aclient,
533655 FastaDB *probe_fdb){
534656 g_assert(!aclient->probe_fdb);
535 aclient->probe_fdb = FastaDB_share(probe_fdb);
657 aclient->probe_fdb = FastaDB_dup(probe_fdb);
536658 return;
537659 }
538660
591713 static Analysis_Client_Key *Analysis_Client_Key_create(Analysis_Client *aclient,
592714 gint target_id, gint seq_len){
593715 register Analysis_Client_Key *key = g_new(Analysis_Client_Key, 1);
594 key->aclient = aclient;
716 key->aclient = Analysis_Client_share(aclient);
595717 key->target_id = target_id;
596718 key->seq_len = seq_len;
597719 return key;
598720 }
599721
600722 static void Analysis_Client_Key_destroy(Analysis_Client_Key *key){
723 Analysis_Client_destroy(key->aclient);
601724 g_free(key);
602725 return;
603726 }
847970 Analysis *analysis,
848971 Sequence *query,
849972 gboolean swap_chains,
850 gboolean revcomp_target){
973 gboolean revcomp_target,
974 gint priority){
851975 Analysis_Client_set_query(aclient, query);
852976 Analysis_Client_get_hsp_sets(aclient, analysis, swap_chains, revcomp_target);
853977 /* Revcomp query if DNA */
860984 }
861985
862986 static void Analysis_Client_process(Analysis_Client *aclient, Analysis *analysis,
863 gboolean swap_chains){
987 gboolean swap_chains, gint priority){
864988 register FastaDB_Seq *fdbs;
865989 /* FIXME: need to check for appropriate database type */
866990 while((fdbs = FastaDB_next(aclient->probe_fdb, FastaDB_Mask_ALL))){
867991 Analysis_Client_process_query(aclient, analysis, fdbs->seq,
868 swap_chains, FALSE);
992 swap_chains, FALSE, priority);
869993 /* Revcomp target if protein vs DNA or translate_both */
870994 if(((aclient->curr_query->alphabet->type == Alphabet_Type_PROTEIN)
871995 && (aclient->server_alphabet->type == Alphabet_Type_DNA))
872996 || analysis->gam->translate_both){
873997 Analysis_Client_revcomp_target(aclient);
874998 Analysis_Client_process_query(aclient, analysis,
875 fdbs->seq, swap_chains, TRUE);
999 fdbs->seq, swap_chains, TRUE,
1000 priority);
8761001 Analysis_Client_revcomp_target(aclient);
8771002 }
8781003 FastaDB_Seq_destroy(fdbs);
8811006 }
8821007
8831008 /**/
1009
1010 static Analysis_Server *Analysis_Server_create(Analysis_Builder *ab,
1011 gchar *name, gint priority){
1012 register Analysis_Server *as = g_new(Analysis_Server, 1);
1013 as->name = g_strdup(name);
1014 as->ab = ab;
1015 as->priority = priority;
1016 return as;
1017 }
1018
1019 static void Analysis_Server_destroy(Analysis_Server *as){
1020 g_free(as->name);
1021 g_free(as);
1022 return;
1023 }
1024
1025 /**/
1026
1027 static Analysis_Builder *Analysis_Builder_create(GPtrArray *path_list,
1028 Analysis *analysis,
1029 gint verbosity){
1030 register Analysis_Builder *ab;
1031 register gint i;
1032 register Analysis_Client *ac;
1033 register Analysis_Server *as;
1034 g_assert(path_list->len);
1035 ac = Analysis_Client_create(path_list->pdata[0], analysis->verbosity);
1036 if(!ac)
1037 return NULL;
1038 /**/
1039 ab = g_new(Analysis_Builder, 1);
1040 ab->verbosity = verbosity;
1041 ab->server_list = g_ptr_array_new();
1042 ab->server_type = ac->server_alphabet->type;
1043 ab->probe_fdb = NULL;
1044 ab->analysis = analysis;
1045 Analysis_Client_destroy(ac);
1046 for(i = 0; i < path_list->len; i++){
1047 as = Analysis_Server_create(ab, path_list->pdata[i], i);
1048 g_ptr_array_add(ab->server_list, as);
1049 }
1050 return ab;
1051 }
1052
1053 static void Analysis_Builder_destroy(Analysis_Builder *ab){
1054 register gint i;
1055 register Analysis_Server *as;
1056 for(i = 0; i < ab->server_list->len; i++){
1057 as = ab->server_list->pdata[i];
1058 Analysis_Server_destroy(as);
1059 }
1060 g_ptr_array_free(ab->server_list, TRUE);
1061 if(ab->probe_fdb)
1062 FastaDB_close(ab->probe_fdb);
1063 g_free(ab);
1064 return;
1065 }
1066
1067 static void Analysis_Server_run(gpointer data){
1068 register Analysis_Server *server = data;
1069 register Analysis_Client *client
1070 = Analysis_Client_create(server->name,
1071 server->ab->analysis->verbosity);
1072 if(!client)
1073 g_error("Could not connect to server [%s]", server->name);
1074 Analysis_Client_set_param(client, server->ab->analysis->gam);
1075 Analysis_Client_set_probe_fdb(client, server->ab->probe_fdb);
1076 Analysis_Client_process(client, server->ab->analysis,
1077 server->ab->swap_chains, server->priority);
1078 /**/
1079 Analysis_Client_destroy(client);
1080 return;
1081 }
1082
1083 static void Analysis_Builder_process(Analysis_Builder *ab,
1084 Analysis *analysis, gboolean swap_chains){
1085 register gint i;
1086 register Analysis_Server *as;
1087 ab->swap_chains = swap_chains;
1088 for(i = 0; i < ab->server_list->len; i++){
1089 as = ab->server_list->pdata[i];
1090 #ifdef USE_PTHREADS
1091 g_assert(analysis->job_queue);
1092 JobQueue_submit(analysis->job_queue, Analysis_Server_run, as, i);
1093 #else /* USE_PTHREADS */
1094 Analysis_Server_run(as);
1095 #endif /* USE_PTHREADS */
1096 }
1097 return;
1098 }
1099
1100 static void Analysis_Builder_set_probe_fdb(Analysis_Builder *ab,
1101 FastaDB *probe_fdb){
1102 g_assert(!ab->probe_fdb);
1103 ab->probe_fdb = FastaDB_share(probe_fdb);
1104 return;
1105 }
1106
1107 /**/
1108
1109 static void Analysis_path_list_destroy(GPtrArray *path_list){
1110 register gint i;
1111 register gchar *path;
1112 for(i = 0; i < path_list->len; i++){
1113 path = path_list->pdata[i];
1114 g_free(path);
1115 }
1116 g_ptr_array_free(path_list, TRUE);
1117 return;
1118 }
1119
1120 static GPtrArray *Analysis_FOSN_expand_path_list(GPtrArray *path_list){
1121 register gint i;
1122 register gchar *path, *npath;
1123 struct stat buf;
1124 register gboolean expanded_list = FALSE;
1125 register GPtrArray *npath_list = g_ptr_array_new();
1126 register FILE *fp;
1127 register LineParse *lp;
1128 for(i = 0; i < path_list->len; i++){
1129 path = path_list->pdata[i];
1130 if((stat(path, &buf)) /* Cannot read file (ie. servername) */
1131 || (S_ISDIR(buf.st_mode)) /* Is directory */
1132 || (FastaDB_file_is_fasta(path))){ /* 1st non-whitespace char is '>' */
1133 npath = g_strdup(path);
1134 g_ptr_array_add(npath_list, npath);
1135 } else { /* Assume to be fosn */
1136 fp = fopen(path, "r");
1137 if(!fp)
1138 g_error("Could not open FOSN file [%s]", path);
1139 lp = LineParse_create(fp);
1140 while(LineParse_line(lp) != EOF){
1141 g_strstrip(lp->line->str); /* strip whitespace */
1142 if(lp->line->str[0]){
1143 npath = g_strdup(lp->line->str);
1144 g_ptr_array_add(npath_list, npath);
1145 expanded_list = TRUE;
1146 }
1147 }
1148 LineParse_destroy(lp);
1149 fclose(fp);
1150 }
1151 }
1152 if(!expanded_list){
1153 for(i = 0; i < npath_list->len; i++){
1154 npath = npath_list->pdata[i];
1155 g_free(npath);
1156 }
1157 g_ptr_array_free(npath_list, TRUE);
1158 return NULL;
1159 }
1160 return npath_list;
1161 }
1162 /* If members of the path list are files
1163 * where the first non-whitespace character is not '>',
1164 * it is assumed to be a FOSN, and parsed to expand the path_list.
1165 */
8841166
8851167 Analysis *Analysis_create(
8861168 GPtrArray *query_path_list, Alphabet_Type query_type,
8981180 *codon_hsp_param;
8991181 register Match_ArgumentSet *mas = Match_ArgumentSet_create(NULL);
9001182 register gboolean use_horizon;
1183 register GPtrArray *expanded_query_path_list = NULL,
1184 *expanded_target_path_list = NULL;
9011185 g_assert(query_path_list);
9021186 g_assert(target_path_list);
9031187 g_assert(query_path_list->len);
9041188 g_assert(target_path_list->len);
9051189 analysis->aas = Analysis_ArgumentSet_create(NULL);
906
9071190 analysis->verbosity = verbosity;
908 /**/
909 if(query_path_list->len == 1)
910 analysis->query_ac
911 = Analysis_Client_create((gchar*)query_path_list->pdata[0],
912 verbosity);
913 if(target_path_list->len == 1)
914 analysis->target_ac
915 = Analysis_Client_create((gchar*)target_path_list->pdata[0],
916 verbosity);
1191 analysis->job_queue = JobQueue_create(analysis->aas->thread_count);
1192 /* Expand FOSN paths */
1193 expanded_query_path_list = Analysis_FOSN_expand_path_list(
1194 query_path_list);
1195 expanded_target_path_list = Analysis_FOSN_expand_path_list(
1196 target_path_list);
1197 if(expanded_query_path_list)
1198 query_path_list = expanded_query_path_list;
1199 if(expanded_target_path_list)
1200 target_path_list = expanded_target_path_list;
1201 /**/
1202 analysis->query_builder = Analysis_Builder_create(query_path_list,
1203 analysis, verbosity);
1204 analysis->target_builder = Analysis_Builder_create(target_path_list,
1205 analysis, verbosity);
9171206 /**/
9181207 if(query_type == Alphabet_Type_UNKNOWN){
919 if(analysis->query_ac){
920 query_type = analysis->query_ac->server_alphabet->type;
1208 if(analysis->query_builder){
1209 query_type = analysis->query_builder->server_type;
9211210 } else {
9221211 query_type = FastaDB_guess_type(
9231212 (gchar*)query_path_list->pdata[0]);
9271216 }
9281217 }
9291218 if(target_type == Alphabet_Type_UNKNOWN){
930 if(analysis->target_ac){
931 target_type = analysis->target_ac->server_alphabet->type;
1219 if(analysis->target_builder){
1220 target_type = analysis->target_builder->server_type;
9321221 } else {
9331222 target_type = FastaDB_guess_type(
9341223 (gchar*)target_path_list->pdata[0]);
9521241 analysis->aas->use_exhaustive,
9531242 verbosity);
9541243 /**/
955 if(analysis->query_ac)
956 Analysis_Client_set_param(analysis->query_ac, analysis->gam);
957 if(analysis->target_ac)
958 Analysis_Client_set_param(analysis->target_ac, analysis->gam);
959 /**/
9601244 Analysis_find_matches(analysis, &dna_match, &protein_match,
9611245 &codon_match);
9621246 match = dna_match;
9651249 if(!match)
9661250 match = codon_match;
9671251 g_assert(match);
968 if(!analysis->query_ac)
1252 if(!analysis->query_builder)
9691253 query_fdb = FastaDB_open_list_with_limit(query_path_list,
9701254 match->query->alphabet, query_chunk_id, query_chunk_total);
971 if(!analysis->target_ac)
1255 if(!analysis->target_builder)
9721256 target_fdb = FastaDB_open_list_with_limit(target_path_list,
9731257 match->target->alphabet, target_chunk_id, target_chunk_total);
9741258 if(analysis->aas->use_exhaustive){
975 if(analysis->query_ac || analysis->target_ac) /* FIXME: ni */
1259 if(analysis->query_builder || analysis->target_builder) /* FIXME: ni */
9761260 g_error("Exhaustive alignment against server not implemented");
9771261 analysis->fasta_pipe = FastaPipe_create(
9781262 query_fdb, target_fdb,
9821266 Analysis_FastaPipe_Pair_query_func,
9831267 Analysis_FastaPipe_Pair_target_func,
9841268 FastaDB_Mask_ALL,
985 analysis->gam->translate_both);
1269 analysis->gam->translate_both,
1270 analysis->aas->use_revcomp);
9861271 analysis->curr_query = NULL;
9871272 } else { /* Not exhaustive */
9881273 use_horizon = (analysis->aas->use_bigseq
989 || analysis->query_ac
990 || analysis->target_ac)?FALSE:TRUE;
1274 || analysis->query_builder
1275 || analysis->target_builder)?FALSE:TRUE;
9911276 dna_hsp_param = dna_match
9921277 ? HSP_Param_create(dna_match, use_horizon)
9931278 : NULL;
10251310 = analysis->gam->gas->threshold;
10261311 }
10271312 /* Don't need HSP horizon for bigseq comparison */
1028 if(analysis->query_ac || analysis->target_ac){
1029 if(analysis->query_ac && analysis->target_ac)
1313 if(analysis->query_builder || analysis->target_builder){
1314 if(analysis->query_builder && analysis->target_builder)
10301315 g_error("Server vs server comparison not impelemented");
10311316 analysis->fasta_pipe = NULL;
1032 if(analysis->query_ac){
1033 Analysis_Client_set_probe_fdb(analysis->query_ac, target_fdb);
1317 if(analysis->query_builder){
1318 Analysis_Builder_set_probe_fdb(analysis->query_builder,
1319 target_fdb);
10341320 } else {
1035 g_assert(analysis->target_ac);
1036 Analysis_Client_set_probe_fdb(analysis->target_ac, query_fdb);
1321 g_assert(analysis->target_builder);
1322 Analysis_Builder_set_probe_fdb(analysis->target_builder,
1323 query_fdb);
10371324 }
10381325 } else {
10391326 if(analysis->aas->use_bigseq){
10481335 Analysis_FastaPipe_Pair_query_func,
10491336 Analysis_FastaPipe_Pair_target_func,
10501337 FastaDB_Mask_ALL,
1051 analysis->gam->translate_both);
1338 analysis->gam->translate_both,
1339 analysis->aas->use_revcomp);
10521340 analysis->curr_query = NULL;
10531341 } else { /* Use Seeder */
10541342 analysis->scan_query = Analysis_decide_scan_query(query_fdb,
10751363 Analysis_FastaPipe_Seeder_term_func,
10761364 Analysis_FastaPipe_Seeder_query_func,
10771365 Analysis_FastaPipe_Seeder_target_func,
1078 FastaDB_Mask_ALL, analysis->gam->translate_both);
1366 FastaDB_Mask_ALL, analysis->gam->translate_both,
1367 analysis->aas->use_revcomp);
10791368 }
10801369 }
10811370 }
10841373 if(target_fdb)
10851374 FastaDB_close(target_fdb);
10861375 /**/
1376 if(expanded_query_path_list)
1377 Analysis_path_list_destroy(expanded_query_path_list);
1378 if(expanded_target_path_list)
1379 Analysis_path_list_destroy(expanded_target_path_list);
10871380 return analysis;
10881381 }
10891382
10901383 void Analysis_destroy(Analysis *analysis){
1384 JobQueue_destroy(analysis->job_queue);
10911385 if(analysis->fasta_pipe)
10921386 FastaPipe_destroy(analysis->fasta_pipe);
10931387 if(analysis->curr_query)
10981392 BSAM_destroy(analysis->bsam);
10991393 if(analysis->comparison_param)
11001394 Comparison_Param_destroy(analysis->comparison_param);
1395 /*
11011396 if(analysis->query_ac)
11021397 Analysis_Client_destroy(analysis->query_ac);
11031398 if(analysis->target_ac)
11041399 Analysis_Client_destroy(analysis->target_ac);
1400 */
1401 if(analysis->query_builder)
1402 Analysis_Builder_destroy(analysis->query_builder);
1403 if(analysis->target_builder)
1404 Analysis_Builder_destroy(analysis->target_builder);
11051405 GAM_destroy(analysis->gam);
11061406 g_free(analysis);
11071407 return;
11081408 }
11091409
11101410 void Analysis_process(Analysis *analysis){
1111 if(analysis->query_ac){
1112 Analysis_Client_process(analysis->query_ac, analysis, TRUE);
1113 } else if(analysis->target_ac){
1114 Analysis_Client_process(analysis->target_ac, analysis, FALSE);
1411 if(analysis->query_builder){
1412 Analysis_Builder_process(analysis->query_builder, analysis, TRUE);
1413 } else if(analysis->target_builder){
1414 Analysis_Builder_process(analysis->target_builder, analysis, FALSE);
11151415 } else {
11161416 while(FastaPipe_process(analysis->fasta_pipe, analysis));
11171417 }
1418 if(analysis->job_queue)
1419 JobQueue_complete(analysis->job_queue);
11181420 GAM_report(analysis->gam);
11191421 return;
11201422 }
22 * Analysis module for exonerate *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
2929 #include "seeder.h"
3030 #include "comparison.h"
3131 #include "socket.h"
32 #include "jobqueue.h"
3233
3334 typedef struct {
3435 gboolean use_exhaustive;
3536 gboolean use_bigseq;
37 gboolean use_revcomp;
3638 gchar *force_scan;
3739 gint saturate_threshold;
3840 gchar *custom_server_command;
41 gint thread_count;
3942 } Analysis_ArgumentSet;
4043
4144 Analysis_ArgumentSet *Analysis_ArgumentSet_create(Argument *arg);
4346 /**/
4447
4548 typedef struct {
46 SocketClient *sc;
4749 gint verbosity;
50 gint ref_count;
4851 Alphabet *server_alphabet;
4952 gboolean is_masked;
5053 guint64 num_seqs;
5154 guint64 max_seq_len;
5255 guint64 total_seq_len;
5356 /**/
57 SocketClient *sc;
5458 FastaDB *probe_fdb;
5559 Sequence *curr_query;
5660 Sequence **seq_cache;
5761 } Analysis_Client;
5862
5963 typedef struct {
64 gchar *name;
65 gint priority; /* used for job queues */
66 struct Analysis_Builder *ab;
67 } Analysis_Server;
68
69 typedef struct Analysis_Builder {
70 gint verbosity;
71 FastaDB *probe_fdb;
72 GPtrArray *server_list; /* Contains Analysis_Server objects */
73 Alphabet_Type server_type;
74 struct Analysis *analysis;
75 gboolean swap_chains;
76 } Analysis_Builder;
77
78 typedef struct Analysis {
6079 FastaPipe *fasta_pipe;
6180 GAM *gam;
6281 BSAM *bsam;
6685 gboolean scan_query;
6786 Comparison_Param *comparison_param;
6887 gint verbosity;
88 /*
6989 Analysis_Client *query_ac;
7090 Analysis_Client *target_ac;
91 */
92 Analysis_Builder *query_builder;
93 Analysis_Builder *target_builder;
94 JobQueue *job_queue;
7195 } Analysis;
7296
7397 Analysis *Analysis_create(
22 * Analysis module for exonerate *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
22 * BSAM: Big Sequence Alignment Manager *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
22 * BSAM: Big Sequence Alignment Manager *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
22 * BSAM: Big Sequence Alignment Manager *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
22 * GAM: Gapped Alignment Manager *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
161161
162162 static void GAM_display_alignment(GAM *gam,
163163 Alignment *alignment, Sequence *query, Sequence *target,
164 gint result_id, gint rank, gpointer user_data, FILE *fp);
165
166 #if 0
167 static FILE *GAM_bestn_tmp_file = NULL;
168
169 static void GAM_StoredResult_print(const gchar *string){
170 g_assert(GAM_bestn_tmp_file);
171 fprintf(GAM_bestn_tmp_file, "%s", string);
172 return;
173 }
174 #endif /* 0 */
164 gint result_id, gint rank,
165 gpointer user_data, gpointer self_data, FILE *fp);
175166
176167 static GAM_StoredResult *GAM_StoredResult_create(GAM *gam,
177168 Sequence *query, Sequence *target,
178 Alignment *alignment, gpointer user_data){
169 Alignment *alignment,
170 gpointer user_data, gpointer self_data){
179171 register GAM_StoredResult *gsr = g_new(GAM_StoredResult, 1);
180 /* register GPrintFunc prev_print_func; */
181172 gsr->score = alignment->score;
182173 gsr->pos = ftell(gam->bestn_tmp_file);
183 /*
184 GAM_bestn_tmp_file = gam->bestn_tmp_file;
185 prev_print_func = g_set_print_handler(GAM_StoredResult_print);
186 */
187174 GAM_display_alignment(gam, alignment, query, target,
188 0, -1, user_data, gam->bestn_tmp_file);
189 /* g_set_print_handler(prev_print_func); */
175 0, -1, user_data, self_data, gam->bestn_tmp_file);
190176 gsr->len = ftell(gam->bestn_tmp_file)
191177 - gsr->pos;
192178 return gsr;
267253 gam_result->query,
268254 gam_result->target,
269255 alignment,
270 gam_result->user_data);
256 gam_result->user_data,
257 gam_result->self_data);
271258 PQueue_push(gqr->pq, gsr);
272259 return;
273260 }
336323 /**/
337324
338325 static gboolean GAM_QueryResult_report_traverse_func(gpointer data,
339 gpointer user_data){
326 gpointer user_data){
340327 register GAM_StoredResult *gsr = data;
341328 register GPtrArray *result_list = user_data;
342329 g_ptr_array_add(result_list, gsr);
423410 register GAM *gam = g_new0(GAM, 1);
424411 register gint i;
425412 register C4_Span *span;
426 gam->ref_count = 1;
413 gam->thread_ref = ThreadRef_create();
427414 gam->dna_submat = Submat_share(dna_submat);
428415 gam->protein_submat = Submat_share(protein_submat);
429416 gam->translate = Translate_share(translate);
430417 gam->gas = GAM_ArgumentSet_create(NULL);
431418 if(use_exhaustive && gam->gas->use_subopt)
432419 g_warning("Exhaustively generating suboptimal alignments"
433 " will be VERY SLOW");
420 " will be VERY SLOW: use -S no");
434421 gam->query_type = query_type;
435422 gam->target_type = target_type;
436423 if(gam->gas->best_n){
445432 gam->model = Model_Type_get_model(gam->gas->type,
446433 query_type, target_type);
447434 if((!use_exhaustive) && (!C4_Model_is_local(gam->model)))
448 g_error("Cannot perform heuristic alignment using non-local model");
435 g_error("Cannot perform heuristic alignments using non-local models: use -E");
449436 gam->match_list = GAM_build_match_list(gam->model);
450437 if(use_exhaustive){
451438 gam->optimal = Optimal_create(gam->model, NULL,
479466 if(gam->max_target_span < span->max_target)
480467 gam->max_target_span = span->max_target;
481468 }
469 #ifdef USE_PTHREADS
470 pthread_mutex_init(&gam->gam_lock, NULL);
471 #endif /* USE_PTHREADS */
482472 return gam;
483473 }
484474
485475 GAM *GAM_share(GAM *gam){
486476 g_assert(gam);
487 gam->ref_count++;
477 ThreadRef_share(gam->thread_ref);
488478 return gam;
489479 }
490480
556546
557547 void GAM_destroy(GAM *gam){
558548 g_assert(gam);
559 if(--gam->ref_count)
549 if(ThreadRef_destroy(gam->thread_ref))
560550 return;
551 #ifdef USE_PTHREADS
552 pthread_mutex_destroy(&gam->gam_lock);
553 #endif /* USE_PTHREADS */
561554 g_assert(gam->model);
562555 g_ptr_array_free(gam->match_list, TRUE);
563556 C4_Model_destroy(gam->model);
638631 gam_result->target = Sequence_share(target);
639632 gam_result->user_data = Model_Type_create_data(gam->gas->type,
640633 query, target);
634 gam_result->self_data = Model_Type_create_data(gam->gas->type,
635 query, query);
641636 gam_result->subopt = SubOpt_create(query->len, target->len);
642637 return gam_result;
643638 }
11071102 /* Keep HSPs marked as keep */
11081103 hsp_id = GAM_Result_geneseed_select(comparison->dna_hspset,
11091104 gsd.fwd_keep, gsd.rev_keep, hsp_id);
1110 hsp_id = GAM_Result_geneseed_select(comparison->protein_hspset, gsd.fwd_keep, gsd.rev_keep, hsp_id);
1105 hsp_id = GAM_Result_geneseed_select(comparison->protein_hspset,
1106 gsd.fwd_keep, gsd.rev_keep, hsp_id);
11111107 hsp_id = GAM_Result_geneseed_select(comparison->codon_hspset,
11121108 gsd.fwd_keep, gsd.rev_keep, hsp_id);
11131109 /**/
11511147 /* Raise score threshold to geneseed
11521148 * to prevent low-scoring subopt alignments.
11531149 */
1150 GAM_lock(gam);
11541151 if(gam->gas->threshold < has->geneseed_threshold)
11551152 gam->gas->threshold = has->geneseed_threshold;
1153 GAM_unlock(gam);
11561154 GAM_Result_geneseed_filter(gam, comparison);
11571155 }
11581156 if(!Comparison_has_hsps(comparison))
11781176 Sequence *target){
11791177 register Alignment *alignment;
11801178 register C4_Score threshold;
1181 register GAM_Result *gam_result = GAM_Result_create(gam,
1182 query, target);
1179 register GAM_Result *gam_result;
11831180 register OPair *opair;
11841181 g_assert(gam->optimal);
1182 GAM_lock(gam);
1183 Sequence_lock(query);
1184 Sequence_lock(target);
1185 gam_result = GAM_Result_create(gam, query, target);
1186 Sequence_unlock(query);
1187 Sequence_unlock(target);
11851188 opair = OPair_create(gam->optimal, gam_result->subopt,
11861189 query->len, target->len, gam_result->user_data);
1190 GAM_unlock(gam);
11871191 if(gam->verbosity > 1)
11881192 g_message("Exhaustive alignment of [%s] [%s]",
1189 query->id, target->id);
1193 query->id, target->id);
11901194 /**/
11911195 do {
1196 GAM_lock(gam);
11921197 threshold = GAM_get_query_threshold(gam, query);
1198 GAM_unlock(gam);
11931199 alignment = OPair_next_path(opair, threshold);
11941200 if(!alignment)
11951201 break;
12231229 }
12241230 Model_Type_destroy_data(gam_result->gam->gas->type,
12251231 gam_result->user_data);
1232 Model_Type_destroy_data(gam_result->gam->gas->type,
1233 gam_result->self_data);
12261234 Sequence_destroy(gam_result->query);
12271235 Sequence_destroy(gam_result->target);
1236 GAM_lock(gam_result->gam);
12281237 GAM_destroy(gam_result->gam);
12291238 SubOpt_destroy(gam_result->subopt);
1239 GAM_unlock(gam_result->gam);
12301240 g_free(gam_result);
12311241 return;
12321242 }
12331243
12341244 static void GAM_display_alignment(GAM *gam, Alignment *alignment,
12351245 Sequence *query, Sequence *target,
1236 gint result_id, gint rank, gpointer user_data, FILE *fp){
1246 gint result_id, gint rank,
1247 gpointer user_data, gpointer self_data, FILE *fp){
12371248 if(gam->gas->show_alignment)
12381249 Alignment_display(alignment, query, target,
12391250 gam->dna_submat, gam->protein_submat,
12451256 if(gam->gas->show_vulgar)
12461257 Alignment_display_vulgar(alignment, query, target, fp);
12471258 if(gam->gas->show_query_gff)
1248 Alignment_display_gff(alignment, query, target,
1249 TRUE, FALSE, result_id, fp);
1259 Alignment_display_gff(alignment, query, target, gam->translate,
1260 TRUE, FALSE, result_id, user_data, fp);
12501261 if(gam->gas->show_target_gff)
1251 Alignment_display_gff(alignment, query, target, FALSE,
1252 Model_Type_has_genomic_target(gam->gas->type), result_id, fp);
1262 Alignment_display_gff(alignment, query, target, gam->translate,
1263 FALSE, Model_Type_has_genomic_target(gam->gas->type),
1264 result_id, user_data, fp);
12531265 if(gam->gas->ryo)
12541266 Alignment_display_ryo(alignment, query, target,
12551267 gam->gas->ryo, gam->translate, rank,
1256 user_data, fp);
1268 user_data, self_data, fp);
12571269 fflush(fp);
12581270 return;
12591271 }
12661278 alignment = gam_result->alignment_list->pdata[i];
12671279 GAM_display_alignment(gam_result->gam, alignment,
12681280 gam_result->query, gam_result->target,
1269 i+1, 0, gam_result->user_data, stdout);
1281 i+1, 0, gam_result->user_data, gam_result->self_data, stdout);
12701282 }
12711283 return;
12721284 }
12741286 void GAM_Result_submit(GAM_Result *gam_result){
12751287 register GAM_QueryResult *gqr;
12761288 g_assert(gam_result);
1289 GAM_lock(gam_result->gam);
12771290 if(gam_result->gam->gas->best_n){
12781291 gqr = g_tree_lookup(gam_result->gam->bestn_tree,
12791292 gam_result->query->id);
12891302 } else {
12901303 GAM_Result_display(gam_result);
12911304 }
1305 GAM_unlock(gam_result->gam);
1306 return;
1307 }
1308
1309 void GAM_lock(GAM *gam){
1310 #ifdef USE_PTHREADS
1311 pthread_mutex_lock(&gam->gam_lock);
1312 #endif /* USE_PTHREADS */
1313 return;
1314 }
1315
1316 void GAM_unlock(GAM *gam){
1317 #ifdef USE_PTHREADS
1318 pthread_mutex_unlock(&gam->gam_lock);
1319 #endif /* USE_PTHREADS */
12921320 return;
12931321 }
12941322
22 * GAM: Gapped Alignment Manager *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
2121
2222 #include <glib.h>
2323
24 #ifdef USE_PTHREADS
25 #include <pthread.h>
26 #endif /* USE_PTHREADS */
27
2428 #include "sequence.h"
2529 #include "c4.h"
2630 #include "heuristic.h"
3539 #include "comparison.h"
3640 #include "sdp.h"
3741 #include "subopt.h"
42 #include "threadref.h"
3843
3944 typedef enum {
4045 GAM_Refinement_NONE,
8388 } GAM_QueryInfo;
8489
8590 typedef struct {
86 gint ref_count;
91 ThreadRef *thread_ref;
8792 Alphabet_Type query_type;
8893 Alphabet_Type target_type;
8994 C4_Model *model;
105110 PQueueSet *pqueue_set;
106111 gint max_query_span;
107112 gint max_target_span;
113 #ifdef USE_PTHREADS
114 pthread_mutex_t gam_lock;
115 #endif /* USE_PTHREADS */
108116 } GAM;
109117
110118 GAM *GAM_create(Alphabet_Type query_type, Alphabet_Type target_type,
122130 Sequence *target;
123131 GPtrArray *alignment_list;
124132 gpointer user_data;
133 gpointer self_data;
125134 SubOpt *subopt;
126135 } GAM_Result;
127136
141150 void GAM_Result_destroy(GAM_Result *gam_result);
142151 void GAM_Result_submit(GAM_Result *gam_result);
143152
153 void GAM_lock(GAM *gam);
154 void GAM_unlock(GAM *gam);
155
144156 #ifdef __cplusplus
145157 }
146158 #endif /* __cplusplus */
22 * GAM: Gapped Alignment Manager *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
2525 $(top_srcdir)/src/sequence/translate.o \
2626 $(top_srcdir)/src/general/argument.o \
2727 $(top_srcdir)/src/general/lineparse.o \
28 $(top_srcdir)/src/general/threadref.o \
2829 -lm
2930
3031 ALIGNMENT_OBJ = $(top_srcdir)/src/comparison/match.o \
6969 VERSION = @VERSION@
7070 codegen_extra_ldadd = @codegen_extra_ldadd@
7171 codegen_extra_sources = @codegen_extra_sources@
72 custom_guint64_format = @custom_guint64_format@
7273 datarootdir = @datarootdir@
7374 glib_cflags = @glib_cflags@
7475 glib_libs = @glib_libs@
8586 INCLUDES = -I$(top_srcdir)/src/c4 -I$(top_srcdir)/src/bsdp -I$(top_srcdir)/src/sdp -I$(top_srcdir)/src/sequence -I$(top_srcdir)/src/general -I$(top_srcdir)/src/comparison -I$(top_srcdir)/src/struct -DSOURCE_ROOT_DIR="\"@source_root_dir@\"" -DGLIB_CFLAGS="\"@glib_cflags@\""
8687
8788
88 SEQUENCE_OBJ = $(top_srcdir)/src/struct/sparsecache.o $(top_srcdir)/src/struct/matrix.o $(top_srcdir)/src/sequence/sequence.o $(top_srcdir)/src/sequence/alphabet.o $(top_srcdir)/src/sequence/splice.o $(top_srcdir)/src/sequence/translate.o $(top_srcdir)/src/general/argument.o $(top_srcdir)/src/general/lineparse.o -lm
89 SEQUENCE_OBJ = $(top_srcdir)/src/struct/sparsecache.o $(top_srcdir)/src/struct/matrix.o $(top_srcdir)/src/sequence/sequence.o $(top_srcdir)/src/sequence/alphabet.o $(top_srcdir)/src/sequence/splice.o $(top_srcdir)/src/sequence/translate.o $(top_srcdir)/src/general/argument.o $(top_srcdir)/src/general/lineparse.o $(top_srcdir)/src/general/threadref.o -lm
8990
9091
9192 ALIGNMENT_OBJ = $(top_srcdir)/src/comparison/match.o $(top_srcdir)/src/sequence/codonsubmat.o $(top_srcdir)/src/sequence/submat.o $(SEQUENCE_OBJ)
186187 $(top_srcdir)/src/sequence/splice.o \
187188 $(top_srcdir)/src/sequence/translate.o \
188189 $(top_srcdir)/src/general/argument.o \
189 $(top_srcdir)/src/general/lineparse.o
190 $(top_srcdir)/src/general/lineparse.o \
191 $(top_srcdir)/src/general/threadref.o
190192 edit_distance_test_LDFLAGS =
191193 affine_test_OBJECTS = affine.test.o affine.o ungapped.o
192194 affine_test_DEPENDENCIES = $(top_srcdir)/src/struct/slist.o \
205207 $(top_srcdir)/src/sequence/splice.o \
206208 $(top_srcdir)/src/sequence/translate.o \
207209 $(top_srcdir)/src/general/argument.o \
208 $(top_srcdir)/src/general/lineparse.o
210 $(top_srcdir)/src/general/lineparse.o \
211 $(top_srcdir)/src/general/threadref.o
209212 affine_test_LDFLAGS =
210213 protein2dna_test_OBJECTS = protein2dna.test.o protein2dna.o affine.o \
211214 ungapped.o frameshift.o
225228 $(top_srcdir)/src/sequence/splice.o \
226229 $(top_srcdir)/src/sequence/translate.o \
227230 $(top_srcdir)/src/general/argument.o \
228 $(top_srcdir)/src/general/lineparse.o
231 $(top_srcdir)/src/general/lineparse.o \
232 $(top_srcdir)/src/general/threadref.o
229233 protein2dna_test_LDFLAGS =
230234 ner_test_OBJECTS = ner.test.o ner.o affine.o ungapped.o
231235 ner_test_DEPENDENCIES = $(top_srcdir)/src/struct/slist.o \
244248 $(top_srcdir)/src/sequence/splice.o \
245249 $(top_srcdir)/src/sequence/translate.o \
246250 $(top_srcdir)/src/general/argument.o \
247 $(top_srcdir)/src/general/lineparse.o
251 $(top_srcdir)/src/general/lineparse.o \
252 $(top_srcdir)/src/general/threadref.o
248253 ner_test_LDFLAGS =
249254 est2genome_test_OBJECTS = est2genome.test.o est2genome.o affine.o \
250255 ungapped.o intron.o
264269 $(top_srcdir)/src/sequence/splice.o \
265270 $(top_srcdir)/src/sequence/translate.o \
266271 $(top_srcdir)/src/general/argument.o \
267 $(top_srcdir)/src/general/lineparse.o
272 $(top_srcdir)/src/general/lineparse.o \
273 $(top_srcdir)/src/general/threadref.o
268274 est2genome_test_LDFLAGS =
269275 ungapped_test_OBJECTS = ungapped.test.o ungapped.o
270276 ungapped_test_DEPENDENCIES = $(top_srcdir)/src/struct/slist.o \
283289 $(top_srcdir)/src/sequence/splice.o \
284290 $(top_srcdir)/src/sequence/translate.o \
285291 $(top_srcdir)/src/general/argument.o \
286 $(top_srcdir)/src/general/lineparse.o
292 $(top_srcdir)/src/general/lineparse.o \
293 $(top_srcdir)/src/general/threadref.o
287294 ungapped_test_LDFLAGS =
288295 intron_test_OBJECTS = intron.test.o intron.o
289296 intron_test_DEPENDENCIES = $(top_srcdir)/src/struct/slist.o \
302309 $(top_srcdir)/src/sequence/splice.o \
303310 $(top_srcdir)/src/sequence/translate.o \
304311 $(top_srcdir)/src/general/argument.o \
305 $(top_srcdir)/src/general/lineparse.o
312 $(top_srcdir)/src/general/lineparse.o \
313 $(top_srcdir)/src/general/threadref.o
306314 intron_test_LDFLAGS =
307315 protein2genome_test_OBJECTS = protein2genome.test.o protein2genome.o \
308316 protein2dna.o ungapped.o intron.o affine.o frameshift.o phase.o
322330 $(top_srcdir)/src/sequence/splice.o \
323331 $(top_srcdir)/src/sequence/translate.o \
324332 $(top_srcdir)/src/general/argument.o \
325 $(top_srcdir)/src/general/lineparse.o
333 $(top_srcdir)/src/general/lineparse.o \
334 $(top_srcdir)/src/general/threadref.o
326335 protein2genome_test_LDFLAGS =
327336 coding2coding_test_OBJECTS = coding2coding.test.o coding2coding.o \
328337 affine.o ungapped.o frameshift.o
342351 $(top_srcdir)/src/sequence/splice.o \
343352 $(top_srcdir)/src/sequence/translate.o \
344353 $(top_srcdir)/src/general/argument.o \
345 $(top_srcdir)/src/general/lineparse.o
354 $(top_srcdir)/src/general/lineparse.o \
355 $(top_srcdir)/src/general/threadref.o
346356 coding2coding_test_LDFLAGS =
347357 frameshift_test_OBJECTS = frameshift.test.o frameshift.o
348358 frameshift_test_DEPENDENCIES = $(top_srcdir)/src/struct/slist.o \
361371 $(top_srcdir)/src/sequence/splice.o \
362372 $(top_srcdir)/src/sequence/translate.o \
363373 $(top_srcdir)/src/general/argument.o \
364 $(top_srcdir)/src/general/lineparse.o
374 $(top_srcdir)/src/general/lineparse.o \
375 $(top_srcdir)/src/general/threadref.o
365376 frameshift_test_LDFLAGS =
366377 coding2genome_test_OBJECTS = coding2genome.test.o coding2genome.o \
367378 coding2coding.o affine.o ungapped.o frameshift.o intron.o phase.o
381392 $(top_srcdir)/src/sequence/splice.o \
382393 $(top_srcdir)/src/sequence/translate.o \
383394 $(top_srcdir)/src/general/argument.o \
384 $(top_srcdir)/src/general/lineparse.o
395 $(top_srcdir)/src/general/lineparse.o \
396 $(top_srcdir)/src/general/threadref.o
385397 coding2genome_test_LDFLAGS =
386398 cdna2genome_test_OBJECTS = cdna2genome.test.o cdna2genome.o affine.o \
387399 ungapped.o frameshift.o intron.o phase.o coding2coding.o \
402414 $(top_srcdir)/src/sequence/splice.o \
403415 $(top_srcdir)/src/sequence/translate.o \
404416 $(top_srcdir)/src/general/argument.o \
405 $(top_srcdir)/src/general/lineparse.o
417 $(top_srcdir)/src/general/lineparse.o \
418 $(top_srcdir)/src/general/threadref.o
406419 cdna2genome_test_LDFLAGS =
407420 genome2genome_test_OBJECTS = genome2genome.test.o genome2genome.o \
408421 coding2coding.o affine.o ungapped.o frameshift.o intron.o phase.o \
423436 $(top_srcdir)/src/sequence/splice.o \
424437 $(top_srcdir)/src/sequence/translate.o \
425438 $(top_srcdir)/src/general/argument.o \
426 $(top_srcdir)/src/general/lineparse.o
439 $(top_srcdir)/src/general/lineparse.o \
440 $(top_srcdir)/src/general/threadref.o
427441 genome2genome_test_LDFLAGS =
428442 phase_test_OBJECTS = phase.test.o phase.o intron.o
429443 phase_test_DEPENDENCIES = $(top_srcdir)/src/struct/slist.o \
442456 $(top_srcdir)/src/sequence/splice.o \
443457 $(top_srcdir)/src/sequence/translate.o \
444458 $(top_srcdir)/src/general/argument.o \
445 $(top_srcdir)/src/general/lineparse.o
459 $(top_srcdir)/src/general/lineparse.o \
460 $(top_srcdir)/src/general/threadref.o
446461 phase_test_LDFLAGS =
447462 modeltype_test_OBJECTS = modeltype.test.o modeltype.o ungapped.o \
448463 affine.o est2genome.o ner.o protein2dna.o protein2genome.o \
464479 $(top_srcdir)/src/sequence/splice.o \
465480 $(top_srcdir)/src/sequence/translate.o \
466481 $(top_srcdir)/src/general/argument.o \
467 $(top_srcdir)/src/general/lineparse.o
482 $(top_srcdir)/src/general/lineparse.o \
483 $(top_srcdir)/src/general/threadref.o
468484 modeltype_test_LDFLAGS =
469485 bootstrapper_OBJECTS = bootstrapper.o modeltype.o ungapped.o affine.o \
470486 est2genome.o ner.o protein2dna.o protein2genome.o coding2coding.o \
492508 $(top_srcdir)/src/sequence/splice.o \
493509 $(top_srcdir)/src/sequence/translate.o \
494510 $(top_srcdir)/src/general/argument.o \
495 $(top_srcdir)/src/general/lineparse.o
511 $(top_srcdir)/src/general/lineparse.o \
512 $(top_srcdir)/src/general/threadref.o
496513 bootstrapper_LDFLAGS =
497514 CFLAGS = @CFLAGS@
498515 COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
22 * Module for various affine gapped models *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
22 * Module for various affine gapped models *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
22 * Module for various affine gapped models *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
22 * bootstrapper: required prior to static model linking *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
22 * cDNA <-> genomic alignment model *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
22 * cDNA <-> genomic alignment model *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
22 * cDNA <-> genomic alignment model *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
3131 query->len, target->len);
3232 score = Optimal_find_score(optimal, region, cd2gd, NULL);
3333 g_message("Score is [%d]", score);
34 g_assert(score == 1290);
34 g_assert(score == 1281);
3535 alignment = Optimal_find_path(optimal, region, cd2gd,
3636 C4_IMPOSSIBLY_LOW_SCORE, NULL);
3737 g_message("Alignment score is [%d]", alignment->score);
22 * Coding DNA comparison model *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
22 * Coding DNA comparison model *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
22 * Coding DNA comparison model *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
22 * Coding <-> Genome comparison model *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
22 * Coding <-> Genome comparison model *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
22 * Coding <-> Genome comparison model *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
22 * edit distance model *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
22 * edit distance model *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
22 * edit distance model *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
22 * Module for EST <-> genome alignments *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
22 * Module for EST <-> genome alignments *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
22 * Module for EST <-> genome alignments *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
5959 e2gd = EST2Genome_Data_create(query, target);
6060 score = Optimal_find_score(optimal, region, e2gd, NULL);
6161 g_message("Score is [%d]", score);
62 g_assert(score == 159);
62 g_assert(score == 157);
6363 /**/
6464 alignment = Optimal_find_path(optimal, region, e2gd,
6565 C4_IMPOSSIBLY_LOW_SCORE, NULL);
22 * Module for frameshift modelling *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
22 * Module for frameshift modelling *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
22 * Module for frameshift modelling *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
22 * Genome <-> Genome comparison model *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
22 * Genome <-> Genome comparison model *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
22 * Genome <-> Genome comparison model *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
22 * Module of splice site and intron modelling *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
22 * Module of splice site and intron modelling *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
22 * Module for splice site and intron modelling *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
22 * Interface for different types of alignment model *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
22 * Interface for different types of alignment model *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
22 * Interface for different types of alignment model *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
22 * Model for alignments with non-equivalenced regions *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
22 * Model for alignments with non-equivalenced regions *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
22 * Model for alignments with non-equivalenced regions *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
22 * Model for phased introns. *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
22 * Model for phased introns. *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
22 * Model for phased introns. *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
22 * Protein <-> DNA comparison model *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
22 * Protein <-> DNA comparison model *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
22 * Protein <-> DNA comparison model *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
22 * Protein <-> Genome comparison model *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
22 * Protein <-> Genome comparison model *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
22 * Protein <-> Genome comparison model *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
2929 register Region *region = Region_create(0, 0,
3030 query->len, target->len);
3131 score = Optimal_find_score(optimal, region, p2gd, NULL);
32 g_message("Score is [%d] (expect 131)", score);
33 g_assert(score == 129);
32 g_message("Score is [%d] (expect 125)", score);
33 g_assert(score == 125);
3434 alignment = Optimal_find_path(optimal, region, p2gd,
3535 C4_IMPOSSIBLY_LOW_SCORE, NULL);
3636 g_message("Alignment score is [%d]", alignment->score);
22 * Module for various ungapped alignment models *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
22 * Module for various ungapped alignment models *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
22 * Module for various ungapped alignment models *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
1111 -I$(top_srcdir)/src/hub \
1212 -I$(top_srcdir)/src/general \
1313 -DHOSTTYPE="\"@host@\"" \
14 -DSOURCE_ROOT_DIR="\"@source_root_dir@\""
14 -DSOURCE_ROOT_DIR="\"@source_root_dir@\"" \
15 -DCUSTOM_GUINT64_FORMAT="\"@custom_guint64_format@\""
1516
1617 # Missing viterb.o and scheduler.o so codegen versions may be substituted
1718 C4_OBJECTS = $(top_srcdir)/src/c4/c4.o \
5758 $(top_srcdir)/src/general/argument.o \
5859 $(top_srcdir)/src/general/lineparse.o \
5960 $(top_srcdir)/src/general/socket.o \
61 $(top_srcdir)/src/general/jobqueue.o \
6062 $(top_srcdir)/src/comparison/match.o \
6163 $(top_srcdir)/src/sequence/submat.o \
6264 $(top_srcdir)/src/sequence/codonsubmat.o
9597 $(top_srcdir)/src/hub/bsam.o \
9698 $(top_srcdir)/src/hub/analysis.o \
9799 $(top_srcdir)/src/general/compoundfile.o \
100 $(top_srcdir)/src/general/threadref.o \
98101 $(C4_OBJECTS)
99102
100103 exonerate_SOURCES = exonerate.c
156159 $(top_srcdir)/src/sequence/codonsubmat.o \
157160 $(top_srcdir)/src/general/compoundfile.o \
158161 $(top_srcdir)/src/general/lineparse.o \
162 $(top_srcdir)/src/general/threadref.o \
159163 -lm
160164
161165 CLEANFILES = $(EXTRA_exonerate_SOURCES) @codegen_extra_sources@ \
6969 VERSION = @VERSION@
7070 codegen_extra_ldadd = @codegen_extra_ldadd@
7171 codegen_extra_sources = @codegen_extra_sources@
72 custom_guint64_format = @custom_guint64_format@
7273 datarootdir = @datarootdir@
7374 glib_cflags = @glib_cflags@
7475 glib_libs = @glib_libs@
7980
8081 bin_PROGRAMS = exonerate ipcress exonerate-server
8182
82 INCLUDES = -I$(top_srcdir)/src/sequence -I$(top_srcdir)/src/database -I$(top_srcdir)/src/comparison -I$(top_srcdir)/src/struct -I$(top_srcdir)/src/c4 -I$(top_srcdir)/src/bsdp -I$(top_srcdir)/src/sdp -I$(top_srcdir)/src/model -I$(top_srcdir)/src/hub -I$(top_srcdir)/src/general -DHOSTTYPE="\"@host@\"" -DSOURCE_ROOT_DIR="\"@source_root_dir@\""
83 INCLUDES = -I$(top_srcdir)/src/sequence -I$(top_srcdir)/src/database -I$(top_srcdir)/src/comparison -I$(top_srcdir)/src/struct -I$(top_srcdir)/src/c4 -I$(top_srcdir)/src/bsdp -I$(top_srcdir)/src/sdp -I$(top_srcdir)/src/model -I$(top_srcdir)/src/hub -I$(top_srcdir)/src/general -DHOSTTYPE="\"@host@\"" -DSOURCE_ROOT_DIR="\"@source_root_dir@\"" -DCUSTOM_GUINT64_FORMAT="\"@custom_guint64_format@\""
8384
8485
8586 # Missing viterb.o and scheduler.o so codegen versions may be substituted
86 C4_OBJECTS = $(top_srcdir)/src/c4/c4.o $(top_srcdir)/src/c4/codegen.o $(top_srcdir)/src/c4/cgutil.o $(top_srcdir)/src/c4/opair.o $(top_srcdir)/src/c4/alignment.o $(top_srcdir)/src/c4/optimal.o $(top_srcdir)/src/c4/layout.o $(top_srcdir)/src/c4/region.o $(top_srcdir)/src/c4/subopt.o $(top_srcdir)/src/bsdp/bsdp.o $(top_srcdir)/src/bsdp/sar.o $(top_srcdir)/src/bsdp/heuristic.o $(top_srcdir)/src/bsdp/hpair.o $(top_srcdir)/src/sdp/boundary.o $(top_srcdir)/src/sdp/sdp.o $(top_srcdir)/src/sdp/lookahead.o $(top_srcdir)/src/sdp/straceback.o $(top_srcdir)/src/struct/matrix.o $(top_srcdir)/src/struct/slist.o $(top_srcdir)/src/struct/pqueue.o $(top_srcdir)/src/struct/recyclebin.o $(top_srcdir)/src/struct/rangetree.o $(top_srcdir)/src/sequence/sequence.o $(top_srcdir)/src/sequence/alphabet.o $(top_srcdir)/src/sequence/translate.o $(top_srcdir)/src/sequence/splice.o $(top_srcdir)/src/model/affine.o $(top_srcdir)/src/model/est2genome.o $(top_srcdir)/src/model/ner.o $(top_srcdir)/src/model/protein2dna.o $(top_srcdir)/src/model/protein2genome.o $(top_srcdir)/src/model/coding2coding.o $(top_srcdir)/src/model/coding2genome.o $(top_srcdir)/src/model/cdna2genome.o $(top_srcdir)/src/model/genome2genome.o $(top_srcdir)/src/model/ungapped.o $(top_srcdir)/src/model/intron.o $(top_srcdir)/src/model/frameshift.o $(top_srcdir)/src/model/phase.o $(top_srcdir)/src/model/modeltype.o $(top_srcdir)/src/general/argument.o $(top_srcdir)/src/general/lineparse.o $(top_srcdir)/src/general/socket.o $(top_srcdir)/src/comparison/match.o $(top_srcdir)/src/sequence/submat.o $(top_srcdir)/src/sequence/codonsubmat.o
87 C4_OBJECTS = $(top_srcdir)/src/c4/c4.o $(top_srcdir)/src/c4/codegen.o $(top_srcdir)/src/c4/cgutil.o $(top_srcdir)/src/c4/opair.o $(top_srcdir)/src/c4/alignment.o $(top_srcdir)/src/c4/optimal.o $(top_srcdir)/src/c4/layout.o $(top_srcdir)/src/c4/region.o $(top_srcdir)/src/c4/subopt.o $(top_srcdir)/src/bsdp/bsdp.o $(top_srcdir)/src/bsdp/sar.o $(top_srcdir)/src/bsdp/heuristic.o $(top_srcdir)/src/bsdp/hpair.o $(top_srcdir)/src/sdp/boundary.o $(top_srcdir)/src/sdp/sdp.o $(top_srcdir)/src/sdp/lookahead.o $(top_srcdir)/src/sdp/straceback.o $(top_srcdir)/src/struct/matrix.o $(top_srcdir)/src/struct/slist.o $(top_srcdir)/src/struct/pqueue.o $(top_srcdir)/src/struct/recyclebin.o $(top_srcdir)/src/struct/rangetree.o $(top_srcdir)/src/sequence/sequence.o $(top_srcdir)/src/sequence/alphabet.o $(top_srcdir)/src/sequence/translate.o $(top_srcdir)/src/sequence/splice.o $(top_srcdir)/src/model/affine.o $(top_srcdir)/src/model/est2genome.o $(top_srcdir)/src/model/ner.o $(top_srcdir)/src/model/protein2dna.o $(top_srcdir)/src/model/protein2genome.o $(top_srcdir)/src/model/coding2coding.o $(top_srcdir)/src/model/coding2genome.o $(top_srcdir)/src/model/cdna2genome.o $(top_srcdir)/src/model/genome2genome.o $(top_srcdir)/src/model/ungapped.o $(top_srcdir)/src/model/intron.o $(top_srcdir)/src/model/frameshift.o $(top_srcdir)/src/model/phase.o $(top_srcdir)/src/model/modeltype.o $(top_srcdir)/src/general/argument.o $(top_srcdir)/src/general/lineparse.o $(top_srcdir)/src/general/socket.o $(top_srcdir)/src/general/jobqueue.o $(top_srcdir)/src/comparison/match.o $(top_srcdir)/src/sequence/submat.o $(top_srcdir)/src/sequence/codonsubmat.o
8788
8889
8990 EXTRA_exonerate_SOURCES = c4_model_archive.a c4_model_archive.h
9192 BUILT_SOURCES = c4_model_archive.a
9293 BOOTSTRAPPER = $(top_srcdir)/src/model/bootstrapper
9394
94 exonerate_COMPONENTS = @codegen_extra_ldadd@ $(top_srcdir)/src/comparison/wordhood.o $(top_srcdir)/src/comparison/hspset.o $(top_srcdir)/src/comparison/seeder.o $(top_srcdir)/src/comparison/comparison.o $(top_srcdir)/src/database/fastapipe.o $(top_srcdir)/src/database/fastadb.o $(top_srcdir)/src/struct/dejavu.o $(top_srcdir)/src/struct/fsm.o $(top_srcdir)/src/struct/vfsm.o $(top_srcdir)/src/struct/sparsecache.o $(top_srcdir)/src/hub/gam.o $(top_srcdir)/src/hub/bsam.o $(top_srcdir)/src/hub/analysis.o $(top_srcdir)/src/general/compoundfile.o $(C4_OBJECTS)
95 exonerate_COMPONENTS = @codegen_extra_ldadd@ $(top_srcdir)/src/comparison/wordhood.o $(top_srcdir)/src/comparison/hspset.o $(top_srcdir)/src/comparison/seeder.o $(top_srcdir)/src/comparison/comparison.o $(top_srcdir)/src/database/fastapipe.o $(top_srcdir)/src/database/fastadb.o $(top_srcdir)/src/struct/dejavu.o $(top_srcdir)/src/struct/fsm.o $(top_srcdir)/src/struct/vfsm.o $(top_srcdir)/src/struct/sparsecache.o $(top_srcdir)/src/hub/gam.o $(top_srcdir)/src/hub/bsam.o $(top_srcdir)/src/hub/analysis.o $(top_srcdir)/src/general/compoundfile.o $(top_srcdir)/src/general/threadref.o $(C4_OBJECTS)
9596
9697
9798 exonerate_SOURCES = exonerate.c
105106 # Files to clear away
106107
107108 exonerate_server_SOURCES = exonerate-server.c
108 exonerate_server_LDADD = $(top_srcdir)/src/general/socket.o $(top_srcdir)/src/general/argument.o $(top_srcdir)/src/comparison/hspset.o $(top_srcdir)/src/comparison/match.o $(top_srcdir)/src/comparison/wordhood.o $(top_srcdir)/src/database/dataset.o $(top_srcdir)/src/database/index.o $(top_srcdir)/src/database/fastadb.o $(top_srcdir)/src/struct/bitarray.o $(top_srcdir)/src/struct/sparsecache.o $(top_srcdir)/src/struct/matrix.o $(top_srcdir)/src/struct/splaytree.o $(top_srcdir)/src/struct/noitree.o $(top_srcdir)/src/struct/vfsm.o $(top_srcdir)/src/struct/pqueue.o $(top_srcdir)/src/struct/rangetree.o $(top_srcdir)/src/struct/recyclebin.o $(top_srcdir)/src/sequence/sequence.o $(top_srcdir)/src/sequence/alphabet.o $(top_srcdir)/src/sequence/translate.o $(top_srcdir)/src/sequence/splice.o $(top_srcdir)/src/sequence/submat.o $(top_srcdir)/src/sequence/codonsubmat.o $(top_srcdir)/src/general/compoundfile.o $(top_srcdir)/src/general/lineparse.o -lm
109 exonerate_server_LDADD = $(top_srcdir)/src/general/socket.o $(top_srcdir)/src/general/argument.o $(top_srcdir)/src/comparison/hspset.o $(top_srcdir)/src/comparison/match.o $(top_srcdir)/src/comparison/wordhood.o $(top_srcdir)/src/database/dataset.o $(top_srcdir)/src/database/index.o $(top_srcdir)/src/database/fastadb.o $(top_srcdir)/src/struct/bitarray.o $(top_srcdir)/src/struct/sparsecache.o $(top_srcdir)/src/struct/matrix.o $(top_srcdir)/src/struct/splaytree.o $(top_srcdir)/src/struct/noitree.o $(top_srcdir)/src/struct/vfsm.o $(top_srcdir)/src/struct/pqueue.o $(top_srcdir)/src/struct/rangetree.o $(top_srcdir)/src/struct/recyclebin.o $(top_srcdir)/src/sequence/sequence.o $(top_srcdir)/src/sequence/alphabet.o $(top_srcdir)/src/sequence/translate.o $(top_srcdir)/src/sequence/splice.o $(top_srcdir)/src/sequence/submat.o $(top_srcdir)/src/sequence/codonsubmat.o $(top_srcdir)/src/general/compoundfile.o $(top_srcdir)/src/general/lineparse.o $(top_srcdir)/src/general/threadref.o -lm
109110
110111
111112 CLEANFILES = $(EXTRA_exonerate_SOURCES) @codegen_extra_sources@ @codegen_extra_ld_add@
159160 $(top_srcdir)/src/sequence/splice.o $(top_srcdir)/src/sequence/submat.o \
160161 $(top_srcdir)/src/sequence/codonsubmat.o \
161162 $(top_srcdir)/src/general/compoundfile.o \
162 $(top_srcdir)/src/general/lineparse.o
163 $(top_srcdir)/src/general/lineparse.o \
164 $(top_srcdir)/src/general/threadref.o
163165 exonerate_server_LDFLAGS =
164166 CFLAGS = @CFLAGS@
165167 COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
22 * The exonerate server *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
6565 if(preload)
6666 Dataset_preload_seqs(exonerate_server->dataset);
6767 exonerate_server->verbosity = verbosity;
68 if(verbosity >= 1){
69 Dataset_info(exonerate_server->dataset);
70 Index_info(exonerate_server->index);
71 }
6872 return exonerate_server;
6973 }
7074
9296 gint dna_hsp_threshold;
9397 gint protein_hsp_threshold;
9498 gint codon_hsp_threshold;
99 gint dna_word_limit;
100 gint protein_word_limit;
101 gint codon_word_limit;
95102 gint dna_hsp_dropoff;
96103 gint protein_hsp_dropoff;
97104 gint codon_hsp_dropoff;
117124 connection->dna_hsp_threshold = has->dna_hsp_threshold;
118125 connection->protein_hsp_threshold = has->protein_hsp_threshold;
119126 connection->codon_hsp_threshold = has->codon_hsp_threshold;
127 connection->dna_word_limit = has->dna_word_limit;
128 connection->protein_word_limit = has->protein_word_limit;
129 connection->codon_word_limit = has->codon_word_limit;
120130 connection->dna_hsp_dropoff = has->dna_hsp_dropoff;
121131 connection->protein_hsp_dropoff = has->protein_hsp_dropoff;
122132 connection->codon_hsp_dropoff = has->codon_hsp_dropoff;
142152 /**/
143153
144154 static gpointer Exonerate_Server_Connection_open(gpointer user_data){
145 g_message("[%s]", __FUNCTION__);
146155 return Exonerate_Server_Connection_create();
147156 }
148157
150159 gpointer user_data){
151160 register Exonerate_Server_Connection *server_connection
152161 = connection_data;
153 g_message("[%s]", __FUNCTION__);
154162 Exonerate_Server_Connection_destroy(server_connection);
155163 return;
156164 }
220228 "\n"
221229 " valid parameters:\n"
222230 " seedrepeat\n"
231 "\n"
223232 " dnahspthreshold\n"
224233 " proteinhspthreshold\n"
225234 " codonhspthreshold\n"
235 "\n"
236 " dnawordlimit\n"
237 " proteinwordlimit\n"
238 " codonwordlimit\n"
226239 "\n"
227240 " geneseedthreshold\n"
228241 " geneseedrepeat\n"
391404 HSP_Param_set_codon_hsp_threshold(connection->hsp_param,
392405 connection->codon_hsp_threshold);
393406 /**/
407 HSP_Param_set_dna_word_limit(connection->hsp_param,
408 connection->dna_word_limit);
409 HSP_Param_set_protein_word_limit(connection->hsp_param,
410 connection->protein_word_limit);
411 HSP_Param_set_codon_word_limit(connection->hsp_param,
412 connection->codon_word_limit);
413 /**/
394414 HSP_Param_set_dna_hsp_dropoff(connection->hsp_param,
395415 connection->dna_hsp_dropoff);
396416 HSP_Param_set_protein_hsp_dropoff(connection->hsp_param,
452472 if(connection->hsp_param)
453473 HSP_Param_set_codon_hsp_threshold(connection->hsp_param,
454474 codonhspthreshold);
475 return g_strdup_printf("ok: set\n");
476 }
477
478 /**/
479
480 static gchar *Exonerate_Server_set_param_dnawordlimit(
481 Exonerate_Server_Connection *connection, GPtrArray *word_list){
482 register gint dnawordlimit = atoi(word_list->pdata[3]);
483 if(dnawordlimit < 0)
484 return g_strdup_printf("error: dnawordlimit must be >= 0\n");
485 connection->dna_word_limit = dnawordlimit;
486 if(connection->hsp_param)
487 HSP_Param_set_dna_word_limit(connection->hsp_param, dnawordlimit);
488 return g_strdup_printf("ok: set\n");
489 }
490
491 static gchar *Exonerate_Server_set_param_proteinwordlimit(
492 Exonerate_Server_Connection *connection, GPtrArray *word_list){
493 register gint proteinwordlimit = atoi(word_list->pdata[3]);
494 if(proteinwordlimit < 0)
495 return g_strdup_printf("error: proteinwordlimit must be >= 0\n");
496 connection->protein_word_limit = proteinwordlimit;
497 if(connection->hsp_param)
498 HSP_Param_set_protein_word_limit(connection->hsp_param,
499 proteinwordlimit);
500 return g_strdup_printf("ok: set\n");
501 }
502
503 static gchar *Exonerate_Server_set_param_codonwordlimit(
504 Exonerate_Server_Connection *connection, GPtrArray *word_list){
505 register gint codonwordlimit = atoi(word_list->pdata[3]);
506 if(codonwordlimit < 0)
507 return g_strdup_printf("error: codonwordlimit must be >= 0\n");
508 connection->codon_word_limit = codonwordlimit;
509 if(connection->hsp_param)
510 HSP_Param_set_codon_word_limit(connection->hsp_param,
511 codonwordlimit);
455512 return g_strdup_printf("ok: set\n");
456513 }
457514
544601 } else if(!strcmp(name, "codonhspthreshold")){
545602 reply = Exonerate_Server_set_param_codonhspthreshold(connection,
546603 word_list);
604 } else if(!strcmp(name, "dnawordlimit")){
605 reply = Exonerate_Server_set_param_dnawordlimit(connection,
606 word_list);
607 } else if(!strcmp(name, "proteinwordlimit")){
608 reply = Exonerate_Server_set_param_proteinwordlimit(connection,
609 word_list);
610 } else if(!strcmp(name, "codonwordlimit")){
611 reply = Exonerate_Server_set_param_codonwordlimit(connection,
612 word_list);
547613 } else if(!strcmp(name, "dnahspdropoff")){
548614 reply = Exonerate_Server_set_param_dnahspdropoff(connection, word_list);
549615 } else if(!strcmp(name, "proteinhspdropoff")){
599665 (*reply) = NULL;
600666 keep_connection = FALSE;
601667 } else if(!strcmp(word, "dbinfo")){
602 (*reply) = g_strdup_printf("dbinfo: %s %s %lld %lld %lld\n",
668 (*reply) = g_strdup_printf("dbinfo: %s %s"
669 " %" CUSTOM_GUINT64_FORMAT
670 " %" CUSTOM_GUINT64_FORMAT
671 " %" CUSTOM_GUINT64_FORMAT "\n",
603672 (server->dataset->header->type & 1)?"dna":"protein",
604673 (server->dataset->header->type & (1<<1))
605674 ?"softmasked":"unmasked",
22 * exonerate : a generic sequence comparison tool *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
7676 Argument_parse_int, &verbosity);
7777 /**/
7878 Argument_absorb_ArgumentSet(arg, as_input);
79 Translate_ArgumentSet_create(arg);
7980 Analysis_ArgumentSet_create(arg);
8081 FastaDB_ArgumentSet_create(arg);
8182 GAM_ArgumentSet_create(arg);
9394 Intron_ArgumentSet_create(arg);
9495 Frameshift_ArgumentSet_create(arg);
9596 Alphabet_ArgumentSet_create(arg);
96 Translate_ArgumentSet_create(arg);
9797 HSPset_ArgumentSet_create(arg);
9898 Alignment_ArgumentSet_create(arg);
9999 SAR_ArgumentSet_create(arg);
101101 /**/
102102 Argument_process(arg, "exonerate",
103103 "A generic sequence comparison tool\n"
104 "Guy St.C. Slater. guy@ebi.ac.uk. 2000-2008.\n",
104 "Guy St.C. Slater. guy@ebi.ac.uk. 2000-2009.\n",
105105 "\n"
106106 "Examples of use:\n"
107107 "\n"
135135 return 0;
136136 }
137137
138 /**/
139
22 * ipcress : in-silico PCR experiment simulation system *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
2222 $(top_srcdir)/src/sequence/translate.o \
2323 $(top_srcdir)/src/general/argument.o \
2424 $(top_srcdir)/src/general/lineparse.o \
25 $(top_srcdir)/src/general/threadref.o \
2526 -lm
2627
2728 C4_OBJ = $(top_srcdir)/src/c4/c4.o \
6969 VERSION = @VERSION@
7070 codegen_extra_ldadd = @codegen_extra_ldadd@
7171 codegen_extra_sources = @codegen_extra_sources@
72 custom_guint64_format = @custom_guint64_format@
7273 datarootdir = @datarootdir@
7374 glib_cflags = @glib_cflags@
7475 glib_libs = @glib_libs@
8788
8889 noinst_HEADERS = scheduler.h sdp.h lookahead.h boundary.h straceback.h
8990
90 SEQUENCE_OBJ = $(top_srcdir)/src/struct/sparsecache.o $(top_srcdir)/src/struct/matrix.o $(top_srcdir)/src/sequence/sequence.o $(top_srcdir)/src/sequence/alphabet.o $(top_srcdir)/src/sequence/splice.o $(top_srcdir)/src/sequence/translate.o $(top_srcdir)/src/general/argument.o $(top_srcdir)/src/general/lineparse.o -lm
91 SEQUENCE_OBJ = $(top_srcdir)/src/struct/sparsecache.o $(top_srcdir)/src/struct/matrix.o $(top_srcdir)/src/sequence/sequence.o $(top_srcdir)/src/sequence/alphabet.o $(top_srcdir)/src/sequence/splice.o $(top_srcdir)/src/sequence/translate.o $(top_srcdir)/src/general/argument.o $(top_srcdir)/src/general/lineparse.o $(top_srcdir)/src/general/threadref.o -lm
9192
9293
9394 C4_OBJ = $(top_srcdir)/src/c4/c4.o $(top_srcdir)/src/c4/alignment.o $(top_srcdir)/src/c4/optimal.o $(top_srcdir)/src/c4/codegen.o $(top_srcdir)/src/c4/region.o $(top_srcdir)/src/c4/layout.o $(top_srcdir)/src/c4/viterbi.o $(top_srcdir)/src/c4/subopt.o $(top_srcdir)/src/c4/cgutil.o
149150 $(top_srcdir)/src/sequence/splice.o \
150151 $(top_srcdir)/src/sequence/translate.o \
151152 $(top_srcdir)/src/general/argument.o \
152 $(top_srcdir)/src/general/lineparse.o
153 $(top_srcdir)/src/general/lineparse.o \
154 $(top_srcdir)/src/general/threadref.o
153155 sdp_test_LDFLAGS =
154156 lookahead_test_OBJECTS = lookahead.test.o lookahead.o
155157 lookahead_test_LDADD = $(LDADD)
176178 $(top_srcdir)/src/sequence/splice.o \
177179 $(top_srcdir)/src/sequence/translate.o \
178180 $(top_srcdir)/src/general/argument.o \
179 $(top_srcdir)/src/general/lineparse.o
181 $(top_srcdir)/src/general/lineparse.o \
182 $(top_srcdir)/src/general/threadref.o
180183 scheduler_test_LDFLAGS =
181184 straceback_test_OBJECTS = straceback.test.o straceback.o
182185 straceback_test_DEPENDENCIES = $(top_srcdir)/src/struct/recyclebin.o \
191194 $(top_srcdir)/src/sequence/splice.o \
192195 $(top_srcdir)/src/sequence/translate.o \
193196 $(top_srcdir)/src/general/argument.o \
194 $(top_srcdir)/src/general/lineparse.o
197 $(top_srcdir)/src/general/lineparse.o \
198 $(top_srcdir)/src/general/threadref.o
195199 straceback_test_LDFLAGS =
196200 CFLAGS = @CFLAGS@
197201 COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
22 * C4 dynamic programming library - Boundary Object *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
22 * C4 dynamic programming library - Boundary Object *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
22 * C4 dynamic programming library - Boundary Object *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
22 * C4 dynamic programming library - SDP Lookahead Object *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
22 * C4 dynamic programming library - SDP Lookahead Object *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
22 * C4 dynamic programming library - SDP Lookahead Object *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
22 * C4 dynamic programming library - DP Scheduler *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
22 * C4 dynamic programming library - DP Scheduler *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
22 * C4 dynamic programming library - DP Scheduler *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
22 * C4 dynamic programming library - Seeded Dynamic Programming *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
299299 register SDP *sdp = g_new0(SDP, 1);
300300 register C4_Portal *portal;
301301 /**/
302 sdp->ref_count = 1;
302 sdp->thread_ref = ThreadRef_create();
303303 sdp->sas = SDP_ArgumentSet_create(NULL);
304304 g_assert(model);
305305 g_assert(!model->is_open);
355355
356356 SDP *SDP_share(SDP *sdp){
357357 g_assert(sdp);
358 sdp->ref_count++;
358 ThreadRef_share(sdp->thread_ref);
359359 return sdp;
360360 }
361361
362362 void SDP_destroy(SDP *sdp){
363363 g_assert(sdp);
364 if(--sdp->ref_count)
364 if(ThreadRef_destroy(sdp->thread_ref))
365365 return;
366366 if(sdp->find_starts_scheduler)
367367 Scheduler_destroy(sdp->find_starts_scheduler);
22 * C4 dynamic programming library - Seeded Dynamic Programming *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
3232 #include "sparsecache.h"
3333 #include "boundary.h"
3434 #include "scheduler.h"
35 #include "threadref.h"
3536
3637 /**/
3738
6566 /**/
6667
6768 typedef struct {
68 gint ref_count;
69 ThreadRef *thread_ref;
6970 SDP_ArgumentSet *sas;
7071 C4_Model *model;
7172 gboolean use_boundary;
22 * C4 dynamic programming library - Seeded Dynamic Programming *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
22 * C4 dynamic programming library - Scheduler Traceback *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
22 * C4 dynamic programming library - Scheduler Traceback *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
22 * C4 dynamic programming library - Scheduler Traceback *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
6969 VERSION = @VERSION@
7070 codegen_extra_ldadd = @codegen_extra_ldadd@
7171 codegen_extra_sources = @codegen_extra_sources@
72 custom_guint64_format = @custom_guint64_format@
7273 datarootdir = @datarootdir@
7374 glib_cflags = @glib_cflags@
7475 glib_libs = @glib_libs@
22 * Simple Alphabet Object *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
150150 register Alphabet *a = g_new0(Alphabet, 1);
151151 a->ref_count = 1;
152152 a->type = type;
153 a->is_soft_masked = is_soft_masked;
153154 /* Set look-up tables */
154155 a->unmasked = Alphabet_Filter_get(Alphabet_Filter_TO_UPPER);
155156 if(is_soft_masked){
371372 return short_names[index[(guchar)aa]];
372373 }
373374
375 gchar *Alphabet_nt2ambig(gchar nt){
376 static gchar *ambig[16] = {
377 /* - */ NULL,
378 /* G */ "G",
379 /* A */ "A",
380 /* R */ "AG",
381 /* T */ "T",
382 /* K */ "GT",
383 /* W */ "AT",
384 /* D */ "AGT",
385 /* C */ "C",
386 /* S */ "CG",
387 /* M */ "AC",
388 /* V */ "ACG",
389 /* Y */ "CT",
390 /* B */ "CGT",
391 /* H */ "ACT",
392 /* N */ "ACGT"
393 };
394 static guchar index[(1<<8)] = { /* GARTKWDCSMVYBHN */
395 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
396 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
397 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
398 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
399 0, 2, 13, 8, 7, 0, 0, 1, 14, 0, 0, 5, 0, 10, 15, 0,
400 0, 0, 3, 9, 4, 0, 11, 6, 0, 12, 0, 0, 0, 0, 0, 0,
401 0, 2, 13, 8, 7, 0, 0, 1, 14, 0, 0, 5, 0, 10, 15, 0,
402 0, 0, 3, 9, 4, 0, 11, 6, 0, 12, 0, 0, 0, 0, 0, 0,
403 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
404 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
405 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
406 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
407 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
408 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
409 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
410 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
411 };
412 g_assert(index[(guchar)nt]);
413 return ambig[index[(guchar)nt]];
414 }
415
22 * Simple Alphabet Object *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
4848
4949 typedef struct {
5050 gint ref_count;
51 gboolean is_soft_masked;
5152 guchar *member;
5253 Alphabet_Type type;
5354 guchar *is_member;
112113 /* Give three-letter-abbreviation for amino acid.
113114 * eg 'M' -> "Met" etc */
114115
116 gchar *Alphabet_nt2ambig(gchar nt);
117 /* Returns the ambiguity bases for the given nucleotide
118 * The returned string does not need to be freed.
119 */
120
121
115122 /**/
116123
117124 #ifdef __cplusplus
22 * Simple Alphabet Object *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
22 * Codon Substutition Matrix Object *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
22 * Codon Substitution Matrix Object *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
22 * Codon Substitution Matrix Object *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
22 * Simple Sequence Object *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
180180 ? g_tree_lookup(sas->annotation_tree, s->id)
181181 : NULL;
182182 s->len = len;
183 #ifdef USE_PTHREADS
184 pthread_mutex_init(&s->seq_lock, NULL);
185 #endif /* USE_PTHREADS */
183186 return s;
184187 }
185188
235238
236239 Sequence *Sequence_share(Sequence *s){
237240 g_assert(s);
241 Sequence_lock(s);
238242 g_assert(s->ref_count);
239243 s->ref_count++;
244 Sequence_unlock(s);
240245 return s;
241246 }
242247
539544
540545 /**/
541546
547 #if 0
542548 static void Sequence_print_type(Sequence *s){
543549 register Sequence_Subseq *subseq;
544550 register Sequence *revcomp;
579585 }
580586 return;
581587 }
588 #endif /* 0 */
589
582590
583591 void Sequence_strncpy(Sequence *s, gint start, gint length, gchar *dst){
584592 register gint i;
646654
647655 void Sequence_destroy(Sequence *s){
648656 g_assert(s);
649 if(--s->ref_count)
657 #ifdef USE_PTHREADS
658 pthread_mutex_lock(&s->seq_lock);
659 #endif /* USE_PTHREADS */
660 if(--s->ref_count){
661 #ifdef USE_PTHREADS
662 pthread_mutex_unlock(&s->seq_lock);
663 #endif /* USE_PTHREADS */
650664 return;
665 }
666 #ifdef USE_PTHREADS
667 pthread_mutex_unlock(&s->seq_lock);
668 #endif /* USE_PTHREADS */
651669 if(s->id)
652670 g_free(s->id);
653671 if(s->def)
678696 }
679697 }
680698 Alphabet_destroy(s->alphabet);
699 #ifdef USE_PTHREADS
700 pthread_mutex_destroy(&s->seq_lock);
701 #endif /* USE_PTHREADS */
681702 g_free(s);
682703 return;
683704 }
784805 }
785806
786807
808 void Sequence_lock(Sequence *s){
809 register Sequence_Subseq *subseq;
810 register Sequence_Filter *filter;
811 register Sequence_Translation *translation;
812 register Sequence *revcomp;
813 g_assert(s);
814 #ifdef USE_PTHREADS
815 pthread_mutex_lock(&s->seq_lock);
816 if(s->data){
817 switch(s->type){
818 case Sequence_Type_INTMEM:
819 break;
820 case Sequence_Type_EXTMEM:
821 break;
822 case Sequence_Type_SUBSEQ:
823 subseq = s->data;
824 Sequence_lock(subseq->sequence);
825 break;
826 case Sequence_Type_REVCOMP:
827 revcomp = s->data;
828 Sequence_lock(revcomp);
829 break;
830 case Sequence_Type_FILTER:
831 filter = s->data;
832 Sequence_lock(filter->sequence);
833 break;
834 case Sequence_Type_TRANSLATE:
835 translation = s->data;
836 Sequence_lock(translation->sequence);
837 break;
838 default:
839 g_error("Unknown Sequence type [%d]", s->type);
840 break;
841 }
842 }
843 #endif /* USE_PTHREADS */
844 return;
845 }
846
847 void Sequence_unlock(Sequence *s){
848 register Sequence_Subseq *subseq;
849 register Sequence_Filter *filter;
850 register Sequence_Translation *translation;
851 register Sequence *revcomp;
852 g_assert(s);
853 #ifdef USE_PTHREADS
854 pthread_mutex_unlock(&s->seq_lock);
855 if(s->data){
856 switch(s->type){
857 case Sequence_Type_INTMEM:
858 break;
859 case Sequence_Type_EXTMEM:
860 break;
861 case Sequence_Type_SUBSEQ:
862 subseq = s->data;
863 Sequence_unlock(subseq->sequence);
864 break;
865 case Sequence_Type_REVCOMP:
866 revcomp = s->data;
867 Sequence_unlock(revcomp);
868 break;
869 case Sequence_Type_FILTER:
870 filter = s->data;
871 Sequence_unlock(filter->sequence);
872 break;
873 case Sequence_Type_TRANSLATE:
874 translation = s->data;
875 Sequence_unlock(translation->sequence);
876 break;
877 default:
878 g_error("Unknown Sequence type [%d]", s->type);
879 break;
880 }
881 }
882 #endif /* USE_PTHREADS */
883 return;
884 }
885
886
887
22 * Simple Sequence Object *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
2121
2222 #include <stdio.h>
2323 #include <glib.h>
24
25 #ifdef USE_PTHREADS
26 #include <pthread.h>
27 #endif /* USE_PTHREADS */
2428
2529 #include "alphabet.h"
2630 #include "translate.h"
8286 gpointer data;
8387 Sequence_Type type;
8488 gint (*get_symbol)(gpointer data, gint pos);
89 #ifdef USE_PTHREADS
90 pthread_mutex_t seq_lock;
91 #endif /* USE_PTHREADS */
8592 } Sequence;
8693
8794 #define Sequence_get_symbol(sequence, pos) \
133140 Sequence *Sequence_translate(Sequence *s, Translate *translate, gint frame);
134141
135142 Sequence *Sequence_mask(Sequence *s);
143 void Sequence_lock(Sequence *s);
144 void Sequence_unlock(Sequence *s);
136145
137146 /**/
138147
22 * Simple Sequence Object *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
22 * Library for Splice site prediction. *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
281281 for(j = 0; j < 4; j++){
282282 sp->model_data[i][j] = (((gfloat)(1+sp->model_data[i][j]))
283283 /((25.0+1.0)));
284 sp->model_data[i][j] = log(sp->model_data[i][j]) * 2.0;
284 sp->model_data[i][j] = log(sp->model_data[i][j]) * 1.5;
285285 }
286286 sp->model_data[i][4] = 0.0;
287287 }
22 * Library for Splice site prediction. *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
22 * Library for Splice site prediction. *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
22 * Substutition Matrix Object *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
265265 }
266266 break;
267267 case '0': case '1': case '2': case '3': case '4':
268 case '5': case '6': case '7': case '8': case '9':
268 case '5': case '6': case '7': case '8': case '9':
269269 num *= 10;
270270 num += (ch-'0');
271271 seen = TRUE;
22 * Substitution Matrix Object *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
22 * Substitution Matrix Object *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
22 * Nucleotide Translation Code *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
1919 #include "translate.h"
2020
2121 /* ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
22 CTAG
2223 0 - 0000 - blank Representation of Nucleotides
2324 1 G 0001 C -----------------------------
2425 2 A 0010 T
7172 "pon", "jihP", "fCcd", "rHmpi", "xfrj", "Xx*" };
7273 for(i = 0; i < Translate_AA_SET_SIZE; i++)
7374 t->aa2d[t->aa[i]] = i;
74 for(i = 1; i < 22; i++)
75 for(i = 1; i < 23; i++)
7576 t->aamask[i] = (1L<<(i-1)); /* First is zero */
7677 for(i = 0; i < Translate_PIMA_SET_SIZE; i++){
7778 t->aamask[t->aa2d[pimagrp[i][0]]]
137138 result[n++] = code[(table[a] << 4)
138139 | (table[b] << 2)
139140 | table[c]];
140 /* g_print("generated genetic code [%s]\n", result); */
141141 return result;
142142 }
143143 /* Converts genetic code from NCBI format (TCAG order)
22 * Nucleotide Translation Code *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
22 * Nucleotide Translation Code *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
2323
2424 static void check_translate(Translate *t, gchar *codon, gchar crib){
2525 register gchar aa = Translate_codon(t, codon);
26 g_message("Translate [%s] -> [%c] (crib:[%c]", codon, aa, crib);
2627 g_assert(aa == crib);
27 g_message("Translate [%s] -> [%c] (crib:[%c]", codon, aa, crib);
2828 return;
2929 }
3030
3838 }
3939
4040 gint Argument_main(Argument *arg){
41 register Translate *t = Translate_create(FALSE);
41 register Translate *t;
42 Translate_ArgumentSet_create(arg);
43 Argument_process(arg, "translate.test", NULL, NULL);
44 t = Translate_create(FALSE);
4245 check_translate(t, "ATG", 'M');
4346 check_translate(t, "GGX", 'G');
4447 check_translate(t, "NGT", 'X');
48 check_translate(t, "TGA", '*');
4549 /**/
4650 check_reverse_translate(t, "S*MXG", 72);
4751 check_reverse_translate(t, "SSSSS", 7776);
00
11 TESTS = fsm.test matrix.test pqueue.test slist.test rangetree.test \
22 vfsm.test recyclebin.test sparsecache.test dejavu.test \
3 bitarray.test splaytree.test noitree.test
3 bitarray.test splaytree.test noitree.test
4 # huffman.test fmindex.test
5
46 noinst_PROGRAMS = $(TESTS)
57
68 noinst_HEADERS = fsm.h matrix.h pqueue.h slist.h rangetree.h vfsm.h \
79 recyclebin.h sparsecache.h dejavu.h bitarray.h \
810 splaytree.h noitree.h
11 # huffman.h fmindex.h
12
13 INCLUDES = -DCUSTOM_GUINT64_FORMAT="\"@custom_guint64_format@\""
914
1015 fsm_test_SOURCES = fsm.test.c fsm.c
1116 fsm_test_LDADD = recyclebin.o
3035 noitree_test_SOURCES = noitree.test.c noitree.c
3136 noitree_test_LDADD = recyclebin.o splaytree.o
3237
38 # huffman_test_SOURCES = huffman.test.c huffman.c
39 # huffman_test_LDADD = bitarray.o pqueue.o recyclebin.o
40
41 # fmindex_test_SOURCES = fmindex.test.c fmindex.c
42 # fmindex_test_LDADD = bitarray.o pqueue.o recyclebin.o huffman.o
43
3344 # Files to clear away
3445
3546 MAINTAINERCLEANFILES = Makefile.in
6969 VERSION = @VERSION@
7070 codegen_extra_ldadd = @codegen_extra_ldadd@
7171 codegen_extra_sources = @codegen_extra_sources@
72 custom_guint64_format = @custom_guint64_format@
7273 datarootdir = @datarootdir@
7374 glib_cflags = @glib_cflags@
7475 glib_libs = @glib_libs@
7778 source_root_dir = @source_root_dir@
7879 use_pthreads = @use_pthreads@
7980
80 TESTS = fsm.test matrix.test pqueue.test slist.test rangetree.test vfsm.test recyclebin.test sparsecache.test dejavu.test bitarray.test splaytree.test noitree.test
81 TESTS = fsm.test matrix.test pqueue.test slist.test rangetree.test vfsm.test recyclebin.test sparsecache.test dejavu.test bitarray.test splaytree.test noitree.test
82
83 # huffman.test fmindex.test
8184
8285 noinst_PROGRAMS = $(TESTS)
8386
8487 noinst_HEADERS = fsm.h matrix.h pqueue.h slist.h rangetree.h vfsm.h recyclebin.h sparsecache.h dejavu.h bitarray.h splaytree.h noitree.h
8588
89 # huffman.h fmindex.h
90
91 INCLUDES = -DCUSTOM_GUINT64_FORMAT="\"@custom_guint64_format@\""
8692
8793 fsm_test_SOURCES = fsm.test.c fsm.c
8894 fsm_test_LDADD = recyclebin.o
106112
107113 noitree_test_SOURCES = noitree.test.c noitree.c
108114 noitree_test_LDADD = recyclebin.o splaytree.o
115
116 # huffman_test_SOURCES = huffman.test.c huffman.c
117 # huffman_test_LDADD = bitarray.o pqueue.o recyclebin.o
118
119 # fmindex_test_SOURCES = fmindex.test.c fmindex.c
120 # fmindex_test_LDADD = bitarray.o pqueue.o recyclebin.o huffman.o
109121
110122 # Files to clear away
111123
22 * A simple bitarray data structure *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
22 * A simple bitarray data structure *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
5151
5252 void BitArray_write_int(guint64 num, FILE *fp);
5353 guint64 BitArray_read_int(FILE *fp);
54 void BitArray_int_print(guint64 num);
55 gchar *BitArray_int_sprintf(guint64 num);
5456
5557 #ifdef __cplusplus
5658 }
22 * A simple bitarray data structure *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
22 * Deja-vu library for fast linear space repeat finding *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
6868 continue;
6969 if(first[ch] == -1)
7070 first[ch] = i;
71 if(last[ch] != -1){
71 if(last[ch] != -1)
7272 dv->next[last[ch]] = i;
73 }
7473 last[ch] = i;
7574 }
7675 for(i = 0; i < ALPHABET_SIZE; i++){
22 * Deja-vu library for fast linear space repeat finding *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
22 * Deja-vu library for fast linear space repeat finding *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
22 * Library for FSM-based word matching. *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
217217 return;
218218 }
219219
220 /**/
221
22 * Library for FSM-based word matching. *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
22 * Library for FSM-based word matching. *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
22 * Simple matrix creation routines *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
22 * Simple matrix creation routines *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
22 * Simple matrix creation routines *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
22 * NOI_Tree : non-overlapping interval tree *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
22 * NOI_Tree : non-overlapping interval tree *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
22 * NOI_Tree : non-overlapping interval tree *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
22 * Priority queue library using pairing heaps. *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
22 * Priority queue library using pairing heaps. *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
22 * Priority queue library using pairing heaps. *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
22 * Trees for 2D range searching. *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
22 * Trees for 2D range searching. *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
22 * Trees for 2D range searching. *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
22 * Efficient Memory Allocation Routines *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
1515 #include <string.h>
1616 #include "recyclebin.h"
1717
18 #ifndef USE_PTHREADS
1819 static GTree *global_recycle_bin_tree = NULL;
20 #endif /* USE_PTHREADS */
1921
22 #ifndef USE_PTHREADS
2023 static gint RecycleBin_compare(gconstpointer a,
2124 gconstpointer b){
2225 return a - b;
2326 }
27 #endif /* USE_PTHREADS */
2428
2529 RecycleBin *RecycleBin_create(gchar *name, gsize node_size,
2630 gint nodes_per_chunk){
3539 recycle_bin->node_size = node_size;
3640 recycle_bin->count = 0;
3741 recycle_bin->recycle = NULL;
42 #ifndef USE_PTHREADS
3843 if(!global_recycle_bin_tree)
3944 global_recycle_bin_tree = g_tree_new(RecycleBin_compare);
4045 g_tree_insert(global_recycle_bin_tree, recycle_bin, recycle_bin);
46 #endif /* USE_PTHREADS */
4147 return recycle_bin;
4248 }
4349
4551 register gint i;
4652 if(--recycle_bin->ref_count)
4753 return;
54 #ifndef USE_PTHREADS
4855 g_assert(global_recycle_bin_tree);
4956 g_assert(g_tree_lookup(global_recycle_bin_tree, recycle_bin));
5057 g_tree_remove(global_recycle_bin_tree, recycle_bin);
5259 g_tree_destroy(global_recycle_bin_tree);
5360 global_recycle_bin_tree = NULL;
5461 }
62 #endif /* USE_PTHREADS */
5563 for(i = 0; i < recycle_bin->chunk_list->len; i++)
5664 g_free(recycle_bin->chunk_list->pdata[i]);
5765 g_ptr_array_free(recycle_bin->chunk_list, TRUE);
114122 return;
115123 }
116124
125 #ifndef USE_PTHREADS
117126 static gint RecycleBin_profile_traverse(gpointer key,
118127 gpointer value,
119128 gpointer data){
125134 recycle_bin->count);
126135 return FALSE;
127136 }
137 #endif /* USE_PTHREADS */
128138
129139 void RecycleBin_profile(void){
130140 g_message("BEGIN RecycleBin profile");
141 #ifdef USE_PTHREADS
142 g_message("multi-threaded RecycleBin_profile() not implemented");
143 #else /* USE_PTHREADS */
131144 if(global_recycle_bin_tree)
132145 g_tree_traverse(global_recycle_bin_tree,
133146 RecycleBin_profile_traverse, G_IN_ORDER, NULL);
134147 else
135148 g_message("no active RecycleBins");
149 #endif /* USE_PTHREADS */
136150 g_message("END RecycleBin profile");
137151 return;
138152 }
22 * Efficient Memory Allocation Routines *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
22 * Efficient Memory Allocation Routines *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
22 * Efficient single-linked list routines. *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
22 * Efficient single-linked list routines. *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
22 * Efficient single-linked list routines. *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
22 * Sparse Cache Object *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
22 * Sparse Cache Object *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
22 * Sparse Cache Object *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
22 * Splay Tree Library *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
22 * Splay Tree Library *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
22 * Splay Tree Library *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
22 * VFSM Library : complete trie navigation *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
22 * VFSM Library : complete trie navigation *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
2121 #ifdef G_HAVE_GINT64
2222 typedef guint64 VFSM_Int;
2323 #define VFSM_MAX G_GINT64_CONSTANT(18446744073709551615U)
24 #ifdef CUSTOM_GUINT64_FORMAT
25 #define VFSM_PRINT_FORMAT CUSTOM_GUINT64_FORMAT
26 #else /* CUSTOM_GUINT64_FORMAT */
2427 #define VFSM_PRINT_FORMAT "llu"
28 #endif /* CUSTOM_GUINT64_FORMAT */
2529 #else /* G_HAVE_GINT64 */
2630 typedef guint32 VFSM_Int;
2731 #define VFSM_MAX 4294967295U
22 * VFSM Library : complete trie navigation *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
5656
5757 esd2esi_LDADD = $(top_srcdir)/src/database/dataset.o \
5858 $(top_srcdir)/src/database/index.o \
59 $(top_srcdir)/src/general/threadref.o \
5960 $(top_srcdir)/src/struct/bitarray.o \
6061 $(top_srcdir)/src/struct/vfsm.o \
6162 $(top_srcdir)/src/struct/pqueue.o \
6969 VERSION = @VERSION@
7070 codegen_extra_ldadd = @codegen_extra_ldadd@
7171 codegen_extra_sources = @codegen_extra_sources@
72 custom_guint64_format = @custom_guint64_format@
7273 datarootdir = @datarootdir@
7374 glib_cflags = @glib_cflags@
7475 glib_libs = @glib_libs@
115116 fasta2esd_LDADD = $(top_srcdir)/src/database/dataset.o $(top_srcdir)/src/struct/bitarray.o $(LDADD)
116117
117118
118 esd2esi_LDADD = $(top_srcdir)/src/database/dataset.o $(top_srcdir)/src/database/index.o $(top_srcdir)/src/struct/bitarray.o $(top_srcdir)/src/struct/vfsm.o $(top_srcdir)/src/struct/pqueue.o $(top_srcdir)/src/struct/recyclebin.o $(top_srcdir)/src/struct/rangetree.o $(top_srcdir)/src/struct/noitree.o $(top_srcdir)/src/struct/splaytree.o $(top_srcdir)/src/sequence/submat.o $(top_srcdir)/src/sequence/codonsubmat.o $(top_srcdir)/src/comparison/wordhood.o $(top_srcdir)/src/comparison/hspset.o $(top_srcdir)/src/comparison/match.o $(LDADD)
119 esd2esi_LDADD = $(top_srcdir)/src/database/dataset.o $(top_srcdir)/src/database/index.o $(top_srcdir)/src/general/threadref.o $(top_srcdir)/src/struct/bitarray.o $(top_srcdir)/src/struct/vfsm.o $(top_srcdir)/src/struct/pqueue.o $(top_srcdir)/src/struct/recyclebin.o $(top_srcdir)/src/struct/rangetree.o $(top_srcdir)/src/struct/noitree.o $(top_srcdir)/src/struct/splaytree.o $(top_srcdir)/src/sequence/submat.o $(top_srcdir)/src/sequence/codonsubmat.o $(top_srcdir)/src/comparison/wordhood.o $(top_srcdir)/src/comparison/hspset.o $(top_srcdir)/src/comparison/match.o $(LDADD)
119120
120121
121122 EXTRA_fastavalidcds_SOURCES = fastavalidcds.c
435436 fastaannotatecdna_LDFLAGS =
436437 esd2esi_OBJECTS = esd2esi.o
437438 esd2esi_DEPENDENCIES = $(top_srcdir)/src/database/dataset.o \
438 $(top_srcdir)/src/database/index.o $(top_srcdir)/src/struct/bitarray.o \
439 $(top_srcdir)/src/struct/vfsm.o $(top_srcdir)/src/struct/pqueue.o \
440 $(top_srcdir)/src/struct/recyclebin.o \
439 $(top_srcdir)/src/database/index.o \
440 $(top_srcdir)/src/general/threadref.o \
441 $(top_srcdir)/src/struct/bitarray.o $(top_srcdir)/src/struct/vfsm.o \
442 $(top_srcdir)/src/struct/pqueue.o $(top_srcdir)/src/struct/recyclebin.o \
441443 $(top_srcdir)/src/struct/rangetree.o $(top_srcdir)/src/struct/noitree.o \
442444 $(top_srcdir)/src/struct/splaytree.o \
443445 $(top_srcdir)/src/sequence/submat.o \
22 * esd2esi - generate an exonerate index file from a dataset *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
2525 gboolean is_translated = FALSE;
2626 register gint word_length;
2727 gint dna_word_length, protein_word_length,
28 word_jump, saturate_threshold, memory_limit;
28 word_jump, word_ambiguity,
29 saturate_threshold, memory_limit;
2930 /**/
3031 ArgumentSet_add_option(as, 'd', "dataset", "path",
3132 "Exonerate dataset file", NULL,
4748 ArgumentSet_add_option(as, 0, "wordjump", NULL,
4849 "Jump between database words", "1",
4950 Argument_parse_int, &word_jump);
51 ArgumentSet_add_option(as, 0, "wordambiguity", NULL,
52 "Number of ambiguous words to index", "1",
53 Argument_parse_int, &word_ambiguity);
5054 ArgumentSet_add_option(as, 0, "saturatethreshold", NULL,
5155 "Word saturation threshold", "10",
5256 Argument_parse_int, &saturate_threshold);
6468 || (dataset->alphabet->type == Alphabet_Type_PROTEIN))
6569 ? protein_word_length
6670 : dna_word_length;
71 if(word_ambiguity < 1)
72 g_error("Word ambiguity cannot be less than one.");
73 if((word_ambiguity > 1)
74 && (dataset->alphabet->type == Alphabet_Type_PROTEIN))
75 g_error("Protein ambuigity symbols not implemented");
6776 g_message("Building index");
68 index = Index_create(dataset, is_translated, word_length, word_jump,
77 index = Index_create(dataset, is_translated, word_length,
78 word_jump, word_ambiguity,
6979 saturate_threshold, index_path, dataset_path,
7080 memory_limit);
7181 Index_destroy(index);
22 * fasta2esd - generate an exonerate sequence database file *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
22 * fastaannotatecdna : a utility to annotate cDNA with a protein *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
22 * fastachecksum : a utility to print GCG checksums *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
22 * fastaclean : a utility to clean fasta format files *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
22 * fastaclip : clip terminal Ns from fasta format sequences *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
22 * fastacomposition : a utility to dump sequence composition *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
22 * fastadiff : a utility to compare fasta sequence files *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
22 * fastaexplode : break a fasta file into individual sequences *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
22 * fastafetch : fetch a sequence from a fasta format file *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
4343 static CompoundFile_Pos fasta_index_lookup(FastaDB *fdb, FILE *index_fp,
4444 gchar *id){
4545 register long left, right, pos;
46 CompoundFile_Pos result = -1;
46 CompoundFile_Pos_scan_type result = -1;
4747 register GString *curr = g_string_sized_new(100);
4848 register gint cond;
4949 left = 0;
7979 }
8080 }
8181 g_string_free(curr, TRUE);
82 return result;
82 return (CompoundFile_Pos)result;
8383 }
8484
8585 static FastaDB_Seq *fasta_index_fetch(FastaDB *fdb, FILE *index_fp,
22 * fastahardmask : convert lower case chars to 'N's *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
22 * fastaindex : index a fasta format file *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
22 * fastalength : a utility to print fasta sequence length *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
22 * fastanrdb : create non-redundant versions of fasta database *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
22 * fastaoverlap: generate overlapping sequences *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
22 * fastalength : a utility to reformat fasta format sequences *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
22 * fastaremove : remove sequences from a fasta format file *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
22 * fastarevcomp : a utility to revcomp fasta format sequences *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
22 * fastasoftmask: merge masked and unmasked files to softmask *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
22 * fastasort : a utility for sorting fasta format databases *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
22 * fastasplit: split a fasta format file into chunks *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
22 * fastasubseq: extract subsequences from fasta format sequences *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
22 * fastatranslate: a utility to translate fasta format sequences *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
3636 } else {
3737 aa_seq = Sequence_translate(fdbs->seq, translate, frame);
3838 }
39 Sequence_print_fasta(aa_seq, stdout, FALSE);
39 if(aa_seq->len)
40 Sequence_print_fasta(aa_seq, stdout, FALSE);
4041 Sequence_destroy(aa_seq);
4142 return;
4243 }
4647 register FastaDB_Seq *fdbs;
4748 register ArgumentSet *as
4849 = ArgumentSet_create("Sequence Input Options");
49 register Translate *translate = Translate_create(FALSE);
50 register Translate *translate;
5051 register Alphabet *dna_alphabet
5152 = Alphabet_create(Alphabet_Type_DNA, FALSE);
5253 register Alphabet *protein_alphabet
6566 "A utility to translate fasta format sequences\n"
6667 "Guy St.C. Slater. guy@ebi.ac.uk. 2000-2003.\n", NULL);
6768 fdb = FastaDB_open(query_path, dna_alphabet);
69 translate = Translate_create(FALSE);
6870 while((fdbs = FastaDB_next(fdb, FastaDB_Mask_ALL))){
6971 fasta_translate_seq(fdbs, translate, frame, protein_alphabet);
7072 FastaDB_Seq_destroy(fdbs);
22 * fastavalidcds: a utility to check for valid CDS sequences *
33 * *
44 * Guy St.C. Slater.. mailto:guy@ebi.ac.uk *
5 * Copyright (C) 2000-2008. All Rights Reserved. *
5 * Copyright (C) 2000-2009. All Rights Reserved. *
66 * *
77 * This source code is distributed under the terms of the *
88 * GNU General Public License, version 3. See the file COPYING *
6969 VERSION = @VERSION@
7070 codegen_extra_ldadd = @codegen_extra_ldadd@
7171 codegen_extra_sources = @codegen_extra_sources@
72 custom_guint64_format = @custom_guint64_format@
7273 datarootdir = @datarootdir@
7374 glib_cflags = @glib_cflags@
7475 glib_libs = @glib_libs@
6969 VERSION = @VERSION@
7070 codegen_extra_ldadd = @codegen_extra_ldadd@
7171 codegen_extra_sources = @codegen_extra_sources@
72 custom_guint64_format = @custom_guint64_format@
7273 datarootdir = @datarootdir@
7374 glib_cflags = @glib_cflags@
7475 glib_libs = @glib_libs@
6969 VERSION = @VERSION@
7070 codegen_extra_ldadd = @codegen_extra_ldadd@
7171 codegen_extra_sources = @codegen_extra_sources@
72 custom_guint64_format = @custom_guint64_format@
7273 datarootdir = @datarootdir@
7374 glib_cflags = @glib_cflags@
7475 glib_libs = @glib_libs@
6969 VERSION = @VERSION@
7070 codegen_extra_ldadd = @codegen_extra_ldadd@
7171 codegen_extra_sources = @codegen_extra_sources@
72 custom_guint64_format = @custom_guint64_format@
7273 datarootdir = @datarootdir@
7374 glib_cflags = @glib_cflags@
7475 glib_libs = @glib_libs@
6969 VERSION = @VERSION@
7070 codegen_extra_ldadd = @codegen_extra_ldadd@
7171 codegen_extra_sources = @codegen_extra_sources@
72 custom_guint64_format = @custom_guint64_format@
7273 datarootdir = @datarootdir@
7374 glib_cflags = @glib_cflags@
7475 glib_libs = @glib_libs@
6969 VERSION = @VERSION@
7070 codegen_extra_ldadd = @codegen_extra_ldadd@
7171 codegen_extra_sources = @codegen_extra_sources@
72 custom_guint64_format = @custom_guint64_format@
7273 datarootdir = @datarootdir@
7374 glib_cflags = @glib_cflags@
7475 glib_libs = @glib_libs@
6969 VERSION = @VERSION@
7070 codegen_extra_ldadd = @codegen_extra_ldadd@
7171 codegen_extra_sources = @codegen_extra_sources@
72 custom_guint64_format = @custom_guint64_format@
7273 datarootdir = @datarootdir@
7374 glib_cflags = @glib_cflags@
7475 glib_libs = @glib_libs@