| 1 | /*#include "/us1/user/julie/dmalloc/malloc.h"*/ |
|---|
| 2 | /*********************CLUSTALW.H*********************************************/ |
|---|
| 3 | /****************************************************************************/ |
|---|
| 4 | |
|---|
| 5 | /* |
|---|
| 6 | Main header file for ClustalW. Uncomment ONE of the following 4 lines |
|---|
| 7 | depending on which compiler you wish to use. |
|---|
| 8 | */ |
|---|
| 9 | |
|---|
| 10 | /*#define VMS 1 VAX or ALPHA VMS */ |
|---|
| 11 | |
|---|
| 12 | /*#define MAC 1 Think_C for Macintosh */ |
|---|
| 13 | |
|---|
| 14 | /*#define MSDOS 1 Turbo C for PC's */ |
|---|
| 15 | |
|---|
| 16 | #define UNIX 1 /*Ultrix/Decstation, Gnu C for |
|---|
| 17 | Sun, IRIX/SGI, OSF1/ALPHA */ |
|---|
| 18 | |
|---|
| 19 | /***************************************************************************/ |
|---|
| 20 | /***************************************************************************/ |
|---|
| 21 | |
|---|
| 22 | |
|---|
| 23 | #include "general.h" |
|---|
| 24 | |
|---|
| 25 | #define MAXNAMES 30 /* Max chars read for seq. names */ |
|---|
| 26 | #define MAXTITLES 60 /* Title length */ |
|---|
| 27 | #define FILENAMELEN 256 /* Max. file name length */ |
|---|
| 28 | |
|---|
| 29 | #define UNKNOWN 0 |
|---|
| 30 | #define EMBLSWISS 1 |
|---|
| 31 | #define PIR 2 |
|---|
| 32 | #define PEARSON 3 |
|---|
| 33 | #define GDE 4 |
|---|
| 34 | #define CLUSTAL 5 /* DES */ |
|---|
| 35 | #define MSF 6 /* DES */ |
|---|
| 36 | #define RSF 7 /* JULIE */ |
|---|
| 37 | #define USER 8 /* DES */ |
|---|
| 38 | #define PHYLIP 9 /* DES */ |
|---|
| 39 | #define NEXUS 10/* DES */ |
|---|
| 40 | #define FASTA 11/* Ramu */ |
|---|
| 41 | |
|---|
| 42 | #define NONE 0 |
|---|
| 43 | #define SECST 1 |
|---|
| 44 | #define GMASK 2 |
|---|
| 45 | |
|---|
| 46 | #define PROFILE 0 |
|---|
| 47 | #define SEQUENCE 1 |
|---|
| 48 | |
|---|
| 49 | #define BS_NODE_LABELS 2 |
|---|
| 50 | #define BS_BRANCH_LABELS 1 |
|---|
| 51 | |
|---|
| 52 | #define PAGE_LEN 22 /* Number of lines of help sent to screen */ |
|---|
| 53 | |
|---|
| 54 | #define PAGEWIDTH 80 /* maximum characters on output file page */ |
|---|
| 55 | #define LINELENGTH 60 /* Output file line length */ |
|---|
| 56 | #define GCG_LINELENGTH 50 |
|---|
| 57 | |
|---|
| 58 | #ifdef VMS /* Defaults for VAX VMS */ |
|---|
| 59 | #define COMMANDSEP '/' |
|---|
| 60 | #define DIRDELIM ']' /* Last character before file name in full file |
|---|
| 61 | specs */ |
|---|
| 62 | #define INT_SCALE_FACTOR 1000 /* Scaling factor to convert float to integer for profile scores */ |
|---|
| 63 | |
|---|
| 64 | #elif MAC |
|---|
| 65 | #define COMMANDSEP '/' |
|---|
| 66 | #define DIRDELIM ':' |
|---|
| 67 | #define INT_SCALE_FACTOR 100 /* Scaling factor to convert float to integer for profile scores */ |
|---|
| 68 | |
|---|
| 69 | #elif MSDOS |
|---|
| 70 | #define COMMANDSEP '/' |
|---|
| 71 | #define DIRDELIM '\\' |
|---|
| 72 | #define INT_SCALE_FACTOR 100 /* Scaling factor to convert float to integer for profile scores */ |
|---|
| 73 | |
|---|
| 74 | #elif UNIX |
|---|
| 75 | #define COMMANDSEP '-' |
|---|
| 76 | #define DIRDELIM '/' |
|---|
| 77 | #define INT_SCALE_FACTOR 1000 /* Scaling factor to convert float to integer for profile scores */ |
|---|
| 78 | #endif |
|---|
| 79 | |
|---|
| 80 | #define NUMRES 32 /* max size of comparison matrix */ |
|---|
| 81 | |
|---|
| 82 | #define INPUT 0 |
|---|
| 83 | #define ALIGNED 1 |
|---|
| 84 | |
|---|
| 85 | #define LEFT 1 |
|---|
| 86 | #define RIGHT 2 |
|---|
| 87 | |
|---|
| 88 | #define NODE 0 |
|---|
| 89 | #define LEAF 1 |
|---|
| 90 | |
|---|
| 91 | #define GAPCOL 32 /* position of gap open penalty in profile */ |
|---|
| 92 | #define LENCOL 33 /* position of gap extension penalty in profile */ |
|---|
| 93 | |
|---|
| 94 | typedef struct node { /* phylogenetic tree structure */ |
|---|
| 95 | struct node *left; |
|---|
| 96 | struct node *right; |
|---|
| 97 | struct node *parent; |
|---|
| 98 | float dist; |
|---|
| 99 | sint leaf; |
|---|
| 100 | int order; |
|---|
| 101 | char name[64]; |
|---|
| 102 | } stree, *treeptr; |
|---|
| 103 | |
|---|
| 104 | typedef struct { |
|---|
| 105 | char title[30]; |
|---|
| 106 | char string[30]; |
|---|
| 107 | } MatMenuEntry; |
|---|
| 108 | |
|---|
| 109 | typedef struct { |
|---|
| 110 | int noptions; |
|---|
| 111 | MatMenuEntry opt[10]; |
|---|
| 112 | } MatMenu; |
|---|
| 113 | |
|---|
| 114 | #define MAXMAT 10 |
|---|
| 115 | |
|---|
| 116 | typedef struct { |
|---|
| 117 | int llimit; |
|---|
| 118 | int ulimit; |
|---|
| 119 | short *matptr; |
|---|
| 120 | short *aa_xref; |
|---|
| 121 | } SeriesMat; |
|---|
| 122 | |
|---|
| 123 | typedef struct { |
|---|
| 124 | int nmat; |
|---|
| 125 | SeriesMat mat[MAXMAT]; |
|---|
| 126 | } UserMatSeries; |
|---|
| 127 | |
|---|
| 128 | |
|---|
| 129 | /* |
|---|
| 130 | Prototypes |
|---|
| 131 | */ |
|---|
| 132 | |
|---|
| 133 | /* alnscore.c */ |
|---|
| 134 | void aln_score(void); |
|---|
| 135 | /* interface.c */ |
|---|
| 136 | void parse_params(Boolean); |
|---|
| 137 | void init_amenu(void); |
|---|
| 138 | void init_interface(void); |
|---|
| 139 | void main_menu(void); |
|---|
| 140 | FILE *open_output_file(const char *, const char *, char *, const char *); |
|---|
| 141 | FILE *open_explicit_file(const char *); |
|---|
| 142 | sint seq_input(Boolean); |
|---|
| 143 | Boolean open_alignment_output(char *); |
|---|
| 144 | void create_alignment_output(sint fseq,sint lseq); |
|---|
| 145 | void align(char *phylip_name); |
|---|
| 146 | void profile_align(char *p1_tree_name,char *p2_tree_name);/* Align 2 alignments */ |
|---|
| 147 | void make_tree(char *phylip_name); |
|---|
| 148 | void get_tree(char *phylip_name); |
|---|
| 149 | sint profile_input(void); /* read a profile */ |
|---|
| 150 | void new_sequence_align(char *phylip_name); |
|---|
| 151 | Boolean user_mat(char *, short *, short *); |
|---|
| 152 | Boolean user_mat_series(char *, short *, short *); |
|---|
| 153 | void get_help(char); |
|---|
| 154 | void clustal_out(FILE *, sint, sint, sint, sint); |
|---|
| 155 | void nbrf_out(FILE *, sint, sint, sint, sint); |
|---|
| 156 | void gcg_out(FILE *, sint, sint, sint, sint); |
|---|
| 157 | void phylip_out(FILE *, sint, sint, sint, sint); |
|---|
| 158 | void gde_out(FILE *, sint, sint, sint, sint); |
|---|
| 159 | void nexus_out(FILE *, sint, sint, sint, sint); |
|---|
| 160 | void fasta_out(FILE *, sint, sint, sint, sint); |
|---|
| 161 | void print_sec_struct_mask(int prf_length,char *mask,char *struct_mask); |
|---|
| 162 | void fix_gaps(void); |
|---|
| 163 | |
|---|
| 164 | |
|---|
| 165 | /* calcgapcoeff.c */ |
|---|
| 166 | void calc_gap_coeff(char **alignment, sint *gaps, sint **profile, Boolean struct_penalties, |
|---|
| 167 | char *gap_penalty_mask, sint first_seq, sint last_seq, |
|---|
| 168 | sint prf_length, sint gapcoef, sint lencoef); |
|---|
| 169 | /* calcprf1.c */ |
|---|
| 170 | void calc_prf1(sint **profile, char **alignment, sint *gaps, sint matrix[NUMRES ][NUMRES ], |
|---|
| 171 | sint *seq_weight, sint prf_length, sint first_seq, sint last_seq); |
|---|
| 172 | /* calcprf2.c */ |
|---|
| 173 | void calc_prf2(sint **profile, char **alignment, sint *seq_weight, sint prf_length, |
|---|
| 174 | sint first_seq, sint last_seq); |
|---|
| 175 | /* calctree.c */ |
|---|
| 176 | void calc_seq_weights(sint first_seq, sint last_seq,sint *seq_weight); |
|---|
| 177 | void create_sets(sint first_seq, sint last_seq); |
|---|
| 178 | sint read_tree(char *treefile, sint first_seq, sint last_seq); |
|---|
| 179 | void clear_tree(treeptr p); |
|---|
| 180 | sint calc_similarities(sint nseqs); |
|---|
| 181 | /* clustalw.c */ |
|---|
| 182 | int main(int argc, char **argv); |
|---|
| 183 | /* gcgcheck.c */ |
|---|
| 184 | int SeqGCGCheckSum(char *seq, sint len); |
|---|
| 185 | /* malign.c */ |
|---|
| 186 | sint malign(sint istart,char *phylip_name); |
|---|
| 187 | sint seqalign(sint istart,char *phylip_name); |
|---|
| 188 | sint palign1(void); |
|---|
| 189 | float countid(sint s1, sint s2); |
|---|
| 190 | sint palign2(char *p1_tree_name,char *p2_tree_name); |
|---|
| 191 | /* pairalign.c */ |
|---|
| 192 | sint pairalign(sint istart, sint iend, sint jstart, sint jend); |
|---|
| 193 | /* prfalign.c */ |
|---|
| 194 | lint prfalign(sint *group, sint *aligned); |
|---|
| 195 | /* random.c */ |
|---|
| 196 | unsigned long linrand(unsigned long r); |
|---|
| 197 | unsigned long addrand(unsigned long r); |
|---|
| 198 | void addrandinit(unsigned long s); |
|---|
| 199 | /* readmat.c */ |
|---|
| 200 | void init_matrix(void); |
|---|
| 201 | sint get_matrix(short *matptr, short *xref, sint matrix[NUMRES ][NUMRES ], Boolean neg_flag, |
|---|
| 202 | sint scale); |
|---|
| 203 | sint read_user_matrix(char *filename, short *usermat, short *xref); |
|---|
| 204 | sint read_matrix_series(char *filename, short *usermat, short *xref); |
|---|
| 205 | int getargs(char *inline1, char *args[], int max); |
|---|
| 206 | /* sequence.c */ |
|---|
| 207 | void fill_chartab(void); |
|---|
| 208 | sint readseqs(sint first_seq); |
|---|
| 209 | /* showpair.c */ |
|---|
| 210 | void show_pair(sint istart, sint iend, sint jstart, sint jend); |
|---|
| 211 | /* trees.c */ |
|---|
| 212 | void phylogenetic_tree(char *phylip_name,char *clustal_name,char *dist_name, char *nexus_name, char *pim_name); |
|---|
| 213 | void bootstrap_tree(char *phylip_name,char *clustal_name, char *nexus_name); |
|---|
| 214 | sint dna_distance_matrix(FILE *tree); |
|---|
| 215 | sint prot_distance_matrix(FILE *tree); |
|---|
| 216 | void guide_tree(FILE *tree,int first_seq,sint nseqs); |
|---|
| 217 | |
|---|
| 218 | void calc_percidentity(FILE *pfile); |
|---|
| 219 | |
|---|
| 220 | /* util.c */ |
|---|
| 221 | |
|---|
| 222 | void alloc_aln(sint nseqs); |
|---|
| 223 | void realloc_aln(sint first_seq,sint nseqs); |
|---|
| 224 | void free_aln(sint nseqs); |
|---|
| 225 | void alloc_seq(sint seq_no,sint length); |
|---|
| 226 | void realloc_seq(sint seq_no,sint length); |
|---|
| 227 | void free_seq(sint seq_no); |
|---|
| 228 | |
|---|
| 229 | void *ckalloc(size_t bytes); |
|---|
| 230 | void *ckrealloc(void *ptr, size_t bytes); |
|---|
| 231 | void *ckfree(void *ptr); |
|---|
| 232 | char prompt_for_yes_no(const char *title,const char *prompt); |
|---|
| 233 | void fatal(const char *msg, ...); |
|---|
| 234 | void error(const char *msg, ...); |
|---|
| 235 | void warning(const char *msg, ...); |
|---|
| 236 | void info(const char *msg, ...); |
|---|
| 237 | char *rtrim(char *str); |
|---|
| 238 | char *blank_to_(char *str); |
|---|
| 239 | char *upstr(char *str); |
|---|
| 240 | char *lowstr(char *str); |
|---|
| 241 | void getstr(const char *instr, char *outstr, int outstrSize); |
|---|
| 242 | double getreal(const char *instr, double minx, double maxx, double def); |
|---|
| 243 | int getint(const char *instr, int minx, int maxx, int def); |
|---|
| 244 | void do_system(void); |
|---|
| 245 | Boolean linetype(const char *line, const char *code); |
|---|
| 246 | Boolean keyword(const char *line, const char *code); |
|---|
| 247 | Boolean blankline(char *line); |
|---|
| 248 | void get_path(char *str, char *path); |
|---|
| 249 | |
|---|
| 250 | |
|---|