├── .gitignore
├── VERSION
├── .travis.yml
├── fptr.h
├── bitmap.h
├── dprog.h
├── bitmap.c
├── Makefile
├── metagenomic.h
├── README.md
├── gene.h
├── sequence.h
├── training.h
├── node.h
├── CHANGES
├── metagenomic.c
├── dprog.c
├── anthus_aco.fas
├── gene.c
├── main.c
├── sequence.c
└── LICENSE
/.gitignore:
--------------------------------------------------------------------------------
1 | *.o
2 | prodigal
3 |
--------------------------------------------------------------------------------
/VERSION:
--------------------------------------------------------------------------------
1 | v2.6.3: February 2016
2 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 |
2 | script:
3 | - sudo make install
4 | - prodigal -h
5 | - prodigal -i anthus_aco.fas -o anthus_aco_genes.txt -a anthus_aco_proteins.faa
6 | - cat anthus_aco_genes.txt
7 | - cat anthus_aco_proteins.faa
8 |
--------------------------------------------------------------------------------
/fptr.h:
--------------------------------------------------------------------------------
1 | #ifndef SGC_H__
2 | #define SGC_H__
3 | #ifdef SUPPORT_GZIP_COMPRESSED
4 | #include "zlib.h"
5 | #define fptr gzFile
6 | #define INPUT_OPEN gzopen
7 | #define INPUT_SEEK gzseek
8 | #define INPUT_CLOSE gzclose
9 | #define INPUT_GETS(str, n, stream) gzgets(stream, str, n)
10 | #else
11 | #define fptr FILE *
12 | #define INPUT_OPEN fopen
13 | #define INPUT_SEEK fseek
14 | #define INPUT_CLOSE fclose
15 | #define INPUT_GETS(str, n, stream) fgets(str, n, stream)
16 | #endif
17 | #endif
18 |
--------------------------------------------------------------------------------
/bitmap.h:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | PRODIGAL (PROkaryotic DynamIc Programming Genefinding ALgorithm)
3 | Copyright (C) 2007-2016 University of Tennessee / UT-Battelle
4 |
5 | Code Author: Doug Hyatt
6 |
7 | This program is free software: you can redistribute it and/or modify
8 | it under the terms of the GNU General Public License as published by
9 | the Free Software Foundation, either version 3 of the License, or
10 | (at your option) any later version.
11 |
12 | This program is distributed in the hope that it will be useful,
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | GNU General Public License for more details.
16 |
17 | You should have received a copy of the GNU General Public License
18 | along with this program. If not, see .
19 | *******************************************************************************/
20 |
21 | #ifndef BITMAP_H_
22 | #define BITMAP_H_
23 |
24 | unsigned char test(unsigned char *, int);
25 | void clear(unsigned char *, int);
26 | void set(unsigned char *, int);
27 | void toggle(unsigned char *, int);
28 |
29 | #endif
30 |
--------------------------------------------------------------------------------
/dprog.h:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | PRODIGAL (PROkaryotic DynamIc Programming Genefinding ALgorithm)
3 | Copyright (C) 2007-2016 University of Tennessee / UT-Battelle
4 |
5 | Code Author: Doug Hyatt
6 |
7 | This program is free software: you can redistribute it and/or modify
8 | it under the terms of the GNU General Public License as published by
9 | the Free Software Foundation, either version 3 of the License, or
10 | (at your option) any later version.
11 |
12 | This program is distributed in the hope that it will be useful,
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | GNU General Public License for more details.
16 |
17 | You should have received a copy of the GNU General Public License
18 | along with this program. If not, see .
19 | *******************************************************************************/
20 |
21 | #ifndef _DPROG_H
22 | #define _DPROG_H
23 |
24 | #include
25 | #include
26 | #include "sequence.h"
27 | #include "node.h"
28 |
29 | #define MAX_SAM_OVLP 60
30 | #define MAX_OPP_OVLP 200
31 | #define MAX_NODE_DIST 500
32 |
33 | int dprog(struct _node *, int, struct _training *, int);
34 | void score_connection(struct _node *, int, int, struct _training *, int);
35 | void eliminate_bad_genes(struct _node *, int, struct _training *);
36 |
37 | #endif
38 |
--------------------------------------------------------------------------------
/bitmap.c:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | PRODIGAL (PROkaryotic DynamIc Programming Genefinding ALgorithm)
3 | Copyright (C) 2007-2016 University of Tennessee / UT-Battelle
4 |
5 | Code Author: Doug Hyatt
6 |
7 | This program is free software: you can redistribute it and/or modify
8 | it under the terms of the GNU General Public License as published by
9 | the Free Software Foundation, either version 3 of the License, or
10 | (at your option) any later version.
11 |
12 | This program is distributed in the hope that it will be useful,
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | GNU General Public License for more details.
16 |
17 | You should have received a copy of the GNU General Public License
18 | along with this program. If not, see .
19 | *******************************************************************************/
20 |
21 | #include "bitmap.h"
22 |
23 | /* Test a bit, 0 = not set, 1 = set */
24 | unsigned char test(unsigned char *bm, int ndx) {
25 | return ( bm[ndx>>3] & (1 << (ndx&0x07))?1:0 );
26 | }
27 |
28 | /* Clear a bit (set it to 0) */
29 | void clear(unsigned char *bm, int ndx) {
30 | bm[ndx>>3] &= ~(1 << (ndx&0x07));
31 | }
32 |
33 | /* Set a bit to 1 */
34 | void set(unsigned char *bm, int ndx) {
35 | bm[ndx>>3] |= (1 << (ndx&0x07));
36 | }
37 |
38 | /* Flip a bit's value 0->1 or 1->0 */
39 | void toggle(unsigned char *bm, int ndx) {
40 | bm[ndx>>3] ^= (1 << (ndx&0x07));
41 | }
42 |
--------------------------------------------------------------------------------
/Makefile:
--------------------------------------------------------------------------------
1 | ##############################################################################
2 | # PRODIGAL (PROkaryotic DynamIc Programming Genefinding ALgorithm)
3 | # Copyright (C) 2007-2016 University of Tennessee / UT-Battelle
4 | #
5 | # Code Author: Doug Hyatt
6 | #
7 | # This program is free software: you can redistribute it and/or modify
8 | # it under the terms of the GNU General Public License as published by
9 | # the Free Software Foundation, either version 3 of the License, or
10 | # (at your option) any later version.
11 | #
12 | # This program is distributed in the hope that it will be useful,
13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | # GNU General Public License for more details.
16 | #
17 | # You should have received a copy of the GNU General Public License
18 | # along with this program. If not, see .
19 | ##############################################################################
20 |
21 | SHELL = /bin/sh
22 | CC = gcc
23 |
24 | CFLAGS += -pedantic -Wall -O3 -DSUPPORT_GZIP_COMPRESSED
25 | LFLAGS = -lm $(LDFLAGS) -lz
26 |
27 | TARGET = prodigal
28 | ZTARGET = zprodigal
29 | SOURCES = $(shell echo *.c)
30 | HEADERS = $(shell echo *.h)
31 | OBJECTS = $(SOURCES:.c=.o)
32 | ZOBJECTS = $(SOURCES:.c=.oz)
33 |
34 | INSTALLDIR = /usr/local/bin
35 |
36 | all: $(TARGET)
37 |
38 | $(TARGET): $(OBJECTS)
39 | $(CC) $(CFLAGS) -o $@ $^ $(LFLAGS)
40 |
41 | %.o: %.c $(HEADERS)
42 | $(CC) $(CFLAGS) -c -o $@ $<
43 |
44 | install: $(TARGET)
45 | install -d -m 0755 $(INSTALLDIR)
46 | install -m 0755 $(TARGET) $(INSTALLDIR)
47 |
48 | uninstall:
49 | -rm $(INSTALLDIR)/$(TARGET)
50 |
51 | clean:
52 | -rm -f $(OBJECTS) $(ZOBJECTS)
53 |
54 | distclean: clean
55 | -rm -f $(TARGET)
56 |
57 | .PHONY: all install uninstall clean distclean
58 |
--------------------------------------------------------------------------------
/metagenomic.h:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | PRODIGAL (PROkaryotic DynamIc Programming Genefinding ALgorithm)
3 | Copyright (C) 2007-2016 University of Tennessee / UT-Battelle
4 |
5 | Code Author: Doug Hyatt
6 |
7 | This program is free software: you can redistribute it and/or modify
8 | it under the terms of the GNU General Public License as published by
9 | the Free Software Foundation, either version 3 of the License, or
10 | (at your option) any later version.
11 |
12 | This program is distributed in the hope that it will be useful,
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | GNU General Public License for more details.
16 |
17 | You should have received a copy of the GNU General Public License
18 | along with this program. If not, see .
19 | *******************************************************************************/
20 |
21 | #ifndef SAMPLE_H_
22 | #define SAMPLE_H_
23 |
24 | #include
25 | #include
26 | #include
27 | #include "sequence.h"
28 | #include "training.h"
29 | #include "node.h"
30 |
31 | #define NUM_BIN 6
32 | #define NUM_META 50
33 | #define SAMPLE_LEN 120
34 | #define MAX_SAMPLE 200
35 |
36 | struct _metagenomic_bin {
37 | int index; /* Index used for sorting */
38 | int clusnum; /* Cluster number */
39 | char desc[500]; /* Text description of this bin */
40 | double weight; /* Current weight/score of this bin */
41 | double gc; /* GC distance from target sequence */
42 | struct _training *tinf; /* Pointer to the training file for this bin */
43 | };
44 |
45 | void initialize_metagenomic_bins(struct _metagenomic_bin *);
46 | double score_edges(unsigned char *, unsigned char *, int,
47 | struct _training *tinf);
48 | double score_sample(unsigned char *, unsigned char *, int, int, int, struct
49 | _training *tinf);
50 | void determine_top_bins(unsigned char *, unsigned char *, int, double,
51 | struct _metagenomic_bin *);
52 | int compare_meta_bins(const void *, const void *);
53 |
54 | #endif
55 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Prodigal
2 |
3 | Fast, reliable protein-coding gene prediction for prokaryotic genomes.
4 |
5 | ```bash
6 | prodigal -i my.genome.fna -o my.genes -a my.proteins.faa
7 | prodigal -i my.metagenome.fna -o my.genes -a my.proteins.faa -p meta
8 | prodigal -h
9 | ```
10 |
11 | ### New in 2.6.3 (February 2016)
12 | * Fixed a bug in protein translation output of partial genes where TTG/GTG
13 | codons were being incorrectly translated to methionine.
14 |
15 | ### Getting Started
16 |
17 | Prodigal consists of a single binary, which is provided for Linux, Mac OS X, and Windows with each official release. You can also install from source (you will need Cygwin or MinGW on Windows) as follows:
18 |
19 | ```bash
20 | $ make install
21 | ```
22 |
23 | For more detail, see [Installing Prodigal](https://www.github.com/hyattpd/Prodigal/wiki/installation).
24 |
25 | To see a complete list of options:
26 |
27 | ```bash
28 | $ prodigal -h
29 | ```
30 |
31 | ### Features
32 |
33 | * **Predicts protein-coding genes**: Prodigal provides fast, accurate protein-coding gene predictions in GFF3, Genbank, or Sequin table format.
34 | * **Handles draft genomes and metagenomes**: Prodigal runs smoothly on finished genomes, draft genomes, and metagenomes.
35 | * **Runs quickly**: Prodigal analyzes the *E. coli K-12* genome in 10 seconds on a modern MacBook Pro.
36 | * **Runs unsupervised**: Prodigal is an unsupervised machine learning algorithm. It does not need to be provided with any training data, and instead automatically learns the properties of the genome from the sequence itself, including RBS motif usage, start codon usage, and coding statistics.
37 | * **Handles gaps and partial genes**: The user can specify if Prodigal should build genes across runs of N's as well as how to handle genes at the edges of contigs.
38 | * **Identifies translation initiation sites**: Prodigal predicts the correct translation initiation site for most genes, and can output information about every potential start site in the genome, including confidence score, RBS motif, and much more.
39 |
40 | ### More Information
41 |
42 | * [Website](http://prodigal.ornl.gov/)
43 | * [Wiki Documentation](https://github.com/hyattpd/prodigal/wiki)
44 | * [Options Cheat Sheet](https://github.com/hyattpd/prodigal/wiki#cheat-sheet)
45 | * [Google Discussion Group](https://groups.google.com/group/prodigal-discuss)
46 |
47 | #### Contributors
48 |
49 | * Author: [Doug Hyatt](https://github.com/hyattpd/)
50 |
51 | #### License
52 |
53 | [GPL](LICENSE)
54 |
--------------------------------------------------------------------------------
/gene.h:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | PRODIGAL (PROkaryotic DynamIc Programming Genefinding ALgorithm)
3 | Copyright (C) 2007-2016 University of Tennessee / UT-Battelle
4 |
5 | Code Author: Doug Hyatt
6 |
7 | This program is free software: you can redistribute it and/or modify
8 | it under the terms of the GNU General Public License as published by
9 | the Free Software Foundation, either version 3 of the License, or
10 | (at your option) any later version.
11 |
12 | This program is distributed in the hope that it will be useful,
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | GNU General Public License for more details.
16 |
17 | You should have received a copy of the GNU General Public License
18 | along with this program. If not, see .
19 | *******************************************************************************/
20 |
21 | #ifndef _GENE_H
22 | #define _GENE_H
23 |
24 | #include
25 | #include "training.h"
26 | #include "node.h"
27 | #include "dprog.h"
28 |
29 | #define MAX_GENES 30000
30 |
31 | struct _gene {
32 | int begin; /* Left end of the gene */
33 | int end; /* Right end of the gene */
34 | int start_ndx; /* Index to the start node in the nodes file */
35 | int stop_ndx; /* Index to the stop node in the nodes file */
36 | char gene_data[500]; /* String containing gene information */
37 | char score_data[500]; /* String containing scoring information */
38 | };
39 |
40 | int add_genes(struct _gene *, struct _node *, int);
41 | void record_gene_data(struct _gene *, int, struct _node *, struct _training *,
42 | int);
43 | void tweak_final_starts(struct _gene *, int, struct _node *, int, struct
44 | _training *);
45 |
46 | void print_genes(FILE *, struct _gene *, int, struct _node *, int, int, int,
47 | int, char *, struct _training *, char *, char *, char *);
48 | void write_translations(FILE *, struct _gene *, int, struct _node *,
49 | unsigned char *, unsigned char *, unsigned char *, int,
50 | struct _training *, int, char *);
51 | void write_nucleotide_seqs(FILE *, struct _gene *, int, struct _node *,
52 | unsigned char *, unsigned char *, unsigned char *,
53 | int, struct _training *, int, char *);
54 | double calculate_confidence(double, double);
55 |
56 | #endif
57 |
--------------------------------------------------------------------------------
/sequence.h:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | PRODIGAL (PROkaryotic DynamIc Programming Genefinding ALgorithm)
3 | Copyright (C) 2007-2016 University of Tennessee / UT-Battelle
4 |
5 | Code Author: Doug Hyatt
6 |
7 | This program is free software: you can redistribute it and/or modify
8 | it under the terms of the GNU General Public License as published by
9 | the Free Software Foundation, either version 3 of the License, or
10 | (at your option) any later version.
11 |
12 | This program is distributed in the hope that it will be useful,
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | GNU General Public License for more details.
16 |
17 | You should have received a copy of the GNU General Public License
18 | along with this program. If not, see .
19 | *******************************************************************************/
20 |
21 | #ifndef _SEQ_H
22 | #define _SEQ_H
23 |
24 | #include
25 | #include
26 | #include
27 | #include
28 | #include "bitmap.h"
29 | #include "training.h"
30 | #include "fptr.h"
31 |
32 | #define MAX_SEQ 32000000
33 | #define MAX_LINE 10000
34 | #define WINDOW 120
35 | #define MASK_SIZE 50
36 | #define MAX_MASKS 5000
37 | #define ATG 0
38 | #define GTG 1
39 | #define TTG 2
40 | #define STOP 3
41 | #define ACCEPT "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.:^*$@!+_?-|"
42 |
43 | typedef struct _mask {
44 | int begin;
45 | int end;
46 | } mask;
47 |
48 | int read_seq_training(fptr, unsigned char *, unsigned char *, double *, int,
49 | mask *, int *);
50 | int next_seq_multi(fptr, unsigned char *, unsigned char *, int *, double *,
51 | int, mask *, int *, char *, char *);
52 | void rcom_seq(unsigned char *, unsigned char *, unsigned char *, int);
53 |
54 | void calc_short_header(char *header, char *short_header, int);
55 |
56 | int is_a(unsigned char *, int);
57 | int is_c(unsigned char *, int);
58 | int is_g(unsigned char *, int);
59 | int is_t(unsigned char *, int);
60 | int is_n(unsigned char *, int);
61 | int is_gc(unsigned char *, int);
62 |
63 | int is_stop(unsigned char *, int, struct _training *);
64 | int is_start(unsigned char *, int, struct _training *);
65 | int is_atg(unsigned char *, int);
66 | int is_gtg(unsigned char *, int);
67 | int is_ttg(unsigned char *, int);
68 |
69 | double gc_content(unsigned char *, int, int);
70 |
71 | char amino(unsigned char *, int, struct _training *, int);
72 | int amino_num(char);
73 | char amino_letter(int);
74 |
75 | int rframe(int, int);
76 | int max_fr(int, int, int);
77 |
78 | int *calc_most_gc_frame(unsigned char *, int);
79 |
80 | int mer_ndx(int, unsigned char *, int);
81 | void mer_text(char *, int, int);
82 | void calc_mer_bg(int, unsigned char *, unsigned char *, int, double *);
83 |
84 | int shine_dalgarno_exact(unsigned char *, int, int, double *);
85 | int shine_dalgarno_mm(unsigned char *, int, int, double *);
86 |
87 | int imin(int, int);
88 |
89 | #endif
90 |
--------------------------------------------------------------------------------
/training.h:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | PRODIGAL (PROkaryotic DynamIc Programming Genefinding ALgorithm)
3 | Copyright (C) 2007-2016 University of Tennessee / UT-Battelle
4 |
5 | Code Author: Doug Hyatt
6 |
7 | This program is free software: you can redistribute it and/or modify
8 | it under the terms of the GNU General Public License as published by
9 | the Free Software Foundation, either version 3 of the License, or
10 | (at your option) any later version.
11 |
12 | This program is distributed in the hope that it will be useful,
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | GNU General Public License for more details.
16 |
17 | You should have received a copy of the GNU General Public License
18 | along with this program. If not, see .
19 | *******************************************************************************/
20 |
21 | #ifndef _TRAIN_H
22 | #define _TRAIN_H
23 |
24 | #include
25 | #include
26 | #include
27 |
28 |
29 | struct _training {
30 | double gc; /* GC Content */
31 | int trans_table; /* 11 = Standard Microbial, NCBI Trans Table to
32 | use */
33 | double st_wt; /* Start weight */
34 | double bias[3]; /* GC frame bias for each of the 3 positions */
35 | double type_wt[3]; /* Weights for ATG vs GTG vs TTG */
36 | int uses_sd; /* 0 if doesn't use SD motif, 1 if it does */
37 | double rbs_wt[28]; /* Set of weights for RBS scores */
38 | double ups_comp[32][4]; /* Base composition weights for non-RBS-distance
39 | motifs. 0-1 are the -1/-2 position, 2-31 are
40 | the -15 to -44 positions. Second array is
41 | the base A,C,T,G,etc. */
42 | double mot_wt[4][4][4096]; /* Weights for upstream motifs. First index is
43 | the motif length (3-6), the second is the
44 | spacer distance (0 = 5-10bp, 1 = 3-4bp, 2 =
45 | 11-12bp, 3 = 13-15bp), and the last is the
46 | numerical value of the motif (ranging from 0
47 | to 4095 for 6-mers, less for shorter
48 | motifs) */
49 | double no_mot; /* Weight for the case of no motif */
50 | double gene_dc[4096]; /* Coding statistics for the genome */
51 | };
52 |
53 | int write_training_file(char *, struct _training *);
54 | int read_training_file(char *, struct _training *);
55 |
56 | void initialize_metagenome_0(struct _training *);
57 | void initialize_metagenome_1(struct _training *);
58 | void initialize_metagenome_2(struct _training *);
59 | void initialize_metagenome_3(struct _training *);
60 | void initialize_metagenome_4(struct _training *);
61 | void initialize_metagenome_5(struct _training *);
62 | void initialize_metagenome_6(struct _training *);
63 | void initialize_metagenome_7(struct _training *);
64 | void initialize_metagenome_8(struct _training *);
65 | void initialize_metagenome_9(struct _training *);
66 | void initialize_metagenome_10(struct _training *);
67 | void initialize_metagenome_11(struct _training *);
68 | void initialize_metagenome_12(struct _training *);
69 | void initialize_metagenome_13(struct _training *);
70 | void initialize_metagenome_14(struct _training *);
71 | void initialize_metagenome_15(struct _training *);
72 | void initialize_metagenome_16(struct _training *);
73 | void initialize_metagenome_17(struct _training *);
74 | void initialize_metagenome_18(struct _training *);
75 | void initialize_metagenome_19(struct _training *);
76 | void initialize_metagenome_20(struct _training *);
77 | void initialize_metagenome_21(struct _training *);
78 | void initialize_metagenome_22(struct _training *);
79 | void initialize_metagenome_23(struct _training *);
80 | void initialize_metagenome_24(struct _training *);
81 | void initialize_metagenome_25(struct _training *);
82 | void initialize_metagenome_26(struct _training *);
83 | void initialize_metagenome_27(struct _training *);
84 | void initialize_metagenome_28(struct _training *);
85 | void initialize_metagenome_29(struct _training *);
86 | void initialize_metagenome_30(struct _training *);
87 | void initialize_metagenome_31(struct _training *);
88 | void initialize_metagenome_32(struct _training *);
89 | void initialize_metagenome_33(struct _training *);
90 | void initialize_metagenome_34(struct _training *);
91 | void initialize_metagenome_35(struct _training *);
92 | void initialize_metagenome_36(struct _training *);
93 | void initialize_metagenome_37(struct _training *);
94 | void initialize_metagenome_38(struct _training *);
95 | void initialize_metagenome_39(struct _training *);
96 | void initialize_metagenome_40(struct _training *);
97 | void initialize_metagenome_41(struct _training *);
98 | void initialize_metagenome_42(struct _training *);
99 | void initialize_metagenome_43(struct _training *);
100 | void initialize_metagenome_44(struct _training *);
101 | void initialize_metagenome_45(struct _training *);
102 | void initialize_metagenome_46(struct _training *);
103 | void initialize_metagenome_47(struct _training *);
104 | void initialize_metagenome_48(struct _training *);
105 | void initialize_metagenome_49(struct _training *);
106 |
107 | #endif
108 |
--------------------------------------------------------------------------------
/node.h:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | PRODIGAL (PROkaryotic DynamIc Programming Genefinding ALgorithm)
3 | Copyright (C) 2007-2016 University of Tennessee / UT-Battelle
4 |
5 | Code Author: Doug Hyatt
6 |
7 | This program is free software: you can redistribute it and/or modify
8 | it under the terms of the GNU General Public License as published by
9 | the Free Software Foundation, either version 3 of the License, or
10 | (at your option) any later version.
11 |
12 | This program is distributed in the hope that it will be useful,
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | GNU General Public License for more details.
16 |
17 | You should have received a copy of the GNU General Public License
18 | along with this program. If not, see .
19 | *******************************************************************************/
20 |
21 | #ifndef _NODE_H
22 | #define _NODE_H
23 |
24 | #include
25 | #include
26 | #include "sequence.h"
27 | #include "training.h"
28 |
29 | #define STT_NOD 100000
30 | #define MIN_GENE 90
31 | #define MIN_EDGE_GENE 60
32 | #define MAX_SAM_OVLP 60
33 | #define ST_WINDOW 60
34 | #define OPER_DIST 60
35 | #define EDGE_BONUS 0.74
36 | #define EDGE_UPS -1.00
37 | #define META_PEN 7.5
38 |
39 | struct _motif {
40 | int ndx; /* Index of the best motif for this node */
41 | int len; /* Length of the motif */
42 | int spacer; /* Spacer between coding start and the motif */
43 | int spacendx; /* Index for this spacer length */
44 | double score; /* Score for the motif */
45 | };
46 |
47 | struct _node {
48 | int type; /* 0=ATG, 1=GTG, 2=TTG/Other, 3=Stop */
49 | int edge; /* Runs off the edge; 0 = normal, 1 = edge node */
50 | int ndx; /* position in the sequence of the node */
51 | int strand; /* 1 = forward, -1 = reverse */
52 | int stop_val; /* For a stop, record previous stop; for start, record
53 | its stop */
54 | int star_ptr[3]; /* Array of starts w/in MAX_SAM_OVLP bases of a stop in 3
55 | frames */
56 | int gc_bias; /* Frame of highest GC content within this node */
57 | double gc_score[3]; /* % GC content in different codon positions */
58 | double cscore; /* Coding score for this node (based on 6-mer usage) */
59 | double gc_cont; /* GC Content for the node */
60 | int rbs[2]; /* SD RBS score for this node (based on binding energy)
61 | rbs[0] = best motif with exact match, rbs[1] = with
62 | mismatches */
63 | struct _motif mot; /* Upstream motif information for this node */
64 | double uscore; /* Score for the upstream -1/-2, -15to-45 region */
65 | double tscore; /* Score for the ATG/GTG/TTG value */
66 | double rscore; /* Score for the RBS motif */
67 | double sscore; /* Score for the strength of the start codon */
68 | int traceb; /* Traceback to connecting node */
69 | int tracef; /* Forward trace */
70 | int ov_mark; /* Marker to help untangle overlapping genes */
71 | double score; /* Score of total solution to this point */
72 | int elim; /* If set to 1, eliminate this gene from the model */
73 | };
74 |
75 | int add_nodes(unsigned char *, unsigned char *, int, struct _node *, int,
76 | mask *, int, struct _training *);
77 | void reset_node_scores(struct _node *, int);
78 | int compare_nodes(const void *, const void *);
79 | int stopcmp_nodes(const void *, const void *);
80 |
81 | void record_overlapping_starts(struct _node *, int, struct _training *, int);
82 | void record_gc_bias(int *, struct _node *, int, struct _training *);
83 |
84 | void calc_dicodon_gene(struct _training *, unsigned char *, unsigned char *,
85 | int, struct _node *, int);
86 | void calc_amino_bg(struct _training *, unsigned char *, unsigned char *, int,
87 | struct _node *, int);
88 |
89 | void score_nodes(unsigned char *, unsigned char *, int, struct _node *, int,
90 | struct _training *, int, int);
91 | void raw_coding_score(unsigned char *, unsigned char *, int, struct _node *,
92 | int, struct _training *);
93 | void calc_orf_gc(unsigned char *, unsigned char *, int, struct _node *, int,
94 | struct _training *);
95 | void rbs_score(unsigned char *, unsigned char *, int, struct _node *, int,
96 | struct _training *);
97 | void score_upstream_composition(unsigned char *, int, struct _node *,
98 | struct _training *);
99 |
100 | void determine_sd_usage(struct _training *);
101 |
102 | double intergenic_mod(struct _node *, struct _node *, struct _training *);
103 |
104 | void train_starts_sd(unsigned char *, unsigned char *, int, struct _node *,
105 | int, struct _training *);
106 | void train_starts_nonsd(unsigned char *, unsigned char *, int, struct _node *,
107 | int, struct _training *);
108 |
109 | void count_upstream_composition(unsigned char *, int, int, int,
110 | struct _training *);
111 |
112 | void build_coverage_map(double [4][4][4096], int [4][4][4096], double, int);
113 | void find_best_upstream_motif(struct _training *, unsigned char *, unsigned
114 | char *, int, struct _node *, int);
115 | void update_motif_counts(double [4][4][4096], double *, unsigned char *,
116 | unsigned char *, int, struct _node *, int);
117 |
118 | void write_start_file(FILE *, struct _node *, int, struct _training *, int,
119 | int, int, char *, char *, char *);
120 |
121 | int cross_mask(int, int, mask *, int);
122 |
123 | double dmax(double, double);
124 | double dmin(double, double);
125 |
126 | #endif
127 |
--------------------------------------------------------------------------------
/CHANGES:
--------------------------------------------------------------------------------
1 | VERSION 2.6.3
2 |
3 | * Fixed a bug in protein translation output of partial genes where TTG/GTG
4 | codons were being incorrectly translated to methionine.
5 |
6 | VERSION 2.6.2
7 |
8 | * Added support for translation table 25.
9 | * Corrected another bug affecting MacOS.
10 | * Fixed a line in the 'uninstall' directive in the Makefile.
11 |
12 | VERSION 2.6.1
13 |
14 | * Fixed a bug that mainly affected Mac compiles 7/2013 and
15 | posted to Google Code and Github as 2.60 (bad, as we already
16 | had a 2.60). Re-releasing this version 8/2014 as 2.6.1,
17 | but the source is identical to "2.60bugfix1" except for updated dates.
18 | a more streamlined Makefile, and a new markdown README.md.
19 | * Moved to semantic versioning (major.minor.patch) with the 8/2014
20 | re-release. Committed to being more rigorous about this moving
21 | forward.
22 |
23 | VERSION 2.60
24 |
25 | * Minor Output Changes: There are some output changes in this version. See
26 | below for more details.
27 | * Added a confidence score to the output, representing the % likelihood the
28 | gene is real. (conf=99.99;, etc.)
29 | * Redid the training for metagenomic gene prediction and added more weights
30 | and rules. Upped the number of training files to 50.
31 | * Eliminated the sampling phase of metagenomic prediction and replaced it with
32 | running on all training files within a given range of GC content.
33 | * Fixed a bug where Prodigal incorrectly reported "Piped input detected..."
34 | when there was no piped input.
35 | * Changed the output function not to replace header names unless the header
36 | is empty (formerly replaced headers <4 letters in length).
37 | * Changed the output function to report the first word of headers in GFF/
38 | Genbank outputs as is, without checking for GFF3 characters that need to be
39 | escaped.
40 | * Eliminated the sequence number from the protein translation/mrna outputs.
41 | * Fixed a bug in protein translation where N's in the nucleotide sequence
42 | were being translated to P's instead of X's.
43 |
44 | VERSION 2.50
45 |
46 | * In GFF output, changed "type=ATG" to "start_type=ATG" to fix a bug where
47 | BioPerl's GFF parser couldn't parse the Prodigal GFF output due to a conflict
48 | with this tag.
49 | * Fixed a problem with genes being truncated early in small contigs when they
50 | should run off the edges.
51 | * Fixed a problem with multiple overlapping genes running off edges.
52 | * Reduced the number of metagenomic bins from 8 to 6, which reduces the
53 | running time of the metagenomic program. This was found not to lose any
54 | significant accuracy.
55 | * Redid the metagenomic clustering using a different methodology and wound up
56 | with 39 training files instead of 30.
57 | * Added rules to increase sensitivity in draft/metagenomic fragments.
58 | * Added rules to reduce false positives of negative coding genes in metagenomic
59 | fragments.
60 |
61 | VERSION 2.00
62 |
63 | * Added metagenomic genefinding routines to Prodigal, accessible via the -p
64 | meta option.
65 | * Substantial Output Changes: A definition line is now printed before each set
66 | of CDS entries, and a '//' is printed after each set of CDS. Detailed
67 | information is now printed in /note fields, and in the attributes field of GFF.
68 | For more information, see the README file.
69 | * GFF3 Support: The GFF output is now 9 columns (gff version 3).
70 | * Argument Change: The '-f' option now specifies output format type (formerly
71 | this was done by '-o').
72 | * New Options: -i, -o for input/output files, -p for metagenomic/single genome
73 | modes, -d to write DNA sequence of genes to a file, -q to run quietly.
74 | * Built multiple FASTA handling into the base program (draft_prodigal.pl
75 | script is no longer needed).
76 | * Changed existing rules and added new ones specifically to handle large
77 | numbers of small contigs (and genes that run off the edges of them).
78 | * Fixed bugs in the add_nodes function and cleaned it up.
79 |
80 | Output is no longer in the same format as 1.0-1.20.
81 | Some command line options have changed from 1.0-1.20.
82 |
83 | VERSION 1.20
84 |
85 | * Moderately improved start site prediction by adding an upstream
86 | scoring system for the -1/-2 positions and the -15 to -45 positions.
87 | * Added a routine to correct starts of rarer types (TTG in E. coli, etc.)
88 | that win via every other parameter (coding, RBS, and upstream score).
89 | * Reduced the minimum gene size for genes running off edges to 50bp. This
90 | should help in identifying fragmented genes in draft or metagenomic data.
91 | * Added more detailed information to the starts file, including ATG/GTG/TTG
92 | usage, the RBS bin and spacer distance, and the new upstream composition
93 | score.
94 | * Added a '-n' option to force the program not to use the SD motif finder.
95 | (This can be useful if you suspect the organism uses a motif like AAGAGG and
96 | you would like to get to the AAG/etc. motifs which will be missed by the SD
97 | finder. It is also useful to get very specific RBS motifs and spacers in
98 | the starts file).
99 | * Added gene.c/h files containing a data structure for final gene models
100 | (exported from the dynamic programming). Moved printing of translations and
101 | gene models to this data structure.
102 | * Added GFF output specifiable with the '-o gff' option.
103 | * Fixed a bug where running with a training file and without a training file
104 | produced different results (this elusive bug has existed since 1.0).
105 | * Modifed intergenic score weighting and fixed some minor bugs with this
106 | function.
107 | * Fixed some bugs that only occurred when compiled for Windows.
108 | * Modified draft_prodigal.pl to catch signals and generally run more robustly.
109 |
110 | Starts files are no longer in the same format as 1.0-1.10.
111 | Training files for 1.0-1.10 are NOT compatible with 1.20+.
112 |
113 | VERSION 1.10
114 |
115 | * Added support for multiple FASTA input via a wrapper script called
116 | "draft_prodigal". Requires Perl 5.
117 | * Added an alternative start scoring model that automatically discovers RBS
118 | motifs and builds a model from upstream regions. This model was found to
119 | perform slightly worse in SD genomes than the existing code, and it also takes
120 | twice as long, so we only use it when a genome is determined not to use the SD
121 | motif.
122 | * Fixed a bug in parsing Genbank files where the parser did not understand lines
123 | with "[gap 100] Extend Ns" etc. in them.
124 |
125 | Training files for 1.0-1.05 are NOT compatible with 1.10+.
126 |
127 | VERSION 1.05
128 |
129 | * Added support for exclusion of RNA regions from gene modeling via masking such
130 | objects in the sequence with n's and using the '-m' option to make Prodigal
131 | recognize them as such.
132 |
133 | VERSION 1.04
134 |
135 | * Modified Prodigal to allow genes to run off edges. (User can disallow this
136 | with the -c option).
137 | * Allowed Prodigal to run on any size sequences if using data from a training
138 | file.
139 |
140 | VERSION 1.03
141 |
142 | * Fixed a bug where Prodigal didn't handle Windows C/R's in sequence input.
143 | * Modified the start trainer to function better in the absence (or scarcity) of
144 | good genes to train on.
145 |
146 | VERSION 1.02
147 |
148 | * Added protein translation support via -a flag.
149 | * Added full translation table support via -g flag and removed the -n option.
150 | * Fixed a bug that caused prodigal to hang occasionally (involving 4 consecutive
151 | overlapping genes in the dynamic programming model).
152 |
153 | Training files for version 1.01 are NOT compatible with version 1.02+.
154 |
155 | VERSION 1.01
156 |
157 | * Reduced the number of false positives by fixing a bug in the
158 | eliminate_bad_genes routine that was causing genes not to be omitted.
159 | * Increased the accuracy of the RBS scorer slightly by creating more bins based
160 | on distance and motifs and ordering then slightly differently.
161 | * Fixed a bug in the dynamic programming model in zero gene cases.
162 |
163 | Training files for version 1.0 are NOT compatible with version 1.01.
164 |
--------------------------------------------------------------------------------
/metagenomic.c:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | PRODIGAL (PROkaryotic DynamIc Programming Genefinding ALgorithm)
3 | Copyright (C) 2007-2016 University of Tennessee / UT-Battelle
4 |
5 | Code Author: Doug Hyatt
6 |
7 | This program is free software: you can redistribute it and/or modify
8 | it under the terms of the GNU General Public License as published by
9 | the Free Software Foundation, either version 3 of the License, or
10 | (at your option) any later version.
11 |
12 | This program is distributed in the hope that it will be useful,
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | GNU General Public License for more details.
16 |
17 | You should have received a copy of the GNU General Public License
18 | along with this program. If not, see .
19 | *******************************************************************************/
20 |
21 | #include "metagenomic.h"
22 |
23 | /*******************************************************************************
24 | Initialize the metagenomic bins with the precalculated training files
25 | from the model organisms that best represent all of microbial Genbank.
26 | *******************************************************************************/
27 | void initialize_metagenomic_bins(struct _metagenomic_bin *meta) {
28 | initialize_metagenome_0(meta[0].tinf);
29 | initialize_metagenome_1(meta[1].tinf);
30 | initialize_metagenome_2(meta[2].tinf);
31 | initialize_metagenome_3(meta[3].tinf);
32 | initialize_metagenome_4(meta[4].tinf);
33 | initialize_metagenome_5(meta[5].tinf);
34 | initialize_metagenome_6(meta[6].tinf);
35 | initialize_metagenome_7(meta[7].tinf);
36 | initialize_metagenome_8(meta[8].tinf);
37 | initialize_metagenome_9(meta[9].tinf);
38 | initialize_metagenome_10(meta[10].tinf);
39 | initialize_metagenome_11(meta[11].tinf);
40 | initialize_metagenome_12(meta[12].tinf);
41 | initialize_metagenome_13(meta[13].tinf);
42 | initialize_metagenome_14(meta[14].tinf);
43 | initialize_metagenome_15(meta[15].tinf);
44 | initialize_metagenome_16(meta[16].tinf);
45 | initialize_metagenome_17(meta[17].tinf);
46 | initialize_metagenome_18(meta[18].tinf);
47 | initialize_metagenome_19(meta[19].tinf);
48 | initialize_metagenome_20(meta[20].tinf);
49 | initialize_metagenome_21(meta[21].tinf);
50 | initialize_metagenome_22(meta[22].tinf);
51 | initialize_metagenome_23(meta[23].tinf);
52 | initialize_metagenome_24(meta[24].tinf);
53 | initialize_metagenome_25(meta[25].tinf);
54 | initialize_metagenome_26(meta[26].tinf);
55 | initialize_metagenome_27(meta[27].tinf);
56 | initialize_metagenome_28(meta[28].tinf);
57 | initialize_metagenome_29(meta[29].tinf);
58 | initialize_metagenome_30(meta[30].tinf);
59 | initialize_metagenome_31(meta[31].tinf);
60 | initialize_metagenome_32(meta[32].tinf);
61 | initialize_metagenome_33(meta[33].tinf);
62 | initialize_metagenome_34(meta[34].tinf);
63 | initialize_metagenome_35(meta[35].tinf);
64 | initialize_metagenome_36(meta[36].tinf);
65 | initialize_metagenome_37(meta[37].tinf);
66 | initialize_metagenome_38(meta[38].tinf);
67 | initialize_metagenome_39(meta[39].tinf);
68 | initialize_metagenome_40(meta[40].tinf);
69 | initialize_metagenome_41(meta[41].tinf);
70 | initialize_metagenome_42(meta[42].tinf);
71 | initialize_metagenome_43(meta[43].tinf);
72 | initialize_metagenome_44(meta[44].tinf);
73 | initialize_metagenome_45(meta[45].tinf);
74 | initialize_metagenome_46(meta[46].tinf);
75 | initialize_metagenome_47(meta[47].tinf);
76 | initialize_metagenome_48(meta[48].tinf);
77 | initialize_metagenome_49(meta[49].tinf);
78 | sprintf(meta[0].desc, "%d|%s|%s|%.1f|%d|%d", 0,
79 | "Mycoplasma_bovis_PG45",
80 | "B", 29.31, meta[0].tinf->trans_table, meta[0].tinf->uses_sd);
81 | sprintf(meta[1].desc, "%d|%s|%s|%.1f|%d|%d", 1,
82 | "Mycoplasma_pneumoniae_M129",
83 | "B", 40.01, meta[1].tinf->trans_table, meta[1].tinf->uses_sd);
84 | sprintf(meta[2].desc, "%d|%s|%s|%.1f|%d|%d", 2,
85 | "Mycoplasma_suis_Illinois",
86 | "B", 31.08, meta[2].tinf->trans_table, meta[2].tinf->uses_sd);
87 | sprintf(meta[3].desc, "%d|%s|%s|%.1f|%d|%d", 3,
88 | "Aeropyrum_pernix_K1",
89 | "A", 56.31, meta[3].tinf->trans_table, meta[3].tinf->uses_sd);
90 | sprintf(meta[4].desc, "%d|%s|%s|%.1f|%d|%d", 4,
91 | "Akkermansia_muciniphila_ATCC_BAA_835",
92 | "B", 55.76, meta[4].tinf->trans_table, meta[4].tinf->uses_sd);
93 | sprintf(meta[5].desc, "%d|%s|%s|%.1f|%d|%d", 5,
94 | "Anaplasma_marginale_Maries",
95 | "B", 49.76, meta[5].tinf->trans_table, meta[5].tinf->uses_sd);
96 | sprintf(meta[6].desc, "%d|%s|%s|%.1f|%d|%d", 6,
97 | "Anaplasma_phagocytophilum_HZ",
98 | "B", 41.64, meta[6].tinf->trans_table, meta[6].tinf->uses_sd);
99 | sprintf(meta[7].desc, "%d|%s|%s|%.1f|%d|%d", 7,
100 | "Archaeoglobus_fulgidus_DSM_4304",
101 | "A", 48.58, meta[7].tinf->trans_table, meta[7].tinf->uses_sd);
102 | sprintf(meta[8].desc, "%d|%s|%s|%.1f|%d|%d", 8,
103 | "Bacteroides_fragilis_NCTC_9343",
104 | "B", 43.19, meta[8].tinf->trans_table, meta[8].tinf->uses_sd);
105 | sprintf(meta[9].desc, "%d|%s|%s|%.1f|%d|%d", 9,
106 | "Brucella_canis_ATCC_23365",
107 | "B", 57.21, meta[9].tinf->trans_table, meta[9].tinf->uses_sd);
108 | sprintf(meta[10].desc, "%d|%s|%s|%.1f|%d|%d", 10,
109 | "Burkholderia_rhizoxinica_HKI_454",
110 | "B", 59.70, meta[10].tinf->trans_table, meta[10].tinf->uses_sd);
111 | sprintf(meta[11].desc, "%d|%s|%s|%.1f|%d|%d", 11,
112 | "Candidatus_Amoebophilus_asiaticus_5a2",
113 | "B", 35.05, meta[11].tinf->trans_table, meta[11].tinf->uses_sd);
114 | sprintf(meta[12].desc, "%d|%s|%s|%.1f|%d|%d", 12,
115 | "Candidatus_Korarchaeum_cryptofilum_OPF8",
116 | "A", 49.00, meta[12].tinf->trans_table, meta[12].tinf->uses_sd);
117 | sprintf(meta[13].desc, "%d|%s|%s|%.1f|%d|%d", 13,
118 | "Catenulispora_acidiphila_DSM_44928",
119 | "B", 69.77, meta[13].tinf->trans_table, meta[13].tinf->uses_sd);
120 | sprintf(meta[14].desc, "%d|%s|%s|%.1f|%d|%d", 14,
121 | "Cenarchaeum_symbiosum_B",
122 | "A", 57.19, meta[14].tinf->trans_table, meta[14].tinf->uses_sd);
123 | sprintf(meta[15].desc, "%d|%s|%s|%.1f|%d|%d", 15,
124 | "Chlorobium_phaeobacteroides_BS1",
125 | "B", 48.93, meta[15].tinf->trans_table, meta[15].tinf->uses_sd);
126 | sprintf(meta[16].desc, "%d|%s|%s|%.1f|%d|%d", 16,
127 | "Chlorobium_tepidum_TLS",
128 | "B", 56.53, meta[16].tinf->trans_table, meta[16].tinf->uses_sd);
129 | sprintf(meta[17].desc, "%d|%s|%s|%.1f|%d|%d", 17,
130 | "Desulfotomaculum_acetoxidans_DSM_771",
131 | "B", 41.55, meta[17].tinf->trans_table, meta[17].tinf->uses_sd);
132 | sprintf(meta[18].desc, "%d|%s|%s|%.1f|%d|%d", 18,
133 | "Desulfurococcus_kamchatkensis_1221n",
134 | "B", 45.34, meta[18].tinf->trans_table, meta[18].tinf->uses_sd);
135 | sprintf(meta[19].desc, "%d|%s|%s|%.1f|%d|%d", 19,
136 | "Erythrobacter_litoralis_HTCC2594",
137 | "B", 63.07, meta[19].tinf->trans_table, meta[19].tinf->uses_sd);
138 | sprintf(meta[20].desc, "%d|%s|%s|%.1f|%d|%d", 20,
139 | "Escherichia_coli_UMN026",
140 | "B", 50.72, meta[20].tinf->trans_table, meta[20].tinf->uses_sd);
141 | sprintf(meta[21].desc, "%d|%s|%s|%.1f|%d|%d", 21,
142 | "Haloquadratum_walsbyi_DSM_16790",
143 | "A", 47.86, meta[21].tinf->trans_table, meta[21].tinf->uses_sd);
144 | sprintf(meta[22].desc, "%d|%s|%s|%.1f|%d|%d", 22,
145 | "Halorubrum_lacusprofundi_ATCC_49239",
146 | "A", 57.14, meta[22].tinf->trans_table, meta[22].tinf->uses_sd);
147 | sprintf(meta[23].desc, "%d|%s|%s|%.1f|%d|%d", 23,
148 | "Hyperthermus_butylicus_DSM_5456",
149 | "A", 53.74, meta[23].tinf->trans_table, meta[23].tinf->uses_sd);
150 | sprintf(meta[24].desc, "%d|%s|%s|%.1f|%d|%d", 24,
151 | "Ignisphaera_aggregans_DSM_17230",
152 | "A", 35.69, meta[24].tinf->trans_table, meta[24].tinf->uses_sd);
153 | sprintf(meta[25].desc, "%d|%s|%s|%.1f|%d|%d", 25,
154 | "Marinobacter_aquaeolei_VT8",
155 | "B", 57.27, meta[25].tinf->trans_table, meta[25].tinf->uses_sd);
156 | sprintf(meta[26].desc, "%d|%s|%s|%.1f|%d|%d", 26,
157 | "Methanopyrus_kandleri_AV19",
158 | "A", 61.16, meta[26].tinf->trans_table, meta[26].tinf->uses_sd);
159 | sprintf(meta[27].desc, "%d|%s|%s|%.1f|%d|%d", 27,
160 | "Methanosphaerula_palustris_E1_9c",
161 | "A", 55.35, meta[27].tinf->trans_table, meta[27].tinf->uses_sd);
162 | sprintf(meta[28].desc, "%d|%s|%s|%.1f|%d|%d", 28,
163 | "Methanothermobacter_thermautotrophicus_Delta_H",
164 | "B", 49.54, meta[28].tinf->trans_table, meta[28].tinf->uses_sd);
165 | sprintf(meta[29].desc, "%d|%s|%s|%.1f|%d|%d", 29,
166 | "Methylacidiphilum_infernorum_V4",
167 | "B", 45.48, meta[29].tinf->trans_table, meta[29].tinf->uses_sd);
168 | sprintf(meta[30].desc, "%d|%s|%s|%.1f|%d|%d", 30,
169 | "Mycobacterium_leprae_TN",
170 | "B", 57.80, meta[30].tinf->trans_table, meta[30].tinf->uses_sd);
171 | sprintf(meta[31].desc, "%d|%s|%s|%.1f|%d|%d", 31,
172 | "Natrialba_magadii_ATCC_43099",
173 | "A", 61.42, meta[31].tinf->trans_table, meta[31].tinf->uses_sd);
174 | sprintf(meta[32].desc, "%d|%s|%s|%.1f|%d|%d", 32,
175 | "Orientia_tsutsugamushi_Boryong",
176 | "B", 30.53, meta[32].tinf->trans_table, meta[32].tinf->uses_sd);
177 | sprintf(meta[33].desc, "%d|%s|%s|%.1f|%d|%d", 33,
178 | "Pelotomaculum_thermopropionicum_SI",
179 | "B", 52.96, meta[33].tinf->trans_table, meta[33].tinf->uses_sd);
180 | sprintf(meta[34].desc, "%d|%s|%s|%.1f|%d|%d", 34,
181 | "Prochlorococcus_marinus_MIT_9313",
182 | "B", 50.74, meta[34].tinf->trans_table, meta[34].tinf->uses_sd);
183 | sprintf(meta[35].desc, "%d|%s|%s|%.1f|%d|%d", 35,
184 | "Pyrobaculum_aerophilum_IM2",
185 | "A", 51.36, meta[35].tinf->trans_table, meta[35].tinf->uses_sd);
186 | sprintf(meta[36].desc, "%d|%s|%s|%.1f|%d|%d", 36,
187 | "Ralstonia_solanacearum_PSI07",
188 | "B", 66.13, meta[36].tinf->trans_table, meta[36].tinf->uses_sd);
189 | sprintf(meta[37].desc, "%d|%s|%s|%.1f|%d|%d", 37,
190 | "Rhizobium_NGR234",
191 | "B", 58.49, meta[37].tinf->trans_table, meta[37].tinf->uses_sd);
192 | sprintf(meta[38].desc, "%d|%s|%s|%.1f|%d|%d", 38,
193 | "Rhodococcus_jostii_RHA1",
194 | "B", 65.05, meta[38].tinf->trans_table, meta[38].tinf->uses_sd);
195 | sprintf(meta[39].desc, "%d|%s|%s|%.1f|%d|%d", 39,
196 | "Rickettsia_conorii_Malish_7",
197 | "B", 32.44, meta[39].tinf->trans_table, meta[39].tinf->uses_sd);
198 | sprintf(meta[40].desc, "%d|%s|%s|%.1f|%d|%d", 40,
199 | "Rothia_dentocariosa_ATCC_17931",
200 | "B", 53.69, meta[40].tinf->trans_table, meta[40].tinf->uses_sd);
201 | sprintf(meta[41].desc, "%d|%s|%s|%.1f|%d|%d", 41,
202 | "Shigella_dysenteriae_Sd197",
203 | "B", 51.25, meta[41].tinf->trans_table, meta[41].tinf->uses_sd);
204 | sprintf(meta[42].desc, "%d|%s|%s|%.1f|%d|%d", 42,
205 | "Synechococcus_CC9605",
206 | "B", 59.22, meta[42].tinf->trans_table, meta[42].tinf->uses_sd);
207 | sprintf(meta[43].desc, "%d|%s|%s|%.1f|%d|%d", 43,
208 | "Synechococcus_JA_2_3B_a_2_13_",
209 | "B", 58.45, meta[43].tinf->trans_table, meta[43].tinf->uses_sd);
210 | sprintf(meta[44].desc, "%d|%s|%s|%.1f|%d|%d", 44,
211 | "Thermoplasma_volcanium_GSS1",
212 | "A", 39.92, meta[44].tinf->trans_table, meta[44].tinf->uses_sd);
213 | sprintf(meta[45].desc, "%d|%s|%s|%.1f|%d|%d", 45,
214 | "Treponema_pallidum_Nichols",
215 | "B", 52.77, meta[45].tinf->trans_table, meta[45].tinf->uses_sd);
216 | sprintf(meta[46].desc, "%d|%s|%s|%.1f|%d|%d", 46,
217 | "Tropheryma_whipplei_TW08_27",
218 | "B", 46.31, meta[46].tinf->trans_table, meta[46].tinf->uses_sd);
219 | sprintf(meta[47].desc, "%d|%s|%s|%.1f|%d|%d", 47,
220 | "Xenorhabdus_nematophila_ATCC_19061",
221 | "B", 44.15, meta[47].tinf->trans_table, meta[47].tinf->uses_sd);
222 | sprintf(meta[48].desc, "%d|%s|%s|%.1f|%d|%d", 48,
223 | "Xylella_fastidiosa_Temecula1",
224 | "B", 51.78, meta[48].tinf->trans_table, meta[48].tinf->uses_sd);
225 | sprintf(meta[49].desc, "%d|%s|%s|%.1f|%d|%d", 49,
226 | "_Nostoc_azollae__0708",
227 | "B", 38.45, meta[49].tinf->trans_table, meta[49].tinf->uses_sd);
228 | }
229 |
--------------------------------------------------------------------------------
/dprog.c:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | PRODIGAL (PROkaryotic DynamIc Programming Genefinding ALgorithm)
3 | Copyright (C) 2007-2016 University of Tennessee / UT-Battelle
4 |
5 | Code Author: Doug Hyatt
6 |
7 | This program is free software: you can redistribute it and/or modify
8 | it under the terms of the GNU General Public License as published by
9 | the Free Software Foundation, either version 3 of the License, or
10 | (at your option) any later version.
11 |
12 | This program is distributed in the hope that it will be useful,
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | GNU General Public License for more details.
16 |
17 | You should have received a copy of the GNU General Public License
18 | along with this program. If not, see .
19 | *******************************************************************************/
20 |
21 | #include "dprog.h"
22 |
23 | /*******************************************************************************
24 | Basic dynamic programming routine for predicting genes. The 'flag' variable
25 | is set to 0 for the initial dynamic programming routine based solely on GC
26 | frame plot (used to construct a training set. If the flag is set to 1, the
27 | routine does the final dynamic programming based on
28 | coding, RBS scores, etc.
29 | *******************************************************************************/
30 |
31 | int dprog(struct _node *nod, int nn, struct _training *tinf, int flag) {
32 | int i, j, min, max_ndx = -1, path, nxt, tmp;
33 | double max_sc = -1.0;
34 |
35 | if(nn == 0) return -1;
36 | for(i = 0; i < nn; i++) {
37 | nod[i].score = 0;
38 | nod[i].traceb = -1;
39 | nod[i].tracef = -1;
40 | }
41 | for(i = 0; i < nn; i++) {
42 |
43 | /* Set up distance constraints for making connections, */
44 | /* but make exceptions for giant ORFS. */
45 | if(i < MAX_NODE_DIST) min = 0; else min = i-MAX_NODE_DIST;
46 | if(nod[i].strand == -1 && nod[i].type != STOP && nod[min].ndx >=
47 | nod[i].stop_val)
48 | while(min >= 0 && nod[i].ndx != nod[i].stop_val) min--;
49 | if(nod[i].strand == 1 && nod[i].type == STOP && nod[min].ndx >=
50 | nod[i].stop_val)
51 | while(min >= 0 && nod[i].ndx != nod[i].stop_val) min--;
52 | if(min < MAX_NODE_DIST) min = 0;
53 | else min = min-MAX_NODE_DIST;
54 | for(j = min; j < i; j++) {
55 | score_connection(nod, j, i, tinf, flag);
56 | }
57 | }
58 | for(i = nn-1; i >= 0; i--) {
59 | if(nod[i].strand == 1 && nod[i].type != STOP) continue;
60 | if(nod[i].strand == -1 && nod[i].type == STOP) continue;
61 | if(nod[i].score > max_sc) { max_sc = nod[i].score; max_ndx = i; }
62 | }
63 |
64 | /* First Pass: untangle the triple overlaps */
65 | path = max_ndx;
66 | while(nod[path].traceb != -1) {
67 | nxt = nod[path].traceb;
68 | if(nod[path].strand == -1 && nod[path].type == STOP &&
69 | nod[nxt].strand == 1 && nod[nxt].type == STOP &&
70 | nod[path].ov_mark != -1 && nod[path].ndx > nod[nxt].ndx) {
71 | tmp = nod[path].star_ptr[nod[path].ov_mark];
72 | for(i = tmp; nod[i].ndx != nod[tmp].stop_val; i--);
73 | nod[path].traceb = tmp;
74 | nod[tmp].traceb = i;
75 | nod[i].ov_mark = -1;
76 | nod[i].traceb = nxt;
77 | }
78 | path = nod[path].traceb;
79 | }
80 |
81 | /* Second Pass: Untangle the simple overlaps */
82 | path = max_ndx;
83 | while(nod[path].traceb != -1) {
84 | nxt = nod[path].traceb;
85 | if(nod[path].strand == -1 && nod[path].type != STOP && nod[nxt].strand == 1
86 | && nod[nxt].type == STOP) {
87 | for(i = path; nod[i].ndx != nod[path].stop_val; i--);
88 | nod[path].traceb = i; nod[i].traceb = nxt;
89 | }
90 | if(nod[path].strand == 1 && nod[path].type == STOP && nod[nxt].strand == 1
91 | && nod[nxt].type == STOP) {
92 | nod[path].traceb = nod[nxt].star_ptr[(nod[path].ndx)%3];
93 | nod[nod[path].traceb].traceb = nxt;
94 | }
95 | if(nod[path].strand == -1 && nod[path].type == STOP && nod[nxt].strand == -1
96 | && nod[nxt].type == STOP) {
97 | nod[path].traceb = nod[path].star_ptr[(nod[nxt].ndx)%3];
98 | nod[nod[path].traceb].traceb = nxt;
99 | }
100 | path = nod[path].traceb;
101 | }
102 |
103 | /* Mark forward pointers */
104 | path = max_ndx;
105 | while(nod[path].traceb != -1) {
106 | nod[nod[path].traceb].tracef = path;
107 | path = nod[path].traceb;
108 | }
109 |
110 | if(nod[max_ndx].traceb == -1) return -1;
111 | else return max_ndx;
112 | }
113 |
114 | /*******************************************************************************
115 | This routine scores the connection between two nodes, the most basic of which
116 | is 5'fwd->3'fwd (gene) and 3'rev->5'rev (rev gene). If the connection ending
117 | at n2 is the maximal scoring model, it updates the pointers in the dynamic
118 | programming model. n3 is used to handle overlaps, i.e. cases where 5->3'
119 | overlaps 5'->3' on the same strand. In this case, 3' connects directly to 3',
120 | and n3 is used to untangle the 5' end of the second gene.
121 | *******************************************************************************/
122 |
123 | void score_connection(struct _node *nod, int p1, int p2, struct _training *tinf,
124 | int flag) {
125 | struct _node *n1 = &(nod[p1]), *n2 = &(nod[p2]), *n3;
126 | int i, left = n1->ndx, right = n2->ndx, bnd, ovlp = 0, maxfr = -1;
127 | double score = 0.0, scr_mod = 0.0, maxval;
128 |
129 | /***********************/
130 | /* Invalid Connections */
131 | /***********************/
132 |
133 | /* 5'fwd->5'fwd, 5'rev->5'rev */
134 | if(n1->type != STOP && n2->type != STOP && n1->strand == n2->strand) return;
135 |
136 | /* 5'fwd->5'rev, 5'fwd->3'rev */
137 | else if(n1->strand == 1 && n1->type != STOP && n2->strand == -1) return;
138 |
139 | /* 3'rev->5'fwd, 3'rev->3'fwd) */
140 | else if(n1->strand == -1 && n1->type == STOP && n2->strand == 1) return;
141 |
142 | /* 5'rev->3'fwd */
143 | else if(n1->strand == -1 && n1->type != STOP && n2->strand == 1 && n2->type ==
144 | STOP) return;
145 |
146 | /******************/
147 | /* Edge Artifacts */
148 | /******************/
149 | if(n1->traceb == -1 && n1->strand == 1 && n1->type == STOP) return;
150 | if(n1->traceb == -1 && n1->strand == -1 && n1->type != STOP) return;
151 |
152 | /*********/
153 | /* Genes */
154 | /*********/
155 |
156 | /* 5'fwd->3'fwd */
157 | else if(n1->strand == n2->strand && n1->strand == 1 && n1->type != STOP &&
158 | n2->type == STOP) {
159 | if(n2->stop_val >= n1->ndx) return;
160 | if(n1->ndx % 3 != n2->ndx % 3) return;
161 | right += 2;
162 | if(flag == 0) scr_mod = tinf->bias[0]*n1->gc_score[0] +
163 | tinf->bias[1]*n1->gc_score[1] + tinf->bias[2]*n1->gc_score[2];
164 | else if(flag == 1) score = n1->cscore + n1->sscore;
165 | }
166 |
167 | /* 3'rev->5'rev */
168 | else if(n1->strand == n2->strand && n1->strand == -1 && n1->type == STOP &&
169 | n2->type != STOP) {
170 | if(n1->stop_val <= n2->ndx) return;
171 | if(n1->ndx % 3 != n2->ndx % 3) return;
172 | left -= 2;
173 | if(flag == 0) scr_mod = tinf->bias[0]*n2->gc_score[0] +
174 | tinf->bias[1]*n2->gc_score[1] + tinf->bias[2]*n2->gc_score[2];
175 | else if(flag == 1) score = n2->cscore + n2->sscore;
176 | }
177 |
178 | /********************************/
179 | /* Intergenic Space (Noncoding) */
180 | /********************************/
181 |
182 | /* 3'fwd->5'fwd */
183 | else if(n1->strand == 1 && n1->type == STOP && n2->strand == 1 && n2->type !=
184 | STOP) {
185 | left += 2;
186 | if(left >= right) return;
187 | if(flag == 1) score = intergenic_mod(n1, n2, tinf);
188 | }
189 |
190 | /* 3'fwd->3'rev */
191 | else if(n1->strand == 1 && n1->type == STOP && n2->strand == -1 && n2->type ==
192 | STOP) {
193 | left += 2; right -= 2;
194 | if(left >= right) return;
195 | /* Overlapping Gene Case 2: Three consecutive overlapping genes f r r */
196 | maxfr = -1; maxval = 0.0;
197 | for(i = 0; i < 3; i++) {
198 | if(n2->star_ptr[i] == -1) continue;
199 | n3 = &(nod[n2->star_ptr[i]]);
200 | ovlp = left - n3->stop_val + 3;
201 | if(ovlp <= 0 || ovlp >= MAX_OPP_OVLP) continue;
202 | if(ovlp >= n3->ndx - left) continue;
203 | if(n1->traceb == -1) continue;
204 | if(ovlp >= n3->stop_val - nod[n1->traceb].ndx - 2) continue;
205 | if((flag == 1 && n3->cscore + n3->sscore + intergenic_mod(n3, n2, tinf) >
206 | maxval) || (flag == 0 && tinf->bias[0]*n3->gc_score[0] +
207 | tinf->bias[1]*n3->gc_score[1] + tinf->bias[2]*n3->gc_score[2] >
208 | maxval)) {
209 | maxfr = i;
210 | maxval = n3->cscore + n3->sscore + intergenic_mod(n3, n2, tinf);
211 | }
212 | }
213 | if(maxfr != -1) {
214 | n3 = &(nod[n2->star_ptr[maxfr]]);
215 | if(flag == 0) scr_mod = tinf->bias[0]*n3->gc_score[0] +
216 | tinf->bias[1]*n3->gc_score[1] +
217 | tinf->bias[2]*n3->gc_score[2];
218 | else if(flag == 1) score = n3->cscore + n3->sscore +
219 | intergenic_mod(n3, n2, tinf);
220 | }
221 | else if(flag == 1) score = intergenic_mod(n1, n2, tinf);
222 | }
223 |
224 | /* 5'rev->3'rev */
225 | else if(n1->strand == -1 && n1->type != STOP && n2->strand == -1 && n2->type
226 | == STOP) {
227 | right -= 2;
228 | if(left >= right) return;
229 | if(flag == 1) score = intergenic_mod(n1, n2, tinf);
230 | }
231 |
232 | /* 5'rev->5'fwd */
233 | else if(n1->strand == -1 && n1->type != STOP && n2->strand == 1 && n2->type
234 | != STOP) {
235 | if(left >= right) return;
236 | if(flag == 1) score = intergenic_mod(n1, n2, tinf);
237 | }
238 |
239 | /********************/
240 | /* Possible Operons */
241 | /********************/
242 |
243 | /* 3'fwd->3'fwd, check for a start just to left of first 3' */
244 | else if(n1->strand == 1 && n2->strand == 1 && n1->type == STOP && n2->type ==
245 | STOP) {
246 | if(n2->stop_val >= n1->ndx) return;
247 | if(n1->star_ptr[n2->ndx%3] == -1) return;
248 | n3 = &(nod[n1->star_ptr[n2->ndx%3]]);
249 | left = n3->ndx; right += 2;
250 | if(flag == 0) scr_mod = tinf->bias[0]*n3->gc_score[0] +
251 | tinf->bias[1]*n3->gc_score[1] + tinf->bias[2]*n3->gc_score[2];
252 | else if(flag == 1) score = n3->cscore + n3->sscore +
253 | intergenic_mod(n1, n3, tinf);
254 | }
255 |
256 | /* 3'rev->3'rev, check for a start just to right of second 3' */
257 | else if(n1->strand == -1 && n1->type == STOP && n2->strand == -1 && n2->type
258 | == STOP) {
259 | if(n1->stop_val <= n2->ndx) return;
260 | if(n2->star_ptr[n1->ndx%3] == -1) return;
261 | n3 = &(nod[n2->star_ptr[n1->ndx%3]]);
262 | left -= 2; right = n3->ndx;
263 | if(flag == 0) scr_mod = tinf->bias[0]*n3->gc_score[0] +
264 | tinf->bias[1]*n3->gc_score[1] + tinf->bias[2]*n3->gc_score[2];
265 | else if(flag == 1) score = n3->cscore + n3->sscore +
266 | intergenic_mod(n3, n2, tinf);
267 | }
268 |
269 | /***************************************/
270 | /* Overlapping Opposite Strand 3' Ends */
271 | /***************************************/
272 |
273 | /* 3'for->5'rev */
274 | else if(n1->strand == 1 && n1->type == STOP && n2->strand == -1 && n2->type
275 | != STOP) {
276 | if(n2->stop_val-2 >= n1->ndx+2) return;
277 | ovlp = (n1->ndx+2) - (n2->stop_val-2) + 1;
278 | if(ovlp >= MAX_OPP_OVLP) return;
279 | if((n1->ndx+2 - n2->stop_val-2 + 1) >= (n2->ndx -n1->ndx+3 + 1)) return;
280 | if(n1->traceb == -1) bnd = 0;
281 | else bnd = nod[n1->traceb].ndx;
282 | if((n1->ndx+2 - n2->stop_val-2 + 1) >= (n2->stop_val-3 - bnd + 1)) return;
283 | left = n2->stop_val-2;
284 | if(flag == 0) scr_mod = tinf->bias[0]*n2->gc_score[0] +
285 | tinf->bias[1]*n2->gc_score[1] + tinf->bias[2]*n2->gc_score[2];
286 | else if(flag == 1) score = n2->cscore + n2->sscore - 0.15*tinf->st_wt;
287 | }
288 |
289 | if(flag == 0) score = ((double)(right-left+1-(ovlp*2)))*scr_mod;
290 |
291 | if(n1->score + score >= n2->score) {
292 | n2->score = n1->score + score;
293 | n2->traceb = p1;
294 | n2->ov_mark = maxfr;
295 | }
296 |
297 | return;
298 | }
299 |
300 | /*******************************************************************************
301 | Sometimes bad genes creep into the model due to the node distance constraint
302 | in the dynamic programming routine. This routine just does a sweep through
303 | the genes and eliminates ones with negative scores.
304 | *******************************************************************************/
305 |
306 | void eliminate_bad_genes(struct _node *nod, int dbeg, struct _training *tinf) {
307 | int path;
308 |
309 | if(dbeg == -1) return;
310 | path = dbeg;
311 | while(nod[path].traceb != -1) path = nod[path].traceb;
312 | while(nod[path].tracef != -1) {
313 | if(nod[path].strand == 1 && nod[path].type == STOP)
314 | nod[nod[path].tracef].sscore += intergenic_mod(&nod[path],
315 | &nod[nod[path].tracef], tinf);
316 | if(nod[path].strand == -1 && nod[path].type != STOP)
317 | nod[path].sscore += intergenic_mod(&nod[path], &nod[nod[path].tracef],
318 | tinf);
319 | path = nod[path].tracef;
320 | }
321 |
322 | path = dbeg;
323 | while(nod[path].traceb != -1) path = nod[path].traceb;
324 | while(nod[path].tracef != -1) {
325 | if(nod[path].strand == 1 && nod[path].type != STOP &&
326 | nod[path].cscore + nod[path].sscore < 0) {
327 | nod[path].elim = 1; nod[nod[path].tracef].elim = 1;
328 | }
329 | if(nod[path].strand == -1 && nod[path].type == STOP &&
330 | nod[nod[path].tracef].cscore + nod[nod[path].tracef].sscore < 0) {
331 | nod[path].elim = 1; nod[nod[path].tracef].elim = 1;
332 | }
333 | path = nod[path].tracef;
334 | }
335 | }
336 |
--------------------------------------------------------------------------------
/anthus_aco.fas:
--------------------------------------------------------------------------------
1 | >61430_aco
2 | ACAGGTTAGAAACTACTCTGTTTTCTGGCTCCTTGTTTAATGCCCTGTCCTATTTTATTGCGAAAATTGTCTGTTTTTCACAGAAAACTGAGAGTAGTCAAGGGATTCCTTGTCCTTTGCTTTGGTCTGCACAGCTGTCTTGTTTTAAGGCCAAGTGGAATGAGACAGCTGACTCTTCAGGTGTGAAAACTTGGATGTAGGTGTAGATTGGCTCTCAGTTGACCTCCAGCTGGTGCAGATTCTTCAGTTTGTTTGATGGAGCTTTGAGAAGTCCTTTCAGACTGAAGGATACTCTGAATTTTAGCTATGGAGATAATGTGGATGTTGTGTGTTTAAGTCCTGTTTGCAGTTTTTTTCTGTTCAGTCAGTTATTTTACTGTGTGAGTCAGGACCCTTAGAAGCCCTCAGTGGCAACCACAGAGCGCACAGTTAATTTTCTGTGCAAGAAAATTAAGATCATACTCTGTGTCCAGGAAAGTCAAGAATATTCCTGGTTTTCTCTACTGTAAAATTTTATCTTGTAACTTGTGTTTGGGTCTGCATGATTATTCAAAAATCTTAGTAGATTTGGAAGGATGTTGCATATTATGGAAACAAAGTTGGAAAAAGTTTGTATCAGTTGCAGTATTTCTTCACATCATTTNTTAACNNCNTNNNNNNNNNGCTTCTGCCACTTGAAAAGACAAATTAAAAACNAATTTATAATGCTTATATGCTTTAGTTACATTNGGGTCTTTCAGTAACTTTAGTGCTTTTGATAGCCATACCTGTGAGNTTGACAGTGTCTAAAATTAGAAGTGTTCCTTTTCTTCTGCTCTTCCCATTCTCGTGTGTCTTCAATAGTTTCTGCAAATAATGATGTGCAGACTTAGCATTGATTCAACAGCAGAGGTAAGCATACCTGTGGCTTACTTGGCTTCAGCTTATCCAGCAGTGCCAACCACTCTCTGTTTGTCTTAC
3 | >626029_aco
4 | ACAGGTTAGAAACTACTCTGTTTTCTGGCTGCTTGTTTAATGCCCTCTCCTATTTTATTGTGACGATTGTCTGTTTTTCACAGAAAACTGAGAGTAGTCAAGGGATTCCTTGTCCTTTGCTTTGGTGTGCACAGCTGTCTTGTTTTAAGGCCCAGTGGAATGAGACAGCTGACTCTTCAGGTGTGAAAACTTGGATGTACGTGTAGATTGGCTCTCAGTTGACCTCCAGCTGGTGCAGATTCTTCAGTTTGTTTGATGGAGCTTTGAGAAGTCCTTTCAGACTGAAGGATACTCTGAATTTTAGCTATGGAAATAATGTGGATGTTGTGTGTTTAAGCACTGTTTGCAGTTTTTTTCTGTTCAGTCAGTTATTTTACTGTGTGAGTCAGGACTCTTAGAAGCCCTCTGTGGCAACCACAGAGCGCATAGTTAATTTTCTGTACAAGAAAATTAAGATCCTACTCAGTGTTCAGGAAAGTCAAGAATATTCCTGGTTTTCTCTACTGTAAAATTTTATCTTGTAACTTGTGTTTGGGTCTGCATGATTATTCAAAAATCTTAGTAGATTTGGAAGGATGTTGCATTTTATGGAAACAAAGTTGGGAAAAGTTTGTATCAGTTCCAGTATTTCTTCACATCATTTNTTAACNNCNTNNNNNNNNNGCTTCTACCACTTGAAAAGACAAATTAAAAACNAATTTATAATGCTTATATGCTTTAGTTACATTNGGGTCTTTCAGTAACTTTAGTGCTTTACTTAGCCATACCTGTGAGCNTGGCAGTGTCTAAAATTAGAAGTGTTCCTTTTCTTCTGCTCTTCCCATTCTCGTGTGTCTTCAATAGTTTCTGCAAATAATGATGTGCAGACTTAGCATTGGTTCAACAGCAGAGGTAAAAATACCTGTGGCTTACCCGGCTTCAGCTTATCCAGCAGTGCCAACCACTCTCTGTTTGTCTTAC
5 | >630116_aco
6 | ACAGGTTAGAAACTACTCTGTTTTCTGGCTCCTTGTTTAATGCCCTGTCCTATTTTATTGCGAAAATTGTCTGTTTTTCACAGAAAACTGAGAGTAGTCAAGGGATTCCTTGTCCTTTGCTTTGGTCTGCACAGCTGTCTTGTTTTAAGGCCAAGTGGAATGAGACAGCTGACTCTTCAGGTGTGAAAACTTGGATGTAGGTGTAGATTGGCTCTCAGTTGACCTCCAGCTGGTGCAGATTCTTCAGTTTGTTTGATGGAGCTTTGAGAAGTCCTTTCAGACTGAAGGATACTCTGAATTTTAGCTATGGAGATAATGTGGATGTTGTGTGTTTAAGTCCTGTTTGCAGTTTTTTTCTGTTCAGTCAGTTATTTTACTGTGTGAGTCAGGACCCTTAGAAGCCCTCAGTGGCAACCACAGAGCGCACAGTTAATTTTCTGTGCAAGAAAATTAAGATCATACTCTGTGTCCAGGAAAGTCAAGAATATTCCTGGTTTTCTCTACTGTAAAATTTTATCTTGTAACTTGTGTTTGGGTCTGCATGATTATTCAAAAATCTTAGTAGATTTGGAAGGATGTTGCATATTATGGAAACAAAGTTGGAAAAAGTTTGTATCAGTTGCAGTATTTCTTCACATCATTTNTTAACNNCNTNNNNNNNNNGCTTCTGCCACTTGAAAAGACAAATTAAAAACNAATTTATAATGCTTATATGCTTTAGTTACATTNGGGTCTTTCAGTAACTTTAGTGCTTTTGATAGCCATACCTGTGAGNTTGACAGTGTCTAAAATTAGAAGTGTTCCTTTTCTTCTGCTCTTCCCATTCTCGTGTGTCTTCAATAGTTTCTGCAAATAATGATGTGCAGACTTAGCATTGATTCAACAGCAGAGGTAAGCATACCTGTGGCTTACTTGGCTTCAGCTTATCCAGCAGTGCCAACCACTCTCTGTTTGTCTTAC
7 | >630210_aco
8 | ACAGGTTAGAAACTACTCTGTTTTCTGGCTCCTTGTTTAATGCCCTGTCCTATTTTATTGTGACAATTGTCTGTTTTTCACAGAAAACTGAGAGTAGTCAAGGGATTCCTTGTCCTTTGCTTTGGTCTGCACAGCTGTCTTGTTTTAAGGCCAAGTGGAATGAGACAGCTGACTCTTCAGGTGTGAAAACTTGGATGTAGGTGTAGATTGGCTCTTAGTTGACCTCCAGCTGGTGCAGATTCTTCAGTTTGTTTGATGGAGCTTTGAGAAGTCCTTTCAGACTGAAGGATACTCTGAATTTTAGCTATGGAGATAATGTGGATGTTGTGTGTTTAAGCCCTGTTTGCAGTTTTTTTCTGTTCAGTCAGTTATTTTACTGTGTGAGTCAGGACCCTTAGAAGCCCTCAGTGGCAACCACAGAGCGCACAGTTAATTTTCTGTGCAAGAAAATTAACAACATACTCTGTGTCCAGGAAAGTCAAGAATATTCCTGGTTTTCTCTACTGTAAAATTTTATCTTGTAACTTGTGTTTGGGTCTGCATGATTATTCAAAAATCTTAGTAGATTTGGAAGGATGTTGCATATTATGGAAACAAAGTTGGAAAAAGTTTGTATCAGTTCCAGTAGTTCNNCANGTNATTTCTTCACATCATTTTTAACCTGCTTCTACCACTTGAAAAGACAAATTAAAAACNAATTTATAATGCTTATATGCTTTAGTTACATTNGGGTCTTTCAGTAACTTTAGTGCTTTTGATAGCCATACCTGTGAGNTTGACAGTGTCTAAAATTAGAAGTGTTCCTTTTCTTCTGCTCTTCCCATTCTYGTGTGTCTTCAATAGTTTCTGCAAATAATGATGTGCAGACTTAGCATTGATTCAACAGCAGAGGTAASCATACCTGTGGCTTACTTGGCTTCAGCTTATCCAGCAGTGCCAACCACTCTCTGTTTGTCTTAC
9 | >B25702_aco
10 | ACAGGTTAGAAACTACTCTGTTTTCTGGCTCCTTGTTTAATGCCCTGTCCTATTTTATTGTGACAATTGTCTGTTTTTCACAGAAAACTGAGAGTAGTCAAGGGATTCCTTGTCCTTTGCTTTGGTCTGCACAGCTGTCTTGTTTTAAGGCCCAGTGGAATGAGACAGCTGACTCTTCAGGTGTGAAAACTTGGATGTAGGTGTAGATTGGCTCTCAGTTGACCTCCAGCTGGTGCAGATTCTTCACTTTGTTTGGTGGAGCTTTGAGAAGTCCTTTCAGACTGAAGGATACTCTGAATTTTAGCTATGGAAATAATGTGGATGTTGTGTGTTTAAGCCCTGTTTGCAGTTTTTTTCTGTTCAGTCAGTTATTTTACTGTGTGAGTCAGGACTCTTAGAAGCCCTCTGTGGCAACCACAGAGCGCATAGTTAATTTTCTGTGCAAGAAAATTAAGATCCTACTCAATGTTCAGGAAAGTCAAGAATATTCCTGTTTTTTTCTACTGTAAAATTTTATCTTGTAACTTGTGTTTGGGTCTGCATGATTATTCAAAAATCTTAGTAGATTTGGAAGGATGTTGCATATTATGGAAACAAAGTTGGAAAAAGTTTGTATCAGTTCCAGTATTTCTTCACATCATTTNTTAACNNCNTNNNNNNNNNGCTTCTACCACTTGAAAAGACAAATTAAAAACNAATTTATAATGCTTATATGCTTTAGTTACATTNGGGTCTTTCAGTAACTTTAGTGCTTTTGATAGCCATACCTGTGAGCTTGGCAGTGTCTAAAATTAGAAGTGTTCCTTTTCTTCTGCTCTTCCCATTCTTGTGTGTCTTCAATAGTTTCTGCAAATAATGATGTGCAGACTTAGCATTGGTTCAACAGCAGAGGTAAAAATACCTGTGGCTTACTTGGCTTCAGCTTATCCAGCAGTGCCAACCACTCTCTGTTTGTCTTAC
11 | >B41613_aco
12 | ACAGGTTAGAAACTACTCTGTTTTCTGGCTGCTTGTTTAATGCCCTCTCCTATTTTATTGTGACAATTGTCTGTTTTTCACAGAAAACTGAGAGTAGTCAAGGGATTCCTTGTCCTTTGCTTTGGTCTGCACAGCTGTCTTGTTTTAAGGCCCAGTGGAATGAGACAGCTGACTCTTCAGGTGTGAAAACTTGGATGTAGGTGTAGATTGGCTCTCAGTTGACCTCCAGCTGGTGCAGATTCTTCAGTTTGTTTGATGGAGCTTTGAGAAGTCCTTTCAGACTGAAGGATACTCTGAATTTTAGCTATGGAAATAATGTGGATGTTGTGTGTTTAAGCACTGTTTGCAGTTTTTTTCTGTTCAGTCAGTTATTTTACTGTGTGAGTCAGGACTCTTAGAAGCCCTCTGTGGCAACCACAGAGCGCATAGTTAATTTTCTGTACAAGAAAATTAAGATCCTACTCAGTGTTCAGGAAAGTCAAGAATATTCCTGGTTTTCTCTACTGTAAAATTTTATCTTGTAACTTGTGTTTGGGTCTGCATGATTATTCAAAAATCTTAGTAGATTTGGAAGGATGTTGCATTTTATGGAAACAAAGTTGGGAAAAGTTTGTATCAGTTCCAGTATTTCTTCACATCATTTNTTAACNNCNTNNNNNNNNNGCTTCTACCACTTGAAAAGACAAATTAAAAACNAATTTATAATGCTTATATGCTTTAGTTACATTNGGGTCTTTCAGTAACTTTAGTGCTTTTCATAGCCATACCTGTGAGCNTGGCAGTGTCTAAAATTAGAAGTGTTCCTTTTCTTCTGCTCTTCCCATTCTCGTGTGTCTTCAATAGTTTCTGCAAATAATGATGTGCAGACTTAGCATTGGTTCAACAGCAGAGGTAAAAATACCTGTGGCTTACTTGGCTTCAGCTTATCCAGCAGTGCCAACCACTCTCTGTTTGTCTTAC
13 | >B431_aco
14 | ACAGGTTAGAAACTACTCTGTTTTCTGGCTCCTTGTTTAATGCCCTGTCCTATTTTATTGCGACAATTGTCTGTTTTTCACAGAAAACTGAGAGTAGTCAAGGGATTCCTTGTCCTTTGCTTTGGTCTGCACAGCTGTCTTGTTTTAAGGCGAAGTGGAATGAGACAGCTGACTCTTCAGGTGTGAAAACTTGGATGTAGGTGTAGATTGGCTCTCAGTTGACCTCCAGCTGGTGCAGATTCTTCAGTTTGTTTGATGGAGCTTTGAGAAGTCCTTTCAGACTGAAGGATACTCTGAATTTTAGCTATGGAGATAATGTGGATGTTGTGTGTTTAAGCCCTGTTTGCAGTTTTTTTCTGTTCAGTCAGTTATTTTACTGTGTGAGTCAGGACCCTTAGAAGCCCTCAGTGGCAACCACAGAGCGCACATTTAATTTTCTGTGCAAGAAAATTAACAACATACTCTGTGTCCAGGAAAGTCAAGAATATTCCTGGTTTTCTCTACTGTAAAATTTTATCTTGTAACTTGTGTTTGGGTCTGCATGATTATTCAAAAATCTTAGTAGATTTGGAAGGATGTTGCATATTATGGAAACAAAGTTGGAAAAAGTTTGTATCAGTTCCAGTATTTCTTCACATCATTTNTTAACNNCNTNNNNNNNNNGCTTCTACCACTTCAAAAGACAAATTAAAAACNAATTTATAATGCTTATATGCTTTAGTTACATTAGGGTCTTTCAGTAACTTTAGTGCTTTTGATAGCCATACCTGTGAGNTTGACAGTGTCTAAAATTAGAAGTATTCCTTTTCTTCTGCTCTTCCCATTCTCGTGTGTCTTCAATAGTTTCTGCAAATAATGATGTGCAGACTTAACATTGATTCACCAGCAGAGGTAAGCATACCTGTGGCTTACTTGGCTTCAGCTTATCCAGCAGTGCCAGCCACTCTCTGTTTGTCTTAC
15 | >B87109_aco
16 | ACAGGTTAGAAACTACTCTGTTTTCTGGCTGCTTGTTTAATGCCCTCTCCTATTTTATTGTGACAATTGTCTGTTTTTCACAGAAAACTGAGAGTAGTCAAGGGATTCCTTGTCCTTTGCTTTGGTCTGCACAGCTGTCTTGTTTTAAGGCCCAGTGGAATGAGACAGCTGACTCTTCAGGTGTGAAAACTTGGATGTAGGTGTAGATTGGCTCTCAGTTGACCTCCAGCTGGTGCAGATTTTTCAGTTTGTTTGATGGAGCTTTGAGAAGTCCTTTCAGACTGAAGGATACTCTGAATTTTAGCTATGGAAATAATGTGGATGTTGTGTGTTTAAGCACTGTTTGCAGTTTTTTTCTGTTCAGTCAGTTATTTTACTGTGTGAGTCAGGACTCTTAGAAGCCCTCTGTGGCAACCACAGAGCGCATAGTTAATTTTCTGTGCAAGAAAATTAAGATCCTACTCAGTGTTCAGGAAAGTCAAGAATATTCCTGGTTTTCTCTACTGTAAAATTTTATCTTGTAACTTGTGTTTGGGTCTGCATGATTATTCAAAAATCTTAGTAGATTTGGAAGGATGTTGCATATTATGGAAACAAAGTTGGGAAAAGTTTGTATCAGTTCCAGTATTTCTTCACATCATTTNTTAACNNCNTNNNNNNNNNGCTTCTACCACTTGAAAAGACAAATTAAAAACNAATTTATAATGCTTATATGCTTTAGTTACATTNGGGTCTTTCAGTAACTTTAGTGCTTTTCATAGCCATACCTGTGAGCNTGGCAGTGTCTAAAATTAGAAGTGTTCCTTTTCTTCTGCTCTTCCCATTCTCGTGTGTCTTCAATAGTTTCTGCAAATAATGATGTGCAGACTTAGCATTGGTTCAACAGCAGAGGTAAAAATACCTGTGGCTTACTTGGCTTCAGCTTATCCAGCAGTGCCAACCACTCTCTGTTTGTCTTAC
17 | >B48218_aco
18 | ACAGGTTAGAAACTACTCTGTTTTCTGGCTCCTTGTTTATTGCCCTGTCCTATTTTATTGCGACAATTGTCTGTTTTTCACAGAAAACTGAGAGTAGTCAAGGGATTCCTTGTCCTTTGCTTTGGTCTGCACAGCTGTCTTGTTTTAAGGCCAAGTGGAATGAGACAGCTGACTCTTCAGGTGTGAAAACTTGGATGTAGGTGTAGATTGGCTCTCAGTTGACTTCCAGCTGGTGCAGATTCTTCAGTTTGTTTGATGGAGCTTTGAGAAGTCCTTTCAGACTGAAGGATACTCTGAATTTTAGCTATGGAGATAATGTGGATGTTGTGTGTTTAAGCCCTGTTTGCAGTTTTTTTCTGTTCAGTCAGTTATTTTACTGTGTGAGTCAGGACCCTTAGAAGCCCTCAGTGGCAACCACAGAGCGCACAGTTAATTTTCTGTGCAAGAAAATTAAGATCATACTCTGTGTCCAGGAAAGTCAAGAATATTCCTGGTTTTCTCTACTGTAAAATTTTATCTTATAACTTGTGTTTGGGTCTGCATGATTATTCAAAAATCTTAGTAGATTTGGAAGGATGTNGCATATTATGGAAACAAAGTTGGAAAAAGTTTGTATCAGTTCCAGTATTTCTTCACATCATTTNTTAACNNCNTNNNNNNNNNGCTTCTACCACTTGAAAAGACAAATTAAAAACNAATTTATAATGCTTATATGCTTTAGTTACATTNGGGTCTTTCAGTAACTTTAGTGCTTTTGATAGCCATACCTGTGAGNTTGACAGTGTCTAAAATTAGAAGTGTTCCTTTTCTTCTGCTCTTCCCATTCTTGTGTGTCTTCAATAGTTTCTGCAAATAATGATGTGCAGACTTAGCATTGATTCANCAGCAGAGGTAAGCATACCTGTGGCTTACTTGGCTTCAGCTTATCCAGCAGTGCCAACCACTCTCTGTTTGTCTTAC
19 | >UWBM54394_aco
20 | ACAGGTTAGAAACTACTCTGTTTTCTGGCTCCTTGTTTAATGCCCTGTCCTATTTTATTGCGACAATTGTCTGTTTTTCACAGAAAACTGAGAGTAGTCAAGGGATTCCTTGTCCTTTGCTTTGGTCTGCACAGCTGTCTTGTTTTAAGGCGAAGTGGAATGAGACAGCTGACTCTTCAGGTGTGAAAACTTGGATGTAGGTGTAGATTGGCTCTCAGTTGACCTCCAGCTGGTGCAGATTCTTCAGTTTGTTTGATGGAGCTTTGAGAAGTCCTTTCAGACTGAAGGATACTCTGAATTTTAGCTATGGAGATAATGTGGATGTTGTGTGTTTAAGCCCTGTTTGCAGTTTTTTTCTGTTCAGTCAGTTATTTTACTGTGTGAGTCAGGACCCTTAGAAGCCCTCAGTGGCAACCACAGAGCGCACATTTAATTTTCTGTGCAAGAAAATTAACAACATACTCTGTGTCCAGGAAAGTCAAGAATATTCCTGGTTTTCTCTACTGTAAAATTTTATCTTGTAACTTGTGTTTGGGTCTGCATGATTATTCAAAAATCTTAGTAGATTTGGAAGGATGTTGCATATTATGGAAACAAAGTTGGAAAAAGTTTGTATCAGTTCCAGTATTTCTTCACATCATTTNTTAACNNCNTNNNNNNNNNGCTTCTACCACTTGAAAAGACAAATTAAAAACNAATTTATAATGCTTATATGCTTTAGTTACATTAGGGTCTTTCAGTAACTTTAGTGCTTTTGATAGCCATACCTGTGAGNTTGACAGTGTCTAAAATTAGAAGTATTCCTTTTCTTCTGCTCTTCCCATTCTCGTGTGTCTTCAATAGTTTCTGCAAATAATGATGTGCAGACTTAGCATTGATTCACCAGCAGAGGTAAGCATACCTGTGGCTTACTTGGCTTCAGCTTATCCAGCAGTGCCAGCCACTCTCTGTTTGTCTTAC
21 | >AMNH13589_aco
22 | ACAGGTTAGAAACTACTCTGTTTTCTGGCTCCTTGTTTAATGCCCTGTCCTATTTTATTGCGAAAATTGTCTGTTTTTCACAGAAAACTGAGAGTAGTCAAGGGATTCCTTGTCCTTTGCTTTGGTCTGCACAGCTGTCTTGTTTTAAGGCCAAGTGGAATGAGACAGCTGACTCTTCAGGTGTGAAAACTTGGATGTAGGTGTAGATTGGCTCTCAGTTGACCTCCAGCTGGTGCAGATTCTTCAGTTTGTTTGATGGAGCTTTGAGAAGTCCTTTCAGACTGAAGGATACTCTGAATTTTAGCTATGGAGATAATGTGGATGTTGTGTGTTTAAGTCCTGTTTGCAGTTTTTTTCTGTTCAGTCAGTTATTTTACTGTGTGAGTCAGGACCCTTAGAAGCCCTCAGTGGCAACCACAGAGCGCACAGTTAATTTTCTGTGCAAGAAAATTAAGATCATACTCTGTGTCCAGGAAAGTCAAGAATATTCCTGGTTTTCTCTACTGTAAAATTTTATCTTGTAACTTGTGTTTGGGTCTGCATGATTATTCAAAAATCTTAGTAGATTTGGAAGGATGTTGCATATTATGGAAACAAAGTTGGAAAAAGTTTGTATCAGTTGCAGTATTTCTTCACATCATTTNTTAACNNCNTNNNNNNNNNGCTTCTGCCACTTGAAAAGACAAATTAAAAACNAATTTATAATGCTTATATGCTTTAGTTACATTNGGGTCTTTCAGTAACTTTAGTGCTTTTGATAGCCATACCTGTGAGNTTGACAGTGTCTAAAATTAGAAGTGTTCCTTTTCTTCTGCTCTTCCCATTCTCGTGTGTCTTCAATAGTTTCTGCAAATAATGATGTGCAGACTTAGCATTGATTCAACAGCAGAGGTAAGCATACCTGTGGCTTACTTGGCTTCAGCTTATCCAGCAGTGCCAACCACTCTCTGTTTGTCTTAC
23 | >KU25127_aco
24 | ACAGGTTAGAAACTACTCTGTTTTCTGGCTCCTTGTTTAATGCCCTGTCCTATTTTATTGCGACAATTGTCTGTTTTTCACAGAAAACTGAGAGTAGTCAAGGGATTCCTTGTCCTTTGCTTTGGTCTGCACAGCTGTCTTGTTTTAAGGCCAAGTGGAATGAGACAGCTGACTCTTCAGGTGTGAAAACTTGGATGTAGGTGTAGATTGGCTCTCAGTTGACCTCCAGCTGGTGCAGATTCTTCAGTTTGTTTGATGGAGCTTTGAGAAGTCCTTTCAGACTGAAGGATACTCTGAATTTTAGCTATGGAGATAATGTGGATGTTGTGTGTTTAAGCCCTGTTTGCAGTTTTTTTCTGTTCAGTCAGTTATTTTACTGTGTGAGTCAGGACCCTTAGAAGCCCTCAGTGGCAACCACAGAGCGCACATTTAATTTTCTGTGCAAGAAAATTAACAACATACTCTGTGTCCAGGAAAGTCAAGAATATTCCTGGTTTTCTCTACTGTAAAATTTTATCTTGTAACTTGTGTTTGGGTCTGCATGATTATTCAAAAATCTTAGTAGATTTGGAAGGATGTTGCATATTATGGAAACAAAGTTGGAAAAAGTTTGTATCAGTTCCAGTATTTCTTCACATCATTTNTTAACNNCNTNNNNNNNNNGCTTCTACCACTTCAAAAGACAAATTAAAAACNAATTTATAATGCTTATATGCTTTAGTTACATTAGGGTCTTTCAGTAACTTTAGTGCTTTTGATAGCCATACCTGTGAGNTTGACAGTGTCTAAAATTAGAAGTATTCCTTTTCTTCTGCTCTTCCCATTCTNGTGTGTCTTCAATAGTTTCTGCAAATAATGATGTGCAGACTTAACATTGATTCACCAGCAGAGGTAAGCATACCTGTGGCTTACTTGGCTTCAGCTTATCCAGCAGTGCCAGCCACTCTCTGTTTGTCTTAC
25 | >FALK1_aco
26 | ACAGGTTAGAAACTACTCTGTTTTCTGGCTCCTTGTTTAATGCCCTGTCCTATTTTATTGCGACAATTGTCTGTTTTTCACAGAAAACTGAGAGTAGTCAAGGGATTCCTTGTCCTTTGCTTTGGTCTGCACAGCTGTCTTGTTTTAAGGCCAAGTGGAATGAGACAGCTGACTCTTCAGGTGTGAAAACTTGGATGTAGGTGTAGATTGGCTCTCAGTTGACCTCCAGCTGGTGCAGATTCTTCAGTTTGTTTGATGGAGCTTTGAGAAGTCCTTTCAGACTGAAGGATACTCTGAATTTTAGCTATGGAGATAATGTGGATGTTGTGTGTTTAAGTCCTGTTTGCAGTTTTTTTCTGTTCAGTCAGTTATTTTACTGTGTGAGTCAGGACCCTTAGAAGCCCTCAGTGGCAACCACAGAGCGCACAGTTAATTTTCTGTGCAAGAAAATTAAGATCATACTCTGTGTCCAGGAAAGTCAAGAATATTCCTGGTTTTCTCTACTGTAAAATTTTATCTTGTAACTTGTGTTTGGGTCTGCATGATTATTCAAAAATCTTAGTAGATTTGGAAGGATGTTGCATATTATGGAAACAAAGTTGGAAAAAGTTTGTATCAGTTGCAGTATTTCTTCACATCATTTNTTAACNNCNTNNNNNNNNNGCTTCTGCCACTTGAAAAGACAAATTAAAAACNAATTTATAATGCTTATATGCTTTAGTTACATTNGGGTCTTTCAGTAACTTTAGTGCTTTTGATAGCCATACCTGTGAGNTTGACAGTGTCTAAAATTAGAAGTGTTCCTTTTCTTCTGCTCTTCCCATTCTCGTGTGTCTTCAATAGTTTCTGCAAATAATGATGTGCAGACTTAGCATTGATTCAACAGCAGAGGTAAGCATACCTGTGGCTTACTTGGCTTCAGCTTATCCAGCAGTGCCAACCACTCTCTGTTTGTCTTAC
27 | >KU21673_aco
28 | ACAGGTTAGAAACTACTCTGTTTTCTGGCTCCTTGTTTAATGCCCTGTCCTATTTTATTGTGACAATTGTCTGTTTTTCACAGAAAACTGAGAGTAGTCAAGGGATTCCTTGTCCTTTGCTTTGGTCTGCACAGCTGTCTTGTTTTAAGGCCCAGTGGAATGAGACAGCTGACTCTTCAGGTGTGAAAACTTGGATGTAGGTGTAGATTGGCTCTCAGTTGACCTCCAGCTGGTGCAGATTCTTCAGTTTGTTTGATGGAGCTTTGGGAAGTCCTTTCAGACTGAAGGATACTCTGATTTTTAGCTATGGAAATAATGTGGATGTTGTGTGTTTAAGCCCTGTTTGCAGTTTTTTTCTGTTCAGTCAGTTATTTTACTGTGTGAGTCAGGACTCTTAGAAGCCCTCTGTGGCAACCACAGAGCGCATAGTTAATTTTCTGTGCAAGAAAATTAAGATCCTACTCAGTGTTCAGGAAAGTCAAGAATATTCCTGGTTTTCTCTACTGTAAAATTTTATCTTGTAACTTGTGTTTGGGTCTGCATGATTATTCAAAAATCTTAGTAGATTTGGAAGGATGTTGCATATTATGGAAACAAAGTTGGAAAAAGTTTGTATCAGTTCCAGTATTTCTTCACATCATTTNTTAACNNCNTNNNNNNNNNGCTTCTACCACTTGAAAAGACAAATTAAAAACCAATTTATAATGCTTATATGCTTTAGTTACATTNGGGTCTTTCAGTAACTTTAGTGCTTTTGATAGCCATACCTGTGAGCTTGGCAGTGTCTAAAATTAGAAGTGTTCCTTTTCTTCTGCTCTTCCCATTCTCGTGTGTCTTCAATAGTTTCTGCAAATAATGATGTGCAGACTTAGCATTGGTTCAACAGCAGAGGTAAAAATACCTGTGGCTTACTTGGCTTCAGCTTATCCAGCAGTGCCAACCACTCTCTGTTTGTCTTAC
29 | >KU3604_aco
30 | ACAGGTTAGAAACTACTCTGTTTTCTGGCTCCTTGTTTAATGCCCTGTCCTATTTTATTGCGACAATTGTCTGTTTTTCACAGAAAACTGAGAGTAGTCAAGGGATTCCTTGTCCTTTGCTTTGGTCTGCACAGCTGTCTTGTTTTAAGGCCNAGTGGAATGAGACAGCTGACTCTTCAGGTGTGAAAACTTGGATGTAGGTGTAGATTGGCTCTCAGTTGACCTCCAGCTGGTGCAGATTCTTCATTTTGTTTGATGGAGCTTTGAGAAGTCCTTTCAGACTGAAGGATACTCTGAATTTTAGCTATGGAGATAATGTGAATGTTGTGTGTTTAAGCCCTGTTTGCAGTTTTTTTCTGTTCAGTCAGTTATTTTACTGTGTCAGTCAGGACCCTTAGAAGCCCTCAGTGGCAACCACAGAGCGCACAGTTAATTTTCTGTGCAAGAAAATTAAGATCATACTCTGTGTCCAGGAAAGTCAAGAATATTCCTGGTTTTCTCTACTGTAAAATTTTATCTTGTAACTTGTGTTTGGGTCTGCATGATTATTCAAAAATCTTAGTAGATTTGGAAGGATGTTGCATATTATGGAAACAAAGTTGGAAAAAGTTTGTATCAGTTCTAGTATTTCTTCACATCATTTNTTAACNNCNTNNNNNNNNNGCTTCTACCACTTGAAAAGACAAATTAAAAACNAATTTATAATGCTTATATGCTTTAGTTACATTNGGGTCTTTCAGTAACTTTAGTGCTTTTGATAGCCATACCTGTGAGCTTGACAGTGTCTAAAATTAGAAGTATTCCTTTTCTTCTGCTCTTCCCATTCTAGTGTGTCTTCAATAGTTTCTGCAAATAATGATGTGCAGACTTACCATTGATTCAACAGCAGAGGTAANNATACCTGTGGCTTACTTGGCTTCAGCTTATCCAGCAGTGCCAACCACTCTCTGTTTGTCTTAC
31 | >KU9813_aco
32 | ACAGGTTAGAAACTACTCTGTTTTCTGGCTCCTTGTTTAATGCCCTGTCCTATTTTATTGTGACAATTGTCTGTTTTTCACAGAAAACTGAGAGTAGTCAAGGGATTCCTTGTCCTTTGCTTTGGTCTGCACAGCTGTCTTGTTTTAAGGCCAAGTGGAATGAGACAGCTGACTCTTCAGGTGTGAAAACTTGGATGTAGGTGTAGATTGGCTCTTAGTTGACCTCCAGCTGGTGCAGATTCTTCAGTTTGTTTGATGGAGCTTTGAGAAGTCCTTTCAGACTGAAGGATACTCTGAATTTTAGCTATGGAGATAATGTGGATGTTGTGTGTTTAAGCCCTGTTTGCAGTTTTTTTCTGTTCAGTCAGTTATTTTACTGTGTGAGTCAGGACCCTTAGAAGCCCTCAGTGGCAACCACAGAGCGCACAGTTAATTTTCTGTGCAAGAAAATTAACAACATACTCTGTGTCCAGGAAAGTCAAGAATATTCCTGGTTTTCTCTACTGTAAAATTTTATCTTGTAACTTGTGTTTGGGTCTGCATGATTATTCAAAAATCTTAGTAGATTTGGAAGGATGTTGCATATTATGGAAACAAAGTTGGAAAAAGTTTGTATCAGTTCCAGTAGTTCNNCANGTNATTTCTTCACATCATTTTTAACCTGCTTCTACCACTTGAAAAGACAAATTAAAAACNAATTTATAATGCTTATATGCTTTAGTTACATTNGGGTCTTTCAGTAACTTTAGTGCTTTTGATAGCCATACCTGTGAGNTTGACAGTGTCTAAAATTAGAAGTGTTCCTTTTCTTCTGCTCTTCCCATTCTCGTGTGTCTTCAATAGTTTCTGCAAATAATGATGTGCAGACTTAGCATTGATTCAACAGCAGAGGTAAGCATACCTGTGGCTTACTTGGCTTCAGCTTATCCAGCAGTGCCAACCACTCTCTGTTTGTCTTAC
33 | >UWBM54511_aco
34 | ACAGGTTAGAAACTACTCTGTTTTCTGGCTCCTTGTTTAATGCCCTGTCCTATTTTATTGCGAAAATTGTCTGTTTTTCACAGAAAACTGAGAGTAGTCAAGGGATTCCTTGTCCTTTGCTTTGGTCTGCACAGCTGTCTTGTTTTAAGGCCAAGTGGAATGAGACAGCTGACTCTTCAGGTGTGAAAACTTGGATGTAGGTGTAGATTGGCTCTCAGTTGACCTCCAGCTGGTGCAGATTCTTCAGTTTGTTTGATGGAGCTTTGAGAAGTCCTTTCAGACTGAAGGATACTCTGAATTTTAGCTATGGAGATAATGTGGATGTTGTGTGTTTAAGTCCTGTTTGCAGTTTTTTTCTGTTCAGTCAGTTATTTTACTGTGTGAGTCAGGACCCTTAGAAGCCCTCAGTGGCAACCACAGAGCGCACAGTTAATTTTCTGTGCAAGAAAATTAAGATCATACTCTGTGTCCAGGAAAGTCAAGAATATTCCTGGTTTTCTCTACTGTAAAATTTTATCTTGTAACTTGTGTTTGGGTCTGCATGATTATTCAAAAATCTTAGTAGATTTGGAAGGATGTTGCATATTATGGAAACAAAGTTGGAAAAAGTTTGTATCAGTTGCAGTATTTCTTCACATCATTTNTTAACNNCNTNNNNNNNNNGCTTCTGCCACTTGAAAAGACAAATTAAAAACNAATTTATAATGCTTATATGCTTTAGTTACATTNGGGTCTTTCAGTAACTTTAGTGCTTTTGATAGCCATACCTGTGAGNTTGACAGTGTCTAAAATTAGAAGTGTTCCTTTTCTTCTGCTCTTCCCATTCTCGTGTGTCTTCAATAGTTTCTGCAAATAATGATGTGCAGACTTAGCATTGATTCAACAGCAGAGGTAAGCATACCTGTGGCTTACTTGGCTTCAGCTTATCCAGCAGTGCCAACCACTCTCTGTTTGTCTTAC
35 | >UWBM54556_aco
36 | ACAGGTTAGAAACTACTCTGTTTTCTGGCTGCTTGTTTAATGCCCTGTCCTATTTTATTGTGACAATTGTCTGTTTTTCACAGAAAACTGAGAGTAGTCAAGGGATTCCTTGTCCTTTGCTTTGGTCTGCACAGCTGTCTTGTTTTAAGGCCCAGTGGAATGAGACAGCTGACTCTTCAGGTGTGAAAACTTGGATGTAGGTGTAGATTGGCTCTCAGTTGACCTCCAGCTGGTGCAGATTCTTCAGTTTGTTTGATGGAGCTTTGGGAAGTCCTTTCAGACTGAAGGATACTCTGATTTTTAGCTATGGAAATAATGTGGATGTTGTGTGTTTAAGCCCTGTTTGCAGTTTTTTTCTGTTCAGTCAGTTATTTTACTGTGTGAGTCAGGACTCTTAGAAGCCCTCTGTGGCAACCACAGAGCGCATAGTTTATTTTCTGTGCAAGAAAATTAAGATCCTACTCAGTGTTCAGGAAAGTCAAGAATATTCCTGGTTTTCTCTACTGTAAAATTTTATCTTGTAACTTGTGTTTGGGTCTGCATGATTATTCAAAAATCTTAGTAGATTTGGAAGGATGTTGCATATTATGGAAACAAAGTTGGAAAAAGTTTGTATCAGTTCCAGTATTTCTTCACATCATTTNTTAACNNCNTNNNNNNNNNGCTTCTACCACTTGAAAAGACAAATTAAAAACCAATTTATAATGCTTATATGCTTTAGTTACATTNGAGTCTTTCAGTAACTTTAGTGCTTTTGATAGCCATACCTGTGAGCNTGGCAGTGTCTAAAATTAGAAGTGTTCCTTTTCTTCTGCTCTTCCCATTCTCGTGTGTCTTCAATAGTTTCTGCAAATAATGATGTGCAGACTTAGCATTGGTTCAACAGCAGAGGTAAAAATACCTGTGGCTTACTTGGCTTCAGCTTATCCAGCAGTGCCAACCACTCTCTGTTTGTCTTAC
37 | >bas3_aco
38 | NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN
39 | >dabbenei_aco
40 | NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN
41 | >chacoensis_aco
42 | NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN
43 | >meridae_aco
44 | NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN
45 |
--------------------------------------------------------------------------------
/gene.c:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | PRODIGAL (PROkaryotic DynamIc Programming Genefinding ALgorithm)
3 | Copyright (C) 2007-2016 University of Tennessee / UT-Battelle
4 |
5 | Code Author: Doug Hyatt
6 |
7 | This program is free software: you can redistribute it and/or modify
8 | it under the terms of the GNU General Public License as published by
9 | the Free Software Foundation, either version 3 of the License, or
10 | (at your option) any later version.
11 |
12 | This program is distributed in the hope that it will be useful,
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | GNU General Public License for more details.
16 |
17 | You should have received a copy of the GNU General Public License
18 | along with this program. If not, see .
19 | *******************************************************************************/
20 |
21 | #include "gene.h"
22 |
23 | /* Copies genes from the dynamic programming to a final array */
24 |
25 | int add_genes(struct _gene *glist, struct _node *nod, int dbeg) {
26 | int path, ctr;
27 |
28 | if(dbeg == -1) return 0;
29 | path = dbeg; ctr = 0;
30 | while(nod[path].traceb != -1) path = nod[path].traceb;
31 |
32 | while(path != -1) {
33 | if(nod[path].elim == 1) { path = nod[path].tracef; continue; }
34 | if(nod[path].strand == 1 && nod[path].type != STOP) {
35 | glist[ctr].begin = nod[path].ndx+1;
36 | glist[ctr].start_ndx = path;
37 | }
38 | if(nod[path].strand == -1 && nod[path].type == STOP) {
39 | glist[ctr].begin = nod[path].ndx-1;
40 | glist[ctr].stop_ndx = path;
41 | }
42 | if(nod[path].strand == 1 && nod[path].type == STOP) {
43 | glist[ctr].end = nod[path].ndx+3;
44 | glist[ctr].stop_ndx = path;
45 | ctr++;
46 | }
47 | if(nod[path].strand == -1 && nod[path].type != STOP) {
48 | glist[ctr].end = nod[path].ndx+1;
49 | glist[ctr].start_ndx = path;
50 | ctr++;
51 | }
52 | path = nod[path].tracef;
53 | if(ctr == MAX_GENES) {
54 | fprintf(stderr, "warning, max # of genes exceeded, truncating...\n");
55 | return ctr;
56 | }
57 | }
58 | return ctr;
59 | }
60 |
61 | /*******************************************************************************
62 | This routine attempts to solve the problem of extremely close starts. If two
63 | potential starts are 5 amino acids or less away from each other, this routine
64 | sets their coding equal to each other and lets the RBS/operon/ATG-GTG-TTG
65 | start features determine which start to use, under the assumption that 5 or
66 | less words of coding is too weak a signal to use to select the proper start.
67 |
68 | In addition, we try to correct TTG (or whatever start codon is rare) starts
69 | that have an RBS score, an upstream score, and a coding score all superior
70 | to whatever start we initially chose.
71 |
72 | This routine was tested on numerous genomes and found to increase overall
73 | performance.
74 | *******************************************************************************/
75 | void tweak_final_starts(struct _gene *genes, int ng, struct _node *nod,
76 | int nn, struct _training *tinf) {
77 | int i, j, ndx, mndx, maxndx[2];
78 | double sc, igm, tigm, maxsc[2], maxigm[2];
79 |
80 | for(i = 0; i < ng; i++) {
81 | ndx = genes[i].start_ndx;
82 | sc = nod[ndx].sscore + nod[ndx].cscore;
83 | igm = 0.0;
84 | if(i > 0 && nod[ndx].strand == 1 && nod[genes[i-1].start_ndx].strand == 1)
85 | igm = intergenic_mod(&nod[genes[i-1].stop_ndx], &nod[ndx], tinf);
86 | if(i > 0 && nod[ndx].strand == 1 && nod[genes[i-1].start_ndx].strand == -1)
87 | igm = intergenic_mod(&nod[genes[i-1].start_ndx], &nod[ndx], tinf);
88 | if(i < ng-1 && nod[ndx].strand == -1 && nod[genes[i+1].start_ndx].strand
89 | == 1)
90 | igm = intergenic_mod(&nod[ndx], &nod[genes[i+1].start_ndx], tinf);
91 | if(i < ng-1 && nod[ndx].strand == -1 && nod[genes[i+1].start_ndx].strand
92 | == -1)
93 | igm = intergenic_mod(&nod[ndx], &nod[genes[i+1].stop_ndx], tinf);
94 |
95 | /* Search upstream and downstream for the #2 and #3 scoring starts */
96 | maxndx[0] = -1; maxndx[1] = -1; maxsc[0] = 0; maxsc[1] = 0;
97 | maxigm[0] = 0; maxigm[1] = 0;
98 | for(j = ndx-100; j < ndx+100; j++) {
99 | if(j < 0 || j >= nn || j == ndx) continue;
100 | if(nod[j].type == STOP || nod[j].stop_val != nod[ndx].stop_val)
101 | continue;
102 |
103 | tigm = 0.0;
104 | if(i > 0 && nod[j].strand == 1 && nod[genes[i-1].start_ndx].strand == 1)
105 | {
106 | if(nod[genes[i-1].stop_ndx].ndx - nod[j].ndx > MAX_SAM_OVLP) continue;
107 | tigm = intergenic_mod(&nod[genes[i-1].stop_ndx], &nod[j], tinf);
108 | }
109 | if(i > 0 && nod[j].strand == 1 && nod[genes[i-1].start_ndx].strand == -1)
110 | {
111 | if(nod[genes[i-1].start_ndx].ndx - nod[j].ndx >= 0) continue;
112 | tigm = intergenic_mod(&nod[genes[i-1].start_ndx], &nod[j], tinf);
113 | }
114 | if(i < ng-1 && nod[j].strand == -1 && nod[genes[i+1].start_ndx].strand
115 | == 1) {
116 | if(nod[j].ndx - nod[genes[i+1].start_ndx].ndx >= 0) continue;
117 | tigm = intergenic_mod(&nod[j], &nod[genes[i+1].start_ndx], tinf);
118 | }
119 | if(i < ng-1 && nod[j].strand == -1 && nod[genes[i+1].start_ndx].strand
120 | == -1) {
121 | if(nod[j].ndx - nod[genes[i+1].stop_ndx].ndx > MAX_SAM_OVLP) continue;
122 | tigm = intergenic_mod(&nod[j], &nod[genes[i+1].stop_ndx], tinf);
123 | }
124 |
125 | if(maxndx[0] == -1) {
126 | maxndx[0] = j;
127 | maxsc[0] = nod[j].cscore + nod[j].sscore;
128 | maxigm[0] = tigm;
129 | }
130 | else if(nod[j].cscore + nod[j].sscore + tigm > maxsc[0]) {
131 | maxndx[1] = maxndx[0];
132 | maxsc[1] = maxsc[0];
133 | maxigm[1] = maxigm[0];
134 | maxndx[0] = j;
135 | maxsc[0] = nod[j].cscore + nod[j].sscore;
136 | maxigm[0] = tigm;
137 | }
138 | else if(maxndx[1] == -1 || nod[j].cscore + nod[j].sscore + tigm >
139 | maxsc[1]) {
140 | maxndx[1] = j;
141 | maxsc[1] = nod[j].cscore + nod[j].sscore;
142 | maxigm[1] = tigm;
143 | }
144 | }
145 |
146 | /* Change the start if it's a TTG with better coding/RBS/upstream score */
147 | /* Also change the start if it's <=15bp but has better coding/RBS */
148 | for(j = 0; j < 2; j++) {
149 | mndx = maxndx[j];
150 | if(mndx == -1) continue;
151 |
152 | /* Start of less common type but with better coding, rbs, and */
153 | /* upstream. Must be 18 or more bases away from original. */
154 | if(nod[mndx].tscore < nod[ndx].tscore && maxsc[j]-nod[mndx].tscore >=
155 | sc-nod[ndx].tscore+tinf->st_wt && nod[mndx].rscore > nod[ndx].rscore
156 | && nod[mndx].uscore > nod[ndx].uscore && nod[mndx].cscore >
157 | nod[ndx].cscore && abs(nod[mndx].ndx-nod[ndx].ndx) > 15) {
158 | maxsc[j] += nod[ndx].tscore-nod[mndx].tscore;
159 | }
160 |
161 | /* Close starts. Ignore coding and see if start has better rbs */
162 | /* and type. */
163 | else if(abs(nod[mndx].ndx-nod[ndx].ndx) <= 15 && nod[mndx].rscore+
164 | nod[mndx].tscore > nod[ndx].rscore+nod[ndx].tscore &&
165 | nod[ndx].edge == 0 && nod[mndx].edge == 0) {
166 | if(nod[ndx].cscore > nod[mndx].cscore)
167 | maxsc[j] += nod[ndx].cscore - nod[mndx].cscore;
168 | if(nod[ndx].uscore > nod[mndx].uscore)
169 | maxsc[j] += nod[ndx].uscore - nod[mndx].uscore;
170 | if(igm > maxigm[j]) maxsc[j] += igm - maxigm[j];
171 | }
172 |
173 | else maxsc[j] = -1000.0;
174 | }
175 |
176 | /* Change the gene coordinates to the new maximum. */
177 | mndx = -1;
178 | for(j = 0; j < 2; j++) {
179 | if(maxndx[j] == -1) continue;
180 | if(mndx == -1 && maxsc[j]+maxigm[j] > sc+igm)
181 | mndx = j;
182 | else if(mndx >= 0 && maxsc[j]+maxigm[j] > maxsc[mndx]+maxigm[mndx])
183 | mndx = j;
184 | }
185 | if(mndx != -1 && nod[maxndx[mndx]].strand == 1) {
186 | genes[i].start_ndx = maxndx[mndx];
187 | genes[i].begin = nod[maxndx[mndx]].ndx+1;
188 | }
189 | else if(mndx != -1 && nod[maxndx[mndx]].strand == -1) {
190 | genes[i].start_ndx = maxndx[mndx];
191 | genes[i].end = nod[maxndx[mndx]].ndx+1;
192 | }
193 | }
194 | }
195 |
196 | void record_gene_data(struct _gene *genes, int ng, struct _node *nod,
197 | struct _training *tinf, int sctr) {
198 |
199 | int i, ndx, sndx, partial_left, partial_right, st_type;
200 | double rbs1, rbs2, confidence;
201 | char sd_string[28][100], sd_spacer[28][20], qt[10];
202 | char type_string[4][5] = { "ATG", "GTG", "TTG" , "Edge" };
203 |
204 | /* Initialize RBS string information for default SD */
205 | strcpy(sd_string[0], "None");
206 | strcpy(sd_spacer[0], "None");
207 | strcpy(sd_string[1], "GGA/GAG/AGG");
208 | strcpy(sd_spacer[1], "3-4bp");
209 | strcpy(sd_string[2], "3Base/5BMM");
210 | strcpy(sd_spacer[2], "13-15bp");
211 | strcpy(sd_string[3], "4Base/6BMM");
212 | strcpy(sd_spacer[3], "13-15bp");
213 | strcpy(sd_string[4], "AGxAG");
214 | strcpy(sd_spacer[4], "11-12bp");
215 | strcpy(sd_string[5], "AGxAG");
216 | strcpy(sd_spacer[5], "3-4bp");
217 | strcpy(sd_string[6], "GGA/GAG/AGG");
218 | strcpy(sd_spacer[6], "11-12bp");
219 | strcpy(sd_string[7], "GGxGG");
220 | strcpy(sd_spacer[7], "11-12bp");
221 | strcpy(sd_string[8], "GGxGG");
222 | strcpy(sd_spacer[8], "3-4bp");
223 | strcpy(sd_string[9], "AGxAG");
224 | strcpy(sd_spacer[9], "5-10bp");
225 | strcpy(sd_string[10], "AGGAG(G)/GGAGG");
226 | strcpy(sd_spacer[10], "13-15bp");
227 | strcpy(sd_string[11], "AGGA/GGAG/GAGG");
228 | strcpy(sd_spacer[11], "3-4bp");
229 | strcpy(sd_string[12], "AGGA/GGAG/GAGG");
230 | strcpy(sd_spacer[12], "11-12bp");
231 | strcpy(sd_string[13], "GGA/GAG/AGG");
232 | strcpy(sd_spacer[13], "5-10bp");
233 | strcpy(sd_string[14], "GGxGG");
234 | strcpy(sd_spacer[14], "5-10bp");
235 | strcpy(sd_string[15], "AGGA");
236 | strcpy(sd_spacer[15], "5-10bp");
237 | strcpy(sd_string[16], "GGAG/GAGG");
238 | strcpy(sd_spacer[16], "5-10bp");
239 | strcpy(sd_string[17], "AGxAGG/AGGxGG");
240 | strcpy(sd_spacer[17], "11-12bp");
241 | strcpy(sd_string[18], "AGxAGG/AGGxGG");
242 | strcpy(sd_spacer[18], "3-4bp");
243 | strcpy(sd_string[19], "AGxAGG/AGGxGG");
244 | strcpy(sd_spacer[19], "5-10bp");
245 | strcpy(sd_string[20], "AGGAG/GGAGG");
246 | strcpy(sd_spacer[20], "11-12bp");
247 | strcpy(sd_string[21], "AGGAG");
248 | strcpy(sd_spacer[21], "3-4bp");
249 | strcpy(sd_string[22], "AGGAG");
250 | strcpy(sd_spacer[22], "5-10bp");
251 | strcpy(sd_string[23], "GGAGG");
252 | strcpy(sd_spacer[23], "3-4bp");
253 | strcpy(sd_string[24], "GGAGG");
254 | strcpy(sd_spacer[24], "5-10bp");
255 | strcpy(sd_string[25], "AGGAGG");
256 | strcpy(sd_spacer[25], "11-12bp");
257 | strcpy(sd_string[26], "AGGAGG");
258 | strcpy(sd_spacer[26], "3-4bp");
259 | strcpy(sd_string[27], "AGGAGG");
260 | strcpy(sd_spacer[27], "5-10bp");
261 |
262 | char buffer[500] = {0};
263 |
264 | for(i = 0; i < ng; i++) {
265 | ndx = genes[i].start_ndx;
266 | sndx = genes[i].stop_ndx;
267 |
268 | /* Record basic gene data */
269 | if((nod[ndx].edge == 1 && nod[ndx].strand == 1) ||
270 | (nod[sndx].edge == 1 && nod[ndx].strand == -1))
271 | partial_left = 1;
272 | else partial_left = 0;
273 | if((nod[sndx].edge == 1 && nod[ndx].strand == 1) ||
274 | (nod[ndx].edge == 1 && nod[ndx].strand == -1))
275 | partial_right = 1;
276 | else partial_right = 0;
277 | if(nod[ndx].edge == 1) st_type = 3;
278 | else st_type = nod[ndx].type;
279 |
280 | sprintf(genes[i].gene_data, "ID=%d_%d;partial=%d%d;start_type=%s;", sctr,
281 | i+1, partial_left, partial_right, type_string[st_type]);
282 |
283 | /* Record rbs data */
284 | rbs1 = tinf->rbs_wt[nod[ndx].rbs[0]]*tinf->st_wt;
285 | rbs2 = tinf->rbs_wt[nod[ndx].rbs[1]]*tinf->st_wt;
286 | if(tinf->uses_sd == 1) {
287 | if(rbs1 > rbs2) {
288 | sprintf(buffer, "rbs_motif=%s;rbs_spacer=%s",
289 | sd_string[nod[ndx].rbs[0]],
290 | sd_spacer[nod[ndx].rbs[0]]);
291 | strcat(genes[i].gene_data, buffer);
292 | } else {
293 | sprintf(buffer, "rbs_motif=%s;rbs_spacer=%s",
294 | sd_string[nod[ndx].rbs[1]],
295 | sd_spacer[nod[ndx].rbs[1]]);
296 | strcat(genes[i].gene_data, buffer);
297 | }
298 | }
299 | else {
300 | mer_text(qt, nod[ndx].mot.len, nod[ndx].mot.ndx);
301 | if(tinf->no_mot > -0.5 && rbs1 > rbs2 && rbs1 > nod[ndx].mot.score *
302 | tinf->st_wt) {
303 | sprintf(buffer, "rbs_motif=%s;rbs_spacer=%s",
304 | sd_string[nod[ndx].rbs[0]],
305 | sd_spacer[nod[ndx].rbs[0]]);
306 | strcat(genes[i].gene_data, buffer);
307 | } else if(tinf->no_mot > -0.5 && rbs2 >= rbs1 && rbs2 > nod[ndx].mot.score *
308 | tinf->st_wt) {
309 | sprintf(buffer, "rbs_motif=%s;rbs_spacer=%s",
310 | sd_string[nod[ndx].rbs[1]],
311 | sd_spacer[nod[ndx].rbs[1]]);
312 | strcat(genes[i].gene_data, buffer);
313 | } else if(nod[ndx].mot.len == 0) {
314 | strcat(genes[i].gene_data, "rbs_motif=None;rbs_spacer=None");
315 | } else {
316 | sprintf(buffer, "rbs_motif=%s;rbs_spacer=%dbp",
317 | qt, nod[ndx].mot.spacer);
318 | strcat(genes[i].gene_data, buffer);
319 | }
320 | }
321 | sprintf(buffer, ";gc_cont=%.3f", nod[ndx].gc_cont);
322 | strcat(genes[i].gene_data, buffer);
323 |
324 | /* Record score data */
325 | confidence = calculate_confidence(nod[ndx].cscore + nod[ndx].sscore,
326 | tinf->st_wt);
327 | sprintf(genes[i].score_data,
328 | "conf=%.2f;score=%.2f;cscore=%.2f;sscore=%.2f;rscore=%.2f;uscore=%.2f;",
329 | confidence, nod[ndx].cscore+nod[ndx].sscore,nod[ndx].cscore,
330 | nod[ndx].sscore, nod[ndx].rscore, nod[ndx].uscore);
331 |
332 | sprintf(buffer, "tscore=%.2f;", nod[ndx].tscore);
333 | strcat(genes[i].score_data, buffer);
334 | }
335 |
336 | }
337 |
338 | /* Print the genes. 'Flag' indicates which format to use. */
339 | void print_genes(FILE *fp, struct _gene *genes, int ng, struct _node *nod,
340 | int slen, int flag, int sctr, int is_meta, char *mdesc,
341 | struct _training *tinf, char *header, char *short_hdr,
342 | char *version) {
343 | int i, ndx, sndx;
344 | char left[50], right[50];
345 | char seq_data[MAX_LINE*2], run_data[MAX_LINE];
346 | char buffer[MAX_LINE] = {0};
347 |
348 | /* Initialize sequence data */
349 | sprintf(seq_data, "seqnum=%d;seqlen=%d;seqhdr=\"%s\"", sctr, slen, header);
350 |
351 | /* Initialize run data string */
352 | if(is_meta == 0) {
353 | sprintf(run_data, "version=Prodigal.v%s;run_type=Single;", version);
354 | strcat(run_data, "model=\"Ab initio\";");
355 | }
356 | else {
357 | sprintf(run_data, "version=Prodigal.v%s;run_type=Metagenomic;", version);
358 | sprintf(buffer, "model=\"%s\";", mdesc);
359 | strcat(run_data, buffer);
360 | }
361 | sprintf(buffer, "gc_cont=%.2f;transl_table=%d;uses_sd=%d",
362 | tinf->gc*100.0, tinf->trans_table, tinf->uses_sd);
363 | strcat(run_data, buffer);
364 |
365 | strcpy(left, "");
366 | strcpy(right, "");
367 |
368 | /* Print the gff header once */
369 | if(flag == 3 && sctr == 1) fprintf(fp, "##gff-version 3\n");
370 |
371 | /* Print sequence/model information */
372 | if(flag == 0) {
373 | fprintf(fp, "DEFINITION %s;%s\n", seq_data, run_data);
374 | fprintf(fp, "FEATURES Location/Qualifiers\n");
375 | }
376 | else if(flag != 1) {
377 | fprintf(fp, "# Sequence Data: %s\n", seq_data);
378 | fprintf(fp, "# Model Data: %s\n", run_data);
379 | }
380 |
381 | /* Print the genes */
382 | for(i = 0; i < ng; i++) {
383 | ndx = genes[i].start_ndx;
384 | sndx = genes[i].stop_ndx;
385 |
386 | /* Print the coordinates and data */
387 | if(nod[ndx].strand == 1) {
388 |
389 | if(nod[ndx].edge == 1) sprintf(left, "<%d", genes[i].begin);
390 | else sprintf(left, "%d", genes[i].begin);
391 | if(nod[sndx].edge == 1) sprintf(right, ">%d", genes[i].end);
392 | else sprintf(right, "%d", genes[i].end);
393 |
394 | if(flag == 0) {
395 | fprintf(fp, " CDS %s..%s\n", left, right);
396 | fprintf(fp, " ");
397 | fprintf(fp, "/note=\"%s;%s\"\n", genes[i].gene_data,
398 | genes[i].score_data);
399 | }
400 | if(flag == 1)
401 | fprintf(fp, "gene_prodigal=%d|1|f|y|y|3|0|%d|%d|%d|%d|-1|-1|1.0\n", i+1,
402 | genes[i].begin, genes[i].end, genes[i].begin, genes[i].end);
403 | if(flag == 2) fprintf(fp, ">%d_%d_%d_+\n", i+1, genes[i].begin,
404 | genes[i].end);
405 | if(flag == 3) {
406 | fprintf(fp, "%s\tProdigal_v%s\tCDS\t%d\t%d\t%.1f\t+\t0\t%s;%s",
407 | short_hdr, version, genes[i].begin, genes[i].end,
408 | nod[ndx].cscore+nod[ndx].sscore, genes[i].gene_data,
409 | genes[i].score_data);
410 | fprintf(fp, "\n");
411 | }
412 | }
413 | else {
414 |
415 | if(nod[sndx].edge == 1) sprintf(left, "<%d", genes[i].begin);
416 | else sprintf(left, "%d", genes[i].begin);
417 | if(nod[ndx].edge == 1) sprintf(right, ">%d", genes[i].end);
418 | else sprintf(right, "%d", genes[i].end);
419 |
420 | if(flag == 0) {
421 | fprintf(fp, " CDS complement(%s..%s)\n", left, right);
422 | fprintf(fp, " ");
423 | fprintf(fp, "/note=\"%s;%s\"\n", genes[i].gene_data,
424 | genes[i].score_data);
425 | }
426 | if(flag == 1)
427 | fprintf(fp, "gene_prodigal=%d|1|r|y|y|3|0|%d|%d|%d|%d|-1|-1|1.0\n", i+1,
428 | slen+1-genes[i].end, slen+1-genes[i].begin,
429 | slen+1-genes[i].end, slen+1-genes[i].begin);
430 | if(flag == 2) fprintf(fp, ">%d_%d_%d_-\n", i+1, genes[i].begin,
431 | genes[i].end);
432 | if(flag == 3) {
433 | fprintf(fp, "%s\tProdigal_v%s\tCDS\t%d\t%d\t%.1f\t-\t0\t%s;%s",
434 | short_hdr, version, genes[i].begin, genes[i].end,
435 | nod[ndx].cscore+nod[ndx].sscore, genes[i].gene_data,
436 | genes[i].score_data);
437 | fprintf(fp, "\n");
438 | }
439 | }
440 | }
441 |
442 | /* Footer */
443 | if(flag == 0) fprintf(fp, "//\n");
444 |
445 | }
446 |
447 | /* Print the gene translations */
448 | void write_translations(FILE *fh, struct _gene *genes, int ng, struct
449 | _node *nod, unsigned char *seq, unsigned char *rseq,
450 | unsigned char *useq, int slen, struct _training *tinf,
451 | int sctr, char *short_hdr) {
452 | int i, j;
453 |
454 | for(i = 0; i < ng; i++) {
455 | if(nod[genes[i].start_ndx].strand == 1) {
456 | fprintf(fh, ">%s_%d # %d # %d # 1 # %s\n", short_hdr, i+1,
457 | genes[i].begin, genes[i].end, genes[i].gene_data);
458 | for(j = genes[i].begin; j < genes[i].end; j+=3) {
459 | if(is_n(useq, j-1) == 1 || is_n(useq, j) == 1 || is_n(useq, j+1) == 1)
460 | fprintf(fh, "X");
461 | else fprintf(fh, "%c", amino(seq, j-1, tinf, (j==genes[i].begin?1:0) &&
462 | (1-nod[genes[i].start_ndx].edge)));
463 | if((j-genes[i].begin)%180 == 177) fprintf(fh, "\n");
464 | }
465 | if((j-genes[i].begin)%180 != 0) fprintf(fh, "\n");
466 | }
467 | else {
468 | fprintf(fh, ">%s_%d # %d # %d # -1 # %s\n", short_hdr, i+1,
469 | genes[i].begin, genes[i].end, genes[i].gene_data);
470 | for(j = slen+1-genes[i].end; j < slen+1-genes[i].begin; j+=3) {
471 | if(is_n(useq, slen-j) == 1 || is_n(useq, slen-1-j) == 1 ||
472 | is_n(useq, slen-2-j) == 1)
473 | fprintf(fh, "X");
474 | else fprintf(fh, "%c", amino(rseq, j-1, tinf, (j==slen+1-genes[i].end?1:0)
475 | && (1-nod[genes[i].start_ndx].edge)));
476 | if((j-slen-1+genes[i].end)%180 == 177) fprintf(fh, "\n");
477 | }
478 | if((j-slen-1+genes[i].end)%180 != 0) fprintf(fh, "\n");
479 | }
480 | }
481 | }
482 |
483 | /* Print the gene nucleotide sequences */
484 | void write_nucleotide_seqs(FILE *fh, struct _gene *genes, int ng, struct
485 | _node *nod, unsigned char *seq, unsigned char *rseq,
486 | unsigned char *useq, int slen, struct _training
487 | *tinf, int sctr, char *short_hdr) {
488 | int i, j;
489 |
490 | for(i = 0; i < ng; i++) {
491 | if(nod[genes[i].start_ndx].strand == 1) {
492 | fprintf(fh, ">%s_%d # %d # %d # 1 # %s\n", short_hdr, i+1,
493 | genes[i].begin, genes[i].end, genes[i].gene_data);
494 | for(j = genes[i].begin-1; j < genes[i].end; j++) {
495 | if(is_a(seq, j) == 1) fprintf(fh, "A");
496 | else if(is_t(seq, j) == 1) fprintf(fh, "T");
497 | else if(is_g(seq, j) == 1) fprintf(fh, "G");
498 | else if(is_c(seq, j) == 1 && is_n(useq, j) == 0) fprintf(fh, "C");
499 | else fprintf(fh, "N");
500 | if((j-genes[i].begin+1)%70 == 69) fprintf(fh, "\n");
501 | }
502 | if((j-genes[i].begin+1)%70 != 0) fprintf(fh, "\n");
503 | }
504 | else {
505 | fprintf(fh, ">%s_%d # %d # %d # -1 # %s\n", short_hdr, i+1,
506 | genes[i].begin, genes[i].end, genes[i].gene_data);
507 | for(j = slen-genes[i].end; j < slen+1-genes[i].begin; j++) {
508 | if(is_a(rseq, j) == 1) fprintf(fh, "A");
509 | else if(is_t(rseq, j) == 1) fprintf(fh, "T");
510 | else if(is_g(rseq, j) == 1) fprintf(fh, "G");
511 | else if(is_c(rseq, j) == 1 && is_n(useq, slen-1-j) == 0)
512 | fprintf(fh, "C");
513 | else fprintf(fh, "N");
514 | if((j-slen+genes[i].end)%70 == 69) fprintf(fh, "\n");
515 | }
516 | if((j-slen+genes[i].end)%70 != 0) fprintf(fh, "\n");
517 | }
518 | }
519 | }
520 |
521 | /* Convert score to a percent confidence */
522 | double calculate_confidence(double score, double start_weight) {
523 | double conf;
524 |
525 | if(score/start_weight < 41) {
526 | conf = exp(score/start_weight);
527 | conf = (conf/(conf+1))*100.0;
528 | }
529 | else conf = 99.99;
530 | if(conf <= 50.00) { conf = 50.00; }
531 | return conf;
532 | }
533 |
--------------------------------------------------------------------------------
/main.c:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | PRODIGAL (PROkaryotic DynamIc Programming Genefinding ALgorithm)
3 | Copyright (C) 2007-2016 University of Tennessee / UT-Battelle
4 |
5 | Code Author: Doug Hyatt
6 |
7 | This program is free software: you can redistribute it and/or modify
8 | it under the terms of the GNU General Public License as published by
9 | the Free Software Foundation, either version 3 of the License, or
10 | (at your option) any later version.
11 |
12 | This program is distributed in the hope that it will be useful,
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | GNU General Public License for more details.
16 |
17 | You should have received a copy of the GNU General Public License
18 | along with this program. If not, see .
19 | *******************************************************************************/
20 |
21 | #include
22 | #include
23 | #include "sequence.h"
24 | #include "metagenomic.h"
25 | #include "node.h"
26 | #include "dprog.h"
27 | #include "gene.h"
28 | #include "fptr.h"
29 |
30 |
31 | #define VERSION "2.6.3"
32 | #define DATE "February, 2016"
33 |
34 | #define MIN_SINGLE_GENOME 20000
35 | #define IDEAL_SINGLE_GENOME 100000
36 |
37 |
38 | void version();
39 | void usage(char *);
40 | void help();
41 | int copy_standard_input_to_file(char *, int);
42 |
43 | int main(int argc, char *argv[]) {
44 |
45 | int rv, slen, nn, ng, i, ipath, *gc_frame, do_training, output, max_phase;
46 | int closed, do_mask, nmask, force_nonsd, user_tt, is_meta, num_seq, quiet;
47 | int piped, max_slen, fnum;
48 | double max_score, gc, low, high;
49 | unsigned char *seq, *rseq, *useq;
50 | char *train_file, *start_file, *trans_file, *nuc_file;
51 | char *input_file, *output_file, input_copy[MAX_LINE];
52 | char cur_header[MAX_LINE], new_header[MAX_LINE], short_header[MAX_LINE];
53 | FILE *output_ptr, *start_ptr, *trans_ptr, *nuc_ptr;
54 | fptr input_ptr = NULL;
55 | struct stat fbuf;
56 | pid_t pid;
57 | struct _node *nodes;
58 | struct _gene *genes;
59 | struct _training tinf;
60 | struct _metagenomic_bin meta[NUM_META];
61 | mask mlist[MAX_MASKS];
62 |
63 | /* Allocate memory and initialize variables */
64 | seq = (unsigned char *)malloc(MAX_SEQ/4*sizeof(unsigned char));
65 | rseq = (unsigned char *)malloc(MAX_SEQ/4*sizeof(unsigned char));
66 | useq = (unsigned char *)malloc(MAX_SEQ/8*sizeof(unsigned char));
67 | nodes = (struct _node *)malloc(STT_NOD*sizeof(struct _node));
68 | genes = (struct _gene *)malloc(MAX_GENES*sizeof(struct _gene));
69 | if(seq == NULL || rseq == NULL || nodes == NULL || genes == NULL) {
70 | fprintf(stderr, "\nError: Malloc failed on sequence/orfs\n\n"); exit(1);
71 | }
72 | memset(seq, 0, MAX_SEQ/4*sizeof(unsigned char));
73 | memset(rseq, 0, MAX_SEQ/4*sizeof(unsigned char));
74 | memset(useq, 0, MAX_SEQ/8*sizeof(unsigned char));
75 | memset(nodes, 0, STT_NOD*sizeof(struct _node));
76 | memset(genes, 0, MAX_GENES*sizeof(struct _gene));
77 | memset(&tinf, 0, sizeof(struct _training));
78 |
79 | for(i = 0; i < NUM_META; i++) {
80 | memset(&meta[i], 0, sizeof(struct _metagenomic_bin));
81 | strcpy(meta[i].desc, "None");
82 | meta[i].tinf = (struct _training *)malloc(sizeof(struct _training));
83 | if(meta[i].tinf == NULL) {
84 | fprintf(stderr, "\nError: Malloc failed on training structure.\n\n");
85 | exit(1);
86 | }
87 | memset(meta[i].tinf, 0, sizeof(struct _training));
88 | }
89 | nn = 0; slen = 0; ipath = 0; ng = 0; nmask = 0;
90 | user_tt = 0; is_meta = 0; num_seq = 0; quiet = 0;
91 | max_phase = 0; max_score = -100.0;
92 | train_file = NULL; do_training = 0;
93 | start_file = NULL; trans_file = NULL; nuc_file = NULL;
94 | start_ptr = stdout; trans_ptr = stdout; nuc_ptr = stdout;
95 | input_file = NULL; output_file = NULL; piped = 0;
96 | output_ptr = stdout; max_slen = 0;
97 | output = 0; closed = 0; do_mask = 0; force_nonsd = 0;
98 |
99 | /* Filename for input copy if needed */
100 | pid = getpid();
101 | sprintf(input_copy, "tmp.prodigal.stdin.%d", pid);
102 |
103 | /***************************************************************************
104 | Set the start score weight. Changing this number can dramatically
105 | affect the performance of the program. Some genomes want it high (6+),
106 | and some prefer it low (2.5-3). Attempts were made to determine this
107 | weight dynamically, but none were successful. Therefore, we just
108 | manually set the weight to an average value that seems to work decently
109 | for 99% of genomes. This problem may be revisited in future versions.
110 | ***************************************************************************/
111 | tinf.st_wt = 4.35;
112 | tinf.trans_table = 11;
113 |
114 | /* Parse the command line arguments */
115 | for(i = 1; i < argc; i++) {
116 | if(i == argc-1 && (strcmp(argv[i], "-t") == 0 || strcmp(argv[i], "-T") == 0
117 | || strcmp(argv[i], "-a") == 0 || strcmp(argv[i], "-A") == 0 ||
118 | strcmp(argv[i], "-g") == 0 || strcmp(argv[i], "-g") == 0 ||
119 | strcmp(argv[i], "-f") == 0 || strcmp(argv[i], "-F") == 0 ||
120 | strcmp(argv[i], "-s") == 0 || strcmp(argv[i], "-S") == 0 ||
121 | strcmp(argv[i], "-i") == 0 || strcmp(argv[i], "-I") == 0 ||
122 | strcmp(argv[i], "-o") == 0 || strcmp(argv[i], "-O") == 0 ||
123 | strcmp(argv[i], "-p") == 0 || strcmp(argv[i], "-P") == 0))
124 | usage("-a/-f/-g/-i/-o/-p/-s options require parameters.");
125 | else if(strcmp(argv[i], "-c") == 0 || strcmp(argv[i], "-C") == 0)
126 | closed = 1;
127 | else if(strcmp(argv[i], "-q") == 0 || strcmp(argv[i], "-Q") == 0)
128 | quiet = 1;
129 | else if(strcmp(argv[i], "-m") == 0 || strcmp(argv[i], "-M") == 0)
130 | do_mask = 1;
131 | else if(strcmp(argv[i], "-n") == 0 || strcmp(argv[i], "-N") == 0)
132 | force_nonsd = 1;
133 | else if(strcmp(argv[i], "-h") == 0 || strcmp(argv[i], "-H") == 0) help();
134 | else if(strcmp(argv[i], "-v") == 0 || strcmp(argv[i], "-V") == 0) version();
135 | else if(strcmp(argv[i], "-a") == 0 || strcmp(argv[i], "-A") == 0) {
136 | trans_file = argv[i+1];
137 | i++;
138 | }
139 | else if(strcmp(argv[i], "-d") == 0 || strcmp(argv[i], "-d") == 0) {
140 | nuc_file = argv[i+1];
141 | i++;
142 | }
143 | else if(strcmp(argv[i], "-i") == 0 || strcmp(argv[i], "-I") == 0) {
144 | input_file = argv[i+1];
145 | i++;
146 | }
147 | else if(strcmp(argv[i], "-o") == 0 || strcmp(argv[i], "-O") == 0) {
148 | output_file = argv[i+1];
149 | i++;
150 | }
151 | else if(strcmp(argv[i], "-s") == 0 || strcmp(argv[i], "-S") == 0) {
152 | start_file = argv[i+1];
153 | i++;
154 | }
155 | else if(strcmp(argv[i], "-t") == 0 || strcmp(argv[i], "-T") == 0) {
156 | train_file = argv[i+1];
157 | i++;
158 | }
159 | else if(strcmp(argv[i], "-g") == 0 || strcmp(argv[i], "-G") == 0) {
160 | tinf.trans_table = atoi(argv[i+1]);
161 | if(tinf.trans_table < 1 || tinf.trans_table > 25 || tinf.trans_table == 7
162 | || tinf.trans_table == 8 || (tinf.trans_table >= 17 && tinf.trans_table
163 | <= 20))
164 | usage("Invalid translation table specified.");
165 | user_tt = tinf.trans_table;
166 | i++;
167 | }
168 | else if(strcmp(argv[i], "-p") == 0 || strcmp(argv[i], "-P") == 0) {
169 | if(argv[i+1][0] == '0' || argv[i+1][0] == 's' || argv[i+1][0] ==
170 | 'S') is_meta = 0;
171 | else if(argv[i+1][0] == '1' || argv[i+1][0] == 'm' || argv[i+1][0] ==
172 | 'M') is_meta = 1;
173 | else usage("Invalid meta/single genome type specified.");
174 | i++;
175 | }
176 | else if(strcmp(argv[i], "-f") == 0 || strcmp(argv[i], "-F") == 0) {
177 | if(strncmp(argv[i+1], "0", 1) == 0 || strcmp(argv[i+1], "gbk") == 0 ||
178 | strcmp(argv[i+1], "GBK") == 0)
179 | output = 0;
180 | else if(strncmp(argv[i+1], "1", 1) == 0 || strcmp(argv[i+1], "gca") == 0
181 | || strcmp(argv[i+1], "GCA") == 0)
182 | output = 1;
183 | else if(strncmp(argv[i+1], "2", 1) == 0 || strcmp(argv[i+1], "sco") == 0
184 | || strcmp(argv[i+1], "SCO") == 0)
185 | output = 2;
186 | else if(strncmp(argv[i+1], "3", 1) == 0 || strcmp(argv[i+1], "gff") == 0
187 | || strcmp(argv[i+1], "GFF") == 0)
188 | output = 3;
189 | else usage("Invalid output format specified.");
190 | i++;
191 | }
192 | else usage("Unknown option.");
193 | }
194 |
195 | /* Print header */
196 | if(quiet == 0) {
197 | fprintf(stderr, "-------------------------------------\n");
198 | fprintf(stderr, "PRODIGAL v%s [%s] \n", VERSION, DATE);
199 | fprintf(stderr, "Univ of Tenn / Oak Ridge National Lab\n");
200 | fprintf(stderr, "Doug Hyatt, Loren Hauser, et al. \n");
201 | fprintf(stderr, "-------------------------------------\n");
202 | }
203 |
204 | /* Read in the training file (if specified) */
205 | if(train_file != NULL) {
206 | if(is_meta == 1) {
207 | fprintf(stderr, "\nError: cannot specify metagenomic sequence with a");
208 | fprintf(stderr, " training file.\n");
209 | exit(2);
210 | }
211 | rv = read_training_file(train_file, &tinf);
212 | if(rv == 1) do_training = 1;
213 | else {
214 | if(force_nonsd == 1) {
215 | fprintf(stderr, "\nError: cannot force non-SD finder with a training");
216 | fprintf(stderr, " file already created!\n"); exit(3);
217 | }
218 | if(quiet == 0)
219 | fprintf(stderr, "Reading in training data from file %s...", train_file);
220 | if(user_tt > 0 && user_tt != tinf.trans_table) {
221 | fprintf(stderr, "\n\nWarning: user-specified translation table does");
222 | fprintf(stderr, "not match the one in the specified training file! \n\n");
223 | }
224 | if(rv == -1) {
225 | fprintf(stderr, "\n\nError: training file did not read correctly!\n");
226 | exit(4);
227 | }
228 | if(quiet == 0) {
229 | fprintf(stderr, "done!\n");
230 | fprintf(stderr, "-------------------------------------\n");
231 | }
232 | }
233 | }
234 |
235 | /* Determine where standard input is coming from and react accordingly */
236 | if(is_meta == 0 && train_file == NULL && input_file == NULL) {
237 | fnum = fileno(stdin);
238 | if(fstat(fnum, &fbuf) == -1) {
239 | fprintf(stderr, "\nError: can't fstat standard input.\n\n");
240 | exit(5);
241 | }
242 | if(S_ISCHR(fbuf.st_mode)) help();
243 | else if(S_ISREG(fbuf.st_mode)) { /* do nothing */ }
244 | else if(S_ISFIFO(fbuf.st_mode)) {
245 | piped = 1;
246 | if(copy_standard_input_to_file(input_copy, quiet) == -1) {
247 | fprintf(stderr, "\nError: can't copy stdin to file.\n\n");
248 | exit(5);
249 | }
250 | input_file = input_copy;
251 | }
252 | }
253 |
254 | /* Check i/o files (if specified) and prepare them for reading/writing */
255 | if(input_file != NULL) {
256 | input_ptr = INPUT_OPEN(input_file, "r");
257 | if(input_ptr == NULL) {
258 | fprintf(stderr, "\nError: can't open input file %s.\n\n", input_file);
259 | exit(5);
260 | }
261 | }
262 | if(input_ptr == NULL) {
263 | input_ptr = INPUT_OPEN("/dev/stdin", "r");
264 | if(input_ptr == NULL) {
265 | fprintf(stderr, "\nError: can't open input file %s.\n\n", input_file);
266 | exit(5);
267 | }
268 | }
269 | if(output_file != NULL) {
270 | output_ptr = fopen(output_file, "w");
271 | if(output_ptr == NULL) {
272 | fprintf(stderr, "\nError: can't open output file %s.\n\n", output_file);
273 | exit(6);
274 | }
275 | }
276 | if(start_file != NULL) {
277 | start_ptr = fopen(start_file, "w");
278 | if(start_ptr == NULL) {
279 | fprintf(stderr, "\nError: can't open start file %s.\n\n", start_file);
280 | exit(7);
281 | }
282 | }
283 | if(trans_file != NULL) {
284 | trans_ptr = fopen(trans_file, "w");
285 | if(trans_ptr == NULL) {
286 | fprintf(stderr, "\nError: can't open translation file %s.\n\n",
287 | trans_file);
288 | exit(8);
289 | }
290 | }
291 | if(nuc_file != NULL) {
292 | nuc_ptr = fopen(nuc_file, "w");
293 | if(nuc_ptr == NULL) {
294 | fprintf(stderr, "\nError: can't open gene nucleotide file %s.\n\n",
295 | nuc_file);
296 | exit(16);
297 | }
298 | }
299 |
300 | /***************************************************************************
301 | Single Genome Training: Read in the sequence(s) and perform the
302 | training on them.
303 | ***************************************************************************/
304 | if(is_meta == 0 && (do_training == 1 || (do_training == 0 && train_file ==
305 | NULL))) {
306 | if(quiet == 0) {
307 | fprintf(stderr, "Request: Single Genome, Phase: Training\n");
308 | fprintf(stderr, "Reading in the sequence(s) to train...");
309 | }
310 | slen = read_seq_training(input_ptr, seq, useq, &(tinf.gc), do_mask, mlist,
311 | &nmask);
312 | if(slen == 0) {
313 | fprintf(stderr, "\n\nSequence read failed (file must be Fasta, ");
314 | fprintf(stderr, "Genbank, or EMBL format).\n\n");
315 | exit(9);
316 | }
317 | if(slen < MIN_SINGLE_GENOME) {
318 | fprintf(stderr, "\n\nError: Sequence must be %d", MIN_SINGLE_GENOME);
319 | fprintf(stderr, " characters (only %d read).\n(Consider", slen);
320 | fprintf(stderr, " running with the -p meta option or finding");
321 | fprintf(stderr, " more contigs from the same genome.)\n\n");
322 | exit(10);
323 | }
324 | if(slen < IDEAL_SINGLE_GENOME) {
325 | fprintf(stderr, "\n\nWarning: ideally Prodigal should be given at");
326 | fprintf(stderr, " least %d bases for ", IDEAL_SINGLE_GENOME);
327 | fprintf(stderr, "training.\nYou may get better results with the ");
328 | fprintf(stderr, "-p meta option.\n\n");
329 | }
330 | rcom_seq(seq, rseq, useq, slen);
331 | if(quiet == 0) {
332 | fprintf(stderr, "%d bp seq created, %.2f pct GC\n", slen, tinf.gc*100.0);
333 | }
334 |
335 | /***********************************************************************
336 | Find all the potential starts and stops, sort them, and create a
337 | comprehensive list of nodes for dynamic programming.
338 | ***********************************************************************/
339 | if(quiet == 0) {
340 | fprintf(stderr, "Locating all potential starts and stops...");
341 | }
342 | if(slen > max_slen && slen > STT_NOD*8) {
343 | nodes = (struct _node *)realloc(nodes, (int)(slen/8)*sizeof(struct _node));
344 | if(nodes == NULL) {
345 | fprintf(stderr, "Realloc failed on nodes\n\n");
346 | exit(11);
347 | }
348 | max_slen = slen;
349 | }
350 | nn = add_nodes(seq, rseq, slen, nodes, closed, mlist, nmask, &tinf);
351 | qsort(nodes, nn, sizeof(struct _node), &compare_nodes);
352 | if(quiet == 0) {
353 | fprintf(stderr, "%d nodes\n", nn);
354 | }
355 |
356 | /***********************************************************************
357 | Scan all the ORFS looking for a potential GC bias in a particular
358 | codon position. This information will be used to acquire a good
359 | initial set of genes.
360 | ***********************************************************************/
361 | if(quiet == 0) {
362 | fprintf(stderr, "Looking for GC bias in different frames...");
363 | }
364 | gc_frame = calc_most_gc_frame(seq, slen);
365 | if(gc_frame == NULL) {
366 | fprintf(stderr, "Malloc failed on gc frame plot\n\n");
367 | exit(11);
368 | }
369 | record_gc_bias(gc_frame, nodes, nn, &tinf);
370 | if(quiet == 0) {
371 | fprintf(stderr, "frame bias scores: %.2f %.2f %.2f\n", tinf.bias[0],
372 | tinf.bias[1], tinf.bias[2]);
373 | }
374 | free(gc_frame);
375 |
376 | /***********************************************************************
377 | Do an initial dynamic programming routine with just the GC frame
378 | bias used as a scoring function. This will get an initial set of
379 | genes to train on.
380 | ***********************************************************************/
381 | if(quiet == 0) {
382 | fprintf(stderr, "Building initial set of genes to train from...");
383 | }
384 | record_overlapping_starts(nodes, nn, &tinf, 0);
385 | ipath = dprog(nodes, nn, &tinf, 0);
386 | if(quiet == 0) {
387 | fprintf(stderr, "done!\n");
388 | }
389 |
390 | /***********************************************************************
391 | Gather dicodon statistics for the training set. Score the entire set
392 | of nodes.
393 | ***********************************************************************/
394 | if(quiet == 0) {
395 | fprintf(stderr, "Creating coding model and scoring nodes...");
396 | }
397 | calc_dicodon_gene(&tinf, seq, rseq, slen, nodes, ipath);
398 | raw_coding_score(seq, rseq, slen, nodes, nn, &tinf);
399 | if(quiet == 0) {
400 | fprintf(stderr, "done!\n");
401 | }
402 |
403 | /***********************************************************************
404 | Determine if this organism uses Shine-Dalgarno or not and score the
405 | nodes appropriately.
406 | ***********************************************************************/
407 | if(quiet == 0) {
408 | fprintf(stderr, "Examining upstream regions and training starts...");
409 | }
410 | rbs_score(seq, rseq, slen, nodes, nn, &tinf);
411 | train_starts_sd(seq, rseq, slen, nodes, nn, &tinf);
412 | determine_sd_usage(&tinf);
413 | if(force_nonsd == 1) tinf.uses_sd = 0;
414 | if(tinf.uses_sd == 0) train_starts_nonsd(seq, rseq, slen, nodes, nn, &tinf);
415 | if(quiet == 0) {
416 | fprintf(stderr, "done!\n");
417 | }
418 |
419 | /* If training specified, write the training file and exit. */
420 | if(do_training == 1) {
421 | if(quiet == 0) {
422 | fprintf(stderr, "Writing data to training file %s...", train_file);
423 | }
424 | rv = write_training_file(train_file, &tinf);
425 | if(rv != 0) {
426 | fprintf(stderr, "\nError: could not write training file!\n");
427 | exit(12);
428 | }
429 | else {
430 | if(quiet == 0) fprintf(stderr, "done!\n");
431 | exit(0);
432 | }
433 | }
434 |
435 | /* Rewind input file */
436 | if(quiet == 0) fprintf(stderr, "-------------------------------------\n");
437 | if(INPUT_SEEK(input_ptr, 0, SEEK_SET) == -1) {
438 | fprintf(stderr, "\nError: could not rewind input file.\n");
439 | exit(13);
440 | }
441 |
442 | /* Reset all the sequence/dynamic programming variables */
443 | memset(seq, 0, (slen/4+1)*sizeof(unsigned char));
444 | memset(rseq, 0, (slen/4+1)*sizeof(unsigned char));
445 | memset(useq, 0, (slen/8+1)*sizeof(unsigned char));
446 | memset(nodes, 0, nn*sizeof(struct _node));
447 | nn = 0; slen = 0; ipath = 0; nmask = 0;
448 | }
449 |
450 | /* Initialize the training files for a metagenomic request */
451 | else if(is_meta == 1) {
452 | if(quiet == 0) {
453 | fprintf(stderr, "Request: Metagenomic, Phase: Training\n");
454 | fprintf(stderr, "Initializing training files...");
455 | }
456 | initialize_metagenomic_bins(meta);
457 | if(quiet == 0) {
458 | fprintf(stderr, "done!\n");
459 | fprintf(stderr, "-------------------------------------\n");
460 | }
461 | }
462 |
463 | /* Print out header for gene finding phase */
464 | if(quiet == 0) {
465 | if(is_meta == 1)
466 | fprintf(stderr, "Request: Metagenomic, Phase: Gene Finding\n");
467 | else fprintf(stderr, "Request: Single Genome, Phase: Gene Finding\n");
468 | }
469 |
470 | /* Read and process each sequence in the file in succession */
471 | sprintf(cur_header, "Prodigal_Seq_1");
472 | sprintf(new_header, "Prodigal_Seq_2");
473 | while((slen = next_seq_multi(input_ptr, seq, useq, &num_seq, &gc,
474 | do_mask, mlist, &nmask, cur_header, new_header)) != -1) {
475 | rcom_seq(seq, rseq, useq, slen);
476 | if(slen == 0) {
477 | fprintf(stderr, "\nSequence read failed (file must be Fasta, ");
478 | fprintf(stderr, "Genbank, or EMBL format).\n\n");
479 | exit(14);
480 | }
481 |
482 | if(quiet == 0) {
483 | fprintf(stderr, "Finding genes in sequence #%d (%d bp)...", num_seq, slen);
484 | }
485 |
486 | /* Reallocate memory if this is the biggest sequence we've seen */
487 | if(slen > max_slen && slen > STT_NOD*8) {
488 | nodes = (struct _node *)realloc(nodes, (int)(slen/8)*sizeof(struct _node));
489 | if(nodes == NULL) {
490 | fprintf(stderr, "Realloc failed on nodes\n\n");
491 | exit(11);
492 | }
493 | max_slen = slen;
494 | }
495 |
496 | /* Calculate short header for this sequence */
497 | calc_short_header(cur_header, short_header, num_seq);
498 |
499 | if(is_meta == 0) { /* Single Genome Version */
500 |
501 | /***********************************************************************
502 | Find all the potential starts and stops, sort them, and create a
503 | comprehensive list of nodes for dynamic programming.
504 | ***********************************************************************/
505 | nn = add_nodes(seq, rseq, slen, nodes, closed, mlist, nmask, &tinf);
506 | qsort(nodes, nn, sizeof(struct _node), &compare_nodes);
507 |
508 | /***********************************************************************
509 | Second dynamic programming, using the dicodon statistics as the
510 | scoring function.
511 | ***********************************************************************/
512 | score_nodes(seq, rseq, slen, nodes, nn, &tinf, closed, is_meta);
513 | if(start_ptr != stdout)
514 | write_start_file(start_ptr, nodes, nn, &tinf, num_seq, slen, 0, NULL,
515 | VERSION, cur_header);
516 | record_overlapping_starts(nodes, nn, &tinf, 1);
517 | ipath = dprog(nodes, nn, &tinf, 1);
518 | eliminate_bad_genes(nodes, ipath, &tinf);
519 | ng = add_genes(genes, nodes, ipath);
520 | tweak_final_starts(genes, ng, nodes, nn, &tinf);
521 | record_gene_data(genes, ng, nodes, &tinf, num_seq);
522 | if(quiet == 0) {
523 | fprintf(stderr, "done!\n");
524 | }
525 |
526 | /* Output the genes */
527 | print_genes(output_ptr, genes, ng, nodes, slen, output, num_seq, 0, NULL,
528 | &tinf, cur_header, short_header, VERSION);
529 | fflush(output_ptr);
530 | if(trans_ptr != stdout)
531 | write_translations(trans_ptr, genes, ng, nodes, seq, rseq, useq, slen,
532 | &tinf, num_seq, short_header);
533 | if(nuc_ptr != stdout)
534 | write_nucleotide_seqs(nuc_ptr, genes, ng, nodes, seq, rseq, useq, slen,
535 | &tinf, num_seq, short_header);
536 | }
537 |
538 | else { /* Metagenomic Version */
539 |
540 | low = 0.88495*gc - 0.0102337;
541 | if(low > 0.65) low = 0.65;
542 | high = 0.86596*gc + .1131991;
543 | if(high < 0.35) high = 0.35;
544 |
545 | max_score = -100.0;
546 | for(i = 0; i < NUM_META; i++) {
547 | if(i == 0 || meta[i].tinf->trans_table !=
548 | meta[i-1].tinf->trans_table) {
549 | memset(nodes, 0, nn*sizeof(struct _node));
550 | nn = add_nodes(seq, rseq, slen, nodes, closed, mlist, nmask,
551 | meta[i].tinf);
552 | qsort(nodes, nn, sizeof(struct _node), &compare_nodes);
553 | }
554 | if(meta[i].tinf->gc < low || meta[i].tinf->gc > high) continue;
555 | reset_node_scores(nodes, nn);
556 | score_nodes(seq, rseq, slen, nodes, nn, meta[i].tinf, closed, is_meta);
557 | record_overlapping_starts(nodes, nn, meta[i].tinf, 1);
558 | ipath = dprog(nodes, nn, meta[i].tinf, 1);
559 | if(nodes[ipath].score > max_score) {
560 | max_phase = i;
561 | max_score = nodes[ipath].score;
562 | eliminate_bad_genes(nodes, ipath, meta[i].tinf);
563 | ng = add_genes(genes, nodes, ipath);
564 | tweak_final_starts(genes, ng, nodes, nn, meta[i].tinf);
565 | record_gene_data(genes, ng, nodes, meta[i].tinf, num_seq);
566 | }
567 | }
568 |
569 | /* Recover the nodes for the best of the runs */
570 | memset(nodes, 0, nn*sizeof(struct _node));
571 | nn = add_nodes(seq, rseq, slen, nodes, closed, mlist, nmask,
572 | meta[max_phase].tinf);
573 | qsort(nodes, nn, sizeof(struct _node), &compare_nodes);
574 | score_nodes(seq, rseq, slen, nodes, nn, meta[max_phase].tinf, closed,
575 | is_meta);
576 | if(start_ptr != stdout)
577 | write_start_file(start_ptr, nodes, nn, meta[max_phase].tinf,
578 | num_seq, slen, 1, meta[max_phase].desc, VERSION,
579 | cur_header);
580 |
581 | if(quiet == 0) {
582 | fprintf(stderr, "done!\n");
583 | }
584 |
585 | /* Output the genes */
586 | print_genes(output_ptr, genes, ng, nodes, slen, output, num_seq, 1,
587 | meta[max_phase].desc, meta[max_phase].tinf, cur_header,
588 | short_header, VERSION);
589 | fflush(output_ptr);
590 | if(trans_ptr != stdout)
591 | write_translations(trans_ptr, genes, ng, nodes, seq, rseq, useq, slen,
592 | meta[max_phase].tinf, num_seq, short_header);
593 | if(nuc_ptr != stdout)
594 | write_nucleotide_seqs(nuc_ptr, genes, ng, nodes, seq, rseq, useq, slen,
595 | meta[max_phase].tinf, num_seq, short_header);
596 | }
597 |
598 | /* Reset all the sequence/dynamic programming variables */
599 | memset(seq, 0, (slen/4+1)*sizeof(unsigned char));
600 | memset(rseq, 0, (slen/4+1)*sizeof(unsigned char));
601 | memset(useq, 0, (slen/8+1)*sizeof(unsigned char));
602 | memset(nodes, 0, nn*sizeof(struct _node));
603 | nn = 0; slen = 0; ipath = 0; nmask = 0;
604 | strcpy(cur_header, new_header);
605 | sprintf(new_header, "Prodigal_Seq_%d\n", num_seq+1);
606 | }
607 |
608 | if(num_seq == 0) {
609 | fprintf(stderr, "\nError: no input sequences to analyze.\n\n");
610 | exit(18);
611 | }
612 |
613 | /* Free all memory */
614 | free(seq);
615 | free(rseq);
616 | free(useq);
617 | free(nodes);
618 | free(genes);
619 | for(i = 0; i < NUM_META; i++) free(meta[i].tinf);
620 |
621 | /* Close all the filehandles and exit */
622 | INPUT_CLOSE(input_ptr);
623 | if(output_ptr != stdout) fclose(output_ptr);
624 | if(start_ptr != stdout) fclose(start_ptr);
625 | if(trans_ptr != stdout) fclose(trans_ptr);
626 |
627 | /* Remove tmp file */
628 | if(piped == 1 && remove(input_copy) != 0) {
629 | fprintf(stderr, "Could not delete tmp file %s.\n", input_copy);
630 | exit(18);
631 | }
632 |
633 | exit(0);
634 | }
635 |
636 | void version() {
637 | fprintf(stderr, "\nProdigal V%s: %s\n\n", VERSION, DATE);
638 | exit(0);
639 | }
640 |
641 | void usage(char *msg) {
642 | fprintf(stderr, "\n%s\n", msg);
643 | fprintf(stderr, "\nUsage: prodigal [-a trans_file] [-c] [-d nuc_file]");
644 | fprintf(stderr, " [-f output_type]\n");
645 | fprintf(stderr, " [-g tr_table] [-h] [-i input_file] [-m]");
646 | fprintf(stderr, " [-n] [-o output_file]\n");
647 | fprintf(stderr, " [-p mode] [-q] [-s start_file]");
648 | fprintf(stderr, " [-t training_file] [-v]\n");
649 | fprintf(stderr, "\nDo 'prodigal -h' for more information.\n\n");
650 | exit(15);
651 | }
652 |
653 | void help() {
654 | fprintf(stderr, "\nUsage: prodigal [-a trans_file] [-c] [-d nuc_file]");
655 | fprintf(stderr, " [-f output_type]\n");
656 | fprintf(stderr, " [-g tr_table] [-h] [-i input_file] [-m]");
657 | fprintf(stderr, " [-n] [-o output_file]\n");
658 | fprintf(stderr, " [-p mode] [-q] [-s start_file]");
659 | fprintf(stderr, " [-t training_file] [-v]\n");
660 | fprintf(stderr, "\n -a: Write protein translations to the selected ");
661 | fprintf(stderr, "file.\n");
662 | fprintf(stderr, " -c: Closed ends. Do not allow genes to run off ");
663 | fprintf(stderr, "edges.\n");
664 | fprintf(stderr, " -d: Write nucleotide sequences of genes to the ");
665 | fprintf(stderr, "selected file.\n");
666 | fprintf(stderr, " -f: Select output format (gbk, gff, or sco). ");
667 | fprintf(stderr, "Default is gbk.\n");
668 | fprintf(stderr, " -g: Specify a translation table to use (default");
669 | fprintf(stderr, " 11).\n");
670 | fprintf(stderr, " -h: Print help menu and exit.\n");
671 | fprintf(stderr, " -i: Specify FASTA/Genbank input file (default ");
672 | fprintf(stderr, "reads from stdin).\n");
673 | fprintf(stderr, " -m: Treat runs of N as masked sequence; don't");
674 | fprintf(stderr, " build genes across them.\n");
675 | fprintf(stderr, " -n: Bypass Shine-Dalgarno trainer and force");
676 | fprintf(stderr, " a full motif scan.\n");
677 | fprintf(stderr, " -o: Specify output file (default writes to ");
678 | fprintf(stderr, "stdout).\n");
679 | fprintf(stderr, " -p: Select procedure (single or meta). Default");
680 | fprintf(stderr, " is single.\n");
681 | fprintf(stderr, " -q: Run quietly (suppress normal stderr output).\n");
682 | fprintf(stderr, " -s: Write all potential genes (with scores) to");
683 | fprintf(stderr, " the selected file.\n");
684 | fprintf(stderr, " -t: Write a training file (if none exists); ");
685 | fprintf(stderr, "otherwise, read and use\n");
686 | fprintf(stderr, " the specified training file.\n");
687 | fprintf(stderr, " -v: Print version number and exit.\n\n");
688 | exit(0);
689 | }
690 |
691 | /* For piped input, we make a copy of stdin so we can rewind the file. */
692 |
693 | int copy_standard_input_to_file(char *path, int quiet) {
694 | char line[MAX_LINE+1];
695 | FILE *wp;
696 |
697 | if(quiet == 0) {
698 | fprintf(stderr, "Piped input detected, copying stdin to a tmp file...");
699 | }
700 |
701 | wp = fopen(path, "w");
702 | if(wp == NULL) return -1;
703 | while(fgets(line, MAX_LINE, stdin) != NULL) {
704 | fprintf(wp, "%s", line);
705 | }
706 | fclose(wp);
707 |
708 | if(quiet == 0) {
709 | fprintf(stderr, "done!\n");
710 | fprintf(stderr, "-------------------------------------\n");
711 | }
712 | return 0;
713 | }
714 |
--------------------------------------------------------------------------------
/sequence.c:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | PRODIGAL (PROkaryotic DynamIc Programming Genefinding ALgorithm)
3 | Copyright (C) 2007-2016 University of Tennessee / UT-Battelle
4 |
5 | Code Author: Doug Hyatt
6 |
7 | This program is free software: you can redistribute it and/or modify
8 | it under the terms of the GNU General Public License as published by
9 | the Free Software Foundation, either version 3 of the License, or
10 | (at your option) any later version.
11 |
12 | This program is distributed in the hope that it will be useful,
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | GNU General Public License for more details.
16 |
17 | You should have received a copy of the GNU General Public License
18 | along with this program. If not, see .
19 | *******************************************************************************/
20 |
21 | #include "sequence.h"
22 |
23 | /*******************************************************************************
24 | Read the sequence for training purposes. If we encounter multiple
25 | sequences, we insert TTAATTAATTAA between each one to force stops in all
26 | six frames. When we hit MAX_SEQ bp, we stop and return what we've got so
27 | far for training. This routine reads in FASTA, and has a very 'loose'
28 | Genbank and Embl parser, but, to be safe, FASTA should generally be
29 | preferred.
30 | *******************************************************************************/
31 |
32 | int read_seq_training(fptr fp, unsigned char *seq, unsigned char *useq,
33 | double *gc, int do_mask, mask *mlist, int *nm) {
34 | char line[MAX_LINE+1];
35 | int hdr = 0, fhdr = 0, bctr = 0, len = 0, wrn = 0;
36 | int gc_cont = 0, mask_beg = -1;
37 | unsigned int i, gapsize = 0;
38 |
39 | line[MAX_LINE] = '\0';
40 | while(INPUT_GETS(line, MAX_LINE, fp) != NULL) {
41 | if(hdr == 0 && line[strlen(line)-1] != '\n' && wrn == 0) {
42 | wrn = 1;
43 | fprintf(stderr, "\n\nWarning: saw non-sequence line longer than ");
44 | fprintf(stderr, "%d chars, sequence might not be read ", MAX_LINE);
45 | fprintf(stderr, "correctly.\n\n");
46 | }
47 | if(line[0] == '>' || (line[0] == 'S' && line[1] == 'Q') ||
48 | (strlen(line) > 6 && strncmp(line, "ORIGIN", 6) == 0)) {
49 | hdr = 1;
50 | if(fhdr > 0) {
51 | for(i = 0; i < 12; i++) {
52 | if(i%4 == 0 || i%4 == 1) { set(seq, bctr); set(seq, bctr+1); }
53 | bctr+=2; len++;
54 | }
55 | }
56 | fhdr++;
57 | }
58 | else if(hdr == 1 && (line[0] == '/' && line[1] == '/')) hdr = 0;
59 | else if(hdr == 1) {
60 | if(strstr(line, "Expand") != NULL && strstr(line, "gap") != NULL) {
61 | sscanf(strstr(line, "gap")+4, "%u", &gapsize);
62 | if(gapsize < 1 || gapsize > MAX_LINE) {
63 | fprintf(stderr, "Error: gap size in gbk file can't exceed line");
64 | fprintf(stderr, " size.\n");
65 | exit(51);
66 | }
67 | for(i = 0; i < gapsize; i++) line[i] = 'n';
68 | line[i] = '\0';
69 | }
70 | for(i = 0; i < strlen(line); i++) {
71 | if(line[i] < 'A' || line[i] > 'z') continue;
72 | if(do_mask == 1 && mask_beg != -1 && line[i] != 'N' && line[i] != 'n') {
73 | if(len - mask_beg >= MASK_SIZE) {
74 | if(*nm == MAX_MASKS) {
75 | fprintf(stderr, "Error: saw too many regions of 'N''s in the ");
76 | fprintf(stderr, "sequence.\n");
77 | exit(52);
78 | }
79 | mlist[*nm].begin = mask_beg;
80 | mlist[*nm].end = len-1;
81 | (*nm)++;
82 | }
83 | mask_beg = -1;
84 | }
85 | if(do_mask == 1 && mask_beg == -1 && (line[i] == 'N' || line[i] == 'n'))
86 | mask_beg = len;
87 | if(line[i] == 'g' || line[i] == 'G') { set(seq, bctr); gc_cont++; }
88 | else if(line[i] == 't' || line[i] == 'T') {
89 | set(seq, bctr);
90 | set(seq, bctr+1);
91 | }
92 | else if(line[i] == 'c' || line[i] == 'C') {
93 | set(seq, bctr+1);
94 | gc_cont++;
95 | }
96 | else if(line[i] != 'a' && line[i] != 'A') {
97 | set(seq, bctr+1);
98 | set(useq, len);
99 | }
100 | bctr+=2; len++;
101 | }
102 | }
103 | if(len+MAX_LINE >= MAX_SEQ) {
104 | fprintf(stderr, "\n\nWarning: Sequence is long (max %d for training).\n",
105 | MAX_SEQ);
106 | fprintf(stderr, "Training on the first %d bases.\n\n", MAX_SEQ);
107 | break;
108 | }
109 | }
110 | if(fhdr > 1) {
111 | for(i = 0; i < 12; i++) {
112 | if(i%4 == 0 || i%4 == 1) { set(seq, bctr); set(seq, bctr+1); }
113 | bctr+=2; len++;
114 | }
115 | }
116 | *gc = ((double)gc_cont / (double)len);
117 | return len;
118 | }
119 |
120 | /* This routine reads in the next sequence in a FASTA/GB/EMBL file */
121 |
122 | int next_seq_multi(fptr fp, unsigned char *seq, unsigned char *useq,
123 | int *sctr, double *gc, int do_mask, mask *mlist, int *nm,
124 | char *cur_hdr, char *new_hdr) {
125 | char line[MAX_LINE+1];
126 | int reading_seq = 0, genbank_end = 0, bctr = 0, len = 0, wrn = 0;
127 | int gc_cont = 0, mask_beg = -1;
128 | unsigned int i, gapsize = 0;
129 |
130 | sprintf(new_hdr, "Prodigal_Seq_%d", *sctr+2);
131 |
132 | if(*sctr > 0) reading_seq = 1;
133 | line[MAX_LINE] = '\0';
134 | while(INPUT_GETS(line, MAX_LINE, fp) != NULL) {
135 | if(reading_seq == 0 && line[strlen(line)-1] != '\n' && wrn == 0) {
136 | wrn = 1;
137 | fprintf(stderr, "\n\nWarning: saw non-sequence line longer than ");
138 | fprintf(stderr, "%d chars, sequence might not be read ", MAX_LINE);
139 | fprintf(stderr, "correctly.\n\n");
140 | }
141 | if(strlen(line) > 10 && strncmp(line, "DEFINITION", 10) == 0) {
142 | if(genbank_end == 0) {
143 | strcpy(cur_hdr, line+12);
144 | cur_hdr[strlen(cur_hdr)-1] = '\0';
145 | }
146 | else {
147 | strcpy(new_hdr, line+12);
148 | new_hdr[strlen(new_hdr)-1] = '\0';
149 | }
150 | }
151 | if(line[0] == '>' || (line[0] == 'S' && line[1] == 'Q') ||
152 | (strlen(line) > 6 && strncmp(line, "ORIGIN", 6) == 0)) {
153 | if(reading_seq == 1 || genbank_end == 1 || *sctr > 0) {
154 | if(line[0] == '>') {
155 | strcpy(new_hdr, line+1);
156 | new_hdr[strlen(new_hdr)-1] = '\0';
157 | }
158 | break;
159 | }
160 | if(line[0] == '>') {
161 | strcpy(cur_hdr, line+1);
162 | cur_hdr[strlen(cur_hdr)-1] = '\0';
163 | }
164 | reading_seq = 1;
165 | }
166 | else if(reading_seq == 1 && (line[0] == '/' && line[1] == '/')) {
167 | reading_seq = 0;
168 | genbank_end = 1;
169 | }
170 | else if(reading_seq == 1) {
171 | if(strstr(line, "Expand") != NULL && strstr(line, "gap") != NULL) {
172 | sscanf(strstr(line, "gap")+4, "%u", &gapsize);
173 | if(gapsize < 1 || gapsize > MAX_LINE) {
174 | fprintf(stderr, "Error: gap size in gbk file can't exceed line");
175 | fprintf(stderr, " size.\n");
176 | exit(54);
177 | }
178 | for(i = 0; i < gapsize; i++) line[i] = 'n';
179 | line[i] = '\0';
180 | }
181 | for(i = 0; i < strlen(line); i++) {
182 | if(line[i] < 'A' || line[i] > 'z') continue;
183 | if(do_mask == 1 && mask_beg != -1 && line[i] != 'N' && line[i] != 'n') {
184 | if(len - mask_beg >= MASK_SIZE) {
185 | if(*nm == MAX_MASKS) {
186 | fprintf(stderr, "Error: saw too many regions of 'N''s in the ");
187 | fprintf(stderr, "sequence.\n");
188 | exit(55);
189 | }
190 | mlist[*nm].begin = mask_beg;
191 | mlist[*nm].end = len-1;
192 | (*nm)++;
193 | }
194 | mask_beg = -1;
195 | }
196 | if(do_mask == 1 && mask_beg == -1 && (line[i] == 'N' || line[i] == 'n'))
197 | mask_beg = len;
198 | if(line[i] == 'g' || line[i] == 'G') { set(seq, bctr); gc_cont++; }
199 | else if(line[i] == 't' || line[i] == 'T') {
200 | set(seq, bctr);
201 | set(seq, bctr+1);
202 | }
203 | else if(line[i] == 'c' || line[i] == 'C') {
204 | set(seq, bctr+1);
205 | gc_cont++;
206 | }
207 | else if(line[i] != 'a' && line[i] != 'A') {
208 | set(seq, bctr+1);
209 | set(useq, len);
210 | }
211 | bctr+=2; len++;
212 | }
213 | }
214 | if(len+MAX_LINE >= MAX_SEQ) {
215 | fprintf(stderr, "Sequence too long (max %d permitted).\n", MAX_SEQ);
216 | exit(56);
217 | }
218 | }
219 | if(len == 0) return -1;
220 | *gc = ((double)gc_cont / (double)len);
221 | *sctr = *sctr + 1;
222 | return len;
223 | }
224 |
225 | /* Takes first word of header */
226 | void calc_short_header(char *header, char *short_header, int sctr) {
227 | int i;
228 |
229 | strcpy(short_header, header);
230 | for(i = 0; i < strlen(header); i++) {
231 | if(header[i] == ' ' || header[i] == '\t' || header[i] == '\r' ||
232 | header[i] == '\n') {
233 | strncpy(short_header, header, i);
234 | short_header[i] = '\0';
235 | break;
236 | }
237 | }
238 | if(i == 0) { sprintf(short_header, "Prodigal_Seq_%d", sctr); }
239 | }
240 |
241 | /* Takes rseq and fills it up with the rev complement of seq */
242 |
243 | void rcom_seq(unsigned char *seq, unsigned char *rseq, unsigned char *useq,
244 | int len) {
245 | int i, slen=len*2;
246 | for(i = 0; i < slen; i++)
247 | if(test(seq, i) == 0) set(rseq, slen-i-1+(i%2==0?-1:1));
248 | for(i = 0; i < len; i++) {
249 | if(test(useq, i) == 1) {
250 | toggle(rseq, slen-1-i*2);
251 | toggle(rseq, slen-2-i*2);
252 | }
253 | }
254 | }
255 |
256 | /* Simple routines to say whether or not bases are */
257 | /* a, c, t, g, starts, stops, etc. */
258 |
259 | int is_a(unsigned char *seq, int n) {
260 | int ndx = n*2;
261 | if(test(seq, ndx) == 1 || test(seq, ndx+1) == 1) return 0;
262 | return 1;
263 | }
264 |
265 | int is_c(unsigned char *seq, int n) {
266 | int ndx = n*2;
267 | if(test(seq, ndx) == 1 || test(seq, ndx+1) == 0) return 0;
268 | return 1;
269 | }
270 |
271 | int is_g(unsigned char *seq, int n) {
272 | int ndx = n*2;
273 | if(test(seq, ndx) == 0 || test(seq, ndx+1) == 1) return 0;
274 | return 1;
275 | }
276 |
277 | int is_t(unsigned char *seq, int n) {
278 | int ndx = n*2;
279 | if(test(seq, ndx) == 0 || test(seq, ndx+1) == 0) return 0;
280 | return 1;
281 | }
282 |
283 | int is_n(unsigned char *useq, int n) {
284 | if(test(useq, n) == 0) return 0;
285 | return 1;
286 | }
287 |
288 | int is_stop(unsigned char *seq, int n, struct _training *tinf) {
289 |
290 | /* TAG */
291 | if(is_t(seq, n) == 1 && is_a(seq, n+1) == 1 && is_g(seq, n+2) == 1) {
292 | if(tinf->trans_table == 6 || tinf->trans_table == 15 ||
293 | tinf->trans_table == 16 || tinf->trans_table == 22) return 0;
294 | return 1;
295 | }
296 |
297 | /* TGA */
298 | if(is_t(seq, n) == 1 && is_g(seq, n+1) == 1 && is_a(seq, n+2) == 1) {
299 | if((tinf->trans_table >= 2 && tinf->trans_table <= 5) ||
300 | tinf->trans_table == 9 || tinf->trans_table == 10 ||
301 | tinf->trans_table == 13 || tinf->trans_table == 14 ||
302 | tinf->trans_table == 21 || tinf->trans_table == 25) return 0;
303 | return 1;
304 | }
305 |
306 | /* TAA */
307 | if(is_t(seq, n) == 1 && is_a(seq, n+1) == 1 && is_a(seq, n+2) == 1) {
308 | if(tinf->trans_table == 6 || tinf->trans_table == 14) return 0;
309 | return 1;
310 | }
311 |
312 | /* Code 2 */
313 | if(tinf->trans_table == 2 && is_a(seq, n) == 1 && is_g(seq, n+1) == 1 &&
314 | is_a(seq, n+2) == 1) return 1;
315 | if(tinf->trans_table == 2 && is_a(seq, n) == 1 && is_g(seq, n+1) == 1 &&
316 | is_g(seq, n+2) == 1) return 1;
317 |
318 | /* Code 22 */
319 | if(tinf->trans_table == 22 && is_t(seq, n) == 1 && is_c(seq, n+1) == 1 &&
320 | is_a(seq, n+2) == 1) return 1;
321 |
322 | /* Code 23 */
323 | if(tinf->trans_table == 23 && is_t(seq, n) == 1 && is_t(seq, n+1) == 1 &&
324 | is_a(seq, n+2) == 1) return 1;
325 |
326 | return 0;
327 | }
328 |
329 | int is_start(unsigned char *seq, int n, struct _training *tinf) {
330 |
331 | /* ATG */
332 | if(is_a(seq, n) == 1 && is_t(seq, n+1) == 1 && is_g(seq, n+2) == 1) return 1;
333 |
334 | /* Codes that only use ATG */
335 | if(tinf->trans_table == 6 || tinf->trans_table == 10 ||
336 | tinf->trans_table == 14 || tinf->trans_table == 15 ||
337 | tinf->trans_table == 16 || tinf->trans_table == 22) return 0;
338 |
339 | /* GTG */
340 | if(is_g(seq, n) == 1 && is_t(seq, n+1) == 1 && is_g(seq, n+2) == 1) {
341 | if(tinf->trans_table == 1 || tinf->trans_table == 3 ||
342 | tinf->trans_table == 12 || tinf->trans_table == 22) return 0;
343 | return 1;
344 | }
345 |
346 | /* TTG */
347 | if(is_t(seq, n) == 1 && is_t(seq, n+1) == 1 && is_g(seq, n+2) == 1) {
348 | if(tinf->trans_table < 4 || tinf->trans_table == 9 ||
349 | (tinf->trans_table >= 21 && tinf->trans_table < 25)) return 0;
350 | return 1;
351 | }
352 |
353 | /* We do not handle other initiation codons */
354 | return 0;
355 | }
356 |
357 | int is_atg(unsigned char *seq, int n) {
358 | if(is_a(seq, n) == 0 || is_t(seq, n+1) == 0 || is_g(seq, n+2) == 0) return 0;
359 | return 1;
360 | }
361 |
362 | int is_gtg(unsigned char *seq, int n) {
363 | if(is_g(seq, n) == 0 || is_t(seq, n+1) == 0 || is_g(seq, n+2) == 0) return 0;
364 | return 1;
365 | }
366 |
367 | int is_ttg(unsigned char *seq, int n) {
368 | if(is_t(seq, n) == 0 || is_t(seq, n+1) == 0 || is_g(seq, n+2) == 0) return 0;
369 | return 1;
370 | }
371 |
372 | int is_gc(unsigned char *seq, int n) {
373 | int ndx = n*2;
374 | if(test(seq, ndx) != test(seq, ndx+1)) return 1;
375 | return 0;
376 | }
377 |
378 | double gc_content(unsigned char *seq, int a, int b) {
379 | double sum = 0.0, gc = 0.0;
380 | int i;
381 | for(i = a; i <= b; i++) {
382 | if(is_g(seq, i) == 1 || is_c(seq, i) == 1) gc++;
383 | sum++;
384 | }
385 | return gc/sum;
386 | }
387 |
388 | /* Returns a single amino acid for this position */
389 | char amino(unsigned char *seq, int n, struct _training *tinf, int is_init) {
390 | if(is_stop(seq, n, tinf) == 1) return '*';
391 | if(is_start(seq, n, tinf) == 1 && is_init == 1) return 'M';
392 | if(is_t(seq, n) == 1 && is_t(seq, n+1) == 1 && is_t(seq, n+2) == 1)
393 | return 'F';
394 | if(is_t(seq, n) == 1 && is_t(seq, n+1) == 1 && is_c(seq, n+2) == 1)
395 | return 'F';
396 | if(is_t(seq, n) == 1 && is_t(seq, n+1) == 1 && is_a(seq, n+2) == 1)
397 | return 'L';
398 | if(is_t(seq, n) == 1 && is_t(seq, n+1) == 1 && is_g(seq, n+2) == 1)
399 | return 'L';
400 | if(is_t(seq, n) == 1 && is_c(seq, n+1) == 1) return 'S';
401 | if(is_t(seq, n) == 1 && is_a(seq, n+1) == 1 && is_t(seq, n+2) == 1)
402 | return 'Y';
403 | if(is_t(seq, n) == 1 && is_a(seq, n+1) == 1 && is_c(seq, n+2) == 1)
404 | return 'Y';
405 | if(is_t(seq, n) == 1 && is_a(seq, n+1) == 1 && is_a(seq, n+2) == 1) {
406 | if(tinf->trans_table == 6) return 'Q';
407 | if(tinf->trans_table == 14) return 'Y';
408 | }
409 | if(is_t(seq, n) == 1 && is_a(seq, n+1) == 1 && is_g(seq, n+2) == 1) {
410 | if(tinf->trans_table == 6 || tinf->trans_table == 15) return 'Q';
411 | if(tinf->trans_table == 22) return 'L';
412 | }
413 | if(is_t(seq, n) == 1 && is_g(seq, n+1) == 1 && is_t(seq, n+2) == 1)
414 | return 'C';
415 | if(is_t(seq, n) == 1 && is_g(seq, n+1) == 1 && is_c(seq, n+2) == 1)
416 | return 'C';
417 | if(is_t(seq, n) == 1 && is_g(seq, n+1) == 1 && is_a(seq, n+2) == 1) {
418 | if(tinf->trans_table == 25) return 'G';
419 | else return 'W';
420 | }
421 | if(is_t(seq, n) == 1 && is_g(seq, n+1) == 1 && is_g(seq, n+2) == 1)
422 | return 'W';
423 | if(is_c(seq, n) == 1 && is_t(seq, n+1) == 1 && is_t(seq, n+2) == 1) {
424 | if(tinf->trans_table == 3) return 'T';
425 | return 'L';
426 | }
427 | if(is_c(seq, n) == 1 && is_t(seq, n+1) == 1 && is_c(seq, n+2) == 1) {
428 | if(tinf->trans_table == 3) return 'T';
429 | return 'L';
430 | }
431 | if(is_c(seq, n) == 1 && is_t(seq, n+1) == 1 && is_a(seq, n+2) == 1) {
432 | if(tinf->trans_table == 3) return 'T';
433 | return 'L';
434 | }
435 | if(is_c(seq, n) == 1 && is_t(seq, n+1) == 1 && is_g(seq, n+2) == 1) {
436 | if(tinf->trans_table == 3) return 'T';
437 | if(tinf->trans_table == 12) return 'S';
438 | return 'L';
439 | }
440 | if(is_c(seq, n) == 1 && is_c(seq, n+1) == 1) return 'P';
441 | if(is_c(seq, n) == 1 && is_a(seq, n+1) == 1 && is_t(seq, n+2) == 1)
442 | return 'H';
443 | if(is_c(seq, n) == 1 && is_a(seq, n+1) == 1 && is_c(seq, n+2) == 1)
444 | return 'H';
445 | if(is_c(seq, n) == 1 && is_a(seq, n+1) == 1 && is_a(seq, n+2) == 1)
446 | return 'Q';
447 | if(is_c(seq, n) == 1 && is_a(seq, n+1) == 1 && is_g(seq, n+2) == 1)
448 | return 'Q';
449 | if(is_c(seq, n) == 1 && is_g(seq, n+1) == 1) return 'R';
450 | if(is_a(seq, n) == 1 && is_t(seq, n+1) == 1 && is_t(seq, n+2) == 1)
451 | return 'I';
452 | if(is_a(seq, n) == 1 && is_t(seq, n+1) == 1 && is_c(seq, n+2) == 1)
453 | return 'I';
454 | if(is_a(seq, n) == 1 && is_t(seq, n+1) == 1 && is_a(seq, n+2) == 1) {
455 | if(tinf->trans_table == 2 || tinf->trans_table == 3 ||
456 | tinf->trans_table == 5 || tinf->trans_table == 13 ||
457 | tinf->trans_table == 21) return 'M';
458 | return 'I';
459 | }
460 | if(is_a(seq, n) == 1 && is_t(seq, n+1) == 1 && is_g(seq, n+2) == 1)
461 | return 'M';
462 | if(is_a(seq, n) == 1 && is_c(seq, n+1) == 1) return 'T';
463 | if(is_a(seq, n) == 1 && is_a(seq, n+1) == 1 && is_t(seq, n+2) == 1)
464 | return 'N';
465 | if(is_a(seq, n) == 1 && is_a(seq, n+1) == 1 && is_c(seq, n+2) == 1)
466 | return 'N';
467 | if(is_a(seq, n) == 1 && is_a(seq, n+1) == 1 && is_a(seq, n+2) == 1) {
468 | if(tinf->trans_table == 9 || tinf->trans_table == 14 ||
469 | tinf->trans_table == 21) return 'N';
470 | return 'K';
471 | }
472 | if(is_a(seq, n) == 1 && is_a(seq, n+1) == 1 && is_g(seq, n+2) == 1)
473 | return 'K';
474 | if(is_a(seq, n) == 1 && is_g(seq, n+1) == 1 && is_t(seq, n+2) == 1)
475 | return 'S';
476 | if(is_a(seq, n) == 1 && is_g(seq, n+1) == 1 && is_c(seq, n+2) == 1)
477 | return 'S';
478 | if(is_a(seq, n) == 1 && is_g(seq, n+1) == 1 && (is_a(seq, n+2) == 1 ||
479 | is_g(seq, n+2) == 1)) {
480 | if(tinf->trans_table == 13) return 'G';
481 | if(tinf->trans_table == 5 || tinf->trans_table == 9 ||
482 | tinf->trans_table == 14 || tinf->trans_table == 21) return 'S';
483 | return 'R';
484 | }
485 | if(is_g(seq, n) == 1 && is_t(seq, n+1) == 1) return 'V';
486 | if(is_g(seq, n) == 1 && is_c(seq, n+1) == 1) return 'A';
487 | if(is_g(seq, n) == 1 && is_a(seq, n+1) == 1 && is_t(seq, n+2) == 1)
488 | return 'D';
489 | if(is_g(seq, n) == 1 && is_a(seq, n+1) == 1 && is_c(seq, n+2) == 1)
490 | return 'D';
491 | if(is_g(seq, n) == 1 && is_a(seq, n+1) == 1 && is_a(seq, n+2) == 1)
492 | return 'E';
493 | if(is_g(seq, n) == 1 && is_a(seq, n+1) == 1 && is_g(seq, n+2) == 1)
494 | return 'E';
495 | if(is_g(seq, n) == 1 && is_g(seq, n+1) == 1) return 'G';
496 | return 'X';
497 | }
498 |
499 | /* Converts an amino acid letter to a numerical value */
500 | int amino_num(char aa) {
501 | if(aa == 'a' || aa == 'A') return 0;
502 | if(aa == 'c' || aa == 'C') return 1;
503 | if(aa == 'd' || aa == 'D') return 2;
504 | if(aa == 'e' || aa == 'E') return 3;
505 | if(aa == 'f' || aa == 'F') return 4;
506 | if(aa == 'g' || aa == 'G') return 5;
507 | if(aa == 'h' || aa == 'H') return 6;
508 | if(aa == 'i' || aa == 'I') return 7;
509 | if(aa == 'k' || aa == 'K') return 8;
510 | if(aa == 'l' || aa == 'L') return 9;
511 | if(aa == 'm' || aa == 'M') return 10;
512 | if(aa == 'n' || aa == 'N') return 11;
513 | if(aa == 'p' || aa == 'P') return 12;
514 | if(aa == 'q' || aa == 'Q') return 13;
515 | if(aa == 'r' || aa == 'R') return 14;
516 | if(aa == 's' || aa == 'S') return 15;
517 | if(aa == 't' || aa == 'T') return 16;
518 | if(aa == 'v' || aa == 'V') return 17;
519 | if(aa == 'w' || aa == 'W') return 18;
520 | if(aa == 'y' || aa == 'Y') return 19;
521 | return -1;
522 | }
523 |
524 | /* Converts a numerical value to an amino acid letter */
525 | char amino_letter(int num) {
526 | if(num == 0) return 'A';
527 | if(num == 1) return 'C';
528 | if(num == 2) return 'D';
529 | if(num == 3) return 'E';
530 | if(num == 4) return 'F';
531 | if(num == 5) return 'G';
532 | if(num == 6) return 'H';
533 | if(num == 7) return 'I';
534 | if(num == 8) return 'K';
535 | if(num == 9) return 'L';
536 | if(num == 10) return 'M';
537 | if(num == 11) return 'N';
538 | if(num == 12) return 'P';
539 | if(num == 13) return 'Q';
540 | if(num == 14) return 'R';
541 | if(num == 15) return 'S';
542 | if(num == 16) return 'T';
543 | if(num == 17) return 'V';
544 | if(num == 18) return 'W';
545 | if(num == 19) return 'Y';
546 | return 'X';
547 | }
548 |
549 | /* Returns the corresponding frame on the reverse strand */
550 |
551 | int rframe(int fr, int slen) {
552 | int md = slen%3-1;
553 | if(md == 0) md = 3;
554 | return (md-fr);
555 | }
556 |
557 | /* Simple 3-way max function */
558 |
559 | int max_fr(int n1, int n2, int n3) {
560 | if(n1 > n2)
561 | if(n1 > n3) return 0; else return 2;
562 | else
563 | if(n2 > n3) return 1; else return 2;
564 | }
565 |
566 | /*******************************************************************************
567 | Creates a GC frame plot for a given sequence. This is simply a string with
568 | the highest GC content frame for a window centered on position for every
569 | position in the sequence.
570 | *******************************************************************************/
571 |
572 | int *calc_most_gc_frame(unsigned char *seq, int slen) {
573 | int i, j, *fwd, *bwd, *tot;
574 | int win, *gp;
575 |
576 | gp = (int *)malloc(slen*sizeof(double));
577 | fwd = (int *)malloc(slen*sizeof(int));
578 | bwd = (int *)malloc(slen*sizeof(int));
579 | tot = (int *)malloc(slen*sizeof(int));
580 | if(fwd == NULL || bwd == NULL || gp == NULL || tot == NULL) return NULL;
581 | for(i = 0; i < slen; i++) { fwd[i] = 0; bwd[i] = 0; tot[i] = 0; gp[i] = -1; }
582 |
583 | for(i = 0; i < 3; i++) {
584 | for(j = 0 + i; j < slen; j++) {
585 | if(j < 3) fwd[j] = is_gc(seq, j);
586 | else fwd[j] = fwd[j-3] + is_gc(seq, j);
587 | if(j < 3) bwd[slen-j-1] = is_gc(seq, slen-j-1);
588 | else bwd[slen-j-1] = bwd[slen-j+2] + is_gc(seq, slen-j-1);
589 | }
590 | }
591 | for(i = 0; i < slen; i++) {
592 | tot[i] = fwd[i] + bwd[i] - is_gc(seq, i);
593 | if(i - WINDOW/2 >= 0) tot[i] -= fwd[i-WINDOW/2];
594 | if(i + WINDOW/2 < slen) tot[i] -= bwd[i+WINDOW/2];
595 | }
596 | free(fwd); free(bwd);
597 | for(i = 0; i < slen-2; i+=3) {
598 | win = max_fr(tot[i], tot[i+1], tot[i+2]);
599 | for(j = 0; j < 3; j++) gp[i+j] = win;
600 | }
601 | free(tot);
602 | return gp;
603 | }
604 |
605 |
606 | /* Converts a word of size len to a number */
607 | int mer_ndx(int len, unsigned char *seq, int pos) {
608 | int i, ndx = 0;
609 | for(i = 0; i < 2*len; i++) ndx |= (test(seq, pos*2+i)<>= (i*2);
632 | qt[i] = letters[val];
633 | }
634 | qt[i] = '\0';
635 | }
636 | }
637 |
638 | /* Builds a 'len'-mer background for whole sequence */
639 | void calc_mer_bg(int len, unsigned char *seq, unsigned char *rseq, int slen,
640 | double *bg) {
641 | int i, glob = 0, size = 1;
642 | int *counts;
643 |
644 | for(i = 1; i <= len; i++) size *= 4;
645 | counts = (int *)malloc(size * sizeof(int));
646 | for(i = 0; i < size; i++) counts[i] = 0;
647 | for(i = 0; i < slen-len+1; i++) {
648 | counts[mer_ndx(len, seq, i)]++;
649 | counts[mer_ndx(len, rseq, i)]++;
650 | glob+=2;
651 | }
652 | for(i = 0; i < size; i++) bg[i] = (double)((counts[i]*1.0)/(glob*1.0));
653 | free(counts);
654 | }
655 |
656 | /*******************************************************************************
657 | Finds the highest-scoring region similar to AGGAGG in a given stretch of
658 | sequence upstream of a start.
659 | *******************************************************************************/
660 |
661 | int shine_dalgarno_exact(unsigned char *seq, int pos, int start, double *rwt) {
662 | int i, j, k, mism, rdis, limit, max_val, cur_val = 0;
663 | double match[6], cur_ctr, dis_flag;
664 |
665 | limit = imin(6, start-4-pos);
666 | for(i = 0; i < 6; i++) match[i] = -10.0;
667 |
668 | /* Compare the 6-base region to AGGAGG */
669 | for(i = 0; i < limit; i++) {
670 | if(pos + i >= 0) {
671 | if(i%3 == 0 && is_a(seq, pos+i) == 1) match[i] = 2.0;
672 | else if(i%3 != 0 && is_g(seq, pos+i) == 1) match[i] = 3.0;
673 | }
674 | }
675 |
676 | /* Find the maximally scoring motif */
677 | max_val = 0;
678 | for(i = limit; i >= 3; i--) {
679 | for(j = 0; j <= limit-i; j++) {
680 | cur_ctr = -2.0;
681 | mism = 0;
682 | for(k = j; k < j+i; k++) {
683 | cur_ctr += match[k];
684 | if(match[k] < 0.0) mism++;
685 | }
686 | if(mism > 0) continue;
687 | rdis = start - (pos+j+i);
688 | if(rdis < 5 && i < 5) dis_flag = 2;
689 | else if(rdis < 5 && i >= 5) dis_flag = 1;
690 | else if(rdis > 10 && rdis <= 12 && i < 5) dis_flag = 1;
691 | else if(rdis > 10 && rdis <= 12 && i >= 5) dis_flag = 2;
692 | else if(rdis >= 13) { dis_flag = 3; }
693 | else dis_flag = 0;
694 | if(rdis > 15 || cur_ctr < 6.0) continue;
695 |
696 | /* Exact-Matching RBS Motifs */
697 | if(cur_ctr < 6.0) cur_val = 0;
698 | else if(cur_ctr == 6.0 && dis_flag == 2) cur_val = 1;
699 | else if(cur_ctr == 6.0 && dis_flag == 3) cur_val = 2;
700 | else if(cur_ctr == 8.0 && dis_flag == 3) cur_val = 3;
701 | else if(cur_ctr == 9.0 && dis_flag == 3) cur_val = 3;
702 | else if(cur_ctr == 6.0 && dis_flag == 1) cur_val = 6;
703 | else if(cur_ctr == 11.0 && dis_flag == 3) cur_val = 10;
704 | else if(cur_ctr == 12.0 && dis_flag == 3) cur_val = 10;
705 | else if(cur_ctr == 14.0 && dis_flag == 3) cur_val = 10;
706 | else if(cur_ctr == 8.0 && dis_flag == 2) cur_val = 11;
707 | else if(cur_ctr == 9.0 && dis_flag == 2) cur_val = 11;
708 | else if(cur_ctr == 8.0 && dis_flag == 1) cur_val = 12;
709 | else if(cur_ctr == 9.0 && dis_flag == 1) cur_val = 12;
710 | else if(cur_ctr == 6.0 && dis_flag == 0) cur_val = 13;
711 | else if(cur_ctr == 8.0 && dis_flag == 0) cur_val = 15;
712 | else if(cur_ctr == 9.0 && dis_flag == 0) cur_val = 16;
713 | else if(cur_ctr == 11.0 && dis_flag == 2) cur_val = 20;
714 | else if(cur_ctr == 11.0 && dis_flag == 1) cur_val = 21;
715 | else if(cur_ctr == 11.0 && dis_flag == 0) cur_val = 22;
716 | else if(cur_ctr == 12.0 && dis_flag == 2) cur_val = 20;
717 | else if(cur_ctr == 12.0 && dis_flag == 1) cur_val = 23;
718 | else if(cur_ctr == 12.0 && dis_flag == 0) cur_val = 24;
719 | else if(cur_ctr == 14.0 && dis_flag == 2) cur_val = 25;
720 | else if(cur_ctr == 14.0 && dis_flag == 1) cur_val = 26;
721 | else if(cur_ctr == 14.0 && dis_flag == 0) cur_val = 27;
722 |
723 | if(rwt[cur_val] < rwt[max_val]) continue;
724 | if(rwt[cur_val] == rwt[max_val] && cur_val < max_val) continue;
725 | max_val = cur_val;
726 | }
727 | }
728 |
729 | return max_val;
730 | }
731 |
732 | /*******************************************************************************
733 | Finds the highest-scoring region similar to AGGAGG in a given stretch of
734 | sequence upstream of a start. Only considers 5/6-mers with 1 mismatch.
735 | *******************************************************************************/
736 |
737 | int shine_dalgarno_mm(unsigned char *seq, int pos, int start, double *rwt) {
738 | int i, j, k, mism, rdis, limit, max_val, cur_val = 0;
739 | double match[6], cur_ctr, dis_flag;
740 |
741 | limit = imin(6, start-4-pos);
742 | for(i = 0; i < 6; i++) match[i] = -10.0;
743 |
744 | /* Compare the 6-base region to AGGAGG */
745 | for(i = 0; i < limit; i++) {
746 | if(pos+i >= 0) {
747 | if(i % 3 == 0) {
748 | if(is_a(seq, pos+i) == 1) match[i] = 2.0;
749 | else match[i] = -3.0;
750 | }
751 | else {
752 | if(is_g(seq, pos+i) == 1) match[i] = 3.0;
753 | else match[i] = -2.0;
754 | }
755 | }
756 | }
757 |
758 | /* Find the maximally scoring motif */
759 | max_val = 0;
760 | for(i = limit; i >= 5; i--) {
761 | for(j = 0; j <= limit-i; j++) {
762 | cur_ctr = -2.0;
763 | mism = 0;
764 | for(k = j; k < j+i; k++) {
765 | cur_ctr += match[k];
766 | if(match[k] < 0.0) mism++;
767 | if(match[k] < 0.0 && (k <= j+1 || k >= j+i-2)) cur_ctr -= 10.0;
768 | }
769 | if(mism != 1) continue;
770 | rdis = start - (pos+j+i);
771 | if(rdis < 5) { dis_flag = 1; }
772 | else if(rdis > 10 && rdis <= 12) { dis_flag = 2; }
773 | else if(rdis >= 13) { dis_flag = 3; }
774 | else dis_flag = 0;
775 | if(rdis > 15 || cur_ctr < 6.0) continue;
776 |
777 | /* Single-Mismatch RBS Motifs */
778 | if(cur_ctr < 6.0) cur_val = 0;
779 | else if(cur_ctr == 6.0 && dis_flag == 3) cur_val = 2;
780 | else if(cur_ctr == 7.0 && dis_flag == 3) cur_val = 2;
781 | else if(cur_ctr == 9.0 && dis_flag == 3) cur_val = 3;
782 | else if(cur_ctr == 6.0 && dis_flag == 2) cur_val = 4;
783 | else if(cur_ctr == 6.0 && dis_flag == 1) cur_val = 5;
784 | else if(cur_ctr == 6.0 && dis_flag == 0) cur_val = 9;
785 | else if(cur_ctr == 7.0 && dis_flag == 2) cur_val = 7;
786 | else if(cur_ctr == 7.0 && dis_flag == 1) cur_val = 8;
787 | else if(cur_ctr == 7.0 && dis_flag == 0) cur_val = 14;
788 | else if(cur_ctr == 9.0 && dis_flag == 2) cur_val = 17;
789 | else if(cur_ctr == 9.0 && dis_flag == 1) cur_val = 18;
790 | else if(cur_ctr == 9.0 && dis_flag == 0) cur_val = 19;
791 |
792 | if(rwt[cur_val] < rwt[max_val]) continue;
793 | if(rwt[cur_val] == rwt[max_val] && cur_val < max_val) continue;
794 | max_val = cur_val;
795 | }
796 | }
797 |
798 | return max_val;
799 | }
800 |
801 | /* Returns the minimum of two numbers */
802 | int imin(int x, int y) {
803 | if(x < y) return x;
804 | return y;
805 | }
806 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | GNU GENERAL PUBLIC LICENSE
2 | Version 3, 29 June 2007
3 |
4 | Copyright (C) 2007 Free Software Foundation, Inc.
5 | Everyone is permitted to copy and distribute verbatim copies
6 | of this license document, but changing it is not allowed.
7 |
8 | Preamble
9 |
10 | The GNU General Public License is a free, copyleft license for
11 | software and other kinds of works.
12 |
13 | The licenses for most software and other practical works are designed
14 | to take away your freedom to share and change the works. By contrast,
15 | the GNU General Public License is intended to guarantee your freedom to
16 | share and change all versions of a program--to make sure it remains free
17 | software for all its users. We, the Free Software Foundation, use the
18 | GNU General Public License for most of our software; it applies also to
19 | any other work released this way by its authors. You can apply it to
20 | your programs, too.
21 |
22 | When we speak of free software, we are referring to freedom, not
23 | price. Our General Public Licenses are designed to make sure that you
24 | have the freedom to distribute copies of free software (and charge for
25 | them if you wish), that you receive source code or can get it if you
26 | want it, that you can change the software or use pieces of it in new
27 | free programs, and that you know you can do these things.
28 |
29 | To protect your rights, we need to prevent others from denying you
30 | these rights or asking you to surrender the rights. Therefore, you have
31 | certain responsibilities if you distribute copies of the software, or if
32 | you modify it: responsibilities to respect the freedom of others.
33 |
34 | For example, if you distribute copies of such a program, whether
35 | gratis or for a fee, you must pass on to the recipients the same
36 | freedoms that you received. You must make sure that they, too, receive
37 | or can get the source code. And you must show them these terms so they
38 | know their rights.
39 |
40 | Developers that use the GNU GPL protect your rights with two steps:
41 | (1) assert copyright on the software, and (2) offer you this License
42 | giving you legal permission to copy, distribute and/or modify it.
43 |
44 | For the developers' and authors' protection, the GPL clearly explains
45 | that there is no warranty for this free software. For both users' and
46 | authors' sake, the GPL requires that modified versions be marked as
47 | changed, so that their problems will not be attributed erroneously to
48 | authors of previous versions.
49 |
50 | Some devices are designed to deny users access to install or run
51 | modified versions of the software inside them, although the manufacturer
52 | can do so. This is fundamentally incompatible with the aim of
53 | protecting users' freedom to change the software. The systematic
54 | pattern of such abuse occurs in the area of products for individuals to
55 | use, which is precisely where it is most unacceptable. Therefore, we
56 | have designed this version of the GPL to prohibit the practice for those
57 | products. If such problems arise substantially in other domains, we
58 | stand ready to extend this provision to those domains in future versions
59 | of the GPL, as needed to protect the freedom of users.
60 |
61 | Finally, every program is threatened constantly by software patents.
62 | States should not allow patents to restrict development and use of
63 | software on general-purpose computers, but in those that do, we wish to
64 | avoid the special danger that patents applied to a free program could
65 | make it effectively proprietary. To prevent this, the GPL assures that
66 | patents cannot be used to render the program non-free.
67 |
68 | The precise terms and conditions for copying, distribution and
69 | modification follow.
70 |
71 | TERMS AND CONDITIONS
72 |
73 | 0. Definitions.
74 |
75 | "This License" refers to version 3 of the GNU General Public License.
76 |
77 | "Copyright" also means copyright-like laws that apply to other kinds of
78 | works, such as semiconductor masks.
79 |
80 | "The Program" refers to any copyrightable work licensed under this
81 | License. Each licensee is addressed as "you". "Licensees" and
82 | "recipients" may be individuals or organizations.
83 |
84 | To "modify" a work means to copy from or adapt all or part of the work
85 | in a fashion requiring copyright permission, other than the making of an
86 | exact copy. The resulting work is called a "modified version" of the
87 | earlier work or a work "based on" the earlier work.
88 |
89 | A "covered work" means either the unmodified Program or a work based
90 | on the Program.
91 |
92 | To "propagate" a work means to do anything with it that, without
93 | permission, would make you directly or secondarily liable for
94 | infringement under applicable copyright law, except executing it on a
95 | computer or modifying a private copy. Propagation includes copying,
96 | distribution (with or without modification), making available to the
97 | public, and in some countries other activities as well.
98 |
99 | To "convey" a work means any kind of propagation that enables other
100 | parties to make or receive copies. Mere interaction with a user through
101 | a computer network, with no transfer of a copy, is not conveying.
102 |
103 | An interactive user interface displays "Appropriate Legal Notices"
104 | to the extent that it includes a convenient and prominently visible
105 | feature that (1) displays an appropriate copyright notice, and (2)
106 | tells the user that there is no warranty for the work (except to the
107 | extent that warranties are provided), that licensees may convey the
108 | work under this License, and how to view a copy of this License. If
109 | the interface presents a list of user commands or options, such as a
110 | menu, a prominent item in the list meets this criterion.
111 |
112 | 1. Source Code.
113 |
114 | The "source code" for a work means the preferred form of the work
115 | for making modifications to it. "Object code" means any non-source
116 | form of a work.
117 |
118 | A "Standard Interface" means an interface that either is an official
119 | standard defined by a recognized standards body, or, in the case of
120 | interfaces specified for a particular programming language, one that
121 | is widely used among developers working in that language.
122 |
123 | The "System Libraries" of an executable work include anything, other
124 | than the work as a whole, that (a) is included in the normal form of
125 | packaging a Major Component, but which is not part of that Major
126 | Component, and (b) serves only to enable use of the work with that
127 | Major Component, or to implement a Standard Interface for which an
128 | implementation is available to the public in source code form. A
129 | "Major Component", in this context, means a major essential component
130 | (kernel, window system, and so on) of the specific operating system
131 | (if any) on which the executable work runs, or a compiler used to
132 | produce the work, or an object code interpreter used to run it.
133 |
134 | The "Corresponding Source" for a work in object code form means all
135 | the source code needed to generate, install, and (for an executable
136 | work) run the object code and to modify the work, including scripts to
137 | control those activities. However, it does not include the work's
138 | System Libraries, or general-purpose tools or generally available free
139 | programs which are used unmodified in performing those activities but
140 | which are not part of the work. For example, Corresponding Source
141 | includes interface definition files associated with source files for
142 | the work, and the source code for shared libraries and dynamically
143 | linked subprograms that the work is specifically designed to require,
144 | such as by intimate data communication or control flow between those
145 | subprograms and other parts of the work.
146 |
147 | The Corresponding Source need not include anything that users
148 | can regenerate automatically from other parts of the Corresponding
149 | Source.
150 |
151 | The Corresponding Source for a work in source code form is that
152 | same work.
153 |
154 | 2. Basic Permissions.
155 |
156 | All rights granted under this License are granted for the term of
157 | copyright on the Program, and are irrevocable provided the stated
158 | conditions are met. This License explicitly affirms your unlimited
159 | permission to run the unmodified Program. The output from running a
160 | covered work is covered by this License only if the output, given its
161 | content, constitutes a covered work. This License acknowledges your
162 | rights of fair use or other equivalent, as provided by copyright law.
163 |
164 | You may make, run and propagate covered works that you do not
165 | convey, without conditions so long as your license otherwise remains
166 | in force. You may convey covered works to others for the sole purpose
167 | of having them make modifications exclusively for you, or provide you
168 | with facilities for running those works, provided that you comply with
169 | the terms of this License in conveying all material for which you do
170 | not control copyright. Those thus making or running the covered works
171 | for you must do so exclusively on your behalf, under your direction
172 | and control, on terms that prohibit them from making any copies of
173 | your copyrighted material outside their relationship with you.
174 |
175 | Conveying under any other circumstances is permitted solely under
176 | the conditions stated below. Sublicensing is not allowed; section 10
177 | makes it unnecessary.
178 |
179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
180 |
181 | No covered work shall be deemed part of an effective technological
182 | measure under any applicable law fulfilling obligations under article
183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or
184 | similar laws prohibiting or restricting circumvention of such
185 | measures.
186 |
187 | When you convey a covered work, you waive any legal power to forbid
188 | circumvention of technological measures to the extent such circumvention
189 | is effected by exercising rights under this License with respect to
190 | the covered work, and you disclaim any intention to limit operation or
191 | modification of the work as a means of enforcing, against the work's
192 | users, your or third parties' legal rights to forbid circumvention of
193 | technological measures.
194 |
195 | 4. Conveying Verbatim Copies.
196 |
197 | You may convey verbatim copies of the Program's source code as you
198 | receive it, in any medium, provided that you conspicuously and
199 | appropriately publish on each copy an appropriate copyright notice;
200 | keep intact all notices stating that this License and any
201 | non-permissive terms added in accord with section 7 apply to the code;
202 | keep intact all notices of the absence of any warranty; and give all
203 | recipients a copy of this License along with the Program.
204 |
205 | You may charge any price or no price for each copy that you convey,
206 | and you may offer support or warranty protection for a fee.
207 |
208 | 5. Conveying Modified Source Versions.
209 |
210 | You may convey a work based on the Program, or the modifications to
211 | produce it from the Program, in the form of source code under the
212 | terms of section 4, provided that you also meet all of these conditions:
213 |
214 | a) The work must carry prominent notices stating that you modified
215 | it, and giving a relevant date.
216 |
217 | b) The work must carry prominent notices stating that it is
218 | released under this License and any conditions added under section
219 | 7. This requirement modifies the requirement in section 4 to
220 | "keep intact all notices".
221 |
222 | c) You must license the entire work, as a whole, under this
223 | License to anyone who comes into possession of a copy. This
224 | License will therefore apply, along with any applicable section 7
225 | additional terms, to the whole of the work, and all its parts,
226 | regardless of how they are packaged. This License gives no
227 | permission to license the work in any other way, but it does not
228 | invalidate such permission if you have separately received it.
229 |
230 | d) If the work has interactive user interfaces, each must display
231 | Appropriate Legal Notices; however, if the Program has interactive
232 | interfaces that do not display Appropriate Legal Notices, your
233 | work need not make them do so.
234 |
235 | A compilation of a covered work with other separate and independent
236 | works, which are not by their nature extensions of the covered work,
237 | and which are not combined with it such as to form a larger program,
238 | in or on a volume of a storage or distribution medium, is called an
239 | "aggregate" if the compilation and its resulting copyright are not
240 | used to limit the access or legal rights of the compilation's users
241 | beyond what the individual works permit. Inclusion of a covered work
242 | in an aggregate does not cause this License to apply to the other
243 | parts of the aggregate.
244 |
245 | 6. Conveying Non-Source Forms.
246 |
247 | You may convey a covered work in object code form under the terms
248 | of sections 4 and 5, provided that you also convey the
249 | machine-readable Corresponding Source under the terms of this License,
250 | in one of these ways:
251 |
252 | a) Convey the object code in, or embodied in, a physical product
253 | (including a physical distribution medium), accompanied by the
254 | Corresponding Source fixed on a durable physical medium
255 | customarily used for software interchange.
256 |
257 | b) Convey the object code in, or embodied in, a physical product
258 | (including a physical distribution medium), accompanied by a
259 | written offer, valid for at least three years and valid for as
260 | long as you offer spare parts or customer support for that product
261 | model, to give anyone who possesses the object code either (1) a
262 | copy of the Corresponding Source for all the software in the
263 | product that is covered by this License, on a durable physical
264 | medium customarily used for software interchange, for a price no
265 | more than your reasonable cost of physically performing this
266 | conveying of source, or (2) access to copy the
267 | Corresponding Source from a network server at no charge.
268 |
269 | c) Convey individual copies of the object code with a copy of the
270 | written offer to provide the Corresponding Source. This
271 | alternative is allowed only occasionally and noncommercially, and
272 | only if you received the object code with such an offer, in accord
273 | with subsection 6b.
274 |
275 | d) Convey the object code by offering access from a designated
276 | place (gratis or for a charge), and offer equivalent access to the
277 | Corresponding Source in the same way through the same place at no
278 | further charge. You need not require recipients to copy the
279 | Corresponding Source along with the object code. If the place to
280 | copy the object code is a network server, the Corresponding Source
281 | may be on a different server (operated by you or a third party)
282 | that supports equivalent copying facilities, provided you maintain
283 | clear directions next to the object code saying where to find the
284 | Corresponding Source. Regardless of what server hosts the
285 | Corresponding Source, you remain obligated to ensure that it is
286 | available for as long as needed to satisfy these requirements.
287 |
288 | e) Convey the object code using peer-to-peer transmission, provided
289 | you inform other peers where the object code and Corresponding
290 | Source of the work are being offered to the general public at no
291 | charge under subsection 6d.
292 |
293 | A separable portion of the object code, whose source code is excluded
294 | from the Corresponding Source as a System Library, need not be
295 | included in conveying the object code work.
296 |
297 | A "User Product" is either (1) a "consumer product", which means any
298 | tangible personal property which is normally used for personal, family,
299 | or household purposes, or (2) anything designed or sold for incorporation
300 | into a dwelling. In determining whether a product is a consumer product,
301 | doubtful cases shall be resolved in favor of coverage. For a particular
302 | product received by a particular user, "normally used" refers to a
303 | typical or common use of that class of product, regardless of the status
304 | of the particular user or of the way in which the particular user
305 | actually uses, or expects or is expected to use, the product. A product
306 | is a consumer product regardless of whether the product has substantial
307 | commercial, industrial or non-consumer uses, unless such uses represent
308 | the only significant mode of use of the product.
309 |
310 | "Installation Information" for a User Product means any methods,
311 | procedures, authorization keys, or other information required to install
312 | and execute modified versions of a covered work in that User Product from
313 | a modified version of its Corresponding Source. The information must
314 | suffice to ensure that the continued functioning of the modified object
315 | code is in no case prevented or interfered with solely because
316 | modification has been made.
317 |
318 | If you convey an object code work under this section in, or with, or
319 | specifically for use in, a User Product, and the conveying occurs as
320 | part of a transaction in which the right of possession and use of the
321 | User Product is transferred to the recipient in perpetuity or for a
322 | fixed term (regardless of how the transaction is characterized), the
323 | Corresponding Source conveyed under this section must be accompanied
324 | by the Installation Information. But this requirement does not apply
325 | if neither you nor any third party retains the ability to install
326 | modified object code on the User Product (for example, the work has
327 | been installed in ROM).
328 |
329 | The requirement to provide Installation Information does not include a
330 | requirement to continue to provide support service, warranty, or updates
331 | for a work that has been modified or installed by the recipient, or for
332 | the User Product in which it has been modified or installed. Access to a
333 | network may be denied when the modification itself materially and
334 | adversely affects the operation of the network or violates the rules and
335 | protocols for communication across the network.
336 |
337 | Corresponding Source conveyed, and Installation Information provided,
338 | in accord with this section must be in a format that is publicly
339 | documented (and with an implementation available to the public in
340 | source code form), and must require no special password or key for
341 | unpacking, reading or copying.
342 |
343 | 7. Additional Terms.
344 |
345 | "Additional permissions" are terms that supplement the terms of this
346 | License by making exceptions from one or more of its conditions.
347 | Additional permissions that are applicable to the entire Program shall
348 | be treated as though they were included in this License, to the extent
349 | that they are valid under applicable law. If additional permissions
350 | apply only to part of the Program, that part may be used separately
351 | under those permissions, but the entire Program remains governed by
352 | this License without regard to the additional permissions.
353 |
354 | When you convey a copy of a covered work, you may at your option
355 | remove any additional permissions from that copy, or from any part of
356 | it. (Additional permissions may be written to require their own
357 | removal in certain cases when you modify the work.) You may place
358 | additional permissions on material, added by you to a covered work,
359 | for which you have or can give appropriate copyright permission.
360 |
361 | Notwithstanding any other provision of this License, for material you
362 | add to a covered work, you may (if authorized by the copyright holders of
363 | that material) supplement the terms of this License with terms:
364 |
365 | a) Disclaiming warranty or limiting liability differently from the
366 | terms of sections 15 and 16 of this License; or
367 |
368 | b) Requiring preservation of specified reasonable legal notices or
369 | author attributions in that material or in the Appropriate Legal
370 | Notices displayed by works containing it; or
371 |
372 | c) Prohibiting misrepresentation of the origin of that material, or
373 | requiring that modified versions of such material be marked in
374 | reasonable ways as different from the original version; or
375 |
376 | d) Limiting the use for publicity purposes of names of licensors or
377 | authors of the material; or
378 |
379 | e) Declining to grant rights under trademark law for use of some
380 | trade names, trademarks, or service marks; or
381 |
382 | f) Requiring indemnification of licensors and authors of that
383 | material by anyone who conveys the material (or modified versions of
384 | it) with contractual assumptions of liability to the recipient, for
385 | any liability that these contractual assumptions directly impose on
386 | those licensors and authors.
387 |
388 | All other non-permissive additional terms are considered "further
389 | restrictions" within the meaning of section 10. If the Program as you
390 | received it, or any part of it, contains a notice stating that it is
391 | governed by this License along with a term that is a further
392 | restriction, you may remove that term. If a license document contains
393 | a further restriction but permits relicensing or conveying under this
394 | License, you may add to a covered work material governed by the terms
395 | of that license document, provided that the further restriction does
396 | not survive such relicensing or conveying.
397 |
398 | If you add terms to a covered work in accord with this section, you
399 | must place, in the relevant source files, a statement of the
400 | additional terms that apply to those files, or a notice indicating
401 | where to find the applicable terms.
402 |
403 | Additional terms, permissive or non-permissive, may be stated in the
404 | form of a separately written license, or stated as exceptions;
405 | the above requirements apply either way.
406 |
407 | 8. Termination.
408 |
409 | You may not propagate or modify a covered work except as expressly
410 | provided under this License. Any attempt otherwise to propagate or
411 | modify it is void, and will automatically terminate your rights under
412 | this License (including any patent licenses granted under the third
413 | paragraph of section 11).
414 |
415 | However, if you cease all violation of this License, then your
416 | license from a particular copyright holder is reinstated (a)
417 | provisionally, unless and until the copyright holder explicitly and
418 | finally terminates your license, and (b) permanently, if the copyright
419 | holder fails to notify you of the violation by some reasonable means
420 | prior to 60 days after the cessation.
421 |
422 | Moreover, your license from a particular copyright holder is
423 | reinstated permanently if the copyright holder notifies you of the
424 | violation by some reasonable means, this is the first time you have
425 | received notice of violation of this License (for any work) from that
426 | copyright holder, and you cure the violation prior to 30 days after
427 | your receipt of the notice.
428 |
429 | Termination of your rights under this section does not terminate the
430 | licenses of parties who have received copies or rights from you under
431 | this License. If your rights have been terminated and not permanently
432 | reinstated, you do not qualify to receive new licenses for the same
433 | material under section 10.
434 |
435 | 9. Acceptance Not Required for Having Copies.
436 |
437 | You are not required to accept this License in order to receive or
438 | run a copy of the Program. Ancillary propagation of a covered work
439 | occurring solely as a consequence of using peer-to-peer transmission
440 | to receive a copy likewise does not require acceptance. However,
441 | nothing other than this License grants you permission to propagate or
442 | modify any covered work. These actions infringe copyright if you do
443 | not accept this License. Therefore, by modifying or propagating a
444 | covered work, you indicate your acceptance of this License to do so.
445 |
446 | 10. Automatic Licensing of Downstream Recipients.
447 |
448 | Each time you convey a covered work, the recipient automatically
449 | receives a license from the original licensors, to run, modify and
450 | propagate that work, subject to this License. You are not responsible
451 | for enforcing compliance by third parties with this License.
452 |
453 | An "entity transaction" is a transaction transferring control of an
454 | organization, or substantially all assets of one, or subdividing an
455 | organization, or merging organizations. If propagation of a covered
456 | work results from an entity transaction, each party to that
457 | transaction who receives a copy of the work also receives whatever
458 | licenses to the work the party's predecessor in interest had or could
459 | give under the previous paragraph, plus a right to possession of the
460 | Corresponding Source of the work from the predecessor in interest, if
461 | the predecessor has it or can get it with reasonable efforts.
462 |
463 | You may not impose any further restrictions on the exercise of the
464 | rights granted or affirmed under this License. For example, you may
465 | not impose a license fee, royalty, or other charge for exercise of
466 | rights granted under this License, and you may not initiate litigation
467 | (including a cross-claim or counterclaim in a lawsuit) alleging that
468 | any patent claim is infringed by making, using, selling, offering for
469 | sale, or importing the Program or any portion of it.
470 |
471 | 11. Patents.
472 |
473 | A "contributor" is a copyright holder who authorizes use under this
474 | License of the Program or a work on which the Program is based. The
475 | work thus licensed is called the contributor's "contributor version".
476 |
477 | A contributor's "essential patent claims" are all patent claims
478 | owned or controlled by the contributor, whether already acquired or
479 | hereafter acquired, that would be infringed by some manner, permitted
480 | by this License, of making, using, or selling its contributor version,
481 | but do not include claims that would be infringed only as a
482 | consequence of further modification of the contributor version. For
483 | purposes of this definition, "control" includes the right to grant
484 | patent sublicenses in a manner consistent with the requirements of
485 | this License.
486 |
487 | Each contributor grants you a non-exclusive, worldwide, royalty-free
488 | patent license under the contributor's essential patent claims, to
489 | make, use, sell, offer for sale, import and otherwise run, modify and
490 | propagate the contents of its contributor version.
491 |
492 | In the following three paragraphs, a "patent license" is any express
493 | agreement or commitment, however denominated, not to enforce a patent
494 | (such as an express permission to practice a patent or covenant not to
495 | sue for patent infringement). To "grant" such a patent license to a
496 | party means to make such an agreement or commitment not to enforce a
497 | patent against the party.
498 |
499 | If you convey a covered work, knowingly relying on a patent license,
500 | and the Corresponding Source of the work is not available for anyone
501 | to copy, free of charge and under the terms of this License, through a
502 | publicly available network server or other readily accessible means,
503 | then you must either (1) cause the Corresponding Source to be so
504 | available, or (2) arrange to deprive yourself of the benefit of the
505 | patent license for this particular work, or (3) arrange, in a manner
506 | consistent with the requirements of this License, to extend the patent
507 | license to downstream recipients. "Knowingly relying" means you have
508 | actual knowledge that, but for the patent license, your conveying the
509 | covered work in a country, or your recipient's use of the covered work
510 | in a country, would infringe one or more identifiable patents in that
511 | country that you have reason to believe are valid.
512 |
513 | If, pursuant to or in connection with a single transaction or
514 | arrangement, you convey, or propagate by procuring conveyance of, a
515 | covered work, and grant a patent license to some of the parties
516 | receiving the covered work authorizing them to use, propagate, modify
517 | or convey a specific copy of the covered work, then the patent license
518 | you grant is automatically extended to all recipients of the covered
519 | work and works based on it.
520 |
521 | A patent license is "discriminatory" if it does not include within
522 | the scope of its coverage, prohibits the exercise of, or is
523 | conditioned on the non-exercise of one or more of the rights that are
524 | specifically granted under this License. You may not convey a covered
525 | work if you are a party to an arrangement with a third party that is
526 | in the business of distributing software, under which you make payment
527 | to the third party based on the extent of your activity of conveying
528 | the work, and under which the third party grants, to any of the
529 | parties who would receive the covered work from you, a discriminatory
530 | patent license (a) in connection with copies of the covered work
531 | conveyed by you (or copies made from those copies), or (b) primarily
532 | for and in connection with specific products or compilations that
533 | contain the covered work, unless you entered into that arrangement,
534 | or that patent license was granted, prior to 28 March 2007.
535 |
536 | Nothing in this License shall be construed as excluding or limiting
537 | any implied license or other defenses to infringement that may
538 | otherwise be available to you under applicable patent law.
539 |
540 | 12. No Surrender of Others' Freedom.
541 |
542 | If conditions are imposed on you (whether by court order, agreement or
543 | otherwise) that contradict the conditions of this License, they do not
544 | excuse you from the conditions of this License. If you cannot convey a
545 | covered work so as to satisfy simultaneously your obligations under this
546 | License and any other pertinent obligations, then as a consequence you may
547 | not convey it at all. For example, if you agree to terms that obligate you
548 | to collect a royalty for further conveying from those to whom you convey
549 | the Program, the only way you could satisfy both those terms and this
550 | License would be to refrain entirely from conveying the Program.
551 |
552 | 13. Use with the GNU Affero General Public License.
553 |
554 | Notwithstanding any other provision of this License, you have
555 | permission to link or combine any covered work with a work licensed
556 | under version 3 of the GNU Affero General Public License into a single
557 | combined work, and to convey the resulting work. The terms of this
558 | License will continue to apply to the part which is the covered work,
559 | but the special requirements of the GNU Affero General Public License,
560 | section 13, concerning interaction through a network will apply to the
561 | combination as such.
562 |
563 | 14. Revised Versions of this License.
564 |
565 | The Free Software Foundation may publish revised and/or new versions of
566 | the GNU General Public License from time to time. Such new versions will
567 | be similar in spirit to the present version, but may differ in detail to
568 | address new problems or concerns.
569 |
570 | Each version is given a distinguishing version number. If the
571 | Program specifies that a certain numbered version of the GNU General
572 | Public License "or any later version" applies to it, you have the
573 | option of following the terms and conditions either of that numbered
574 | version or of any later version published by the Free Software
575 | Foundation. If the Program does not specify a version number of the
576 | GNU General Public License, you may choose any version ever published
577 | by the Free Software Foundation.
578 |
579 | If the Program specifies that a proxy can decide which future
580 | versions of the GNU General Public License can be used, that proxy's
581 | public statement of acceptance of a version permanently authorizes you
582 | to choose that version for the Program.
583 |
584 | Later license versions may give you additional or different
585 | permissions. However, no additional obligations are imposed on any
586 | author or copyright holder as a result of your choosing to follow a
587 | later version.
588 |
589 | 15. Disclaimer of Warranty.
590 |
591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
599 |
600 | 16. Limitation of Liability.
601 |
602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
610 | SUCH DAMAGES.
611 |
612 | 17. Interpretation of Sections 15 and 16.
613 |
614 | If the disclaimer of warranty and limitation of liability provided
615 | above cannot be given local legal effect according to their terms,
616 | reviewing courts shall apply local law that most closely approximates
617 | an absolute waiver of all civil liability in connection with the
618 | Program, unless a warranty or assumption of liability accompanies a
619 | copy of the Program in return for a fee.
620 |
621 | END OF TERMS AND CONDITIONS
622 |
623 | How to Apply These Terms to Your New Programs
624 |
625 | If you develop a new program, and you want it to be of the greatest
626 | possible use to the public, the best way to achieve this is to make it
627 | free software which everyone can redistribute and change under these terms.
628 |
629 | To do so, attach the following notices to the program. It is safest
630 | to attach them to the start of each source file to most effectively
631 | state the exclusion of warranty; and each file should have at least
632 | the "copyright" line and a pointer to where the full notice is found.
633 |
634 |
635 | Copyright (C)
636 |
637 | This program is free software: you can redistribute it and/or modify
638 | it under the terms of the GNU General Public License as published by
639 | the Free Software Foundation, either version 3 of the License, or
640 | (at your option) any later version.
641 |
642 | This program is distributed in the hope that it will be useful,
643 | but WITHOUT ANY WARRANTY; without even the implied warranty of
644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
645 | GNU General Public License for more details.
646 |
647 | You should have received a copy of the GNU General Public License
648 | along with this program. If not, see .
649 |
650 | Also add information on how to contact you by electronic and paper mail.
651 |
652 | If the program does terminal interaction, make it output a short
653 | notice like this when it starts in an interactive mode:
654 |
655 | Copyright (C)
656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
657 | This is free software, and you are welcome to redistribute it
658 | under certain conditions; type `show c' for details.
659 |
660 | The hypothetical commands `show w' and `show c' should show the appropriate
661 | parts of the General Public License. Of course, your program's commands
662 | might be different; for a GUI interface, you would use an "about box".
663 |
664 | You should also get your employer (if you work as a programmer) or school,
665 | if any, to sign a "copyright disclaimer" for the program, if necessary.
666 | For more information on this, and how to apply and follow the GNU GPL, see
667 | .
668 |
669 | The GNU General Public License does not permit incorporating your program
670 | into proprietary programs. If your program is a subroutine library, you
671 | may consider it more useful to permit linking proprietary applications with
672 | the library. If this is what you want to do, use the GNU Lesser General
673 | Public License instead of this License. But first, please read
674 | .
675 |
--------------------------------------------------------------------------------