1 /****************************************************************************
3 ALSCRIPT - Sequence alignment to PostScript
5 Copyright: Geoffrey J. Barton (1992,1993,1997)
8 Please see the file README for limitations on the use of this program.
10 All use of this program must cite: Barton, G. J. (1993), ALSCRIPT: A Tool to
11 Format Multiple Sequence Alignments, Protein Engineering, Volume 6, No. 1,
14 $Id: alscript.c,v 1.2 1998/09/17 16:54:59 geoff Exp $
16 Revision 1.2 1998/09/17 16:54:59 geoff
17 Check consistency with archive
20 ****************************************************************************
22 ALSCRIPT is a program for producing pretty versions of multiple sequence aligments.
23 ALSCRIPT will also format single sequences.
24 A full description of the program is given in the file "alscript.doc".
26 Ways of running alscript:
28 1. Interactive mode: just type alscript.
29 You will be prompted for a command file name. The command file will
30 define the AMPS blocfile, and name of the file to store the PostScript
31 output - see alscript.doc for details.
33 2. alscript <command_file> has same effect as 1, But does not prompt for the command file
34 e.g. alscript example1.com
36 3. alscript -q < <blocfile> > <PostScript>
37 Quick mode - uses default commands, reads alignment from stdin, writes PostScript
39 e.g. alscript -q < example1.blc > example1.ps
41 4. alscript -f <command_file>
44 5. alscript -f <command_file> -s
45 Silent operation: No messages are written to stderr, unless fatal.
46 Silent operation may be toggled by the silent_mode command in the command file.
48 6. alscript -f <command_file> -p < <blocfile> > <PostScript>
49 Make alscript work like a pipe - blocfile is read from stdin, postscript is written
50 to stdout. Messages are written to stderr. To supress messages include
52 e.g. alscript -f example1.com -p -s < example1.blc > example1.ps
54 Using alscript as a pipe has the advantage of allowing the blocfile to
55 be created on the fly by the programs msf2blc or clus2blc. For example
56 if we have a GCG .msf file called "pileup.msf" we can run alscript with
57 default shading/fonts and send the results straight to the PostScript
58 printer "lpr" as follows:
60 msf2blc -q < pileup.msf | alscript -q -s | lpr
62 See alps.c for revision history;
63 fprintf(std_err,"\n Version 2.0 - 23 May 1995\n");
81 void ALwritestddefs(FILE *);
82 int alps(char *command_file,int silent, int pipe, int single);
84 main(int argc,char *argv[])
91 int singlepage; /* flag for EPS output */
93 char *Alscript_Version = ALSCRIPT_VERSION;
95 extern FILE *std_out,*std_err,*std_in;
103 /* initialize the file streams for GJ... routines */
109 /* check for -f option - if present, then define name for command file */
112 if(argv[i][0] == '-'){
113 if(strcmp(argv[i],"-f")==0){
114 /* command file name */
115 alps_file = GJstrdup(argv[++i]);
116 }else if(strcmp(argv[i],"-s")==0){
119 }else if(strcmp(argv[i],"-q")==0){
120 /* quick mode - defines its own command file */
123 }else if(strcmp(argv[i],"-p")==0){
124 /* send all output to std_out rather than the file defined in the command file */
127 }else if(strcmp(argv[i],"-single")==0){
128 /* single page mode - will generate a BoundingBox */
133 /* we have just defined the alscript command file */
134 alps_file = GJstrdup(argv[1]);
141 fprintf(std_err,"\nALSCRIPT (ALignment to PostScript)\n");
143 fprintf(std_err,"%s\n",Alscript_Version);
144 fprintf(std_err,"\nSee ALSCRIPT.DOC for details\n");
146 fprintf(std_err,"\nPlease Reference: Barton, G. J. (1993), Protein Engineering, 6, 37-40.\n");
148 fprintf(std_err,"\nBy: G. J. Barton\n");
149 fprintf(std_err,"\nCopyright: Geoffrey J. Barton (1992,1997)\n");
150 fprintf(std_err,"email: geoff@ebi.ac.uk\n\n");
152 fprintf(std_err,"Initial Defaults:\n");
153 fprintf(std_err,"Maximum number of sequences:\t %d \t(Change using MAX_NSEQ command)\n",MAXnbloc);
154 fprintf(std_err,"Maximum sequence length:\t %d \t(Change using MAX_SEQ_LEN command)\n",MAXslen);
155 fprintf(std_err,"Maximum identifier length:\t %d \t(Change using MAX_ID_LEN command)\n",MAXilen);
158 if(alps_file == NULL && !quick){
159 fprintf(std_err,"Enter ALscript Command File name: ");
160 alps_file = (char *) GJmalloc(sizeof(char) * MAXtlen);
161 fscanf(std_in,"%s",alps_file);
165 /* create an alscript command file */
166 fp = GJfopen("ALPSQ.COM","w",1);
169 alps_file = GJstrdup("ALPSQ.COM");
172 if(!silent)fprintf(std_err,"ALscript Command File: %s\n",alps_file);
174 if(alps(alps_file,silent,pipe,singlepage) == 1){
175 if(!silent)fprintf(std_err,"ALscript Finished\n");
178 error("Error in ALscript",1);
182 /* Write an alscript command file with some standard definitions */
184 void ALwritestddefs(FILE *alps_file)
186 fprintf(alps_file,"#ALSCRIPT - Default definitions\n");
187 fprintf(alps_file,"#For explanation of commands see file: alscript.doc\n");
188 fprintf(alps_file,"#Input from stdin and output to stdout by default\n");
189 fprintf(alps_file,"#block_file ?\n");
190 fprintf(alps_file,"#output_file ?\n");
191 fprintf(alps_file,"landscape\n");
192 fprintf(alps_file,"number_seqs\n");
193 fprintf(alps_file,"pointsize 8\n");
194 fprintf(alps_file,"define_font 0 Helvetica DEFAULT\n");
195 fprintf(alps_file,"define_font 1 Helvetica REL 0.5 \n");
196 fprintf(alps_file,"define_font 2 Helvetica-Bold DEFAULT\n");
197 fprintf(alps_file,"define_font 3 Times-Bold DEFAULT\n");
198 fprintf(alps_file,"define_font 4 Helvetica-BoldOblique DEFAULT\n");
199 fprintf(alps_file,"setup\n");
200 fprintf(alps_file,"mask SETUP\n");
201 fprintf(alps_file,"mask LEGAL \"ARNDCQEGHILKMFPSTWYVBZX\"\n");
202 fprintf(alps_file,"mask FRE ALL\n");
203 fprintf(alps_file,"mask SHADE ALL 0\n");
204 fprintf(alps_file,"mask INVERSE ALL\n");
205 fprintf(alps_file,"mask SHADE ALL 0\n");
206 fprintf(alps_file,"mask RESET\n");
207 fprintf(alps_file,"#shade_chars GP ALL 0\n");
208 fprintf(alps_file,"#inverse_chars GP ALL \n");
209 fprintf(alps_file,"#shade_chars LIVAWYFM ALL 0.8 \n");
210 fprintf(alps_file,"font_chars DEKRH ALL 4\n");