boxshade-3.1.1.orig/0042755000175100017510000000000010017361565014144 5ustar moellermoellerboxshade-3.1.1.orig/box.c0100644000175100017510000013402306346046534015104 0ustar moellermoeller/*----------------------------------------------------------------------- BOXSHADE 3.3 (May 1997) this program makes multiple-aligned output from either - PRETTY files from old LINEUP - MSF files from new PILEUP - CLUSTAL- .ALN files - MALIGNED data files - ESEE files - PHYLIP files various kinds of shading can be applied to identical/similar residues Output formats supported are - ANSI for display on terminal with ANSI.SYS loaded (PC version) - VT100 for display on VT100 compatible terminals - CRT for display on the main screen ( * PC-version only! * ) - POSTSCRIPT (TM) - Encapsulated POSTSCRIPT (for export to graphics programs) - HPGL for output on plotters or export to graphics programs - RTF (Rich text format) for export to word processing programs - ReGIS graphics for disply on terminals with ReGIS capabilities (DEC) - ReGIS file for printing after conversion with RETOS - LJ250 coloir printer format (DEC) - ASCII output showing either conserved or variable residues - FIG file output for use with xfig 2.1 program - PICT file, mostly used by Mac graphics progs, also many PC progs - HTML output for Web publishing This program might still contain bugs and is not particularly user-friendly. It is completely public-domain and may be passed around and modified without any notice to the author. the authors addresses are: Kay Hofmann Michael D. Baron Bioinformatics Group BBSRC Institute for Animal Health ISREC Pirbright, Surrey GU24 0NF CH-1066 Epalinges s/Lausanne U.K. Switzerland C port by Hartmut Schirmer Technische Fakultaet Kaiserstr. 2 D-24143 Kiel Germany for any comments write an E-mail to Kay: khofmann@isrec-sun1.unil.ch Michael: baron@bbsrc.ac.uk (though kay wrote 99% of the program and is more likely to be of help, especially with input and output problems) Hartmut: hsc@techfak.uni-kiel.de (don't send Kay or Michael any questions concerning the 'C' version of boxshade) MODIFICATION HISTORY 3.3 -converted from Pascal to C, includes several bug fixes over Pascal v3.21, mostly in page switching code. Rewritten Postscript driver: Compact output following the document structure conventions (DSC), additional color mode added. Enhanced memory allocation allows bigger alignments to be processed. Added ruler feature and /grp & /sim command line parameter. Added HTML output. 3.2 -added PICT output, somewhat experimental, all feedback gratefully received (by MDB). There are two options, either to output the Text with the shading (T) or just the shading (S); the latter option is for those who find the full file too big for their computer/program, and want to combine the shading with a simple formatted text version of their multiple sequence file e.g. the output from PRETTY (remember to set the block size equal to the linelength). 3.0 -major changes to shading strategy introduced by Michael Baron, see Documentation for details -addition of a new set of files (*.grp) and a few new command line qualifiers necessary for this new strategy -added support for ASCII output, showing one complete sequence and either conserved or deviating residues in the other sequences -added FIG output for use with the x-windows based public domain graphics program xfig 2.1 -bug fixes in the reading routine, boxshade can now import files created by clustalW and the MSF format created by readseq 2.7 -unified source code for VAX/VMS, AXP/OSF1 and MSDOS (Turbo Pascal) -all features of previous 2.6DOS version available for OSF1 and VMS -reads parameter and alignment files in both DOS and UNIX format -writes output files in native format of the machine. UNIX or DOS style text files can be forced by the qualifiers /unix or /dos -added /check qualifier for listing of command line parameters -added the option to hide the master sequence (see documentation) -finally dropped UIS support -minor bug fixes 2.6DOS -added RTF output 2.5DOS -added HPGL output -added consensus formation and output -added the /NUMDEF qualifier for default numbering -added the /SPLIT qualifier for splitting output to one page per file. -added the /CONS and /SYMBCONS qualifiers for output of consensus sequence 2.4DOS -initial MSDOS version -ported from VMS version 2.4 -added CRT support 2.4a -fixed a bug (terminal size problems) 2.4 -modified POSTSCRIPT/EPS output, allows scaling of fonts. (.PAR file structure modified, BOX.PSP now obsolete) -support of vertical POSTSCRIPT output -support of output on VT-series terminals -support of input from CLUSTAL V -slight reordering of interactive input -minor bug in command line handling fixed -minor bug in EPS-bounding box fixed 2.3 -default parameter management -option for shading according to similarity to a instead of a consensus sequence -support of GCG V7 MSF-format 2.2 -support of sequence numbering in output -support of MALIGNED data files 2.1 -output code completely rewritten for allowing easier modification -support of ENCAPSULATED POSTSCRIPT output -more compact POSTSCRIPT output files -multipage output for all devices -modifications in PRETTY and CLUSTAL reading routines for coping with slightly altered formats 2.0 -added POSTSCRIPT and ReGIS output routines -added a version that compiles without VWS (BOX_NO_UIS) -some minor bugfixes -creation of a .COM file for setting logicals 1.0 -initial version -CLUSTAL and PRETTY input -UIS/VWS and LJ250 sixel output ----------------------------------------------------------------------- */ #define BX_TYPES_G #include "bx_types.h" #include "bx_read.h" #include "dv_all.h" #include "version.h" #define DNAPEP() (dnaflag ? "dna" : "pep") char *aaset = "ACDEFGHIKLMNPQRSTVWY"; char *aasetlow = "acdefghiklmnpqrstvwy"; char *argv0=NULL; static GraphicsDevice *OutDev = NULL; static int cons_idx = -1; static int ruler_idx = -1; /*--------------------------------------------------------------------------*/ /* user query section section */ /*--------------------------------------------------------------------------*/ static char *explain_cl(char *cl) { static char ncl[256]; printf("Allowed command line parameters are:\n"); printf(C_SEP "help show this text\n"); printf(C_SEP "check show this text and extend command line\n"); printf(C_SEP "def use defaults, no unnecessary questions\n"); printf(C_SEP "numdef use default numbering\n"); printf(C_SEP "dna assume DNA sequences, use box_dna.par\n"); printf(C_SEP "split create separate files for multiple pages\n"); printf(C_SEP "toseq=xxx shading according to sequence No. xxx\n"); printf(C_SEP "in=xxxxx xxxxx is input file name\n"); printf(C_SEP "out=xxxxx xxxxx is output file name\n"); printf(C_SEP "par=xxxxx xxxxx is parameter file name\n"); printf(C_SEP "sim=xxxxx xxxxx is file name for similar residues def.\n"); printf(C_SEP "grp=xxxxx xxxxx is file name for grouping residues def.\n"); printf(C_SEP "thr=x x is the fraction of sequences that must agree" " for a consensus\n"); printf(C_SEP "dev=x x is output device class (see documentation)\n"); printf(C_SEP "type=x x is input file format (see documentation)\n"); printf(C_SEP "ruler print ruler line\n"); printf(C_SEP "cons create consensus line\n"); printf(C_SEP "symbcons=xyz xyz are consensus symbols\n"); printf(C_SEP "symbcons=\"xyz\" if the one above does not work, try this one\n"); printf(C_SEP "unix output files lines are terminated with LF only\n"); printf(C_SEP "mac output files lines are terminated with CR only\n"); printf(C_SEP "dos output files lines are terminated with CRLF\n"); /* printf("On unix systems, use the dash (-) as parameter delimiter\n\n"); */ if (cl != NULL) { printf("actual command line: %s\n", cl); printf("add to command line: "); Gets(ncl); } else *ncl = '\0'; return ncl; } static char *get_cl_filename(char *Result, char *cl, char *tag) { char *p, *r; int p1; p1 = indx(cl, tag); p = cl + p1 + strlen(tag) - 1; r = Result; while (*p != '\0' && *p != ' ' && *p != c_sep) *(r++) = *(p++); *r = '\0'; return Result; } static double get_cl_real(char *cl, char *tag) { char *p, *r; int p1; char dummy[256]; p1 = indx(cl, tag); p = cl + p1 + strlen(tag) - 1; r = dummy; while (*p != '\0' && *p != ' ' && *p != c_sep) *(r++) = *(p++); *r = '\0'; return( str2real(dummy) ); } static int get_cl_int(char *cl, char *tag) { char *p, *r; int p1; char dummy[256]; p1 = indx(cl, tag); p = cl + p1 + strlen(tag) - 1; r = dummy; while (*p != '\0' && *p != ' ' && *p != c_sep) *(r++) = *(p++); *r = '\0'; return( str2int(dummy) ); } static void process_command_line(int argc, char **argv) { char cl[500]; int incr, idx; save_binpath(argv[0]); *cl = '\0'; for (idx=1; idx < argc; idx++) { strcat(cl, argv[idx]); strcat(cl, " "); } if ( indx(cl, C_SEP "help") > 0) { explain_cl(NULL); exit(0); } if ( indx(cl, C_SEP "check") > 0) { strcat(cl, " "); strcat(cl, explain_cl(cl) ); } if (indx(cl, C_SEP "dna") > 0) dnaflag = TRUE; else dnaflag = FALSE; if (indx(cl, C_SEP "def") > 0) interactflag = FALSE; else interactflag = TRUE; if (indx(cl, C_SEP "in") > 0) { clinflag = TRUE; get_cl_filename(inname, cl, C_SEP "in="); } else clinflag = FALSE; if (indx(cl, C_SEP "out=") > 0) { cloutflag = TRUE; get_cl_filename(outname, cl, C_SEP "out="); } else cloutflag = FALSE; if (indx(cl, C_SEP "par=") > 0) { clparflag = TRUE; get_cl_filename(parname, cl, C_SEP "par="); } else clparflag = FALSE; if (indx(cl, C_SEP "sim=") > 0) { clsimflag = TRUE; get_cl_filename(clsimname, cl, C_SEP "sim="); } else clsimflag = FALSE; if (indx(cl, C_SEP "grp=") > 0) { clgrpflag = TRUE; get_cl_filename(clgrpname, cl, C_SEP "grp="); } else clgrpflag = FALSE; if ( (idx=indx(cl, C_SEP "type=")) > 0) { cltypeflag = TRUE; inputmode = cl[idx + 5]; } else cltypeflag = FALSE; if (indx(cl, C_SEP "thr=") > 0) { clthrflag = TRUE; thrfrac = get_cl_real(cl, C_SEP "thr="); if ((unsigned)thrfrac > 1) clthrflag = FALSE; } else clthrflag = FALSE; if (indx(cl, C_SEP "toseq=") > 0) { clseqconsflag = TRUE; seqconsflag = TRUE; consensnum = get_cl_int(cl, C_SEP "toseq="); } else clseqconsflag = FALSE; if ( (idx=indx(cl, C_SEP "dev=")) > 0) { cldevflag = TRUE; outputmode = cl[idx + 4]; } else cldevflag = FALSE; if (indx(cl, C_SEP "cons") > 0) { consflag = TRUE; clconsflag = TRUE; } else clconsflag = FALSE; if (indx(cl, C_SEP "ruler") > 0) { rulerflag = TRUE; } else rulerflag = FALSE; if ( (idx=indx(cl, C_SEP "symbcons=")) > 0) { clsymbconsflag = TRUE; consflag = TRUE; clconsflag = TRUE; incr = 0; if (cl[idx + 9] == '"' || cl[idx + 9] == '\'') incr = 1; symbcons[0] = cl[idx + incr + 9]; symbcons[1] = cl[idx + incr + 10]; symbcons[2] = cl[idx + incr + 11]; } else clsymbconsflag = FALSE; if (indx(cl, C_SEP "split") > 0) splitflag = TRUE; else splitflag = FALSE; EOLmode = EOL_default; if (indx(cl, C_SEP "unix" ) > 0) EOLmode = EOL_unix; else if (indx(cl, C_SEP "dos") > 0) EOLmode = EOL_dos; else if (indx(cl, C_SEP "mac") > 0) EOLmode = EOL_mac; if (indx(cl, C_SEP "numdef") > 0 || !interactflag) numdefflag = TRUE; else numdefflag = FALSE; } static BOOL SimGrp(char *template, char *fn, char *explain) { filenametype neu; sprintf(fn, template, DNAPEP()); if (fexist(fn)) return TRUE; strcpy(neu, fn); sprintf(fn, "%s%c", get_logical("BOXDIR"), d_sep); strcat(fn, neu); if (fexist(fn)) return TRUE; if (explain == NULL) return FALSE; for (;;) { printf("%s %s does not exist, enter filename: ", explain, neu); Gets(fn); if (fexist(fn)) return TRUE; strcpy(neu, fn); printf("\007file does not exist \n"); } } static void ask(void) { unsigned i; BOOL ok; char instring[51]; double inno; if (!clparflag) sprintf(parname, "box_%s.par", DNAPEP()); if (!fexist(parname)) sprintf(parname, "%s%cbox_%s.par", get_logical("BOXDIR"), d_sep, DNAPEP()); if (!fexist(parname)) { ok = FALSE; do { printf("Default-parameter file %s does not exist, enter filename: ", parname); Gets(parname); ok = fexist(parname); if (!ok) printf("\007file does not exist \n"); } while (!ok); } parfile = fopen(parname, TXT_RD); assert(parfile != NULL); do { Fgets(line_, 256, parfile); } while (indx(line_, ":GENERAL") != 1); Fgets(line_, 256, parfile); if (!clinflag) inputmode = line_[0]; Fgets(line_, 256, parfile); if (!cldevflag) outputmode = line_[0]; Fgets(line_, 256, parfile); if (line_[0] == 'Y' || line_[0] == 'y') seqconsflag = TRUE; else seqconsflag = FALSE; hideflag = FALSE; masternormal = FALSE; fscanf(parfile, "%d%*[^\n]", &outlen); getc(parfile); Fgets(line_, 256, parfile); if (line_[0] == 'Y' || line_[0] == 'y') seqnameflag = TRUE; else seqnameflag = FALSE; Fgets(line_, 256, parfile); if (line_[0] == 'Y' || line_[0] == 'y') seqnumflag = TRUE; else seqnumflag = FALSE; fscanf(parfile, "%d%*[^\n]", &interlines); getc(parfile); Fgets(line_, 256, parfile); if (line_[0] == 'Y' || line_[0] == 'y') simflag = TRUE; else simflag = FALSE; Fgets(line_, 256, parfile); if (line_[0] == 'Y' || line_[0] == 'y') globalflag = TRUE; else globalflag = FALSE; Fgets(line_, 256, parfile); if (!consflag) { if (line_[0] == 'Y' || line_[0] == 'y') consflag = TRUE; else consflag = FALSE; } Fgets(line_, 256, parfile); if (!clsymbconsflag) { symbcons[0] = line_[0]; symbcons[1] = line_[1]; symbcons[2] = line_[2]; } Fgets(line_, 256, parfile); if (!splitflag) { if (line_[0] == 'Y' || line_[0] == 'y') splitflag = TRUE; else splitflag = FALSE; } Fgets(line_, 256, parfile); if (!numdefflag) { if (line_[0] == 'Y' || line_[0] == 'y') numdefflag = TRUE; else numdefflag = FALSE; } if (!clthrflag) { fscanf(parfile, "%lg%*[^\n]", &thrfrac); getc(parfile); } else { Fgets(line_, 256, parfile); } for (i = 0; i < max_no_seq; i++) memset(seq[i], ' ', max_no_res); printf("\n"); printf("BOXSHADE %s\n", BOXSHADE_ver); printf( "This program makes multiple-aligned output from either\n" "PILEUP-MSF, CLUSTAL-ALN, MALIGNED-data and ESEE-save files\n" "(limited to a maximum of %d sequences with up to %d elements each)\n", max_no_seq, max_no_res); printf( "Various kinds of shading can be applied to identical/similar residues\n" "Output is written to screen or to a file in the following formats:\n" "ANSI/VT100, PS/EPS, RTF, HPGL, ReGIS, LJ250-printer, ASCII, xFIG,\n" "PICT, HTML\n" "\n" ); /**** ask for infile ****/ *instring = '\0'; ok = FALSE; do { if (!clinflag) { printf("name of aligned input-file : "); Gets(inname); printf("\n"); } ok = fexist(inname); if (!ok) { printf("\007aligned input file does not exist \n"); clinflag = FALSE; } } while (!ok); /**** ask for infile type ****/ if (!cltypeflag) { if (indx(inname, ".pre") > 0 || indx(inname, ".PRE") > 0 || indx(inname, ".msf") > 0 || indx(inname, ".MSF") > 0) inputmode = '1'; else { if (indx(inname, ".aln") > 0 || indx(inname, ".ALN") > 0) inputmode = '2'; else { if (indx(inname, ".mal") > 0 || indx(inname, ".MAL") > 0) inputmode = '3'; else { if (indx(inname, ".ese") > 0 || indx(inname, ".ESE") > 0) inputmode = '4'; } } } if (indx(inname, ".phy") > 0 || indx(inname, ".PHY") > 0) inputmode = '5'; } if (interactflag && !cltypeflag) { do { printf("Do you want to process (1) Lineup-PRETTY/Pileup-MSF file\n" " (2) CLUSTAL .ALN file\n" " (3) MALIGNED data file\n" " (4) ESEE save file\n" " (5) PHYLIP file (* %c *) : ", inputmode); Fgets(instring, 51, stdin); if (*instring == '\0') sprintf(instring, "%c", inputmode); if (indx("12345", instring) == 0) { printf(" \n"); printf("\007---> Please choose a supported type\n"); printf(" \n"); } } while (indx("12345", instring) <= 0); } printf(" \n"); if (*instring != '\0') inputmode = instring[0]; *instring = '\0'; if (!cldevflag) { do { printf("Output suitable for (%2c) POSTSCRIPT\n", oPS); printf(" (%2c) encapsulated POSTSCRIPT\n", oEPS); printf(" (%2c) HPGL\n", oHPGL); printf(" (%2c) RTF (Rich Text Format)\n", oRTF); #ifdef oCRT printf(" (%2c) PC-screen (PCs only!)\n", oCRT); #endif printf(" (%2c) ANSI-screen (PC-version)\n", oANSI); printf(" (%2c) VT100-screen (DEC-version)\n", oVT); printf(" (%2c) ReGIS-screen (25 lines each\n", oREGISt); printf(" (%2c) ReGIS-file (without breaks)\n", oREGISp); printf(" (%2c) LJ250-printer file\n", oLJ250); printf(" (%2c) ASCII file\n", oASCII); printf(" (%2c) FIG file (for XFIG)\n", oFIG); printf(" (%2c) PICT file\n", oPICT); printf(" (%2c) HTML file\n", oHTML); printf(" current: (* %c *) : ", outputmode); Fgets(instring, 51, stdin); if (*instring == '\0') sprintf(instring, "%c", outputmode); if (indx(allowed_devices, instring) == 0) { printf("\n"); printf("\007---> Please choose a supported type\n"); printf("\n"); } } while (indx(allowed_devices, instring) <= 0); } if (*instring != '\0') outputmode = instring[0]; printf("\n"); if (outputmode == oASCII) seqconsflag = TRUE; if (clseqconsflag) seqconsflag = TRUE; if (!seqconsflag) { *instring = '\0'; if (interactflag) { do { printf( "-------------------------------------------------------------------\n"); if (seqconsflag) printf("similarity to a single sequence? (* y *) : "); else printf("similarity to a single sequence? (* n *) : "); Fgets(instring, 51, stdin); } while (indx("nNyY", instring) <= 0 && *instring != '\0'); } seqconsflag = (toupper(*instring) == 'Y'); } *instring = '\0'; if (interactflag && !clconsflag) { do { printf("-------------------------------------------------------------------\n"); printf("display consensus line ? (* %c *) : ", YESNO(consflag) ); Fgets(instring, 51, stdin); } while (indx("nNyY", instring) <= 0 && *instring != '\0'); if (*instring != '\0') consflag = (toupper(instring[0]) == 'Y'); } else if (clconsflag && !clsymbconsflag) printf("-------------------------------------------------------------------\n\n"); *instring = '\0'; if (interactflag && consflag && !clsymbconsflag) { printf("\n" "Enter now a string of 3 symbols to be used for consensus display\n" " representing different/all-similar/all-identical residues\n" " see documentation for symbol definition, examples are:\n" " \" .*\" or \"-LU\" (ommit quotes but use blanks)\n" "SYMBOL : "); Fgets(instring, 51, stdin); if (*instring != '\0') { while (strlen(instring) != 3) { printf("\007please enter string of THREE (3) symbols !\n"); printf("SYMBOL : "); Fgets(instring, 51, stdin); } symbcons[0] = instring[0]; symbcons[1] = instring[1]; symbcons[2] = instring[2]; } } *instring = '\0'; if (interactflag && !rulerflag) { do { printf("-------------------------------------------------------------------\n" "display ruler line ? (* %c *) : ", YESNO(rulerflag) ); Fgets(instring, 51, stdin); } while (indx("nNyY", instring) <= 0 && *instring != '\0'); if (*instring != '\0') rulerflag = (toupper(instring[0]) == 'Y'); } *instring = '\0'; if (interactflag && !clthrflag && outputmode != oASCII) { *instring = '\0'; ok = FALSE; do { printf("--------------------------------------------------------------\n" "The threshold is the fraction of residues that must be identical\n" "or similar for shading to occur\n" "Value for threshold (* %6.2f *):", thrfrac); Fgets(instring, 51, stdin); if (*instring == '\0') ok = TRUE; else { *depend_err = '\0'; inno = str2real((void *)instring); if (*depend_err == '\0' && inno <= 1.0 && inno > 0.0) { ok = TRUE; thrfrac = inno; } if (!ok) printf("The fraction must be between 0 and 1\n\n"); } } while (!ok); } if (outputmode == oASCII) thrfrac = 0.0; *instring = '\0'; if (interactflag) { do { printf("-------------------------------------------------------------------\n" "\n" "How many sequence characters per line (* %3d *) : ", outlen); Fgets(instring, 51, stdin); if (*instring != '\0') outlen = str2int((void *)instring); printf("\n"); } while (outlen <= min_outlen || outlen >= max_outlen); } *instring = '\0'; if (interactflag) { do { printf("should sequence name be printed (* %c *) : ", YESNO(seqnameflag)); Fgets(instring, 51, stdin); } while (indx("nNyY", instring) <= 0 && *instring != '\0'); } if (*instring != '\0') seqnameflag = (toupper(instring[0]) == 'Y'); *instring = '\0'; if (interactflag && !rulerflag) { do { printf("should position numbers be printed (* %c *) : ", YESNO(seqnumflag)); Fgets(instring, 51, stdin); printf("\n"); } while (indx("nNyY", instring) <= 0 && *instring != '\0'); } if (*instring != '\0') seqnumflag = (toupper(instring[0]) == 'Y'); *instring = '\0'; if (interactflag) { do { printf("How many lines between two sequence blocks (* %2d *) : ", interlines); Fgets(instring, 51, stdin); if (*instring != '\0') interlines = str2int((void *)instring); printf(" \n"); } while (interlines <= 0 || interlines >= 100); } *instring = '\0'; if (interactflag) { do { printf("special label for similar residues (* %c *) : ", YESNO(simflag)); Fgets(instring, 51, stdin); } while (indx("nNyY", instring) <= 0 && *instring != '\0'); } if (*instring != '\0') simflag = (toupper(instring[0]) == 'Y'); if (simflag) { if (clsimflag) clsimflag = SimGrp(clsimname, simname, NULL); if (!clsimflag) SimGrp("box_%s.sim", simname, "Similarity-file"); if (clgrpflag) clgrpflag = SimGrp(clgrpname, grpname, NULL); if (!clgrpflag) SimGrp("box_%s.grp", grpname, "Group-file"); #if 0 sprintf(simname, "box_%s.sim", DNAPEP()); sprintf(grpname, "box_%s.grp", DNAPEP()); if (!fexist(simname)) sprintf(simname, "%s%cbox_%s.sim", get_logical("BOXDIR"), d_sep, DNAPEP()); if (!fexist(simname)) { ok = FALSE; do { printf("Similarity-file %s does not exist, enter filename: ", simname); Gets(simname); ok = fexist(simname); if (!ok) printf("\007file does not exist \n"); } while (!ok); } if (!fexist(grpname)) sprintf(grpname, "%s%cbox_%s.grp", get_logical("BOXDIR"), d_sep, DNAPEP()); if (!fexist(grpname)) { ok = FALSE; do { printf("Group-file %s does not exist, enter filename: ", grpname); Gets(grpname); ok = fexist(grpname); if (!ok) printf("\007file does not exist \n"); } while (!ok); } #endif } *instring = '\0'; if (interactflag) { do { if (globalflag) printf("special label for identical residues in all sequences (* y *) : "); else printf("special label for identical residues in all sequences (* n *) : "); Fgets(instring, 51, stdin); } while (indx("nNyY", instring) <= 0 && *instring != '\0'); } if (*instring != '\0') globalflag = (toupper(instring[0]) == 'Y'); for (i = 0; i <= 4; i++) lc[i] = FALSE; switch (outputmode) { #ifdef oCRT case oCRT: OutDev = &Crt; break; #endif case oANSI: OutDev = &Ansi; break; case oPS: OutDev = &Postscript; break; case oEPS: OutDev = &Eps; break; case oHPGL: OutDev = &Hpgl; break; case oRTF: OutDev = &Rtf; break; case oREGISt: OutDev = &RegisT; break; case oREGISp: OutDev = &RegisP; break; case oVT: OutDev = &Vt; break; case oLJ250: OutDev = &Lj250; break; case oASCII: OutDev = &Ascii; break; case oFIG: OutDev = &Fig; break; case oPICT: OutDev = &Pict; break; case oHTML: OutDev = &Html; break; } OutDev->Ask(); ident_sim = FALSE; if (interactflag) { do { printf("create identity / similarity matrix (* n *) : "); Fgets(instring, 51, stdin); } while (indx("nNyY", instring) <= 0 && *instring != '\0'); } if (*instring != '\0') ident_sim = (toupper(instring[0]) == 'Y'); if (ident_sim) { /**** ask for matrix file ****/ *instring = '\0'; printf("name of matrix output-file : "); Gets(identname); printf("\n"); } if (parfile != NULL) fclose(parfile); parfile = NULL; } static void ask_numbers(void) { char instring[11]; int inno, i; printf("-------------------------------------------------------\n" "\n" "You requested sequence numbering in the output.\n" "Enter the number of the first sequence position\n" "or confirm the suggestion of the program\n" ); for (i = 0; i < no_seq; i++) { printf("%s (* %4d *) : ", seqname[i], startno[i]); Fgets(instring, 11, stdin); if (*instring != '\0') { inno = str2int((void *)instring); if (strcmp(depend_err, "str2int")) startno[i] = inno; } else startno[i] = 1; } printf("\n"); } static void ask_seqcons(void) { char instring[11]; int i; if (clseqconsflag) { if (consensnum < 1 || consensnum > no_seq) clseqconsflag = FALSE; } if (!clseqconsflag) { /*only go into this asking routine if nothing on the command line*/ consensnum = 1; /*1 is the default*/ if (interactflag) { printf("-------------------------------------------------------\n" " \n" "You requested consensus formation to a single sequence.\n" "Choose now the sequence to compare to the other ones.\n" ); for (i = 1; i <= no_seq; i++) printf("(%2d) %s\n", i, seqname[i - 1]); do { printf("No. of sequence: (* %3d *) : ", consensnum); Fgets(instring, 11, stdin); if (*instring != '\0') consensnum = str2int((void *)instring); } while (consensnum < 1 || consensnum > no_seq); printf("\n"); *instring = '\0'; do { printf( "-------------------------------------------------------------------\n"); printf("hide this sequence? (* %c *) : ", YESNO(hideflag)); Fgets(instring, 11, stdin); } while (indx("nNyY", instring) <= 0 && *instring != '\0'); if (*instring != '\0') hideflag = (toupper(instring[0]) == 'Y'); } } if (outputmode == oASCII) { masternormal = TRUE; return; } if (!interactflag || clseqconsflag) { masternormal = FALSE; return; } *instring = '\0'; if (!hideflag) { do { printf("show this sequence in all-normal rendition? (* n *) : "); Fgets(instring, 11, stdin); } while (indx("nNyY", instring) <= 0 && *instring != '\0'); } if (*instring == '\0') return; masternormal = (toupper(instring[0]) == 'Y'); } /*--------------------------------------------------------------------------*/ /* read input files and comparison-table */ /*--------------------------------------------------------------------------*/ static void read_cmp(void) { /* Read the .sim and .grp files */ int i, j, p1, p2; char *cp; FILE *simfile, *grpfile; int ll; grpfile = NULL; simfile = NULL; if (simflag) { for (i = 0; i <= 19; i++) { for (j = 0; j <= 19; j++) { simtable[i][j] = FALSE; grptable[i][j] = FALSE; } } for (i = 0; i <= 19; i++) { simtable[i][i] = TRUE; grptable[i][i] = TRUE; } simfile = fopen(simname, TXT_RD); assert(simfile != NULL); do { Fgets(line_, 256, simfile); } while (!feof(simfile) && indx(line_, "..") <= 0); while (!feof(simfile)) { Fgets(line_, 256, simfile); if (*line_ == '\0') continue; cp = strchr(aaset, line_[0]); if (cp == NULL) p1 = 0; else p1 = (int)(cp-aaset)+1; if (p1 > 0) { ll = strlen(line_); for (i = 2; i < ll; i++) { cp = strchr(aaset, line_[i]); if (cp == NULL) p2 = 0; else p2 = (int)(cp-aaset)+1; if (p2 > 0) { simtable[p1 - 1][p2 - 1] = TRUE; simtable[p2 - 1][p1 - 1] = TRUE; } } } } grpfile = fopen(grpname, TXT_RD); assert(grpfile != NULL); do { Fgets(line_, 256, grpfile); } while (!feof(grpfile) && indx(line_, "..") <= 0); while (!feof(grpfile)) { Fgets(line_, 256, grpfile); if ((ll=strlen(line_)) < 2) continue; for (j = 1; j < ll; j++) { cp = strchr(aaset, line_[j-1]); if (cp == NULL) p1 = 0; else p1 = (int)(cp-aaset)+1; if (p1 > 0) { for (i = j; i < ll; i++) { cp = strchr(aaset, line_[i]); if (cp == NULL) p2 = 0; else p2 = (int)(cp-aaset)+1; if (p2 > 0) { grptable[p1 - 1][p2 - 1] = TRUE; grptable[p2 - 1][p1 - 1] = TRUE; } } } } } } if (simfile != NULL) fclose(simfile); if (grpfile != NULL) fclose(grpfile); } static int aaset_idx[256]; #define IDX_aaset(ch) ( aaset_idx[(unsigned char)(ch)] ) #define IN_aaset(ch) ( IDX_aaset(ch) >= 0 ) static void build_aaset_table(void) { int ch; unsigned char *ap; for (ch = 0; ch < 256; ++ch) aaset_idx[ch] = -1; ch = 0; for (ap = &aaset[0]; *ap != '\0'; ++ap) aaset_idx[*ap] = ch++; } static BOOL sim(char a, char b) { int idx1, idx2; idx1 = IDX_aaset(a); if (idx1 < 0) return FALSE; idx2 = IDX_aaset(b); if (idx2 < 0) return FALSE; return simtable[idx1][idx2]; } static BOOL grp(char a, char b) { int idx1, idx2; idx1 = IDX_aaset(a); if (idx1 < 0) return FALSE; idx2 = IDX_aaset(b); if (idx2 < 0) return FALSE; return grptable[idx1][idx2]; } static void make_consensus_length(void) { int i; consenslen = 0; for (i = 0; i < no_seq; i++) { while (seq[i][seqlen[i] - 1] == '-' || seq[i][seqlen[i] - 1] == '.' || seq[i][seqlen[i] - 1] == ' ') seqlen[i]--; if (seqlen[i] > consenslen) consenslen = seqlen[i]; } printf("consensus length is %d\n", consenslen); } static void make_consensus(void) { int i, j, k; int idcount[MAX_NO_SEQ]; int simcount[MAX_NO_SEQ]; int pc; int maxidcount, maxsimcount, idindex, simindex; BOOL unique; /* set consensus length = length of longest sequence (not counting dots, spaces, etc. at the "far" end. May be a problem here for some strange cases */ /* calculate the threshold # of sequences */ thr = (int)(0.5 + thrfrac * no_seq); if (seqconsflag) { for (i = 0; i < consenslen; i++) cons[i] = seq[consensnum - 1][i]; return; } printf("Building consensus "); fflush(stdout); /* build a lookup table for 'strchr(aaset,ch)-aaset' */ build_aaset_table(); pc = 0; for (i = 0; i < consenslen; i++) { int p = (int)((50.0*i) / consenslen); if (p > pc) { printf("."); fflush(stdout); pc = p; } for (j = 0; j < no_seq; j++) { idcount[j] = 0; simcount[j] = 0; for (k = 0; k < no_seq; k++) { /* increment idcount AND simcount if the two residues are the same */ char seq_ji = seq[j][i]; if ( IN_aaset(seq_ji)) { if (seq[k][i] == seq_ji) { idcount[j]++; simcount[j]++; } else /* increment only simcount if residues are not the same but fall into the same group */ if (grp(seq[k][i], seq_ji)) simcount[j]++; } } } /* Find the maximum values in idcount and simcount, along with the indices of those maxima */ cons[i] = ' '; unique = FALSE; maxidcount = idcount[0]; maxsimcount = simcount[0]; idindex = 1; simindex = 1; for (j = 2; j <= no_seq; j++) { if (idcount[j - 1] > maxidcount) { idindex = j; maxidcount = idcount[j - 1]; } if (simcount[j - 1] > maxsimcount) { maxsimcount = simcount[j - 1]; simindex = j; } } /* check here for the case where several residues/types may have achieved the same score */ if (maxidcount >= thr) { /*only look if max is high enough*/ unique = TRUE; for (j = 0; j < no_seq; j++) { if (maxidcount == idcount[j] && seq[idindex - 1][i] != seq[j][i]) unique = FALSE; } if (unique) cons[i] = seq[idindex - 1][i]; } /* if there is an equally high idcount for a different residue then there can't be a single residue consensus */ if (maxsimcount >= thr && !unique) { unique = TRUE; for (j = 0; j < no_seq; j++) { if (maxsimcount == simcount[j] && !grp(seq[simindex - 1][i], seq[j][i])) unique = FALSE; } if (unique) cons[i] = tolower(seq[simindex - 1][i]); /*if maxsimcount is not unique and the other residue is NOT in the same similarity group then there is so consensus based on similarity. If the two residues with the same similarity score are in the same similarity group, flag that consensus position by making the residue lowercase*/ } } printf(" done\n"); } static void make_colors(void) { int i, j, idcount, simcount, pc; printf("Colorizing "); fflush(stdout); pc = 0; for (i = 0; i < consenslen; i++) { int p = (int)((50.0*i) / consenslen); if (p > pc) { printf("."); fflush(stdout); pc = p; } idcount = 0; simcount = 0; if (strchr(aasetlow, cons[i]) != NULL) for (j = 0; j < no_seq; j++) { col[j][i] = 0; if (grp(seq[j][i], toupper(cons[i]))) { col[j][i] = 2; simcount++; } } else { for (j = 0; j < no_seq; j++) { if (seq[j][i] == cons[i]) idcount++; else { if (sim(seq[j][i], cons[i])) simcount++; } col[j][i] = 0; } /*count the ids and sims as they are used later for consensus line*/ if (idcount == no_seq && strchr(aaset, cons[i]) != NULL ) { for (j = 0; j < no_seq; j++) col[j][i] = 3; /*if all sequences the same at this point then colour them identical(3)*/ } else { if (idcount + simcount >= thr && strchr(aaset, cons[i]) != NULL ) { for (j = 0; j < no_seq; j++) { if (seq[j][i] == cons[i]) col[j][i] = 1; /*=> conserved residue*/ else if (sim(seq[j][i], cons[i])) col[j][i] = 2; /*=> similar to consensus(2)*/ } } } } /*do shading and count similar residues for the case of a group consensus; note that in this case there cannot be any residues marked as 'identical', by definition*/ if (consflag) { if (idcount == no_seq) { conschar[i] = symbcons[2]; if (toupper(conschar[i]) == 'U') conschar[i] = toupper(cons[i]); else if (toupper(conschar[i]) == 'L') conschar[i] = tolower(cons[i]); else if (toupper(conschar[i]) == 'B') conschar[i] = ' '; } else if (idcount + simcount >= thr) { conschar[i] = symbcons[1]; if (toupper(conschar[i]) == 'U') conschar[i] = toupper(cons[i]); else if (toupper(conschar[i]) == 'L') conschar[i] = tolower(cons[i]); else if (toupper(conschar[i]) == 'B') conschar[i] = ' '; } else { conschar[i] = symbcons[0]; if (toupper(conschar[i]) == 'U') conschar[i] = toupper(cons[i]); else if (toupper(conschar[i]) == 'L') conschar[i] = tolower(cons[i]); else if (toupper(conschar[i]) == 'B') conschar[i] = ' '; } } } printf(" done\n"); } static void make_lowcase(void) { int i, j, pc; if ( ! (lc[0] || lc[1] || lc[2] || lc[3] || lc[4]) ) return; /* nothing to do ! */ printf("Lowercase "); fflush(stdout); pc = 0; for (i = 0; i < no_seq; i++) { int p = (int)((20.0*i) / no_seq); while (p > pc) { printf("."); fflush(stdout); pc++; } for (j = 0; j < seqlen[i]; j++) { if (lc[col[i][j]]) seq[i][j] = tolower(seq[i][j]); } } printf(" done\n"); } static void prepare_names(void) { int i; char *cp; seqname_outlen = 1; for (i = 0; i < no_seq; i++) { cp = seqname[i] + strlen(seqname[i]); while (cp != seqname[i] && *(cp-1) == ' ') *(--cp) = '\0'; if (strlen(seqname[i]) > seqname_outlen) seqname_outlen = strlen(seqname[i]); } for (i = 0; i < no_seq; i++) { int sl = strlen(seqname[i]); int p = seqname_outlen - sl; if (p > 0) sprintf(seqname[i]+sl, "%*s", p, ""); } } static void prepare_numbers(void) { int count, bn, i, j; for (i = 0; i < no_seq; i++) { for (j = 1; j < max_no_block; j++) sprintf(prenum[i][j], "%*s", seqnumlen, ""); sprintf(prenum[i][0], "%*d", seqnumlen, startno[i]); count = startno[i] - 1; bn = 1; for (j = 1; j <= seqlen[i]; j++) { if ( isupper(seq[i][j - 1]) || (i == cons_idx) || (i == ruler_idx) ) count++; if (j % outlen == 0) { bn++; if (count + 1 < seqlen[i] + startno[i]) sprintf(prenum[i][bn-1], "%*d", seqnumlen, count + 1); } } } } /*--------------------------------------------------------------------------*/ /* graphics section */ /*--------------------------------------------------------------------------*/ static void graphics_init(double *xpos, double *ypos) { act_page = 1; OutDev->Init(xpos, ypos); lines_per_page = (int)((dev_maxy - dev_miny) / dev_ysize); act_page = 1; } static void graphics_setcolor(int colno) { if (colno == act_color) return; OutDev->Setcolor(colno); act_color = colno; } static void graphics_charout(char c, double *xpos, double *ypos) { OutDev->Charout(c, xpos, ypos); } void GenericStringOut(char *s, double *xpos, double *ypos) { while (*s != '\0') { OutDev->Charout(*s, xpos, ypos); ++s; } OutDev->Charout(' ', xpos, ypos); } static void graphics_stringout(char *s, double *xpos, double *ypos) { OutDev->Stringout(s, xpos, ypos); } static void graphics_newline(double *xpos, double *ypos) { OutDev->Newline(xpos, ypos); } static void graphics_newpage(double *xpos, double *ypos) { OutDev->Newpage(xpos, ypos); act_page++; } static void graphics_exit(void) { OutDev->Exit(); } static void graphics_out(void) { double xpos, ypos; /*current position of text cursor*/ int i, j, k; char pagesymbol; int linecount; pagesymbol = '1'; act_color = -1; no_blocks = (consenslen - 1) / outlen + 1; if (consflag && no_seq < max_no_seq) { cons_idx = no_seq; seqlen[cons_idx] = consenslen; strcpy(seqname[cons_idx], "consensus"); startno[cons_idx] = 1; for (i = 0; i < consenslen; i++) { seq[cons_idx][i] = conschar[i]; col[cons_idx][i] = 4; /*set colour to predefined "title" type*/ } no_seq++; } if (seqconsflag && masternormal) { for (i = 0; i < consenslen; i++) col[consensnum - 1][i] = 4; } if (seqconsflag && hideflag) { if (consensnum < no_seq) { for (i = consensnum; i < no_seq; i++) { seqlen[i - 1] = seqlen[i]; strcpy(seqname[i - 1], seqname[i]); startno[i - 1] = startno[i]; memcpy(seq[i - 1], seq[i], max_no_res * sizeof(char)); memcpy(col[i - 1], col[i], max_no_res * sizeof(byte)); } } no_seq--; } if (rulerflag && no_seq < max_no_seq) { ruler_idx = no_seq; seqlen[ruler_idx] = consenslen; strcpy(seqname[ruler_idx], ""); startno[ruler_idx] = 1; for (i = 0; i < consenslen; i++) { seq[ruler_idx][i] = '.'; col[ruler_idx][i] = 4; /*set colour to predefined "title" type*/ } seq[ruler_idx][0] = '1'; for (i=10; i <= consenslen; i+=10) { char no[20]; j=i-1; do { ++j; sprintf(no, "%d", j); k = strlen(no); } while ( ((j-1)%outlen)+k > outlen || j > consenslen); if (j+k-1 <= consenslen && (j%10)+k < 9) memcpy(&seq[ruler_idx][j-1], no, k); } no_seq++; } if (seqnameflag) prepare_names(); if (seqnumflag) prepare_numbers(); lines_left = no_blocks * (no_seq + interlines) - interlines; graphics_init(&xpos, &ypos); linecount = 0; for (i = 0; i < no_blocks; i++) { for (j = 0; j < no_seq; j++) { if (seqnameflag) { graphics_setcolor(4); /*set colours to "title" type*/ /* for (k = 0; k < seqname_outlen; k++) graphics_charout(seqname[j][k], &xpos, &ypos); graphics_charout(' ', &xpos, &ypos); */ graphics_stringout(seqname[j], &xpos, &ypos); } if (seqnumflag) { graphics_setcolor(4); /* { int sl = strlen(prenum[j][i]); for (k = 0; k < sl; k++) graphics_charout(prenum[j][i][k], &xpos, &ypos); } graphics_charout(' ', &xpos, &ypos); */ graphics_stringout(prenum[j][i], &xpos, &ypos); } for (k = 0; k < outlen; k++) { if (i * outlen + k < consenslen) { graphics_setcolor(col[j][i * outlen + k]); graphics_charout(seq[j][i * outlen + k], &xpos, &ypos); } } linecount++; if (linecount >= lines_per_page) { lines_left -= linecount; linecount = 0; if (lines_left > 0) { if (splitflag) { graphics_exit(); pagesymbol++; outname[indx(outname, ".") - 2] = pagesymbol; graphics_init(&xpos, &ypos); } else graphics_newpage(&xpos, &ypos); } } else graphics_newline(&xpos, &ypos); } /* for j */ if (linecount + interlines + no_seq <= lines_per_page) { /*will the next block fit?*/ for (j = 0; j < interlines; j++) { graphics_newline(&xpos, &ypos); linecount++; } } else { /* skipping interlines ... */ lines_left -= interlines; lines_left -= linecount; if (lines_left > 0) { if (splitflag) { graphics_exit(); pagesymbol++; outname[indx(outname, ".") - 2] = pagesymbol; graphics_init(&xpos, &ypos); linecount = 0; } else { graphics_newpage(&xpos, &ypos); linecount = 0; } } } } /* for i */ graphics_exit(); } static void do_out(FILE *outf, BOOL goon) { int i, j, k, id, sim, conlen; BOOL fl1, fl2; int pc; prepare_names(); if (goon) printf("Building identity/similarity matrix "); fflush(stdout); pc = 0; for (i = 1; i <= no_seq; i++) { if (goon) { int p = (int)((20.0*i) / no_seq); while (p > pc) { printf("."); fflush(stdout); pc++; } } fprintf(outf, "%s ", seqname[i - 1]); /* Identities */ for (j = 0; j < i - 1; j++) { id = 0; conlen = 0; for (k = 0; k < consenslen; k++) { fl1 = IN_aaset(seq[i-1][k]); fl2 = IN_aaset(seq[j ][k]); if (fl1 || fl2) { conlen++; if (seq[i-1][k] == seq[j][k]) id++; } } fprintf(outf, " %5.1f", 100.0 * id / conlen); } fprintf(outf, "%6s", "----"); for (j = i; j < no_seq; j++) { sim = 0; conlen = 0; for (k = 0; k < consenslen; k++) { fl1 = IN_aaset(seq[i-1][k]); fl2 = IN_aaset(seq[j ][k]); if (fl1 || fl2) { conlen++; if (seq[i-1][k] == seq[j][k] || grp(seq[i-1][k], seq[j][k])) sim++; } } fprintf(outf, " %5.1f", 100.0 * sim / conlen); } putc('\n', outf); } if (goon) printf(" done\n"); } static void ident_sim_out(void) { if (*identname != '\0') { MYFILE idf; assert( outopen(&idf, identname) != NULL ); do_out(idf.f, TRUE); fclose(idf.f); } else do_out(stdout, FALSE); } /* * * * * * * * * * * * * * * * * * * * * * * * * * * Allocate memory -- actually this should be done * * after we know how many sequences there are and * * how long each is -- future work */ static void allocate1(void) { int i; cons = NULL; conschar = NULL; seq = Malloc(MAX_NO_SEQ * sizeof(char *)); col = Malloc(MAX_NO_SEQ * sizeof(byte *)); prenum = Malloc(MAX_NO_SEQ * sizeof(numtype *)); max_no_seq = MAX_NO_SEQ; max_no_res = MAX_NO_RES; for (i = 0; i < MAX_NO_SEQ; i++) { seq[i] = malloc(max_no_res * sizeof(char)); col[i] = NULL; prenum[i] = NULL; if (seq[i] == NULL) { if (i > 10) { --i; Free(&seq[i]); --i; Free(&seq[i]); } max_no_seq = i-1; break; } } } static void allocate2(void) { int i, need; need = no_seq; if (consflag) ++need; if (rulerflag) ++need; if (need > max_no_seq) need = max_no_seq; for (i=max_no_seq-1; i >= need; --i) Free(&seq[i]); if (consenslen < max_no_res / 2) { for (i=no_seq; i >= 0; --i) { seq[i] = realloc(seq[i], (consenslen+1)*sizeof(char)); assert(seq[i] != NULL); } } max_no_seq = need; max_no_res = consenslen+1; cons = Malloc(max_no_res * sizeof(char)); if (consflag) conschar = Malloc(max_no_res * sizeof(char)); for (i = 0; i < max_no_seq; i++) { col[i] = Malloc(max_no_res * sizeof(byte)); if (seqnumflag) prenum[i] = Malloc(max_no_block * sizeof(numtype)); } } /*--------------------------------------------------------------------------*/ /* main program */ /*--------------------------------------------------------------------------*/ int main(int argc, char **argv) { allocate1(); process_command_line(argc, argv); ask(); switch (inputmode) { case '1': read_file_pretty(); break; case '2': read_file_clustal(); break; case '3': read_file_maligned(); break; case '4': read_file_esee(); break; case '5': read_file_phylip(); break; } if (seqnumflag && !numdefflag) ask_numbers(); if (seqconsflag) ask_seqcons(); read_cmp(); make_consensus_length(); allocate2(); make_consensus(); if (ident_sim) ident_sim_out(); make_colors(); make_lowcase(); graphics_out(); return 0; } boxshade-3.1.1.orig/box_dna.grp0100644000175100017510000000011106346046534016262 0ustar moellermoellerThis file is a Nucleic-acid group file for use with BOXSHADE. .. AGR CTY boxshade-3.1.1.orig/box_dna.par0100644000175100017510000001226706346046534016273 0ustar moellermoellerThis is a file of default parameters for use with BOXSHADE there are several sections, one for GENERAL parameters and one for each output device. The parameters may be edited freely, they reflect the input expected from the keyboard if BOXSHADE is run interactively. The purpose of each parameter is documented briefly within the respective line. When editing, one has to regard: - one parameter per line (background/foreground shading = one parameter) - parameters of a section (labeled :SECTION) start in the first line after the label - there may be no empty (or comment) lines between the parameters of a section. These lines are allowed only between sections - only the leftmost part of every parameter line is looked at. Comments are allowed starting at row 10 - don't change the section header :GENERAL 1 input type (1: PRETTY) 1 output device (1: ANSI Terminal) N consensus to single sequence? 60 sequence chars per line Y sequence names to be printed? N sequence numbers to be printed? 1 No of empty lines between blocks N special shading for similar residues N special shading for conserved residues N consensus output LU consensus display pattern N split output to multiple files N default numbering (starting at 1) 0.8 default threshold fraction :HTML WB normal residues BW identical residues 3W similar residues B2 globally conserved residues :POSTSCRIPT WB normal residues BW identical residues 3W similar residues B2 globally conserved residues 10 character size (in Pts.) N landscape mode :FIG WB normal residues BW identical residues 1B similar residues BY globally conserved residues 12 0=Tms,12=Cour,16=Helv,28=Palat 10 character size (in Pts.) :LJ250 B normal residues R identical residues L similar residues M globally conserved residues :CRT LD normal residues BL identical residues LR similar residues BW globally conserved residues :RTF WK normal residues WR identical residues WB similar residues WM globally conserved residues 10 character size (in pts) :ASCII . normal residues L identical residues l similar residues L globally conserved residues :ANSI N normal residues R identical residues B similar residues E globally conserved residues :ReGIS WB normal residues BW identical residues LW similar residues BY globally conserved residues :HPGL 0F1N normal residues (bgnd/fgnd) 2F1N identical residues 3F1N similar residues 2F4N globally conserved residues 8 character size (in Pts.) N landscape mode :PICTFILE WB normal residues BW identical residues 1B similar residues B2 globally conserved residues 10 character size (in Pts.) S shade only? n landscape mode :VT N R B E boxshade-3.1.1.orig/box_dna.sim0100644000175100017510000000122306346046534016267 0ustar moellermoellerThis file is a Nucleic-acid similarity file for use with BOXSHADE. Is resembles the GCG simplify.txt, but similarities contained in this file are not automatically set-forming. This means: The line I LVM means that I is similar to L,V and M and also that L,V,M are similar to I. It does not imply that L is similar to V or to M. For achieving this, more lines (the next ones) are necessary. Although is seems weird, this feature has been chosen DELIBERATELY because I think it could be helpful in some cases. Other format requirements are the same as for SIMPLIFY.TXT in the GCG-package. .. A GR G AR R AG C TY T CY Y CT boxshade-3.1.1.orig/box_pep.grp0100644000175100017510000000060106346046534016310 0ustar moellermoellerThis file is a Amino-acid grouping file for use with NEWBOX. Each line contains a set of amino acids which are considered 'similar' when calculating the consensus. The .SIM file is different and is used in colouring residues that are "similar" to a single consensus residue. Other format requirements are the same as for SIMPLIFY.TXT in the GCG-package. .. FYW ILVM RK DE GA TS NQ boxshade-3.1.1.orig/box_pep.par0100644000175100017510000001264706346046534016317 0ustar moellermoellerThis is a file of default parameters for use with BOXSHADE there are several sections, one for GENERAL parameters and one for each output device. The parameters may be edited freely, they reflect the input expected from the keyboard if BOXSHADE is run interactively. The purpose of each parameter is documented briefly within the respective line. When editing, one has to regard: - one parameter per line (background/foreground shading = one parameter) - parameters of a section (labeled :SECTION) start in the first line after the label - there may be no empty (or comment) lines between the parameters of a section. These lines are allowed only between sections - only the leftmost part of every parameter line is looked at. Comments are allowed starting at row 10 - don't change the section header :GENERAL 1 input type (1: PRETTY) 1 output device (1: ANSI Terminal) N consensus to single sequence? 60 sequence chars per line Y sequence names to be printed? N sequence numbers to be printed? 1 No of empty lines between blocks Y special shading for similar residues N special shading for conserved residues N consensus output LU consensus display pattern N split output to multiple files N default numbering (starting at 1) 0.5 default threshold fraction :HTML WB normal residues BW identical residues 1B similar residues B2 globally conserved residues :POSTSCRIPT WB normal residues BW identical residues 1B similar residues B2 globally conserved residues 10 character size (in Pts.) n landscape mode :CRT LD normal residues BL identical residues LR similar residues BW globally conserved residues :RTF WK normal residues WR identical residues WB similar residues WM globally conserved residues 10 character size (in pts) :ANSI N normal residues R identical residues B similar residues E globally conserved residues :ASCII L normal residues - identical residues l similar residues . globally conserved residues :HPGL 0F1N normal residues (bgnd/fgnd) 2F1N identical residues 3F1N similar residues 2F4N globally conserved residues 8 character size (in Pts.) N landscape mode :LJ250 B normal residues R identical residues L similar residues M globally conserved residues :FIG WB normal residues BW identical residues 1B similar residues BY globally conserved residues 12 0=Tms,12=Cour,16=Helv,28=Palat 10 character size (in Pts.) :ReGIS WB normal residues BW identical residues LW similar residues BY globally conserved residues :VT N normal residues R identical residues B similar residues E globally conserved residues :PICTFILE WB normal residues BW identical residues 1B similar residues B2 globally conserved residues 10 character size (in Pts.) T shade only ? n landscape mode boxshade-3.1.1.orig/box_pep.sim0100644000175100017510000000122206346046534016310 0ustar moellermoellerThis file is a Amino-acid similarity file for use with BOX. Is resembles the GCG simplify.txt, but similarities contained in this file are not automatically set-forming. This means: The line I LVM means that I is similar to L,V and M and also that L,V,M are similar to I. It does not imply that L is similar to V or to M. For achieving this, more lines (the next ones) are necessary. Although is seems weird, this feature has been chosen DELIBERATELY because I think it could be helpful in some cases. Other format requirements are the same as for SIMPLIFY.TXT in the GCG-package. .. F YW Y WF W FY I LVM L VMI V MIL M ILV R K D E G A T S N Q boxshade-3.1.1.orig/bx_misc.c0100644000175100017510000002147206346046534015743 0ustar moellermoeller#include "bx_types.h" #include #ifdef MSDOS #include #else #include #endif MYFILE outfile = { NULL, FALSE}; FILE *parfile = NULL; char depend_err[50] = ""; void *Malloc(size_t sze) { void *res = malloc(sze); assert(res!=NULL); return res; } int min(int a, int b) { if (a < b) return a; return b; } static char *binpath = NULL; void save_binpath(char *arg0) { int sl = strlen(arg0); char *ap = ""; /* Accept three path seperators: / \ : */ while (sl > 0 && strchr("\\/:", arg0[sl-1]) == NULL) --sl; if (sl <= 0) return; if (arg0[sl-1] == ':') ap = ":."; binpath = Malloc(sl + strlen(ap) ); if (binpath == NULL) return; strncpy(binpath, arg0, sl-1); strcpy(binpath+sl-1, ap); } char *get_logical(char *logical) { char *r; static char res[300]; r = getenv(logical); if (r == NULL) r = ""; strcpy(res, r); if (*res != '\0' || strcmp(logical, "BOXDIR")!=0 || binpath == NULL) return res; /* looking for BOXDIR -> default to exe directory ! */ strcpy(res, binpath); /* exec path */ return res; } BOOL fexist(char *fname) { BOOL Result; FILE *f; f = fopen(fname, TXT_RD); Result = (f != NULL); if (f != NULL) fclose(f); return Result; } int indx(char *mainstring, char *substring) { char *cp; if (*mainstring == '\0') return 0; cp = strstr(mainstring, substring); if (cp == NULL) return 0; return (int)(cp-mainstring)+1; } MYFILE *outopen(MYFILE *mf, char *fn) { mf->bin = EOLmode != EOL_default; mf->f = fopen(fn, (mf->bin ? BIN_WR : TXT_WR)); return (mf->f != NULL ? mf : NULL); } static char *uwb = NULL; void uwriteln(MYFILE *f, char *fmt, ...) { va_list argptr; if ( !f->bin) { defeol: va_start(argptr, fmt); vfprintf(f->f, fmt, argptr); va_end(argptr); fputs("\n", f->f); return; } if (uwb == NULL) { uwb = malloc(4000); if (uwb == NULL) goto defeol; } { char *cp1, *cp2; int cnt; va_start(argptr, fmt); cnt = vsprintf(uwb, fmt, argptr); va_end(argptr); uwb[cnt] = '\n'; uwb[cnt+1] = '\0'; cp1 = uwb; while (cp1 != NULL && *cp1 != '\0') { cp2 = strchr(cp1, '\n'); if (cp2 != NULL) { *cp2 = '\0'; ++cp2; } fputs(cp1, f->f); if (cp2 != NULL) { fflush(f->f); switch (EOLmode) { case EOL_dos : putc('\r', f->f); putc('\n', f->f); break; case EOL_mac : putc('\r', f->f); break; case EOL_unix : default : putc('\n', f->f); break; } } cp1 = cp2; } } } double str2real(void *s) { double r; int err; err = (sscanf((char *)s, "%lg", &r) == 0); if (err != 0) { strcpy(depend_err, "str2real"); return 0.0; } else return r; } int str2int(void *s) { int i, err; err = (sscanf((char *)s, "%d", &i) == 0); if (err != 0) { strcpy(depend_err, "str2real"); return 0; } else return i; } #if 0 static long rand_m = 100000000L, rand_m1 = 10000, rand_b = 31415821L; static long rand_a[55]; static int rand_j, filecount; char lowcase(char c) { if (c <= 90 && c >= 65) return (c + 32); else return c; } char *int2str(char *Result, int intg, int dig) { char s[100]; sprintf(s, "%*d", dig, intg); return strcpy(Result, s); } char *real2str(char *Result, double rl, int dig1, int dig2) { char s[100]; sprintf(s, "%*.*f", dig1, dig2, rl); return strcpy(Result, s); } char *get_command_line(char *Result) { string255 cl; int i; *cl = '\0'; if (P_argc > 1) { for (i = 1; i < P_argc; i++) strcat(cl, P_argv[i]); } return strcpy(Result, cl); } static char *getTEMPname(char *Result, char *s_) { string255 s; strcpy(s, s_); s[strlen(s) - 1] = '~'; return strcpy(Result, s); } void fopen_(FILE **f, char *fname_, char acc) { /*acc = r,w,a */ string255 fname; FILE *tmpfile; string255 tmpname, line; char c; char buf1[6144], buf2[6144]; BOOL uxmode; char tmpfile_NAME[_FNSIZE]; strcpy(fname, fname_); tmpfile = NULL; if (acc == 'w' || acc == 'W') { assign(*f, fname); /* p2c: dep_tp.pas, line 128: Note: REWRITE does not specify a name [181] */ if (*f != NULL) rewind(*f); else *f = tmpfile(); if (*f == NULL) _EscIO(FileNotFound); } else if (acc == 'a' || acc == 'A') { assign(*f, fname); /* p2c: dep_tp.pas, line 133: Note: APPEND does not specify a name [181] */ if (*f != NULL) rewind(*f); else *f = tmpfile(); if (*f == NULL) _EscIO(FileNotFound); } else { assign(*f, fname); rewind(*f); /* p2c: dep_tp.pas, line 139: * Note: Turbo Pascal conditional compilation directive was ignored [218] */ /*$IFNDEF NO_UNIX*/ do { c = getc(*f); } while (!(P_eoln(*f) || c == '\n')); rewind(*f); if (c == '\n') { uxmode = TRUE; /* p2c: dep_tp.pas, line 142: * Warning: Symbol 'UXMODE' is not defined [221] */ } else uxmode = FALSE; if (uxmode) { setvbuf(*f, buf1, _IOFBF, 6144); getTEMPname(tmpname, fname); strcpy(tmpfile_NAME, tmpname); if (tmpfile != NULL) tmpfile = freopen(tmpfile_NAME, "w", tmpfile); else tmpfile = fopen(tmpfile_NAME, "w"); _SETIO(tmpfile != NULL, FileNotFound); /* p2c: dep_tp.pas, line 149: * Note: Make sure setvbuf() call occurs when file is open [200] */ setvbuf(*f, buf2, _IOFBF, 6144); while (!P_eof(*f)) { ureadln(f, (void *)line); if (P_ioresult != 0) goto _Ll_exit; _SETIO(fprintf(tmpfile, "%s\n", line) >= 0, FileWriteError); } if (tmpfile != NULL) fclose(tmpfile); tmpfile = NULL; if (*f != NULL) fclose(*f); *f = NULL; /* p2c: dep_tp.pas, line 157: Note: Encountered an ASSIGN statement [179] */ assign(*f, tmpname); rewind(*f); _Ll_exit: if (P_ioresult != 0) strcpy(depend_err, "could not convert unix format"); } /* p2c: dep_tp.pas, line 145: * Note: Make sure setvbuf() call occurs when file is open [200] */ /*$endif*/ } /* p2c: dep_tp.pas, line 127: Note: Encountered an ASSIGN statement [179] */ if (tmpfile != NULL) fclose(tmpfile); /* p2c: dep_tp.pas, line 132: Note: Encountered an ASSIGN statement [179] */ /* p2c: dep_tp.pas, line 137: Note: Encountered an ASSIGN statement [179] */ } char *substr_(char *Result, void *original, int pos1, int count) { return strsub(Result, (char[256])original, pos1, count); } static long mult(long p, long q) { long p1, p0, q1, q0; p1 = p / rand_m1; p0 = p % rand_m1; /* p2c: dep_tp.pas, line 182: * Note: Using % for possibly-negative arguments [317] */ q1 = q / rand_m1; q0 = q % rand_m1; /* p2c: dep_tp.pas, line 183: * Note: Using % for possibly-negative arguments [317] */ return (((p0 * q1 + p1 * q0) % rand_m1 * rand_m1 + p0 * q0) % rand_m); /* p2c: dep_tp.pas, line 184: * Note: Using % for possibly-negative arguments [317] */ /* p2c: dep_tp.pas, line 184: * Note: Using % for possibly-negative arguments [317] */ } void rand_init(int seed) { rand_a[0] = seed; rand_j = 0; do { rand_j++; rand_a[rand_j] = (mult(rand_b, rand_a[rand_j - 1]) + 1) % rand_m; /* p2c: dep_tp.pas, line 193: * Note: Using % for possibly-negative arguments [317] */ } while (rand_j != 54); } int rand_int(int limit) { /*from 0 to limit-1*/ rand_j = (rand_j + 1) % 55; /* p2c: dep_tp.pas, line 198: * Note: Using % for possibly-negative arguments [317] */ rand_a[rand_j] = (rand_a[(rand_j + 23) % 55] + rand_a[(rand_j + 54) % 55]) % rand_m; /* p2c: dep_tp.pas, line 199: * Note: Using % for possibly-negative arguments [317] */ /* p2c: dep_tp.pas, line 200: * Note: Using % for possibly-negative arguments [317] */ /* p2c: dep_tp.pas, line 200: * Note: Using % for possibly-negative arguments [317] */ return (rand_a[rand_j] / rand_m1 * limit / rand_m1); } double rand_real(void) { /* from 0(incl) to 1(excl) */ return (rand_int(32000) / 32000.0); } typedef char string1[2]; void ureadln(FILE **f, void *line) { BOOL done; char c; char STR1[256]; done = FALSE; *(string1)line = '\0'; do { c = getc(*f); if (c == '\n') done = TRUE; else if (c != '\015') { sprintf(STR1, "%s%c", (char[256])line, c); strcpy((char *)(&line), STR1); } if (P_eoln(*f)) { fscanf(*f, "%*[^\n]"); getc(*f); done = TRUE; } } while (!done); } BOOL getunixmode(char *fname) { BOOL Result; char c; FILE *f; char f_NAME[_FNSIZE]; f = NULL; strcpy(f_NAME, fname); if (f != NULL) f = freopen(f_NAME, "r", f); else f = fopen(f_NAME, "r"); if (f == NULL) _EscIO(FileNotFound); do { c = getc(f); } while (!(c == '\n' || P_eoln(f))); if (c == '\n') Result = TRUE; else Result = FALSE; if (f != NULL) fclose(f); f = NULL; if (f != NULL) fclose(f); return Result; } void _dep_tp_init(void) { static int _was_initialized = 0; if (_was_initialized++) return; filecount = 100; rand_init(1); } #endif boxshade-3.1.1.orig/bx_read.c0100644000175100017510000002503706346046534015724 0ustar moellermoeller#include "bx_read.h" FILE *infile = NULL; char *Gets(char *s) { fflush(stdout); return gets(s); } /* ** Handle all those End-Of-Line sequences: ** ** System CR LF ** MAC X - ** MSDOS X X ** UNIX - X ** VMS ? ? ** ** Does _NOT_ return '\n' !!! */ char *Fgets(char *l, size_t sze, FILE *f) { char *cp = l; BOOL cr, eoln = FALSE; if (f == stdin) return Gets(l); if (feof(f)) return NULL; cr = FALSE; while (sze>1 && !feof(f)) { int c = fgetc(f); if (c == EOF) { if (ferror(f)) return NULL; break; } if (cr && c != '\n') { /* CR end-of-line (MAC) */ ungetc(c,f); eoln = TRUE; break; } else cr = (c=='\r'); if ( cr ) continue; --sze; if (c=='\n') { eoln = TRUE; break; } *(cp++) = c; } *cp = '\0'; cr = FALSE; while (!eoln && !feof(f)) { int c = fgetc(f); if (c == EOF) break; if (cr && c != '\n') { /* CR end-of-line (MAC) */ ungetc(c,f); break; } else cr = (c=='\r'); if ( cr ) continue; if (c=='\n') break; } return l; } void term_par(char *term) { assert(parfile != NULL); rewind(parfile); do { Fgets(line_, 256, parfile); } while (!feof(parfile) && (*line_ != ':' || indx(line_, term) != 2) ); assert(!feof(parfile)); } void read_file_clustal(void) { int i, j, sl; char nametag[41], emptytag[41]; int taglen, seqstart, emptycount; sprintf(emptytag, "%*s", seqnamelen, ""); infile = fopen(inname, TXT_RD); assert(infile != NULL); no_seq = 0; emptycount = 0; do { Fgets(line_, 256, infile); emptycount++; } while (strlen(line_) >= 5); do { Fgets(line_, 256, infile); emptycount++; } while (strlen(line_) <= 12); taglen = 0; do { if ((sl=strlen(line_)) > 12) { i = 1; do { i++; } while (!isspace(line_[i - 1]) && i < sl); taglen = i - 1; do { i++; } while (isspace(line_[i - 1]) && i < sl); if (taglen < 2) { /* seqstart:=i; */ /****** is that correct ??? ******/ strcpy(nametag, emptytag); } else { seqstart = i; strncpy(nametag, line_, taglen); nametag[taglen] = '\0'; } } else strcpy(nametag, emptytag); if (strcmp(nametag, emptytag)) { no_seq++; if (no_seq >= max_no_seq) { printf("OOPS, too many sequences in %s. Sorry, limit is %d!\n", inname, max_no_seq); exit(1); } strcpy(seqname[no_seq - 1], emptytag); startno[no_seq - 1] = 1; if (taglen > seqnamelen) taglen = seqnamelen; for (i = 0; i < taglen; i++) seqname[no_seq-1][i] = nametag[i]; } if (!feof(infile)) { Fgets(line_, 256, infile); } else strcpy(nametag, emptytag); } while (strcmp(nametag, emptytag)); rewind(infile); printf("%s has %d sequences. Reading ", inname, no_seq); fflush(stdout); for (i = 1; i < emptycount; i++) { Fgets(line_, 256, infile); } for (i = 0; i < no_seq; i++) seqlen[i] = 0; while (!feof(infile)) { for (i = 0; i < no_seq; i++) { Fgets(line_, 256, infile); j = 1; while (seqstart + j - 1 <= strlen(line_)) { seq[i][seqlen[i] + j - 1] = toupper(line_[seqstart + j - 2]); j++; } seqlen[i] += j - 1; } if (!feof(infile)) { Fgets(dummystring, 81, infile); } if (feof(infile)) break; Fgets(dummystring, 81, infile); printf("."); fflush(stdout); } if (infile != NULL) fclose(infile); printf(" done\n"); } #define blocklen 10 #define blockno 5 #define blockdist 1 void read_file_pretty(void) { int blockstart, i, j, k; int offs; BOOL found; char nametag[256], tempname[256]; char emptytag[81]; BOOL msfflag, num_mode; infile = NULL; num_mode = FALSE; /*new*/ infile = fopen( inname, TXT_RD); assert(infile != NULL); do { Fgets(line_, 256, infile); } while (!(indx(line_, "..") > 0 || feof(infile))); do { Fgets(line_, 256, infile); } while (!(indx(line_, "//") > 0 || feof(infile))); if (!feof(infile)) msfflag = TRUE; else { msfflag = FALSE; fseek(infile, 0, SEEK_SET); assert(infile != NULL); do { Fgets(line_, 256, infile); } while (indx(line_, "..") <= 0); } Fgets(dummystring, 81, infile); Fgets(line_, 256, infile); /*numbers or first sequence*/ if (indx(line_, " 1 ") > 0) { Fgets(line_, 256, infile); num_mode = TRUE; } blockstart = 1; while (line_[blockstart - 1] == ' ') blockstart++; while (line_[blockstart - 1] != ' ') blockstart++; while (line_[blockstart - 1] == ' ') blockstart++; sprintf(emptytag, "%*s", blockstart, ""); no_seq = 0; fseek(infile, 0, SEEK_SET); assert(infile != NULL); do { Fgets(line_, 256, infile); } while (!(indx(line_, "..") > 0 || feof(infile))); do { Fgets(line_, 256, infile); } while (!(indx(line_, "//") > 0 || feof(infile))); while (Fgets(line_, 256, infile) != NULL) { if (strlen(line_) < blockstart) continue; /* if (!strcmp(substr_(STR1, (void *)line_, 1, blockstart - 1), emptytag)) */ if (! strncmp(line_, emptytag, blockstart - 1) ) continue; *tempname = '\0'; i = 1; while (line_[i - 1] == ' ') i++; while (line_[i - 1] != ' ') { sprintf(tempname + strlen(tempname), "%c", line_[i - 1]); i++; } if (no_seq == 0) { no_seq = 1; strcpy(seqname[0], tempname); continue; } found = FALSE; for (i = 0; i < no_seq; i++) { if (!strcmp(tempname, seqname[i])) found = TRUE; } if (found == FALSE) { no_seq++; strcpy(seqname[no_seq - 1], tempname); } } for (i = 0; i < no_seq; i++) startno[i] = 1; fseek(infile, 0, SEEK_SET); assert(infile != NULL); do { Fgets(line_, 256, infile); } while (indx(line_, "..") <= 0); if (msfflag) { do { Fgets(line_, 256, infile); } while (indx(line_, "//") <= 0); } Fgets(dummystring, 81, infile); if (num_mode) { Fgets(dummystring, 81, infile); } offs = 1; do { i = 1; if (!feof(infile)) { Fgets(line_, 256, infile); } do { if (strlen(line_) >= blockstart) { if (strncmp(line_, emptytag, blockstart-1)) { /* if (strcmp(substr_(STR1, (void *)line_, 1, blockstart - 1), emptytag)) { */ char *cp = nametag; j = 0; while (line_[j] == ' ') j++; while (line_[j] != ' ') { *(cp++) = line_[j]; j++; } *cp = '\0'; while (line_[j] == ' ') j++; blockstart = min(blockstart, j+1); } else *nametag = '\0'; } else *nametag = '\0'; if (strcmp(nametag, seqname[i - 1])) { for (j = -1; j <= blocklen * blockno - 2; j++) seq[i - 1][offs + j] = ' '; } else { for (j = 0; j < blockno; j++) { for (k = -1; k <= blocklen - 2; k++) { if (blockstart + j * (blocklen + blockdist) + k + 1 <= strlen(line_)) seq[i - 1][offs + j * blocklen + k] = toupper( line_[blockstart + j * (blocklen + blockdist) + k]); } } if (!feof(infile)) { Fgets(line_, 256, infile); } } i++; } while (i <= no_seq); offs += blocklen * blockno; if (num_mode && !feof(infile)) { Fgets(line_, 256, infile); } } while (!feof(infile)); for (i = 0; i < no_seq; i++) { int sl; seqlen[i] = offs - 1; if ((sl=strlen(seqname[i])) < seqnamelen) sprintf(seqname[i]+sl, "%*s", seqnamelen-sl, ""); } if (infile != NULL) fclose(infile); infile = NULL; } #undef blocklen #undef blockno #undef blockdist void read_file_maligned(void) { int i, j, sl; char emptytag[256]; infile = NULL; sprintf(emptytag, "%*s", seqnamelen, ""); infile = fopen(inname, TXT_RD); assert(infile != NULL); no_seq = 0; Fgets(line_, 256, infile); Fgets(line_, 256, infile); while (Fgets(line_, 256, infile) != NULL) { if (!feof(infile)) { /*filename*/ Fgets(line_, 256, infile); } if (feof(infile)) continue; no_seq++; strcpy(seqname[no_seq - 1], emptytag); Fgets(line_, 256, infile); j = min(strlen(line_), seqnamelen); for (i = 0; i < j; i++) seqname[no_seq - 1][i] = line_[i]; fscanf(infile, "%d%*[^\n]", &startno[no_seq - 1]); getc(infile); /*seqstart, seqend*/ seqlen[no_seq - 1] = 0; while (!feof(infile) && *line_ != '\0') { Fgets(line_, 256, infile); if (*line_ == '\0') break; sl = strlen(line_); for (j = 0; j < sl; j++) { seq[no_seq-1][seqlen[no_seq-1] + j] = toupper(line_[j]); seqlen[no_seq-1] += j+1; } } } if (infile != NULL) fclose(infile); } void read_file_esee(void) { int i, j; char emptytag[256]; byte b, versno, snl; infile = NULL; sprintf(emptytag, "%*s", seqnamelen, ""); infile = fopen(inname, BIN_RD); assert(infile != NULL); fread(&versno, sizeof(byte), 1, infile); fread(&b, sizeof(byte), 1, infile); no_seq = b; fread(&b, sizeof(byte), 1, infile); no_seq += b * 256; for (i = 0; i < no_seq; i++) { fread(&b, sizeof(byte), 1, infile); seqlen[i] = b; fread(&b, sizeof(byte), 1, infile); seqlen[i] += b * 256 - 1; for (j = 0; j < seqlen[i]; j++) { fread(&b, sizeof(byte), 1, infile); seq[i][j] = toupper(b); } fread(&b, sizeof(byte), 1, infile); if (b != 1) printf("ESEE format error in seq:%2d\n", i + 1); fread(&b, sizeof(byte), 1, infile); snl = b; strcpy(seqname[i], emptytag); startno[i] = 1; for (j = 1; j <= 64; j++) { fread(&b, sizeof(byte), 1, infile); if (j <= snl && j <= seqnamelen) seqname[i][j-1] = b; } for (j = 1; j <= 6; j++) /*linesum*/ fread(&b, sizeof(byte), 1, infile); for (j = 1; j <= 6; j++) /*start*/ fread(&b, sizeof(byte), 1, infile); fread(&b, sizeof(byte), 1, infile); /*type*/ fread(&b, sizeof(byte), 1, infile); /*NrOFF*/ fread(&b, sizeof(byte), 1, infile); /*reverse*/ } if (infile != NULL) fclose(infile); } void read_file_phylip(void) { int i, j, sl; FILE *infile; BOOL firstline; infile = NULL; infile = fopen(inname, TXT_RD); assert(infile != NULL); no_seq = 0; firstline = TRUE; fscanf(infile, "%d%*[^\n]", &no_seq); getc(infile); while (!feof(infile)) { for (i = 0; i < no_seq; i++) { Fgets(line_, 256, infile); if (firstline) { startno[i] = 1; seqlen[i] = 0; strncpy(seqname[i], line_, 10); seqname[i][10] = '\0'; memmove(line_,line_+11, sizeof(line_)-11); } sl = strlen(line_); for (j = 0; j < sl; j++) { if (line_[j] != ' ') { seq[i][seqlen[i]] = line_[j]; seqlen[i]++; } } } Fgets(dummystring, 81, infile); firstline = FALSE; } if (infile != NULL) fclose(infile); } boxshade-3.1.1.orig/bx_read.h0100644000175100017510000000053006346046534015720 0ustar moellermoeller#ifndef BX_READ_H #define BX_READ_H #include "bx_types.h" extern char *Gets(char *s); extern char *Fgets(char *l, size_t sze, FILE *f); extern void read_file_clustal(void); extern void read_file_pretty(void); extern void read_file_maligned(void); extern void read_file_esee(void); extern void read_file_phylip(void); #endif /*BX_READ_H*/ boxshade-3.1.1.orig/bx_types.h0100644000175100017510000001710606346046534016160 0ustar moellermoeller#ifndef BX_TYPES_H #define BX_TYPES_H #include #include #include #include #include #ifdef BX_TYPES_G # define vextern #else # define vextern extern #endif #if (defined(__TURBOC__) || defined(GO32)) #ifndef MSDOS #define MSDOS #endif #undef UNIX #undef MAC #endif #ifdef MSDOS #define BIN_RD "rb" #define TXT_RD "rt" #define BIN_WR "wb" #define TXT_WR "wt" #define c_sep '/' /* command line separator */ #define C_SEP "/" /* command line separator */ #define d_sep '\\' /* directory separator */ #else #define BIN_RD "r" #define TXT_RD "r" #define BIN_WR "w" #define TXT_WR "w" #define c_sep '-' /* command line separator */ #define C_SEP "-" /* command line separator */ #define d_sep '/' /* directory separator */ #endif #define oPS '1' #define oEPS '2' #define oHPGL '3' #define oRTF '4' #if (defined(__TURBOC__) || defined(GO32)) && !defined(_Windows) #define oCRT '5' #endif #define oANSI '6' #define oVT '7' #define oREGISt '8' #define oREGISp '9' #define oLJ250 'a' #define oASCII 'b' #define oFIG 'c' #define oPICT 'd' #define oHTML 'e' #ifdef oCRT #define allowed_devices "123456789abcde" #else #define allowed_devices "12346789abcde" #endif /* #if defined(__TURBOC__) && !defined(_Windows) #define MAX_NO_RES 5000 #else */ #define MAX_NO_RES 10000 /* #endif */ #define MAX_NO_SEQ 150 vextern unsigned max_no_seq; vextern unsigned max_no_res; /* if one allows a large number of residues, and someone sets a short line length, there will be too many blocks. Therefore, the minimum linelength is set here equal to max_no_res/max_no_block to prevent errors in accessing the prenum array. */ #define min_outlen ((long)((double)max_no_res / max_no_block)) #define max_no_block 400 #define max_outlen 255 #define max_linelen 255 /* defines linetype */ #define seqnamelen 40 /* defines sseqnametype */ #define seqnumlen 4 /* defines numtype */ #define idpref 1 #define simpref 1 typedef int BOOL; #ifndef TRUE #define TRUE ((BOOL)(1==1)) #endif #ifndef FALSE #define FALSE ((BOOL)(1==0)) #endif #define YESNO(fl) ((fl) ? 'y' : 'n') typedef struct { FILE *f; BOOL bin; } MYFILE; typedef unsigned char byte; typedef char **seqtype; typedef byte **coltype; #define max_prenum_len (seqnumlen+1) typedef char numtype[max_prenum_len]; typedef numtype **prenumtype; typedef char linetype[256]; typedef char sseqnametype[41]; typedef sseqnametype seqnametype[MAX_NO_SEQ]; typedef BOOL cmptype[20][20]; typedef char filenametype[256]; typedef char prestring[21]; typedef char txtstring[21]; typedef char parstringtype[6]; typedef enum { Init, SetCol, CharOut, NewLine, NewPage, Exit } actiontype; typedef enum { rTERM, rPAGE } regmodetype; typedef enum { EOL_default, EOL_unix, EOL_mac, EOL_dos } EOLstate; typedef char cltagtype[21]; typedef char cllinetype[256]; extern char *aaset, *aasetlow; extern MYFILE outfile; extern FILE *parfile; vextern char dummystring[81]; /* vextern int errcode;*/ /*turbo-specific IO-error indicator*/ vextern seqtype seq; /*all sequences (characters)*/ vextern int consenslen; /*maximum sequence length */ vextern int seqlen[MAX_NO_SEQ]; /*all sequence lengths*/ vextern int startno[MAX_NO_SEQ]; /*all sequence starts*/ vextern prenumtype prenum; /*blocknumbers for output*/ vextern coltype col; /*all sequences (cell colors)*/ vextern char *cons; /*the consensus sequence*/ vextern char *conschar; /*line for consensus display*/ vextern seqnametype seqname; /*all sequence names*/ vextern linetype line_; /* line input bufer */ vextern int thr; vextern double thrfrac; vextern int no_seq; /*how many sequences*/ vextern int outlen; /*length of an output block*/ vextern int seqname_outlen; /*output length of seqnames*/ vextern int no_blocks; /*output how many blocks*/ vextern int lines_per_page; /*how many lines per page*/ vextern int lines_left; /*how many lines left to print*/ vextern filenametype inname, outname, identname, simname, grpname, parname, clsimname, clgrpname; /*misc. filenames*/ vextern cmptype simtable, grptable; vextern char outputmode; /*PS, EPS, HPGL, RTF, (CRT), ANSI, VT100, ReGISterm*/ /*ReGISprint, LJ250, ASCII, PICT*/ vextern char inputmode; /*1=Lineup, 2=Clustal, 3=Maligned, 4=ESEE*/ vextern int consensnum; /* sequence to make consensus to */ vextern BOOL lc[5]; vextern BOOL ident_sim, simflag; /*mark similar residues?*/ vextern BOOL globalflag; /*mark globally consvd. residues?*/ vextern int interlines; /*how many lines between blocks*/ vextern BOOL seqnameflag; /*sequence names to be printed*/ vextern BOOL seqnumflag; /*position numbers to be printed*/ vextern BOOL rulerflag; /*print ruler?*/ vextern BOOL seqconsflag; /*consensus to a master sequence*/ vextern BOOL hideflag; /*hide master sequence*/ vextern BOOL masternormal; /*print master sequence all-normal*/ vextern BOOL dnaflag; /*DNA or proteins to be aligned*/ vextern BOOL interactflag; /*interaction with user?*/ vextern BOOL clinflag; /*input filename in commandline?*/ vextern BOOL cloutflag; /*output filename in commandline?*/ vextern BOOL clparflag; /*param filename in commandline?*/ vextern BOOL clsimflag; /*file name for similar residues in cmdline?*/ vextern BOOL clgrpflag; /*file name for grouping residues in cmdline?*/ vextern BOOL cltypeflag; /*input file type in commandline?*/ vextern BOOL cldevflag; /*output device type in comline?*/ vextern BOOL clconsflag; /*cons requested in commandline?*/ vextern BOOL clsymbconsflag; /*symbcons defined in commandline?*/ vextern BOOL clthrflag; /*threshold defined in commandline?*/ vextern BOOL consflag; /*display consensus line?*/ vextern BOOL clseqconsflag; /*sequence to compare others to specified in command line?*/ vextern BOOL splitflag; /*multiple file output?*/ vextern BOOL numdefflag; /*default numbering?*/ vextern EOLstate EOLmode; /* select EOL code of text output */ vextern BOOL shadeonlyflag; /*write only the shading to PICT file?*/ vextern char symbcons[3]; /*symbols for consensus*/ vextern double dev_maxx, dev_maxy; /*maximal device coordinates*/ vextern double dev_miny, dev_minx; /*minimal device coordinates*/ vextern double dev_ysize,dev_xsize;/*character sizes for device*/ vextern int act_color; /*actual color*/ vextern int act_page; /*actual page no*/ vextern BOOL landscapeflag; #define depend_mode "tp" extern char depend_err[]; #undef min extern int min(int a, int b); extern BOOL fexist(char *fname); extern int indx(char *mainstring, char *substring); extern MYFILE *outopen(MYFILE *mf, char *fn); extern void uwriteln(MYFILE *f, char *fmt, ...); extern void term_par(char *term); extern int str2int(void *s); extern double str2real(void *s); extern void save_binpath(char *arg0); extern char *get_logical(char *logical); extern void *Malloc(size_t sze); #define Free(p) do { \ if ((*(p)) != NULL) { \ free(*(p)); \ (*(p)) = NULL; \ } \ } while (0) /*extern void Free(void *p);*/ #undef vextern #endif /*BX_TYPES_H*/ boxshade-3.1.1.orig/clust160.grp0100644000175100017510000000066206346046534016244 0ustar moellermoellerThis file is a Amino-acid grouping file for use with NEWBOX. Each line contains a set of amino acids which are considered 'similar' when calculating the consensus. The .SIM file is different and is used in colouring residues that are "similar" to a single consensus residue. This table was taken from ClustalW v1.60 Other format requirements are the same as for SIMPLIFY.TXT in the GCG-package. .. ACST NT EQ NQ ED KRQH GN NH FY IVLM boxshade-3.1.1.orig/clust160.sim0100644000175100017510000000130406346046534016236 0ustar moellermoellerThis file is a Amino-acid similarity file for use with BOX. Is resembles the GCG simplify.txt, but similarities contained in this file are not automatically set-forming. This means: The line I LVM means that I is similar to L,V and M and also that L,V,M are similar to I. It does not imply that L is similar to V or to M. For achieving this, more lines (the next ones) are necessary. Although is seems weird, this feature has been chosen DELIBERATELY because I think it could be helpful in some cases. Other format requirements are the same as for SIMPLIFY.TXT in the GCG-package. .. F YW Y WF W YF I LVM L VMI V MVI R KH K HR H RK G A A GS T S S TA D EN E DQ N QD Q NE boxshade-3.1.1.orig/dv_all.h0100644000175100017510000000176506346046534015570 0ustar moellermoeller/* Header for module bx_dev, generated by p2c */ #ifndef _DV_ALL_HEADER_ #define _DV_ALL_HEADER_ #include "bx_types.h" #include "bx_read.h" typedef struct { char *dev; void (*Ask)(void); void (*Init)(double *xpos, double *ypos); void (*Setcolor)(int colno); void (*Charout)(char c, double *xpos, double *ypos); void (*Stringout)(char *s, double *xpos, double *ypos); void (*Newline)(double *xpos, double *ypos); void (*Newpage)(double *xpos, double *ypos); void (*Exit)(void); } GraphicsDevice; extern GraphicsDevice Ansi; extern GraphicsDevice Ascii; #ifdef oCRT extern GraphicsDevice Crt; #endif extern GraphicsDevice Rtf; extern GraphicsDevice Pict; extern GraphicsDevice Postscript; extern GraphicsDevice Eps; extern GraphicsDevice Hpgl; extern GraphicsDevice Lj250; extern GraphicsDevice Fig; extern GraphicsDevice RegisT, RegisP; extern GraphicsDevice Vt; extern GraphicsDevice Html; extern void GenericStringOut(char *s, double *xpos, double *ypos); #endif /* _DV_ALL_HEADER_ */ boxshade-3.1.1.orig/dv_ansi.c0100644000175100017510000000725706346046535015750 0ustar moellermoeller#include "dv_all.h" #define ESC "\x1b" static char *pre_reset; static char *pre[5]; /*------------------------------------*/ /* ANSI-Terminal specific section */ /*------------------------------------*/ static void menu_ansi(char **pre, BOOL *lc, char *txt, char *parstring) { char code; char instring[41]; if (interactflag) { printf("\n-------------------------------------------------------------\n"); printf("Enter the text attributes for printing of >%s< residues:\n", txt); printf("Different letters specify renditions,\n" "lowercase choices mean lowercase residues:\n" "(N,n) normal (B,b) bold (U,u) underscore (R,r) reverse\n" "(F,f) flashing (E,e) reverse/bold (L,l) reverse/flashing\n\n" "choose from NnBbUuRrFfEeLl ( * %c * ) : ", parstring[0]); Fgets(instring, 41, stdin); } else *instring = '\0'; if (*instring == '\0') code = parstring[0]; else code = instring[0]; if (strchr("NBURELF", toupper(code)) == NULL) code = 'N'; *lc = islower(code); code = toupper(code); switch (code) { case 'N': *pre = ESC "[0m"; break; case 'B': *pre = ESC "[0;1m"; break; case 'U': *pre = ESC "[0;4m"; break; case 'R': *pre = ESC "[0;7m"; break; case 'E': *pre = ESC "[0;1;7m"; break; case 'L': *pre = ESC "[0;5;7m"; break; case 'F': *pre = ESC "[0;5m"; break; } } static void ask(char *term) { char parstring[6]; term_par(term); if (interactflag) printf("-------------------------------------------------------------\n"); pre_reset = ESC "[0m"; Fgets(parstring, 6, parfile); parstring[2] = '\0'; menu_ansi(&pre[0], lc, "different", parstring); Fgets(parstring, 6, parfile); parstring[2] = '\0'; menu_ansi(&pre[1], &lc[1], "identical", parstring); Fgets(parstring, 6, parfile); parstring[2] = '\0'; if (simflag) menu_ansi(&pre[2], &lc[2], "similar", parstring); else { pre[2] = pre[0]; lc[2] = lc[0]; } Fgets(parstring, 6, parfile); parstring[2] = '\0'; if (globalflag) menu_ansi(&pre[3], &lc[3], "conserved", parstring); else { pre[3] = pre[1]; lc[3] = lc[1]; } pre[4] = ESC "[0m"; lc[4] = FALSE; if (!cloutflag) { printf("filename for %s-output (return for terminal) : ", term); gets(outname); } } static void ask_vt(void) { ask("VT"); } static void ask_ansi(void) { ask("ANSI"); } /* ------------------- output functions */ static void VTinit(double *xpos, double *ypos) { if (*outname == '\0') { outfile.f = stdout; outfile.bin = FALSE; } else assert(outopen(&outfile, outname) != NULL); fputs(ESC "[2J" ESC "[0;0H", outfile.f); fputs(pre_reset, outfile.f); dev_minx = 0.0; dev_miny = 1.0; dev_maxx = 80.0; dev_maxy = 25.0; dev_xsize = 1.0; dev_ysize = 1.0; *xpos = dev_minx; *ypos = dev_miny; } static void VTsetcolor(int colno) { fputs(pre[colno], outfile.f); } static void VTcharout(char c, double *xpos, double *ypos) { putc(c, outfile.f); *xpos += dev_xsize; } static void VTnewline(double *xpos, double *ypos) { uwriteln(&outfile, pre_reset); *xpos = dev_minx; *ypos += dev_ysize; } static void VTnewpage(double *xpos, double *ypos) { printf("\007"); fflush(stdout); scanf("%*[^\n]"); getchar(); *xpos = dev_minx; *ypos = dev_miny; } static void VTexit(void) { uwriteln(&outfile, pre_reset); if (outfile.f != NULL && outfile.f != stdout) fclose(outfile.f); outfile.f = NULL; } GraphicsDevice Ansi = { "ANSI", ask_ansi, VTinit, VTsetcolor, VTcharout, GenericStringOut, VTnewline, VTnewpage, VTexit }; GraphicsDevice Vt = { "VT100", ask_vt, VTinit, VTsetcolor, VTcharout, GenericStringOut, VTnewline, VTnewpage, VTexit }; boxshade-3.1.1.orig/dv_ascii.c0100644000175100017510000000610406346046535016074 0ustar moellermoeller#include "dv_all.h" static char acs[5]; /*ASCII sprecific vars*/ static char ascii_char; /*------------------------------------*/ /* ASCII specific section */ /*------------------------------------*/ static void menu_ascii(char *acs, BOOL *lc, char *txt, char *parstring) { char code; char instring[41]; if (interactflag) { printf("\n-------------------------------------------------------------\n" "This output method should only be used in conjunction with\n" "\"shading according to a single sequence\"\n" "Enter the symbol used for printing of >%s< residues:\n", txt); printf("(L,l) the letter itself, in upper- or lower case, respectively\n" "or type any other on-character symbol (like . or - )\n" "the blank-character should be enclosed in quotes\n\n" "type one character ( * %c * ) : ", parstring[0]); Fgets(instring, 41, stdin); } else *instring = '\0'; if (strlen(instring) == 3) instring[0] = instring[1]; if (*instring == '\0') code = parstring[0]; else code = instring[0]; *lc = islower(code); code = toupper(code); *acs = code; } static void ask_ascii(void) { char parstring[6]; term_par("ASCII"); if (interactflag) printf("-------------------------------------------------------------\n"); Fgets(parstring, 6, parfile); parstring[2] = '\0'; menu_ascii(acs, lc, "different", parstring); Fgets(parstring, 6, parfile); parstring[2] = '\0'; menu_ascii(&acs[1], &lc[1], "identical", parstring); Fgets(parstring, 6, parfile); parstring[2] = '\0'; if (simflag) menu_ascii(&acs[2], &lc[2], "similar", parstring); else { acs[2] = acs[0]; lc[2] = lc[0]; } Fgets(parstring, 6, parfile); parstring[2] = '\0'; if (globalflag) menu_ascii(&acs[3], &lc[3], "conserved", parstring); else { acs[3] = acs[1]; lc[3] = lc[1]; } acs[4] = 'L'; lc[4] = FALSE; if (!cloutflag) { printf("filename for ASCII-output (return for terminal) : "); gets(outname); } } static void ASCinit(double *xpos, double *ypos) { if (*outname == '\0') { outfile.f = stdout; outfile.bin = FALSE; } else assert(outopen(&outfile, outname) != NULL); dev_minx = 0.0; dev_miny = 1.0; dev_maxx = 255.0; dev_maxy = 10000.0; dev_xsize = 1.0; dev_ysize = 1.0; *xpos = dev_minx; *ypos = dev_miny; } static void ASCsetcolor(int colno) { ascii_char = acs[colno]; } static void ASCcharout(char c, double *xpos, double *ypos) { if (toupper(ascii_char) == 'L') putc(c, outfile.f); else putc(ascii_char, outfile.f); *xpos += dev_xsize; } static void ASCnewline(double *xpos, double *ypos) { uwriteln(&outfile, ""); *xpos = dev_minx; *ypos += dev_ysize; } static void ASCnewpage(double *xpos, double *ypos) { *xpos = dev_minx; *ypos = dev_miny; } static void ASCexit(void) { uwriteln(&outfile, ""); if (outfile.f != NULL && outfile.f != stdout) fclose(outfile.f); outfile.f = NULL; } GraphicsDevice Ascii = { "ASCII", ask_ascii, ASCinit, ASCsetcolor, ASCcharout, GenericStringOut, ASCnewline, ASCnewpage, ASCexit }; boxshade-3.1.1.orig/dv_crt.c0100644000175100017510000001025406346046535015575 0ustar moellermoeller#include "dv_all.h" #ifdef oCRT typedef struct crtrecord { byte bgnd, fgnd; } crtrecord; static crtrecord crtrec[5]; /* CRT-specifics*/ static struct text_info ti; #include /*----------------------------------------*/ /* CRT specific section */ /*----------------------------------------*/ static void menu_crt(crtrecord *crtrec, BOOL *lc, char *txt, char *parstring) { char code; char instring[41]; if (interactflag) { printf("\n-------------------------------------------------------------\n" "Enter the text attributes for printing of ***>%s<*** residues:\n", txt); printf("First choose the color/gray-value of the letter ***>background<***\n" "Different letters specify different colors,\n" "(R) red (G) green (U) blue \n" "(B) black (L) light gray\n\n" "choose from RGUYDL ( * %c * ) : ", parstring[0]); Fgets(instring, 41, stdin); } else *instring = '\0'; if (*instring == '\0') code = parstring[0]; else code = instring[0]; code = toupper(code); if (strchr("RGUYDL", code) == NULL) code = 'R'; switch (code) { case 'B': crtrec->bgnd = BLACK; break; case 'R': crtrec->bgnd = RED; break; case 'G': crtrec->bgnd = GREEN; break; case 'U': crtrec->bgnd = BLUE; break; case 'L': crtrec->bgnd = LIGHTGRAY; break; } if (interactflag) { printf("\n\nNow choose the color/gray-value of the letter **>foreground<**\n" "lowercase choices mean lowercase letters in the sequence:\n" "(R,r) red (G,g) green (U,u) blue (Y,y) yellow\n" "(B,b) black (W,w) white (D,d) dark gray (L,l) light gray\n\n" "choose from RrGgUuYyBbWwDdLl ( * %c * ) : ", parstring[1]); Fgets(instring, 41, stdin); } else *instring = '\0'; if (*instring == '\0') code = parstring[1]; else code = instring[0]; if (strchr("BWRGUYDL", toupper(code)) == NULL) code = 'B'; *lc = islower(code); code = toupper(code); switch (code) { case 'B': crtrec->fgnd = BLACK; break; case 'W': crtrec->fgnd = WHITE; break; case 'R': crtrec->fgnd = RED; break; case 'G': crtrec->fgnd = GREEN; break; case 'U': crtrec->fgnd = BLUE; break; case 'Y': crtrec->fgnd = YELLOW; break; case 'D': crtrec->fgnd = DARKGRAY; break; case 'L': crtrec->fgnd = LIGHTGRAY; break; } } static void ask_crt(void) { char parstring[6]; term_par("CRT"); if (interactflag) printf("-------------------------------------------------------------\n"); Fgets(parstring, 6, parfile); parstring[2] = '\0'; menu_crt(crtrec, lc, "different", parstring); Fgets(parstring, 6, parfile); parstring[2] = '\0'; menu_crt(&crtrec[1], &lc[1], "identical", parstring); Fgets(parstring, 6, parfile); parstring[2] = '\0'; if (simflag) menu_crt(&crtrec[2], &lc[2], "similar", parstring); else { crtrec[2] = crtrec[0]; lc[2] = lc[0]; } Fgets(parstring, 6, parfile); parstring[2] = '\0'; if (globalflag) menu_crt(&crtrec[3], &lc[3], "conserved", parstring); else { crtrec[3] = crtrec[1]; lc[3] = lc[1]; } crtrec[4] = crtrec[0]; lc[4] = lc[0]; } static void CRTinit(double *xpos, double *ypos) { gettextinfo(&ti); dev_minx = 0.0; dev_miny = 1.0; dev_maxx = ti.screenwidth; dev_maxy = ti.screenheight; dev_xsize = 1.0; dev_ysize = 1.0; *xpos = dev_minx; *ypos = dev_maxy; textbackground(crtrec[0].bgnd); textcolor(crtrec[0].fgnd); clrscr(); } static void CRTsetcolor(int colno) { textbackground(crtrec[colno].bgnd); textcolor(crtrec[colno].fgnd); } static void CRTcharout(char c, double *xpos, double *ypos) { putch(c); *xpos += dev_xsize; } static void CRTnewline(double *xpos, double *ypos) { textbackground(crtrec[0].bgnd); textcolor(crtrec[0].fgnd); cprintf("\r\n"); *xpos = dev_minx; *ypos -= dev_ysize; } static void CRTnewpage(double *xpos, double *ypos) { scanf("%*[^\n]"); getchar(); *xpos = dev_minx; *ypos = dev_miny; } static void CRTexit(void) { normvideo(); clreol(); } GraphicsDevice Crt = { "CRT", ask_crt, CRTinit, CRTsetcolor, CRTcharout, GenericStringOut, CRTnewline, CRTnewpage, CRTexit }; #endif boxshade-3.1.1.orig/dv_fig.c0100644000175100017510000001467506346046535015565 0ustar moellermoeller#include "dv_all.h" /*--------------------------------------------------------------------------*/ /* fig specific section */ /*--------------------------------------------------------------------------*/ typedef struct figrecord { int bgnd, fgnd, fontno; } figrecord; static int fig_fontsize; /* XFIG specifics */ static int fig_fontno_offset; /* 0=Tms,12=Cour,16=Helv,28=Palat */ static figrecord figrec[5]; static int fig_fontno; /* current values go here*/ static int fig_fgnd, fig_bgnd; /* ... to here*/ static void menu_fig(figrecord *figrec, BOOL *lc, char *txt, char *parstring) { char code; char instring[51]; if (interactflag) { printf("\n----------------------------------------------------------------\n" "Enter the text attributes for printing of **>%s<** residues:\n", txt); printf("First choose the color/gray-value of the letter **>background<**\n" "Different letters specify different colors,\n" "(B) black (W) white (1,2,3,4) 4 different gray values, 4 is darkest\n\n" "choose from BW1234 ( * %c * ) : ", parstring[0]); Fgets(instring, 51, stdin); } else *instring = '\0'; if (*instring == '\0') code = parstring[0]; else code = instring[0]; code = toupper(code); if (strchr("BW1234", code) == NULL) code = 'W'; switch (code) { case 'B': figrec->bgnd = 21; break; case 'W': figrec->bgnd = 0; break; case '1': figrec->bgnd = 4; break; case '2': figrec->bgnd = 8; break; case '3': figrec->bgnd = 12; break; case '4': figrec->bgnd = 16; break; } if (interactflag) { printf("\n\nNow choose the color/gray-value of the letter **>foreground<**\n" "lowercase choices mean lowercase letters in the sequence:\n" "(B,b) black,normal (E,e) black, emphasized\n" "(W,w) white normal (F,f) white, emphasized\n" "(L,l) Blue (M,m) Magenta (Y,y) Yellow (G,g) Green (R,r) Red\n\n" "choose from BbEeWwFfLlMmYyGgRr ( * %c * ) : ", parstring[1]); Fgets(instring, 51, stdin); } else *instring = '\0'; if (*instring == '\0') code = parstring[1]; else code = instring[0]; if (strchr("BEWFLMYGR", toupper(code)) == NULL) code = 'B'; *lc = islower(code); code = toupper(code); switch (code) { case 'B': figrec->fgnd = 0; figrec->fontno = 0; break; case 'E': figrec->fgnd = 0; figrec->fontno = 2; break; case 'W': figrec->fgnd = 7; figrec->fontno = 0; break; case 'F': figrec->fgnd = 7; figrec->fontno = 2; break; case 'L': figrec->fgnd = 1; figrec->fontno = 0; break; case 'M': figrec->fgnd = 5; figrec->fontno = 0; break; case 'Y': figrec->fgnd = 6; figrec->fontno = 0; break; case 'G': figrec->fgnd = 2; figrec->fontno = 0; break; case 'R': figrec->fgnd = 4; figrec->fontno = 0; break; } } static void ask_fig(void) { char parstring[6]; char instring[41]; term_par("FIG"); if (interactflag) printf("-------------------------------------------------------------\n"); Fgets(parstring, 6, parfile); parstring[2] = '\0'; menu_fig(&figrec[0], &lc[0], "different", parstring); Fgets(parstring, 6, parfile); parstring[2] = '\0'; menu_fig(&figrec[1], &lc[1], "identical", parstring); Fgets(parstring, 6, parfile); parstring[2] = '\0'; if (simflag) menu_fig(&figrec[2], &lc[2], "similar", parstring); else { figrec[2] = figrec[0]; lc[2] = lc[0]; } Fgets(parstring, 6, parfile); parstring[2] = '\0'; if (globalflag) menu_fig(&figrec[3], &lc[3], "conserved", parstring); else { figrec[3] = figrec[1]; lc[3] = lc[1]; } figrec[4].bgnd = 0; figrec[4].fgnd = 0; figrec[4].fontno = 0; lc[4] = FALSE; fscanf(parfile, "%d%*[^\n]", &fig_fontno_offset); getc(parfile); fscanf(parfile, "%d%*[^\n]", &fig_fontsize); getc(parfile); if (interactflag) { do { printf("Character size in Points ( * %4d * ) : ", fig_fontsize); Fgets(instring, 41, stdin); if (*instring != '\0') fig_fontsize = str2int((void *)instring); } while (fig_fontsize < 1 || fig_fontsize > 100); } if (!cloutflag) { printf("name of fig-file : "); gets(outname); } } static void FIGinit(double *xpos, double *ypos) { assert(outopen(&outfile, outname) != NULL); dev_minx = fig_fontsize * 4.0; dev_miny = fig_fontsize * 4.0; dev_maxx = 10000.0; dev_maxy = 10000.0; dev_xsize = fig_fontsize + 1.0; dev_ysize = fig_fontsize; *xpos = dev_minx; *ypos = dev_miny; uwriteln(&outfile, "#FIG 2.1"); uwriteln(&outfile, "80 2"); } static void FIGsetcolor(int colno) { dev_xsize = fig_fontsize + 1.0; fig_fontno = fig_fontno_offset + figrec[colno].fontno; fig_fgnd = figrec[colno].fgnd; fig_bgnd = figrec[colno].bgnd; } static void FIGcharout(char c, double *xpos, double *ypos) { if (fig_bgnd > 0) { /*draw box*/ double bxshift, byshift; int bx1, by1, bx2, by2; bxshift = fig_fontsize * 0.25; byshift = fig_fontsize * 0.15; bx1 = (int)(*xpos + 0.5 - bxshift); bx2 = (int)(*xpos + dev_xsize + 0.5 - bxshift); by2 = (int)(*ypos + 0.5 + byshift); by1 = (int)(*ypos - dev_ysize + 0.5 + byshift); /*compound object*/ uwriteln(&outfile, "6 %5d%5d%5d%5d", bx2, by1, bx1, by2); uwriteln(&outfile, "2 2 0 0 0 5 0 " /*box*/ "%3d 0.0 0 0 0", fig_bgnd); fprintf(outfile.f, "\t "); fprintf(outfile.f, "%5d%5d%5d%5d%5d%5d", bx2, by2, bx2, by1, bx1, by1); uwriteln(&outfile, "%5d%5d%5d%5d 9999 9999", bx1, by2, bx2, by2); } fprintf(outfile.f, "4 0 %2d%3d", fig_fontno, fig_fontsize); fprintf(outfile.f, " 0 %2d 0 0.0 4 ", fig_fgnd); fprintf(outfile.f, "%3ld%3ld",(long)(dev_ysize+0.5), (long)(dev_xsize+0.5)); fprintf(outfile.f, "%5ld%5ld %c",(long)(*xpos+0.5), (long)(*ypos+0.5), c); uwriteln(&outfile, "\001"); if (fig_bgnd > 0) /*end of compound*/ uwriteln(&outfile, "-6"); *xpos += dev_xsize; } static void FIGnewline(double *xpos, double *ypos) { *xpos = dev_minx; *ypos += dev_ysize; } static void FIGnewpage(double *xpos, double *ypos) { /* this should never happen*/ FIGnewline(xpos, ypos); } static void FIGexit(void) { if (outfile.f != NULL) fclose(outfile.f); outfile.f = NULL; } GraphicsDevice Fig = { "fig", ask_fig, FIGinit, FIGsetcolor, FIGcharout, GenericStringOut, FIGnewline, FIGnewpage, FIGexit }; boxshade-3.1.1.orig/dv_hpgl.c0100644000175100017510000002100406346046535015732 0ustar moellermoeller#include "dv_all.h" #include /*----------------------------------------*/ /* HPGL specific section */ /*----------------------------------------*/ typedef struct hpglrecord { char *hatch; int bgnd, fgnd; } hpglrecord; static hpglrecord hpglrec[5]; /* HPGL-specifics*/ static double hpglcell; /* character cell size */ static int actcol; /* actual color No. */ static int hpglpen; /* actual pen No. (1-8/0) */ static char *hpglhatch; /* actual hatch type */ #define HATCHES 4 static char *hatches[HATCHES] = { "", "3,0.8,45", "4,0.8,0", "1" }; /* -------------- VERY simple output optimizer */ typedef struct { char c; byte col; float px, py; } STORE; #define MAX_STORE 256 static STORE store[MAX_STORE]; static int store_idx = 0; static int print_len = 0; static char buf[100]; static void print(char *fmt, ...) { va_list argptr; int len; va_start(argptr, fmt); len = vsprintf(buf, fmt, argptr); va_end(argptr); if (print_len+len > 78) { uwriteln(&outfile, ""); print_len = 0; } fprintf(outfile.f, "%s", buf); print_len += len; } /* select a new pen */ static int select_pen(int pen) { if (pen != hpglpen) { hpglpen = pen; print("SP%d;", hpglpen); return TRUE; } return FALSE; } /* write out all stored characters */ static void flush_fg(int pen) { int idx; for (idx = 0; idx < store_idx; ++idx) { if ( store[idx].c != ' ' && hpglrec[store[idx].col].fgnd == pen ) { select_pen(pen); print("PU%1.2f,%1.2f;", store[idx].px, store[idx].py); print("LB%c\003;", store[idx].c); } } } /* draw all saved background shadings */ static void flush_bg(int pen) { int idx, h; if (pen <= 0) return; for (idx = 0; idx < store_idx; ++idx) { if (hpglrec[store[idx].col].bgnd != pen) continue; for (h = 0; h < HATCHES; ++h) { if (hpglrec[store[idx].col].hatch == hatches[h]) { double act_x = store[idx].px - dev_xsize/8; double act_y = store[idx].py - dev_ysize/4; select_pen(pen); print("PU%1.2f,%1.2f;", act_x, act_y); if (hatches[h] != hpglhatch) { hpglhatch = hatches[h]; print("FT%s;", hpglhatch); } print("RR%1.2f,%1.2f;", dev_xsize, dev_ysize); } } } } /* save stored character cells */ static void store_flush(void) { int p, sp; /* first background */ sp = hpglpen; flush_bg(sp); /* actual pen first */ for (p=1; p < 10; ++p) if (p!=sp) flush_bg(p); /* then foreground */ sp = hpglpen; flush_fg(sp); /* actual pen first */ for (p=0; p < 10; ++p) if (p!=sp) flush_fg(p); store_idx = 0; } /* save a character for optimizing HPGL output */ static void store_char(char c, int col, double px, double py) { store[store_idx].c = c; store[store_idx].px = (float) px; store[store_idx].py = (float) py; store[store_idx].col= (byte) col; ++store_idx; if (store_idx == MAX_STORE) store_flush(); } /* - - - - - - - - - - - - - - */ static void menu_hpgl(hpglrecord *hpglrec, BOOL *lc, char *txt, char *parstring) { char code1, code2; char instring[41]; if (interactflag) { printf("\n-------------------------------------------------------------\n" "Enter the text attributes for printing of **>%s<** residues:\n", txt); printf("First choose color and hatching type of the letter **>background<**\n" "NUMBERS specify plotter Pens,\n" "LETTERS specify hatching types.\n" "input has to be composed of a number and a letter\n" "1-9, 0 : PEN No. (0 means no background)\n" "(N) : no hatching (S) : slash\n" "(C) : crosshatch (F) : fill\n\n" "choose a number and a letter ( * %c%c * ) : ", parstring[0], parstring[1]); Fgets(instring, 41, stdin); } else *instring = '\0'; if (*instring == '\0') { code1 = parstring[0]; code2 = parstring[1]; } else { code1 = instring[0]; code2 = instring[1]; } code1 = toupper(code1); code2 = toupper(code2); if (strchr("NSCF", code2) == NULL) code2 = 'N'; switch (code2) { case 'N': hpglrec->hatch = hatches[0]; break; case 'S': hpglrec->hatch = hatches[1]; break; case 'C': hpglrec->hatch = hatches[2]; break; case 'F': hpglrec->hatch = hatches[3]; break; } hpglrec->bgnd = code1-'0'; if (interactflag) { printf("\n\nEnter the text attributes for printing of **>%s<** residues:\n", txt); printf("Now choose color and case of the letter **>foreground<**\n" "NUMBERS specify plotter Pens,\n" "A letter \"n\" behind the number means \"normal printing\"\n" "A letter \"l\" behind the number means \"lowercase printing\"\n" "1-9, 0 : PEN No. (0 means no printing)\n" "e.g. \"1n\" means : PEN #1 is to be used\n" "e.g. \"2l\" means : PEN #2 and lowercase types are to be used\n\n" "choose a number and a letter ( * %c%c * ) : ", parstring[2], parstring[3]); Fgets(instring, 41, stdin); } else *instring = '\0'; if (*instring == '\0') { code1 = parstring[2]; code2 = parstring[3]; } else { code1 = instring[0]; code2 = instring[1]; } if (code2 == 'L' || code2 == 'l') *lc = TRUE; else *lc = FALSE; hpglrec->fgnd = code1 - '0'; } static void ask_hpgl(void) { char parstring[6]; char instring[41]; term_par("HPGL"); if (interactflag) printf( "-----------------------------------------------------------------------\n"); Fgets(parstring, 6, parfile); parstring[4] = '\0'; menu_hpgl(hpglrec, lc, "different", parstring); Fgets(parstring, 6, parfile); parstring[4] = '\0'; menu_hpgl(&hpglrec[1], &lc[1], "identical", parstring); Fgets(parstring, 6, parfile); parstring[4] = '\0'; if (simflag) menu_hpgl(&hpglrec[2], &lc[2], "similar", parstring); else { hpglrec[2] = hpglrec[0]; lc[2] = lc[0]; } Fgets(parstring, 6, parfile); parstring[4] = '\0'; if (globalflag) menu_hpgl(&hpglrec[3], &lc[3], "conserved", parstring); else { hpglrec[3] = hpglrec[1]; lc[3] = lc[1]; } hpglrec[4].bgnd = 0; hpglrec[4].hatch = hatches[0]; hpglrec[4].fgnd = hpglrec[0].fgnd; lc[4] = FALSE; fscanf(parfile, "%lg%*[^\n]", &hpglcell); getc(parfile); Fgets(parstring, 6, parfile); if (parstring[0] == 'Y' || parstring[0] == 'y') landscapeflag = TRUE; else landscapeflag = FALSE; if (interactflag) { do { printf("Character size in Points ( * %4.1f * ) : ", hpglcell); Fgets(instring, 41, stdin); if (*instring != '\0') hpglcell = str2int((void *)instring); } while (hpglcell < 1 || hpglcell > 100); printf("Rotate plot ( * %c * ) : ", YESNO(landscapeflag)); Fgets(instring, 41, stdin); if (*instring != '\0') { if (instring[0] == 'Y' || instring[0] == 'y') landscapeflag = TRUE; else landscapeflag = FALSE; } } if (!cloutflag) { printf("filename for HPGL-output : "); gets(outname); } } static void HPGLinit(double *xpos, double *ypos) { double xd, yd; if (landscapeflag) { dev_minx = 10.75; /* borders of a A4 page in mm */ dev_miny = 5.0; dev_maxx = 260.75; dev_maxy = 185.0; } else { dev_minx = 5.0; /* borders of a A4 page in mm */ dev_miny = 10.75; dev_maxx = 185.0; dev_maxy = 260.75; } dev_xsize = hpglcell * 0.351; dev_ysize = hpglcell * 0.351 * 2.0 / 1.5; hpglpen = 0; hpglhatch = hatches[0]; *xpos = dev_minx; *ypos = dev_maxy; /* 0,0 is lower left corner */ assert(outopen(&outfile, outname) != NULL); xd = dev_xsize * 100 / 1.5 / (dev_maxx - dev_minx); yd = dev_ysize * 100 / 2.0 / (dev_maxy - dev_miny); print("IN;%sIP;SI%5.3f;", (landscapeflag?"RO 90;":""), hpglcell*0.351); print("SC%1.2f,%1.2f,%1.2f,%1.2f;", dev_minx,dev_maxx, dev_miny,dev_maxy); print("SR%1.4f,%1.4f;", xd, yd); uwriteln(&outfile, "PU;"); print_len = 0; } static void HPGLsetcolor(int colno) { actcol = colno; } static void HPGLcharout(char c, double *xpos, double *ypos) { store_char(c, actcol, *xpos, *ypos); *xpos += dev_xsize; } static void HPGLnewline(double *xpos, double *ypos) { *xpos = dev_minx; *ypos -= dev_ysize; } static void HPGLnewpage(double *xpos, double *ypos) { store_flush(); uwriteln(&outfile, "PG"); print_len = 0; *xpos = dev_minx; *ypos = dev_maxy; print("PU;"); } static void HPGLexit(void) { store_flush(); uwriteln(&outfile, "PG"); print_len = 0; if (outfile.f != NULL) fclose(outfile.f); outfile.f = NULL; } GraphicsDevice Hpgl = { "HPGL", ask_hpgl, HPGLinit, HPGLsetcolor, HPGLcharout, GenericStringOut, HPGLnewline, HPGLnewpage, HPGLexit }; boxshade-3.1.1.orig/dv_html.c0100644000175100017510000001633706346046535015761 0ustar moellermoeller#include "dv_all.h" #include "version.h" #include #include #include /*----------------------------------------*/ /* POSTSCRIPT specific section */ /*----------------------------------------*/ typedef struct { double r, g, b; } RGB; typedef struct { RGB fg, bg; } HTMLrecord; static HTMLrecord html[5]; /* POSTSCRIPT-specifics*/ static int open_TR = FALSE; static int open_TABLE = FALSE; static int Col; static void Gray(RGB *rgb, double gray) { rgb->r = gray; rgb->g = gray; rgb->b = gray; } static void Rgb(RGB *rgb, double r, double g, double b) { rgb->r = r; rgb->g = g; rgb->b = b; } static void Code2Color(char code, RGB *rgb) { switch (code) { case 'W': Gray(rgb, 1.0); break; case '1': case '5': Gray(rgb, 0.8); break; case '2': case '6': Gray(rgb, 0.6); break; case '3': case '7': Gray(rgb, 0.4); break; case '4': case '8': Gray(rgb, 0.2); break; case 'B': Gray(rgb, 0.0); break; case 'R': Rgb(rgb, 1.0, 0.0, 0.0); break; case 'G': Rgb(rgb, 0.0, 1.0, 0.0); break; case 'L': Rgb(rgb, 0.0, 0.0, 1.0); break; case 'Y': Rgb(rgb, 1.0, 1.0, 0.0); break; case 'M': Rgb(rgb, 1.0, 0.0, 1.0); break; case 'C': Rgb(rgb, 0.0, 1.0, 1.0); break; } } static void menu_HTML(HTMLrecord *html, BOOL *lc, char *txt, char *parstring) { char code; char instring[41]; if (interactflag) { printf("\n----------------------------------------------------------------\n" "Enter the text attributes for printing of **>%s<** residues:\n", txt); printf("First choose the color/gray-value of the letter **>background<**\n" "Different letters specify different colors,\n" "(B) Black, (W) white (1,2,3,4) 4 different gray values, 4 is darkest\n" "(R) Red, (G) Green, (L) Blue, (Y) Yellow, (M) Magenta, (C) Cyan\n\n" "choose from BWRGLYMC1234 ( * %c * ) : ", parstring[0]); Fgets(instring, 41, stdin); } else *instring = '\0'; if (*instring == '\0') code = parstring[0]; else code = instring[0]; code = toupper(code); if (strchr( "BWRGLYMC1234", code) == NULL) code = 'W'; Code2Color(code, &(html->bg)); if (interactflag) { printf("\n\nNow choose the color/gray-value of the letter **>foreground<**\n" "lowercase choices mean lowercase letters in the sequence:\n" "(B,b) black (W,w) white (1,2,3,4) 4 different gray values, 4 is darkest\n" "(R,r) red (G,g) green (5,6,7,8) same, but lowercase letters\n" "(L,l) blue (Y,y) yellow (M,m) magenta (C,c) cyan\n\n" "choose from BbWwRrGgLlYyMmCc12345678 ( * %c * ) : ", parstring[1]); Fgets(instring, 41, stdin); } else *instring = '\0'; if (*instring == '\0') code = parstring[1]; else code = instring[0]; if (strchr("BbWwRrGgLlYyMmCc12345678", code) == NULL) code = 'B'; switch (code) { case '1' : case '2' : case '3' : case '4' : *lc = FALSE; break; case '5' : case '6' : case '7' : case '8' : *lc = TRUE; break; default : *lc = islower(code); break; } code = toupper(code); Code2Color(code, &(html->fg)); } static void Ask(void) { char parstring[6]; if (interactflag) printf("----------------------------------------------------------------\n"); term_par("HTML"); Fgets(parstring, 6, parfile); parstring[2] = '\0'; menu_HTML(&html[0], &lc[0], "different", parstring); Fgets(parstring, 6, parfile); parstring[2] = '\0'; menu_HTML(&html[1], &lc[1], "identical", parstring); Fgets(parstring, 6, parfile); parstring[2] = '\0'; if (simflag) menu_HTML(&html[2], &lc[2], "similar", parstring); else { html[2] = html[0]; lc[2] = lc[0]; } Fgets(parstring, 6, parfile); parstring[2] = '\0'; if (globalflag) menu_HTML(&html[3], &lc[3], "conserved", parstring); else { html[3] = html[1]; lc[3] = lc[1]; } Gray(&html[4].bg, 1.0); Gray(&html[4].fg, 0.0); lc[4] = FALSE; if (!cloutflag) do { printf("filename for HTML-output : "); gets(outname); } while (*outname == '\0'); } #define col255(cv) ((int)(255.0*(cv))) static void ColWrite(RGB *rgb) { fprintf(outfile.f, "\"#%02X%02X%02X\"", col255(rgb->r), col255(rgb->g), col255(rgb->b)); } static int coleq(RGB *c1, RGB *c2) { return (col255(c1->r) == col255(c2->r)) && (col255(c1->g) == col255(c2->g)) && (col255(c1->b) == col255(c2->b)); } #define isBG(rgb) coleq((rgb),&html[4].bg) #define isTC(rgb) coleq((rgb),&html[4].fg) static void StartTR(void) { if (!open_TR) { uwriteln(&outfile, ""); open_TR = TRUE; } } static void CloseTR(void) { if (open_TR) { uwriteln(&outfile, ""); open_TR = FALSE; } } static void StartTable(void) { uwriteln(&outfile, ""); open_TR = FALSE; open_TABLE = TRUE; } static void CloseTable(void) { CloseTR(); if (open_TABLE) { uwriteln(&outfile, "
"); open_TABLE = FALSE; } } static void dv_Init(double *xpos, double *ypos) { dev_minx = 0.0; dev_miny = 0.0; dev_maxx = 1000.0; dev_maxy = 10000.0; dev_xsize = 1.0; dev_ysize = 1.0; *xpos = dev_minx; *ypos = dev_maxy - dev_ysize; lines_per_page = (int)((dev_maxy - dev_miny) / dev_ysize); assert( outopen(&outfile, outname) != NULL); uwriteln(&outfile, ""); uwriteln(&outfile, ""); uwriteln(&outfile, "BoxShade " BOXSHADE_ver " Output"); uwriteln(&outfile, ""); fprintf(outfile.f, ""); } static void Setcolor(int colno) { Col = colno; } static void StrgChar(int ch, char *s, double *xpos, double *ypos) { char *fc = ""; if (!open_TABLE) StartTable(); StartTR(); fprintf(outfile.f, ""); if (!isTC(&html[Col].fg)) { fprintf(outfile.f, ""); fc = ""; } if (s == NULL) { if (ch != ' ') fprintf(outfile.f, "%c%s", ch, fc); else fprintf(outfile.f, " %s", fc); *xpos += dev_xsize; } else { fprintf(outfile.f, "%s%s   ", s, fc); *xpos += strlen(s)*dev_xsize; } uwriteln(&outfile, ""); } static void Charout(char c, double *xpos, double *ypos) { StrgChar(c, NULL, xpos, ypos); } static void Stringout(char *s, double *xpos, double *ypos) { StrgChar('\0', s, xpos, ypos); } static void Newline(double *xpos, double *ypos) { if (!open_TR) { StartTR(); uwriteln(&outfile, " "); } CloseTR(); *xpos = dev_minx; *ypos -= dev_ysize; } static void Newpage(double *xpos, double *ypos) { Newline(xpos, ypos); *xpos = dev_minx; *ypos = dev_maxy - dev_ysize; } static void dv_Exit(void) { CloseTR(); CloseTable(); uwriteln(&outfile, ""); uwriteln(&outfile, ""); if (outfile.f != NULL) fclose(outfile.f); outfile.f = NULL; } GraphicsDevice Html = { "HTML", Ask, dv_Init, Setcolor, Charout, Stringout, Newline, Newpage, dv_Exit }; boxshade-3.1.1.orig/dv_lj250.c0100644000175100017510000000650206346046535015642 0ustar moellermoeller#include "dv_all.h" #define CMD "\x9b" static char *pre_reset; static char *pre[5]; /*--------------------------------------------------------------------------*/ /* LJ250 specific section */ /*--------------------------------------------------------------------------*/ static void menu_lj250(char **pre, BOOL *lc, char *txt, char *parstring) { char code; char instring[51]; if (interactflag) { printf("\n" "-------------------------------------------------------------\n" "Enter the text attributes for printing of >%s< residues:\n", txt); printf("Different letters specify different colors,\n" "lowercase choices mean lowercase residues:\n" "(B,b) black,normal (E,e) black, emphasized (L,l) Blue\n" "(C,c) Cyan (M,m) Magenta (Y,y) Yellow (G,g) Green (R,r) Red\n\n" "choose from BbEeLlCcMmYyGgRr (* %c *) : ", parstring[0]); Fgets(instring, 51, stdin); } else *instring = '\0'; if (*instring == '\0') code = parstring[0]; else code = instring[0]; if (strchr("BELCMYGR", toupper(code)) == NULL) code = 'B'; *lc = islower(code); code = tolower(code); switch (code) { case 'b': *pre = CMD "0m"; break; case 'e': *pre = CMD "0;1m"; break; case 'l': *pre = CMD "0;34m"; break; case 'c': *pre = CMD "0;36m"; break; case 'm': *pre = CMD "0;35m"; break; case 'y': *pre = CMD "0;33m"; break; case 'g': *pre = CMD "0;32m"; break; case 'r': *pre = CMD "0;31m"; break; } } static void ask_lj250(void) { char parstring[6]; term_par("LJ250"); if (interactflag) printf("-------------------------------------------------------------\n"); pre_reset = CMD "0m"; Fgets(parstring, 6, parfile); parstring[2] = '\0'; menu_lj250(&pre[0], lc, "different", parstring); Fgets(parstring, 6, parfile); parstring[2] = '\0'; menu_lj250(&pre[1], &lc[1], "identical", parstring); Fgets(parstring, 6, parfile); parstring[2] = '\0'; if (simflag) menu_lj250(&pre[2], &lc[2], "similar", parstring); else { pre[2] = pre[0]; lc[2] = lc[0]; } Fgets(parstring, 6, parfile); parstring[2] = '\0'; if (globalflag) menu_lj250(&pre[3], &lc[3], "conserved", parstring); else { pre[3] = pre[1]; lc[3] = lc[1]; } pre[4] = CMD "0m"; lc[4] = FALSE; if (!cloutflag) { printf("name of print-file : "); gets(outname); } } static void LJinit(double *xpos, double *ypos) { assert(outopen(&outfile, outname) != NULL); fputs(pre_reset, outfile.f); dev_minx = 0.0; dev_miny = 1.0; dev_maxx = 80.0; dev_maxy = 63.0; dev_xsize = 1.0; dev_ysize = 1.0; *xpos = dev_minx; *ypos = dev_miny; } static void LJsetcolor(int colno) { fputs(pre[colno], outfile.f); } static void LJcharout(char c, double *xpos, double *ypos) { putc(c, outfile.f); *xpos += dev_xsize; } static void LJnewline(double *xpos, double *ypos) { uwriteln(&outfile, ""); *xpos = dev_minx; *ypos += dev_ysize; } static void LJnewpage(double *xpos, double *ypos) { uwriteln(&outfile, "\f"); *xpos = dev_minx; *ypos = dev_miny; } static void LJexit(void) { if (outfile.f != NULL) fclose(outfile.f); outfile.f = NULL; } GraphicsDevice Lj250 = { "LJ250", ask_lj250, LJinit, LJsetcolor, LJcharout, GenericStringOut, LJnewline, LJnewpage, LJexit }; boxshade-3.1.1.orig/dv_pict.c0100644000175100017510000003220406346046535015743 0ustar moellermoeller#include "dv_all.h" /*----------------------------------------*/ /* PICTfile specific section */ /*----------------------------------------*/ #define CHR static char CHR *StrBlack = "\001\0\0\0\0\0\0"; CHR *StrWhite = "\002\377\377\377\377\377\377"; /* \377 = 255 */ CHR *StrGrey1 = "\003\335\335\335\335\335\335"; /* \335 = 221 */ CHR *StrGrey2 = "\004\273\273\273\273\273\273"; /* \273 = 187 */ CHR *StrGrey3 = "\005\210\210\210\210\210\210"; /* \210 = 136 */ CHR *StrGrey4 = "\006\125\125\125\125\125\125"; /* \125 = 85 */ CHR *StrRed = "\007\377\377\063\063\0\0"; /* \377 = 255, \063 = 51 */ CHR *StrPurple = "\010\231\231\0\0\314\314"; /* \231 = 153, \314 = 204 */ CHR *StrDBlue = "\011\0\0\0\0\335\335"; /* \335 = 221 */ CHR *StrLBlue = "\012\146\146\377\377\377\377"; /* \146 = 102, \377 = 255 */ CHR *StrGreen = "\013\0\0\210\210\0\0"; /* \210 = 136 */ CHR *StrYellow = "\014\377\377\377\377\0\0"; /* \377 = 255 */ CHR *StrMagenta= "\015\377\377\0\0\231\231"; /* \377 = 255, \231 = 153 */ CHR *StrHeaderOp = "\0\021\002\377\014\0\377\377\377\377"; CHR *LongTextOp = "\0\050"; /* \050 = 40 */ CHR *RGBfgndOp = "\0\032"; /* \032 = 26 */ CHR *EndPicOp = "\0\377"; /* \377 = 255 */ CHR *PaintRectOp= "\0\061"; /* \061 = 49 */ CHR *StrHiLiteClip = "\0\036\0\001\0\012"; /* \036 = 30; \001 = 1, \012 = 10 */ CHR *StrCourierBold= "\0\054\0\012\0\026\007" /* \054 = 44, \012 = 10, \026 = 22 */ "Courier" "\0\003\0\026\0\004\001\0\0\015\0"; /* \026 = 22, \015 = 13 */ typedef struct PictRec { char *bgnd, *fgnd; } PictRec; static PictRec pict[5]; /*PICTfile specifics*/ static int pictcell; /*PICT files allow only integer values for char size*/ static char CurrentColour; static PictRec *WantedColour; static int WantedColNo, xshift, yshift, pcount; static char StrFormat[8]; static char StrFormat2[16]; static FILE *outf = NULL; static void menu_pictfile(PictRec *pict, BOOL *lc, char *txt, char *parstring) { char code; char instring[41]; if (interactflag) { printf("\n----------------------------------------------------------------\n" "Enter the text attributes for printing of **>%s<** residues:\n", txt); printf("First choose the color/gray-value of the letter **>background<**\n" "Different letters specify different colors,\n" "(B) Black, (W) white (1,2,3,4) 4 different gray values, 4 is darkest\n" "(R) Red, (P) Purple, (M) Magenta, (Y) Yellow, (G) Green,\n" "(L) Light blue, (D) Dark blue\n\n" "choose from BWRPMYGLD1234 ( * %c * ) : ", parstring[0]); Fgets(instring, 41, stdin); } else *instring = '\0'; if (*instring == '\0') code = parstring[0]; else code = instring[0]; code = toupper(code); if (strchr("BWRPMGYLD1234", code) == NULL) code = 'W'; switch (code) { case 'B': pict->bgnd = StrBlack; break; case 'W': pict->bgnd = StrWhite; break; case '1': pict->bgnd = StrGrey1; break; case '2': pict->bgnd = StrGrey2; break; case '3': pict->bgnd = StrGrey3; break; case '4': pict->bgnd = StrGrey4; break; case 'R': pict->bgnd = StrRed; break; case 'P': pict->bgnd = StrPurple; break; case 'M': pict->bgnd = StrMagenta; break; case 'G': pict->bgnd = StrGreen; break; case 'Y': pict->bgnd = StrYellow; break; case 'L': pict->bgnd = StrLBlue; break; case 'D': pict->bgnd = StrDBlue; break; } if (interactflag) { printf("\n\nNow choose the color/gray-value of the letter **>foreground<**\n" "lowercase choices mean lowercase letters in the sequence:\n" "(B,b) black (W,w) white (1,2,3,4) 4 different gray values, 4 is darkest\n" " (5,6,7,8) same, but lowercase letters\n" "(R) Red, (P) Purple, (M) Magenta, (Y) Yellow, (G) Green,\n" "(L) Light blue, (D) Dark blue\n\n" "choose from BbWwRrPpMmYyGgLlDd12345678 ( * %c * ) : ", parstring[1]); Fgets(instring, 41, stdin); } else *instring = '\0'; if (*instring == '\0') code = parstring[1]; else code = instring[0]; if (strchr("BWRPMGYLD12345678", toupper(code)) == NULL) code = 'B'; *lc = islower(code); if (code == '4' || code == '3' || code == '2' || code == '1') *lc = FALSE; if (code == '8' || code == '7' || code == '6' || code == '5') *lc = TRUE; code = toupper(code); switch (code) { case 'B': pict->fgnd = StrBlack; break; case 'W': pict->fgnd = StrWhite; break; case '5': case '1': pict->fgnd = StrGrey1; break; case '6': case '2': pict->fgnd = StrGrey2; break; case '7': case '3': pict->fgnd = StrGrey3; break; case '8': case '4': pict->fgnd = StrGrey4; break; case 'R': pict->fgnd = StrRed; break; case 'P': pict->fgnd = StrPurple; break; case 'M': pict->fgnd = StrMagenta; break; case 'G': pict->fgnd = StrGreen; break; case 'Y': pict->fgnd = StrYellow; break; case 'L': pict->fgnd = StrLBlue; break; case 'D': pict->fgnd = StrDBlue; break; } } static void ask_pict(void) { char parstring[6]; char instring[41]; splitflag = TRUE; /*although you can have multipage PICTs, I have defined the boundary of the ones created here as an A4 page. Very large PICTs, in any event, with 1000s of objects, might give the average drawing program a headache!*/ if (interactflag) printf("----------------------------------------------------------------\n"); term_par("PICTFILE"); Fgets(parstring, 6, parfile); parstring[2] = '\0'; menu_pictfile(&pict[0], &lc[0], "different", parstring); Fgets(parstring, 6, parfile); parstring[2] = '\0'; menu_pictfile(&pict[1], &lc[1], "identical", parstring); Fgets(parstring, 6, parfile); parstring[2] = '\0'; if (simflag) menu_pictfile(&pict[2], &lc[2], "similar", parstring); else { pict[2] = pict[0]; lc[2] = lc[0]; } Fgets(parstring, 6, parfile); parstring[2] = '\0'; if (globalflag) menu_pictfile(&pict[3], &lc[3], "conserved", parstring); else { pict[3] = pict[1]; lc[3] = lc[1]; } pict[4].bgnd = StrWhite; pict[4].fgnd = StrBlack; lc[4] = FALSE; fscanf(parfile, "%d%*[^\n]", &pictcell); getc(parfile); Fgets(parstring, 6, parfile); shadeonlyflag = toupper(parstring[0]) == 'S'; Fgets(parstring, 6, parfile); landscapeflag = toupper(parstring[0]) == 'Y'; if (interactflag) { do { printf("Character size in Points(5-20) ( * %4d * ) : ", pictcell); Fgets(instring, 41, stdin); if (*instring != '\0') pictcell = str2int((void *)instring); } while (pictcell < 5 || pictcell > 20); /*rather arbitrary limitation, but should cover most people's needs*/ printf("Save shading (S) or Shading+Text (T) (* %c *) ", (shadeonlyflag ? 'S' : 'T')); Fgets(instring, 41, stdin); if (*instring != '\0') shadeonlyflag = toupper(instring[0]) == 'S'; printf("Rotate page ( * %c * ) : ", YESNO(landscapeflag)); Fgets(instring, 41, stdin); if (*instring != '\0') landscapeflag = toupper(instring[0]) == 'Y'; } if (!cloutflag) { printf("filename for PICT file output : "); gets(outname); } } static void MakePoint(int *xpoint, int *ypoint) { /*converts a pair of points into a string containing the values as hex*/ /*in the order yvalue (hi), yvalue(lo), xvalue(hi), xvalue(lo)*/ putc( (*ypoint >> 8)&255, outf); putc( (*ypoint )&255, outf); putc( (*xpoint >> 8)&255, outf); putc( (*xpoint )&255, outf); } static void PICTinit(double *xpos, double *ypos) { int i, linelen, tlx, tly, brx, bry; if (landscapeflag) { dev_miny = 30.0; /* borders of an A4 page in point units */ dev_minx = 30.0; dev_maxy = 565.0; dev_maxx = 800.0; } else { dev_minx = 30.0; /* borders of an A4 page in point units */ dev_miny = 30.0; dev_maxx = 565.0; dev_maxy = 800.0; } dev_xsize = pictcell * 0.85; /* cells do overlap in x-direction */ dev_ysize = pictcell; *xpos = dev_minx; *ypos = dev_miny + dev_ysize; /* 0,0 is top left corner, and we increase ypos to go down the page*/ lines_per_page = (int)((dev_maxy - dev_miny) / dev_ysize); if (pictcell < 15) { xshift = 1; yshift = 2; } else { xshift = 2; yshift = 3; } /* as the size of the unit cell gets larger, the shift of the character to place it nicely in the "box" changes; I haven't worked out a nice formula that gives integer values that work for any number of points */ outf = fopen(outname, BIN_WR); assert(outf != NULL); /* Calculate here the TopLeft and BottomRight corners of the PICT, based on the size of the image and the page dimensions entered above: changing these to reflect, e.g. US Letter paper will result in a changed 'window' in which the program will draw the PICT. Note that BOXSHADE allows both PICT and EPSF to be *wider* than the defined page (i.e. it doesn't check for user errors over what will fit), but it does split the output into separate files of one 'page-full' (or less) */ linelen = outlen; if (seqnameflag) linelen += seqname_outlen + 1; if (seqnumflag) linelen += seqnumlen + 1; tly = (int)dev_minx; tlx = (int)dev_miny; if (lines_left < lines_per_page) brx = tly + (int)(0.5 + (lines_left + 1) * dev_ysize); else brx = tly + (int)(0.5 + lines_per_page * dev_ysize); bry = tlx + (int)(0.5 + linelen * dev_xsize); StrFormat[0] = tlx / 256; StrFormat[1] = tlx & 255; StrFormat[2] = tly / 256; StrFormat[3] = tly & 255; StrFormat[4] = brx / 256; StrFormat[5] = brx & 255; StrFormat[6] = bry / 256; StrFormat[7] = bry & 255; for (i = 0; i <= 15; i++) StrFormat2[i] = '\0'; /*yes, I know I'm being lazy!*/ StrFormat2[4] = tlx / 256; StrFormat2[5] = tlx & 255; StrFormat2[0] = tly / 256; StrFormat2[1] = tly & 255; StrFormat2[12] = brx / 256; StrFormat2[13] = brx & 255; StrFormat2[8] = bry / 256; StrFormat2[9] = bry & 255; /* I have to write a header of 512 bytes plus 2 bytes for the PICT size field, which fortunately is never read. */ for (i = 1; i <= 514; i++) putc(0, outf); /* now we write the various header opcodes and size for the file */ for (i = 0; i <= 7; i++) putc(StrFormat[i], outf); for (i = 0; i <= 9; i++) putc(StrHeaderOp[i], outf); for (i = 0; i <= 15; i++) putc(StrFormat2[i], outf); for (i = 1; i <= 4; i++) putc(0, outf); for (i = 0; i <= 5; i++) putc(StrHiLiteClip[i], outf); for (i = 0; i <= 7; i++) putc(StrFormat[i], outf); for (i = 0; i <= 24; i++) putc(StrCourierBold[i], outf); putc(pictcell, outf); pcount = 592; } static void PICTsetcolor(int colno) { WantedColour = &pict[colno]; WantedColNo = colno; } static void PICTcharout(char c, double *xpos, double *ypos) { int xpoint, ypoint, i; if (WantedColNo < 4) { if (CurrentColour != WantedColour->bgnd[0]) { if (pcount > 1016) { for (i = pcount; i <= 1023; i++) putc(0, outf); putc('\n', outf); pcount = 0; } fprintf(outf, "%c%c", RGBfgndOp[0], RGBfgndOp[1]); for (i = 1; i <= 6; i++) putc(WantedColour->bgnd[i], outf); CurrentColour = WantedColour->bgnd[0]; pcount += 8; } if (pcount > 1014) { for (i = pcount; i <= 1023; i++) putc(0, outf); putc('\n', outf); pcount = 0; } fprintf(outf, "%c%c", PaintRectOp[0], PaintRectOp[1]); xpoint = (int)(*xpos - xshift + 0.5); ypoint = (int)(*ypos + yshift - dev_ysize + 0.5); MakePoint(&xpoint, &ypoint); xpoint = (int)(*xpos - xshift + dev_xsize + 0.5); ypoint = (int)(*ypos + yshift + 0.5); MakePoint(&xpoint, &ypoint); pcount += 10; } if (!shadeonlyflag) { /*print the text*/ if (CurrentColour != WantedColour->fgnd[0]) { if (pcount > 1016) { for (i = pcount; i <= 1023; i++) putc(0, outf); putc('\n', outf); pcount = 0; } fprintf(outf, "%c%c", RGBfgndOp[0], RGBfgndOp[1]); for (i = 1; i <= 6; i++) putc(WantedColour->fgnd[i], outf); CurrentColour = WantedColour->fgnd[0]; pcount += 8; } if (pcount > 1016) { for (i = pcount; i <= 1023; i++) putc(0, outf); putc('\n', outf); pcount = 0; } fprintf(outf, "%c%c", LongTextOp[0], LongTextOp[1]); xpoint = (int)(*xpos + 0.5); ypoint = (int)(*ypos + 0.5); MakePoint(&xpoint, &ypoint); fprintf(outf, "\001%c", c); pcount += 8; } *xpos += dev_xsize; /*need to move anyway*/ } static void PICTnewline(double *xpos, double *ypos) { *xpos = dev_minx; *ypos += dev_ysize; } static void PICTnewpage(double *xpos, double *ypos) { /* this should never be accessed - /split is enforced with PICT files to stop them becoming too large */ *xpos = dev_minx; *ypos = dev_miny + dev_ysize; } static void PICTexit(void) { int i; if (pcount > 1022) { for (i = pcount; i <= 1023; i++) putc(0, outf); putc('\n', outf); pcount = 0; } fprintf(outf, "%c%c", EndPicOp[0], EndPicOp[1]); for (i = pcount; i <= 1021; i++) putc(0, outf); if (outf != NULL) fclose(outf); outf = NULL; } GraphicsDevice Pict = { "PICT", ask_pict, PICTinit, PICTsetcolor, PICTcharout, GenericStringOut, PICTnewline, PICTnewpage, PICTexit }; boxshade-3.1.1.orig/dv_ps.c0100644000175100017510000003553206346046535015435 0ustar moellermoeller#include "dv_all.h" #include "version.h" #include #include #include /*----------------------------------------*/ /* POSTSCRIPT specific section */ /*----------------------------------------*/ /* maximum line length in postscript file (approx) */ #define MAXLEN 70 /* max string length in print commands */ #define MAX_PRINT_LEN 300 typedef struct { double r, g, b, k; } RGBK; typedef struct { RGBK fg, bg; } psrecord; static char last_ps_cl; static int act_ps_col; static char save_sb[MAXLEN+30]; static int ps_count; static BOOL new_y, new_x; static psrecord ps[5]; /* POSTSCRIPT-specifics*/ static char pscc[5]; static double pscell; /* character cell size */ static void gray(RGBK *rgbk, double gray) { rgbk->r = 0; rgbk->g = 0; rgbk->b = 0; rgbk->k = gray; } static void rgb(RGBK *rgbk, double r, double g, double b) { rgbk->r = r; rgbk->g = g; rgbk->b = b; rgbk->k = 0; } static void Code2Color(char code, RGBK *rgbk) { switch (code) { case 'W': gray(rgbk, 1.0); break; case '1': case '5': gray(rgbk, 0.8); break; case '2': case '6': gray(rgbk, 0.6); break; case '3': case '7': gray(rgbk, 0.4); break; case '4': case '8': gray(rgbk, 0.2); break; case 'B': gray(rgbk, 0.0); break; case 'R': rgb(rgbk, 1.0, 0.0, 0.0); break; case 'G': rgb(rgbk, 0.0, 1.0, 0.0); break; case 'L': rgb(rgbk, 0.0, 0.0, 1.0); break; case 'Y': rgb(rgbk, 1.0, 1.0, 0.0); break; case 'M': rgb(rgbk, 1.0, 0.0, 1.0); break; case 'C': rgb(rgbk, 0.0, 1.0, 1.0); break; } } static void menu_postscript(psrecord *ps, BOOL *lc, char *txt, char *parstring) { char code; char instring[41]; if (interactflag) { printf("\n----------------------------------------------------------------\n" "Enter the text attributes for printing of **>%s<** residues:\n", txt); printf("First choose the color/gray-value of the letter **>background<**\n" "Different letters specify different colors,\n" "(B) Black, (W) white (1,2,3,4) 4 different gray values, 4 is darkest\n" "(R) Red, (G) Green, (L) Blue, (Y) Yellow, (M) Magenta, (C) Cyan\n\n" "choose from BWRGLYMC1234 ( * %c * ) : ", parstring[0]); Fgets(instring, 41, stdin); } else *instring = '\0'; if (*instring == '\0') code = parstring[0]; else code = instring[0]; code = toupper(code); if (strchr( "BWRGLYMC1234", code) == NULL) code = 'W'; Code2Color(code, &(ps->bg)); if (interactflag) { printf("\n\nNow choose the color/gray-value of the letter **>foreground<**\n" "lowercase choices mean lowercase letters in the sequence:\n" "(B,b) black (W,w) white (1,2,3,4) 4 different gray values, 4 is darkest\n" "(R,r) red (G,g) green (5,6,7,8) same, but lowercase letters\n" "(L,l) blue (Y,y) yellow (M,m) magenta (C,c) cyan\n\n" "choose from BbWwRrGgLlYyMmCc12345678 ( * %c * ) : ", parstring[1]); Fgets(instring, 41, stdin); } else *instring = '\0'; if (*instring == '\0') code = parstring[1]; else code = instring[0]; if (strchr("BbWwRrGgLlYyMmCc12345678", code) == NULL) code = 'B'; switch (code) { case '1' : case '2' : case '3' : case '4' : *lc = FALSE; break; case '5' : case '6' : case '7' : case '8' : *lc = TRUE; break; default : *lc = islower(code); break; } code = toupper(code); Code2Color(code, &(ps->fg)); } static void ask(BOOL makeEPS) { char parstring[6]; char instring[41]; int i; char lk; if (interactflag) printf("----------------------------------------------------------------\n"); term_par("POSTSCRIPT"); Fgets(parstring, 6, parfile); parstring[2] = '\0'; menu_postscript(&ps[0], &lc[0], "different", parstring); Fgets(parstring, 6, parfile); parstring[2] = '\0'; menu_postscript(&ps[1], &lc[1], "identical", parstring); Fgets(parstring, 6, parfile); parstring[2] = '\0'; if (simflag) menu_postscript(&ps[2], &lc[2], "similar", parstring); else { ps[2] = ps[0]; lc[2] = lc[0]; } Fgets(parstring, 6, parfile); parstring[2] = '\0'; if (globalflag) menu_postscript(&ps[3], &lc[3], "conserved", parstring); else { ps[3] = ps[1]; lc[3] = lc[1]; } gray(&ps[4].bg, 1.0); gray(&ps[4].fg, 0.0); lc[4] = FALSE; lk = 'K'-1; for (i = 0; i <= 4; i++) { if (!globalflag && i == 3) continue; pscc[i] = ++lk; } fscanf(parfile, "%lg%*[^\n]", &pscell); getc(parfile); Fgets(parstring, 6, parfile); landscapeflag = toupper(parstring[0]) == 'Y'; if (interactflag) { do { printf("Character size in Points ( * %4.1f * ) : ", pscell); Fgets(instring, 41, stdin); if (*instring != '\0') pscell = str2int((void *)instring); } while (pscell < 1 || pscell > 100); if (!makeEPS) { printf("Rotate plot ( * %c * ) : ", YESNO(landscapeflag)); Fgets(instring, 41, stdin); if (*instring != '\0') landscapeflag = toupper(instring[0]) == 'Y'; } } if (!cloutflag) do { printf("filename for POSTSCRIPT-output : "); gets(outname); } while (*outname == '\0'); } static void ask_postscript(void) { ask(FALSE); } static void ask_eps(void) { ask(TRUE); } static void ps_nl(void) { if (ps_count > 0) uwriteln(&outfile, ""); ps_count = 0; } static void ps_space(void) { if (ps_count > MAXLEN) ps_nl(); else if (ps_count > 0){ putc(' ', outfile.f); ps_count++; } } static void ps_string(int cmd, char *fmt, va_list arg_list) { char *cp1, *cp2; static char *buf = NULL; if (buf == NULL) buf=Malloc(MAX_PRINT_LEN); vsprintf(buf, fmt, arg_list); cp1 = buf; while (cp1 != NULL && *cp1 != '\0') { cp2 = strchr(cp1, '\n'); if (cp2 != NULL) { *cp2 = '\0'; ++cp2; } while (*cp1 != '\0') { if (cmd && *cp1 == ' ') ps_space(); else if ( (*cp1 & 0x80) != 0) ps_count += fprintf(outfile.f, "\\%03o", (*cp1)&0xff); else { putc(*cp1, outfile.f); ++ps_count; } ++cp1; } if (cp2 != NULL) ps_nl(); cp1 = cp2; } if (cmd) ps_space(); } static void ps_str(char *fmt, ...) { va_list argptr; va_start(argptr, fmt); ps_string(FALSE, fmt, argptr); va_end(argptr); } static void ps_cmd(char *fmt, ...) { va_list argptr; va_start(argptr, fmt); ps_string(TRUE, fmt, argptr); va_end(argptr); } static void ps_fp(double r, int nk) { char s[20], *cp; sprintf(s, "%1.*f", nk, r); if (nk > 0) { cp = s + strlen(s); while (cp-s > 0 && *(cp-1) == '0') --cp; if (cp-s > 0 && *(cp-1) == '.') --cp; *cp = '\0'; } cp = s; while (*cp == ' ') ++cp; ps_cmd("%s", cp); } static void ps_date(void) { time_t timer; struct tm *tblock; /* gets time of day */ timer = time(NULL); /* converts date/time to a structure */ tblock = localtime(&timer); ps_str("%s", asctime(tblock)); } static void PageSetup(int pn) { ps_str("\n" "%%%%Page: %d %d\n" "%%%%BeginPageSetup\n" "psetup\n" "%%%%EndPageSetup\n", pn, pn); } static void close_sb(void) { if (*save_sb != '\0') { int sl = strlen(save_sb); if (ps_count + sl > MAXLEN) ps_nl(); ps_str("(%s)%c", save_sb, (sl > 1 ? 'S' : 'C')); ps_space(); } *save_sb = '\0'; } static void add_sb(char c) { int sl = strlen(save_sb); save_sb[sl++] = c; save_sb[sl ] = '\0'; if (ps_count+sl > MAXLEN) { ps_str("(%s)%c", save_sb, (sl > 1 ? 'S' : 'C')); ps_space(); *save_sb = '\0'; } } static void ps_color(RGBK *c) { if (c->k > 0 || (c->r == 0 && c->g == 0 && c->b == 0)) { ps_fp(c->k, 1); ps_cmd("setgray"); } else { ps_fp(c->r, 1); ps_fp(c->g, 1); ps_fp(c->b, 1); ps_cmd("setrgbcolor"); } } /* static int ps_white(RGBK *c) { return (c->k > 0.9999); } */ static void DVinit(BOOL makeEPS, double *xpos, double *ypos) { int i; double linelen, bbox_x0, bbox_x1, bbox_y0, bbox_y1; if (landscapeflag && !makeEPS) { dev_miny = 30.0; /* borders of a A4 page in point units */ dev_minx = 30.0; dev_maxy = 545.0; dev_maxx = 800.0; } else { dev_minx = 30.0; /* borders of a A4 page in point units */ dev_miny = 30.0; dev_maxx = 575.0; dev_maxy = 760.0; } dev_xsize = pscell * 0.7; /* cells do overlap in x-direction */ dev_ysize = pscell; *xpos = dev_minx; *ypos = dev_maxy - dev_ysize; /* 0,0 is lower left corner */ lines_per_page = (int)((dev_maxy - dev_miny) / dev_ysize); assert( outopen(&outfile, outname) != NULL); ps_str("%%!PS-Adobe-2.0%s\n", (makeEPS ? " EPSF-2.0" : "") ); ps_str("%%%%Creator: BOXshade %s\n", BOXSHADE_ver); ps_str("%%%%Title: BOXSHADE document %s\n", inname); ps_str("%%%%CreationDate: "); ps_date(); ps_nl(); ps_str("%%%%Pages: %s\n", (makeEPS ? "1" : "(atend)") ); /*calculate the bounding box positions, trying to take into account the actual length of line and the depth on the page (if more than one page). Note that if the figure is more than one page, one really MUST use the /split option with EPSF, or the results will be a mess.*/ if (makeEPS) { linelen = outlen; if (seqnameflag) linelen += seqname_outlen + 1; if (seqnumflag) linelen += seqnumlen + 1; bbox_x0 = dev_minx - 1; if (lines_left > lines_per_page) bbox_y0 = dev_maxy - lines_per_page * dev_ysize; else bbox_y0 = dev_maxy - lines_left * dev_ysize - 1; /*if the bbox is set too wide for the paper, it will be clipped by the printer; however, it should appear as too wide in the graphics program, so the user will notice it.*/ bbox_x1 = dev_minx + linelen * dev_xsize + 1; bbox_y1 = dev_maxy + 1; ps_str("%%%%BoundingBox: %ld %ld %ld %ld\n", (long)bbox_x0, (long)bbox_y0, (long)bbox_x1, (long)bbox_y1); } else { if (landscapeflag) { ps_str("%%%%BoundingBox: %ld %ld %ld %ld\n", (long)dev_miny-1, (long)dev_minx-1, (long)dev_maxy+1, (long)dev_maxx+1); ps_str("%%%%Orientation: landscape\n"); } else { ps_str("%%%%BoundingBox: %ld %ld %ld %ld\n", (long)dev_minx-1, (long)dev_miny-1, (long)dev_maxx+1, (long)dev_maxy+1); ps_str("%%%%Orientation: portrait\n"); } ps_str("%%%%PaperSize: a4\n"); } ps_str("%%%%DocumentNeededFonts: Courier-Bold\n" "%%%%DocumentData: Clean7Bit\n" "%%%%LanguageLevel: 1\n" "%%%%EndComments\n" "%%%%BeginProlog\n"); ps_cmd("/bd { bind def } bind def"); ps_cmd("/xd { exch def } bd"); ps_nl(); ps_str("%%\n" "%% custom color selection\n%%\n" "%% grayscale:\n%%\n" "%% ' setgray'\n%%\n" "%% is a real number between\n" "%% 0.0 (black) and 1.0 (white)\n%%\n"); ps_str("%% RGB (red/green/blue) colors:\n%%\n" "%% ' setrgbcolor'\n%%\n" "%% each color compoment is a real'\n" "%% number between 0.0 (zero intensity) and\n" "%% 1.0 (max intensity)\n%%\n" "%% Change the following definitions for your needs !\n" "%%"); ps_nl(); for (i = 0; i <= 4; i++) { if (!globalflag && i == 3) continue; switch (i) { case 0: ps_str("%% -- different residues"); break; case 1: ps_str("%% -- identical residues"); break; case 2: ps_str("%% -- similar residues"); break; case 3: ps_str("%% -- conserved residues"); break; case 4: ps_str("%% -- normal text"); break; } ps_nl(); ps_cmd("/bg%c {", pscc[i]); ps_color(&ps[i].bg); ps_cmd("} bd"); ps_str("%% background"); ps_nl(); ps_cmd("/fg%c {", pscc[i]); ps_color(&ps[i].fg); ps_cmd("} bd"); ps_str("%% foreground"); ps_nl(); } ps_str("%%\n%% end of custom color selection\n%%"); ps_nl(); ps_cmd("/px 0 def"); ps_cmd("/py 0 def"); ps_cmd("/fg {0 setgray} bd"); ps_cmd("/bg {1 setgray} bd"); ps_cmd("/C {px py moveto gsave"); ps_fp(-0.03*pscell, 1); ps_fp(-0.05*pscell, 1); ps_cmd("rmoveto"); ps_fp(0.70*pscell, 1); ps_cmd("0 rlineto 0"); ps_fp(pscell,1); ps_cmd("rlineto"); ps_fp(-0.70*pscell, 1); ps_cmd("0 rlineto closepath " "bg fill grestore fg 0 2 rmoveto show " "/px px"); ps_fp(dev_xsize, 2); ps_cmd("add def} bd", dev_xsize); ps_cmd("/X {/px xd} bd " "/Y {/py xd} bd " "/A {Y X} bd"); /* ps_cmd("/S { /strg xd /idx 0 def { strg idx 1 " "getinterval C /idx idx 1 add def strg length idx " "eq {exit} if } loop } bd"); */ ps_cmd("/S {0 1 2 index length 1 sub {" "2 copy 1 getinterval C pop" "} for pop} bd"); ps_cmd("/psetup {/Courier-Bold findfont"); ps_fp(pscell, 1); ps_cmd("scalefont setfont} bd"); for (i = 0; i <= 4; i++) { if (!globalflag && i == 3) continue; ps_cmd("/%c {/bg {bg%c} bd" " /fg {fg%c} bd" "} bd", pscc[i], pscc[i], pscc[i]); } ps_nl(); ps_str("%%%%EndProlog\n" "%%%%BeginSetup\n"); ps_cmd("save%s", (makeEPS ? "" : " initgraphics") ); if (landscapeflag && !makeEPS) ps_cmd("575 0 translate 90 rotate"); ps_cmd("120 currentscreen 3 -1 roll pop setscreen\n"); ps_str("%%%%EndSetup\n"); PageSetup(1); last_ps_cl = ' '; act_ps_col = 4; new_x = new_y = TRUE; *save_sb = '\0'; ps_count = 0; } static void Setcolor(int colno) { if (!globalflag && colno == 3) colno = 1; act_ps_col = colno; } static void Charout(char c, double *xpos, double *ypos) { if (pscc[act_ps_col] != last_ps_cl) { close_sb(); last_ps_cl = pscc[act_ps_col]; ps_cmd("%c", last_ps_cl); } if (new_y && new_x) { close_sb(); ps_fp(*xpos, 1); ps_fp(*ypos, 1); ps_cmd("A"); new_x = new_y = FALSE; } else if (new_y) { close_sb(); ps_fp(*ypos, 1); ps_cmd("Y"); new_y = FALSE; } else if (new_x) { close_sb(); ps_fp(*xpos, 1); ps_cmd("X"); new_x = FALSE; } add_sb(c); *xpos += dev_xsize; } static void Newline(double *xpos, double *ypos) { close_sb(); *xpos = dev_minx; *ypos -= dev_ysize; new_x = new_y = TRUE; } static void PSnewpage(double *xpos, double *ypos) { close_sb(); *xpos = dev_minx; ps_cmd("copypage erasepage"); PageSetup(act_page + 1); *ypos = dev_maxy - dev_ysize; new_x = new_y = TRUE; last_ps_cl = ' '; } static void DVexit(BOOL makeEPS) { close_sb(); if (!makeEPS) ps_cmd("copypage erasepage"); ps_str("\n%%%%Trailer\n"); ps_str("restore\n"); if (!makeEPS) ps_str("%%%%Pages: %d\n", act_page); else ps_str("showpage\n"); ps_str("%%%%EOF\n"); if (outfile.f != NULL) fclose(outfile.f); outfile.f = NULL; } static void EPSinit(double *xpos, double *ypos) { DVinit(TRUE, xpos, ypos); } static void PSinit(double *xpos, double *ypos) { DVinit(FALSE, xpos, ypos); } static void PSexit(void) { DVexit(FALSE); } static void EPSexit(void) { DVexit(TRUE); } GraphicsDevice Postscript = { "PS", ask_postscript, PSinit, Setcolor, Charout, GenericStringOut, Newline, PSnewpage, PSexit }; GraphicsDevice Eps = { "EPS", ask_eps, EPSinit, Setcolor, Charout, GenericStringOut, Newline, Newline, EPSexit }; boxshade-3.1.1.orig/dv_regis.c0100644000175100017510000001443606346046535016124 0ustar moellermoeller#include "dv_all.h" #include /*--------------------------------------------------------------------------*/ /* ReGIS specific section */ /*--------------------------------------------------------------------------*/ #define ESC "\x1b" typedef char regisstring[31]; static regisstring regstr[5]; /*ReGIS-specifics*/ static void menu_regis(char *regstr, BOOL *lc, char *txt, char *parstring) { char code; char instring[51]; *regstr = '\0'; if (interactflag) { printf("\n-----------------------------------------------------------------------\n" "Enter the text attributes for printing of **>%s<** residues:\n", txt); printf("First choose the color/gray-value of the letter **>background<**\n" "Different letters specify different colors,\n" "(B) black (W) white (L) Blue (G) Green (R) Red\n" " (C) Cyan (M) Magenta (Y) Yellow \n" "(1,2,3,4) 4 different gray values, 4 is darkest\n\n" "choose from BWLGRCMY1234 (* %c *) : ", parstring[0]); Fgets(instring, 51, stdin); } else *instring = '\0'; if (*instring == '\0') code = parstring[0]; else code = instring[0]; code = tolower(code); if (strchr("bwlgrcmy1234", code) == NULL) code = 'w'; switch (code) { case 'b': strcat(regstr, "S(I(D));"); break; case 'w': strcat(regstr, "S(I(W));"); break; case 'l': strcat(regstr, "S(I(B));"); break; case 'g': strcat(regstr, "S(I(G));"); break; case 'r': strcat(regstr, "S(I(R));"); break; case 'c': strcat(regstr, "S(I(C));"); break; case 'm': strcat(regstr, "S(I(M));"); break; case 'y': strcat(regstr, "S(I(Y));"); break; case '1': strcat(regstr, "S(I(H0L80S0));"); break; case '2': strcat(regstr, "S(I(H0L60S0));"); break; case '3': strcat(regstr, "S(I(H0L40S0));"); break; case '4': strcat(regstr, "S(I(H0L20S0));"); break; } if (interactflag) { printf("\n\nNow choose the color/gray-value of the letter **>foreground<**\n" "lowercase choices mean lowercase letters in the sequence:\n" "(B,b) black (W,w) white (L,l) Blue (G,g) Green (R,r) Red\n" "(C,c) Cyan (M,m) Magenta (Y,y) Yellow \n" "(1,2,3,4) 4 different gray values, 4 is darkest\n" "(5,6,7,8) 4 different gray values, 8 is darkest, but lowercase letters\n\n" "choose from BWLGRCMY1234/bwlgrcmy5678 (* %c *) : ", parstring[1]); Fgets(instring, 51, stdin); printf("\n\n"); } else *instring = '\0'; if (*instring == '\0') code = parstring[1]; else code = instring[0]; if (strchr("BWLGRCMY12345678", toupper(code)) == NULL) code = 'B'; *lc = islower(code); if (code == '4' || code == '3' || code == '2' || code == '1') *lc = FALSE; code = tolower(code); switch (code) { case 'b': strcat(regstr, "W(I(D));"); break; case 'w': strcat(regstr, "W(I(W));"); break; case 'l': strcat(regstr, "W(I(B));"); break; case 'g': strcat(regstr, "W(I(G));"); break; case 'r': strcat(regstr, "W(I(R));"); break; case 'c': strcat(regstr, "W(I(C));"); break; case 'm': strcat(regstr, "W(I(M));"); break; case 'y': strcat(regstr, "W(I(Y));"); break; case '1': case '5': strcat(regstr, "W(I(H0L80S0));"); break; case '2': case '6': strcat(regstr, "W(I(H0L60S0));"); break; case '3': case '7': strcat(regstr, "W(I(H0L40S0));"); break; case '4': case '8': strcat(regstr, "W(I(H0L20S0));"); break; } } static void ask_regis(void) { char parstring[6]; if (interactflag) printf("-----------------------------------------------------------------------\n"); term_par("ReGIS"); Fgets(parstring, 6, parfile); parstring[2] = '\0'; menu_regis(regstr[0], &lc[0], "different", parstring); Fgets(parstring, 6, parfile); parstring[2] = '\0'; menu_regis(regstr[1], &lc[1], "identical", parstring); Fgets(parstring, 6, parfile); parstring[2] = '\0'; if (simflag) menu_regis(regstr[2], &lc[2], "similar", parstring); else { strcpy(regstr[2], regstr[0]); lc[2] = lc[0]; } Fgets(parstring, 6, parfile); parstring[2] = '\0'; if (globalflag) menu_regis(regstr[3], &lc[3], "conserved", parstring); else { strcpy(regstr[3], regstr[1]); lc[3] = lc[1]; } strcpy(regstr[4], "S(I(W));W(I(D));"); lc[4] = FALSE; if (!cloutflag) { printf("filename for REGIS-output : "); gets(outname); } } static void DVinit(regmodetype regmode, double *xpos, double *ypos) { dev_minx = 0.0; dev_miny = 0.0; dev_maxx = 799.0; if (regmode == rTERM) dev_maxy = 479.0; else dev_maxy = 1199.0; dev_xsize = 9.0; dev_ysize = 20.0; assert(outopen(&outfile, outname) != NULL); uwriteln(&outfile, "%s", ESC "[?38l" ESC "Pp"); uwriteln(&outfile, "S(I(W)E);S(C0);S(A[0,0][%ld,%ld]);", (long)floor(dev_maxx + 0.5), (long)floor(dev_maxy + 0.5)); uwriteln(&outfile, "P[0,0];W(R);T(S1)"); *xpos = dev_minx; *ypos = dev_miny; } static void RTinit(double *xpos, double *ypos) { DVinit(rTERM, xpos, ypos); } static void RPinit(double *xpos, double *ypos) { DVinit(rPAGE, xpos, ypos); } static void Rsetcolor(int colno) { fputs(regstr[colno], outfile.f); } static void Rcharout(char c, double *xpos, double *ypos) { uwriteln(&outfile, "T\"%c\";", c); *xpos += dev_xsize; } static void Rnewline(double *xpos, double *ypos) { *xpos = dev_minx; *ypos += dev_ysize; uwriteln(&outfile, "P[0,%ld];", (long)floor(*ypos + 0.5)); } static void RPnewpage(double *xpos, double *ypos) { uwriteln(&outfile, "S(FI(W)E);S(C0);S(A[0,0][%ld,%ld]);", (long)floor(dev_maxx + 0.5), (long)floor(dev_maxy + 0.5)); uwriteln(&outfile, "P[0,0];W(R);T(S1)"); *xpos = dev_minx; *ypos = dev_miny; } static void RTnewpage(double *xpos, double *ypos) { putchar('\007'); scanf("%*[^\n]"); getchar(); RPnewpage(xpos, ypos); } static void Rexit(void) { uwriteln(&outfile, "%s", ESC "\\" ESC "[23;1H"); if (outfile.f != NULL) fclose(outfile.f); outfile.f = NULL; } GraphicsDevice RegisT = { "REGISt", ask_regis, RTinit, Rsetcolor, Rcharout, GenericStringOut, Rnewline, RTnewpage, Rexit }; GraphicsDevice RegisP = { "REGISp", ask_regis, RPinit, Rsetcolor, Rcharout, GenericStringOut, Rnewline, RPnewpage, Rexit }; boxshade-3.1.1.orig/dv_rtf.c0100644000175100017510000001325506346046535015604 0ustar moellermoeller#include "dv_all.h" /*----------------------------------------*/ /* RTF specific section */ /*----------------------------------------*/ typedef struct rtfrecord { int bgnd, fgnd; } rtfrecord; static rtfrecord rtfrec[5]; /*RTF-specifics*/ static int rtfcell; static void menu_rtf(rtfrecord *rtfrec, BOOL *lc, char *txt, char *parstring) { char code; char instring[41]; if (interactflag) { printf("\n-------------------------------------------------------------\n" "Enter the text attributes for printing of ***>%s<*** residues:\n", txt); printf("First choose the color/gray-value of the letter ***>background<***\n" "Different letters specify different colors,\n" "!! Background colors are not supported on most RTF-programs !!\n" "(R) red (G) green (B) blue (C) cyan\n" "(M) magenta (Y) yellow (K) black (W) white\n" "(D) dark gray (L) light gray\n\n" "choose from RGBCMYKWDL ( * %c * ) : ", parstring[0]); Fgets(instring, 41, stdin); } else *instring = '\0'; if (*instring == '\0') code = parstring[0]; else code = instring[0]; code = toupper(code); if (strchr("RGBCMYKWDL", code) == NULL) code = 'W'; switch (code) { case 'R': rtfrec->bgnd = 2; break; case 'G': rtfrec->bgnd = 3; break; case 'B': rtfrec->bgnd = 4; break; case 'C': rtfrec->bgnd = 5; break; case 'M': rtfrec->bgnd = 6; break; case 'Y': rtfrec->bgnd = 7; break; case 'K': rtfrec->bgnd = 0; break; case 'W': rtfrec->bgnd = 1; break; case 'D': rtfrec->bgnd = 8; break; case 'L': rtfrec->bgnd = 9; break; } if (interactflag) { printf("\n\nNow choose the color/gray-value of the letter ***>foreground<***\n" "lowercase choices mean lowercase letters in the sequence:\n" "(R) red (G) green (B) blue (C) cyan\n" "(M) magenta (Y) yellow (K) black (W) white\n" "(D) dark gray (L) light gray\n\n" "choose from RrGgBbCcMmYyKkWwDdLl ( * %c * ) : ", parstring[1]); Fgets(instring, 41, stdin); } else *instring = '\0'; if (*instring == '\0') code = parstring[1]; else code = instring[0]; if (strchr("RGBCMYKWDL", code) == NULL) code = 'K'; *lc = islower(code); code = toupper(code); switch (code) { case 'R': rtfrec->fgnd = 2; break; case 'G': rtfrec->fgnd = 3; break; case 'B': rtfrec->fgnd = 4; break; case 'C': rtfrec->fgnd = 5; break; case 'M': rtfrec->fgnd = 6; break; case 'Y': rtfrec->fgnd = 7; break; case 'K': rtfrec->fgnd = 0; break; case 'W': rtfrec->fgnd = 1; break; case 'D': rtfrec->fgnd = 8; break; case 'L': rtfrec->fgnd = 9; break; } } static void ask_rtf(void) { char parstring[6]; char instring[41]; if (interactflag) printf("-------------------------------------------------------------\n"); term_par("RTF"); Fgets(parstring, 6, parfile); parstring[2] = '\0'; menu_rtf(rtfrec, lc, "different", parstring); Fgets(parstring, 6, parfile); parstring[2] = '\0'; menu_rtf(&rtfrec[1], &lc[1], "identical", parstring); Fgets(parstring, 6, parfile); parstring[2] = '\0'; if (simflag) menu_rtf(&rtfrec[2], &lc[2], "similar", parstring); else { rtfrec[2] = rtfrec[0]; lc[2] = lc[0]; } Fgets(parstring, 6, parfile); parstring[2] = '\0'; if (globalflag) menu_rtf(&rtfrec[3], &lc[3], "conserved", parstring); else { rtfrec[3] = rtfrec[1]; lc[3] = lc[1]; } rtfrec[4].bgnd = 1; rtfrec[4].fgnd = 0; lc[4] = FALSE; fscanf(parfile, "%d%*[^\n]", &rtfcell); getc(parfile); if (interactflag) { do { printf("Character size in Points ( * %2d * ) : ", rtfcell); Fgets(instring, 41, stdin); if (*instring != '\0') rtfcell = str2int((void *)instring); } while (rtfcell < 1 || rtfcell > 40); } if (!cloutflag) { printf("filename for RTF-output : "); gets(outname); } } static void RTFinit(double *xpos, double *ypos) { dev_minx = 0.0; dev_miny = 1.0; dev_maxx = 10480.0; dev_maxy = 15000.0; dev_xsize = rtfcell * 120.0 / 10; dev_ysize = rtfcell * 20.0; *xpos = dev_minx; *ypos = dev_maxy; assert(outopen(&outfile, outname) != NULL); uwriteln(&outfile, "{\\rtf1\\ansi\\deff0"); uwriteln(&outfile, "{\\fonttbl{\\f0\\fmodern Courier New;}}"); uwriteln(&outfile, "{\\info{\\author BOXSHADE}}"); uwriteln(&outfile, "{\\colortbl\n" "\\red0\\green0\\blue0;" "\\red255\\green255\\blue255;" "\\red255\\green0\\blue0;" "\\red0\\green255\\blue0;" "\\red0\\green0\\blue255;" "\\red0\\green255\\blue255;" "\\red255\\green0\\blue255;" "\\red255\\green255\\blue0;" "\\red128\\green128\\blue128;" "\\red192\\green192\\blue192;}"); uwriteln(&outfile, "\\paperw11880\\paperh16820\\margl1000\\margr500"); uwriteln(&outfile, "\\margt910\\margb910\\sectd\\cols1\\pard\\plain"); uwriteln(&outfile, "\\fs%d", rtfcell * 2); } static void RTFsetcolor(int colno) { uwriteln(&outfile, ""); fprintf(outfile.f, "\\highlight%d\\cf%d ", rtfrec[colno].bgnd, rtfrec[colno].fgnd); } static void RTFcharout(char c, double *xpos, double *ypos) { putc(c, outfile.f); *xpos += dev_xsize; } static void RTFnewline(double *xpos, double *ypos) { uwriteln(&outfile, "\n\\highlight%d\\cf%d \\line", rtfrec[0].bgnd, rtfrec[0].fgnd); *xpos = dev_minx; *ypos -= dev_ysize; } static void RTFnewpage(double *xpos, double *ypos) { uwriteln(&outfile, "\\page"); *xpos = dev_minx; *ypos = dev_miny; } static void RTFexit(void) { uwriteln(&outfile, "}"); if (outfile.f != NULL) fclose(outfile.f); outfile.f = NULL; } GraphicsDevice Rtf = { "RTF", ask_rtf, RTFinit, RTFsetcolor, RTFcharout, GenericStringOut, RTFnewline, RTFnewpage, RTFexit }; boxshade-3.1.1.orig/makefile.bcc0100644000175100017510000000257306346046535016403 0ustar moellermoeller# BOXSHADE makefile with BC++ and Borland make CC = bcc CFLAGS = -ml LDFLAGS= -ml OBJ =.obj EXE =.exe HEADER = bx_types.h bx_read.h dv_all.h CSRCbx = box.c bx_read.c bx_misc.c CSRCdv = dv_ansi.c dv_ascii.c dv_crt.c dv_fig.c \ dv_hpgl.c dv_lj250.c dv_pict.c dv_ps.c\ dv_regis.c dv_rtf.c dv_html.c OBJS = box$(OBJ) bx_read$(OBJ) bx_misc$(OBJ) \ dv_ansi$(OBJ) dv_ascii$(OBJ) dv_crt$(OBJ) dv_fig$(OBJ) \ dv_hpgl$(OBJ) dv_lj250$(OBJ) dv_pict$(OBJ) dv_ps$(OBJ)\ dv_regis$(OBJ) dv_rtf$(OBJ) dv_html$(OBJ) boxshade$(EXE): $(OBJS) $(CC) $(LDFLAGS) -e$@ @&&| $(OBJS) | box$(OBJ): box.c bx_types.h bx_read.h dv_all.h version.h bx_read$(OBJ): bx_read.c bx_types.h bx_read.h bx_misc$(OBJ): bx_misc.c bx_types.h dv_ansi$(OBJ): dv_ansi.c bx_types.h bx_read.h dv_all.h dv_ascii$(OBJ): dv_ascii.c bx_types.h bx_read.h dv_all.h dv_crt$(OBJ): dv_crt.c bx_types.h bx_read.h dv_all.h dv_fig$(OBJ): dv_fig.c bx_types.h bx_read.h dv_all.h dv_hpgl$(OBJ): dv_hpgl.c bx_types.h bx_read.h dv_all.h dv_html$(OBJ): dv_html.c bx_types.h bx_read.h dv_all.h version.h dv_lj250$(OBJ): dv_lj250.c bx_types.h bx_read.h dv_all.h dv_pict$(OBJ): dv_pict.c bx_types.h bx_read.h dv_all.h dv_ps$(OBJ): dv_ps.c bx_types.h bx_read.h dv_all.h version.h dv_regis$(OBJ): dv_regis.c bx_types.h bx_read.h dv_all.h dv_rtf$(OBJ): dv_rtf.c bx_types.h bx_read.h dv_all.h boxshade-3.1.1.orig/makefile.djp0100644000175100017510000000272106346046535016424 0ustar moellermoeller# BOXSHADE makefile with DJGPP and GNU-make (MS-DOS): CC = gcc CFLAGS = -Wall -O LDFLAGS= -s LIBS = -lm OBJ =.o EXE =.exe HEADER = bx_types.h bx_read.h dv_all.h CSRCbx = box.c bx_read.c bx_misc.c CSRCdv = dv_ansi.c dv_ascii.c dv_crt.c dv_fig.c \ dv_hpgl.c dv_lj250.c dv_pict.c dv_ps.c\ dv_regis.c dv_rtf.c dv_html.c OBJS = box$(OBJ) bx_read$(OBJ) bx_misc$(OBJ) \ dv_ansi$(OBJ) dv_ascii$(OBJ) dv_crt$(OBJ) dv_fig$(OBJ) \ dv_hpgl$(OBJ) dv_lj250$(OBJ) dv_pict$(OBJ) dv_ps$(OBJ)\ dv_regis$(OBJ) dv_rtf$(OBJ) dv_html$(OBJ) boxshade$(EXE): $(OBJS) $(CC) $(LDFLAGS) -o $@ $(OBJS) $(LIBS) depend: gcc -MM $(CSRCbx) >depend gcc -MM $(CSRCdv) >>depend box$(OBJ): box.c bx_types.h bx_read.h dv_all.h version.h bx_read$(OBJ): bx_read.c bx_types.h bx_read.h bx_misc$(OBJ): bx_misc.c bx_types.h dv_ansi$(OBJ): dv_ansi.c bx_types.h bx_read.h dv_all.h dv_ascii$(OBJ): dv_ascii.c bx_types.h bx_read.h dv_all.h dv_crt$(OBJ): dv_crt.c bx_types.h bx_read.h dv_all.h dv_fig$(OBJ): dv_fig.c bx_types.h bx_read.h dv_all.h dv_hpgl$(OBJ): dv_hpgl.c bx_types.h bx_read.h dv_all.h dv_html$(OBJ): dv_html.c bx_types.h bx_read.h dv_all.h version.h dv_lj250$(OBJ): dv_lj250.c bx_types.h bx_read.h dv_all.h dv_pict$(OBJ): dv_pict.c bx_types.h bx_read.h dv_all.h dv_ps$(OBJ): dv_ps.c bx_types.h bx_read.h dv_all.h version.h dv_regis$(OBJ): dv_regis.c bx_types.h bx_read.h dv_all.h dv_rtf$(OBJ): dv_rtf.c bx_types.h bx_read.h dv_all.h boxshade-3.1.1.orig/makefile.unx0100644000175100017510000000271506346046561016463 0ustar moellermoeller# BOXSHADE makefile for unix (tested under Linux && Solaris) CC = gcc CFLAGS = -O LDFLAGS= -s LIBS = -lm OBJ =.o EXE = HEADER = bx_types.h bx_read.h dv_all.h CSRCbx = box.c bx_read.c bx_misc.c CSRCdv = dv_ansi.c dv_ascii.c dv_crt.c dv_fig.c\ dv_hpgl.c dv_lj250.c dv_pict.c dv_ps.c\ dv_regis.c dv_rtf.c dv_html.c OBJS = box$(OBJ) bx_read$(OBJ) bx_misc$(OBJ) \ dv_ansi$(OBJ) dv_ascii$(OBJ) dv_crt$(OBJ) dv_fig$(OBJ) \ dv_hpgl$(OBJ) dv_lj250$(OBJ) dv_pict$(OBJ) dv_ps$(OBJ)\ dv_regis$(OBJ) dv_rtf$(OBJ) dv_html$(OBJ) boxshade$(EXE): $(OBJS) $(CC) $(LDFLAGS) -o $@ $(OBJS) $(LIBS) depend: gcc -MM $(CSRCbx) >depend gcc -MM $(CSRCdv) >>depend box$(OBJ): box.c bx_types.h bx_read.h dv_all.h version.h bx_read$(OBJ): bx_read.c bx_types.h bx_read.h bx_misc$(OBJ): bx_misc.c bx_types.h dv_ansi$(OBJ): dv_ansi.c bx_types.h bx_read.h dv_all.h dv_ascii$(OBJ): dv_ascii.c bx_types.h bx_read.h dv_all.h dv_crt$(OBJ): dv_crt.c bx_types.h bx_read.h dv_all.h dv_fig$(OBJ): dv_fig.c bx_types.h bx_read.h dv_all.h dv_hpgl$(OBJ): dv_hpgl.c bx_types.h bx_read.h dv_all.h dv_html$(OBJ): dv_html.c bx_types.h bx_read.h dv_all.h version.h dv_lj250$(OBJ): dv_lj250.c bx_types.h bx_read.h dv_all.h dv_pict$(OBJ): dv_pict.c bx_types.h bx_read.h dv_all.h dv_ps$(OBJ): dv_ps.c bx_types.h bx_read.h dv_all.h version.h dv_regis$(OBJ): dv_regis.c bx_types.h bx_read.h dv_all.h dv_rtf$(OBJ): dv_rtf.c bx_types.h bx_read.h dv_all.h boxshade-3.1.1.orig/makefile.w160100644000175100017510000000350506346046535016265 0ustar moellermoeller# # Borland C++ IDE generated makefile # #BCCPATH=k:\borlandc BCCPATH=e:\comp\bc45 CC = bcc LDFLAGS= -L$(BCCPATH)\LIB -Twe -c -C -x OBJ =.obj EXE =.exe CFG = BccW16.cfg .c.obj: $(CC) +$(CFG) -P- -c -o$@ $< CSRCbx = box.c bx_read.c bx_misc.c CSRCdv = dv_ansi.c dv_ascii.c dv_crt.c dv_fig.c \ dv_hpgl.c dv_lj250.c dv_pict.c dv_ps.c\ dv_regis.c dv_rtf.c dv_html.c OBJS = box$(OBJ) bx_read$(OBJ) bx_misc$(OBJ) \ dv_ansi$(OBJ) dv_ascii$(OBJ) dv_crt$(OBJ) dv_fig$(OBJ) \ dv_hpgl$(OBJ) dv_lj250$(OBJ) dv_pict$(OBJ) dv_ps$(OBJ)\ dv_regis$(OBJ) dv_rtf$(OBJ) dv_html$(OBJ) boxshade$(EXE): $(CFG) $(OBJS) tlink @&&| /v $(LDFLAGS) + $(BCCPATH)\LIB\c0wl.obj+ box.obj+ bx_misc.obj+ bx_read.obj+ dv_ansi.obj+ dv_ascii.obj+ dv_crt.obj+ dv_fig.obj+ dv_hpgl.obj+ dv_lj250.obj+ dv_pict.obj+ dv_ps.obj+ dv_regis.obj+ dv_rtf.obj+ dv_html.obj $<,$* $(BCCPATH)\LIB\import.lib+ $(BCCPATH)\LIB\mathwl.lib+ $(BCCPATH)\LIB\cwl.lib | #Compiler configuration file BccW16.cfg : Copy &&| -N -v -vi -ml -WS -I$(BCCPATH)\INCLUDE -D | $@ box$(OBJ): box.c bx_types.h bx_read.h dv_all.h version.h bx_read$(OBJ): bx_read.c bx_types.h bx_read.h bx_misc$(OBJ): bx_misc.c bx_types.h dv_ansi$(OBJ): dv_ansi.c bx_types.h bx_read.h dv_all.h dv_ascii$(OBJ): dv_ascii.c bx_types.h bx_read.h dv_all.h dv_crt$(OBJ): dv_crt.c bx_types.h bx_read.h dv_all.h dv_fig$(OBJ): dv_fig.c bx_types.h bx_read.h dv_all.h dv_hpgl$(OBJ): dv_hpgl.c bx_types.h bx_read.h dv_all.h dv_html$(OBJ): dv_html.c bx_types.h bx_read.h dv_all.h version.h dv_lj250$(OBJ): dv_lj250.c bx_types.h bx_read.h dv_all.h dv_pict$(OBJ): dv_pict.c bx_types.h bx_read.h dv_all.h dv_ps$(OBJ): dv_ps.c bx_types.h bx_read.h dv_all.h version.h dv_regis$(OBJ): dv_regis.c bx_types.h bx_read.h dv_all.h dv_rtf$(OBJ): dv_rtf.c bx_types.h bx_read.h dv_all.h boxshade-3.1.1.orig/positive.grp0100644000175100017510000000056406346046535016527 0ustar moellermoellerThis file is a Amino-acid grouping file for use with NEWBOX. Each line contains a set of amino acids which are considered 'similar' when calculating the consensus. This table was taken from ClustalX v1.3b: WEAK groups: These are all the positively scoring groups that occur in the Gonnet Pam250 matrix. .. FYW CSA ATV SAG STNK STPA SGND SNDEQK NDEQHK NEQHRK FVLIM HFY boxshade-3.1.1.orig/positive.sim0100644000175100017510000000202106346046535016515 0ustar moellermoellerThis file is a Amino-acid similarity file for use with BOX. This file is used in colouring residues that are "similar" to a single consensus residue. Similarities contained in this file are not automatically set-forming. This means: The line I LVM means that I is similar to L,V and M and also that L,V,M are similar to I. It does not imply that L is similar to V or to M. For achieving this, more lines (the next ones) are necessary. Although is seems weird, this feature has been chosen DELIBERATELY because I think it could be helpful in some cases. This table was taken from ClustalX v1.3b: WEAK groups: These are all the positively scoring groups that occur in the Gonnet Pam250 matrix .. F YW Y WF W FY C SA S AC A CS A TV T VA V AT S AG A GS G SA S TNK T NKS N KST K STN S TPA T PAS P AST A STP S GND G NDS N DSG D SGN S NDEQK N DEQKS D EQKSN E QKSND Q KSNDE K SNDEQ N DEQHK D EQHKN E QHKND Q HKNDE H KNDEQ K NDEQH N EQHRK E QHRKN Q HRKNE H RKNEQ R KNEQH K NEQHR F VLIM V LIMF L IMFV I MFVL M FVLI H FY F YH Y HF boxshade-3.1.1.orig/strong.grp0100644000175100017510000000056006346046535016175 0ustar moellermoellerThis file is a Amino-acid grouping file for use with NEWBOX. Each line contains a set of amino acids which are considered 'similar' when calculating the consensus. This table was taken from ClustalX v1.3b: STRONG groups: These are all the positively scoring groups that occur in the Gonnet Pam250 matrix with score >0.5 .. STA NEQK NHQK NDEQ QHRK MILV MILF HY FYW boxshade-3.1.1.orig/strong.sim0100644000175100017510000000161706346046535016201 0ustar moellermoellerThis file is a Amino-acid similarity file for use with BOX. This file is used in colouring residues that are "similar" to a single consensus residue. Similarities contained in this file are not automatically set-forming. This means: The line I LVM means that I is similar to L,V and M and also that L,V,M are similar to I. It does not imply that L is similar to V or to M. For achieving this, more lines (the next ones) are necessary. Although is seems weird, this feature has been chosen DELIBERATELY because I think it could be helpful in some cases. This table was taken from ClustalX v1.3b: STRONG groups: These are all the positively scoring groups that occur in the Gonnet Pam250 matrix with score >0.5 .. S TA T AS A ST N EQK E QKN Q KNE K NEQ N HQK H QKN Q KNH K NHQ N DEQ D EQN E QND Q NDE Q HRK H RKQ R KQH K QHR M ILV I LVM L VMI V MIL M ILF I LFM L FMI F MIL H Y F YW Y WF W FY boxshade-3.1.1.orig/version.h0100644000175100017510000000011506346046535016001 0ustar moellermoeller/* acktual boxshade version */ #define BOXSHADE_ver "v3.31 C (beta, 970507)"