$! ------------------ CUT HERE ----------------------- $ v='f$verify(f$trnlnm("SHARE_VERIFY"))' $! $! This archive created by VMS_SHARE Version 7.2-007 22-FEB-1990 $! On 16-MAY-1992 13:41:00.97 By user SEQUENCE (William R. Pearson) $! $! This VMS_SHARE Written by: $! Andy Harper, Kings College London UK $! $! Acknowledgements to: $! James Gray - Original VMS_SHARE $! Michael Bednarek - Original Concept and implementation $! $!+ THIS PACKAGE DISTRIBUTED IN 8 PARTS, TO KEEP EACH PART $! BELOW 200 BLOCKS $! $! TO UNPACK THIS SHARE FILE, CONCATENATE ALL PARTS IN ORDER $! AND EXECUTE AS A COMMAND PROCEDURE ( @name ) $! $! THE FOLLOWING FILE(S) WILL BE CREATED AFTER UNPACKING: $! 1. 00COPYRIGHT.;1 $! 2. AACOMP.C;1 $! 3. AAMAP.GBL;1 $! 4. ALIGN.1;1 $! 5. ALIGN.C;1 $! 6. ALTDIAG.MAT;1 $! 7. ALTLIB.H;1 $! 8. ALTPROT.MAT;1 $! 9. BESTSCOR.C;1 $! 10. BOVPRL.SEQ;1 $! 11. CHOFAS.C;1 $! 12. CODAA.MAT;1 $! 13. CRCK.C;1 $! 14. DNA.MAT;1 $! 15. EGMSMG.AA;1 $! 16. EXTRACTN.C;1 $! 17. EXTRACTP.C;1 $! 18. FAATRAN.C;1 $! 19. FASTA.1;1 $! 20. FASTA.RSP;1 $! 21. FASTA16.DOC;1 $! 22. FASTA16.ME;1 $! 23. FASTGBS.;1 $! 24. FFFASTA.C;1 $! 25. FGETGB.C;1 $! 26. FIND.GBL;1 $! 27. FINDN.C;1 $! 28. FINDP.C;1 $! 29. FORMAT.DOC;1 $! 30. FROMGB.C;1 $! 31. FXGETAA.C;1 $! 32. GARNIER.C;1 $! 33. GARNIER.H;1 $! 34. GBALL.NAM;1 $! 35. GBANN.C;1 $! 36. GENBANK.H;1 $! 37. GETANN.C;1 $! 38. GETOPT.C;1 $! 39. GREASE.C;1 $! 40. G_BAND.C;1 $! 41. IDNAA.MAT;1 $! 42. IDPAA.MAT;1 $! 43. LALIGN.1;1 $! 44. LALIGN.C;1 $! 45. LCBO.AA;1 $! 46. LCBO.VMS;1 $! 47. LFASTA.RSP;1 $! 48. LLMAX.C;1 $! 49. LLMAX0.C;1 $! 50. LSIM.C;1 $! 51. L_BAND.C;1 $! 52. MAKEFILE.;3 $! 53. MAKEFILE.TC;1 $! 54. MAKEFILE.UNX;1 $! 55. MAKEFILE.VMS;1 $! 56. MCHU.AA;1 $! 57. MCHU.MVS;1 $! 58. MCHU.VMS;1 $! 59. MUSPLFM.AA;1 $! 60. MUSPLFM.VMS;1 $! 61. MWKW.AA;1 $! 62. MWRTC1.AA;1 $! 63. MWRTC1.VMS;1 $! 64. NDISPN.C;1 $! 65. NRAND.C;1 $! 66. NRAND48.C;1 $! 67. NXGETAA.C;1 $! 68. PA875.AA;1 $! 69. PAM.C;1 $! 70. PAM120.MAT;1 $! 71. PAM250.MAT;1 $! 72. PCLDISPN.C;1 $! 73. PLOTSUB.C;1 $! 74. PROT.MAT;1 $! 75. QRHULD.AA;1 $! 76. QRHULD.VMS;1 $! 77. QSUBS.C;1 $! 78. QSUBS.H;1 $! 79. RDF2.1;1 $! 80. README.V15;1 $! 81. README.V16;1 $! 82. RELATE.C;1 $! 83. RSS.1;1 $! 84. SINDEX.C;1 $! 85. SSEARCH.1;1 $! 86. SSEARCH.C;1 $! 87. TGREASE.C;1 $! 88. TIME.C;1 $! 89. TLDISPN.C;1 $! 90. TPLOTSUB.C;1 $! 91. TTDISPN.C;1 $! 92. UASCII.GBL;1 $! 93. UPAM.GBL;1 $! 94. URDF.C;2 $! 95. URSS.C;1 $! 96. UWGETAA.C;1 $! 97. VMSGETEN.C;1 $! 98. ZZGMATA.GBL;1 $! 99. ZZLGMATA.C;1 $! $set="set" $set symbol/scope=(nolocal,noglobal) $f=f$parse("SHARE_TEMP","SYS$SCRATCH:.TMP_"+f$getjpi("","PID")) $e="write sys$error ""%UNPACK"", " $w="write sys$output ""%UNPACK"", " $ if f$trnlnm("SHARE_LOG") then $ w = "!" $ ve=f$getsyi("version") $ if ve-f$extract(0,1,ve) .ges. "4.4" then $ goto START $ e "-E-OLDVER, Must run at least VMS 4.4" $ v=f$verify(v) $ exit 44 $UNPACK: SUBROUTINE ! P1=filename, P2=checksum $ if f$search(P1) .eqs. "" then $ goto file_absent $ e "-W-EXISTS, File ''P1' exists. Skipped." $ delete 'f'* $ exit $file_absent: $ if f$parse(P1) .nes. "" then $ goto dirok $ dn=f$parse(P1,,,"DIRECTORY") $ w "-I-CREDIR, Creating directory ''dn'." $ create/dir 'dn' $ if $status then $ goto dirok $ e "-E-CREDIRFAIL, Unable to create ''dn'. File skipped." $ delete 'f'* $ exit $dirok: $ w "-I-PROCESS, Processing file ''P1'." $ if .not. f$verify() then $ define/user sys$output nl: $ EDIT/TPU/NOSEC/NODIS/COM=SYS$INPUT 'f'/OUT='P1' PROCEDURE Unpacker ON_ERROR ENDON_ERROR;SET(FACILITY_NAME,"UNPACK");SET( SUCCESS,OFF);SET(INFORMATIONAL,OFF);f:=GET_INFO(COMMAND_LINE,"file_name");b:= CREATE_BUFFER(f,f);p:=SPAN(" ")@r&LINE_END;POSITION(BEGINNING_OF(b)); LOOP EXITIF SEARCH(p,FORWARD)=0;POSITION(r);ERASE(r);ENDLOOP;POSITION( BEGINNING_OF(b));g:=0;LOOP EXITIF MARK(NONE)=END_OF(b);x:=ERASE_CHARACTER(1); IF g=0 THEN IF x="X" THEN MOVE_VERTICAL(1);ENDIF;IF x="V" THEN APPEND_LINE; MOVE_HORIZONTAL(-CURRENT_OFFSET);MOVE_VERTICAL(1);ENDIF;IF x="+" THEN g:=1; ERASE_LINE;ENDIF;ELSE IF x="-" THEN IF INDEX(CURRENT_LINE,"+-+-+-+-+-+-+-+")= 1 THEN g:=0;ENDIF;ENDIF;ERASE_LINE;ENDIF;ENDLOOP;t:="0123456789ABCDEF"; POSITION(BEGINNING_OF(b));LOOP r:=SEARCH("`",FORWARD);EXITIF r=0;POSITION(r); ERASE(r);x1:=INDEX(t,ERASE_CHARACTER(1))-1;x2:=INDEX(t,ERASE_CHARACTER(1))-1; COPY_TEXT(ASCII(16*x1+x2));ENDLOOP;WRITE_FILE(b,GET_INFO(COMMAND_LINE, "output_file"));ENDPROCEDURE;Unpacker;QUIT; $ delete/nolog 'f'* $ CHECKSUM 'P1' $ IF CHECKSUM$CHECKSUM .eqs. P2 THEN $ EXIT $ e "-E-CHKSMFAIL, Checksum of ''P1' failed." $ ENDSUBROUTINE $START: $ create 'f' X X Copyright 1988, 1991, 1992 by William R. Pearson and the X University of Virginia. All rights reserved. The FASTA program X and documentation may not be sold or incorporated into a X commercial product, in whole or in part, without written consent X of William R. Pearson and the University of Virginia. For X further information regarding permission for use or reproduction, X please contact: X X`09 William R. Wilkerson X`09 Assistant Provost for Research X`09 University of Virginia X`09 P.O. Box 9025 X`09 Charlottesville, VA 22906-9025 X X`09 (804) 924-6853 X $ CALL UNPACK 00COPYRIGHT.;1 1817657508 $ create 'f' X/*`09aacomp.c`09calculate the molecular wt and aa composition X`09`09`09of a protein sequence X*/`09`09`09 X X#include X#define TRUE 1 X Xchar *aa0; Xint n0; X#define MAXSEQ 5000 X Xint naac`5B23`5D; Xint naa=23; Xchar aa`5B`5D="ACDEFGHIKLMNPQRSTVWYBZX"; Xchar *saa`5B`5D=`7B"Ala","Cys","Asp","Glu","Phe","Gly","His","Ile","Lys","Le Vu", X`09 "Met","Asn","Pro","Gln","Arg","Ser","Thr","Val","Trp","Tyr", X`09 "Asx","Glx"," ? "`7D; X Xfloat wtaa`5B`5D = `7B X`0971.09, 103.15, 115.10, 129.13, 147.19, X`0957.07, 137.16, 113.17, 128.19, 113.17, X`09131.31, 114.12, 97.13, 128.15, 156.20, X`0987.09, 101.12, 99.15, 186.23, 163.19, X`09114.61, 128.64, 0.0 `7D ; X Xfloat molewt; X Xint wtwt; X XFILE *aafd; Xchar fname`5B120`5D; X Xmain(argc,argv) X`09int argc; char **argv; X`7B X`09char *calloc(); X`09int ia; X X`09wtwt=0; X`09if (argc>1) strncpy(fname,argv`5B1`5D,120); X`09else `7B X`09`09fprintf(stderr," usage - aacomp filename\n"); X`09`09exit(1); X`09`7D X X`09if ((aa0=calloc(MAXSEQ,sizeof(char)))==NULL) `7B X`09`09printf(" cannot allocate %d array\n",MAXSEQ); X`09`09exit(1); X`09`09`7D X X`09initmat(aa,naa); X X`09if (strlen(fname)>0) `7B X`09`09if ((aafd=fopen(fname,"r"))==NULL) `7B X`09`09`09printf(" cannot open %s\n",fname); X`09`09`09exit(1); X`09`09`09`7D X`09`09`7D X X`09else aafd = stdin; X X`09if ((n0=fgetseq(aa0,MAXSEQ-1,aafd))<=0) exit(0); X`09 X`09for (ia=0; ia0 && aa`5Biaa`5D>='A' && aa`5Biaa`5D<='Z') X`09`09`09aascii`5Baa`5Biaa`5D-'A'+'a'`5D=aascii`5Baa`5Biaa`5D`5D; X`09`09`7D X`09`7D X X#define FALSE 0 X Xfgetseq(seq,maxs,fptr) X`09char *seq; int maxs; FILE *fptr; X`7B X`09char line`5B120`5D; X`09int i, n; X`09int ic; X X`09i=0; X`09n=0; X`09while(fgets(line,120,fptr)!=0) `7B X`09`09if (line`5B0`5D!='>'&& line`5B0`5D!=';') X`09`09 for (i=0; (n=0); i++) X`09`09`09if (ic>0) seq`5Bn++`5D= --ic; X`09`09`7D X`09if (n==maxs) printf(" sequence may be truncated\n %d %d",n,maxs); X X`09fclose(fptr); X X`09return n; X`09`7D $ CALL UNPACK AACOMP.C;1 357989864 $ create 'f' X X/*`09aamap.gbl`09character and number translations */ X Xchar aacmap`5B64`5D=`7B X`09'K','N','K','N','T','T','T','T','R','S','R','S','I','I','M','I', X`09'Q','H','Q','H','P','P','P','P','R','R','R','R','L','L','L','L', X`09'E','D','E','D','A','A','A','A','G','G','G','G','V','V','V','V', X`09'X','Y','X','Y','S','S','S','S','X','C','W','C','L','F','L','F' X`09`7D; X Xint aamap`5B64`5D;`09/* integer aa values */ Xint aamapr`5B64`5D; /* reverse sequence map */ X X $ CALL UNPACK AAMAP.GBL;1 321663615 $ create 'f' X.TH ALIGN 1 local X.SH NAME X.B align X\- compute the global alignment of two protein or DNA sequences X X.B align0 X\- compute the global alignment of two protein or DNA sequences Xwithout penalizing for end-gaps X X X.SH SYNOPSIS X.B align X`5B -m # -s`20 X.I SMATRIX X-w # `5D sequence-file-1 sequence-file-2 X X.SH DESCRIPTION X.B align Xproduces an optimal global alignment between two protein or DNA sequences. X.B align Xwill automatically decide whether the query sequence is DNA or protein by Xreading the query sequence as protein and determining whether the X`60amino-acid composition' is more than 85% A+C+G+T. X.B align Xuses a modification of the algorithm described by E. Myers and W. Miller Xin "Optimal Alignments in Linear Space" CABIOS (1988) 4:11-17. XThe program can be invoked either with command line arguments or in Xinteractive mode. X.PP X.B align Xweights end gaps, so that an alignment of the form X.nf X.in +5 X\fC-----MACF XSRTKIMACF\fP X.in -5 Xwill have a higher score than: X.in +5 X\fCMACF XMACF\fP X.in -5 X.fi X.B align0 Xuses the same algorithm, but does not weight end gaps. Sometimes this can Xhave surprising effects. X.PP X.B align Xand X.B align0 Xuse the standard X.B fasta Xformat sequence file. Lines beginning Xwith '>' or ';' are considered comments and ignored; sequences can be upper V or Xlower case, blanks,tabs and unrecognizable characters are ignored. X.B align Xexpects sequences to use the single letter amino acid codes, see X.B protcodes(1) X\&. X.SH OPTIONS X.PP X.B align Xcan be directed to change the scoring matrix and Xoutput format by Xentering options on the command line (preceeded by a `60\-' or `60/' for XMS-DOS). All of the options should preceed the file name Xarguments. Alternately, these options can be changed by setting Xenvironment variables. The options and environment variables are: X.TP X\-m # X.B (MARKX) X=1,2,3. Alternate display of matches and mismatches in Xalignments. MARKX=1 uses ":",".","\ ", for identities, consevative Xreplacements, and non-conservative replacements, respectively. MARKX=2 Xuses "\ ","x", and "X". MARKX=3 does not show the second sequence, but Xuses the second alignment line to display matches with a "." for Xidentity, or with the mismatched residue for mismatches. MARKX=3 is Xuseful for aligning large numbers of similar sequences. X.TP X\-s str X.B (SMATRIX) Xthe filename of an alternative scoring matrix file or "120" to use the XPAM120 matrix. X.TP X\-w # X.B (LINLEN) Xoutput line length for sequence alignments. (normally 60, Xcan be set up to 200). X.SH EXAMPLES X.TP X(1) X.B align Xmusplfm.aa lcbo.aa X.PP XCompare the amino acid sequence in the file musplfm.aa with the amino acid Xsequence in the file lcbo.aa Each sequence should be in the form: X.nf X.in +5 X>LCBO bovine preprolactin XWILLLSQ ... X.in -5 X X.fi X.TP X(2) X.B align X\&-w 80 musplfm.aa lcbo.aa > musplfm.aln X.PP XCompare the amino acid sequence in the file musplfm.aa with the sequences Xin the file lcbo.aa XShow both sequences with 80 residues on Xeach output line and write the output to the file X.B musplfm.aln\c X\&. X.TP X(3) X.B align X.PP XRun the X.B align Xprogram in interactive mode. The program will prompt for Xthe file name for the first sequence and the second sequence. X.SH "SEE ALSO" Xrdf2(1),protcodes(5), dnacodes(5) X.SH AUTHOR XBill Pearson X.br Xwrp@virginia.EDU $ CALL UNPACK ALIGN.1;1 1917677242 $ create 'f' X/* align.c X`09protein driver for linear sequence comparison method X*/ X X#include X/*#include */ X X#define TRUE 1 X#define FALSE 0 X X#ifndef BIGMEM X#define MAXTST 2000`09/* longest test sequence */ X#define MAXLIB 10000 X#define MAXDIAG (MAXTST+MAXLIB) X#else X#define MAXTST 10000 X#define MAXLIB 50000 X#define MAXDIAG (MAXTST+MAXLIB) X#endif X XFILE *outfd;`09`09/* fd for output file */ X X/* globals for matching */ X Xlong lmark;`09`09/* position in library file from ftell() */ Xint nlib, onlib; Xlong ntt, ontt;`09`09/* number of library sequences, number of X`09`09`09`09residues scanned*/ Xchar libstr`5B21`5D;`09/* partial title from library sequence */ Xchar name0`5B11`5D, name1`5B11`5D;`09/* for labeling output */ Xint ixstat;`09`09/* >0 if annotations displayed */ X Xchar *aa0, *aa1;`09/* amino acid sequence data */ Xint *res; X Xint nc, nd, gscore; Xchar *seqc0, *seqc1;`09/* aligned sequences */ Xlong sq0off=1, sq1off=1; X Xint dnaseq, lcont; Xint bktup, bkfact, scfact, bestoff, bestscale, histint, bestmax; X Xint maxn, maxt;`09`09/* max space for lib sequence */ Xint n0, n1, nd, noff;`09/* length of aa0, length of aa1, n0+n1, X`09`09`09`09diagonal offset */ Xlong loffset = 0l;`09`09/* offset into sequence */ X X/* the following are defaults for values that are read by X pam.c from *.mat if SMATRIX is defined */ X Xint nshow; char rline`5B20`5D,sline`5B20`5D; X X/* output options */ Xint showall,markx, llen; X Xchar ttitle`5B60`5D, ltitle`5B60`5D; Xint smark`5B4`5D = `7B-10000,-10000,-10000,-10000`7D; Xint min0,min1,max0,max1; X Xlong tstart, tscan, tdone, stime(); X Xextern int optind; Xchar *libenv, *aaenv, *smptr; Xchar smstr`5B40`5D; X X#include "upam.gbl"`09`09/* includes pam array */ X Xmain(argc, argv) X int argc; char **argv; X`7B X`09char tname`5B40`5D, lname`5B40`5D, qline`5B40`5D; X`09int itemp, iln, nln; X`09char *calloc(), *getenv(), *cptr, *bp, *strchr(); X`09float percent; X X`09initenv(argc,argv); X X`09if ((aa0=calloc(MAXTST+MAXLIB,sizeof(char)))==0) `7B X`09`09fprintf(stderr," cannot allocate sequence array\n"); X`09`09exit(1); X`09`09`7D X`09maxn = MAXTST+MAXLIB; X X if (argc-optind < 3) `7B X printf(" align 1.6b `5BOct, 1991`5D compares two sequences\n V"); X`09l1:`09printf(" first sequence file name: "); X`09`09fflush(stdout); X`09`09fgets(tname,40,stdin); X`09`09if (tname`5Bstrlen(tname)-1`5D=='\n') tname`5Bstrlen(tname)-1`5D='\0'; X`09`09if (tname`5B0`5D=='\0') goto l1; X `09if ((n0=getseq(tname,aa0,maxn,&dnaseq))==0) `7B X fprintf(stderr," %s : %s sequence not found\n",tname,sqtyp Ve); X goto l1; X `7D X X`09`09resetp(dnaseq); X`09`09`09 X`09l2:`09printf(" second sequence file name: "); X`09`09fflush(stdout); X`09`09fgets(lname,40,stdin); X`09`09if (lname`5Bstrlen(lname)-1`5D=='\n') lname`5Bstrlen(lname)-1`5D='\0'; X`09`09if (*lname==0) goto l2; X`09`09`7D X`09else `7B X`09`09strncpy(tname,argv`5Boptind+1`5D,40); X `09if ((n0=getseq(tname,aa0,maxn,&dnaseq))==0) `7B X fprintf(stderr," %s : %s sequence not found\n",tname,sqtyp Ve); X exit(1); X `7D X`09`09resetp(dnaseq); X`09`09strncpy(lname,argv`5Boptind+2`5D,40); X`09`09`7D X X`09strncpy(name0,tname,6); name0`5B6`5D='\0'; X X`09fprintf(stderr," %s : %4d %-s\n",tname, n0, sqnam); X X`09aa1 = aa0 + n0 + 2; X`09maxn -= n0 + 3; X X`09openlib(lname,libenv); X X`09tstart = stime(); X X`09n1=getlib(aa1,maxn,libstr,&lmark,&lcont); X`09strncpy(name1,libstr,6);`20 X`09if ((bp = strchr(name1,' '))!=NULL) *bp='\0'; name1`5B6`5D='\0'; X`09gettitle(tname,ttitle,50); X`09gettitle(lname,ltitle,50); X X`09initseq(n0+n1); X X`09initpam2();`09/* convert 1-d pam to 2-d pam2 */ X`09gscore = ALIGN(&aa0`5B-1`5D,&aa1`5B-1`5D,n0,n1,pam2, X`09`09 -(gdelval-ggapval),-ggapval,res); X X`09nc=calcons(aa0,n0,aa1,n1,res); X`09percent = (double)nd*100.0/(double)nc; X X`09tdone = stime(); X X`09printf("%-50s %4d %s vs.\n%-50s %4d %s\n",ttitle,n0,sqnam,ltitle,n1,sqnam V); X`09printf("%4.1f%% identity;\tOptimized score: %d\n",percent,gscore); X X`09outfd = stdout; X`09discons(seqc0,seqc1,nc); X X`09printf("\nElapsed time: "); ptime(stdout,tdone-tstart); printf("\n"); X`09`7D X Xextern int *sascii, nascii`5B`5D, aascii`5B`5D; X Xinitenv(argc,argv) X`09int argc; X`09char **argv; X`7B X`09char *cptr, *getenv(); X`09int copt, getopt(); X`09extern char *optarg; X X`09libenv="\0"; X`09aaenv="\0"; X X`09sascii = aascii; X`09pam = apam; X`09sq = aa; X`09hsq = haa; X`09nsq = naa; X`09dnaseq = 0; X X`09showall = 1; X X`09if ((cptr=getenv("LINLEN"))!=NULL) sscanf(cptr,"%d",&llen); X`09else llen = 60; X`09if (llen>=200) llen=200-1; X`09markx=0; X`09if ((cptr=getenv("MARKX"))==NULL) markx=0; X`09else sscanf(cptr,"%d",&markx); X X`09while ((copt=getopt(argc,argv,"nm:s:w:x:"))!=EOF) X`09`09switch(copt) `7B X`09`09case 'n': dnaseq=1; X`09`09 sascii = nascii; X`09`09 sq = nt; X`09`09 nsq = nnt; X`09`09 hsq = hnt; X`09`09 pam = npam; X`09`09 strcpy(sqnam,"nt"); X`09`09 strcpy(sqtype,"DNA"); X`09`09 resetp(dnaseq); X`09`09 break; X`09`09case 'm': sscanf(optarg,"%d",&markx); break; X`09`09case 's': strncpy(smstr,optarg,sizeof(smstr)); X`09`09 smptr = smstr; X`09`09 if (initpam(smptr)) `7B X`09`09 dnaseq= -1; X`09`09 `7D X`09`09 else smptr="\0"; X`09`09 break; X`09`09case 'w': sscanf(optarg,"%d",&llen); break; X`09`09case 'x': sscanf(optarg,"%ld %ld",&sq0off,&sq1off); X`09`09 break; X`09`09 default : fprintf(stderr," illegal option -%c\n",copt); X`09`09`7D X`09 X`09optind--; X X`09if (dnaseq>=0) `7B X`09`09if ((smptr=getenv("SMATRIX"))!=NULL && initpam(smptr)) `7B X`09`09`09dnaseq = -1; X`09`09`09`7D X`09`09else X`09`09`09smptr="\0"; X`09`09`7D X X`09if (strlen(smptr)>0) fprintf(stderr," using matrix file %s\n",smptr); X`09`7D X Xresetp(dnaseq) X`09int dnaseq; X`7B X`09if (dnaseq==1) pam = npam; X`09`7D X Xinitpam2() X`7B X`09int i, j, k; X X`09k=0; X`09for (i=0; i0) `7B X`09`09`09`09*sp0++ = '-'; X`09`09`09`09*sp1++ = sq`5Baa1`5Bi1++`5D`5D; X`09`09`09`09op--; X`09`09`09`09nc++; X`09`09`09`09`7D X`09`09`09else `7B X`09`09`09`09*sp0++ = sq`5Baa0`5Bi0++`5D`5D; X`09`09`09`09*sp1++ = '-'; X`09`09`09`09op++; X`09`09`09`09nc++; X`09`09`09`09`7D X`09`09`09`7D X`09`09`7D X`09max0 = max1 = nc; X`09return nc; X`09`7D X Xinitseq(seqsiz)`09`09/* initialize arrays */ X`09int seqsiz; X`7B X`09char *calloc(); X X`09res = (int *)calloc(seqsiz,sizeof(int)); X`09seqc0=calloc(seqsiz,sizeof(char)); X`09seqc1=calloc(seqsiz,sizeof(char)); X`09if (res==NULL `7C`7C seqc0==NULL `7C`7C seqc1==NULL) X`09`09`7Bfprintf(stderr,"cannot allocate consensus arrays %d\n",seqsiz); X`09`09 exit();`7D X`09`7D X Xfreeseq() X`7B X`09free(seqc0); free(seqc1); X`09`7D X $ CALL UNPACK ALIGN.C;1 2069308379 $ create 'f' X;P improve lipman test.2 matrix (diagonals only) X 4 27 200 5 2 50 2 X -12 -4 X@ * XA R N D C Q E G H I L K M F P S T W Y V B Z X X0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 2 6 0 X 3`20 X-1 6`20 X-1 -1 7`20 X-1 -1 -1 6`20 X-1 -1 -1 -1 14`20 X-1 -1 -1 -1 -1 4`20 X-1 -1 -1 -1 -1 -1 4`20 X-1 -1 -1 -1 -1 -1 -1 6`20 X-1 -1 -1 -1 -1 -1 -1 -1 10`20 X-1 -1 -1 -1 -1 -1 -1 -1 -1 5`20 X-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 5`20 X-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 4`20 X-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 9`20 X-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 8`20 X-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 5`20 X-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 2`20 X-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 4`20 X-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 12`20 X-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 10`20 X-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 4`20 X-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 4`20 X-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 3`20 X-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 X $ CALL UNPACK ALTDIAG.MAT;1 1233066960 $ create 'f' X X#define LASTLIB 10 X#define BINARYGB 9 X#define DEFAULT 0 X#define FULLGB 1 X#define UNIXPIR 2 X#define EMBLSWISS 3 X#define INTELLIG 4 X#define VMSPIR 5 X Xextern int (*getlib)(), (*ranlib)(); X Xint agetlib(),aranlib();`09/* pearson fasta format */ Xint ggetlib(),granlib();`09/* compressed genbank format BINARYGB */ Xint lgetlib(),lranlib();`09/* full uncompressed GB FULLGB*/ Xint pgetlib(),pranlib();`09/* PIR UNIX protein UNIXPIR */ Xint egetlib(),eranlib();`09/* EMBL/SWISS-PROT EMBLSWISS */ Xint igetlib(),iranlib();`09/* Intelligenetics INTELLIG */ Xint vgetlib(),vranlib();`09/* PIR VMS format */ X Xint (*getliba`5BLASTLIB`5D)()=`7B X`09agetlib,lgetlib,pgetlib,egetlib, X`09igetlib,vgetlib,agetlib,agetlib, X`09agetlib,ggetlib`7D; X Xint (*ranliba`5BLASTLIB`5D)()=`7B X`09aranlib,lranlib,pranlib,eranlib, X`09iranlib,vranlib,aranlib,aranlib, X`09aranlib,granlib`7D; $ CALL UNPACK ALTLIB.H;1 2132280748 $ create 'f' X;P improve lipman test.1 matrix X 4 27 200 5 2 50 2 X -12 -4 X@ * XA R N D C Q E G H I L K M F P S T W Y V B Z X X0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 2 6 0 X 3`20 X-1 6`20 X-1 -1 7`20 X-1 -1 2 6`20 X-2 -1 -3 -7 14`20 X 0 1 -1 1 -3 4`20 X 0 0 -1 3 -2 2 4`20 X 0 -4 -1 -3 -2 -1 -2 6`20 X-4 0 -1 1 -1 0 0 -3 10`20 X-1 -4 -4 -3 -4 -1 -2 -5 -3 5`20 X-2 -2 -4 -5 -4 -4 -3 -4 -3 4 5`20 X 0 2 0 1 -1 0 1 -2 -1 -2 -3 4`20 X-1 0 0 -5 -3 -1 -4 -4 -1 4 2 -1 9`20 X-3 -4 -3 -4 -6 -4 -2 -5 -2 1 1 -5 2 8`20 X-3 -4 -2 -1 -1 -1 -1 -3 -1 -4 -4 -1 -3 -2 5`20 X 1 -1 1 0 -3 -2 -1 0 -2 -4 -3 -1 -1 -2 -1 2`20 X 1 -1 -1 -1 -1 1 0 -2 -1 0 -1 0 -1 -4 -2 1 4`20 X-1 -1 -1 -3 -6 -2 -1 -2 -2 -1 -1 -2 -1 2 -1 -2 -2 12`20 X-3 -2 -1 -4 -7 -2 -3 -3 2 -1 -1 -1 1 5 -1 -3 -4 3 10`20 X 0 -4 -1 -2 -2 -1 -1 -5 -2 4 1 -3 1 -1 -4 -1 0 -7 -1 4`20 X-1 -1 4 4 -5 0 1 -2 0 -3 -5 1 -3 -4 -1 0 -1 -2 -3 -2 4`20 X 0 0 -1 2 -2 3 3 -2 0 -2 -3 1 -3 -3 -1 -1 0 -1 -3 -1 1 3`20 X-1 -1 -1 -1 2 -1 -1 -1 -1 -1 -1 -1 -1 2 -1 -1 -1 -1 -1 -1 -1 -1 -1 X $ CALL UNPACK ALTPROT.MAT;1 643132780 $ create 'f' X/*`09bestscor.c`0913-Mar-1985`09*/ X X/*`09copyright (C) 1983 William R. Pearson */ X X#include X X#define TRUE 1 X#define FALSE 0 X X#define MAXTST 1000`09/* longest test sequence */ X#define MAXLIB 3000`09/* longest library sequence (not used) */ X#define MAXDIAG 4000`09/* sum of test and library sequence */ X Xchar *aa0; Xint n0; X X#include "upam.gbl" X#define XTERNAL X#include "uascii.gbl" Xint histint=2; Xint bestscale=200; Xint bkfact=5; Xint scfact=4; Xint bktup=2; Xint ktmax=2; Xint bestmax=50; Xint bestoff=27;`09/* values for calculating bestcut */ Xint dnaseq = 0; X Xextern int optind; Xchar smstr`5B40`5D, *smptr; X Xmain(argc, argv) X`09int argc; char **argv; X`7B X`09char rline`5B40`5D, tname`5B40`5D; X`09char *calloc(), *getenv(), *smptr; X X`09initenv(argc,argv); X X if (argc-optind < 2) `7B X printf(" bestscor calculates the score of a 100%% identical V match\n"); X`09`09printf(" using the %s scoring matrix\n",smptr); X`09`09printf(" test sequence file name: "); X`09`09fgets(tname,40,stdin); X`09`09if (tname`5Bstrlen(tname)-1`5D=='\n') tname`5Bstrlen(tname)-1`5D='\0'; X`09`09`7D X`09else `7B X`09`09strncpy(tname,argv`5Boptind+1`5D,40); X`09`09`7D X X`09if ((aa0=calloc(MAXDIAG,sizeof(char)))==0) `7B X`09`09printf(" cannot allocate sequence array\n"); X`09`09exit(); X`09`09`7D X X if ((n0=getseq(tname,aa0,MAXDIAG,&dnaseq))==0) `7B X printf(" %s : %s sequence not found\n",tname,sqtype); X exit(); X `7D X X`09resetp(dnaseq); X X`09initpam2();`09`09/* convert 1-d pam to 2-d pam2 */ X X`09printf(" %s : %4d %s\n",tname, n0,sqnam); X`09printf(" 100%% identical score is %d\n",shscore(aa0,n0)); X`09`7D X Xextern int *sascii, nascii`5B`5D, aascii`5B`5D; X Xinitenv(argc,argv) X`09int argc; char **argv; X`7B X`09char *cptr, *getenv(); X`09int copt, getopt(); X`09extern char *optarg; X X`09sascii = aascii; X`09pam = apam; X`09sq = aa; X`09hsq = haa; X`09nsq = naa; X`09dnaseq = 0; X X`09while ((copt=getopt(argc,argv,"s:"))!=EOF) X`09`09switch(copt) `7B X`09`09`09case 's': strncpy(smstr,optarg,sizeof(smstr)); X`09`09`09`09smptr=smstr; X`09`09`09`09if (initpam(smptr)) dnaseq= -1; X`09`09`09`09else smptr="\0"; X`09`09`09`09break; X`09`09`09default : fprintf(stderr," illegal option -%c\n",copt); X`09`09`09`7D X`09optind--; X X`09if (dnaseq>=0) `7B X`09`09if ((smptr=getenv("SMATRIX"))!=NULL && initpam(smptr)) X`09`09`09dnaseq = -1; X`09`09else X`09`09`09smptr="\0"; X`09`09`7D X X`09 X`09if (strlen(smptr)>0) fprintf(stderr," using matrix file %s\n",smptr); X`09`7D X Xresetp(dnaseq) X`09int dnaseq; X`7B X`09if (dnaseq==1) `7B X`09`09pam = npam; X`09`09`7D X`09`7D X Xshscore(aa0,n0)`09/* calculate the 100% identical score */ X`09char *aa0; int n0; X`7B X`09int i, sum; X`09for (i=0,sum=0; i='a' && c<='z') return c-('a'+'A'); X`09else return c; X`09`7D $ CALL UNPACK BESTSCOR.C;1 1143299265 $ create 'f' X>BOVPRL GenBank entry BOVPRL from omam file. 907 nucleotides. XTGCTTGGCTGAGGAGCCATAGGACGAGAGCTTCCTGGTGAAGTGTGTTTCTTGAAATCAT XCACCACCATGGACAGCAAAGGTTCGTCGCAGAAAGGGTCCCGCCTGCTCCTGCTGCTGGT XGGTGTCAAATCTACTCTTGTGCCAGGGTGTGGTCTCCACCCCCGTCTGTCCCAATGGGCC XTGGCAACTGCCAGGTATCCCTTCGAGACCTGTTTGACCGGGCAGTCATGGTGTCCCACTA XCATCCATGACCTCTCCTCGGAAATGTTCAACGAATTTGATAAACGGTATGCCCAGGGCAA XAGGGTTCATTACCATGGCCCTCAACAGCTGCCATACCTCCTCCCTTCCTACCCCGGAAGA XTAAAGAACAAGCCCAACAGACCCATCATGAAGTCCTTATGAGCTTGATTCTTGGGTTGCT XGCGCTCCTGGAATGACCCTCTGTATCACCTAGTCACCGAGGTACGGGGTATGAAAGGAGC XCCCAGATGCTATCCTATCGAGGGCCATAGAGATTGAGGAAGAAAACAAACGACTTCTGGA XAGGCATGGAGATGATATTTGGCCAGGTTATTCCTGGAGCCAAAGAGACTGAGCCCTACCC XTGTGTGGTCAGGACTCCCGTCCCTGCAAACTAAGGATGAAGATGCACGTTATTCTGCTTT XTTATAACCTGCTCCACTGCCTGCGCAGGGATTCAAGCAAGATTGACACTTACCTTAAGCT XCCTGAATTGCAGAATCATCTACAACAACAACTGCTAAGCCCACATTCCATCCTATCCATT XTCTGAGATGGTTCTTAATGATCCATTCCCTGGCAAACTTCTCTGAGCTTTATAGCTTTGT XAATGCATGCTTGGCTCTAATGGGTTTCATCTTAAATAAAAACAGACTCTGTAGCGATGTC XAAAATCT $ CALL UNPACK BOVPRL.SEQ;1 1685803492 $ create 'f' X X/*`09chofas.c`09an adaptation of Kanehisa's fortran program X*/ X X#include X X#include "upam.gbl" X#define XTERNAL X#include "uascii.gbl" X Xchar amino`5B`5D=`7B'A','R','N','D','C','Q','E','G','H','I','L','K','M', X`09`09'F','P','S','T','W','Y','V','X',' ',' '`7D; X Xchar charge`5B`5D=`7B' ','+',' ','-',' ',' ','-',' ','.',' ',' ','+',' ', X`09`09' ',' ',' ',' ',' ',' ',' ',' '`7D; X Xfloat hydro`5B`5D=`7B0.5,0.0,0.0,0.0,1.0,0.0,0.0,0.0,0.5,1.8,1.8,0.0,1.3, X`09`092.5,0.0,0.0,0.4,3.4,2.3,1.5,0.0`7D; X Xint amap`5B23`5D;`20 Xint dnaseq= -1; X X#define MAXSEQ 1000 Xchar`09iseq`5BMAXSEQ`5D; Xint`09n0; X#define MAXT 60 Xchar title`5BMAXT`5D; X Xchar`09cph`5BMAXSEQ`5D, cps`5BMAXSEQ`5D, cpt`5BMAXSEQ`5D; Xint`09iph`5BMAXSEQ`5D, ips`5BMAXSEQ`5D; Xfloat`09ph`5BMAXSEQ`5D, ps`5BMAXSEQ`5D, hyd`5BMAXSEQ`5D, smd`5BMAXSEQ`5D; Xint iarr`5B3`5D; X Xmain(argc,argv) X`09int argc; char *argv`5B`5D; X`7B X`09float ya, yb, yc, da, dab, dbc, db, fn0; X`09int i, l0, l1; X`09`09 X`09if (argc < 2) `7B X`09`09printf(" usage - chofas filename\n"); X`09`09exit(1); X`09`09`7D X X`09sascii = aascii; X`09if ((n0=getseq(argv`5B1`5D,iseq,MAXSEQ,&dnaseq))<=0) `7B X`09`09fprintf(stderr," could not read %s\n",argv`5B1`5D); X`09`09exit(1); X`09`09`7D X`09gettitle(argv`5B1`5D,title,MAXT); X X`09makemap(amino,amap,naa); X X`09for (i=0; i= 8 out of six residues`09*/ X X`09for (i=0; i= 8) `7B X`09`09for (i1=i; i1=0 && parr`5Biseq`5Bi2`5D`5D.nh == 0; i2--); X`09`09for (k=i1; k= 3) `7B X`09`09`09for (i1=i; i1=0 && (parr`5Biseq`5Bi2`5D`5D.ns == 0); i2--); X`09`09`09for (k=i1; k=4; i--) `7B X`09`09`09if (iph`5Bi`5D!=0) continue; X`09`09`09if (ph`5Bi-4`5D < 1.0 && mh`5Bi-4`5D < 0) break; X`09`09`09iph`5Bi`5D = 1; X`09`09`09`7D X`09`09i = i2-1; X`09`09`7D X X/* ---Sheet propagation and termination---`09*/ X X`09for(i=0; i=3; i--) `7B X`09`09`09if (ips`5Bi`5D!=0) continue; X`09`09`09if (ps`5Bi-4`5D<1.0 && ms`5Bi-4`5D<=0) break; X`09`09`09ips`5Bi`5D=1; X`09`09`09`7D X`09`09i = i2-1; X`09`09`7D X X/*`09helix boundaries`09*/ X X`09k=0; X`09ipr=0; X`09for (i=0; i 2) goto l55; Xl53:`09iph`5Bi`5D=k; X`09`09l++; X`09`09goto l60; Xl55:`09if (l>5) goto l51; X`09`09l1 = l-1; X`09`09for (j=0; j5) goto l60; X`09`09l1 = l-1; X`09`09for (j=0; j0) `7B X`09c = *s++; X`09/* if (parity)*/ X`09c &= 0177; X`09q = (crc `5E c) & 017;`09`09/* Low-order nibble */ X`09crc = (crc >> 4) `5E (q * 010201); X`09q = (crc `5E (c >> 4)) & 017;`09/* High order nibble */ X`09crc = (crc >> 4) `5E (q * 010201); X `7D X return(crc); X`7D $ CALL UNPACK CRCK.C;1 1315135270 $ create 'f' X;D standard DNA scoring matrix X 1 45 80 5 6 80 4 X -12 -4 X* @ 0 1 2`20 XACGTRYMWSKDHVBN X0 1 2 3 0 1 0 0 1 2 0 0 0 1 0 X 4`20 X-3 4`20 X-3 -3 4`20 X-3 -3 -3 4`20 X 1 -1 1 -1 1`20 X-1 1 -1 1 -3 1`20 X 1 1 -2 -2 0 0 1`20 X 1 -2 -2 1 0 0 0 1`20 X-2 1 1 -2 0 0 0 0 1`20 X-2 -2 1 1 0 0 0 0 0 1`20 X 1 -2 1 1 1 0 0 1 0 1 1`20 X 1 1 -2 1 0 1 1 1 0 0 0 1`20 X 1 1 1 -2 1 0 1 0 1 0 0 0 1`20 X-2 1 1 1 0 1 0 0 1 1 0 0 0 1`20 X 1 1 1 1 0 0 0 0 0 0 0 0 0 0 1 X $ CALL UNPACK DNA.MAT;1 2016032945 $ create 'f' X>EGMSMG Epidermal growth factor precursor - Mouse XMPWGRRPTWLLLAFLLVFLKISILSVTAWQTGNCQPGPLERSERSGTCAGPAPFLVFSQGKSISRIDPDG XTNHQQLVVDAGISADMDIHYKKERLYWVDVERQVLLRVFLNGTGLEKVCNVERKVSGLAIDWIDDEVLWV XDQQNGVITVTDMTGKNSRVLLSSLKHPSNIAVDPIERLMFWSSEVTGSLHRAHLKGVDVKTLLETGGISV XLTLDVLDKRLFWVQDSGEGSHAYIHSCDYEGGSVRLIRHQARHSLSSMAFFGDRIFYSVLKSKAIWIANK XHTGKDTVRINLHPSFVTPGKLMVVHPRAQPRTEDAAKDPDPELLKQRGRPCRFGLCERDPKSHSSACAEG XYTLSRDRKYCEDVNECATQNHGCTLGCENTPGSYHCTCPTGFVLLPDGKQCHELVS XCPGNVSKCSHGCVLTSDGPRCICPAGSVLGRDGKTCTGCSSPDNGGCSQICLPLRPGSWECDCFPGYDLQ XSDRKSCAASGPQPLLLFANSQDIRHMHFDGTDYKVLLSRQMGMVFALDYDPVESKIYFAQTALKWIERAN XMDGSQRERLITEGVDTLEGLALDWIGRRIYWTDSGKSVVGGSDLSGKHHRIIIQERISRPRGIAVHPRAR XRLFWTDVGMSPRIESASLQGSDRVLIASSNLLEPSGITIDYLTDTLYWCDTKRSVIEMANLDGSKRRRLI XQNDVGHPFSLAVFEDHLWVSDWAIPSVIRVNKRTGQNRVRLQGSMLKPSSLVVVHPLAKPGADPCLYRNG XGCEHICQESLGTARCLCREGFVKAWDGKMCLPQDYPILSGENADLSKEVTSLSNST XQAEVPDDDGTESSTLVAEIMVSGMNYEDDCGPGGCGSHARCVSDGETAECQCLKGFARDGNLCSDIDECV XLARSDCPSTSSRCINTEGGYVCRCSEGYEGDGISCFDIDECQRGAHNCAENAACTNTEGGYNCTCAGRPS XSPGRSCPDSTAPSLLGEDGHHLDRNSYPGCPSSYDGYCLNGGVCMHIESLDSYTCNCVIGYSGDRCQTRD XLRWWELRHAGYGQKHDIMVVAVCMVALVLLLLLGMWGTYYYRTRKQLSNPPKNPCDEPSGSVSSSGPDSS XSGAAVASCPQPWFVVLEKHQDPKNGSLPADGTNGAVVDAGLSPSLQLGSVHLTSWRQKPHIDGMGTGQSC XWIPPSSDRGPQEIEGNSHLPSYRPVGPEKLHSLQSANGSCHERAPDLPRQTEPVK`20 $ CALL UNPACK EGMSMG.AA;1 1090998961 $ create 'f' X/*`09extract.c`09lookup GenBank sequences in the library */ X X/* `09placed in the public domain by William R. Pearson */ X X/*`09this is a version of libprot that uses an index file */ X X X#include X#ifndef MACLSC X#include X#else X#include X#include X#include XSFReply freply; XPoint wpos; Xint tval; Xchar prompt`5B256`5D; X#endif X X#define EOSEQ 127 X#define MAXSQ 32 Xchar nt`5BMAXSQ`5D=`7B'A','C','G','T','U','R','Y','M','W','S','K','D','H','V V','B','N','X'`7D; Xint nnt = 17; X X X#define XTERNAL X#include "genbank.h" X X#define GBFMAX 13 Xchar *gbfiles`5B`5D = `7B"gpri","grod","gmam","gvrt","ginv","gpln", X`09`09 "gorg","gbct","grna","gvrl","gphg","gsyn","guna","gtst"`7D; Xint gb57vers; X X#define NAMLEN 10 X XFILE *tptr, *optr;`09/* file pointers for input, lib, output */ Xint flib; X Xint fidx;`09`09`09/* fd for index */ X X#ifndef UNIX X#define BMODE 0x8000 X#else X#define BMODE 0 X#endif X X#define RMODE 0 Xlong filen, lseek(); Xunsigned minidx,maxidx; X Xstruct ilibhdr idxhdr; Xstruct idxrec indexf; Xstruct alibhdr annhdr; Xextern struct slibhdr libhdr; X Xchar lline`5B512`5D, seqnam`5B120`5D, oname`5B120`5D, lname`5B120`5D; X X#ifdef BIGMEM X#define MAXSEQ 100000 X#else X#define MAXSEQ 20000 X#endif X Xchar *seq, libstr`5B40`5D, *calloc(); Xlong nseq; Xlong libpos; Xchar *libenv; X#ifdef MACLSC Xint glvRef,anvRef, sqvRef, ouvRef; X#endif X Xmain(argc,argv) X`09int argc; char **argv; X`7B X`09char tname`5B40`5D,iname`5B120`5D,iiname`5B120`5D; X`09int i; X`09char *getenv(),*tp,*strpbrk(); X X#ifdef MACLSC X`09Click_On(FALSE); X`09GetVol(prompt,&ouvRef); X`09wpos.h=50; wpos.v=100; X#endif X X`09if ((libenv=getenv("GBLIB"))==NULL) libenv="\0"; X`09strncpy(iname,"glocus.idx",sizeof(iname)); X X`09if (argc < 2) `7B X`09`09printf(" extractn - get sequences from a GenBank library\n"); X`09`09tname`5B0`5D='\0'; X`09`09`7D X`09else `7B X`09`09strncpy(tname,argv`5B1`5D,40); X`09`09`7D X X`09strncpy(iiname,libenv,120); X#ifdef UNIX X`09if (strlen(libenv)>0) strncat(iiname,"/",120); X#endif X`09strncat(iiname,iname,120-strlen(iiname)); X X#ifndef MACLSC Xl2:`09if ((fidx=open(iiname,BMODE+RMODE)) <= 0) `7B X`09`09printf(" could not open index file: %s\n",iiname); X`09`09printf(" index file name `5B%s`5D: ",iiname); X`09`09fgets(iiname,40,stdin); X`09`09if ((tp=strpbrk(iiname,"\r\n"))!=NULL) *tp='\0'; X`09`09goto l2; X`09`09`7D X#else Xl2:`09if ((fidx=open(iiname,BMODE+RMODE)) == -1) `7B X`09`09libenv = "\0"; X`09`09sprintf(prompt,"Cannot open %s\r\rSelect index file",iiname); X`09`09FileDlog(prompt,&freply); X`09`09if (freply.good==TRUE) `7B`09 X`09`09`09PtoCstr(freply.fName); X`09`09`09strcpy(iiname,freply.fName); X`09`09`09glvRef = anvRef = sqvRef = freply.vRefNum; X`09`09`09SetVol("\p\0",glvRef); X`09`09`09goto l2; X`09`09`09`7D X`09`09else return; X`09`09`7D X#endif X X`09read(fidx,(char *)&idxhdr,sizeof(idxhdr)); X`09gb57vers = (idxhdr.rlsnam`5B1`5D-'0')*10 + idxhdr.rlsnam`5B2`5D-'0'; X X`09minidx=(unsigned)idxhdr.firstrec`5B0`5D+(unsigned)idxhdr.firstrec`5B1`5D* V256-1; X`09maxidx = (unsigned)idxhdr.lastrec`5B0`5D+(unsigned)idxhdr.lastrec`5B1`5D* V256; X X`09if ((seq = calloc(MAXSEQ,sizeof(char)))==0) `7B X`09`09printf(" cannot allocate seq array\n"); X`09`09exit(); X`09`09`7D X X`09while (getnames(tname,40)); `09/* get the sequence names and hash them */ X`09`7D X X/* newname generates a new filename with prefix oname and suffix suff */ X Xnewname(nname,oname,suff,maxn) X`09char *nname, *oname, *suff; X`7B X`09char *tptr; X`09strncpy(nname,oname,maxn); X X`09for (tptr=nname; *tptr!='.'&& *tptr; tptr++); /* get to '.' or EOS */ X`09*tptr++='.'; *tptr='\0'; X`09strncat(nname,suff,maxn); X`09`7D X Xgetnames(tname,maxnam)`09/* read in the names and hash them */ X`09char *tname; int maxnam; X`7B X`09int i, tflag; X`09char *strchr(),*bp; X X`09if (tflag=(strlen(tname)==0)) `7B`09/* get names from keyboard */ X`09`09printf(" GenBank sequence identifier: "); X`09`09fgets(tname,maxnam,stdin); X`09`09if ((bp=strchr(tname,'\n'))!=NULL) *bp='\0'; X`09`09if (tname`5B0`5D=='\0') return 0; X`09`09oname`5B0`5D=' '; X`09`09`7D X`09else oname`5B0`5D='\0'; X X`09if (lookup(tname)==0) X`09`09printf(" sequence %s not found\n",tname); X`09else `7B X`09 if (oname`5B0`5D==' ') `7B X`09`09fprintf(stderr," filename for %s: ",tname); X`09`09fgets(oname,sizeof(oname),stdin); X`09`09if ((bp=strchr(oname,'\n'))!=NULL) *bp='\0'; X`09`09`7D X`09 putfile(tname); X`09 `7D X`09tname`5B0`5D='\0'; X`09return tflag; X`09`7D X Xucase(str)`09/* convert a string to upper case */ X`09char *str; X`7B X`09while (*str) `7B X`09`09if (*str >= 'a' && *str <= 'z') *str -= 'a' - 'A'; X`09`09str++; X`09`09`7D X`09`7D X Xlookup(name)`09/* lookup names in library */ X`09char *name; X`7B X`09long hi, lo, mid, diff; X`09long pos; X`09char tname`5B20`5D; X X`09strncpy(tname,name,sizeof(tname)); X X`09ucase(tname); X`09strncat(tname," ",10-strlen(tname)); X X/* binary search for code */ X X`09lo = minidx; X`09hi = maxidx; X X`09while (hi >= lo) `7B X`09`09mid = (hi + lo)/2; X`09`09pos = (long)mid * (long)sizeof(indexf); X`09`09lseek(fidx, pos, 0); X`09`09read(fidx, &indexf, sizeof(indexf)); X`09`09if ((diff = strncmp(tname, indexf.name,10)) == 0) `7B X`09`09`09return 1; X`09`09`09`7D X`09`09else if (diff < 0) X`09`09`09hi = mid - 1; X`09`09else X`09`09`09lo = mid + 1; X`09`09`7D X`09return 0; X`09`7D X Xextern int libfd; Xint ixstat= -1; Xidxann() `7B`7D; X Xputfile(seqnam) X`09char *seqnam; X`7B X`09long lpos; X`09int i, nt, lcont; X`09char llname`5B120`5D; X X`09if (strlen(oname)>0) `7B X#ifdef MACLSC X`09`09SetVol("\p",ouvRef); X#endif X`09`09if ((optr=fopen(oname,"w"))==0) `7B X`09`09`09printf(" cannot open %s\n",oname); X`09`09`09optr=stdout; X`09`09`09`7D X`09`09`7D X`09else optr=stdout; X X`09strncpy(llname,libenv,120); X#ifdef UNIX X`09if (strlen(libenv)>0) strncat(llname,"/",120);`09 X#endif X`09strncpy(lname,gbfiles`5Bindexf.divnum-1`5D,120); X`09if (gb57vers < 57)`20 X`09 sprintf(&lname`5B4`5D,"%d.ano",(indexf.filenum&0xF0)>>4); X`09else X`09 sprintf(&lname`5B4`5D,"%d.ano",indexf.filenum); X X`09strncat(llname,lname,120-strlen(llname)); X`09openann(llname); X`09lpos = ((long)(indexf.annrec`5B0`5D+indexf.annrec`5B1`5D*256-1))* X`09`09(long)(annhdr.recln`5B0`5D+annhdr.recln`5B1`5D*256); X`09ranann(lpos); X`09getann(lline,512); X`09closeann(); X`09for (i=0; i<10&&seqnam`5Bi`5D; i++) `7B X`09`09if (seqnam`5Bi`5D==' ') break; X`09`09libstr`5Bi`5D=seqnam`5Bi`5D; X`09`09`7D X X`09libstr`5Bi`5D='\0'; X X`09fprintf(optr,">%s - %s\n",libstr,lline); X X`09if (gb57vers < 57) X`09 sprintf(&lname`5B4`5D,"%d.seq",indexf.filenum&0xF); X`09else X`09 sprintf(&lname`5B4`5D,"%d.seq",indexf.filenum); X X`09openlib(lname,libenv); X`09lpos = ((long)(indexf.seqrec`5B0`5D+indexf.seqrec`5B1`5D*256-1))* X`09`09(long)(libhdr.recln`5B0`5D+libhdr.recln`5B1`5D*256); X X`09lseek(libfd,lpos,0); X X`09nseq = 0l; X`09lcont=0; X`09while ((nt=getlib(seq,MAXSEQ,libstr,&libpos,&lcont))>0)`7B X`09`09nseq += nt; X`09`09if (lcont==0) break; X`09`09putlib(seq,nt,optr); X`09`09`7D X`09putlib(seq,nt,optr); X`09if (optr!=stdout) fclose(optr); X`09closelib(); X`09fprintf(stderr,"%s %ld\n",libstr,nseq); X`09fprintf(stderr," %s\n",lline); X`09`7D X Xputlib(seq,n,optr) X`09char *seq; X`09int n; X`09FILE *optr; X`7B X`09char *sp; X`09int i, j, ni; X X`09ni = ((n+59)/60)-1; X X`09sp = seq; X`09for (i=0; i"); X`09`09fgets(rline,10,stdin); X`09`09if (toupper(rline`5B0`5D)=='Y') return 0; X`09`09goto l1; X`09`09`7D X#else X`09SetVol("\p",anvRef); X`09if ((annfd=open(lname,O_RDONLY+O_BINARY))==-1) `7B X`09`09libenv="\0"; Xl1:`09`09SetVol("\p",anvRef); X`09`09if ((annfd=open(lname,O_RDONLY+O_BINARY))==-1) `7B X`09`09`09sprintf(prompt," cannot open %s\r\r Select Annotation File",lname); X`09`09`09FileDlog(prompt,&freply); X`09`09`09if (freply.good==TRUE) `7B`09 X`09`09`09`09PtoCstr(freply.fName); X`09`09`09`09strcpy(lname,freply.fName); X`09`09`09`09anvRef=sqvRef=freply.vRefNum; X`09`09`09`09goto l1; X`09`09`09`09`7D X`09`09`09else return -1; X`09`09`09`7D X`09`09`7D X#endif X X`09if (read(annfd,(char *)&annhdr,sizeof(annhdr))==-1) `7B X`09`09printf(" could not read %s annot file\n",lname); X`09`09return -1; X`09`09`7D X X`09return 1; X`09`7D X Xcloseann() X`7B X`09if (annfd>0) `7B X`09`09close(annfd); X`09`09annfd = -1; X`09`09`7D X`09`7D X Xranann(seek) X`09long seek; X`7B X`09lseek(annfd,seek,0); X`09`7D X Xgetann(line,maxl) X`09char *line; int maxl; X`7B X`09int i, j; X X`09j=0; X`09if (read(annfd,annot,ANRLEN)<=0) `7B X`09`09line`5B0`5D='\0'; X`09`09return 0; X`09`09`7D X X`09annot`5BANRLEN`5D='\0'; X`09for (i=19; i0) `7B X`09`09annot`5BANRLEN`5D='\0'; X`09`09for (i=0; i='a' && c<='z') return c-('a'+'A'); X`09else return c; X`09`7D X#endif X $ CALL UNPACK EXTRACTN.C;1 1766102975 $ create 'f' X/*`09extract.c`09lookup protein sequences in the library */ X X/* `09copyright (c) 1984, 1985 William R. Pearson */ X X/*`09this is a version of libprot that uses an index file */ X X X#include X#include X#include X X#ifdef THINK_C X#include X#define getenv mgetenv X#include X#include XSFReply freply; XPoint wpos; Xint tval; Xchar prompt`5B256`5D; X#else X#define TRUE 1 X#define FALSE 0 X#endif X X#define NAMLEN 11 X XFILE *tptr, *lptr, *optr;`09/* file pointers for input, lib, output */ XFILE *finx; X Xint fidx;`09`09`09/* fd for index */ X#ifndef UNIX X#define BMODE 0x8000 X#else X#define BMODE 0x0000 X#endif X#define RMODE 0 Xlong filen, lseek(); Xlong maxidx; X Xlong lmark; Xint lfn; X Xstruct `7B X`09char nam`5BNAMLEN`5D; X`09char fn; X`09long lmark; X`09`7D seq; X Xlong lboff;`09`09/* offset into index file for new type */ X X#define MAXLF 20 X#define MAXLN 50 Xchar libenv`5B80`5D; Xchar lbnarr`5B1000`5D;`09/* name array of libraries to be opened in list */ Xchar *lbnames`5BMAXLF`5D;`09/* names of libraries to be opened */ Xint libfn;`09`09/* current library file being searched */ Xint iln, nln; X Xchar lline`5B512`5D, oline`5B512`5D, seqnam`5B120`5D, oname`5B40`5D; X X#ifdef THINK_C Xint glvRef,anvRef, sqvRef, ouvRef; X#endif X Xmain(argc,argv) X`09int argc; char **argv; X`7B X`09char tname`5B80`5D, lname`5B80`5D, iname`5B80`5D, inname`5B80`5D, rline`5 VB40`5D, *ep, *getenv(); X`09int i, ilb, tmode; X`09char *bp, *strchr(); X X#ifdef THINK_C X`09if (OpenResFile("\pFASTA.rsrc")<0) `7B X`09`09SysBeep(100); fprintf(stderr," WARNING FASTA.rsrc file could not be fo Vund\n"); X`09`09`7D X`09GetVol(prompt,&ouvRef); X`09sqvRef=ouvRef; X`09wpos.h=50; wpos.v=100; X#endif X X`09tname`5B0`5D='\0'; X X`09printf(" extractp `5BMay '90 1.4c`5D - get sequences from a sequence libr Vary\n"); X`09if (argc < 2) `7B X`09`09if ((ep=getenv("AABANK"))==NULL) `7B X`09`09`09ep="\0"; X`09l1:`09`09printf(" library file name: "); X`09`09`09fgets(lname,40,stdin); X`09`09`09if (lname`5Bstrlen(lname)-1`5D=='\n') X`09`09`09`09lname`5Bstrlen(lname)-1`5D='\0'; X`09`09`09if (*lname==0) `7B X`09`09`09`09if (*ep==0) goto l1; X`09`09`09`09else strncpy(lname,ep,80); X`09`09`09`09`7D X`09`09`09`7D X`09`09else `7B X`09`09`09strncpy(lname,ep,80); X`09`09`09printf(" using %s: library file\n",lname); X`09`09`09`7D X`09`09newname(iname,lname,"ixx",80); X`09`09newname(inname,lname,"inx",sizeof(inname)); X`09`09`7D X`09else `7B X`09`09strncpy(lname,argv`5B1`5D,80); X`09`09printf(" using %s library\n",lname); X`09`09newname(iname,lname,"ixx",80); X`09`09newname(inname,lname,"inx",sizeof(inname)); X`09`09`7D X Xl2:`09if ((fidx=open(iname,BMODE+RMODE)) == -1) `7B X#ifndef THINK_C X`09`09printf(" could not open index file: %s\n",iname); X`09`09printf(" index file name `5B%s`5D: ",iname); X`09`09fgets(iname,40,stdin); X`09`09if (iname`5Bstrlen(iname)-1`5D=='\n') iname`5Bstrlen(iname)-1`5D='\0'; X`09`09goto l2; X#else X`09`09sprintf(prompt," could not open index file: %s\r Select index filename V",iname); X`09`09FileDlog(prompt,&freply); X`09`09if (freply.good==TRUE) `7B X`09`09`09strcpy(libenv,"\0");`09 X`09`09`09PtoCstr((char *)freply.fName); X`09`09`09strcpy(iname,(char *)freply.fName); X`09`09`09sqvRef=freply.vRefNum; X`09`09`09SetVol("\p\0",sqvRef); X`09`09`09`7D X`09`09goto l2; X#endif X`09`09`7D X`09 X`09if ((finx=fopen(inname,"r"))==NULL) `7B X`09`09printf(" could not open inx file: %s\n",inname); X`09`09exit(0); X`09`7D X X X`09ilb = i = 0; X`09while ((fgets(lline,sizeof(lline),finx))!=NULL) `7B X`09`09if ((bp=strchr(lline,'\n'))!=NULL) *bp='\0'; X`09`09if (lline`5B0`5D=='<') `7B X`09`09`09strncpy(libenv,&lline`5B1`5D,sizeof(libenv)); X`09`09`7D X`09`09else `7B X`09`09`09lbnames`5Bi++`5D= &lbnarr`5Bilb`5D; X`09`09`09strncpy(&lbnarr`5Bilb`5D,lline,sizeof(lbnarr)-ilb); X`09`09`09ilb += strlen(lline)+1; X`09`09`09if (i>=MAXLF) break; X`09`09`7D X`09`7D X X`09fclose(finx); X`09`09 X X`09nln = i; X X`09libfn = -1; X X`09lboff = 0L; X`09filen = lseek(fidx,0L,2); X`09maxidx = (filen-lboff)/(long)sizeof(seq); X X`09if (argc<3) `7B X`09 `09/* get the sequence names and hash them */ X`09`09getnames(tname,40); X`09`09`7D X`09else for (i=2; i=0 && nname`5Bi`5D!='.'; i--); X`09`09 /* get to '.' or BOS */ X`09if (i>0) nname`5Bi+1`5D='\0'; X`09else `7Bnname`5Bi=strlen(nname)`5D='.'; nname`5Bi+1`5D='\0';`7D X`09strncat(nname,suff,maxn); X`09`7D X Xgetnames(tname,maxnam)`09/* read in the names and hash them */ X`09char *tname; int maxnam; X`7B X`09int i; X`09char tline`5B40`5D; X Xl1:`09if (strlen(tname)==0) `7B`09/* get names from keyboard */ X`09`09printf(" protein sequence identifier: "); X`09`09fgets(tname,maxnam,stdin); X`09`09if (tname`5Bi=strlen(tname)-1`5D=='\n') tname`5Bi`5D='\0'; X`09`09if (tname`5B0`5D=='\0') return; X`09`09`7D X X`09if (tname`5B0`5D=='@') `7B X`09`09if ((tptr=fopen(&tname`5B1`5D,"r"))==0) `7B X`09`09`09printf(" cannot open name file %s\n",&tname`5B1`5D); X`09`09`09tname`5B0`5D='\0'; X`09`09`09goto l1; X`09`09`09`7D X`09`09while (fgets(tline,40,tptr)!=0) `7B X`09`09`09if (tline`5Bi=strlen(tline)-1`5D=='\n') tline`5Bi`5D='\0'; X`09`09`09if (lookup(tline,&lmark,&lfn)==0) X`09`09`09`09printf(" sequence %s not found\n",tline); X`09`09`09else `7B X`09`09`09 putfile(tline,lmark,lfn); X`09`09`09 printf(" found %s, creating %s.aa\n",tline,tline); X`09`09`09 `7D X`09`09`09`7D X`09`09`7D X`09else `7B`20 X`09`09if (lookup(tname,&lmark,&lfn)==0) X`09`09`09printf(" sequence %s not found\n",tname); X`09`09else putfile(tname,lmark,lfn); X`09`09tname`5B0`5D='\0'; X`09`09goto l1; X`09`09`7D X`09`7D X Xucase(str)`09/* convert a string to upper case */ X`09char *str; X`7B X`09while (*str) `7B X`09`09if (*str >= 'a' && *str <= 'z') *str -= 'a' - 'A'; X`09`09str++; X`09`09`7D X`09`7D X Xlcase(str)`09/* convert a string to lower case */ X`09char *str; X`7B X`09while (*str) `7B X`09`09if (*str >= 'A' && *str <= 'Z') *str += 'a' - 'A'; X`09`09str++; X`09`09`7D X`09`7D X Xlookup(name,mark,seqfn)`09/* lookup names in library */ X`09char *name; long *mark; int *seqfn; X`7B X`09long hi, lo, mid, diff; X`09long pos; X X`09ucase(name); X X/* binary search for code */ X X`09lo = 0; X`09hi = maxidx; X`09while (hi >= lo) `7B X`09`09mid = (hi + lo)/2l; X`09`09pos = (long)mid * (long)sizeof(seq); X`09`09lseek(fidx, pos+lboff, 0); X`09`09read(fidx,(char *)&seq, sizeof(seq)); X`09`09if ((diff = strcmp(name, seq.nam)) == 0) `7B X`09`09`09*mark = seq.lmark; X`09`09`09*seqfn = seq.fn; X`09`09`09return 1; X`09`09`09`7D X`09`09else if (diff < 0) X`09`09`09hi = mid - 1l; X`09`09else X`09`09`09lo = mid + 1l; X`09`09`7D X`09return 0; X`09`7D X Xputfile(seqnam,seqmark,seqfn) X`09char *seqnam; long seqmark; int seqfn; X`7B X`09int i; X X`09strncpy(oname,seqnam,40); X`09lcase(oname); X`09strcat(oname,".aa"); X#ifdef THINK_C X`09SetVol("\p0\0",ouvRef); X#endif X`09if ((optr=fopen(oname,"w"))==0) X`09`09printf(" cannot open %s\n",oname); X`09else `7B X`09`09if (seqfn!=libfn) `7B X`09`09`09closelib(); X`09`09`09if (openlib(lbnames`5Bseqfn`5D,libenv)<0) return; X`09`09`09libfn=seqfn; X`09`09`09`7D X`09`09fseek(lptr,seqmark,0); X`09`09fgets(lline,512,lptr); X`09`09if (strlen(lline)>72) `7Blline`5B72`5D='\n'; lline`5B73`5D='\0';`7D X`09`09fputs(lline,optr); X`09`09lline`5B72`5D='\0'; X`09`09while(fgets(lline,71,lptr) && lline`5B0`5D!='>') `7B X`09`09`09if (lline`5B(i=strlen(lline)-1)`5D!='\n') `7B X`09`09`09`09lline`5Bi+1`5D='\n'; lline`5Bi+2`5D='\0'; X`09`09`09`09`7D X`09`09`09fputs(lline,optr); X`09`09`09`7D X`09`09`7D X`09fclose(optr); X`09`7D X Xopenlib(lname,libenv) X`09char *lname, *libenv; X`7B X`09char lbname`5B80`5D,rline`5B10`5D; X`09long ftell(); X`09int wcnt; X X`09wcnt=0; X X`09if (*libenv!='\0') `7B X`09`09strncpy(lbname,libenv,sizeof(lbname)); X#ifdef UNIX X`09`09strcat(lbname,"/"); X#endif X`09`09`7D X`09else *lbname='\0'; X`09strncat(lbname,lname,sizeof(lbname)-strlen(lbname)); X X#ifdef THINK_C X`09SetVol("\p",sqvRef); Xl1:`09if ((lptr=fopen(lbname,"r"))==NULL) `7B X`09`09sprintf(prompt," cannot open %s\r Select library filename",lbname); X`09`09FileDlog(prompt,&freply); X`09`09if (freply.good==TRUE) `7B X`09`09`09strcpy(libenv,"\0");`09 X`09`09`09PtoCstr((char *)freply.fName); X`09`09`09strcpy(lbname,(char *)freply.fName); X`09`09`09sqvRef=anvRef=freply.vRefNum; X`09`09`09SetVol("\p\0",sqvRef); X`09`09`09goto l1; X`09`09`09`7D X`09`09else return -1; X`09`09`7D X#else`09`09/* MSDOS */ X Xl1:`09if ((lptr=fopen(lbname,"r"))==0) `7B X`09`09rline`5B0`5D='\0'; X`09`09fprintf(stderr," cannot open %s library\n",lbname); X`09`09fprintf(stderr," insert another disk or type Y to skip "); X`09`09fflush(stderr); X`09`09if (fgets(rline,10,stdin)==NULL) return -1; X`09`09if (toupper(rline`5B0`5D)=='Y') return 0; X`09`09if (++wcnt > 10) return -1; X`09`09goto l1; X`09`09`7D X#endif X`09return 1; X`09`7D X Xcloselib() X`7B X`09if (lptr!=NULL) fclose(lptr); X`09`7D X Xtoupper(c) X char c; X`7B X if (c>='a' && c<='z') return c-'a'+'A'; X return c; X`7D $ CALL UNPACK EXTRACTP.C;1 1937723323 $ create 'f' X/*`09aatran.c`09translates from nt to aa, 1 char codes */ X/*`09modified July 2, 1987 for all 6 frames */ X/*`0923 Jan 1991`09fixed bug for short sequences */ X X/* `09this mapping is not alphabet independent */ X X#include "aamap.gbl" X#define XTERNAL X#include "upam.gbl" X#include "uascii.gbl" X X/* tnt is used only by aatran.c. It must be consistent with lascii and Xthe nt alphabet. It uses 3,3 because T and U are considered separately X*/ Xint tnt`5B`5D=`7B0,1,2,3,3,0,1,0,0,1,2,0,0,0,1,0,0`7D; X Xaatran(ntseq,aaseq,maxs,frame) X`09char *ntseq, *aaseq; X`09int maxs, frame; X`7B X`09int iaa, im, nna; X`09register int *nnp; X`09register char *nts0; X`09register int *aamp; X`09register char *aap; X X`09iaa=nna=(maxs-frame)/3; X`09if (nna <= 0 ) `7B X`09 aaseq`5B0`5D=EOSEQ; X`09 return 0; X`09`7D X X`09nnp = tnt; X`09if (frame < 3) `7B X`09`09aamp = aamap; X`09`09nts0 = &ntseq`5Bframe`5D; X`09`09aap = aaseq; X`09`09while (nna--) `7B X`09`09`09im = nnp`5B*nts0++`5D<<4; X`09`09`09im += nnp`5B*nts0++`5D<<2; X`09`09`09im += nnp`5B*nts0++`5D; X`09`09`09*aap++ = aamp`5Bim`5D; X`09`09`09`7D X`09`09`7D X`09else `7B X`09`09aamp = aamapr; X`09`09nts0 = &ntseq`5Bmaxs-(frame-3)`5D; X`09`09aap = aaseq; X`09`09while (nna--) `7B X`09`09`09im = nnp`5B*--nts0`5D<<4; X`09`09`09im += nnp`5B*--nts0`5D<<2; X`09`09`09im += nnp`5B*--nts0`5D; X`09`09`09*aap++ = aamp`5Bim`5D; X`09`09`09`7D X`09`09`7D X`09aaseq`5Biaa`5D=EOSEQ; X`09return iaa; X`09`7D X X Xaainit() X`7B X`09int i,j; X X`09for (i=0; i<64; i++) `7B X`09`09aamap`5Bi`5D=aascii`5Baacmap`5Bi`5D`5D; X`09`09aamapr`5Bi`5D=aascii`5Baacmap`5B(`7Ei)&63`5D`5D; X`09`09`7D X`09`7D $ CALL UNPACK FAATRAN.C;1 1551355223 $ create 'f' X.TH FASTA/TFASTA/LFASTAv1.5 1 local X.SH NAME Xfasta \- scan a protein or DNA sequence library for similar sequences X Xtfasta \- compare a protein sequence to a DNA sequence Xlibrary, translating the DNA sequence library `60on-the-fly'. X Xlfasta \- compare two protein or DNA sequences for local similarity and show V the local sequence alignments X Xplfasta \- compare two sequences for local similarity and plot the local seq Vuence alignments X X.SH SYNOPSIS X.B fasta X`5B-a -b # -c # -d # X\& -`5Bf`7Ck`5D -g # -l X.I FASTLIBS X\& -r X.I STATFILE X-m # -o -p # -Q -s X.I SMATRIX X-w # -1 `5D query-sequence-file library-file `5B X.I ktup X`5D X X.B fasta X`5B-Qacglmnoprswx`5D query-file @library-name-file X X.B fasta X`5B-Qacglmnoprswx`5D query-file "%PRMVI" X X.B fasta X`5B-acglmnoprswx`5D \- interactive mode X X.B tfasta X`5B-abcdfgmoprsw3`5D protein-query-file DNA-library `5B X.I ktup X`5D X X.B lfasta X`5B-amnpswx`5D sequence-file-1 sequence-file-2 `5B X.I ktup X`5D X X.B plfasta X`5B-amnpsxv`5D sequence-file-1 sequence-file-2 `5B X.I ktup X`5D X X.SH DESCRIPTION X.B fasta Xis used to compare a protein or DNA sequence to all of the entries in Xa sequence library. For example, X.B fasta Xcan compare a protein sequence to all of the sequences in the NBRF XPIR protein sequence database. X.B fasta Xwill automatically decide whether the query sequence is DNA or protein by Xreading the query sequence as protein and determining whether the X`60amino-acid composition' is more than 85% A+C+G+T. X.B fasta Xuses an improved version of the rapid sequence comparison algorithm Xdescribed by Lipman and Pearson (Science, (1985) 227:1427) that is Xdescribed in Pearson and Lipman, Proc. Natl. Acad. USA, (1988) 85:2444. XThe program can be invoked either with command line arguments or in Xinteractive mode. The optional third argument, X.I ktup Xsets the sensitivity and speed of the search. If X.I ktup=2, Xsimilar regions in the two sequences being compared are found by Xlooking at pairs of aligned residues; if X.I ktup=1, Xsingle aligned amino acids are examined. X.I ktup Xcan be set to 2 or 1 for protein sequences, or from 1 to 6 for DNA sequences V. XThe default if X.I Xktup Xis not specified is 2 for proteins and 6 for DNA. X.PP X.B fasta Xcompares a query sequence to a sequence library which consists Xof sequence data interspersed with comments, see below. Normally X.B fasta Xand X.B tfasta Xsearch the libraries listed in the file pointed to by the environment Xvariable X.B FASTLIBS\c X\&. XThe format of this file is described in the file FASTA.DOC. X.B tfasta Xcompares a protein sequence to a DNA sequence database, translating Xthe DNA sequence library in 6 frames `60on-the-fly' (3 frames with the X\-3 option). The search uses the standard PAM250 scoring matrix, and Xuses a X.I ktup=2 Xby default. X.B tfasta Xsearches a DNA sequence database in the standard text format Xdescribed below. X X.B lfasta Xand X.B plfasta Xprograms compare two sequences looking for local sequence Xsimilarities. While X.B fasta Xand X.B tfasta Xreport only the best alignment between the query sequence and the Xlibrary sequence, X.B lfasta Xand X.B plfasta Xwill report all of the alignments between the two sequences with Xscores greater than a cut-off value. X.B lfasta Xshows the actual local alignments between the two sequences and their Xscores, while X.B plfasta Xproduces a plot of the alignments that looks similar to a X`60dot-matrix' homology plot. On Unix\(tm systems, X.B plfasta Xgenerates tektronix output that can either be displayed on a Xtektronix terminal or piped through the X.B tek2ps Xprogram for output on the laser printer. XOn MS-DOS systems, X.B plfasta Xuses the graphics capabilities of the computer screen together with Xthe *.BGI graphics device drivers supplied by Borland with Turbo X`60C'\(tm. X.PP XThe X.B fasta Xprograms use a standard text format sequence file. Lines beginning Xwith '>' or ';' are considered comments and ignored; sequences can be upper V or Xlower case, blanks,tabs and unrecognizable characters are ignored. X.B fasta Xexpects sequences to use the single letter amino acid codes, see X.B protcodes(1) X\&. XLibrary files for fasta should have the form shown below. X.SH OPTIONS X.PP X.B fasta Xand the other programs can be directed to change the scoring matrix, Xsearch parameters, output format, and default search directories by Xentering options on the command line (preceeded by a `60\-' or `60/' for XMS-DOS). All of the options should preceed the file name and ktup Xarguments). Alternately, these options can be changed by setting Xenvironment variables. The options and environment variables are: X X.TP X\-1 XNormally, the top scoring sequences are ranked by their X.I initn Xscore. By using the X.B -1 Xoption, sequences are ranked by their X.B init1 Xscore. X\-a X.B (SHOWALL) XModifies the display of the two sequences in Xalignments. Normally, both sequences are shown only where they Xoverlap (SHOWALL=0); If \-a or the environment variable SHOWALL = 1, Xboth sequences are shown in their entirety. X.TB X\-b # XThe number of similarity scores to be shown when the X.B -Q Xoption is used. This value is usually calculated based on the Xactual scores. X.TP X\-c # X.B (OPTCUT) XThe threshold for optimization with the`20 X.B -o Xoption. The OPTCUT value Xis normally calculated based on sequence length. X.TP X\-d # XThe number of alignments to be shown. Normally, X.B fasta Xshows the same number of alignments as similarity scores. By using X.B fasta -Q -b`20 X200 X.B -d X50, one would see the top scoring 200 sequences and alignments for the X50 best scores. X.TP X\-f\ `7C\ \-k X.B (PAMFACT) XThis version of fasta uses a more sensitive method for identifying Xinitial regions. Instead of using a constant factor (fact) for each Xmatch in a ktup, it uses the scoring matrix (PAM) scores. While this Xworks well for protein sequences, it has not been as carefully tested Xfor DNA sequences, so by default, this modification is used for Xproteins but not for DNA. The X.B -f Xoption forces this option on. X.B -k Xforces it off. Setting the X.B XPAMFACT Xenvironment variable to 1 forces the option on; PAMFACT=0 turns it off. X.TP X\-g # X.B (GAPCUT) XSets the threshold for joining the initial regions for calculating the X.B initn Xscore. X.TP X\-l # X.B (FASTLIBS) XThe name of the library menu file. Normally this will be determined Xby the environment variable X.B FASTLIBS\c X\&. However, a library menu file can also be specified with X.B \-l\c X\&. X.TP X\-m # X.B (MARKX) X=1,2,3. Alternate display of matches and mismatches in Xalignments. MARKX=1 uses ":","."," ", for identities, consevative Xreplacements, and non-conservative replacements, respectively. MARKX=2 Xuses " ","x", and "X". MARKX=3 does not show the second sequence, but Xuses the second alignment line to display matches with a "." for Xidentity, or with the mismatched residue for mismatches. MARKX=3 is Xuseful for aligning large numbers of similar sequences. X.TP X\-n XForces the query sequence to be treated as a DNA sequence. X.TP X\-o`20 XCauses X.B fasta Xto perform a limited optimization on all of the sequences in the library Xwith X.B initn Xscores greater than X.B OPTCUT\c X\&. This slows the program down about 5-fold, but, when combined with X.B ktup=1\c X\&, provides an extremely sensitive sequence comparison. X.TP X\-Q XQuiet option. This allows fasta and tfasta to search a database and Xreport the results without asking any questions. fasta -Q file library > out Vput Xcan be put in the background or run at a later time with the unix 'at' comma Vnd. XThe number of similarity scores and alignments displayed with the X.B -Q Xoption can be modified with the X.B -b X(scores) and X.B -d X(alignments) options. X.TP X\-r X.I STATFILE XCauses X.B fasta Xto write out the sequence identifier, superfamily number (if available), Xand similarity scores to X.I STATFILE Xfor every sequence in the library. These results are not sorted. X.TP X\-s str X.B (SMATRIX) Xthe filename of an alternative scoring matrix file. X.TP X\-v str X.B (LINEVAL) X(plfasta only) X.B plfasta Xand X.B pclfasta Xcan use up to 4 different line styles to denote the Xscores of local alignments. The scores that correspond to these Xline styles can be specified with the environment variable X.B LINVAL\c X\&, or with the X.B \-v Xoption. In either case, a string with three numbers separated by Xspaces should be given. This string must be surrounded by double Xquotation marks. For example, LINEVAL="200 100 50" tells plfasta Xto use solid lines for local alignments with scores greater than 200, Xlong dashed lines for scores between 100 and 200, short dashed lines Xfor scores between 50 and 100, and dotted lines for scores less than 50. X.in +0.5i Xplfasta -v "200 100 50" X.in -0.5i XNormally, the values are 200, 100, and 50 for protein sequence comparisons Xand 400, 200, and 100 for DNA sequence comparisons. X.TP X\-w # X.B (LINLEN) Xoutput line length for sequence alignments. (normally 60, Xcan be set up to 200). X.TP X\-x "offset1 offset2" XCauses fasta/lfasta/plfasta to start numbering the aligned sequences Xstarting with offset1 and offset2, rather than 1 and 1. This is Xparticularly useful for showing alignments of promoter regions. X.TP X\-3 X.B tfasta Xonly. Normally X.B tfasta Xtranslate sequences in the DNA sequence library in all six frames. XWith the \-3 option, only the three forward frames are searched. X.SH EXAMPLES X.TP X(1) X.B fasta Xmusplfm.aa $AABANK X.PP XCompare the amino acid sequence in the file musplfm.aa with the complete XPIR protein sequence library using X.I ktup X\&= 2 XEach "library" sequence (there need only be one) should start with Xa comment line which starts with a '>', e.g. X.nf X.in +5n X X>LCBO bovine preprolactin XWILLLSQ ... X>LCHU human ... X\&... X.in +0n X X.fi X.TP X(2) X.B fasta X-a -w 80 musplfm.aa lcbo.aa 1 X.PP XCompare the amino acid sequence in the file musplfm.aa with the sequences Xin the file lcbo.aa using X.I ktup X\= 1. Show both sequences in their entirety, with 80 residues on Xeach output line. X.TP X(3) X.B fasta X.PP XRun the X.B fasta Xprogram in interactive mode. The program will prompt for Xthe file name for the query sequence, list alternative libraries Xto be seached (if FASTLIBS is set), and prompt for the`20 X.I ktup. X.SH FILES X.PP XThis version of X.B Xfasta Xprompts for the library file to be searched from a list of file names Xthat are saved in the file pointed to by the environment variable FASTLIBS. XIf FASTLIBS = fastgb.list, then the file fastgb.list might have the entries: X.in +0.5i X.nf X XNBRF Protein$0P/u/lib/aabank.lib 0 XGB Primate$1P@/u/lib/gpri.nam XGB Rodent$1R@/u/lib/grod.nam XGB Mammal$1M@/u/lib/gmammal.nam X X.fi X.in -0.5i XEach line in this file has 4 fields: (1) The library name, separated from Xthe remaining fields by a '$'; (2) A 0 or a 1 indicating protein or DNA Xlibrary respectively; (3) A single letter that will be used to choose the Xlibrary; (4) the location of the library Xfile itself (the library file name can contain an optional library format Xspecfier. X.B Fasta Xrecognizes the following library formats: 0 - Pearson/FASTA; 1 - Genbank tap Ve; X2 - NBRF/PIR Codata; 3 - EMBL/SWISS-PROT; 4 - Intelligenetics; 5 - NBRF/PIR XVMS; 9 - Genbank floppy disk);`20 XNote that this Xfourth field can contain an`20 X.B '@' Xcharacter, which indicates that the library Xfile is an indirect library file containing list of library files, one Xper line. An indirect library file can also contain a line beginning Xwith the symbol '<', followed by the directory where the library files Xmay be found, and a line beginning with a '>', indicating the name of Xthe index file (GENBANK compressed floppy format files only). An indirect Xlibrary file might have the lines: X.in +0.5i X.nf Xglocus.idx`09`09(index file for GENBANK binary files) Xgpri1.seq 9 Xgpri2.seq 9 Xgpri3.seq 9 X\&... Xgrod1.seq 9 X\&... X.fi X.in -0.5i X.PP XThis version of X.B fasta Xcan also distinguish between normal text library files (as shown Xabove in EXAMPLE (2)), and DNA libraries in the GENBANK compressed Xfloppy disk format. These latter files are binary files that are Xdistributed by Intelligenetics on floppy disks. Earlier versions of Xfasta (and fastn before it) used different programs to read the text Xlibrary files (old fasta or ifastn) and the compressed files (old Xfastgb and gfastn). These routines have been combined in the current X.B Xfasta. X.PP XYou can use your own sequence files for X.B fasta\c X\&, just be certain to put a '>' and comment as the first line Xbefore the sequence. Only one library file type, the standard NBRF Xlibrary format, is supported by the VAX/VMS programs. X.B Xlfasta Xand X.B Xplfasta Xdo not required the '>' and comment line. X.B Xfasta Xdoes. X.SH "SEE ALSO" Xrdf2(1),protcodes(5), dnacodes(5) X.SH AUTHOR XBill Pearson X.br Xwrp@virginia.EDU $ CALL UNPACK FASTA.1;1 521482574 $ create 'f' Xl_band.obj g_band.obj pam.obj time.obj getopt.obj $ CALL UNPACK FASTA.RSP;1 352806546 $ create 'f' X X X X XFASTA.DOC Release 1.6 X X X X COPYRIGHT NOTICE X XCopyright 1988, 1991, 1992 by William R. Pearson and the XUniversity of Virginia. All rights reserved. The FASTA program Xand documentation may not be sold or incorporated into a Xcommercial product, in whole or in part, without written consent Xof William R. Pearson and the University of Virginia. For Xfurther information regarding permission for use or reproduction, Xplease contact: William R. Wilkerson, Assistant Provost for XResearch, University of Virginia, P.O. Box 9025, Charlottesville, XVA 22906-9025, (804) 924-6853 X X XThe FASTA program package X XIntroduction X X This documentation describes the version 1.6c of the FASTA Xprogram package (see W. R. Pearson and D. J. Lipman (1988), X"Improved Tools for Biological Sequence Analysis", PNAS 85:2444- X2448, and W. R. Pearson (1990) "Rapid and Sensitive Sequence XComparison with FASTP and FASTA" Methods in Enzymology 183:63- X98). Version 1.6 is the first release for the IBM-PC and XMacintosh since version 1.4 (version 1.5 was distributed only via Xftp to unix machines). Version 1.6 has a large number of Ximprovements over versions 1.4 and 1.5, including the ability to Xsearch libraries in several different formats in the same run, Xmore robust algorithms for aligning sequences along a band, and Xadditional, rigorous (but slow) programs for sequence searching, Xstatistical analysis, and local sequence alignment. In addition, Xseveral additional options are included. Programs that are new Xwith version 1.6 are highlighted in italics. X X XAlthough there are a large number of programs in this package, Xthey belong to three groups: X X X Library search programs: FASTA, TFASTA, SSEARCH X X Local homology programs: LFASTA, PLFASTA, LALIGN, PLALIGN X X Statistical significance: RDF2, RELATE, RSS X X XIn addition, there are several programs for other sequence Xanalysis tasks: X X X ALIGN - global alignment of two sequences (no limit on gaps). X X EXTRACTP, SINDEX - programs to index (SINDEX) and extract sequences X X X - 1 - X X X X X X X XFASTA.DOC Release 1.6 X X X from a protein sequence database. X X EXTRACTN - programs to extract sequences from the GenBank floppy disk X format data base. X X XIn addition, I have included several programs for protein Xsequence analysis, including a Kyte-Doolittle hydropathicity Xplotting program (GREASE, TGREASE), and a secondary structure Xprediction package (GARNIER). X X The FASTA sequence comparison programs on this disk are Ximproved versions of the FASTP program, originally described in XScience (Lipman and Pearson, (1985) Science 227:1435-1441). We Xhave made several improvements. First, the library search Xprograms use a more sensitive method for the initial comparison Xof two sequences which allows the scores of several similar Xregions to be combined. As a result, the results of a library Xsearch are now given with three scores, initn (the new initial Xscore which may include several similar regions), init1 (the old Xfastp initial score from the best initial region), and opt (the Xold fastp optimized score allowing gaps in a 32 residue wide Xband). X X These programs have also been modified to become "universal" X(hence FAST-A, for FASTA-All, as opposed to FAST-P (protein) or XFAST-N (nucleotides)); by changing the environment variable XSMATRIX, the programs can be used to search protein sequences, XDNA sequences, or whatever you like. By default, FASTA, LFASTA, Xand the RDF programs automatically recognize protein and DNA Xsequences. Sequences are first read as amino acids, and then Xconverted to nucleotides if the sequence is greater than 85% XA,C,G,T (the '-n' option can be used to indicate DNA sequences). XTFASTA compares protein sequences to a translated DNA sequence. XAlternative scoring matrices can also be used. In addition to Xthe PAM250 matrix for proteins, matrices based on simple Xidentities or the genetic code can also be used for sequence Xcomparisons or evaluation of significance. Several different Xprotein sequence matrices have been included; instructions for Xconstructing your own scoring matrix are included in the file XFORMAT.DOC. X X XThe remainder of this document is divided into three sections: X(1) a brief history of the changes to the FASTA package; (2) A Xguide to installing the programs and databases; (3) A guide to Xusing the FASTA programs. The programs are very easy to use, so Xif you are using them on a machine that is administered by Xsomeone else, you may want to skip to section (3) to learn how to Xuse the programs, and then read section (1) to look at some of Xthe more recent changes. If you are installing the programs on Xyour own machine, you will need to read section (2) carefully. X X X - 2 - X X X X X X X XFASTA.DOC Release 1.6 X X X1. Revision History X X1.1. Changes with version 1.6 X X FASTA version 1.6 uses a new method for calculating optimal Xscores in a band (the optimization or last step in the FASTA Xalgorithm). In addition, it uses a linear-space method for Xcalculating the actual alignments. The FASTA package also Xincludes four new programs: X XSSEARCH a program to search a sequence database using the X rigorous Smith-Waterman algorithm (this program is X about 100-fold slower than FASTA with ktup=2 (for X proteins). X XRSS a version of RDF2 that uses a rigorous Smith-Waterman X calculation to score similarities X XLALIGN A rigorous local sequence alignment program that will X display the N-best local alignments (N=10 by default). X XPLALIGN a version of lalign that plots the local alignments. X X The LALIGN/PLALIGN programs incorporate the "sim" algorithm Xdescribed by Huang and Miller (1991) Adv. Appl. Math. 12:337-357. XThe SSEARCH and RSS programs incorporate algorithms described by XHuang, Hardison, and Miller (1990) CABIOS 6:373-381. X X LFASTA and PLFASTA now calculate a different number of local Xsimilarities; they now behave more like LALIGN/PLALIGN. Since Xlocal alignments of identical sequences produce "mirror-image" Xalignments, lalign and lfasta consider only one-half of the Xpotential alignments between sequences from identical file names. XThus X X lfasta mchu.aa mchu.aa X XDisplays only two alignments, with earlier versions of the Xprogram, it would have displayed five, including the identity Xalignment. PLFASTA does display five alignments; when two Xidentical filenames are given, it draws the identity alignment, Xcalculates the two unique local alignments, draws them, and draws Xtheir mirror images. LFASTA/PLFASTA and LALIGN/PLALIGN use the Xfilenames, rather than the actual sequences, to determine whether Xsequences are identical; you can "trick" the programs into Xbehaving the old way by putting the same sequence in two Xdifferent files. X X1.2. Changes with version 1.5 X X FASTA version 1.5 includes a number of substantial revisions Xto improve the performance and sensitivity of the program. It is Xnow possible to tell the program to optimize all of the initn X X X - 3 - X X X X X X X XFASTA.DOC Release 1.6 X X Xscores greater than a threshold. The threshold is set at the Xsame value as the old FASTA cutoff score (approximately 0.5 Xstandard deviations above the mean for average length sequences). XFor highest sensitivity, you can use the -c 1 option to set the Xthreshold to 1. (This will slow the search down about 5-fold). XAlternatively, you can tell FASTA to sort the results by the Xinit1, rather than the initn, score by using the -1 option. XFASTA -1 ... will report the results the way the older FASTP Xprogram did. A comparison of the performance of FASTA in this, Xits slowest mode, with the standard FASTA and the Smith-Waterman Xalgorithm has been published in Genomics (1991) 11:635-650. X X A new method has been provided for selecting libraries. In Xthe past, one could enter the name of a sequence file to be Xsearched or a single letter that would specify a library from the Xlist included in the $FASTLIBS file. Now, you can specify a set Xof library files with a string of letters preceded by a '%'. XThus, if the FASTLIBS file has the lines: X X X Genbank 70 primates$1P/seqlib/gbpri.seq X Genbank 70 rodents$1R/seqlib/gbrod.seq X Genbank 70 other mammals$1M/seqlib/gbmam.seq X Genbank 70 vertebrates $1B/seqlib/gbvrt.seq X X XThen the string: "%PRMB" would tell FASTA to search the four Xlibraries listed above. The %PRMB string can be entered either Xon the command line or when the program asks for a filename or Xlibrary letter. X X FASTA1.5 also provides additional flexibility for specifying Xthe number of results and alignments to be displayed with the -Q X(quiet) option. The -b number option allows you to specify the Xnumber of sequence scores to show when the search is finished. XThus X X X FASTA -b 100 ... X X Xtells the program to display the top 100 sequence scores. In the Xpast, if you displayed 100 scores (in -Q mode), you would also Xhave store 100 alignments. The -d option allows you to limit the Xnumber of alignments shown. FASTA -b 100 -d 20 would show 100 Xscores and 20 alignments. X X The old CUTOFF parameter is no longer used. The program Xstores the best 2000 (IBM-PC, MAC) or 6000 (Unix, VMS) scores and Xthen throws out the lowest 25%, stores the next 500 (1500) better Xthan the threshold determined with the first scores were Xdiscarded, and repeats the process as the library is scanned. As Xa result, the best 1500 - 2000 (4500 - 6000) scores are saved. X X X - 4 - X X X X X X X XFASTA.DOC Release 1.6 X X XThe old cut-off parameter was also used to set the joining Xthreshold for the calculation of the initn score from initial Xregions. This joining threshold can now be set with the -g Xoption or with the GAPCUT parameter. X X Finally, FASTA can provide a complete list of all of the Xsequences and scores calculated to a file with the -r (results) Xoption. FASTA -r results.out ... creates a file with a list of Xscores for every sequence in the library. The list is not Xsorted, and only includes those scores calculated during the Xinitial scan of the library (the optimized score is not Xcalculated unless the -o option is used). X X2. Installing the FASTA package X X2.1. Installing the programs X X2.1.1. IBM-PC/DOS version X X For the IBM-PC/DOS version, the FASTA source code disk Xcontains the complete source code to all of the programs on the Xother disks. The programs were compiled with Borland's Turbo X'C++', using Borland's MAKE utility. The graphics programs X(PLFASTA, TGREASE) use the graphics device drivers supplied with Xthe Turbo 'C' V2.0 package. Also included are the documentation Xfiles PROGRAMS.DOC and FORMAT.DOC. You do not need any of the Xfiles the source code disk to run the programs. The files on Xthis disk are identical to the UNIX and VMS versions that run on Xlarger machines. Also included is the code to compile XALIGN0.EXE. ALIGN0 is the same as ALIGN, but does not penalize Xfor end-gaps. X X If you have the DOS or Macintosh version of the FASTA Xpackage, to install the programs you should: X X(1) Make a new directory (folder) for the FASTA programs. This X need not be the same as the directory for your sequence X databases. X X(2) Copy the files from the FASTA source disk to the new X directory. X X(3) (DOS only) Edit your AUTOEXEC.BAT file to (a) modify your X PATH command to include the FASTA directory and (b) add the X line: X X set FASTLIBS=c:\yourfastadirectory\fastgbs X X On the Macintosh, you may need to edit the "environment" X file and change the line that reads: X X FASTLIBS=fastgbs X X X - 5 - X X X X X X X XFASTA.DOC Release 1.6 X X X to indicate the full directory path for the fastgbs file, X for example: X X FASTLIBS=Q105:FASTA:fastgbs X X X(4) Finally, you will need to edit the fastgbs file. This is X usually the most confusing part of the installation. An X example of this file is shown below; to customize this file X for your machine, you will need to change the file names X from those provided in the fastgbs file to ones that reflect X the directory names and file names you use on your machine. X This is explained in more detail below. In addition, some X entries in the fastgbs file refer to other files of file X names. These files of file names (as opposed to actual X database files) may also need to be edited. X X2.1.2. Unix version X X The FASTA distribution comes with several makefile's that Xcan be used to compile the FASTA programs. Over the years, as XATT Unix System 5 and BSD unix have converged, these files have Xbecome very similar. To begin with, I recommend using the Xstandard Makefile. There are two values in the makefile that Xshould be checked against the values used on your system: the HZ Xvalue, which is the frequency in ticks per second used by the Xtimes() system call, this value can usually be found by running: X X grep HZ /usr/include/sys/* X Xand the functions available to return random numbers. If you Xhave a rand48() function that returns a 32-bit random number, use Xit and use the lines: X X NRAND=nrand48 X RANFLG= -DRAND32 X XIf not, you will need to use the rand() function call and Xdetermine whether it returns a 16-bit or a 32-bit value. These Xfunctions are used by RDF2 and RSS. If you have problems Xcompiling the programs, you may want to examine the makefile.unx Xand makefile.sun files, to look for differences. I have tried to Xuse very standard unix functions in these programs, and they have Xbeen successfully compiled, with very small changes to the XMakefile, on Sun's (Sun OS 4.1), IBM RS/6000's (AIX), and MIPS Xmachines (under the BSD environment). X X2.2. Installing the libraries X X2.2.1. The NBRF protein sequence library X X The FASTA program package does not include any protein or XDNA sequence libraries. You can obtain the PIR protein sequence X X X - 6 - X X X X X X X XFASTA.DOC Release 1.6 X X Xdatabase from: X X National Biomedical Research Foundation X Georgetown University Medical Center X 3900 Reservoir Rd, N.W. X Washington, D.C. 20007 X XIn addition, this database is available via anonymous ftp from Xthe host "ftp.bchs.uh.edu". It is available in two formats, VMS Xand CODATA format. The "VMS" format (library type 5 below) can Xbe searched much faster, can be easily reformatted for use by the X"BLAST" rapid searching program, and is compatible with the XGenetics Computer Group package of programs. The CODATA format Xis used by the EUGENE/MBIR computing package from Baylor (library Xtype 2). X X (DOS/Macintosh users) The SINDEX and EXTRACTP programs now Xallow you to index a file in one subdirectory, and then move the Xlibrary without having to remake the index. When you type: XSINDEX @prot.nam, two index files are created: PROT.IXX and XPROT.INX. PROT.IXX is a binary file that cannot be edited; it Xcontains the offsets into the library files for each of the Xsequence entries. PROT.INX looks exactly like the original XPROT.NAM file, and can be edited. However, you cannot change the Xorder of the library files in PROT.INX. What you can do is Xchange the first line, which indicates the directory where the Xlibrary files can be found. The index in PROT.IXX might tell XEXTRACTP to find the entry LCBO at offset 123,456 in the PROT.3 Xfile. If you changed the PROT.3 line in PROT.INX to PROT.4, LCBO Xwould not be extracted properly. However, if you decide to move Xyour library files from disk /usr/tmp to disk /usr/lib, you can Xedit PROT.INX to reflect this change. X X EXTRACTP has also been updated to use the new indexing Xscheme. To extract sequences from a multi-file library that you Xmade with SINDEX @prot.nam, type: EXTRACTP @prot.nam, or set the Xenvironment variable AABANK=@prot.nam. Then enter the protein Xsequence identifiers as before. Remember, if you move the Xlibrary into a different directory, you will need to copy both Xthe *.IXX and *.INX files to use EXTRACTP. You can test EXTRACTP Xby trying to extract the PIR sequences LCBO, HBHU, or CCHU. If Xyou do not get an error message, the sequences were successfully Xextracted. They are automatically saved to a file with the name X"sequence.aa". So "LCBO" would be found in "lcbo.aa". When you Xneed to extract a sequence from the NEW.LIB library, you will Xhave to set AABANK=new.lib. X X2.2.2. The GENBANK DNA sequence library X X FASTA, TFASTA, and EXTRACTN search and extract sequences Xfrom the GENBANK DNA sequence library in its compressed, floppy Xdisk format. This library is available from: X X X - 7 - X X X X X X X XFASTA.DOC Release 1.6 X X X GENBANK X c/o Intelligenetics X 700 E. El Camino Real X Mountain View, CA 94040 X (415) 962-7300 X X(The GBANN program used to extract DNA sequence annotations. XUnfortunately, GBANN has not been updated since release 63.0 of XGENBANK, when some changes in the annotation files were made. XGBANN no longer works.) X X The GenBank DNA sequence library is also available via Xanonymous FTP from genbank.bio.net. X X2.2.3. The EMBL CD-ROM libraries X X The European Molecular Biology Laboratory (EMBL) is Xdistributing a CD-ROM that contains both the complete EMBL DNA Xsequence database (which should be essentially identical to the XGenBank DNA sequence database) and the SWISS-PROT protein Xsequence database. SWISS-PROT is derived from the NBRF Protein Xsequence database with additions from the EMBL DNA sequence Xdatabase. This CD-ROM is a "best-buy," since it provides both XDNA and protein sequence libraries. It is available from: X X X EMBL Data Library X Meyerhofstr. 1 X D-6900 Heidelberg X Germany X +49 6221 387258 X Email: SOFTWARE@EMBL-Heidelberg.DE X X X X In addition, the SWISS-PROT protein sequence database is Xavailable via anonymous FTP from the hosts genbank.bio.net and Xncbi.nlm.nih.gov. X X2.3. Finding the libraries: FASTLIBS X X FASTA and TFASTA use the environment variable FASTLIBS to Xfind the protein and DNA sequence libraries. The FASTLIBS Xvariable contains the name of a file that has the actual Xfilenames of the libraries. The FASTGBS file on is an example of Xa file that can be referred to by FASTLIBS. To use the FASTGBS Xfile, type: X X setenv FASTLIBS /usr/lib/fasta/fastgbs (BSD UNIX) X or X FASTLIBS=/usr/lib/fasta/fastgbs; export FASTLIBS (SysV UNIX) X XThen edit the FASTGBS file to indicate where the protein and DNA X X X - 8 - X X X X X X X XFASTA.DOC Release 1.6 X X Xsequence libraries can be found. If you have a hard disk and Xyour protein sequence library is kept in the file X/usr/lib/aabank.lib and your Genbank DNA sequence library is kept Xin the directory: /usr/lib/genbank, then fastgbs might contain: X X NBRF Protein$0P/usr/lib/seq/aabank.lib 0 X SWISS PROT 10$0S/usr/lib/vmspir/swiss.seq 5 X GB Primate$1P@/usr/lib/genbank/gpri.nam X GB Rodent$1R@/usr/lib/genbank/grod.nam X GB Mammal$1M@/usr/lib/genbank/gmammal.nam X `5E 1 `5E`5E`5E`5E 4 `5E `5E X 23 (5) X XThe first line of this file says that there is a copy of the NBRF Xprotein sequence database (which is a protein database) that can Xbe selected by typing "P" on the command line or when the Xdatabase menu is presented in the file /usr/lib/seq/aabank.lib. X X Note that there are 4 or 5 fields in the lines in fastgbs. XThe first field is the description of the library which will be Xdisplayed by FASTA; it ends with a '$'. The second field (1 Xcharacter), is a 0 if the library is a protein library and 1 if Xit is a DNA library. The third field (1 character) is the Xcharacter to be typed to select the library. X X The fourth field is the name of the library file. In the Xexample above, the /usr/lib/seq/aabank.lib file contains the Xentire protein sequence library. However the DNA library file Xnames are preceded by a '@', because these files (gpri.nam, Xgrod.nam, gmammal.nam) do not contain the sequences; instead they Xthe names of the files which contain the sequences. This is done Xbecause the GENBANK DNA database is broken down in to a large Xnumber of smaller files. In order to search the entire primate Xdatabase, you must search more than a dozen files. X X In addition, an optional fifth field can be used to specify Xthe format of the library file. Alternatively, you can specify +-+-+-+-+-+-+-+- END OF PART 1 +-+-+-+-+-+-+-+- -+-+-+-+-+-+-+-+ START OF PART 2 -+-+-+-+-+-+-+-+ Xthe library format in a file of file names (a file preceded by an X'@'). This field must be separated from the file name by a space Xcharacter (' ') from the filename. In the example above, the Xaabank.lib file is in Pearson/FASTA format, while the swiss.seq Xfile is in PIR/VMS format (from the EMBL CD-ROM), while the DNA Xsequences are in compressed GenBank format. No file type number Xis included for the Genbank files, because it is included in the Xfile of filenames (see below). Currently, FASTA can read the Xfollowing formats: X X 0 Pearson/FASTA (>SEQID - comment/sequence) X 1 Uncompressed Genbank (LOCUS/DEFINITION/ORIGIN) X 2 NBRF CODATA (ENTRY/SEQUENCE) X 3 EMBL/SWISS-PROT (ID/DE/SQ) X 4 Intelligenetics (;comment/SEQID/sequence) X 5 NBRF/PIR VMS (>P1;SEQID/comment/sequence) X X X - 9 - X X X X X X X XFASTA.DOC Release 1.6 X X X 9 Compressed Genbank Floppy format X X(In the near future, I hope to support the BLAST formats.) In Xparticular, this version will work with the EMBL and PIR VMS Xformats that are distributed on the EMBL CD-ROM. The latter Xformat (PIR VMS) is much faster to search than EMBL format. If a Xlibrary format is not specified, for example, because you are Xjust comparing two sequences, Pearson/FASTA (format 0) is used by Xdefault. To change this default, you may set the LIBTYPE Xenvironment variable to a number. For example, X X setenv LIBTYPE 1 X Xwould cause the program to use the GenBank LOCUS format by Xdefault for libraries (or the second sequence file), but the XPearson/FASTA format would still be used for the query sequence. X X You can specify a group of library files by putting a '@' Xsymbol before a file that contains a list of file names to be Xsearched. For example, if @gpri.nam is in the fastgbs file, the Xfile "gpri.nam" might contain the lines: X X glocus.idx X gpri1.seq X gpri2.seq X gpri12.seq X XIn this case, the line beginning with a '<' indicates the Xdirectory the files will be found in. The line beginning with a X'>' indicates the index file; this is only used for the GENBANK Xcompressed DNA database. The remaining lines name the actual Xsequence files. So the first sequence file to be searched would Xbe: X X /usr/lib/genbank/gpri1.seq X XThe notation "glocus.idx X gpri1.seq 9 X gpri2.seq 9 X ... X gpri9.seq 9 X # (this '#' causes the program to display the size of the library) X grod1.seq 9 X ... X gmam1.seq 9 X ... X guna1.seq 9 X ... X unanno.seq 5 X # X X X You do not need to include library format numbers if you X only use the Pearson/FASTA version of the PIR protein se- X quence library and the Genbank DNA database on floppy X disks. If no library type is specified, the program as- X sumes that type 0 is being used (unless you have set LIB- X TYPE). However, if the program sees an index file line X (e.g. ">glocus.idx"), it assumes that the files are in X Genbank floppy disk format (type 9). X X X Although FASTA works best when the libraries are saved on a Xhard disk, this is not required. If you do not have a hard disk, Xyou could refer to the protein database files by making a file X"prot.nam" with the lines: X X ' in the first Xcolumn. (3) distributed sequence libraries (this is a broad class Xthat includes the NBRF/PIR VMS and blocked ascii formats, Genbank Xflat-file format, EMBL flat-file format, and Intelligenetics Xformat. All of the files that you create should be of type (1) Xor (2). Type (2) files (ones with a be used as query or library Xsequence files by all of the programs. X X I have included several sample test files, *.AA. The first Xline may begin with a '>' or ';' followed by a comment. The Xtext after ';' in other lines will be ignored. Spaces and Xtabs (and anything else that is not an amino-acid code) are Xignored. X X Library files should have the form: X X >Sequence name and identifier X A F A S Y T .... actual sequence. X F S S .... second line of sequence. X >Next sequence name and identifier X XThis is the form of the PROT.* supplied with the floppy disk Xversion of the PIR protein sequence library. You can also build Xyour own library by concatenating several sequence files. Just Xbe sure that each sequence is preceded by a line beginning with a X'>' with a sequence name. X X The test file should not have lines longer than 120 Xcharacters, and sequences entered with word processors should use Xa document mode, with normal carriage returns at the end of Xlines. X XProgram Summary X X3.3. Sequence search programs X XFASTA universal sequence comparison. Defaults to comparing X protein sequences; if the sequences are > 85% A+C+G+T X or the -n option is used, a DNA sequence is assumed. X XTFASTA Search DNA library for a protein sequence by X translating the DNA sequence to protein in all six X frames (three forward frames with the -3 command line X option). TFASTA with ktup=2 is about as fast as a DNA X FASTA with ktup=4, and is substantially more sensitive. X (also reads the GENBANK library) X XSSEARCH Universal sequence comparison using the Smith-Waterman X algorithm ( T. F. Smith and M. S. Waterman (1981) J. X Mol. Biol. 147:195-197). This program uses code X developed by Huang and Miller (X. Huang, R. C. X X X - 14 - X X X X X X X XFASTA.DOC Release 1.6 X X X Hardison, W. Miller (1990) CABIOS 6:373-381) for X calculating the local similarity score and code from X the ALIGN program (see below) for calculating the local X alignment. SSEARCH is about 100-times slower than X FASTA with ktup=2 (for proteins). It should never be X used to search an entire protein sequence library, but X can be used to search several hundred sequences. X XALIGN optimal global alignment of two sequences with no X short-cuts. This program is a slightly modified X version of one taken from E. Myers and W. Miller. The X algorithm is described in E. Myers and W. Miller, X "Optimal Alignments in Linear Space" (CABIOS (1988) X 4:11-17). X X3.4. Local similarity programs X XLFASTA local similarity searches showing local alignments. X The algorithm used to calculate the local alignment in X a band has been improved (Chao, Pearson, and Miller, X submitted). X XPLFASTA local similarity searches with plot output (on the IBM, X this program requires that the environment variable X BGIDIR be set). X XPCLFASTA (unix only) local similarity searches with plot output X using pic commands. X XLALIGN Calculates the N-best local alignments using a rigorous X algorithm. (N=10 by default.) The algorithm was X developed by Huang and Miller (X. Huang and W. Miller X (1991) Adv. Appl. Math. 12:337-357), which is a X linear-space version of an algorithm described by M. S. X Waterman and M. Eggert (J. Mol. Biol. 197:723-728). X Like SSEARCH, LALIGN is rigorous, but also very slow. X XPLALIGN A version of LALIGN that plots its output to a screen X or to a Tektronix terminal emulator. X X3.5. Statistical Significance X XRDF2 improved version of RDF program with all three scoring X methods (now includes local, or window, shuffle X routine) X XRSS A version of RDF2 that uses the rigorous Smith-Waterman X calculation used by SSEARCH. RSS should provide a more X rigorous test of the statistical significance of a X similarity score. X XRELATE significance program described by Dayhoff (Atlas of X Protein Sequence and Structure, Vol. 5, Supplement 3). X X X - 15 - X X X X X X X XFASTA.DOC Release 1.6 X X X Each chunk of 25 residues in one sequence is compared X to every 25 residue fragment of the second sequence. X Sequences which are genuinely related will have a large X number of scores greater than 3 standard deviations X above the mean score of all of the comparisons. X X3.6. Other analysis programs X XAACOMP calculate the amino acid composition and molecular X weight of a sequence. X XBESTSCOR calculate the best self-comparison score. X XGREASE Kyte-Doolittle hydropathicity profile X XTGREASE graphic plot of Kyte-Doolittle profile X XFROMGB convert from GenBank LOCUS format (also used by the X IBI-Pustell programs) to Pearson/FASTA format. X XGARNIER A secondary structure prediction program using the X method of Garnier, Osgusthorpe, and Robson, J. Mol. X Biol., (1978) 120:97-120. X X3.7. Searching for keywords X XFINDP (DOS, Macintosh only) Searches the protein sequence X library title lines (or the aabank.nam file created by X SINDEX) for a list of key words. For example: X X FINDP aabank.nam trypsin X X will search the file of title lines and report all X lines with the word "trypsin" in them. You can search X for several words at once, by putting several words on X the line. Normally, FINDP (and FINDN) ignore upper and X lower case. If you would like to search for a specific X case, e.g. Trypsin but not chymotrypsin, use the -l X option: X X FINDP aabank.nam -l Trypsin X X XFINDN Searches the GENBANK *.ano annotation files for words. X FINDN can search a specific file, or a list of X annotation files. For example, if the file GPRIA.NAM X contains the lines: X X gpri1.ano X gpri2.ano X gpri3.ano X ... X then X X X - 16 - X X X X X X X XFASTA.DOC Release 1.6 X X X FINDN @gpria.nam trypsin X X would search all of the files. FINDN also uses "-l" to X preserve upper/lower case distinctions. X X3.8. Options X X These programs have a number of output options, which are Xinvoked by the environment variables LINLEN, SHOWALL, and MARKX. XAlternatively, these values can be controlled by command line Xoptions. The number of sequence residues per output line is now Xadjustable by setting the environment variable LINLEN, or the Xcommand line option -w. LINLEN is normally 60, to change it set XLINLEN=80 before running the program or add -w 80 to the command Xline. LINLEN can be set up to 200. SHOWALL (-a) determines Xwhether all, or just a portion, of the aligned sequences are Xdisplayed. Previously, FASTP would show the entire length of Xboth sequences in an alignment while FASTN would only show the Xportions of the two sequences that overlapped. Now the default is Xto show only the overlap between the two sequences, to show Xcomplete sequences, set SHOWALL=1, or use the -a option on the Xcommand line. X X The differences between the two aligned sequences can be Xhighlighted in three different ways by changing the environment Xvariable MARKX or the -m option. Normally (MARKX=0) the program Xuses ':' do denote identities and '.' to denote conservative Xreplacements. If MARKX=1, the program will not mark identities; Xinstead conservative replacements are denoted by a 'x' and non- Xconservative substitutions by a 'X'. If MARKX=2, the residues in Xthe second sequence are only shown if they are different from the Xfirst. Thus the three options are: X X X MARKX=0 (default) MARKX=1 MARKX=2 X X MWRTCGPPYT MWRTCGPPYT MWRTCGPPYT X ::..:: ::: xx X ..KS..Y... X MWKSCGYPYT MWKSCGYPYT X X X3.9. Command line options X X It is now possible to specify several options on the Xcommand line, instead of using environment variables. The Xcommand line options are preceded by a dash; the following Xoptions are available: X X-a same as showall=1 X X-b number of sequence scores to be shown on output X X X X - 17 - X X X X X X X XFASTA.DOC Release 1.6 X X X-c # threshold score for optimization (OPTCUT). Set "-c 1" X and "-o" to optimize every sequence in a database. X (This slows the program down about 5-fold). X X-d # number of alignments to be reported by default. (Used X in conjunction with -Q). X X-f identical match score from scoring matrix in the scan X for initial regions. (default for protein) (PAMFACT=1) X X-g # Threshold for joining init1 segments to build an initn X score (GAPCUT). X X-k use constant score in scan for initial regions (like X old fastp, fastn, default for DNA) (PAMFACT=0) X X-l file location of library menu file (FASTLIBS) X X-m # MARKX = # (0, 1, 2) X X-n Force the query sequence to be treated as a DNA X sequence. This is particularly useful for query X sequences that contain a large number of ambiguous X residues, e.g. transcription factor binding sites. X X-o optimize all scores greater than OPTCUT. If '-c' is X not specified, OPTCUT will be calculated from the X length of the sequence and the ktup setting, as the old X CUTOFF value used to be. X X-Q quiet - does not prompt for any input. Writes scores X and alignments to the terminal or standard output file. X X-r file save a results summary line for every sequence in the X sequence library. The summary line includes the X sequence identifier, superfamily number (if available) X position in the library, and the similarity scores X calculated. This option can be used to evaluate the X sensitivity and selectivity of different search X strategies (see W. R. Pearson (1991) Genomics 11:635- X 650.) X X-s file SMATRIX is read from file. Several SMATRIX files are X provided with the standard distribution. For protein X sequences: codaa.mat - based on minimum mutation X matrix; idnaa.mat - identity matrix; idpaa.mat - X identity matrix for mismatches, but identical matches X weighted according to the PAM250 matrix; pam250.mat - X the PAM250 matrix developed by Dayhoff et al (Atlas of X Protein Sequence and Structure, vol. 5, suppl. 3, X 1978); pam120.mat - a PAM120 matrix. The SMATRIX also X specifies the penalties for the first residue in a gap X and additional residues in a gap; FASTA, the other X X X - 18 - X X X X X X X XFASTA.DOC Release 1.6 X X X alignment programs, and the SMATRIX files use -12 and X -4. Currently, to change the -12, -4 gap penalties, the X SMATRIX file must be edited. X X-v (LINEVAL) values used for line styles in plfasta X X-w # line length (width) = number (<200) X X-x specifies offsets for the beginning of the query and X library sequence. For example, if you are comparing X upstream regions for two genes, and the first sequence X contains 500 nt of upstream sequence while the second X contains 300 nt of upstream sequence, you might try: X X fasta -x "-500 -300" seq1.nt seq2.nt X X If the -x option is not used, FASTA assumes numbering X starts with 1. This option will not work properly with X the translated library sequence with tfasta. (You X should double check to be certain the negative X numbering works properly.) X X-1 sort output by init1 score (as FASTP used to do). X X-3 (TFASTA only) translate only three forward frames X X XFor example: X X fasta -w 80 -a seq1.aa seq.aa X Xwould compare the sequence in seq1.aa to that in seq2.aa and Xdisplay the results with 80 residues on an output line, showing Xall of the residues in both sequences. Be sure to enter the Xoptions before entering the file names, or just enter the options Xon the command line, and the program will prompt for the file Xnames. X X Not all of these options are appropriate for all of the Xprograms. The options above are used by FASTA and TFASTA RELATE Xuses the -s option, ALIGN uses the -w, -m, and -s options, and Xthe RDF2 programs use -c, -f, -k, and -s. X X4. Environment variable summary X X Environment variables allow you to set search parameters Xthat will be used frequently when you run a program; for example, Xif you prefer to use the PAM120 scoring matrix, you might "set XSMATRIX=120." Command line parameters, if used, always override Xenvironment variable settings. The following environment Xvariables are used by this program: X X X X - 19 - X X X X X X X XFASTA.DOC Release 1.6 X X XAABANK the file name of the default sequence library. X XFASTLIBS the location of the file which contains the list of X library files to be searched. X XGAPCUT threshold used for joining init1 regions in the second X step of FASTA. Normally set based on sequence length X and ktup. X XGBLIB the directory where the EXTRACTN files and glocus.idx X are found. X XLIBTYPE used to specify the format of the library sequence for X FASTA and TFASTA. X XLINLEN output line length - can go up to 200 X XLINEVAL used by plfasta to determine the relationship between X line style and similarity score (-v). This should be a X string of three numbers, e.g. "200 100 50" X XMARKX symbol for denoting matches, mismatches. Note that this X symbol is only used across the optimized local region; X sequences that are outside this region are not marked. X XOPTCUT Set the threshold to be used for optimization in a band X around the best initial region. Normally the OPTCUT X value is calculated from the length of the sequence and X the ktup value (for a 200 residue sequence, it is about X 28). If OPTCUT=1, every sequence in the database will X be optimized. This is the most sensitive option. X XPAMFACT This version of fasta uses a more sensitive method for X identifying initial regions. Instead of using a X constant factor (fact) for each match in a ktup, it X uses the scoring matrix (PAM) scores. While this works X well for protein sequences, it has not been as X carefully tested for DNA sequences, so by default, this X modification is used for proteins but not for DNA. The X -f 1 option forces this option on. -f 0 forces it off. X Setting the PAMFACT environment variable to 1 forces X the option on; PAMFACT=0 turns it off. X XSHOWALL on output, show the complete sequence instead of just X the overlap of the two aligned sequences. X XSMATRIX alternative scoring matrix file. X XTEKPLOT (IBM-PC only, Unix and VMS versions generate Tektronix X graphics by default) Generate Tektronix output. X Normally, PLFASTA and TGREASE plot graphs using the X Turbo C graphics library. Unfortunately, often these X plots cannot be printed out without special programs. X X X - 20 - X X X X X X X XFASTA.DOC Release 1.6 X X X (I have used GRAFPLUS, from Jewell Technologies, (206) X 937-1081, $50, successfully.) However, if you set X TEKPLOT=1, tektronix graphics commands will be used. X Tektronix commands can be used together with the X PLOTDEV program, available from Microplot Systems, 1897 X Red Fern Dr. Columbus, OH, 43229, (614) 882-4786, for X $40, which also allows you to print out graphics on the X screen. X X XAs always, please inform me of bugs as soon as possible. X XWilliam R. Pearson XDepartment of Biochemistry XBox 440, Jordan Hall XU. of Virginia XCharlottesville, VA X Xwrp@virginia.EDU Xwrp@virginia.BITNET X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X - 21 - X X X $ CALL UNPACK FASTA16.DOC;1 2076792259 $ create 'f' X.nr pp 11 X.nr sp 11 X.nr tp 11 X.nr fp 10 X.nr fi 0n X.sz 11 X.he 'FASTA.DOC''Release 1.6' X.fo ''- % -'' X.if t .po 1.0i X.if n \`7B X.po 0 X.na X.nh X\`7D X.ll 6.5i X.ce X\fB\s+2COPYRIGHT NOTICE\s0\fP X.lp XCopyright 1988, 1991, 1992 by William R. Pearson and the University of XVirginia. All rights reserved. The FASTA program and documentation Xmay not be sold or incorporated into a commercial product, in whole or Xin part, without written consent of William R. Pearson and the XUniversity of Virginia. For further information regarding permission Xfor use or reproduction, please contact: William R. Wilkerson, XAssistant Provost for Research, University of Virginia, P.O. Box 9025, XCharlottesville, VA 22906-9025, (804) 924-6853 X.sp X.uh "\s+2The FASTA program package\s0" X.uh "Introduction" X.pp XThis documentation describes the version 1.6c of the FASTA program Xpackage (see W. R. Pearson and D. J. Lipman (1988), "Improved Tools Xfor Biological Sequence Analysis", PNAS 85:2444-2448, and W. R. XPearson (1990) "Rapid and Sensitive Sequence Comparison with FASTP and XFASTA" Methods in Enzymology 183:63-98). Version 1.6 is the first Xrelease for the IBM-PC and Macintosh since version 1.4 (version 1.5 Xwas distributed only via ftp to unix machines). Version 1.6 has a Xlarge number of improvements over versions 1.4 and 1.5, including the Xability to search libraries in several different formats in the same Xrun, more robust algorithms for aligning sequences along a band, and Xadditional, rigorous (but slow) programs for sequence searching, Xstatistical analysis, and local sequence alignment. In addition, Xseveral additional options are included. Programs that are new with Xversion 1.6 are highlighted in \f2italics\fP. X.sp X.lp XAlthough there are a large number of programs in this package, they Xbelong to three groups: X.(l X XLibrary search programs: FASTA, TFASTA, \f2SSEARCH\fP X XLocal homology programs: LFASTA, PLFASTA, \f2LALIGN, PLALIGN\fP X XStatistical significance: RDF2, RELATE, \f2RSS\fP X.)l X.lp XIn addition, there are several programs for other sequence analysis Xtasks: X.(l X XALIGN - global alignment of two sequences (no limit on gaps). X XEXTRACTP, SINDEX - programs to index (SINDEX) and extract sequences Xfrom a protein sequence database. X XEXTRACTN - programs to extract sequences from the GenBank floppy disk Xformat data base. X.)l X.lp XIn addition, I have included several programs for protein sequence Xanalysis, including a Kyte-Doolittle hydropathicity plotting program X(GREASE, TGREASE), and a secondary structure prediction package X(GARNIER). X.pp XThe FASTA sequence comparison programs on this disk are improved Xversions of the FASTP program, originally described in Science (Lipman Xand Pearson, (1985) Science 227:1435-1441). We have made several Ximprovements. First, the library search programs use a more sensitive Xmethod for the initial comparison of two sequences which allows the Xscores of several similar regions to be combined. As a result, the Xresults of a library search are now given with three scores, X\f2initn\fP (the new initial score which may include several similar Xregions), \f2init1\fP (the old fastp initial score from the best Xinitial region), and \f2opt\fP (the old fastp optimized score allowing Xgaps in a 32 residue wide band). X.pp XThese programs have also been modified to become "universal" (hence XFAST-A, for FASTA-All, as opposed to FAST-P (protein) or FAST-N X(nucleotides)); by changing the environment variable SMATRIX, the Xprograms can be used to search protein sequences, DNA sequences, or Xwhatever you like. By default, FASTA, LFASTA, and the RDF programs Xautomatically recognize protein and DNA sequences. Sequences are Xfirst read as amino acids, and then converted to nucleotides if the Xsequence is greater than 85% A,C,G,T (the '-n' option can be used to Xindicate DNA sequences). TFASTA compares protein sequences to a Xtranslated DNA sequence. Alternative scoring matrices can also be Xused. In addition to the PAM250 matrix for proteins, matrices based Xon simple identities or the genetic code can also be used for sequence Xcomparisons or evaluation of significance. Several different protein Xsequence matrices have been included; instructions for constructing Xyour own scoring matrix are included in the file FORMAT.DOC. X.sp 2 XThe remainder of this document is divided into three sections: (1) a Xbrief history of the changes to the FASTA package; (2) A guide to Xinstalling the programs and databases; (3) A guide to using the FASTA Xprograms. The programs are very easy to use, so if you are using them Xon a machine that is administered by someone else, you may want to Xskip to section (3) to learn how to use the programs, and then read Xsection (1) to look at some of the more recent changes. If you are Xinstalling the programs on your own machine, you will need to read Xsection (2) carefully. X.sp X.sh 1 "Revision History" X.sh 2 "Changes with version 1.6" X.pp XFASTA version 1.6 uses a new method for calculating optimal Xscores in a band (the optimization or last step in the FASTA Xalgorithm). In addition, it uses a linear-space method for calculating Xthe actual alignments. The FASTA package also includes four new Xprograms: X.ip "\f2SSEARCH\fP" 1i Xa program to search a sequence database using Xthe rigorous Smith-Waterman algorithm (this Xprogram is about 100-fold slower than FASTA Xwith ktup=2 (for proteins). X.ip "\f2RSS\fP" 1i Xa version of RDF2 that uses a rigorous Smith-Waterman calculation to Xscore similarities X.ip "\f2LALIGN\fP" 1i XA rigorous local sequence alignment program that will display the XN-best local alignments (N=10 by default). X.ip "\f2PLALIGN\fP" 1i Xa version of lalign that plots the local alignments. X.pp XThe LALIGN/PLALIGN programs incorporate the "sim" algorithm Xdescribed by Huang and Miller (1991) Adv. Appl. Math. 12:337-357. XThe SSEARCH and RSS programs incorporate algorithms described by XHuang, Hardison, and Miller (1990) CABIOS 6:373-381. X.pp XLFASTA and PLFASTA now calculate a different number of local Xsimilarities; they now behave more like LALIGN/PLALIGN. XSince local alignments of identical sequences produce "mirror-image" Xalignments, lalign and lfasta consider only one-half of the potential Xalignments between sequences from identical file names. Thus X.(l I X\fClfasta mchu.aa mchu.aa\fP X.)l XDisplays only two alignments, with earlier versions of the program, it Xwould have displayed five, including the identity alignment. PLFASTA Xdoes display five alignments; when two identical filenames are given, Xit draws the identity alignment, calculates the two unique local Xalignments, draws them, and draws their mirror images. `20 XLFASTA/PLFASTA and LALIGN/PLALIGN use the filenames, rather than the Xactual sequences, to determine whether sequences are identical; you Xcan "trick" the programs into behaving the old way by putting the same Xsequence in two different files. X.sh 2 "Changes with version 1.5" X.pp XFASTA version 1.5 includes a number of substantial revisions to Ximprove the performance and sensitivity of the program. It is now Xpossible to tell the program to optimize all of the \f2initn\fP scores Xgreater than a threshold. The threshold is set at the same value as Xthe old FASTA cutoff score (approximately 0.5 standard deviations Xabove the mean for average length sequences). For highest Xsensitivity, you can use the \fC-c 1\fP option to set the threshold to X1. (This will slow the search down about 5-fold). Alternatively, you Xcan tell FASTA to sort the results by the \f2init1\fP, rather than the X\f2initn\fP, score by using the \fC-1\fP option. \fCFASTA -1 ...\fP Xwill report the results the way the older FASTP program did. A Xcomparison of the performance of FASTA in this, its slowest mode, with Xthe standard FASTA and the Smith-Waterman algorithm has been published Xin Genomics (1991) 11:635-650. X.pp XA new method has been provided for selecting libraries. In the Xpast, one could enter the name of a sequence file to be searched or a Xsingle letter that would specify a library from the list included in Xthe $FASTLIBS file. Now, you can specify a set of library files with a Xstring of letters preceded by a '%'. Thus, if the FASTLIBS file has Xthe lines: X.(l I X XGenbank 70 primates$1P/seqlib/gbpri.seq XGenbank 70 rodents$1R/seqlib/gbrod.seq XGenbank 70 other mammals$1M/seqlib/gbmam.seq XGenbank 70 vertebrates $1B/seqlib/gbvrt.seq X X.)l XThen the string: "%PRMB" would tell FASTA to search the four libraries Xlisted above. The %PRMB string can be entered either on the command Xline or when the program asks for a filename or library letter. X.pp XFASTA1.5 also provides additional flexibility for specifying the Xnumber of results and alignments to be displayed with the \fC-Q\fP X(quiet) option. The \fC-b number\fP option allows you to specify the Xnumber of sequence scores to show when the search is finished. Thus X.(l I X X\fCFASTA -b 100 ...\fP X X.)l Xtells the program to display the top 100 sequence scores. In the past, Xif you displayed 100 scores (in \fC-Q\fP mode), you would also have Xstore 100 alignments. The \fC-d\fP option allows you to limit the Xnumber of alignments shown. \fCFASTA -b 100 -d 20\fP would show 100 Xscores and 20 alignments. X.pp XThe old \fCCUTOFF\fP parameter is no longer used. The program Xstores the best 2000 (IBM-PC, MAC) or 6000 (Unix, VMS) scores and then Xthrows out the lowest 25%, stores the next 500 (1500) better than the Xthreshold determined with the first scores were discarded, and repeats Xthe process as the library is scanned. As a result, the best 1500 - X2000 (4500 - 6000) scores are saved. The old cut-off parameter was Xalso used to set the joining threshold for the calculation of the Xinitn score from initial regions. This joining threshold can now be Xset with the \fC-g\fP option or with the \fCGAPCUT\fP parameter. X.pp XFinally, FASTA can provide a complete list of all of the sequences and Xscores calculated to a file with the \fC-r\fP (results) option. X\fCFASTA -r results.out ...\fP creates a file with a list of scores Xfor every sequence in the library. The list is not sorted, and only Xincludes those scores calculated during the initial scan of the Xlibrary (the optimized score is not calculated unless the \fC-o\fP Xoption is used). X.sh 1 "Installing the FASTA package" X.sh 2 "Installing the programs" X.sh 3 "IBM-PC/DOS version" X.pp XFor the IBM-PC/DOS version, the FASTA source code disk contains the Xcomplete source code to all of the programs on the other disks. The Xprograms were compiled with Borland's Turbo 'C++', using Borland's XMAKE utility. The graphics programs (PLFASTA, TGREASE) use the Xgraphics device drivers supplied with the Turbo 'C' V2.0 package. XAlso included are the documentation files PROGRAMS.DOC and FORMAT.DOC. XYou do not need any of the files the source code disk to run the Xprograms. The files on this disk are identical to the UNIX and VMS Xversions that run on larger machines. Also included is the code to Xcompile ALIGN0.EXE. ALIGN0 is the same as ALIGN, but does not Xpenalize for end-gaps. X.pp XIf you have the DOS or Macintosh version of the FASTA package, to Xinstall the programs you should: X.np XMake a new directory (folder) for the FASTA programs. This need not Xbe the same as the directory for your sequence databases. X.np XCopy the files from the FASTA source disk to the new directory. X.np X(DOS only) Edit your AUTOEXEC.BAT file to (a) modify your PATH command Xto include the FASTA directory and (b) add the line: X.(l X\fCset FASTLIBS=c:\\yourfastadirectory\\fastgbs\fP X.)l XOn the Macintosh, you may need to edit the "environment" file and Xchange the line that reads: X.(l X\fCFASTLIBS=fastgbs\fP X.)l Xto indicate the full directory path for the \fCfastgbs\fP file, for Xexample: X.(l X\fCFASTLIBS=Q105:FASTA:fastgbs\fP X.)l X.np XFinally, you will need to edit the \fCfastgbs\fP file. This is usually Xthe most confusing part of the installation. An example of this file Xis shown below; to customize this file for your machine, you will need Xto change the file names from those provided in the \fCfastgbs\fP file to Xones that reflect the directory names and file names you use on your Xmachine. This is explained in more detail below. In addition, some Xentries in the \fCfastgbs\fP file refer to other files of file names. XThese files of file names (as opposed to actual database files) may Xalso need to be edited. X.sh 3 "Unix version" X.pp XThe FASTA distribution comes with several \fCmakefile\fP's that can be Xused to compile the FASTA programs. Over the years, as ATT Unix XSystem 5 and BSD unix have converged, these files have become very Xsimilar. To begin with, I recommend using the standard \fCMakefile\fP. XThere are two values in the \fCmakefile\fP that should be checked against Xthe values used on your system: the \fCHZ\fP value, which is the frequency Xin ticks per second used by the \fCtimes()\fP system call, this value can Xusually be found by running: X.(l I X\fCgrep HZ /usr/include/sys/*\fP X.)l Xand the functions available to return random numbers. If you have a X\fCrand48()\fP function that returns a 32-bit random number, use it and use Xthe lines: X.(l I X\fCNRAND=nrand48 XRANFLG= -DRAND32\fP X.)l XIf not, you will need to use the \fCrand()\fP function call and determine Xwhether it returns a 16-bit or a 32-bit value. These functions are Xused by RDF2 and RSS. X.p XIf you have problems compiling the programs, you may want to examine Xthe \fCmakefile.unx\fP and \fCmakefile.sun\fP files, to look for differences V. XI have tried to use very standard unix functions in these programs, Xand they have been successfully compiled, with very small changes to Xthe \fCMakefile\fP, on Sun's (Sun OS 4.1), IBM RS/6000's (AIX), and MIPS Xmachines (under the BSD environment). X.sh 2 "Installing the libraries" X.sh 3 "The NBRF protein sequence library" X.pp XThe FASTA program package does not include any protein or DNA Xsequence libraries. You can obtain the PIR protein sequence database from: X.(l XNational Biomedical Research Foundation XGeorgetown University Medical Center X3900 Reservoir Rd, N.W. XWashington, D.C. 20007 X.)l XIn addition, this database is available via anonymous ftp from the Xhost "ftp.bchs.uh.edu". It is available in two formats, VMS and CODATA Xformat. The "VMS" format (library type 5 below) can be searched much Xfaster, can be easily reformatted for use by the "BLAST" rapid Xsearching program, and is compatible with the Genetics Computer Group Xpackage of programs. The CODATA format is used by the EUGENE/MBIR Xcomputing package from Baylor (library type 2). X.pp X(DOS/Macintosh users) The SINDEX and EXTRACTP programs now allow you Xto index a file in one subdirectory, and then move the library without Xhaving to remake the index. When you type: SINDEX @prot.nam, two Xindex files are created: PROT.IXX and PROT.INX. PROT.IXX is a binary Xfile that cannot be edited; it contains the offsets into the library Xfiles for each of the sequence entries. PROT.INX looks exactly like Xthe original PROT.NAM file, and can be edited. However, you cannot Xchange the order of the library files in PROT.INX. What you can do is Xchange the first line, which indicates the directory where the library Xfiles can be found. The index in PROT.IXX might tell EXTRACTP to find Xthe entry LCBO at offset 123,456 in the PROT.3 file. If you changed Xthe PROT.3 line in PROT.INX to PROT.4, LCBO would not be extracted Xproperly. However, if you decide to move your library files from disk X/usr/tmp to disk /usr/lib, you can edit PROT.INX to reflect this Xchange. X.pp XEXTRACTP has also been updated to use the new indexing scheme. To Xextract sequences from a multi-file library that you made with SINDEX X@prot.nam, type: EXTRACTP @prot.nam, or set the environment variable XAABANK=@prot.nam. Then enter the protein sequence identifiers as Xbefore. Remember, if you move the library into a different directory, Xyou will need to copy both the *.IXX and *.INX files to use EXTRACTP. XYou can test EXTRACTP by trying to extract the PIR sequences LCBO, XHBHU, or CCHU. If you do not get an error message, the sequences were Xsuccessfully extracted. They are automatically saved to a file with Xthe name "sequence.aa". So "LCBO" would be found in "lcbo.aa". When Xyou need to extract a sequence from the \fCNEW.LIB\fP library, you Xwill have to \fCset AABANK=new.lib\fP. X.sh 3 "The GENBANK DNA sequence library" X.pp XFASTA, TFASTA, and EXTRACTN search and extract sequences Xfrom the GENBANK DNA sequence library in its compressed, Xfloppy disk format. This library is available from: X.(l XGENBANK Xc/o Intelligenetics X700 E. El Camino Real XMountain View, CA 94040 X(415) 962-7300 X.)l X(The GBANN program used to extract DNA sequence annotations. Unfortunately, XGBANN has not been updated since release 63.0 of GENBANK, when some Xchanges in the annotation files were made. GBANN no longer works.) X.pp XThe GenBank DNA sequence library is also available via anonymous FTP Xfrom \fCgenbank.bio.net\fP. X.sh 3 "The EMBL CD-ROM libraries" X.pp XThe European Molecular Biology Laboratory (EMBL) is distributing a XCD-ROM that contains both the complete EMBL DNA sequence database X(which should be essentially identical to the GenBank DNA sequence Xdatabase) and the SWISS-PROT protein sequence database. SWISS-PROT is Xderived from the NBRF Protein sequence database with additions from Xthe EMBL DNA sequence database. This CD-ROM is a "best-buy," since it Xprovides both DNA and protein sequence libraries. It is available Xfrom: X.(l X XEMBL Data Library XMeyerhofstr. 1 XD-6900 Heidelberg XGermany X\&+49 6221 387258`20 XEmail: SOFTWARE@EMBL-Heidelberg.DE X X.)l X.pp XIn addition, the SWISS-PROT protein sequence database is available via Xanonymous FTP from the hosts \fCgenbank.bio.net\fP and \fCncbi.nlm.nih.gov\f VP. X.sh 2 "Finding the libraries: FASTLIBS" X.pp XFASTA and TFASTA use the environment variable FASTLIBS to find the Xprotein and DNA sequence libraries. The FASTLIBS variable contains Xthe name of a file that has the actual filenames of the libraries. XThe \fCFASTGBS\fP file on is an example of a file that Xcan be referred to by FASTLIBS. To use the \fCFASTGBS\fP file, type: X.(l X\fCsetenv FASTLIBS /usr/lib/fasta/fastgbs\fP (BSD UNIX) Xor X\fCFASTLIBS=/usr/lib/fasta/fastgbs; export FASTLIBS\fP (SysV UNIX) X.)l XThen edit the \fCFASTGBS\fP file to indicate where the protein and DNA Xsequence libraries can be found. If you have a hard disk and your Xprotein sequence library is kept in the file \fC/usr/lib/aabank.lib\fP and Xyour Genbank DNA sequence library is kept in the directory: X\fC/usr/lib/genbank\fP, then \fCfastgbs\fP might contain: X.ne 8 X.(l X.ft C XNBRF Protein$0P/usr/lib/seq/aabank.lib 0 XSWISS PROT 10$0S/usr/lib/vmspir/swiss.seq 5 XGB Primate$1P@/usr/lib/genbank/gpri.nam XGB Rodent$1R@/usr/lib/genbank/grod.nam`20 XGB Mammal$1M@/usr/lib/genbank/gmammal.nam X`5E 1 `5E`5E`5E`5E 4 `5E `5E X 23 (5) X.ft R X.)l XThe first line of this file says that there is a copy of the NBRF Xprotein sequence database (which is a protein database) that can be Xselected by typing "P" on the command line or when the database menu Xis presented in the file \fC/usr/lib/seq/aabank.lib\fP. X.pp XNote that there are 4 or 5 fields in the lines in \fCfastgbs\fP. The first Xfield is the description of the library which will be displayed by XFASTA; it ends with a '$'. The second field (1 character), is a 0 if Xthe library is a protein library and 1 if it is a DNA library. The Xthird field (1 character) is the character to be typed to select the Xlibrary. X.pp XThe fourth field is the name of the library file. In the example Xabove, the \fC/usr/lib/seq/aabank.lib\fP file contains the entire Xprotein sequence library. However the DNA library file names are Xpreceded by a '@', because these files (\fCgpri.nam, grod.nam, Xgmammal.nam\fP) do not contain the sequences; instead they the names Xof the files which contain the sequences. This is done because the XGENBANK DNA database is broken down in to a large number of smaller Xfiles. In order to search the entire primate database, you must Xsearch more than a dozen files. X.pp XIn addition, an optional fifth field can be used to specify the format Xof the library file. Alternatively, you can specify the library Xformat in a file of file names (a file preceded by an '@'). This Xfield must be separated from the file name by a space character ('\ ') Xfrom the filename. In the example above, the \fCaabank.lib\fP file is Xin Pearson/FASTA format, while the \fCswiss.seq\fP file is in PIR/VMS format X(from the EMBL CD-ROM), while the DNA sequences are in compressed XGenBank format. No file type number is included for the Genbank Xfiles, because it is included in the file of filenames (see below). XCurrently, FASTA can read the following formats: X.(l I X.ft C X0 Pearson/FASTA (>SEQID - comment/sequence) X1 Uncompressed Genbank (LOCUS/DEFINITION/ORIGIN) X2 NBRF CODATA (ENTRY/SEQUENCE) X3 EMBL/SWISS-PROT (ID/DE/SQ) X4 Intelligenetics (;comment/SEQID/sequence) X5 NBRF/PIR VMS (>P1;SEQID/comment/sequence) X9 Compressed Genbank Floppy format X.ft R X.)l X(In the near future, I hope to support the BLAST formats.) XIn particular, this version will work with the EMBL and PIR VMS Xformats that are distributed on the EMBL CD-ROM. The latter format X(PIR VMS) is much faster to search than EMBL format. If a library Xformat is not specified, for example, because you are just comparing Xtwo sequences, Pearson/FASTA (format 0) is used by default. To Xchange this default, you may set the LIBTYPE environment variable to Xa number. For example, X.(l I X\fCsetenv LIBTYPE 1\fP X.)l Xwould cause the program to use the GenBank LOCUS format by default Xfor libraries (or the second sequence file), but the Pearson/FASTA Xformat would still be used for the query sequence. X.pp XYou can specify a group of library files by putting a '@' symbol Xbefore a file that contains a list of file names to be searched. For Xexample, if @gpri.nam is in the fastgbs file, the file "gpri.nam" Xmight contain the lines: X.(l X.ft C Xglocus.idx Xgpri1.seq Xgpri2.seq X... Xgpri12.seq X.ft R X.)l XIn this case, the line beginning with a '<' indicates the directory Xthe files will be found in. The line beginning with a '>' indicates Xthe index file; this is only used for the GENBANK compressed DNA database. XThe remaining lines name the actual sequence files. So the first sequence Xfile to be searched would be: X.(l X.ft C X/usr/lib/genbank/gpri1.seq X.ft R X.)l XThe notation "\fCglocus.idx Xgpri1.seq 9 Xgpri2.seq 9 X\&... Xgpri9.seq 9 X\&# (this '#' causes the program to display the size of the library) Xgrod1.seq 9 X\&... Xgmam1.seq 9 X\&... Xguna1.seq 9 X\&... Xunanno.seq 5 X\&# X.ft R X.)l X.(l I F XYou do not need to include library format numbers if you only use the XPearson/FASTA version of the PIR protein sequence library and the XGenbank DNA database on floppy disks. If no library type is Xspecified, the program assumes that type 0 is being used (unless you Xhave set LIBTYPE). However, if the program sees an index file line X(e.g. ">glocus.idx"), it assumes that the files are in Genbank floppy Xdisk format (type 9). X.)l`20 X.pp XAlthough FASTA works best when the libraries are saved on a hard Xdisk, this is not required. If you do not have a hard disk, you Xcould refer to the protein database files by making a file "prot.nam" Xwith the lines: X.(l X.ft C X' in the first column. (3) distributed Xsequence libraries (this is a broad class that includes the NBRF/PIR XVMS and blocked ascii formats, Genbank flat-file format, EMBL Xflat-file format, and Intelligenetics format. All of the files that Xyou create should be of type (1) or (2). Type (2) files (ones with a X'>' and comment before the sequence) are preferred, because they can Xbe used as query or library sequence files by all of the programs. X.pp XI have included several sample test files, *.AA. The first line may begin Xwith a '>' or ';' followed by a comment. The text after ';' in other lines Xwill be ignored. Spaces and tabs (and anything else that is not an Xamino-acid code) are ignored. X.pp XLibrary files should have the form: X.(l X.ft C X>Sequence name and identifier XA F A S Y T .... actual sequence. XF S S .... second line of sequence. X>Next sequence name and identifier X.ft R X.)l XThis is the form of the PROT.* supplied with the floppy disk version Xof the PIR protein sequence library. You can also build your own Xlibrary by concatenating several sequence files. Just be sure that Xeach sequence is preceded by a line beginning with a '>' with a Xsequence name. X.pp XThe test file should not have lines longer than 120 characters, and Xsequences entered with word processors should use a document Xmode, with normal carriage returns at the end of lines. X.uh "\s+2Program Summary\s0" X.sh 2 "Sequence search programs" X.nr ii 1i X.ip "FASTA" Xuniversal sequence comparison. Defaults to comparing protein sequences; Xif the sequences are > 85% A+C+G+T or the \fC-n\fP option is used, a XDNA sequence is assumed. X.ip "TFASTA"`20 XSearch DNA library for a protein sequence by translating the DNA Xsequence to protein in all six frames (three forward frames with the X-3 command line option). TFASTA with ktup=2 is about as fast as a DNA XFASTA with ktup=4, and is substantially more sensitive. X(also reads the GENBANK library) X.ip "\f2SSEARCH\fP" XUniversal sequence comparison using the Smith-Waterman algorithm ( XT. F. Smith and M. S. Waterman (1981) J. Mol. Biol. 147:195-197). XThis program uses code developed by Huang and Miller (X. Huang, R. C. XHardison, W. Miller (1990) CABIOS 6:373-381) for calculating the local Xsimilarity score and code from the ALIGN program (see below) for Xcalculating the local alignment. \f2SSEARCH\fP is about 100-times Xslower than FASTA with ktup=2 (for proteins). It should never be used Xto search an entire protein sequence library, but can be used to Xsearch several hundred sequences. X.ip "ALIGN" Xoptimal global alignment of two sequences with no short-cuts. XThis program is a slightly modified version of one taken from E. XMyers and W. Miller. The algorithm is described in E. Myers and W. XMiller, "Optimal Alignments in Linear Space" (CABIOS (1988) 4:11-17). X.sh 2 "Local similarity programs" X.ip "LFASTA" Xlocal similarity searches showing local alignments. The algorithm Xused to calculate the local alignment in a band has been improved X(Chao, Pearson, and Miller, submitted). X.ip "PLFASTA" Xlocal similarity searches with plot output (on the IBM, Xthis program requires that the environment variable BGIDIR be set). X.ip "PCLFASTA" X(unix only) local similarity searches with plot output using pic commands. X.ip "\f2LALIGN\fP" XCalculates the N-best local alignments using a rigorous algorithm. X(N=10 by default.) The algorithm was developed by Huang and Miller (X. XHuang and W. Miller (1991) Adv. Appl. Math. 12:337-357), which is a Xlinear-space version of an algorithm described by M. S. Waterman and XM. Eggert (J. Mol. Biol. 197:723-728). Like \f2SSEARCH\fP, X\f2LALIGN\fP is rigorous, but also very slow. X.ip "\f2PLALIGN\fP" XA version of \f2LALIGN\fP that plots its output to a screen or to a XTektronix terminal emulator. X.sh 2 "Statistical Significance" X.ip "RDF2" Ximproved version of RDF program with all three scoring methods X(now includes local, or window, shuffle routine) X.ip "\f2RSS\fP" XA version of RDF2 that uses the rigorous Smith-Waterman calculation Xused by \f2SSEARCH\fP. \f2RSS\fP should provide a more rigorous Xtest of the statistical significance of a similarity score. X.ip "RELATE" Xsignificance program described by Dayhoff (Atlas of Protein Sequence Xand Structure, Vol. 5, Supplement 3). Each chunk of 25 residues in Xone sequence is compared to every 25 residue fragment of the second Xsequence. Sequences which are genuinely related will have a large Xnumber of scores greater than 3 standard deviations above the mean Xscore of all of the comparisons. X.sh 2 "Other analysis programs" X.ip "AACOMP" Xcalculate the amino acid composition and molecular weight Xof a sequence. X.ip "BESTSCOR" Xcalculate the best self-comparison score. X.ip "GREASE" XKyte-Doolittle hydropathicity profile X.ip "TGREASE" Xgraphic plot of Kyte-Doolittle profile X.ip "FROMGB" Xconvert from GenBank LOCUS format (also used by the IBI-Pustell programs) Xto Pearson/FASTA format. X.ip "GARNIER" XA secondary structure prediction program using the method of Garnier, XOsgusthorpe, and Robson, J. Mol. Biol., (1978) 120:97-120. X.sh 2 "Searching for keywords" X.ip "FINDP" X(DOS, Macintosh only) Searches the protein sequence library title Xlines (or the aabank.nam file created by SINDEX) for a list of key Xwords. For example: X.(l X\fCFINDP aabank.nam trypsin\fP X.)l Xwill search the file of title lines and report all lines with the Xword "trypsin" in them. You can search for several words at once, Xby putting several words on the line. Normally, FINDP (and FINDN) Xignore upper and lower case. If you would like to search for a Xspecific case, e.g. Trypsin but not chymotrypsin, use the -l option: X.(l X\fCFINDP aabank.nam -l Trypsin X.)l X.ip "FINDN" XSearches the GENBANK *.ano annotation files for words. FINDN can Xsearch a specific file, or a list of annotation files. For example, Xif the file GPRIA.NAM contains the lines: X.(l X\fCgpri1.ano Xgpri2.ano Xgpri3.ano X\&...\fP Xthen X\fCFINDN @gpria.nam trypsin\fP X.)l Xwould search all of the files. FINDN also uses "-l" to preserve Xupper/lower case distinctions. X.sh 2 "Options" X.pp XThese programs have a number of output options, which are invoked Xby the environment variables \fBLINLEN\fP, \fBSHOWALL\fP, and X\fBMARKX\fP. Alternatively, these values can be controlled by Xcommand line options. The number of sequence residues per output Xline is now adjustable by setting the environment variable X\fBLINLEN\fP, or the command line option \fB-w\fP. \fBLINLEN\fP is Xnormally 60, to change it set \fBLINLEN=80\fP before running the Xprogram or add \fB-w 80\fP to the command line. \fBLINLEN\fP can Xbe set up to 200. \fBSHOWALL\fP (\fB-a\fP) determines whether all, Xor just a portion, of the aligned sequences are displayed. XPreviously, FASTP would show the entire length of both sequences in Xan alignment while FASTN would only show the portions of the two Xsequences that overlapped. Now the default is to show only the Xoverlap between the two sequences, to show complete sequences, set X\fBSHOWALL=1\fP, or use the \fB-a\fP option on the command line. X.pp XThe differences between the two aligned sequences can be highlighted Xin three different ways by changing the environment variable X\fBMARKX\fP or the \fB-m\fP option. Normally (MARKX=0) the program Xuses ':' do denote identities and '.' to denote conservative Xreplacements. If MARKX=1, the program will not mark identities; Xinstead conservative replacements are denoted by a 'x' and Xnon-conservative substitutions by a 'X'. If MARKX=2, the residues in Xthe second sequence are only shown if they are different from the Xfirst. Thus the three options are: X.(l X.ft C X XMARKX=0 (default) MARKX=1 MARKX=2 X X MWRTCGPPYT MWRTCGPPYT MWRTCGPPYT X ::..:: ::: xx X ..KS..Y... X MWKSCGYPYT MWKSCGYPYT X.ft R X.)l X.sh 2 "Command line options" X.pp XIt is now possible to specify several options on the command Xline, instead of using environment variables. The command line options Xare preceded by a dash; the following options are available: X.ip "-a" Xsame as showall=1 X.ip "-b" Xnumber of sequence scores to be shown on output X.ip "-c #" Xthreshold score for optimization (OPTCUT). Set "-c 1" and "-o" to Xoptimize every sequence in a database. (This slows the program down Xabout 5-fold). X.ip "-d #" Xnumber of alignments to be reported by default. (Used in conjunction Xwith -Q). X.ip "-f" X identical match score from scoring matrix Xin the scan for initial regions. (default for Xprotein) (PAMFACT=1) X.ip "-g #" XThreshold for joining init1 segments to build an initn score (GAPCUT). X.ip "-k" Xuse constant score in scan for initial regions X(like old fastp, fastn, default for DNA) (PAMFACT=0) X.ip "-l file" Xlocation of library menu file (FASTLIBS) X.ip "-m #" XMARKX = # (0, 1, 2) X.ip "-n" XForce the query sequence to be treated as a DNA sequence. This is Xparticularly useful for query sequences that contain a large number of Xambiguous residues, e.g. transcription factor binding sites. X.ip "-o " Xoptimize all scores greater than OPTCUT. If '-c' is not specified, OPTCUT Xwill be calculated from the length of the sequence and the \fIktup\fP settin Vg, Xas the old CUTOFF value used to be. X.ip "-Q" Xquiet - does not prompt for any input. Writes scores and alignments Xto the terminal or standard output file. X.ip "-r file" Xsave a results summary line for every sequence in the sequence Xlibrary. The summary line includes the sequence identifier, Xsuperfamily number (if available) position`20 Xin the library, and the similarity scores calculated. This option can Xbe used to evaluate the sensitivity and selectivity of different Xsearch strategies (see W. R. Pearson (1991) Genomics 11:635-650.) X.ip "-s file" XSMATRIX is read from file. Several SMATRIX files are provided with Xthe standard distribution. For protein sequences: \fCcodaa.mat\fP - Xbased on minimum mutation matrix; \fCidnaa.mat\fP - identity matrix; X\fCidpaa.mat\fP - identity matrix for mismatches, but identical Xmatches weighted according to the PAM250 matrix; \fCpam250.mat\fP - Xthe PAM250 matrix developed by Dayhoff et al (Atlas of Protein XSequence and Structure, vol. 5, suppl. 3, 1978); \fCpam120.mat\fP - a XPAM120 matrix. The SMATRIX also specifies the penalties for the first Xresidue in a gap and additional residues in a gap; FASTA, the other Xalignment programs, and the SMATRIX files use -12 and -4. Currently, to Xchange the -12, -4 gap penalties, the SMATRIX file must be edited. X.ip "-v \"#1 #2 #3\"" X(LINEVAL) values used for line styles in plfasta X.ip "-w #" Xline length (width) = number (<200) X.ip "-x \"off1 off2\"" Xspecifies offsets for the beginning of the query and library sequence. XFor example, if you are comparing upstream regions for two genes, and Xthe first sequence contains 500 nt of upstream sequence while the Xsecond contains 300 nt of upstream sequence, you might try: X.(l I X\fCfasta -x "-500 -300" seq1.nt seq2.nt\fP X.)l XIf the -x option is not used, FASTA assumes numbering starts with 1. XThis option will not work properly with the translated library Xsequence with tfasta. (You should double check to be certain the Xnegative numbering works properly.) X.ip "-1" Xsort output by init1 score (as FASTP used to do). X.ip "-3" X(TFASTA only) translate only three forward frames X.sp X.lp XFor example: X.(l X\fCfasta -w 80 -a seq1.aa seq.aa\fP X.)l Xwould compare the sequence in seq1.aa to that in seq2.aa and display the Xresults with 80 residues on an output line, showing all of the residues Xin both sequences. Be sure to enter the options before entering the file Xnames, or just enter the options on the command line, and the program will Xprompt for the file names. X.pp XNot all of these options are appropriate for all of the programs. The Xoptions above are used by FASTA and TFASTA RELATE uses the -s option, XALIGN uses the -w, -m, and -s options, and the RDF2 programs use -c, X-f, -k, and -s. X.sh 1 "Environment variable summary" X.pp XEnvironment variables allow you to set search parameters that will be Xused frequently when you run a program; for example, if you prefer to Xuse the PAM120 scoring matrix, you might "set SMATRIX=120." Command Xline parameters, if used, always override environment variable Xsettings. The following environment variables are used by this Xprogram: X.ip "AABANK" Xthe file name of the default sequence library. X.ip "FASTLIBS" Xthe location of the file which contains the list Xof library files to be searched. X.ip "GAPCUT" Xthreshold used for joining init1 regions in the second step of FASTA. XNormally set based on sequence length and \fIktup\fP. X.ip "GBLIB" Xthe directory where the EXTRACTN files Xand glocus.idx are found. X.ip "LIBTYPE" Xused to specify the format of the library sequence for FASTA and TFASTA. X.ip "LINLEN" Xoutput line length - can go up to 200 X.ip "LINEVAL" Xused by plfasta to determine the relationship between line style and Xsimilarity score (-v). This should be a string of three numbers, e.g. X"200 100 50" X.ip "MARKX" Xsymbol for denoting matches, mismatches. Note that this symbol is only Xused across the optimized local region; sequences that are outside Xthis region are not marked. X.ip "OPTCUT" XSet the threshold to be used for optimization in a band around the Xbest initial region. Normally the OPTCUT value is calculated from the Xlength of the sequence and the \fIktup\fP value (for a 200 residue Xsequence, it is about 28). If OPTCUT=1, every sequence in the Xdatabase will be optimized. This is the most sensitive option. X.ip "PAMFACT" XThis version of fasta uses a more sensitive method for identifying Xinitial regions. Instead of using a constant factor (fact) for each Xmatch in a ktup, it uses the scoring matrix (PAM) scores. While this Xworks well for protein sequences, it has not been as carefully tested Xfor DNA sequences, so by default, this modification is used for Xproteins but not for DNA. The -f 1 option forces this option on. -f 0 Xforces it off. Setting the PAMFACT environment variable to 1 forces Xthe option on; PAMFACT=0 turns it off. X.ip "SHOWALL" Xon output, show the complete sequence instead of just the Xoverlap of the two aligned sequences. X.ip "SMATRIX" Xalternative scoring matrix file. X.ip "TEKPLOT"`20 X(IBM-PC only, Unix and VMS versions generate Tektronix graphics by Xdefault) Generate Tektronix output. Normally, PLFASTA and TGREASE Xplot graphs using the Turbo C graphics library. Unfortunately, often Xthese plots cannot be printed out without special programs. (I Xhave used GRAFPLUS, from Jewell Technologies, (206) 937-1081, $50, Xsuccessfully.) However, if you set TEKPLOT=1, tektronix graphics Xcommands will be used. Tektronix commands can be used together with Xthe PLOTDEV program, available from Microplot Systems, 1897 Red Fern XDr. Columbus, OH, 43229, (614) 882-4786, for $40, which also allows Xyou to print out graphics on the screen. X.sp X.lp XAs always, please inform me of bugs as soon as possible. X.sp X.nf XWilliam R. Pearson XDepartment of Biochemistry XBox 440, Jordan Hall XU. of Virginia XCharlottesville, VA X Xwrp@virginia.EDU Xwrp@virginia.BITNET X...!uunet!virginia!wrp X $ CALL UNPACK FASTA16.ME;1 1662276956 $ create 'f' XNBRF Annotated Protein Database (rel 25)$0A/p0/slib/lib/protein.seq 5 XNBRF New Protein Database$0N/p0/slib/lib/new.seq 5 XGENBANK Translated Protein Database (rel 63)$0G/p0/slib/lib/genbank.seq 5 XNRL_3d structure database$0D/p0/slib/PIR/nrl_3d.seq 5 XSwiss-Prot Release 14$0S/p0/slib/embl/swiss.seq 5 XCD-ROM EMBL Unannot $1F3/p0/slib/cdlib/unannseq.dat XGB64.0 Primate$1P/p0/slib/gblib/gb/gbpri.seq XGB64.0 Rodent$1R/p0/slib/gblib/gb/gbrod.seq XGB64.0 other Mammal$1M/p0/slib/gblib/gb/gbmam.seq XGB64.0 verteBrates$1B/p0/slib/gblib/gb/gbvrt.seq XGB64.0 Invertebrates$1I/p0/slib/gblib/gb/gbinv.seq XGB64.0 pLants$1L/p0/slib/gblib/gb/gbpln.seq XGB64.0 Organelle$1O/p0/slib/gblib/gb/gborg.seq XGB64.0 Bacteria$1T/p0/slib/gblib/gb/gbbct.seq XGB64.0 Structural RNA$1S/p0/slib/gblib/gb/gbrna.seq XGB64.0 Viral$1V/p0/slib/gblib/gb/gbvrl.seq XGB64.0 Phage$1G/p0/slib/gblib/gb/gbphg.seq XGB64.0 Synthetic$1Y/p0/slib/gblib/gb/gbsyn.seq XGB64.0 Unannotated$1U/p0/slib/gblib/gb/gbuna.seq XGB64.0 All sequences (long)$1A@/p0/slib/gblib/genbank.fil $ CALL UNPACK FASTGBS.;1 189096783 $ create 'f' X/* fffasta.c 12-Feb-1984, 11-Mar-1985, 14-Oct-1985 X copyright (c) 1985,1986,1987,1988,1991,1992 William R. Pearson X*/ X/* X`09Sept-1991 release 1.6 uses W. Miller l_band, g_band for optimization X`0925-Sept-1991`09fixed RLOCAL_ALIGN() call in zzlgmata.c X X`0914-Mar-87`09added BIGMEM for large memory machines X`09 Mar-87`09added TFASTA for translation of DNA X`09 1-Jun-87`09added LFASTA for lfasta generation from same file X`09 3-Jun-87`09added SFASTA for sfasta generation from same file X`0928-Jun-87`09made modifications for speed a la Warren Gish X`09`09`09changed name to flfasta.c X`0924-Aug-87`09no more modulus counting in dhash(), 2X as X`09`09`09fast on the SUN, now MAXDIAG = MAXTST + MAXLIB; X`09`09`09(ALLOCN0 for modulus counting in LFASTA) X`0919-Oct-87`09modified behavior for nbest > MAXBEST, now X`09`09`09resorts nbest and throws out bottom 25% X`09`09`09also modifying bestcut in the process X`0912-Nov-87`09Added automatic detection of protein/DNA sequences X`0928-Feb-88`09added getopt for options X`0921-Mar-88`09added PAM scores for kfact X`0925-Mar-88`09flag -k for using PAM scores for kfact X`0930-Mar-88`09added menu for libraries X`0930-Mar-88`09combine fasta/fastgb, tfasta/tfastgb X`0919-May-88`09added options for fasta mail processing X`09`09`09-Q - quiet, does not ask for any input X`09`09`09with -Q, has heuristic for number of scores X`09`09`09to display, that number will be less than mshow, X`09`09`09which is set with the -o option. X X`094-Feb-89`09modified libchoice for a variety of different X`09`09`09library formats - no more automatic library setting X X`0920-Nov-89`091.3a fixed bug in pamfact that prevented -k option X`09`09`09from working by default with DNA X X`095-Jun-90`09added optall option X`093-Sept-90`09use select() instead of sortbest() X`09`09`09allow individual library letters to be concatenated X`0913-Dec-90`09fixed bug in select() due to lack of sentinel. X`0923-Jan-91`09fixed bug in aatran() for short sequences X`0927-Jan-91`09made certain than showbest() is called with nbest>0. X`0920-May-91`09fixed ashow to reflect nshow X X*/ X/* fastn is a derivative of dfastp for DNA sequences X X`09fastn is designed to search a DNA sequence database X very rapidly. It first looks for diagonals with homology X using a hashing algorithm. X X General structure: X X Read in the test DNA sequence, build a hash table using X a hash length of ktup. DNA bases will be given values X between 0 and 3 (2 bits) and ktup of 1 to 6 will be allowed X (hash table of 4 to 1024 entries, on larger machines, 4096 X (ktup=6) would be acceptable). X X Start reading the library. Reading the library, looking up X the hash table and accumulating diagonals will all be done X in one loop. The max n diagonals will be identified and X scanned with the PAM matrix for each library sequence. X X The max PAM score and diagonal positions are then saved X for comparison against the whole library. After all sequences X have been examined, a mean and s.d. are calculated and the X max matches displayed. X*/ X X#include X Xchar *refstr="\nPlease cite:\n W.R. Pearson & D.J. Lipman PNAS (1988) 85:244 V4-2448\n"; X X#define TRUE 1 X#define FALSE 0 X X#define max(a,b) (((a)>(b))?(a):(b)) X X#ifndef BIGMEM X#define BIGNUM 32000 X#ifdef TFASTA X#define MAXTST 1000`09/* longest test sequence */ X#define MAXTRN 4000`09/* MAXTRN must be (MAXTST*3+MAXLIB)/3 */ X#define MAXLIB 8000 X#define MAXDIAG (MAXTST+MAXTRN) X#else X#define MAXTST 2000`09/* longest test sequence */ X#define MAXLIB 10000 X#define MAXDIAG (MAXTST+MAXLIB) X#endif X#else X#define BIGNUM 1000000000 X#define MAXTST 10000 X#define MAXLIB 50000 X#define MAXDIAG (MAXTST+MAXLIB) X#ifdef TFASTA X#define MAXTRN 30000 X#endif X#endif X X#ifdef LFASTA X#define MAXSAV 250 X#endif X#ifndef MAXSAV X#define MAXSAV 20`09/* number of best diagonals saved */ X#endif X X#define MAXHIST 41`09/* number of histogram divisions */ X X#ifndef BIGMEM X#define MAXBEST 2000`09/* number of good matches remembered */ X#else X#define MAXBEST 6000 X#endif X XFILE *outfd;`09`09/* fd for output file */ Xint smark`5B4`5D; X XFILE *tmpfd; Xchar tmpfname`5B80`5D; Xint dataflg=0; X X/* globals for matching */ X Xlong lmark;`09`09/* position in library file from ftell() */ Xlong nlib, onlib; Xlong ntt, ontt;`09`09/* number of library sequences, number of X`09`09`09`09residues scanned*/ X#ifdef LFASTA Xint oneseq; X#endif X X#define BINARYGB 9`09/* this must agree with altlib.h */ X#ifndef LFASTA Xextern int (*getlib)(), (*ranlib)(); Xextern int sfnum; X#define GETLIB (*getlib) X#define RANLIB (*ranlib) X#else X#define GETLIB getlib X#define RANLIB ranlib X#endif X Xchar libstr`5B21`5D;`09/* partial title from library sequence */ Xchar name0`5B11`5D, name1`5B11`5D;`09/* for labeling output */ Xint ixstat;`09`09/* >0 if annotations displayed */ X X#define MAXLF`09200`09/* number of library names */ X#ifdef BIGMEM X#define MAXLN`0940`09/* size of a library name */ X#else X#define MAXLN`0920 X#endif X Xchar *lbnarr;`09`09/* name array of libraries to be opened in list */ Xchar *lbnames`5BMAXLF`5D;`09/* names of libraries to be opened */ Xint nln;`09`09/* number of library files */ Xint gbflag=0;`09`09/* flag if any library is BINARYGB type */ X#ifndef LFASTA Xint deftype=0;`09`09/* default library type */ X#endif X Xint libfn;`09`09/* current library file being searched */ Xchar iname`5B80`5D; `09/* index file name */ Xchar ldname`5B80`5D; X Xchar *aa0, *aa1;`09/* amino acid sequence data */ X#ifdef TFASTA Xchar *aa10; Xint nframe=6; X#endif X Xint maxn, maxt;`09`09/* max space for lib sequence */ Xint n0, n1, nd, noff;`09/* length of aa0, length of aa1, n0+n1, X`09`09`09`09diagonal offset */ Xlong sq0off=1, sq1off=1; Xlong loffset = 0l;`09`09/* offset into sequence */ X Xstruct dstruct `7B`09/* diagonal structure for saving current run */ X int score;`09/* hash score of current match */ X int start;`09/* start of current match */ X int stop;`09/* end of current match */ X`09struct beststr *dmax;`09/* location in vmax`5B`5D where best score data s Vaved */ X `7D *diag; X X#ifdef I86BUG X#define L2DSTR 3`09/* log(2) of sizeof dstruct for I86 bug in many 'C' X`09`09`09 compilers */ X#endif X Xstruct beststr `7B X`09int score;`09/* pam score with segment optimization*/ X`09int score0;`09/* pam score of best single segment */ X`09int gscore;`09/* score from global match */ X`09long lseek;`09/* position in library file */ X`09int dp;`09`09/* diagonal of match */ X`09int start;`09/* start of match in lib seq */ X`09int stop;`09/* end of match in lib seq */ X`09int cont;`09/* offset into sequence */ X`09int frame; X`09int lib;`09/* library for current sequence */ X`09`7D`20 X`09 *qptr, X#ifndef FAR_PTR X`09 *bbp,`09`09/* pointer for fbest */ X`09 *bestptr,`09/* temp pointer */ X`09 **bptr,`09/* array of pointers for sorting */ X`09 *best,`09/* array of best score data */ X#else X`09 far * bbp, X`09 far * best, X`09 far * bestptr,`09/* temp pointer */ X`09 far * far * bptr, X#endif X`09 vmax`5BMAXSAV`5D,`09/* best matches saved for one sequence */ X`09 *vptr`5BMAXSAV`5D; X X#ifdef LFASTA Xint lcrc0`5BMAXSAV`5D; Xint lcrc1`5BMAXSAV`5D; Xint ncrc; X#endif X Xint iscore, gscore;`09/* for displaying scores without showbest */ X Xint cgap;`09/* gap threshold */ Xint pgap;`09/* gap penalty for optimized alignment of diagonals */ X Xint nbest;`09/* number of sequences better than bestcut in best */ Xint bestcut=1; `09/* cut off for getting into MAXBEST */ Xint optcut=0;`09/* cut off for optimization */ X X/* the following are defaults for values that are read by X pam.c from *.mat if SMATRIX is defined */ X Xint histint=2; Xint bestscale=200; Xint bkfact=5; Xint scfact=4; Xint bktup=2; Xint ktmax=2; Xint bestmax=50; Xint bestoff=27;`09/* values for calculating bestcut */ Xint pamfact= 1;`09/* flag for using pam values for kfact */ Xint dnaseq = 0;`09/* true if DNA query sequence */ Xint ldnaseq = 0; X Xint bestfull=0; Xint igncnt=0; Xint optall=0; Xlong optcount=0l; Xint init1flg=0; X Xint nsav, lowscor;`09/* number of saved runs, worst saved X`09`09`09`09run, score of worst saved run */ Xstruct beststr *lowmax; X Xint hist`5BMAXHIST`5D;`09`09/* histogram of all score */ Xint hist0`5BMAXHIST`5D;`09`09/* histogram of all score */ Xdouble lsum, lsumsq;`09`09/* mean, sd of all scores */ Xdouble lsum0, lsumsq0;`09`09/* mean, sd of all scores */ Xdouble sqrt(); Xlong nmean;`09`09`09/* number of scores averaged in mean */ Xint bigscore; X Xint fact, gm; /* scoring factors */ X Xint hmask, hmax;`09`09/* hash constants */ Xint *pamh2;`09`09`09/* pam based kfact array */ Xint *link, *harr;`09`09/* hash arrays */ Xint ktup, kshft, kt1;`09`09/* ktuple constants */ X Xint nshow=20, mshow=50, ashow=20; Xchar rline`5B20`5D,sline`5B20`5D; X X/* output options */ Xint showall, llen, markx;`09/* show all of both sequences */ X Xchar ttitle`5B60`5D; Xchar ltitle`5B60`5D; X Xlong tstart, tscan, tdone, stime(); X Xextern int optind; Xint optcnt; X X#ifndef LFASTA Xint outtty; X#endif X Xchar *libenv, *aaenv, *smptr; Xchar smstr`5B40`5D; Xchar flstr`5B40`5D; X#ifdef TPLOT Xchar lvstr`5B40`5D; X#endif X X#include "upam.gbl"`09`09/* includes pam array */ X Xmain(argc, argv) X int argc; char **argv; X`7B X`09char tname`5B40`5D, lname`5B80`5D, llname`5B80`5D, qline`5B40`5D; X`09int itemp, iln;`20 X`09char *calloc(), *getenv(), *cptr; X X#ifndef LFASTA X#ifdef UNIX X`09outtty=isatty(1); X#else X`09outtty=1; X#endif X#endif X X`09initenv(argc,argv); X`09if (dataflg && (tmpfd=fopen(tmpfname,"w"))==NULL) `7B X`09`09fprintf(stderr," cannot open temp file: %s\n",tmpfname); X`09`09dataflg=0; X`09`09`7D X X#ifdef TFASTA X`09aainit(); X`09dnaseq = -1;`09/* force to protein */ X`09ldnaseq = 1; X`09if (sqtype`5B0`5D=='D') `7B X`09`09fprintf(stderr," tfasta compares a protein to a translated\n\ XDNA sequence library. Do not use a DNA scoring matrix.\n"); X`09`09exit(1); X`09`09`7D X#endif X X`09if ((aa0=calloc(MAXTST+MAXLIB,sizeof(char)))==0) `7B X`09`09fprintf(stderr," cannot allocate sequence array\n"); X`09`09exit(1); X`09`09`7D X`09maxn = MAXTST+MAXLIB; X X#ifdef TFASTA X`09if ((aa1=calloc(MAXTRN,sizeof(char)))==0) `7B X`09`09fprintf(stderr," cannot allocate translation array\n"); X `09`09exit(1); X `09`09`7D X#endif X X if (argc-optind < 3) `7B X#ifdef LFASTA Xprintf(" lfasta 1.6c2 `5BMarch, 1992`5D compares two sequences\n%s\n",refstr V); X`09l1:`09printf(" first sequence file name: "); X#else X#ifdef TFASTA Xprintf(" tfasta 1.6c2 `5BMarch, 1992`5D translates and searches a sequence d Vata bank\n%s\n",refstr); X`09l1:`09printf(" test sequence file name: "); X#else Xprintf(" fasta 1.6c2 `5BMarch, 1992`5D searches a sequence data bank\n%s\n", Vrefstr); X`09l1:`09printf(" test sequence file name: "); X#endif X#endif X`09`09fflush(stdout); X`09`09if (fgets(tname,40,stdin)==NULL) exit(0); X`09`09if (tname`5Bstrlen(tname)-1`5D=='\n') tname`5Bstrlen(tname)-1`5D='\0'; X`09`09if (tname`5B0`5D=='\0') goto l1; X `09if ((n0=getseq(tname,aa0,maxn,&dnaseq))==0) `7B X fprintf(stderr," %s : %s sequence not found\n",tname,sqtyp Ve); X goto l1; X `7D X X`09`09resetp(dnaseq); X X#ifndef TFASTA X if (dnaseq==1 && n0>(MAXTST+MAXLIB)/3) `7B X `09fprintf(stderr," query sequence is too long %d %s\n",n0,sqnam); X `09exit(1); X`09 `7D X else if (dnaseq==0 && n0>(MAXTST+MAXLIB)/2) `7B X `09fprintf(stderr," query sequence is too long %d %s\n",n0,sqnam); X `09exit(1); X`09 `7D X#else `09 X if (n0 > MAXTST) `7B X `09fprintf(stderr," query sequence is too long %d %s\n",n0,sqnam); X `09exit(1); X`09 `7D X#endif X`09`09`09 X#ifdef LFASTA X`09l2:`09printf(" second sequence file name: "); X`09`09fflush(stdout); X`09`09if (fgets(lname,40,stdin)==NULL) exit(0); X`09`09if (lname`5Bstrlen(lname)-1`5D=='\n') lname`5Bstrlen(lname)-1`5D='\0'; X`09`09if (*lname==0) goto l2; X#else X`09 libchoice(lname,sizeof(lname),aaenv); X#endif X`09`09libselect(lname); X`09`09printf(" ktup? (1 to %d) `5B%d`5D ",ktmax,ktmax); X`09`09if (fgets(qline,40,stdin)==NULL) exit(0); X`09`09ktup = ktmax; X`09`09if (qline`5B0`5D!='\0' && qline`5B0`5D!='\n') `7B X`09`09`09sscanf(qline,"%d",&ktup); X`09`09`09if (ktup < 1 `7C`7C ktup>ktmax ) `7B X`09printf(" warning ktup = %d out of range, reset to %d\n",ktup,ktmax); X`09`09`09`09ktup = ktmax; X`09`09`09`09`7D X`09 `7D X`09`09`7D X`09else `7B X`09`09strncpy(tname,argv`5Boptind+1`5D,sizeof(tname)); X `09if ((n0=getseq(tname,aa0,maxn,&dnaseq))==0) `7B X fprintf(stderr," %s : %s sequence not found\n",tname,sqtyp Ve); X exit(1); X `7D X`09`09resetp(dnaseq); X#ifndef TFASTA X if (dnaseq==1 && n0>(MAXTST+MAXLIB)/3) `7B X `09fprintf(stderr," query sequence is too long %d %s\n",n0,sqnam); X `09exit(1); X`09 `7D X else if (dnaseq==0 && n0>(MAXTST+MAXLIB)/2) `7B X `09fprintf(stderr," query sequence is too long %d %s\n",n0,sqnam); X `09exit(1); X`09 `7D X#else `09 X if (n0 > MAXTST) `7B X `09fprintf(stderr," query sequence is too long %d %s\n",n0,sqnam); X `09exit(1); X`09 `7D X#endif X`09`09strncpy(lname,argv`5Boptind+2`5D,sizeof(lname)); X X`09`09libselect(lname); X`09 if (argc-optind==4) sscanf(argv`5Boptind+3`5D,"%d",&ktup); X`09 else ktup=ktmax; X`09`09if (ktup < 1 `7C`7C ktup>ktmax ) `7B X`09fprintf(stderr," warning ktup = %d out of range, reset to %d\n",ktup,ktma Vx); X`09`09`09ktup = ktmax; X`09`09`09`7D X`09`09`7D X X#ifndef LFASTA X`09if (!outtty) fprintf(stderr," %s : %4d %-s\n",tname, n0, sqnam); X#endif X`09gettitle(tname,ttitle,50); X`09if (strlen(ttitle)>0) X`09`09if (*ttitle=='>') strncpy(name0,&ttitle`5B1`5D,6); X`09`09else strncpy(name0,ttitle,6); X`09else X`09`09strncpy(name0,tname,6); X`09name0`5B6`5D='\0'; X X#ifdef LFASTA X`09if (strcmp(tname,lname)==0) oneseq=1; X#else X`09if (strlen(ttitle)>0) X`09`09printf(" %s : %d %s\n vs %s library\n",ttitle,n0,sqnam,ltitle); X`09else X`09`09printf(" %s : %d %s vs %s library\n",tname,n0,sqnam,ltitle); X X`09if (dataflg) `7B X`09 if (strlen(ttitle)>0) X fprintf(tmpfd,"; %s : %d %s\n; vs %s library\n",ttitle,n0,sqnam,ltitle) V; X`09 else X fprintf(tmpfd,"; %s : %d %s vs %s library\n",tname,n0,sqnam,ltitle); X`09`7D X X#endif X X#ifndef TFASTA X`09aa1 = aa0 + n0 + 2; X#else X`09aa10 = aa0 + n0 + 2; X#endif X X`09maxn -= n0 + 3; X X`09initpam2();`09/* convert 1-d pam to 2-d pam2 */ X X`09initparm(); X`09if (dataflg) `7B X fprintf(tmpfd,"; ktup = %d\n",ktup); X fprintf(tmpfd,"; cutoff = %d; optcut = %d; ggapval %d gdelval %d cgap % Vd\n", X`09bestcut,optcut,ggapval,gdelval,cgap); X`09`7D X X`09tstart = stime(); X X`09fact = ktup*scfact; X`09hashaa(aa0,n0,ktup);`09/* hash test sequence */ X X#ifndef ALLOCN0 X`09allocdiag(MAXDIAG); X#else X`09allocdiag(n0); X#endif X X`09inithist();`09`09/* initialize histogram, mean, sd */ X X`09initbest(MAXBEST+1);`09/* +1 required for select() */ X`09for (nbest=0; nbest0) `7B X`09 printf(" searching %s library\n",lbnames`5Biln`5D); X`09 dhash(); X`09 `7D X`09 if (itemp== -9) `7B X`09 printf(" %8ld %s in %5ld sequences\n",ntt-ontt, X`09`09 sqnam,nlib-onlib); X`09 ontt=ntt; onlib=nlib; continue; X`09 `7D X`09 if (itemp<0) break; X#ifndef LFASTA X`09 closelib(); X#endif X`09`7D X X`09tscan = stime(); X X#ifndef LFASTA X`09if (dataflg) `7B X`09fprintf(tmpfd,"; %8ld %s in %5ld sequences; scan time: ", X`09`09ntt,sqnam,nlib); X`09ptime(tmpfd,tscan-tstart); X`09fputs("\n",tmpfd); X`09if (optall) X`09 fprintf(tmpfd,"; %d optimizations performed\n",optcount); X `7D X`09prhist(stdout);`09`09/* print histogram, statistics */ X#endif X X`09free(diag); X`09freehash(); X X#ifndef LFASTA X`09outfd = stdout; X l3:`09if (outtty) `7Bprintf(" Enter filename for results : "); fflush(stdo Vut);`7D X`09`09rline`5B0`5D='\0'; X`09`09if (outtty && fgets(rline,20,stdin)==NULL) exit(0); X`09`09if (rline`5B0`5D!='\n' && rline`5B0`5D!=0) `7B X`09`09`09rline`5Bstrlen(rline)-1`5D=0; X`09`09`09if ((outfd=fopen(rline,"w"))==0) `7B X`09`09`09`09printf(" could not open %s\n",rline); X`09`09`09`09goto l3; X`09`09`09`09`7D X`09`09`09fprintf(outfd," %s, %d %s vs %s library\n", X`09`09`09`09tname, n0, sqnam, lname); X`09`09`09if (strlen(smptr)>0) X`09`09`09`09fprintf(outfd," using matrix file %s\n",smptr); X`09`09`09else fprintf(outfd," using %s matrix\n",sqtype); X`09`09`09prhist(outfd); X`09`09`09`7D X#else X#ifdef TPLOT X`09outfd = stderr; X#else X`09outfd = stdout; X#endif`09/* LFASTA */ X`09fprintf(outfd," Comparison of:\n(A) %-10s %-50s - %d %s\n", X`09`09tname,ttitle,n0,sqnam); X`09fprintf(outfd,"(B) %-10s %-50s - %ld %s\n",lname,ltitle,ntt,sqnam); X`09if (strlen(smptr)>0) fprintf(outfd," using matrix file %s\n",smptr); X`09else fprintf(outfd," using %s matrix\n",sqtype); X X`09if (nbest<=0) `7B X`09 fprintf(outfd, X`09 " No similar regions with scores greater %d than found\n",optcut); X`09 exit(0);`7D X#endif X X`09sortbest(); X X#ifdef LFASTA X`09nshow = nbest; X#ifdef TPLOT X`09openplt((long)n0,(long)ntt); X`09if (oneseq) drawdiag((long)n0,(long)ntt); X`09showlocal(nshow); X`09closeplt(); X#else X`09showlocal(nshow); X#endif X X#else`09/* !LFASTA */ X`09if (gbflag) `7B X`09`09if (iname`5B0`5D=='\0') newname(iname,lname,"idx",40); X`09`09ixstat=openidx(iname,libenv); X`09`09`7D X X`09if (nbest <= 0) `7B X fprintf(outfd," no sequences with scores greater than %d found\n",bestcut) V; X if (outfd != stdout)`20 X fprintf(outfd," no sequences with scores greater than %d found\n",bestcut) V; X exit(0); X `7D X`09showbest();`09/* display best matches */ X X`09rline`5B0`5D='Y'; X`09if (outtty) `7B X`09`09printf(" Display alignments also? "); fflush(stdout); X`09`09if (fgets(rline,20,stdin)==NULL) exit(0); X`09`09`7D X`09if (toupper(rline`5B0`5D)=='Y') `7B X`09`09if (outtty) `7B X`09`09`09printf(" number of alignments `5B%d`5D? ",nshow); X`09`09`09fflush(stdout); X`09`09`09if (fgets(rline,20,stdin)==NULL) exit(0); X`09`09`09if (rline`5B0`5D!=0) sscanf(rline,"%d",&nshow); X`09`09 ashow=nshow; X`09`09`09`7D X`09`09showalign(nshow); X`09`09`7D X`09tdone = stime(); X`09printf("Library scan: "); ptime(stdout,tscan-tstart); X`09printf(" total CPU time: "); ptime(stdout,tdone-tstart); X`09printf("\n"); X`09if (outfd!=stdout) `7B X`09`09fprintf(outfd,"Library scan: "); ptime(outfd,tscan-tstart); X`09`09fprintf(outfd," total CPU time: "); ptime(outfd,tdone-tstart); X`09`09fprintf(outfd,"\n"); X`09`09`7D X#endif X`09exit(0); X`09`7D X Xextern int *sascii, nascii`5B`5D, aascii`5B`5D; X Xinitenv(argc,argv) X`09int argc; X`09char **argv; X`7B X`09char *cptr, *getenv(); X`09int copt, getopt(); X`09extern char *optarg; X`09int i; X X`09libenv="\0"; X`09if ((aaenv=getenv("AABANK"))==NULL) aaenv="\0"; X`09if ((cptr=getenv("FASTLIBS"))!=NULL) strncpy(flstr,cptr,sizeof(flstr)); X`09else flstr`5B0`5D='\0'; X X`09sascii = aascii; X`09pam = apam; X`09sq = aa; X`09hsq = haa; X`09nsq = naa; X`09dnaseq = 0; X`09ldnaseq = 0; X X`09showall = 0; X X`09if ((cptr=getenv("SHOWALL"))!=NULL) X`09`09if (sscanf(cptr,"%d",&showall)!=1) showall = 1; X X`09if ((cptr=getenv("LINLEN"))!=NULL) sscanf(cptr,"%d",&llen); X`09else llen = 60; X`09if (llen>=200) llen=200-1; X`09markx=0; X`09if ((cptr=getenv("MARKX"))==NULL) markx=0; X`09else sscanf(cptr,"%d",&markx); X X`09if ((cptr=getenv("GAPCUT"))!=NULL) sscanf(cptr,"%d",&cgap); X`09else cgap=0; X X`09if ((cptr=getenv("OPTCUT"))!=NULL) sscanf(cptr,"%d",&optcut); X`09else optcut = 0; X X`09if ((cptr=getenv("PAMFACT"))!=NULL) `7B X`09`09sscanf(cptr,"%d",&pamfact); X`09`09if (pamfact==1) pamfact= -2; else pamfact = 0; X`09`09`7D X X#ifndef LFASTA X`09if ((cptr=getenv("LIBTYPE"))!=NULL) sscanf(cptr,"%d",&deftype); X`09if (deftype<0 `7C`7C deftype>BINARYGB) deftype= 0; X#endif X X`09while ((copt=getopt(argc,argv,"Qqab:c:d:g:kfl:m:nor:s:v:w:x:13"))!=EOF) X`09`09switch(copt) `7B X`09`09`09case 'q': X#ifndef LFASTA X`09`09`09case 'Q': outtty=0; break; X#endif X`09`09`09case 'a': showall=1; break; X`09`09`09case 'b': sscanf(optarg,"%d",&mshow); X`09`09`09`09`09if (mshow<5) mshow=20; X`09`09`09`09`09break; X`09`09`09case 'd': sscanf(optarg,"%d",&ashow); X`09`09`09 `09`09if (ashow<0) ashow=20; X`09`09`09 `09`09break; X`09`09`09case 'c': sscanf(optarg,"%d",&optcut); break; X`09`09`09case 'g': sscanf(optarg,"%d",&cgap); break; X`09`09`09case 'k': pamfact= -1; break; X`09`09`09case 'f': pamfact= -2; break; X`09`09`09case 'l': strncpy(flstr,optarg,sizeof(flstr)); X`09`09`09`09break; X`09`09`09case 'm': sscanf(optarg,"%d",&markx); break; X`09`09`09case 'n': dnaseq=1; X`09`09`09 sascii = nascii; X`09`09`09 sq = nt; X`09`09`09 nsq = nnt; X`09`09`09 hsq = hnt; X`09`09`09 pam = npam; X`09`09`09 strcpy(sqnam,"nt"); X`09`09`09 strcpy(sqtype,"DNA"); X`09`09`09 resetp(dnaseq); X`09`09`09 break; X`09`09`09case 's': strncpy(smstr,optarg,sizeof(smstr)); X`09`09`09 smptr = smstr; X`09`09`09 if (initpam(smptr)) `7B X`09`09`09 dnaseq= -1; X`09`09`09 ldnaseq = (sqtype`5B0`5D=='D')?1:0; X`09`09`09 `7D X`09`09`09 else smptr="\0"; X`09`09`09 break; X`09`09`09case 'w': sscanf(optarg,"%d",&llen); break; X`09`09 case 'x': sscanf(optarg,"%ld %ld",&sq0off,&sq1off); X`09`09`09 break; X#ifndef LFASTA X`09`09`09case '1': init1flg=1; break; X`09`09`09case 'o': optall=1; break; X`09`09`09case 'r': dataflg=1;`20 X`09`09`09`09strncpy(tmpfname,optarg,sizeof(tmpfname)); X`09`09`09`09break; X#else X`09`09`09case '1': init1flg=1; break; X`09`09`09case 'Q':`20 X`09`09`09case 'o': X`09`09`09case 'r':fprintf(stderr," illegal option -%c\n",copt); X`09`09`09`09break; X#endif X#ifdef TPLOT X`09`09`09case 'v': strncpy(lvstr,optarg,sizeof(lvstr)); X`09`09`09`09break; X#endif X#ifdef TFASTA X`09`09`09case '3': nframe=3; break; X#else X`09`09`09case '3': X#endif X`09`09`09default : fprintf(stderr," illegal option -%c\n",copt); X`09`09`09`7D X X`09optind--; X X`09if (dnaseq>=0) `7B X`09`09if ((smptr=getenv("SMATRIX"))!=NULL && initpam(smptr)) `7B X`09`09`09dnaseq = -1; X`09`09`09ldnaseq = (sqtype`5B0`5D=='D')?1:0; X`09`09`09`7D X`09`09else X`09`09`09smptr="\0"; X`09`09`7D X X`09ktmax = bktup; X`09 X`09if (strlen(smptr)>0) fprintf(stderr," using matrix file %s\n",smptr); X`09`7D X Xresetp(dnaseq) X`09int dnaseq; X`7B X`09if (dnaseq==1) `7B X`09`09histint=4; X`09`09bestscale=80; X`09`09bkfact=5; X`09`09scfact=1; X`09`09bktup=6; X`09`09ktmax=6; X`09`09bestmax=80; X`09`09bestoff=45; X`09`09pam = npam; X`09`09ldnaseq=1; X`09`09if (pamfact>=0) pamfact = 0; X`09`09`7D X`09`7D X Xinitparm() X`7B X`09char *getenv(), *cptr; X`09int itemp, btemp; X X`09btemp = 2*bestoff/3 + n0/bestscale + bkfact*(bktup-ktup); X`09if (btemp>bestmax) btemp = bestmax; X`09if (btemp > 3*n0) btemp = 3*shscore(aa0,n0)/5; X X`09bigscore = btemp + 2*bestoff; X`09bestfull = 0; X X`09if (cgap<=0) cgap=btemp+bestoff/3; X`09if (optcut<=0) optcut=btemp; X`09pgap = gdelval+ggapval; X`09`7D X X/*`09hashaa - hash sequence 0 for rapid lookup of seq 1 (library) */ X Xhashaa(aa0, n0, ktup) X`09char *aa0; int n0, ktup; X`7B X`09char *calloc(); X`09int mhv,phv; X `09int i0, hv; X X`09if (pamfact == -1) pamfact=0; X`09else if (pamfact== -2) pamfact=1; X X X`09for (i0=0, mhv= -1; i0mhv) mhv=hsq`5Bi0`5D; X X`09if (mhv<=0) `7B X`09`09fprintf(stderr," maximum hsq <=0 %d\n",mhv); X`09`09exit(1); X`09`09`7D X`09`09 X`09for (kshft=0; mhv>0; mhv/=2) `7B X`09`09kshft++; X`09`7D X X/* kshft = 2;`09*/ X kt1 = ktup-1; X X`09hv = 1; X`09for (i0 = 0; i0>kshft)-1; X X`09allochash(n0,hmax); X X`09for (i0=0; i00) `7B X`09`09nlib++; X`09`09ntt += n1; X`09`09if (n1==1 `7C`7C n1 < ktup) `7B X`09`09`09if (igncnt++ <10) X`09`09`09`09fprintf(stderr,"Ignoring: %s\n",libstr); X`09`09`09goto loop; X`09`09`7D X`09`09if (aa1!=aa1ptr) `7Bn1 += n0; nlib--;`7D X#else X`09maxt = maxn-loff-3; maxt -= maxt%3; maxt++; X while ((n10=GETLIB(aa1ptr,maxt,libstr,&lmark,&lcont))>0) `7B X`09`09nlib++; X`09`09ntt += n10; X`09`09if (n10==1 `7C`7C n10 < 3*ktup) `7B X`09`09`09if (igncnt++ <10) X`09`09`09`09fprintf(stderr,"Ignoring: %s\n",libstr); X`09`09`09goto loop; X`09`09 `7D X`09`09if (aa10!=aa1ptr) `7Bn10 += 3*n0; nlib--;`7D X#endif X X#ifdef TFASTA X`09 for (itt=0; ittstop = -1; X`09`09`09dptr->dmax = NULL; X`09`09`09dptr++->score = 0; X `7D X X`09`09for (vmptr=vmax; vmptr<&vmax`5BMAXSAV`5D; vmptr++) X`09`09`09vmptr->score = 0; X`09`09lowmax = vmax; X`09`09lowscor = 0; X X /* start hashing */ X lhval = 0; X for (lpos=0; lpos=tlim; tpos=link`5Btpos`5D) V `7B X`09`09 if ((tscor = (dptr = &diagp`5B-tpos`5D)->stop)>=0) `7B X#else X`09lposn0 = noff + lpos; X for ( ; lpos=tlim; tpos=link`5Btpos`5D) V `7B X`09`09 dpos = lposn0 - tpos; X`09`09 if ((tscor = (dptr = &diag`5Bdpos%nd`5D)->stop)>=0) `7B X#endif X`09`09`09tscor += ktup; X`09`09`09if ((tscor -=lpos)<=0) `7B X`09`09`09 scor = dptr->score; X#ifdef FKFACT X`09`09`09 if ((tscor += kfact)<0 && lowscor=kfact) `7B X `09`09`09`09dptr->score = tscor; X `09`09`09`09dptr->stop=lpos; X `09`09`09`09`7D X `09`09`09 else `7B X `09`09`09`09dptr->score = kfact; X `09`09`09`09dptr->start = (dptr->stop = lpos) - kt1; X`09`09`09`09`7D X`09`09`09 `7D X`09`09`09else `7B X#ifdef FKFACT X`09`09 `09 dptr->score += fact; X#else X`09`09 `09 dptr->score += pamh1`5Baa0`5Btpos`5D`5D; X#endif X`09`09 `09 dptr->stop = lpos; X`09`09`09 `7D X`09`09`09`7D X`09`09 else `7B X#ifdef FKFACT X`09`09 `09dptr->score = kfact; X#else X`09`09 `09dptr->score = pamh2`5Blhval`5D; X#endif X`09`09 `09dptr->start = (dptr->stop=lpos) - kt1; X`09`09`09`7D X`09`09 `7D /* end tpos */ X X#ifdef LFASTA X`09`09if (oneseq) tlim++; X#endif X#ifdef ALLOCN0 X`09`09/* reinitialize diag structure */ X X`09`09if ((dptr= &diag`5Blpos%nd`5D)->score>lowscor)`20 X`09`09`09savemax(dptr,lpos); X`09`09dptr->stop = -1; X`09`09dptr->dmax = NULL; X`09`09dptr->score = 0; X#endif X `7D /* end lpos */ X X#ifdef ALLOCN0 X`09for (tpos=0, dpos = noff+n1-1; tpos < n0; tpos++,dpos--) `7B X`09`09if ((dptr= &diag`5Bdpos%nd`5D)->score>lowscor) savemax(dptr,dpos); X`09`09`7D X#else X`09for (dptr=diag; dptr < dpmax; ) `7B X`09`09if (dptr->score>lowscor) savemax(dptr); X`09`09dptr->stop = -1; X`09`09dptr->dmax = NULL; X`09`09dptr++->score = 0; X`09`09`7D X`09ndo = nd; X#endif X X/* X at this point all of the elements of aa1`5Blpos`5D X have been searched for elements of aa0`5Btpos`5D X with the results in diag`5Bdpos`5D X*/ X`09for (ib= nsave =0,vmptr=vmax; vmptr < &vmax`5BMAXSAV`5D; vmptr++) `7B X#ifdef LFASTA X`09`09if (oneseq && vmptr->start==0 && vmptr->stop==n1-1) continue; X#endif X`09`09if (vmptr->score>0) `7B X`09`09`09vmptr->score=spam(vmptr); X`09`09`09vptr`5Bib++`5D= vmptr; X`09`09`09nsave++; X`09`09`09`7D X`09`09`7D X X`09if (nsave>0) `7B X X#ifndef LFASTA X`09scor = sconn(vptr,nsave); X`09for (vmptr=vptr`5B0`5D,ib=1; ibscore > vmptr->score) vmptr=vptr`5Bib`5D; X X/* `09kssort(vptr,nsave); */ X`09cscor = scor = max(scor,vmptr->score); X`09addhist(scor,vmptr->score); X#else X`09kssort(vptr,nsave); X#endif X`09 X#ifdef LFASTA X`09for (ib=0; ibscore) > optcut) `7B X`09 vmptr=vptr`5Bib`5D; X#else X`09ib=0; X`09if (optall && scor>optcut) `7B X`09 cscor = gscor = dmatch(noff-vmptr->dp,FALSE); X`09 optcount++; X`09`7D X`09else gscor = 0; X X`09if (dataflg) X`09 fprintf(tmpfd,"%-10s %4d %4d %4d %4d %8ld\n", X`09`09 libstr,sfnum,scor,vmptr->score,gscor,lmark); X X`09if (cscor > bestcut) `7B X#endif X`09 if (nbest >= MAXBEST) `7B X`09 bestfull = nbest-MAXBEST/4; X`09 if (!optall) `7B X`09 select(bestfull-1,nbest); X`09 bestcut = bptr`5Bbestfull-1`5D->score; X`09 `7D X`09 else `7B X`09 gselect(bestfull-1,nbest); X`09 bestcut = bptr`5Bbestfull-1`5D->gscore; X`09 `7D X`09 nbest = bestfull; X`09 `7D X`09 bestptr = bptr`5Bnbest`5D; X`09 bestptr->dp = vmptr->dp; X`09 bestptr->start = vmptr->start; X`09 bestptr->stop = vmptr->stop; X`09 bestptr->score0 = vmptr->score; X`09 bestptr->score = scor; X`09 bestptr->gscore = gscor; X`09 bestptr->lseek = lmark; X`09 bestptr->cont = ocont; X`09 bestptr->lib = libfn; X`09 bestptr->frame = itt; X`09 nbest++; X`09`7D X `7D`20 X#ifndef LFASTA X`09else `7B`09/* nsave <= 0 */ X`09 addhist(0,0); X`09 if (dataflg) fprintf(tmpfd,"%-10s %4d %4d %4d %4d %8d\n", X`09`09`09 libstr,sfnum,0,0,0,lmark); X`09`7D X#endif X#ifdef TFASTA X `7D X#endif X Xloop: X`09if (lcont) `7B X#ifndef TFASTA X`09 loff = n0; X`09 memcpy(aa1,&aa1`5Bn1-n0`5D,n0); X`09 aa1ptr= &aa1`5Bloff`5D; X#else X`09 loff = 3*n0; X`09 memcpy(aa10,&aa10`5Bn10-loff`5D,loff); X`09 aa1ptr= &aa10`5Bloff`5D; X`09 maxt = maxn-loff-3; maxt -= maxt%3; maxt++; X#endif X`09 ocont = lcont; X`09`7D X`09else `7B X`09 loff = 0; X#ifndef TFASTA X`09 aa1ptr=aa1; X#else X`09 aa1ptr = aa10; X`09 maxt = maxn-loff-3; maxt -= maxt%3; maxt++; X#endif X`09 ocont = lcont; X`09`7D X `7D X `7D X X#ifdef ALLOCN0 Xsavemax(dptr,dpos) X`09register struct dstruct *dptr; int dpos; X`7B X`09register struct beststr *vmptr; X`09register int i; X X#else Xsavemax(dptr) X`09register struct dstruct *dptr; X`7B X`09register int dpos; X`09register struct beststr *vmptr; X`09register int i; X#ifndef I86BUG X`09dpos = (int)(dptr-diag); X#else X`09dpos = ((unsigned)dptr-(unsigned)diag)>>L2DSTR; X#endif X#endif X/* check to see if this is the continuation of a run that is already saved * V/ X X`09if ((vmptr=dptr->dmax)!=NULL && vmptr->dp== dpos && X`09`09vmptr->start==dptr->start) `7B X`09`09vmptr->stop = dptr->stop; X`09`09if ((i=dptr->score)<=vmptr->score) return; X`09`09vmptr->score = i; X`09`09if (vmptr!=lowmax) return; X`09`09`7D X`09else `7B X`09`09i=lowmax->score = dptr->score; X`09`09lowmax->dp = dpos; X`09`09lowmax->start = dptr->start; X`09`09lowmax->stop = dptr->stop; X`09`09dptr->dmax = lowmax; X`09`09`7D X X`09for (vmptr = vmax; vmptr < &vmax`5BMAXSAV`5D; vmptr++) X`09`09if (vmptr->score < i) `7B X`09`09`09i = vmptr->score; X`09`09`09lowmax = vmptr; X`09`09`09`7D X`09lowscor = i; X`09`7D X`09 Xinitpam2() X`7B X`09int i, j, k; X X`09k=0; X`09for (i=0; istart`5D; X`09aa0p= &aa0`5Blpos - dmax->dp + noff`5D; X`09curv.start = lpos; X X`09tot = curv.score = maxv.score = 0; X`09for ( ; lpos <= dmax->stop; lpos++) `7B X`09`09tot += pam2`5B*aa0p++`5D`5B*aa1p++`5D; X`09`09if (tot > curv.score) `7B X`09`09`09curv.stop = lpos; X`09`09`09curv.score = tot; X`09`09`09`7D X`09`09else if (tot < 0) `7B X`09`09`09if (curv.score > maxv.score) `7B X`09`09`09`09maxv.start = curv.start; X`09`09`09`09maxv.stop = curv.stop; X`09`09`09`09maxv.score = curv.score; X`09`09`09`09`7D X`09`09`09tot = curv.score = 0; X`09`09`09curv.start = lpos; X`09`09`09`7D X`09`09`7D X X`09if (curv.score > maxv.score) `7B X`09`09maxv.start = curv.start; X`09`09maxv.stop = curv.stop; X`09`09maxv.score = curv.score; X`09`09`7D X X/*`09if (maxv.start != dmax->start `7C`7C maxv.stop != dmax->stop) X`09`09printf(" new region: %3d %3d %3d %3d\n",maxv.start, X`09`09`09dmax->start,maxv.stop,dmax->stop); X*/ X`09dmax->start = maxv.start; X`09dmax->stop = maxv.stop; X X`09return maxv.score; X`09`7D X Xsconn(v,n) X`09struct beststr *v`5B`5D; X`09int n; X`7B X`09int i,si,cmpp(); X`09struct slink `7B X`09`09int score; X`09`09struct beststr *vp; X`09`09struct slink *next; X`09`09`7D *start, *sl, *sj, *so, sarr`5BMAXSAV`5D; X`09int lstart, tstart, plstop, ptstop; X X/*`09sort the score left to right in lib pos */ X X`09kpsort(v,n); X X`09start = NULL; X X/*`09for the remaining runs, see if they fit */ X X`09for (i=0,si=0; iscore < cgap) continue; X`09`09lstart=v`5Bi`5D->start; X`09`09tstart=lstart-v`5Bi`5D->dp+noff; X X/*`09put the run in the group */ X`09`09sarr`5Bsi`5D.vp = v`5Bi`5D; X`09`09sarr`5Bsi`5D.score = v`5Bi`5D->score; X`09`09sarr`5Bsi`5D.next = NULL; X X/* `09if it fits, then increase the score */ X`09`09for (sl=start; sl!= NULL; sl = sl->next) `7B X`09`09`09plstop = sl->vp->stop; X`09`09`09ptstop = plstop - sl->vp->dp + noff; X`09`09`09if (plstopscore+v`5Bi`5D->score+pgap; X`09`09`09`09break; X`09`09`09`09`7D X`09`09`09`7D X X/*`09now recalculate where the score fits */ X`09`09if (start==NULL) start= &sarr`5Bsi`5D; X`09`09else for (sj=start, so=NULL; sj!=NULL; sj = sj->next) `7B X`09`09`09if (sarr`5Bsi`5D.score>sj->score) `7B X`09`09`09`09sarr`5Bsi`5D.next = sj; X`09`09`09`09if (so!=NULL) so->next= &sarr`5Bsi`5D; X`09`09`09`09else start= &sarr`5Bsi`5D; X`09`09`09`09break; X`09`09`09`09`7D X`09`09`09so=sj; X`09`09`09`7D X`09`09si++; X`09`09`7D X X`09if (start!=NULL) return (start->score); X`09else return (0); X`09`7D X Xshscore(aa0,n0)`09/* calculate the 100% identical score */ X`09char *aa0; int n0; X`7B X`09int i, sum; X`09for (i=0,sum=0; i' : ' '; X`09`09pch = (i==0) ? '<' : pch; X`09`09hl = hist`5Bi`5D; X`09`09gl = hist0`5Bi`5D; X`09`09fprintf(fd,"%c%3d %5d %5d:", X`09`09`09pch,(i 50) hl = 50; X`09`09if ((gl=(gl+1)/2) > 50) gl = 50; X`09`09if (gl==hl) `7Bfor (j=0; jhl) `7B X`09`09`09`09for (j=0; j1) `7B X`09`09lsd = (lsumsq - (lsum*lsum)/nmean)/(nmean-1); X`09`09lsd = sqrt(lsd); X`09`09lsd0 = (lsumsq0 - (lsum0*lsum0)/nmean)/(nmean-1); X`09`09lsd0 = sqrt(lsd0); X`09`09`7D X`09else lsd = lsd0 = 0.0; X`09if (nmean>0) `7Blmean = lsum/nmean; lmean0 = lsum0/nmean;`7D X`09else lmean = lmean0 = 0.0; X`09if (pamfact) strncpy(hline,"variable pamfact",sizeof(hline)); X`09else sprintf(hline,"fact: %d",fact); X`09fprintf(fd, X`09 "%7ld residues in %5ld sequences\n",ntt,nlib); X`09fprintf(fd," statistics exclude scores greater than %d\n",bigscore); X`09fprintf(fd," mean initn score: %5.1f (%.2f)\n",lmean,lsd); X`09fprintf(fd," mean init1 score: %5.1f (%.2f)\n",lmean0,lsd0); X`09fprintf(fd," %4d scores better than %d saved, ktup: %d, %s\n", X`09`09nbest,bestcut,ktup,hline); X`09if (optall) fprintf(fd, X`09" joining threshold: %d, optimization threshold: %d",cgap,optcut); X`09else fprintf(fd," joining threshold: %d",cgap); X`09 X`09if (dataflg) `7B X`09fprintf(tmpfd,"; statistics exclude scores greater than: %3d\n",bigscore) V; X`09fprintf(tmpfd,"; mean initn score: %5.1f (%.2f)\n",lmean,lsd); X`09fprintf(tmpfd,"; mean init1 score: %5.1f (%.2f)\n",lmean0,lsd0); X `7D X`09fprintf(fd," scan time: "); ptime(fd,tscan-tstart); fprintf(fd,"\n"); X`09fflush(fd); X`09`7D X Xaddhist(score,score0) X`09int score,score0; X`7B X`09double tmp; X`09if (score < bigscore) `7B X`09`09tmp = (double)score; X`09`09lsum += tmp; X`09`09lsumsq += tmp*tmp; X`09`09tmp = (double)score0; X`09`09lsum0 += tmp; X`09`09lsumsq0 += tmp*tmp; X`09`09nmean++; X`09`09`7D X`09score = (score-1)/histint; X`09if (score < 0) score=0; X`09else if (score >= MAXHIST) score = MAXHIST-1; X`09hist`5Bscore`5D++; X`09score0 = (score0-1)/histint; X`09if (score0 < 0) score0=0; X`09else if (score0 >= MAXHIST) score0 = MAXHIST-1; X`09hist0`5Bscore0`5D++; X`09`7D X Xallocdiag(dsize)`09/* allocates diagonal structures */ X`09int dsize; X`7B X`09char *calloc(); X X#ifdef I86BUG X`09if (sizeof(struct dstruct) != (1<lib!=olib) `7B X`09`09`09closelib(); X`09`09`09if (openlib(lbnames`5Bbbp->lib`5D,"\0")<=0) exit(0); X`09`09`09olib=bbp->lib; X`09`09`09`7D X X`09`09RANLIB(bline,55,bbp->lseek); X`09`09if (strlen(bline)==0) `7B X`09`09`09bline`5B0`5D='>'; X`09`09`09strncpy(&bline`5B1`5D,lbnames`5Bbbp->lib`5D,55); X`09`09`09`7D X#ifndef TFASTA X`09 aa1ptr=aa1; X#else X`09 aa1ptr = aa10; X#endif X`09 loff=0; loffset = 0l; lcont=0; X`09 for (ccont=0; ccont<=bbp->cont; ccont++) `7B X#ifndef TFASTA X`09`09n1=GETLIB(aa1ptr,maxn-loff,libstr,&lmark,&lcont); X`09`09if (aa1ptr!=aa1) n1 += n0; X#else X`09`09maxt = maxn-loff-3; maxt -= maxt%3; maxt++; X`09`09n10 = GETLIB(aa1ptr,maxt,libstr,&lmark,&lcont); X`09`09if (aa1ptr!=aa10) n10 += 3*n0; X#endif X`09`09if (lcont>bbp->cont) break; X#ifndef TFASTA X`09`09if (lcont) `7B X`09`09 loff = n0; X`09`09 memcpy(aa1,&aa1`5Bn1-n0`5D,n0); X`09`09 aa1ptr= &aa1`5Bloff`5D; X`09`09 loffset += n1-n0; X`09`09 `7D X`09`09else `7B X`09`09 loff = 0; X`09`09 aa1ptr=aa1; X`09`09 `7D X#else X`09`09if (lcont) `7B X`09`09 loff = 3*n0; X`09`09 memcpy(aa10,&aa10`5Bn10-loff`5D,loff); X`09`09 aa1ptr= &aa10`5Bloff`5D; X`09`09 loffset += n10-loff; X`09`09 maxt = maxn-loff-3; maxt -= maxt%3; maxt++; X`09`09 `7D X`09`09else `7B X`09`09 loff = 0; X`09`09 aa1ptr = aa10; X`09`09 maxt = maxn-loff-3; maxt -= maxt%3; maxt++; X`09`09 `7D X#endif X`09`09`7D X#ifdef TFASTA X`09`09n1 = aatran(aa10,aa1,n10,bbp->frame); X`09`09loffset /= 3; X#endif X`09`09fprintf(outfd,"%-55s",bline); X#ifndef TFASTA X`09`09fprintf(outfd,"%4d %4d %4d\n",bbp->score,bbp->score0, X`09`09`09bbp->gscore); X#else X`09`09fprintf(outfd,"(%1d) %4d %4d %4d\n",bbp->frame+1,bbp->score, X`09`09`09bbp->score0,bbp->gscore); X#endif X`09`09strncpy(name1,bline,6); X`09`09name1`5B6`5D='\0'; X`09`09if ((bp = strchr(name1,' '))!=NULL) *bp = '\0'; X`09`09smark`5B2`5D=bbp->start; X`09`09smark`5B3`5D=bbp->stop; X`09`09smark`5B0`5D=noff+smark`5B2`5D-bbp->dp; X`09`09smark`5B1`5D=noff+smark`5B3`5D-bbp->dp; X`09`09iscore=bbp->score0; X`09`09dmatch(noff-bbp->dp,TRUE); X`09`09fprintf(outfd,"\n"); X`09`09fflush(outfd); X`09`09`7D X`09`7D X#endif X X#ifdef LFASTA Xshowlocal(nshow) X`09int nshow; X`7B X`09int ib, istart, istop; X`09char bline`5B120`5D, *bp, *strchr(); X`09int lcont, olcont, ccont, loff; X`09char *aa1ptr; X`09int olib; X X`09olcont = -1; X X`09istart = 0; istop = nbest; X X`09bbp = bptr`5B0`5D; X X`09for (ib=istart; ibcont!=olcont) `7B X X`09RANLIB(bline,55,bbp->lseek); X`09if (strlen(bline)==0) `7B X`09`09bline`5B0`5D='>'; X`09`09strncpy(&bline`5B1`5D,lbnames`5Bbbp->lib`5D,55); X`09`09`7D X X`09 aa1ptr=aa1; X X`09 loff=0; loffset = 0l; lcont=0; X`09 for (ccont=0; ccont<=bbp->cont; ccont++) `7B X`09`09n1=GETLIB(aa1ptr,maxn-loff,libstr,&lmark,&lcont); X`09`09if (aa1ptr!=aa1) n1 += n0; X`09`09if (lcont>bbp->cont) break; X`09`09if (lcont) `7B X`09`09 loff = n0; X`09`09 memcpy(aa1,&aa1`5Bn1-n0`5D,n0); X`09`09 aa1ptr= &aa1`5Bloff`5D; X`09`09 loffset += n1-n0; X`09`09 `7D X`09`09else `7B X`09`09 loff = 0; X`09`09 aa1ptr=aa1; X`09`09 `7D X`09`09`7D X`09`09olcont = bbp->cont; X`09`09`7D X`09`09strncpy(name1,bline,6); X`09`09name1`5B6`5D='\0'; X`09`09if ((bp = strchr(name1,' '))!=NULL) *bp = '\0'; X`09`09smark`5B2`5D=bbp->start; X`09`09smark`5B3`5D=bbp->stop; X`09`09smark`5B0`5D=noff+smark`5B2`5D-bbp->dp; X`09`09smark`5B1`5D=noff+smark`5B3`5D-bbp->dp; X`09`09iscore=bbp->score0; X#ifndef TPLOT X`09`09if (dmatch(smark`5B1`5D,smark`5B3`5D,TRUE)>=0)`20 X`09`09`09fprintf(outfd,"\n----------\n"); X#else`09`09/* !TPLOT */ X`09`09dmatch(smark`5B1`5D,smark`5B3`5D,FALSE); X#endif`09`09/* TPLOT */ X`09`09`7D X`09`7D X#endif X X#ifdef FAR_PTR X#ifdef M_XENIX X#include X#else X#ifdef TURBOC X#define FMALLOC farmalloc X#define MTYPE long X#define FFREE farfree X#else X#define FMALLOC _fmalloc X#define MTYPE unsigned X#define FFREE _ffree X#endif X#endif X#endif X Xinitbest(nbest)`09`09/* allocate arrays for best sort */ X`09int nbest; X`7B X#ifndef FAR_PTR X`09char *calloc(); X`09if ((best=(struct beststr *)calloc(nbest,sizeof(struct beststr))) X`09`09== NULL) `7Bfprintf(stderr,"cannot allocate best struct\n"); exit(1);` V7D X`09if ((bptr=(struct beststr **)calloc(nbest,sizeof(struct beststr *))) X`09`09== NULL) `7Bfprintf(stderr,"cannot allocate bptr\n"); exit(1);`7D X#else`09/* FAR_PTR */ X#ifndef M_XENIX X`09char far * FMALLOC(); X`09if ((best=(struct beststr far *) X`09 FMALLOC((MTYPE)(nbest*sizeof(struct beststr)))) X`09`09== (char far *)0) `7B X`09`09fprintf(stderr,"cannot allocate best struct\n"); exit(1);`7D X`09if ((bptr=(struct beststr far * far *) X`09 FMALLOC((MTYPE)(nbest*sizeof(struct beststr far *)))) X`09`09== (char far * far *)0) `7Bfprintf(stderr,"cannot allocate bptr\n"); e Vxit(1);`7D X#else`09/* M_XENIX */`09`09 X`09char far * brkctl(); X`09if ((best=(struct beststr far *) X`09 brkctl(BR_NEWSEG,(long)((unsigned)nbest*(unsigned)sizeof(struct bests Vtr)))) X`09`09== (struct beststr far *)-1) `7Bfprintf(stderr,"cannot allocate best s Vtruct\n"); exit(1);`7D X`09if ((bptr=(struct beststr far * far *) X`09 brkctl(BR_NEWSEG,(long)(nbest*sizeof(struct beststr far *)))) X`09`09== (struct beststr far * far *)-1) `7Bfprintf(stderr,"cannot allocate V bptr\n"); exit(1);`7D X#endif`09/* M_XENIX */ X#endif`09/* FAR_PTR */ X`09`7D X Xfreebest() X`7B X#ifndef BIGMEM X#ifndef FAR_PTR X`09free(bptr); X`09free(best); X#else`09/* FAR_PTR */ X#ifndef M_XENIX X`09FFREE(bptr); X`09FFREE(best); X#else`09/* M_XENIX */ X`09brkctl(BR_ARGSEG,(long)(-(unsigned)nbest*(unsigned)sizeof(struct beststr V far *)),bptr); X`09brkctl(BR_IMPSEG,0L,bptr); X`09brkctl(BR_ARGSEG,(long)(-nbest*sizeof(struct beststr)),best); X`09brkctl(BR_IMPSEG,0L,best); X#endif`09/* M_XENIX */ X#endif`09/* FAR_PTR */ X#endif`09/* BIGMEM */ X`09`7D X Xgetbest() X`7B X`09`7D X X#ifndef LFASTA Xshowbest() X`7B X`09int ib, istart, istop; X`09char bline`5B120`5D; X`09int ntmp; X`09int lcont, ccont, loff; X`09char *aa1ptr; X`09int olib; X`09int hcutoff; X#ifdef TFASTA X`09int n10; X#endif X X`09if (nshow <= 0) return; X X`09hcutoff = 6*(MAXHIST-1)*histint; X`09hcutoff /= 10; X`09olib = -1; X X`09nshow = min(nshow,nbest); X`09mshow = min(mshow,nbest); X`09if (outtty) `7B X`09`09printf(" How many scores would you like to see? `5B%d`5D ",nshow); X`09`09fflush(stdout); X`09`09if (fgets(rline,20,stdin)==NULL) exit(0); X`09`09if (rline`5B0`5D!='\n' && rline`5B0`5D!=0) sscanf(rline,"%d",&nshow); X`09`09if (nshow<=0) nshow = min(20,nbest); X`09`09`7D X`09else nshow=mshow; X X#ifndef TFASTA X`09fprintf(outfd,"The best scores are:\t\t\t\t initn init1 opt\n"); X#else X `09fprintf(outfd,"The best scores are:\t\t\t\t\t initn init1 opt\n"); X#endif X`09if (outfd != stdout) X#ifndef TFASTA X`09 fprintf(stdout,"The best scores are:\t\t\t\t initn init1 opt\n") V; X#else X`09 fprintf(stdout,"The best scores are:\t\t\t\t\t initn init1 opt\n"); X#endif X`09istart = 0; Xl1:`09istop = min(nbest,nshow); X`09for (ib=istart; iblib!=olib) `7B X`09`09`09closelib(); X`09`09`09if (openlib(lbnames`5Bbbp->lib`5D,"\0")<=0) exit(0); X`09`09`09olib=bbp->lib; X`09`09`09`7D X X`09`09RANLIB(bline,60,bbp->lseek); X`09`09bline`5B54`5D='\0'; X X#ifndef TFASTA X`09 aa1ptr=aa1; X#else X`09 aa1ptr = aa10; X#endif X`09 loff=0; lcont=0; X`09 for (ccont=0; ccont <= bbp->cont; ccont++) `7B X#ifndef TFASTA X`09`09n1=GETLIB(aa1ptr,maxn-loff,libstr,&lmark,&lcont); X`09`09if (aa1ptr!=aa1) n1 += n0; X#else X`09`09maxt = maxn-loff-3; maxt -= maxt%3; maxt++; X`09`09n10=GETLIB(aa1ptr,maxt,libstr,&lmark,&lcont); X`09`09if (aa1ptr!=aa10) n10 += 3*n0; X#endif X`09`09if (lcont>bbp->cont) break; X#ifndef TFASTA X`09`09if (lcont) `7B X`09`09 loff = n0; X`09`09 memcpy(aa1,&aa1`5Bn1-n0`5D,n0); X`09`09 aa1ptr= &aa1`5Bloff`5D; X`09`09 `7D X`09`09else `7B X`09`09 loff = 0; X`09`09 aa1ptr=aa1; X`09`09 `7D X#else X`09`09if (lcont) `7B X`09`09 loff = 3*n0; X`09`09 memcpy(aa10,&aa10`5Bn10-loff`5D,loff); X`09`09 aa1ptr= &aa10`5Bloff`5D; X`09`09 maxt = maxn-loff-3; maxt -= maxt%3; maxt++; X`09`09 `7D X`09`09else `7B X`09`09 aa1ptr=aa10; X`09`09 loff = 0; X`09`09 maxt = maxn-loff-3; maxt -= maxt%3; maxt++; X`09`09 `7D X#endif X`09`09`7D X X#ifdef TFASTA X`09`09n1=aatran(aa10,aa1,n10,bbp->frame); X#endif X`09`09bbp->gscore=dmatch(noff-bbp->dp,FALSE); X X`09`09fprintf(outfd,"%-55s",bline); X#ifndef TFASTA X`09`09fprintf(outfd,"%4d %4d %4d\n",bbp->score,bbp->score0, X`09`09`09bbp->gscore); X#else X `09`09fprintf(outfd,"(%1d) %4d %4d %4d\n",bbp->frame+1,bbp->score, X `09`09`09bbp->score0,bbp->gscore); X#endif X X`09`09if (outfd!=stdout) `7B X`09`09 fprintf(stdout,"%-55s",bline); X#ifndef TFASTA X`09`09 fprintf(stdout,"%4d %4d %4d\n",bbp->score,bbp->score0, X`09`09`09bbp->gscore); X#else X `09`09fprintf(stdout,"(%1d) %4d %4d %4d\n",bbp->frame+1,bbp->score, X `09`09`09bbp->score0,bbp->gscore); X#endif X`09`09 `7D X`09`09`7D X X`09fflush(outfd); if (outfd!=stdout) fflush(stdout); X X`09if (outtty) `7B X`09`09printf(" More scores? `5B0`5D "); X`09`09fflush(stdout); X`09`09if (fgets(rline,20,stdin)==NULL) exit(0); X`09`09ntmp = 0; X`09`09if (rline`5B0`5D!='\n' && rline`5B0`5D!=0) sscanf(rline,"%d",&ntmp); X`09`09if (ntmp<=0) ntmp = 0; X`09`09if (ntmp>0) `7B X`09`09`09istart = istop; X`09`09`09nshow += ntmp; X`09`09`09mshow += ntmp; X`09`09`09goto l1; X`09`09`09`7D X`09`09`7D X`09else if ((bbp->score > (2*hcutoff)) `7C`7C X`09`09(bbp->score > hcutoff && bbp->gscore > (4*bbp->score/3))) `7B X`09`09istart=istop; X`09`09nshow += 10; X`09`09if (istart l ) `7B X i = l-1; X j = r; X v = bptr`5Br`5D->score; X do `7B X while (bptr`5B++i`5D->score > v ) ; X while (bptr`5B--j`5D->score < v ) ; X tmptr = bptr`5Bi`5D; bptr`5Bi`5D=bptr`5Bj`5D; bptr`5Bj`5D=tmptr; X `7D while (j > i); X bptr`5Bj`5D=bptr`5Bi`5D; bptr`5Bi`5D=bptr`5Br`5D; bptr`5Br`5D=tmptr; X if (i>=k) r = i-1; X if (i<=k) l = i+1; X `7D X`7D X Xgselect(k,n)`09/* k is rank in array */ X int k,n; X`7B X int v, t, i, j, l, r; X#ifndef FAR_PTR X struct beststr *tmptr; X#else X struct beststr far * tmptr; X#endif X X l=0; r=n-1; X X while ( r > l ) `7B X i = l-1; X j = r; X v = bptr`5Br`5D->gscore; X do `7B X while (bptr`5B++i`5D->gscore > v ) ; X while (bptr`5B--j`5D->gscore < v ) ; X tmptr = bptr`5Bi`5D; bptr`5Bi`5D=bptr`5Bj`5D; bptr`5Bj`5D=tmptr; X `7D while (j > i); X bptr`5Bj`5D=bptr`5Bi`5D; bptr`5Bi`5D=bptr`5Br`5D; bptr`5Br`5D=tmptr; X if (i>=k) r = i-1; X if (i<=k) l = i+1; X `7D X`7D X Xsortbest() X`7B X#ifndef FAR_PTR X`09int cmps(), cmp1(), cmpa(); X`09if (init1flg) ksort(bptr,nbest,cmp1); X`09else if (optall) ksort(bptr,nbest,cmpa); X`09else ksort(bptr,nbest,cmps); X#else X`09int fcmps(), fcmp1(), fcmpa(); X`09if (init1flg) fksort(bptr,nbest,fcmp1); X`09else if (optall) fksort(bptr,nbest,fcmpa); X`09else fksort(bptr,nbest,fcmps); X#endif X`09`7D X Xcmps(ptr1,ptr2) X`09struct beststr *ptr1, *ptr2; X`7B X`09if (ptr1->score < ptr2->score) return (1); X`09else if (ptr1->score > ptr2->score) return (-1); X`09else return (0); X`09`7D X Xcmpa(ptr1,ptr2) X`09struct beststr *ptr1, *ptr2; X`7B X`09if (ptr1->gscore < ptr2->gscore) return (1); X`09else if (ptr1->gscore > ptr2->gscore) return (-1); X`09else return (0); X`09`7D X Xcmp1(ptr1,ptr2) X`09struct beststr *ptr1, *ptr2; X`7B X`09if (ptr1->score0 < ptr2->score0) return (1); X`09else if (ptr1->score0 > ptr2->score0) return (-1); X`09else return (0); X`09`7D X X#ifdef FAR_PTR Xfcmps(ptr1,ptr2) X`09struct beststr far * ptr1, far * ptr2; X`7B X`09if (ptr1->score < ptr2->score) return (1); X`09else if (ptr1->score > ptr2->score) return (-1); X`09else return (0); X`09`7D X Xfcmp1(ptr1,ptr2) X`09struct beststr far * ptr1, far * ptr2; X`7B X`09if (ptr1->score0 < ptr2->score0) return (1); X`09else if (ptr1->score0 > ptr2->score0) return (-1); X`09else return (0); X`09`7D X Xfcmpa(ptr1,ptr2) X`09struct beststr far * ptr1, far * ptr2; X`7B X`09if (ptr1->gscore < ptr2->gscore) return (1); X`09else if (ptr1->gscore > ptr2->gscore) return (-1); X`09else return (0); X`09`7D X#endif X Xcmpp(ptr1,ptr2) X`09struct beststr *ptr1, *ptr2; X`7B X`09if (ptr1->start < ptr2->start) return (-1); X`09else if (ptr1->start > ptr2->start) return (1); X`09else return (0); X`09`7D X Xkssort(v,n) X`09struct beststr *v`5B`5D; int n; X`7B X`09int gap, i, j; X`09struct beststr *tmp; X`09 X`09for (gap=n/2; gap>0; gap/=2) X`09`09for (i=gap; i=0; j -= gap) `7B X`09`09`09`09if (v`5Bj`5D->score >= v`5Bj+gap`5D->score) X`09`09`09`09`09break; X`09`09`09`09tmp = v`5Bj`5D; v`5Bj`5D=v`5Bj+gap`5D; v`5Bj+gap`5D=tmp; X`09`09`09`09`7D X`09`7D X Xkpsort(v,n) X`09struct beststr *v`5B`5D; int n; X`7B X`09int gap, i, j; X`09struct beststr *tmp; X`09 X`09for (gap=n/2; gap>0; gap/=2) X`09`09for (i=gap; i=0; j -= gap) `7B X`09`09`09`09if (v`5Bj`5D->start <= v`5Bj+gap`5D->start) X`09`09`09`09`09break; X`09`09`09`09tmp = v`5Bj`5D; v`5Bj`5D=v`5Bj+gap`5D; v`5Bj+gap`5D=tmp; X`09`09`09`09`7D X`09`7D X X Xksort(v,n,comp) X`09char *v`5B`5D; int n, (*comp)(); X`7B X`09int gap, i, j; X`09char *tmp; X`09 X`09for (gap=n/2; gap>0; gap/=2) X`09`09for (i=gap; i=0; j -= gap) `7B X`09`09`09`09if ((*comp)(v`5Bj`5D,v`5Bj+gap`5D) <=0) X`09`09`09`09`09break; X`09`09`09`09tmp = v`5Bj`5D; v`5Bj`5D=v`5Bj+gap`5D; v`5Bj+gap`5D=tmp; X`09`09`09`09`7D X`09`7D X X#ifdef FAR_PTR Xfksort(v,n,comp) X`09char far * far *v; X`09int n, (*comp)(); X`7B X`09int gap, i, j; X`09char far *tmp; X`09 X`09for (gap=n/2; gap>0; gap/=2) X`09`09for (i=gap; i=0; j -= gap) `7B X`09`09`09`09if ((*comp)(v`5Bj`5D,v`5Bj+gap`5D) <=0) X`09`09`09`09`09break; X`09`09`09`09tmp = v`5Bj`5D; v`5Bj`5D=v`5Bj+gap`5D; v`5Bj+gap`5D=tmp; X`09`09`09`09`7D X`09`7D X X#endif X Xgetlnames(tname)`09`09/* read in the library names */ X`09char *tname; X`7B X`09int i; X`09char *calloc(), *bp, *strchr(); X`09char lline`5B120`5D; X`09FILE *tptr; X X`09if (*tname != '@') `7Baddfile(tname,"\0"); return;`7D X`09else tname++; X X`09if ((bp=strchr(tname,' '))!=NULL) `7B X`09`09 *bp='\0'; X#ifndef LFASTA X`09`09 sscanf(bp+1,"%d",&deftype); X`09`09 if (deftype<0 `7C`7C deftype>BINARYGB) `7B X`09`09`09fprintf(stderr," default type error %d\n",deftype); X`09`09`09deftype=0; X`09`09 `7D X#endif`09`09 X`09`09 `7D X X`09if ((tptr=fopen(tname,"r"))==NULL) `7B X`09`09fprintf(stderr," could not open file of names: %s\n",tname); X`09`09return 0; X`09`09`7D X X`09while (fgets(lline,sizeof(lline),tptr)!=NULL) `7B X`09`09if (lline`5B0`5D==';') continue; X`09`09if ((bp=strchr(lline,'\n'))!=NULL) *bp='\0'; X`09`09if (lline`5B0`5D=='>') `7B X`09`09`09strncpy(iname,&lline`5B1`5D,sizeof(iname)); X`09`09`09iname`5Bsizeof(iname)-1`5D='\0'; X#ifndef LFASTA X`09`09`09if (deftype==0) deftype=BINARYGB; X#endif X`09`09`09gbflag=1; X`09`09 `7D X`09`09else if (lline`5B0`5D=='<') `7B X`09`09 if (ldname`5B0`5D!='\0' && strcmp(ldname,lline+1)!=0)`20 X`09`09 fprintf(stderr, X`09`09`09 " changing default directory name from %s to %s\n", X`09`09`09 ldname,lline+1); X`09`09`09strncpy(ldname,&lline`5B1`5D,sizeof(ldname)); X`09`09`09ldname`5Bsizeof(iname)-1`5D='\0'; X`09`09`09libenv=ldname; X`09`09`09`7D X`09`09else addfile(lline,libenv); X`09 `7D X`09fclose(tptr); X`09return 1; X`7D X X/*`09modified Dec 13, 1989 requires different FASTLIBS */ X X#define MAXCHFIL 80 X#define MAXCH 20 X Xlibchoice(lname,nl,aaenv) X`09char *lname, *aaenv; X`09int nl; X`7B X`09char tolower(); X`09FILE *fch; X`09char line`5B120`5D, *bp, *strchr(); X`09char *chstr`5BMAXCH`5D,*chfile`5BMAXCH`5D; X`09char *calloc(), *chtmp, *charr; X`09int i,j,k,chlen; X X`09charr = NULL; X`09if (strlen(flstr)>0) `7B X`09`09chlen = MAXCH*MAXCHFIL; X`09`09if ((chtmp=charr=calloc(chlen,sizeof(char)))==NULL) `7B X`09`09`09fprintf(stderr,"cannot allocate choice file array\n"); X`09`09`09goto l1; X`09`09`09`7D X`09`09chlen--; X`09`09if ((fch=fopen(flstr,"r"))==NULL) `7B X`09`09`09fprintf(stderr," cannot open choice file: %s\n",flstr); X`09`09`09goto l1; X`09`09`09`7D X`09`09fprintf(stderr,"\n Choose sequence library:\n\n"); X X`09`09for (i=j=0; j<20; i++) `7B X`09`09`09if (fgets(line,sizeof(line),fch)==NULL) break; X`09`09`09if (line`5B0`5D==';') continue; X`09`09`09if ((bp=strchr(line,'\n'))!=NULL) *bp='\0'; X`09`09`09if ((bp=strchr(line,'$'))==NULL) continue; X`09`09`09*bp++='\0'; X`09`09`09if ((*bp++ -'0')!=ldnaseq) continue; X`09`09`09if ((k=strlen(line))>chlen) break; X`09`09`09strncpy(chstr`5Bj`5D=chtmp,line,chlen); X`09`09`09chtmp += k+1; chlen -= k+1; X`09`09`09if ((k=strlen(bp))>chlen) break; X`09`09`09strncpy(chfile`5Bj`5D=chtmp,bp,chlen); X`09`09`09chtmp += k+1; chlen -= k+1; X`09`09`09fprintf(stderr," %c: %s\n",*chfile`5Bj++`5D,line); X`09`09`09`7D Xl2: fprintf(stderr,"\n Enter library filename (e.g. %s), letter (e.g. P)\n" V, X`09`09`09(ldnaseq==0)? "prot.lib" : "dna.lib"); X fprintf(stderr," or a %% followed by a list of letters (e.g. %%PN): "); X`09`09fflush(stderr); X`09`09if (fgets(line,sizeof(line),stdin)==NULL) exit(0); X`09`09if ((bp=strchr(line,'\n'))!=NULL) *bp='\0'; X`09`09if (strlen(line)==0) goto l2; X`09`09strncpy(lname,line,nl); X`09`09`7D X `09else `7B Xl1:`09`09fprintf(stderr," library file name: `5B%s`5D",aaenv); X`09`09fflush(stderr); X`09`09if (fgets(line,sizeof(line),stdin)==NULL) exit(0); X`09`09if ((bp=strchr(line,'\n'))!=NULL) *bp='\0'; X`09`09if (strlen(line)>0) strncpy(lname,line,nl); X`09`09else strncpy(lname,aaenv,nl); X`09`09`7D X`09if (charr!=NULL) `7B X`09`09fclose(fch); X`09`09free(charr); X`09`09`7D X`09`7D X X Xlibselect(lname) X`09char *lname; X`7B X`09char tolower(); X`09char line`5B120`5D, *bp, *strchr(), *ulindex(); X`09FILE *fch; X`09int i; X X`09if (strlen(lname)>1 && *lname != '%') getlnames(lname); X`09else `7B X`09 if (*lname=='%') lname++; X`09 if (strlen(flstr)>0) `7B X`09 if ((fch=fopen(flstr,"r"))==NULL) `7B X`09 fprintf(stderr," cannot open choice file: %s\n",flstr); X`09 return; X`09 `7D X`09 `7D X`09 else addfile(lname,"\0"); X X`09 while (fgets(line,sizeof(line),fch)!=NULL) `7B`20 X`09 if (line`5B0`5D==';') continue; X`09 if ((bp=strchr(line,'\n'))!=NULL) *bp='\0'; X`09 if ((bp=strchr(line,'$'))==NULL) continue; X`09 *bp++='\0'; X`09 if ((*bp++ -'0')!=ldnaseq) continue; X`09 if (ulindex(lname,*bp)!=NULL) `7B X`09 strncpy(ltitle,line,sizeof(ltitle)); X`09 getlnames(bp+1); X`09 `7D X`09 `7D X`09 fclose(fch); X`09`7D X `7D X Xchar *lbptr; Xint nnsize; X Xaddfile(fname,env) X char *fname, *env; X`7B X char tname`5B120`5D; X char *calloc(); X int len, lenv, i; X X/* allocate some space for file names */ X if (lbnarr==NULL) `7B X if ((lbnarr=calloc(MAXLF*MAXLN,sizeof(char)))==NULL) `7B X`09fprintf(stderr," could not allocate name table\n"); X`09exit(1); X`09`7D X X nln = 0; X nnsize = MAXLF*MAXLN; X lbptr = lbnarr; X `7D X X lenv = strlen(env)+1; X len=strlen(fname)+1+lenv; X if (nnsize > sizeof(tname)) `7B X if (lenv > 1 && *fname != '#') `7B X strncpy(tname,env,sizeof(tname)); X#ifdef UNIX X strcat(tname,"/"); X#endif X `7D X else tname`5B0`5D='\0'; X strncat(tname,fname,sizeof(tname)-strlen(tname)-1); X len=strlen(tname)+1; X strncpy(lbptr,tname,nnsize); X `7D X else fprintf(stderr,"no more space for filenames: %s ignored\n",fname); X if (nln< MAXLF) lbnames`5Bnln++`5D=lbptr; X else fprintf(stderr," no more file name slots: %s ignored\n",lbptr); X lbptr += len; X nnsize -= len; X`7D X Xchar tolower(a) X char a; X`7B X if (a>='A' && a<='Z') return a + ('a'-'A'); X else return a; X`7D X Xchar *ulindex(str,chr) X char *str, chr; X`7B X char c; X`20 X c = tolower(chr); X X while (*str != '\0' && tolower(*str) !=c ) str++; X if (*str=='\0') return NULL; X else return str; X`7D $ CALL UNPACK FFFASTA.C;1 1735045582 $ create 'f' X/*`09fgetgb.c read a sequence from a compressed floppy disk X`09format genbank library X X`09written by William R. Pearson, placed in the public domain X*/ X X#ifdef MACLSC Xextern char prompt`5B`5D; X#include Xextern SFReply freply; Xextern int glvRef,anvRef, sqvRef, ouvRef; X#endif X X#include X X#define TRUE 1 X#define FALSE 0 X X#define NA 124 X#define EL 125 X#define ES 126 X X#define EOSEQ 127 X#define MAXSQ 32 X X#include "genbank.h" X X#define MAXR 15 Xint lascii`5B`5D = `7BES, 0, 1, 7, X`09`09 2, 5, 9,13, X`09`09 3, 8, 6,12, X`09`0910,11,14,15`7D; X X#define LAMASK 15 X X#ifdef MACLSC X#include X#else X#include X#endif X X#ifndef O_RAW X#ifdef O_BINARY X#define O_RAW O_BINARY X#else X#define O_RAW 0 X#endif X#endif X Xint libfd= -1; Xlong lpos; X X Xstruct slibhdr libhdr; Xstruct seqhdr namrec; Xchar seqrec`5BSQRLEN`5D; Xint jsave, recsav; X Xopenlib(lname,libenv) X`09char *lname, *libenv; X`7B X`09char rline`5B10`5D; X`09char libname`5B120`5D; X`09int wcnt, i; X X`09if (strlen(libenv)>0) `7B X`09`09strncpy(libname,libenv,120); X#ifdef UNIX X`09`09strncat(libname,"/",120); X#endif X`09`09strncat(libname,lname,120-strlen(libenv)); X`09`09`7D X`09else strncpy(libname,lname,120); X X`09wcnt=0; X#ifndef MACLSC Xl1:`09if ((libfd=open(libname,O_RDONLY+O_RAW))==-1) `7B X`09`09rline`5B0`5D='\0'; X`09`09fprintf(stderr," cannot open %s library\n",libname); X#ifdef MSDOS X`09`09fprintf(stderr," insert another disk or type Y to skip "); X#else X`09`09fprintf(stderr," library filename: to skip: "); X#endif X`09`09fflush(stderr); X`09`09fgets(rline,10,stdin); X#ifdef MSDOS X`09`09if (toupper(rline`5B0`5D)=='Y') return 0; X#else X`09`09if (libname`5Bi=strlen(libname)-1`5D=='\n') libname`5Bi`5D='\0'; X`09`09if (libname`5B0`5D=='\0') return 0; X#endif X`09`09if (++wcnt > 10) return 0; X`09`09goto l1; X`09`09`7D X#else X`09SetVol("\p",sqvRef); Xl1:`09if ((libfd=open(libname,O_RDONLY+O_RAW))==-1) `7B X`09`09rline`5B0`5D='\0'; X`09`09sprintf(prompt," cannot open %s\r Select library filename",libname); X`09`09FileDlog(prompt,&freply); X`09`09if (freply.good==TRUE) `7B`09 X`09`09`09PtoCstr(freply.fName); X`09`09`09strcpy(libname,freply.fName); X`09`09`09sqvRef=anvRef=freply.vRefNum; X`09`09`09SetVol("\p\0",sqvRef); X`09`09`09goto l1; X`09`09`09`7D X`09`09else return -1; X`09`09`7D X#endif X`09if (read(libfd,(char *)&libhdr,sizeof(libhdr))==-1) `7B X`09`09fprintf(" could not read %s library\n",libname); X`09`09fflush(stderr); X`09`09return -1; X`09`09`7D X X`09return 1; X`09`7D X Xcloselib() X`7B X`09if (libfd>0) `7B X`09`09close(libfd); X`09`09libfd = -1; X`09`09`7D X`09`7D X Xgetlib(seq,maxs,libstr,libpos,lcont) X`09char *seq; X`09int maxs; X`09char *libstr; X`09long *libpos; X`09int *lcont; X`7B X`09int i, j, m, n; X`09int arec, nrec, rrec, trec; X`09register int *lap; X`09register char *sptr, *tptr; X`09char *ttptr; X`09int mc2, tmp; X`09char sname`5B11`5D; X`09long lseek(); X X`09sptr = seq; X`09lap = lascii; X X`09if (*lcont==0) `7B X`09`09*libpos = lseek(libfd,0L,1); X`09`09if (read(libfd,(char *)&namrec,sizeof(namrec))==0) return 0; X`09`09recsav = namrec.rcnt`5B0`5D + (namrec.rcnt`5B1`5D<<8) - 1; X`09`09for (j=0; j<11; j++)`20 X`09`09`09if (!(*sptr++ = namrec.seqstart`5Bj`5D)) goto done; X`09`09maxs -= 22; X`09`09strncpy(sname,namrec.seqnam,10); X`09`09sname`5B10`5D='\0'; X`09`09strncpy(libstr,sname,20); X`09`09libstr`5B10`5D='\0'; X`09`09`7D X X`09arec = (maxs-2)/(2*SQRLEN); X`09rrec = min(arec,recsav); X`09if (rrec>0 X`09 && (trec=read(libfd,(char *)sptr,rrec*SQRLEN))!=rrec*SQRLEN) X`09`09goto error; X`09if (rrec == recsav) *lcont=0; X`09else `7B(*lcont)++; recsav -= rrec;`7D X X`09sptr += rrec*SQRLEN; X Xdone: X`09tptr = ttptr = seq + 2*(int)(sptr - seq); X`09while (sptr>seq) `7B X`09`09*--tptr = lap`5B*--sptr&LAMASK`5D; X`09`09*--tptr = lap`5B(*sptr>>4)&LAMASK`5D; X`09`09`7D X X`09tptr = ttptr; X`09while (*--tptr>MAXR); X`09n = (int)(tptr-seq)+1; X`09seq`5Bn`5D= EOSEQ; X`09return (n); X Xerror:`09fprintf(stderr," error reading %10s %4d %4d %4d\n",sname,trec,rrec* VSQRLEN,SQRLEN); X`09fflush(stderr); X`09return (-1); X`09`7D X Xextern int ixstat; X Xranlib(str,cnt,seek) X`09char *str; int cnt; X`09long seek; X`7B X`09int ctmp; X`09long lseek(); X`09if (ixstat>0) `7B X`09`09lseek(libfd,seek,0); X`09`09if (read(libfd,(char *)&namrec,sizeof(namrec))==0) return 0; X`09`09strncpy(str,namrec.seqnam,10); X`09`09str`5B10`5D='\0'; X`09`09ctmp=cnt-10; X`09`09idxann(str,&str`5B10`5D,ctmp); X`09`09`7D X`09else if (ixstat==0) str`5B0`5D='\0'; X X`09lseek(libfd,seek,0); X`09`7D X $ CALL UNPACK FGETGB.C;1 1125256272 $ create 'f' X#define TRUE 1 X#define FALSE 0 X`20 X#define MAXLINE 128 X X#define MAXWORDS 10 X#define MAXCHARS 100 X Xchar ignore; Xchar filename`5B40`5D; XFILE *fbuf; X Xint numwrds,numchars; Xint numlets; Xchar *nextbyte;`09`09/* pointer to position in wordarr for next char */ Xchar *wordarr;`09`09/* wordarr`5BMAXCHARS`5D holds the patterns */ X Xchar *ascarr;`09`09/* the mapper from letter to subset */ X Xchar **wordptr;`09`09/* points to each word */ Xint nextwrd;`09`09/* index into wordptr`5B`5D next empty word - # of words * V/ X X#define MAXSTATE 100 Xint **tabarr;`09`09/* holds the state table */ Xint mstate; Xint *backptr; Xchar **bword; X Xstruct queue `7B X`09char *current; X`09char *name; X`09int qstate; X`09`7D *squeue, *qptr; X Xint head, tail, qlength; $ CALL UNPACK FIND.GBL;1 1460165830 $ create 'f' X/*`09find.c`09`0928-Apr-83 X X`09uses finite state machine to search a file for a group of X`09strings X X`09copyright (c) 1983 William R. Pearson X X*/ X X#include X#include X X#include "find.gbl" Xchar *libenv; X Xmain (argc,argv) X`09int argc; char *argv`5B`5D; X`7B X`09int ic,i; X`09char *getenv(), fline`5B40`5D; X`09FILE *fdn; X X`09if ((libenv=getenv("GBLIB"))==NULL) libenv="\0"; X X`09if (argc<3) `7B X`09`09printf(" usage - find inputfile `5B-l`5D str1 str2 str3\n"); X`09`09printf("\t or - find inputfile `5B-l`5D @strfile\n"); X`09`09return (-1);`7D X X`09initgbls(); X`09allocgbls(); X X`09ignore = TRUE; X`09for (ic = 1; ic < argc; ic++) `7B X`09`09if (*argv`5Bic`5D=='-'&& tolower(argv`5Bic`5D`5B1`5D)=='l') `7B X`09`09`09ignore = FALSE; X`09`09`09`7D X`09`09else if (!filename`5B0`5D) strncpy(filename,argv`5Bic`5D,40); X`09`09else if (*argv`5Bic`5D == '@') getfile(&argv`5Bic`5D`5B1`5D); X`09`09else install(argv`5Bic`5D); X`09`09`7D X X`09numwrds = nextwrd; X X`09numlets = packlets(); X X`09allocstat(); X`09initqueue(numwrds+2);`09/* +2 to make room for slop and tail=head */ X X`09trie(); X X`09allocback(mstate); X`09clean(); X X`09if (filename`5B0`5D!='@') `7B X`09`09if (openann(filename,libenv)<=0) `7B X`09`09`09printf(" could not open %s library\n",filename); X`09`09`09exit(1); X`09`09`09`7D X`09`09scan();`09/* do the hash through the library */ X`09`09`7D X`09else `7B X`09`09if ((fdn=fopen(&filename`5B1`5D,"r"))==0) `7B X`09`09 printf(" cannot open file of file names %s\n",filename); X`09`09 exit(-1); X`09`09 `7D X X`09`09while (fgets(fline,40,fdn)) `7B X`09`09`09if (fline`5Bi=strlen(fline)-1`5D=='\n') fline`5Bi`5D=0; X`09`09`09if (fline`5B0`5D=='>' `7C`7C fline`5B0`5D=='<') continue; X`09`09`09openann(fline,libenv); X`09`09`09scan(); X`09`09`09closeann(); X`09`09`09`7D X`09`09fclose(fdn); X`09`09`7D X`09`7D X Xinitgbls() X`7B X`09numwrds = 0; X`09`7D X Xallocgbls() X`7B X`09char *calloc(); X X`09if ((wordarr=calloc(MAXCHARS,sizeof(char)))==NULL) `7B X`09`09printf(" cannot allocate word array\n"); X`09`09exit(); X`09`09`7D X`09nextbyte = wordarr; X X`09if ((ascarr=(char *)calloc(128,sizeof(char)))==NULL) `7B X`09`09printf(" cannot allocate ascii array\n"); X`09`09exit(); X`09`09`7D X X`09if ((wordptr=(char **)calloc(MAXWORDS,sizeof(char *)))==NULL) `7B X`09`09printf(" cannot allocate word pointers\n"); X`09`09exit(); X`09`09`7D X`09`7D`09 X Xinstall(word) X`09char *word; X`7B X`09wordptr`5Bnextwrd++`5D = nextbyte; X`09while (*word) *nextbyte++ = *word++; X`09*nextbyte++ = NULL; X`09`7D X Xgetfile(fname) X`09char *fname; X`7B X`09char fline`5BMAXLINE`5D; X`09char fword`5BMAXLINE`5D; X`09int iw,i; X X`09if ((fbuf=fopen(fname,"r"))==0) `7B X`09`09printf(" cannot open pattern file %s\n",fname); X`09`09exit(); X`09`09`7D X`09while (fgets(fline,MAXLINE,fbuf)) `7B X`09`09if (fline`5Bi=strlen(fline)-1`5D=='\n') fline`5Bi`5D=0; X`09`09install(fline); X`09`09`7D X X`09fclose(fbuf); X`09`7D X Xpacklets()`09/* scan all of the words looking for different letters */ X`7B X`09int ia, il; X`09char *ic; X X`09for (ia = 0; ia <128; ia++) ascarr`5Bia`5D = 0; X X`09for (ic = wordarr, ia=0; ic < nextbyte; ic++,ia++) X`09`09`09if (*ic) ascarr`5B*ic`5D = 1; X X`09if (ignore) for (ia = 'a'; ia <= 'z'; ia++) X`09`09if (ascarr`5Bia`5D) `7B X`09`09`09ascarr`5Btoupper(ia)`5D=1; X`09`09`09ascarr`5Bia`5D=0; X`09`09`09`7D X X`09for (ia = 1, il = 1; ia < 127; ia++) X`09`09if (ascarr`5Bia`5D)`09ascarr`5Bia`5D = il++; X X`09if (ignore) for (ia='a'; ia<='z'; ia++) X`09`09ascarr`5Bia`5D=ascarr`5Btoupper(ia)`5D; X`09return il-1; X`09`7D X Xallocstat() X`7B X`09int large, statsiz; X`09int *iptr, i; X`09char *calloc(); X X`09if ((tabarr=(int **)calloc(MAXSTATE,sizeof(int *)))==NULL) `7B X`09`09printf(" cannot allocate state pointers\n"); X`09`09exit(); X`09`09`7D X X`09for (i=0; icurrent`5D; X`09`09state = qptr->qstate; X`09`09qptr->current++; X`09`09if (!tabarr`5Bstate`5D`5Bch`5D) tabarr`5Bstate`5D`5Bch`5D= ++mstate; X`09`09state = tabarr`5Bstate`5D`5Bch`5D; X`09 `09if (*qptr->current) `7B X`09`09`09enqueue(qptr->current, qptr->name, state); X`09`09`09`7D X`09`09else bword`5Bstate`5D=qptr->name; X`09`09`7D X`09`7D X Xallocback(size) X`09unsigned size; X`7B X`09char *calloc(); X X`09if ((backptr=(int *)calloc((size+1),sizeof(int)))==NULL) `7B X`09`09printf(" cannot allocate back pointer\n"); X`09`09exit(); X`09`09`7D X`09`7D X Xclean() X`7B X`09char ch, nch; X`09int state, gctail, nexts; X X`09for (state=0; state<=mstate; state++) backptr`5Bstate`5D = -1; X X`09for (state = 0; state <= mstate; state++) `7B X`09 for (ch = 0; ch <= numlets; ch++) `7B X`09`09nexts = tabarr`5Bstate`5D`5Bch`5D; X`09`09if (nexts > state && backptr`5Bnexts`5D == -1) `7B X`09`09 if (backptr`5Bstate`5D!=-1) X`09`09`09gctail=tabarr`5Bbackptr`5Bstate`5D`5D`5Bch`5D; X`09`09 else gctail = 0; X`09`09 backptr`5Bnexts`5D=gctail; X`09`09 if (bword`5Bnexts`5D==0) bword`5Bnexts`5D=bword`5Bgctail`5D; X`09`09 for (nch=0; nch<=numlets; nch++) X`09`09`09if (tabarr`5Bnexts`5D`5Bnch`5D==0) X`09`09`09`09tabarr`5Bnexts`5D`5Bnch`5D=tabarr`5Bgctail`5D`5Bnch`5D; X`09`09 `7D X`09`09`7D X`09 if (bword`5Bfbackptr(state)`5D==bword`5Bstate`5D `7C`7C X`09`09`09 bword`5Bfbackptr(state)`5D==0) X`09`09`09backptr`5Bstate`5D=fbackptr(fbackptr(state)); X`09 `7D X`09`7D X Xfbackptr(state) X`09int state; X`7B X`09if (state<0) return 0; X`09if (backptr`5Bstate`5D<0) return 0; X`09return backptr`5Bstate`5D; X`09`7D X X#include X#ifndef O_RAW X#define O_RAW O_BINARY X#endif X#include "genbank.h" X Xstruct alibhdr annhdr; Xstruct arechdr `7B X`09char seqnam`5B10`5D; X`09char d_year; X`09char d_mon; X`09char d_day; X`09char code; X`09int nrec; X`09char field`5B16`5D; X`09`7D annrec; X X Xint annfd = -1; Xchar annot`5BANRLEN+1`5D; /* this depends on characters being signed */ X Xopenann(libname,libenv) X`09char *libname,*libenv; X`7B X`09char lname`5B120`5D, rline`5B10`5D; X X`09strncpy(lname,libenv,120); X#ifdef UNIX X`09strncat(lname,"/",120); X#endif X`09strncat(lname,libname,120-strlen(lname)); X Xl1:`09if ((annfd=open(lname,O_RDONLY+O_RAW))==-1) `7B X`09`09rline`5B0`5D='\0'; X`09`09printf(" cannot open %s annot file\n",lname); X`09`09printf(" insert another disk or type Y to skip "); X`09`09fgets(rline,10,stdin); X`09`09if (toupper(rline`5B0`5D)=='Y') return 0; X`09`09goto l1; X`09`09`7D X X`09if (read(annfd,(char *)&annhdr,sizeof(annhdr))==-1) `7B X`09`09printf(" could not read %s annot file\n",lname); X`09`09return -1; X`09`09`7D X X`09return 1; X`09`7D X Xcloseann() X`7B X`09if (annfd>0) `7B X`09`09close(annfd); X`09`09annfd = -1; X`09`09`7D X`09`7D X Xgetann(line,maxl) X`09char *line; int maxl; X`7B X`09int i, j, irec, nrec; X X`09irec=0; X`09if (read(annfd,(char *)&annrec,sizeof(annrec))<=0) `7B X`09`09line`5B0`5D='\0'; X`09`09return 0; X`09`09`7D X`09irec++; X X`09nrec = annrec.nrec; X`09 X`09for (i=0; i<10; i++) line`5Bi`5D=annrec.seqnam`5Bi`5D; X`09line`5Bi++`5D=' '; j=i; X`09for (i=3; i<16&&j0) `7B X`09`09irec++; X`09`09for (i=0; i0) `7B X`09`09il=fline; X`09`09lc++; X`09`09charcnt=0; X`09`09while (nxtchar=*il++) `7B X`09`09 nxtchar = ascarr`5Bnxtchar`5D; X`09`09 report = state = tabarr`5Bstate`5D`5Bnxtchar`5D; X`09`09 if (bword`5Breport`5D) `7B X`09`09`09if (clc!=lc) `7B X`09`09`09`09printf("%s\n",fline); X`09`09`09`09`7D X`09`09`09while (bword`5Breport`5D) `7B X`09`09`09`09report = backptr`5Breport`5D; X`09`09`09`09`7D X`09`09`09clc = lc; X`09`09`09`7D X`09`09 charcnt++; X`09`09 `7D X`09`09`7D X`09`7D $ CALL UNPACK FINDN.C;1 2099349148 $ create 'f' X/*`09find.c`09`0928-Apr-83 X X`09uses finite state machine to search a file for a group of X`09strings X X`09copyright (c) 1983 William R. Pearson X X*/ X X#include X#include X X#include "find.gbl" X Xmain (argc,argv) X`09int argc; char *argv`5B`5D; X`7B X`09int ic,i; X X`09if (argc<3) `7B X`09`09printf(" usage - find inputfile `5B-l`5D str1 str2 str3\n"); X`09`09printf("\t or - find inputfile `5B-l`5D @strfile\n"); X`09`09return;`7D X X`09initgbls(); X`09allocgbls(); X X`09ignore = TRUE; X`09for (ic = 1; ic < argc; ic++) `7B X`09`09if (*argv`5Bic`5D=='-'&& tolower(argv`5Bic`5D`5B1`5D)=='l') `7B X`09`09`09ignore = FALSE; X`09`09`09`7D X`09`09else if (*argv`5Bic`5D == '@') getfile(&argv`5Bic`5D`5B1`5D); X`09`09else if (!filename`5B0`5D) strncpy(filename,argv`5Bic`5D,40); X`09`09else install(argv`5Bic`5D); X`09`09`7D X X`09numwrds = nextwrd; X X`09numlets = packlets(); X X`09allocstat(); X`09initqueue(numwrds+2);`09/* +2 to make room for slop and tail=head */ X X`09trie(); X X`09allocback(mstate); X`09clean(); X X`09scan(filename); X X`09`7D X Xinitgbls() X`7B X`09numwrds = 0; X`09`7D X Xallocgbls() X`7B X`09char *calloc(); X X`09if ((wordarr=calloc(MAXCHARS,sizeof(char)))==NULL) `7B X`09`09printf(" cannot allocate word array\n"); X`09`09exit(); X`09`09`7D X`09nextbyte = wordarr; X X`09if ((ascarr=(char *)calloc(128,sizeof(char)))==NULL) `7B X`09`09printf(" cannot allocate ascii array\n"); X`09`09exit(); X`09`09`7D X X`09if ((wordptr=(char **)calloc(MAXWORDS,sizeof(char *)))==NULL) `7B X`09`09printf(" cannot allocate word pointers\n"); X`09`09exit(); X`09`09`7D X`09`7D`09 X Xinstall(word) X`09char *word; X`7B X`09wordptr`5Bnextwrd++`5D = nextbyte; X`09while (*word) *nextbyte++ = *word++; X`09*nextbyte++ = NULL; X`09`7D X Xgetfile(fname) X`09char *fname; X`7B X`09char fline`5BMAXLINE`5D; X`09char fword`5BMAXLINE`5D; X`09int iw,i; X X`09if ((fbuf=fopen(fname,"r"))==0) `7B X`09`09printf(" cannot open pattern file %s\n",fname); X`09`09exit(); X`09`09`7D X`09while (fgets(fline,MAXLINE,fbuf)) `7B X`09`09if (fline`5Bi=strlen(fline)-1`5D=='\n') fline`5Bi`5D=0; X`09`09install(fline); X`09`09`7D X X`09fclose(fbuf); X`09`7D X Xpacklets()`09/* scan all of the words looking for different letters */ X`7B X`09int ia, il; X`09char *ic; X X`09for (ia = 0; ia <128; ia++) ascarr`5Bia`5D = 0; X X`09for (ic = wordarr, ia=0; ic < nextbyte; ic++,ia++) X`09`09`09if (*ic) ascarr`5B*ic`5D = 1; X X`09if (ignore) for (ia = 'a'; ia <= 'z'; ia++) X`09`09if (ascarr`5Bia`5D) `7B X`09`09`09ascarr`5Btoupper(ia)`5D=1; X`09`09`09ascarr`5Bia`5D=0; X`09`09`09`7D X X`09for (ia = 1, il = 1; ia < 127; ia++) X`09`09if (ascarr`5Bia`5D)`09ascarr`5Bia`5D = il++; X X`09if (ignore) for (ia='a'; ia<='z'; ia++) X`09`09ascarr`5Bia`5D=ascarr`5Btoupper(ia)`5D; X`09return il-1; X`09`7D X Xallocstat() X`7B X`09int large, statsiz; X`09int *iptr, i; X`09char *calloc(); X X`09if ((tabarr=(int **)calloc(MAXSTATE,sizeof(int *)))==NULL) `7B X`09`09printf(" cannot allocate state pointers\n"); X`09`09exit(); X`09`09`7D X X`09for (i=0; icurrent`5D; X`09`09state = qptr->qstate; X`09`09qptr->current++; X`09`09if (!tabarr`5Bstate`5D`5Bch`5D) tabarr`5Bstate`5D`5Bch`5D= ++mstate; X`09`09state = tabarr`5Bstate`5D`5Bch`5D; X`09 `09if (*qptr->current) `7B X`09`09`09enqueue(qptr->current, qptr->name, state); X`09`09`09`7D X`09`09else bword`5Bstate`5D=qptr->name; X`09`09`7D X`09`7D X Xallocback(size) X`09unsigned size; X`7B X`09char *calloc(); X X`09if ((backptr=(int *)calloc((size+1),sizeof(int)))==NULL) `7B X`09`09printf(" cannot allocate back pointer\n"); X`09`09exit(); X`09`09`7D X`09`7D X Xclean() X`7B X`09char ch, nch; X`09int state, gctail, nexts; X X`09for (state=0; state<=mstate; state++) backptr`5Bstate`5D = -1; X X`09for (state = 0; state <= mstate; state++) `7B X`09 for (ch = 0; ch <= numlets; ch++) `7B X`09`09nexts = tabarr`5Bstate`5D`5Bch`5D; X`09`09if (nexts > state && backptr`5Bnexts`5D == -1) `7B X`09`09 if (backptr`5Bstate`5D!=-1) X`09`09`09gctail=tabarr`5Bbackptr`5Bstate`5D`5D`5Bch`5D; X`09`09 else gctail = 0; X`09`09 backptr`5Bnexts`5D=gctail; X`09`09 if (bword`5Bnexts`5D==0) bword`5Bnexts`5D=bword`5Bgctail`5D; X`09`09 for (nch=0; nch<=numlets; nch++) X`09`09`09if (tabarr`5Bnexts`5D`5Bnch`5D==0) X`09`09`09`09tabarr`5Bnexts`5D`5Bnch`5D=tabarr`5Bgctail`5D`5Bnch`5D; X`09`09 `7D X`09`09`7D X`09 if (bword`5Bfbackptr(state)`5D==bword`5Bstate`5D `7C`7C X`09`09`09 bword`5Bfbackptr(state)`5D==0) X`09`09`09backptr`5Bstate`5D=fbackptr(fbackptr(state)); X`09 `7D X`09`7D X Xfbackptr(state) X`09int state; X`7B X`09if (state<0) return 0; X`09if (backptr`5Bstate`5D<0) return 0; X`09return backptr`5Bstate`5D; X`09`7D X X Xscan(filename) X`09char *filename; X`7B X`09int state, report; X`09char nxtchar; X`09int lc, clc, ll; X`09int charcnt, ic; X`09char fline`5B512`5D, *il; X X`09if ((fbuf=fopen(filename,"r"))==0) `7B X`09`09printf(" cannot open file %s to be scanned\n",filename); X`09`09exit(); X`09`09`7D X X`09ll = 512; X`09clc = 0; X`09state = 0; X`09lc = 0; X`09while (il=fgets(fline,512,fbuf)) `7B X`09`09if (fline`5B0`5D!='>') continue; X`09`09lc++; X`09`09charcnt=0; X`09`09while (nxtchar=*il++) `7B X`09`09 nxtchar = ascarr`5Bnxtchar`5D; X`09`09 report = state = tabarr`5Bstate`5D`5Bnxtchar`5D; X`09`09 if (bword`5Breport`5D) `7B X`09`09`09if (clc!=lc) `7B X`09`09`09`09fputs(fline,stdout); X`09`09`09`09`7D X`09`09`09while (bword`5Breport`5D) `7B X`09`09`09`09report = backptr`5Breport`5D; X`09`09`09`09`7D X`09`09`09clc = lc; X`09`09`09`7D X`09`09 charcnt++; X`09`09 `7D X`09`09`7D X`09`7D $ CALL UNPACK FINDP.C;1 520604599 $ create 'f' X`09`09`09`09`09July 9, 1986 X X`09The programs FASTA, LFASTA and RDF2 are new versions of a "universal" XFASTP/FASTN program. They are directly descended from FASTN, but instead Xof using a fixed alphabet (ACGT or amino acids) and built-in scoring Xmatrices, all of the search parameters can be read in from a disk file. X X`09FASTA, TFASTA, LFASTA, RDF2, and the sequence analysis Xprograms AACOMP, GARNIER, (T)GREASE, CHOFAS, all read files in the Xstandard protein library format, i.e. X X`09>CODE - title line X`09either protein sequence or DNA sequence X X X`09>CODE2 - next sequence X`09.... X XThe FASTGB program reads the GENBANK floppy disk format for the DNA Xsequence library. It should only be used copies of these files. You must Xset FILES=16 (or greater) in a CONFIG.SYS file when using GFASTA, and you Xshould set the environment variable: X X`09set GBLIB=c:\bbnlib\ X Xso the files can be found. X XThe scoring matrix file is determined by setting the environment variable XSMATRIX. So by typing: X X`09set SMATRIX=c:\fasta\dna.mat X Xthe program will use the DNA alphabet (A,C,G,T,U,R,Q,N, etc) and scoring Xmatrix used in FASTN. If you do not set SMATRIX to anything, it uses an Xinternal alphabet and scoring matrix for proteins which is identical to XFASTP. The configuration files on the disk are: X X`09codaa.mat`09genetic code matrix for proteins X`09idnaa.mat`09identity matrix for proteins using PAM250 self scores X`09iidnaa.mat`09identity matrix for proteins using 1, 0 X`09prot.mat`09pam250 matrix X`09dna.mat`09DNA alphabet and scoring matrix. X`09altprot.mat`09an experimental replacement for the PAM matrix X`09`09`09developed by D. Lipman X XThe format of the SMATRIX file is: X Xline1:`09;P or ;D, this comment (if present) is used to determine whether X`09`09 amino acids (aa) or nucleotides (nt) should be used X`09`09 int the program. Xline2: scoring parameters X`09KFACT BESTOFF BESTSCALE BKFACT BKTUP BESTMAX HISTSIZ X X`09KFACT is used in the "diagonal method" search for the best Xinitial regions, for proteins, KFACT = 4, for DNA, KFACT = 1. X X`09BESTOFF, BESTSCALE, BKFACT, BKTUP and BESTMAX are used to Xcalculate the cutoff score. The bestcut parameter is calculated from Xparameters 2 - 6. If N0 is the length of the query sequence: X X`09BESTCUT = BESTOFF + N0/BESTSCALE + BKFACT*(BKTUP-KTUP) X`09if (BESTCUT>BESTMAX) BESTCUT=BESTMAX X XHISTSIZ is the size of the histogram interval. X Xline3: deletion penalties. X`09the first value is the penalty for the first residue in a gap, Xthe second value is the penalty charged to each subsequent residue in Xa gap. X Xline4: end of sequence characters X`09(these are not required, since IFASTA uses '>' for the Xbeginning of a sequence, but they are included). If not used, the Xline must be left blank. X Xline5: The alphabet X Xline6: the hash values for each letter in the alphabet. This allows Xseveral characters to be hashed to the same value, e.g. a DNA sequence Xalphabet with A = adenosine, 1 = probably adenosine, P = purine, would have Xeach of these characters hash to 0. The lowest hash value should be 0. X Xline7 - n: X X`09The lower triangle of the symmetric scoring matrix. There should Xbe exactly as many lines as there are characters in the alphabet, and the Xlast line should have n-1 entries. The program does not check for the Xlength of each line (perhaps it should), so it is easy to screw up a matrix Xbadly by having fewer entries in the scoring matrix than in the alphabet, Xor vice-versa. X X`09In addition to the using the universal scoring matrix, FASTA has Xseveral improvements from FASTN. You can search libraries Xthat are made up of a number of files. For example: X X`09FASTA test.seq @rodent.lib X Xwould search the files named in the rodent.lib file. If rodent.lib Xcontained: X X`09rat.lib X`09mouse.lib X`09hamster.lib X Xthese three files would be searched by FASTA. This can be used to search a Xnumber of individual sequences without combining them into one file. X X`09FASTA also uses an improved method for calculating the initial Xscore, which allows the scores of several similar to be combined. Thus XFASTA now reports three scores in the summary,`20 X X`09initn - the best score using multiple region alignment. X`09init1 - the old fastp/n score from the best single region X`09opt - `09an optimized score around the init0 region. An optn score X`09`09is not ready yet. X X X $ CALL UNPACK FORMAT.DOC;1 553733331 $ create 'f' X/*`09fromgb.c`09convert from Genbank (and IBI gel reader) format */ X/*`09copyright (C) 1988 William R. Pearson */ X/* `09coverts files of the following format: X XLOCUS oD001primer 184 BP ENTERED 1/28/86 XORIGIN genomic between exons 3a and 3b of dros MHC gene X 1 ACAAAAATTA AACATAACCA ATCGAACgAA TCCGACACAC CGAACGAAAC TGATATACAG X 61 ACACGACTTT gGAAAGATCT GCTCCAGCAA GTGACCCCCC GACTACGAAA AAGCCGTGGA X 121 TATGTCCACT TGACATACTT ACGTGCTCTG TGCTCATACT GGCGGTACTA CACAGCTGAT X 181 CTAC X// X Xto standard Pearson FASTA format: X X>oD001primer genomic between exons 3a and 3b of dros MHC gene XACAAAAATTA AACATAACCA ATCGAACgAA TCCGACACAC CGAACGAAAC TGATATACAG XACACGACTTT gGAAAGATCT GCTCCAGCAA GTGACCCCCC GACTACGAAA AAGCCGTGGA XTATGTCCACT TGACATACTT ACGTGCTCTG TGCTCATACT GGCGGTACTA CACAGCTGAT XCTAC X X*/ X X/* check for arguments on the command line, write a file that has Xthe same prefix but the 'nt' suffix, if no argments on the command Xline, then prompt for input/output file names */ X X/* the program looks for a LOCUS line, then looks for an origin line, then Xcopies starting at column 11 until a // is found */ X X#include X X#define MAXNAME 80 X#define MAXLINE 128 X Xchar lline`5BMAXLINE`5D; Xchar filin`5BMAXNAME`5D, filout`5BMAXNAME`5D; X XFILE *fin, *fout; X Xmain(argc,argv) X`09int argc; char *argv`5B`5D; X`7B X`09char *strchr(), *bp; X`09int argi; X X`09if (argc < 2) `7B X`09`09fprintf(stderr," fromgb file1 ...\n"); X`09`09fprintf(stderr," enter name of file to be converted: "); X`09`09if (fgets(filin,sizeof(filin),stdin)==NULL) exit(0); X`09`09if ((bp=strchr(filin,'\n'))!=NULL) *bp='\0'; X`09`09fprintf(stderr," enter name for converted file: "); X`09`09if (fgets(filout,sizeof(filout),stdin)==NULL) exit(0); X`09`09if ((bp=strchr(filout,'\n'))!=NULL) *bp='\0'; X X`09`09 Xl1:`09`09if ((fin=fopen(filin,"r"))==NULL) `7B X`09`09 fprintf(stderr," cannot open input file: %s\n",filin); X`09`09 fprintf(stderr," enter name of file to be converted: "); X`09`09 if (fgets(filin,sizeof(filin),stdin)==NULL) exit(0); X`09`09 if ((bp=strchr(filin,'\n'))!=NULL) *bp='\0'; X`09`09 goto l1; X`09`09 `7D X Xl2:`09`09if (strcmp(filin,filout)==0) `7B X`09`09 fprintf(stderr, X`09`09`09 " your input and output file names are identical\n"); X`09`09 fprintf(stderr," choose a new output file name: "); X`09`09 if (fgets(filout,sizeof(filout),stdin)==NULL) exit(0); X`09`09 if ((bp=strchr(filout,'\n'))!=NULL) *bp='\0'; X`09`09 goto l2; X`09`09 `7D X`09`09`20 X Xl3:`09`09if ((fout=fopen(filout,"w"))==NULL) `7B X`09`09 fprintf(stderr," cannot open output file: %s",filout); X`09`09 fprintf(stderr," enter name for converted file: "); X`09`09 if (fgets(filout,sizeof(filout),stdin)==NULL) exit(0); X`09`09 if ((bp=strchr(filout,'\n'))!=NULL) *bp='\0'; X`09`09 goto l3; X`09`09 `7D X X`09`09convert(); X`09`09`7D X`09else `09`09/* file names are on the command line */ X`09`09 X`09`09for (argi=1; argi%s %s\n",locus,&lline`5B12`5D); X`09`09if (dflag==0) `7B`09`09/* we have a definition line */ X`09`09 while (fgets(lline,sizeof(lline),fin)!=NULL && X`09`09 strncmp(lline,"ORIGIN",6)!=0) ; X`09`09 if (feof(fin)) break; X`09`09 `7D X X`09`09while (fgets(lline,sizeof(lline),fin)!=NULL && X`09`09 strncmp(lline,"//",2)!=0) `7B X`09`09 fprintf(fout,&lline`5B10`5D); X`09`09 `7D X`09`09if (feof(fin)) break; X`09`09`7D X`09`7D $ CALL UNPACK FROMGB.C;1 107632197 $ create 'f' X/*`09May, June 1987`09- modified for rapid read of database X X`09June 2, 1987 - added TFASTA X`09March 30, 1988 - combined ffgetaa, fgetgb; X`09April 8, 1988 - added PIRLIB format for unix X`09copyright (c) 1987,1988 William R. Pearson X X`09getnt.c`09associated subroutines for matching sequences */ X X/* X8-April-88 X`09The compile time #define PIRLIB allows this routine to be used X`09to read protein and DNA sequence libraries in the NBRF/PIR X`09VAX/VMS library format. That is: X X`09>P1;LCBO X`09This is a line of description X`09GTYH ... the sequence starts on this line X X`09This may ease conversion from UWGCG format libraries. It X`09has not been extensively tested. X X`09In addition, sequence libraries with a '>' in the 4th position X`09are recognized as NBRF format libraries for consistency with X`09UWGCG X*/ X X/* `09Nov 12, 1987`09- this version checks to see if the sequence X`09is DNA or protein by asking whether > 85% is A, C, G, T X X`09May 5, 1988 - modify the DNA/PROTEIN checker by re-reading X`09DNA sequences in order to check for 'U'. X*/ X X#include X X#include "uascii.gbl" X X#ifdef VMS X#define PIRLIB X#endif X X#define XTERNAL X#include "upam.gbl" X X#define TRUE 1 X#define FALSE 0 X#define MAXLINE 512 X X#define MAXR 15 Xint lascii`5B`5D = `7BES, 0, 1, 7, X`09`09 2, 5, 9,13, X`09`09 3, 8, 6,12, X`09`0910,11,14,15`7D; X X#define LAMASK 15 X Xgetseq(filen,seq,maxs,dnaseq) X`09char *filen, *seq; X`09int maxs, *dnaseq; X`7B X`09FILE *fptr; X`09char line`5B512`5D; X`09int i, j, n; X`09int ic; X`09float fc; X X`09if ((fptr=fopen(filen,"r"))==NULL) `7B X`09`09fprintf(stderr," could not open %s\n",filen); X`09`09return 0; X`09`09`7D X`09n=0; X`09while(fgets(line,512,fptr)!=NULL) `7B X#ifdef PIRLIB X`09`09if (line`5B0`5D=='>'&& (line`5B3`5D==';'`7C`7Cline`5B3`5D=='>')) X`09`09`09fgets(line,512,fptr); X`09`09else X#endif X`09`09if (line`5B0`5D!='>'&& line`5B0`5D!=';') `7B X`09`09 for (i=0; (n 0.85) `7B X`09`09*dnaseq = 1; X`09`09`09`09/* convert from protein to DNA sequence */ X`09`09sascii = nascii; X`09`09fseek(fptr,0l,0); X`09`09n=0; X`09`09while(fgets(line,512,fptr)!=NULL) `7B X#ifdef PIRLIB X`09`09`09if (line`5B0`5D=='>'&& (line`5B3`5D==';'`7C`7Cline`5B3`5D=='>')) X`09`09`09`09fgets(line,512,fptr); X`09`09`09else X#endif X`09`09`09if (line`5B0`5D!='>'&& line`5B0`5D!=';') `7B X`09`09`09 for (i=0; (n'`7C`7C line`5B0`5D==';') goto found; X`09`09`7D X`09fclose(fptr); X`09title`5B0`5D='\0'; X`09return 0; X Xfound: X#ifdef PIRLIB X`09if (line`5B0`5D=='>'&&(line`5B3`5D==';'`7C`7Cline`5B3`5D=='>')) `7B X`09`09if ((bp = strchr(line,'\n'))!=NULL) *bp='\0'; X`09`09ll=strlen(line); line`5Bll++`5D=' '; line`5Bll`5D='\0'; X`09`09fgets(&line`5Bll`5D,512-ll,fptr); X`09`7D X#endif X#ifdef MSDOS X`09bp = strpbrk(line,"\n\r"); X#else X`09bp = strchr(line,'\n'); X#endif X`09if (bp!=NULL) *bp = 0; X`09strncpy(title,line,len); X`09title`5Blen-1`5D='\0'; X`09fclose(fptr); X`09return strlen(title); X`09`7D`09 X X#ifndef VMS XFILE *libf=NULL; X#else Xint libf = -1; X#endif X#ifdef NOLIB Xint leof = 0; X#endif X Xlong lpos; Xchar lline`5BMAXLINE`5D; X X#ifndef NOLIB X#include "genbank.h" Xextern int gbflag; Xextern int ldnaseq; Xint (*getlib)(); Xint (*ranlib)(); X#define GETLIB agetlib X#define RANLIB aranlib X#ifndef VMS Xstruct slibhdr libhdr; Xstruct seqhdr namrec; Xchar seqrec`5BSQRLEN`5D; Xint jsave, recsav; X#endif`09`09/* VMS */ X#else X#define GETLIB getlib X#define RANLIB ranlib Xint gbflag=0; X#endif X X#ifndef VMS X/*`09the following is from fgetgb.c */ X X#include X#ifndef O_RAW X#ifdef O_BINARY X#define O_RAW O_BINARY X#else X#define O_RAW 0 X#endif`09`09/* O_BINARY */ X#endif`09`09/* O_RAW */ Xint libfd= -1; X#endif`09`09/* VMS */ X X Xopenlib(lname,libenv) X`09char *lname, *libenv; X`7B X`09char rline`5B10`5D,libn`5B120`5D, *strchr(), *bp; X`09long ftell(); X#ifndef NOLIB X`09int agetlib(),aranlib(),ggetlib(),granlib(); X#endif X`09int wcnt, ll, opnflg; X X`09wcnt = 0; X#ifndef NOLIB X`09if (strlen(libenv)!=0) `7B X`09`09strncpy(libn,libenv,120); X#ifdef UNIX X`09`09strncat(libn,"/",120); X#endif X`09`09strncat(libn,lname,120-strlen(libn)); X`09`09`7D X`09else strncpy(libn,lname,120); X#else X`09strncpy(libn,lname,120); X#endif X X#ifndef MSDOS X#ifndef VMS`09/* here for !MSDOS && !VMS */ Xl1:`09if (gbflag<=0) opnflg=((libf=fopen(libn,"r"))!=NULL); X`09else if (gbflag==1) opnflg=((libfd=open(libn,O_RDONLY+O_RAW))!= -1); X#else`09`09/* VMS */ Xl1:`09opnflg=((libf=open(libn,0))!= -1); X#endif X`09if (!opnflg) `7B X`09`09rline`5B0`5D='\0'; X`09`09fprintf(stderr," cannot open %s library\n",libn); X`09`09fprintf(stderr," enter new file name or to quit "); X`09`09fflush(stderr); X`09`09if (fgets(libn,120,stdin)==NULL) return -1; X`09`09if ((bp=strchr(libn,'\n'))!=0) *bp='\0'; X`09`09if (strlen(libn)==0) return 0; X#else`09`09/* MSDOS */ Xl1:`09if (gbflag<=0) opnflg=((libf=fopen(libn,"rb"))!=NULL); X`09else if (gbflag==1) opnflg=((libfd=open(libn,O_RDONLY+O_RAW))!=-1); X`09if (!opnflg) `7B X`09`09rline`5B0`5D='\0'; X`09`09fprintf(stderr," cannot open %s library\n",libn); X`09`09fprintf(stderr," insert another disk or type Y to skip "); X`09`09fflush(stderr); X`09`09fgets(rline,10,stdin); X`09`09if (toupper(rline`5B0`5D)=='Y') return 0; X#endif X`09`09if (++wcnt > 10) return -1; X`09`09goto l1; X`09`09`7D X#ifndef VMS X`09if (gbflag<=0) `7B X`09`09lpos = ftell(libf); X`09`09if (fgets(lline,MAXLINE,libf)==NULL) return -1; X`09`09`7D X#ifndef NOLIB X`09else if (gbflag==1) `7B X`09`09if (read(libfd,(char *)&libhdr,sizeof(libhdr))==-1) `7B X`09`09`09fprintf(" could not read %s library\n",libn); X`09`09`09fflush(stderr); X`09`09`09return -1; X`09`09`09`7D X`09`09`7D X X`09if (gbflag<0) `7B X`09`09getlib = agetlib; X`09`09ranlib = aranlib; X`09`09gbflag=0; X`09`09if (ldnaseq!=1) return 1; X`09`09if (lline`5B0`5D==' '&& lline`5B1`5D=='\0') `7B X`09`09`09gbflag = 1; X`09`09`09getlib = ggetlib; X`09`09`09ranlib = granlib; X`09`09`09fclose(libf); X`09`09`09libfd=open(libn,O_RDONLY+O_RAW); X`09`09`09if (read(libfd,(char *)&libhdr,sizeof(libhdr))==-1) `7B X`09`09`09`09fprintf(" could not read %s library\n",libn); X`09`09`09`09fflush(stderr); X`09`09`09`09return -1; X`09`09`09`09`7D X`09`09`09`7D X`09`09`7D X#else`09`09/* NOLIB */ X`09leof = 0; X`09gbflag = 0; X#endif`09`09/* NOLIB */ X#else`09`09/* VMS */ X#ifndef NOLIB X`09getlib = agetlib; X`09ranlib = aranlib; X#else: X`09leof = 0; X#endif`09`09/* NOLIB */ X`09gbflag = 0; X`09lpos = lseek(libf,0,1); X`09ll=read(libf,lline,MAXLINE); lline`5Bll`5D='\0'; X#endif`09`09/* VMS */ X`09return 1; X`09`7D X Xcloselib() X`7B X#ifndef VMS X`09if (gbflag==0) `7B X`09`09if (libf!=NULL) `7B X`09`09`09fclose(libf); X`09`09`09libf = NULL; X`09`09`09`7D X`09`09`7D X`09else `7B X`09`09if (libfd>0) `7B X`09`09`09close(libfd); X`09`09`09libfd = -1; X`09`09`09`7D X`09`09`7D X#else X`09if (libf!= -1) `7B X`09`09close(libf); X`09`09libf = -1; X`09`09`7D X#endif X`09`7D X XGETLIB(seq,maxs,libstr,libpos,lcont) X`09char *seq; X`09int maxs; X`09char *libstr; X`09long *libpos; X`09int *lcont; X`7B X#ifndef VMS X`09long ftell(); X#else X`09long lseek(); X#endif X`09int i, n, ll; X`09int ic; X`09register char *cp; X`09register char *seqp; X`09register int *ap; X`09char *seqm, *seqm1, *linep, *strchr(); X X`09seqp = seq; X`09seqm = &seq`5Bmaxs-9`5D; X`09seqm1 = seqm-1; X#ifndef TFASTA X`09ap = sascii; X#else X`09ap = nascii; X#endif X`09i=0; X`09n=0; X`09if (*lcont==0) `7B X#ifndef NOLIB X`09`09while (lline`5B0`5D!='>' && lline`5B0`5D!=';') `7B X#ifndef VMS X`09`09`09lpos = ftell(libf); X`09`09`09if (fgets(lline,MAXLINE,libf)==NULL) return 0; X`09`09`7D X#ifndef PIRLIB X`09`09strncpy(libstr,lline,20); X#else`09`09/* PIRLIB */ X`09`09strncpy(libstr,&lline`5B4`5D,20); X`09`09fgets(lline,MAXLINE,libf); X#endif`09`09/* PIRLIB */ X#else`09`09/* VMS */ X`09`09`09if ((ll=read(libf,lline,MAXLINE))==0) return 0; X`09`09`09lline`5Bll`5D='\0'; X`09`09`09lpos = lseek(libf,0,1); X`09`09`7D X`09`09strncpy(libstr,&lline`5B4`5D,20); X`09`09ll=read(libf,lline,512); lline`5Bll`5D='\0'; X#endif X`09`09libstr`5B10`5D='\0'; X`09`09*libpos = lpos; X#else`09/* NOLIB */ X`09`09if (leof) return 0; X`09`09*libpos = lpos; X`09`09if (lline`5B0`5D=='>' `7C`7C lline`5B0`5D==';') `7B X`09`09`09strncpy(libstr,lline,20); X`09`09`09libstr`5B10`5D='\0'; X#ifdef PIRLIB`09`09`09`09 X`09`09`09if (lline`5B0`5D=='>'&&(lline`5B3`5D==';'`7C`7Clline`5B3`5D=='>')) V `7B X#ifdef VMS X`09`09`09`09ll=read(libf,lline,MAXLINE); X`09`09`09`09lline`5Bll`5D='\0'; X#else X`09`09`09`09fgets(lline,MAXLINE,libf); X#endif`09/* VMS */ X`09`09`09`09`7D X#endif`09/* PIRLIB */ X`09`09`09`7D X`09`09else `7B X`09`09`09libstr`5B0`5D='\0'; X`09`09`09strncpy(seqp,lline,(int)(seqm-seqp)); X`09`09`09for (cp=seqp; seqpNA) break; X`09`09`09`09`7D X`09`09`09if (*seqp==ES) goto done; X`09`09`09`7D X#endif X`09`09`7D X X`09lline`5B0`5D='\0'; X#ifndef VMS X`09while (seqp0) `7B X`09`09seqp`5Bll`5D='\0'; X`09`09lpos = lseek(libf,0,1); X#endif X`09`09if (*seqp=='>') goto new; X`09`09if (*seqp==';') `7B X`09`09`09if (strchr(seqp,'\n')==NULL) goto cont; X`09`09`09continue; X`09`09`09`7D X`09`09for (cp=seqp; seqpNA) break; X`09`09`09 `7D X`09`09if (*seqp==ES) goto done; X#ifndef VMS X`09`09lpos = ftell(libf); X#endif X`09`09`7D X`09goto done; Xnew:`09strncpy(lline,seqp,MAXLINE); X`09lline`5BMAXLINE-1`5D='\0'; X`09if (strchr(seqp,'\n')==NULL) fgets(lline,MAXLINE-strlen(lline),libf); X`09goto done; X Xcont: X#ifndef VMS X`09fgets(lline,MAXLINE,libf); X#else X`09ll=read(libf,lline,MAXLINE); X`09lline`5Bll`5D='\0'; X#endif X`09seqm1 = seqp; X Xdone:`09if (seqp>=seqm1) `7B X`09`09(*lcont)++; X`09`09`7D X`09else `7B X#ifdef NOLIB X`09leof = 1; X#endif X`09*lcont=0; X`09`09`7D X X X`09*seqp = EOSEQ; X`09return (int)(seqp-seq); X`09`7D X XRANLIB(str,cnt,seek) X`09char *str; int cnt; long seek; X`7B X`09char *bp; X`09int ll; X#ifdef MSDOS X`09char *strpbrk(); X#else X`09char *strchr(); X#endif X#ifndef VMS X`09fseek(libf, seek, 0); X`09fgets(lline,MAXLINE,libf); X#else X`09lseek(libf,seek,0); X`09ll=read(libf,lline,MAXLINE); X`09lline`5Bll`5D='\0'; X#endif X`09if (lline`5B0`5D=='>' `7C`7C lline`5B0`5D==';') `7B X`09`09strncpy(str,lline,cnt); X#ifdef PIRLIB X`09if (lline`5B0`5D=='>'&&(lline`5B3`5D==';'`7C`7Clline`5B3`5D=='>')) X`09`09strncpy(str,&lline`5B3`5D,cnt); X#endif X`09`09str`5Bcnt-1`5D='\0'; X#ifdef MSDOS X`09`09bp = strpbrk(str,"\r\n"); X#else X`09`09bp = strchr(str,'\n'); X#endif X`09`09if (bp!=NULL) *bp = 0; X`09`09else str`5Bcnt-1`5D='\0'; X#ifdef PIRLIB X`09`09if (lline`5B0`5D=='>'&&(lline`5B3`5D==';'`7C`7Clline`5B3`5D=='>')) `7B X#ifdef VMS X`09`09`09ll=read(libf,lline,MAXLINE); X#else X`09`09`09fgets(lline,MAXLINE,libf); X#endif`09/* VMS */ X`09`09`09if ((bp = strchr(lline,'\n'))!=NULL) *bp='\0'; X`09`09`09strncat(str," ",cnt); X`09`09`09strncat(str,lline,cnt-strlen(str)); X`09`09`09`7D X#endif`09/* PIRLIB */ X`09`09`7D X`09else `7B X`09`09str`5B0`5D='\0'; X`09`09`7D X#ifdef NOLIB X`09leof=0; X#endif X#ifdef PIRLIB X#ifdef VMS X`09lseek(libf,seek,0); X`09ll=read(libf,lline,MAXLINE); lline`5Bll`5D='\0'; X#else X`09fseek(libf,seek,0); X`09fgets(lline,MAXLINE,libf); X#endif X#endif`09/* PIRLIB */ X`09`7D X X#ifndef NOLIB X#ifndef VMS Xggetlib(seq,maxs,libstr,libpos,lcont) X`09char *seq; X`09int maxs; X`09char *libstr; X`09long *libpos; X`09int *lcont; X`7B X`09int i, j, m, n; X`09int arec, nrec, rrec, trec; X`09register int *lap; X`09register char *sptr, *tptr; X`09char *ttptr; X`09int mc2, tmp; X`09char sname`5B11`5D; X`09long lseek(); X X`09sptr = seq; X`09lap = lascii; X X`09if (*lcont==0) `7B X`09`09*libpos = lseek(libfd,0L,1); X`09`09if (read(libfd,(char *)&namrec,sizeof(namrec))==0) return 0; X`09`09recsav = namrec.rcnt`5B0`5D + (namrec.rcnt`5B1`5D<<8) - 1; X`09`09for (j=0; j<11; j++)`20 X`09`09`09if (!(*sptr++ = namrec.seqstart`5Bj`5D)) goto done; X`09`09maxs -= 22; X`09`09strncpy(sname,namrec.seqnam,10); X`09`09sname`5B10`5D='\0'; X`09`09strncpy(libstr,sname,20); X`09`09libstr`5B10`5D='\0'; X`09`09`7D X X`09arec = (maxs-2)/(2*SQRLEN); X`09rrec = min(arec,recsav); X`09if (rrec>0 X`09 && (trec=read(libfd,(char *)sptr,rrec*SQRLEN))!=rrec*SQRLEN) X`09`09goto error; X`09if (rrec == recsav) *lcont=0; X`09else `7B(*lcont)++; recsav -= rrec;`7D X X`09sptr += rrec*SQRLEN; X Xdone: X`09tptr = ttptr = seq + 2*(int)(sptr - seq); X`09while (sptr>seq) `7B X`09`09*--tptr = lap`5B*--sptr&LAMASK`5D; X`09`09*--tptr = lap`5B(*sptr>>4)&LAMASK`5D; X`09`09`7D X X`09tptr = ttptr; X`09while (*--tptr>MAXR); X`09n = (int)(tptr-seq)+1; X`09seq`5Bn`5D= EOSEQ; X`09return (n); X Xerror:`09fprintf(stderr," error reading %10s %4d %4d %4d\n",sname,trec,rrec* VSQRLEN,SQRLEN); X`09fflush(stderr); X`09return (-1); X`09`7D X Xextern int ixstat; X Xgranlib(str,cnt,seek) X`09char *str; int cnt; X`09long seek; X`7B X`09int ctmp; X`09long lseek(); X`09if (ixstat>0) `7B X`09`09lseek(libfd,seek,0); X`09`09if (read(libfd,(char *)&namrec,sizeof(namrec))==0) return 0; X`09`09strncpy(str,namrec.seqnam,10); X`09`09str`5B10`5D='\0'; X`09`09ctmp=cnt-10; X`09`09idxann(str,&str`5B10`5D,ctmp); X`09`09`7D X`09else if (ixstat==0) `7B X`09`09lseek(libfd,seek,0); X`09`09if (read(libfd,(char *)&namrec,sizeof(namrec))==0) `7B X`09`09`09str`5B0`5D='\0'; return 0;`7D X`09`09strncpy(str,namrec.seqnam,10); X`09`09str`5B10`5D='\0'; X`09`09`7D X`09lseek(libfd,seek,0); X`09`7D X#endif`09/* VMS */ X#endif`09/* NOLIB */ X Xscanseq(seq,n,str) X`09char *seq, *str; X`09int n; X`7B X`09int tot,i; X`09char aaray`5BMAXSQ`5D;`09`09/* this must be set > nsq */ X`09 X`09for (i=0; i= 0 && nt < nsq) return cnt`5Bnt`5D; X`09else `7B X`09`09fprintf(stderr," sequence error %d\n",nt); X`09`09fflush(stderr); X`09`7D X`09return -1; X`09`7D X*/ X X#ifdef VMS Xmemcpy(ar0, ar1, n) X`09char *ar0, *ar1; unsigned n; X`7B X`09while (n--) *ar0++ = *ar1++; X`09`7D X Xopenidx() `7B`7D Xnewname() `7B`7D X#endif X#ifdef MACLSC Xmemcpy(ar0, ar1, n) X`09char *ar0, *ar1; unsigned n; X`7B X`09while (n--) *ar0++ = *ar1++; X`09`7D X#endif $ CALL UNPACK FXGETAA.C;1 756728842 $ create 'f' X/*`09garnier.c`09calculate garnier secondary structure prediction */ X/*`09corrected (?) for misinterpretation of matrix, Nov 1, 1988 */ X#include X X#include "upam.gbl" X#include "garnier.h" X#define XTERNAL X#include "uascii.gbl" X Xint amap`5B20`5D;`20 Xint nna = 20; X X#define MAXSEQ 5000 Xchar seq`5BMAXSEQ`5D; Xchar type`5BMAXSEQ`5D; X#define MAXT 60 Xchar title`5BMAXT`5D; X X/*`09parr`5B0`5D = helix; parr`5B1`5D=extend; parr`5B2`5D=turn; parr`5B3`5D= Vcoil */ Xint parr`5B4`5D; Xint dharr`5B`5D=`7B0,158,-75,-100`7D; Xint dsarr`5B`5D=`7B0,50,-88,-88`7D; X Xchar carr`5B`5D="HETC"; Xint iarr`5B4`5D; X Xint dnaseq= -1; X Xint`09n0; X Xmain(argc,argv) X`09int argc; char *argv`5B`5D; X`7B X`09int i, j, k, m, l0, l1, idc, dcs, dch, lastk; X`09float fn0; X`09`09 X`09if (argc < 2) `7B X`09`09printf(" usage - garnier filename\n"); X`09`09exit(1); X`09`09`7D X X`09sascii = aascii; X`09if ((n0=getseq(argv`5B1`5D,seq,MAXSEQ,&dnaseq))<=0) `7B X`09`09fprintf(stderr," could not read %s\n",argv`5B1`5D); X`09`09exit(1); X`09`09`7D X X`09gettitle(argv`5B1`5D,title,MAXT); X X`09if (argc>2) `7Bsscanf(argv`5B2`5D,"%d",&idc); if (idc <0 `7C`7C idc >6) i Vdc = 0;`7D X`09else idc = 0; X X`09if (idc <= 0) dcs=dch=0; X`09else if (idc < 4) `7Bdch = dharr`5Bidc`5D; dcs = 0;`7D X`09else if (idc <= 6) `7Bdch = 0; dcs = dsarr`5Bidc-3`5D;`7D X`09else dcs=dch=0; X X`09makemap(amino,amap,nna); X X`09for (i=0; i=0) `7B X`09`09`09`09parr`5B0`5D += helix`5Bseq`5Bi-j`5D`5D`5B8+j`5D; X`09`09`09`09parr`5B1`5D += extend`5Bseq`5Bi-j`5D`5D`5B8+j`5D; X`09`09`09`09parr`5B2`5D += turns`5Bseq`5Bi-j`5D`5D`5B8+j`5D; X`09`09`09`09parr`5B3`5D += coil`5Bseq`5Bi-j`5D`5D`5B8+j`5D; X`09`09`09`09`7D X`09`09 `09if ((i+j)parr`5Bk`5D) k=j; X`09`09if (parr`5Blastk`5D>=parr`5Bk`5D) k=lastk; X`09`09lastk = k; X`09`09type`5Bi`5D=carr`5Bk`5D; X`09`09iarr`5Bk`5D++; X`09`09`7D X X`09printf(" garnier plot of %s, %3d aa; DCH = %d, DCS = %d\n", X`09`09`09argv`5B1`5D,n0,dch,dcs); X`09printf(" %-s\n",title); X X`09l1 = n0/60 + 1; X`09for (l0=0; l0glocus.idx Xgbct1.seq Xgbct2.seq Xgbct3.seq Xgbct4.seq Xgbct5.seq Xgbct6.seq Xgbct7.seq Xgbct8.seq Xgbct9.seq Xgbct10.seq Xgbct11.seq Xgbct12.seq Xgbct13.seq Xgbct14.seq Xgbct15.seq +-+-+-+-+-+-+-+- END OF PART 3 +-+-+-+-+-+-+-+- -+-+-+-+-+-+-+-+ START OF PART 4 -+-+-+-+-+-+-+-+ Xgbct16.seq Xgbct17.seq Xgbct18.seq Xgbct19.seq Xgbct20.seq Xgbct21.seq Xgbct22.seq Xginv1.seq Xginv2.seq Xginv3.seq Xginv4.seq Xginv5.seq Xginv6.seq Xginv7.seq Xginv8.seq Xginv9.seq Xginv10.seq Xginv11.seq Xginv12.seq Xginv13.seq Xgmam1.seq Xgmam2.seq Xgmam3.seq Xgmam4.seq Xgmam5.seq Xgmam6.seq Xgmam7.seq Xgorg1.seq Xgorg2.seq Xgorg3.seq Xgorg4.seq Xgorg5.seq Xgorg6.seq Xgorg7.seq Xgphg1.seq Xgphg2.seq Xgphg3.seq Xgpln1.seq Xgpln2.seq Xgpln3.seq Xgpln4.seq Xgpln5.seq Xgpln6.seq Xgpln7.seq Xgpln8.seq Xgpln9.seq Xgpln10.seq Xgpln11.seq Xgpln12.seq Xgpln13.seq Xgpln14.seq Xgpln15.seq Xgpln16.seq Xgpri1.seq Xgpri2.seq Xgpri3.seq Xgpri4.seq Xgpri5.seq Xgpri6.seq Xgpri7.seq Xgpri8.seq Xgpri9.seq Xgpri10.seq Xgpri11.seq Xgpri12.seq Xgpri13.seq Xgpri14.seq Xgpri15.seq Xgpri16.seq Xgpri17.seq Xgpri18.seq Xgpri19.seq Xgpri20.seq Xgpri21.seq Xgpri22.seq Xgpri23.seq Xgpri24.seq Xgpri25.seq Xgpri26.seq Xgpri27.seq Xgpri28.seq Xgpri29.seq Xgpri30.seq Xgpri31.seq Xgrna1.seq Xgrna2.seq Xgrna3.seq Xgrod1.seq Xgrod2.seq Xgrod3.seq Xgrod4.seq Xgrod5.seq Xgrod6.seq Xgrod7.seq Xgrod8.seq Xgrod9.seq Xgrod10.seq Xgrod11.seq Xgrod12.seq Xgrod13.seq Xgrod14.seq Xgrod15.seq Xgrod16.seq Xgrod17.seq Xgrod18.seq Xgrod19.seq Xgrod20.seq Xgrod21.seq Xgrod22.seq Xgrod23.seq Xgrod24.seq Xgrod25.seq Xgrod26.seq Xgrod27.seq Xgsyn1.seq Xgsyn2.seq Xgsyn3.seq Xguna1.seq Xguna2.seq Xguna3.seq Xguna4.seq Xgvrl1.seq Xgvrl2.seq Xgvrl3.seq Xgvrl4.seq Xgvrl5.seq Xgvrl6.seq Xgvrl7.seq Xgvrl8.seq Xgvrl9.seq Xgvrl10.seq Xgvrl11.seq Xgvrl12.seq Xgvrl13.seq Xgvrl14.seq Xgvrl15.seq Xgvrl16.seq Xgvrl17.seq Xgvrl18.seq Xgvrl19.seq Xgvrt1.seq Xgvrt2.seq Xgvrt3.seq Xgvrt4.seq Xgvrt5.seq Xgvrt6.seq Xgvrt7.seq Xgvrt8.seq $ CALL UNPACK GBALL.NAM;1 2035916840 $ create 'f' X/*`09gbann.c`09lookup GenBank annotations in the library */ X/*`09modified for release 57 changes to format */ X X/* `09placed in the public domain by William R. Pearson */ X X#include X#ifdef MACLSC X#include X#include X#include XSFReply freply; XPoint wpos; Xint tval; X Xchar prompt`5B256`5D; X#else X#include X#endif X X#ifndef MSDOS X#ifndef MACLSC X#define O_BINARY 0 X#endif X#endif X X#define MAXSQ 32 Xchar nt`5BMAXSQ`5D=`7B'a','c','g','t','u','r','y','m','w','s','k','d','h','v V','b','n','x'`7D; Xint nnt = 17; X X#define XTERNAL X#include "genbank.h" X X#define GBFMAX 13 Xchar *gbfiles`5B`5D = `7B"gpri","grod","gmam","gvrt","ginv","gpln", X`09`09 "gorg","gbct","grna","gvrl","gphg","gsyn","guna","gtst"`7D; Xint gb57vers; X X#define NAMLEN 10 X XFILE *tptr, *optr;`09/* file pointers for input, lib, output */ Xint flib; Xint anonly=1; X Xint fidx;`09`09`09/* fd for index */ X X#define BMODE 0x8000 X#define RMODE 0 Xlong filen, lseek(); Xunsigned minidx,maxidx; X Xstruct ilibhdr idxhdr; Xstruct idxrec indexf; Xstruct alibhdr anhead; Xstruct seqhdr seqent; Xstruct annhdr annent; Xextern struct slibhdr libhdr; X Xint annfd = -1; Xint ixstat = -1; Xextern int libfd; X Xchar lline`5B512`5D, seqnam`5B120`5D, oname`5B120`5D, tmpname`5B20`5D, lname V`5B120`5D; X X#ifndef BIGMEM X#define MAXSEQ 10000 X#define MAXANN 16384+ANRLEN X#else X#define MAXSEQ 100000 X#define MAXANN 65536+ANRLEN X#endif X Xchar *seq, *annbuf, *annptr, libstr`5B40`5D, *calloc(); Xchar iline`5B80`5D; X Xlong nseq; Xlong ntc`5B5`5D; Xlong libpos; Xchar *libenv; X#ifdef MACLSC Xint glvRef,anvRef, sqvRef, ouvRef; X#endif Xextern int optind; Xint optcnt; X Xmain(argc,argv) X`09int argc; char **argv; X`7B X`09char tname`5B40`5D,iname`5B120`5D,iiname`5B120`5D; X`09int i; X`09char *getenv(),*tp,*strpbrk(); X`09int copt, getopt(); X`09extern char *optarg; X X#ifdef MACLSC X`09Click_On(FALSE); X`09GetVol(prompt,&ouvRef); X`09wpos.h=50; wpos.v=100; X#endif X X`09while ((copt=getopt(argc,argv,"a"))!=EOF) `7B X`09`09switch(copt) `7B X`09`09`09case 'a': anonly=0; break; X`09`09`09default: break; X`09`09`09`7D X`09`09`7D X`09optind--; X X`09memset(iline,' ',80); X X`09if ((libenv=getenv("GBLIB"))==NULL) libenv="\0"; X`09strncpy(iname,"glocus.idx",120); X X`09if (argc-optind < 2) `7B X`09`09printf(" gbann - get annotations from a GenBank library\n"); X`09`09tname`5B0`5D='\0'; X`09`09`7D X`09else `7B X`09`09strncpy(tname,argv`5Boptind+1`5D,40); X`09`09`7D X X`09strncpy(iiname,libenv,120); X#ifdef UNIX X`09if (strlen(iiname)>0) strncat(iiname,"/",120); X#endif X`09strncat(iiname,iname,120-strlen(iiname)); X#ifndef MACLSC Xl2:`09if ((fidx=open(iiname,BMODE+RMODE)) == -1) `7B X`09`09printf(" could not open index file: %s\n",iiname); X`09`09printf(" index file name `5B%s`5D: ",iiname); X`09`09fgets(iiname,40,stdin); X`09`09if ((tp=strpbrk(iiname,"\r\n"))!=NULL) *tp='\0'; X`09`09goto l2; X`09`09`7D X#else Xl2:`09if ((fidx=open(iiname,BMODE+RMODE)) == -1) `7B X`09`09libenv = "\0"; X`09`09sprintf(prompt,"Cannot open %s\r\rSelect index file",iiname); X`09`09FileDlog(prompt,&freply); X`09`09if (freply.good==TRUE) `7B`09 X`09`09`09PtoCstr(freply.fName); X`09`09`09strcpy(iiname,freply.fName); X`09`09`09glvRef = anvRef = sqvRef = freply.vRefNum; X`09`09`09SetVol("\p\0",glvRef); X`09`09`09goto l2; X`09`09`09`7D X`09`09else return; X`09`09`7D X#endif X`09read(fidx,(char *)&idxhdr,sizeof(idxhdr)); X`09gb57vers = (idxhdr.rlsnam`5B1`5D-'0')*10 + idxhdr.rlsnam`5B2`5D-'0'; X X`09minidx=(unsigned)idxhdr.firstrec`5B0`5D+(unsigned)idxhdr.firstrec`5B1`5D* V256-1; X`09maxidx = (unsigned)idxhdr.lastrec`5B0`5D+(unsigned)idxhdr.lastrec`5B1`5D* V256; X X`09if ((seq = calloc(MAXSEQ,sizeof(char)))==NULL) `7B X`09`09printf(" cannot allocate seq array\n"); X`09`09exit(); X`09`09`7D X X`09if ((annbuf = calloc(MAXANN,sizeof(char)))==NULL) `7B X`09`09printf(" cannot allocate annot array\n"); X`09`09exit(); X`09`09`7D X X`09while(getnames(tname,40)); `09/* get the sequence names and hash them */ X`09`7D X X/* newname generates a new filename with prefix oname and suffix suff */ X Xnewname(nname,oname,suff,maxn) X`09char *nname, *oname, *suff; X`7B X`09char *tptr; X`09strncpy(nname,oname,maxn); X X`09for (tptr=nname; *tptr!='.'&& *tptr; tptr++); /* get to '.' or EOS */ X`09*tptr++='.'; *tptr='\0'; X`09strncat(nname,suff,maxn); X`09`7D X Xgetnames(tname,maxnam)`09/* read in the names and hash them */ X`09char *tname; int maxnam; X`7B X`09int i, tflag; X`09char tline`5B40`5D, *bp, *strchr(); X X`09if (tflag=(strlen(tname)==0)) `7B`09/* get names from keyboard */ X`09`09printf(" GenBank sequence identifier: "); X`09`09fgets(tname,maxnam,stdin); X`09`09if ((bp=strchr(tname,'\n'))!=NULL) *bp='\0'; X`09`09if (tname`5B0`5D=='\0') return 0; X`09`09oname`5B0`5D=' '; X`09`09`7D X`09else oname`5B0`5D='\0'; X X`09if (lookup(tname)==0) X`09`09fprintf(stderr," sequence %s not found\n",tname); X`09else `7B X`09`09if (oname`5B0`5D==' ') `7B X`09`09`09fprintf(stderr," Filename for %s : ",tname); X`09`09`09fgets(oname,sizeof(oname),stdin); X`09`09`09if ((bp=strchr(oname,'\n'))!=NULL) *bp='\0'; X`09`09`09`7D X`09`09putfile(oname); X`09`09`7D X`09tname`5B0`5D='\0'; X`09return tflag; X`09`7D X Xucase(str)`09/* convert a string to upper case */ X`09char *str; X`7B X`09while (*str) `7B X`09`09if (*str >= 'a' && *str <= 'z') *str -= 'a' - 'A'; X`09`09str++; X`09`09`7D X`09`7D X Xlookup(name,mark)`09/* lookup names in library */ X`09char *name; long *mark; X`7B X`09long hi, lo, mid, diff; X`09char tname`5B120`5D; X`09long pos; X X`09strncpy(tname,name,sizeof(tname)); X`09ucase(tname); X`09strncat(tname," ",10-strlen(name)); X X/* binary search for code */ X X`09lo = minidx; X`09hi = maxidx; X X`09while (hi >= lo) `7B X`09`09mid = (hi + lo)/2; X`09`09pos = (long)mid * (long)sizeof(indexf); X`09`09lseek(fidx, pos, 0); X`09`09read(fidx, &indexf, sizeof(indexf)); X`09`09if ((diff = strncmp(tname, indexf.name,10)) == 0) `7B X`09`09`09return 1; X`09`09`09`7D X`09`09else if (diff < 0) X`09`09`09hi = mid - 1; X`09`09else X`09`09`09lo = mid + 1; X`09`09`7D X`09return 0; X`09`7D X Xchar *montab`5B`5D=`7B"JAN","FEB","MAR","APR","MAY","JUN","JUL","AUG","SEP", X`09`09"OCT","NOV","DEC"`7D; Xputfile(seqnam) X`09char *seqnam; X`7B X`09char *strchr(), *bp, *sp; X`09long slpos,alpos; X`09int i, nnt, lcont, iostat; X`09char llname`5B120`5D; X X`09strncpy(llname,libenv,120); X#ifdef UNIX X`09if (strlen(llname)>0) strncat(llname,"/",120); X#endif X`09strncpy(lname,gbfiles`5Bindexf.divnum-1`5D,120); X`09if (gb57vers < 57) X`09 sprintf(&lname`5B4`5D,"%d.ano",(indexf.filenum&0xF0)>>4); X`09else X`09 sprintf(&lname`5B4`5D,"%d.ano",indexf.filenum); X`09strncat(llname,lname,120-strlen(llname)); X X`09openann(llname); X X/* get to the beginning of the annotation */ X X`09alpos = (long)(indexf.annrec`5B0`5D+indexf.annrec`5B1`5D*256-1)* X`09`09(long)(idxhdr.anrecl`5B0`5D+idxhdr.anrecl`5B1`5D*256); X X`09lseek(annfd,alpos,0); X`09if (read(annfd,(char *)&annent,sizeof(annent))!=sizeof(annent)) `7B X`09`09fprintf(stderr,"cannot read annotation entry %d\n"); X`09`09`7D X X`09for (i=0; i<10&&annent.name`5Bi`5D; i++) `7B X`09`09if (annent.name`5Bi`5D==' ') break; X`09`09libstr`5Bi`5D=annent.name`5Bi`5D; X`09`09`7D X`09libstr`5Bi`5D='\0'; X X X`09if (gb57vers<57) sprintf(&lname`5B4`5D,"%d.seq",indexf.filenum&0xF); X`09else sprintf(&lname`5B4`5D,"%d.seq",indexf.filenum); X`09openlib(lname,libenv); X X`09slpos = (long)(indexf.seqrec`5B0`5D+indexf.seqrec`5B1`5D*256-1)* X`09`09(long)(idxhdr.sqrecl`5B0`5D+idxhdr.sqrecl`5B1`5D*256); X X X/* get to the beginning of the sequence */ X`09lseek(libfd,slpos,0); X`09read(libfd,&seqent,sizeof(seqent)); X`09lseek(libfd,slpos,0); X`09`09`09 X X`09nseq = ntc`5B0`5D = ntc`5B1`5D = ntc`5B2`5D= ntc`5B3`5D = ntc`5B4`5D= 0l; X X`09lcont=0; X`09while ((nnt=getlib(seq,MAXSEQ,libstr,&libpos,&lcont))>0)`7B X`09`09nseq += nnt; X`09`09if (lcont==0) break; X`09`09for (sp=seq; sp< &seq`5Bnnt`5D; sp++) X`09`09`09(*sp < 4) ? ntc`5B*sp`5D++: ntc`5B4`5D++; X`09`09`7D X`09for (sp=seq; sp< &seq`5Bnnt`5D; sp++) X`09`09(*sp < 4) ? ntc`5B*sp`5D++: ntc`5B4`5D++; X`09if (optr!=stdout) fclose(optr); X`09if (anonly) closelib(); X X`09if (strlen(seqnam)>0) `7B X#ifdef MACLSC X`09`09SetVol("\p",ouvRef); X#endif X`09`09if ((optr=fopen(seqnam,"w"))==NULL) `7B X`09`09`09printf(" cannot open %s\n",seqnam); X`09`09`09optr=stdout; X`09`09`09`7D X`09`09`7D X`09else optr = stdout; X X`09fprintf(optr,"LOCUS %-10s %6ld bp ",libstr,nseq); X X`09fprintf(optr,"%s",seqtype67`5B(seqent.seqtype&192)>>6`5D); X`09if (gb57vers<57) `7B X`09`09if (seqent.seqtype&1) X`09`09`09fprintf(optr,"%s",seqtype23`5B(seqent.seqtype&12)>>2`5D); X`09`09else fprintf(optr,"DNA "); X`09`7D else `7B X`09`09if ((seqent.seqtype&3)==3) X`09`09`09fprintf(optr,"%s",seqtype23`5B(seqent.seqtype&12)>>2`5D); X`09`09else fprintf(optr,"%s",seqtype12`5B(seqent.seqtype&3)`5D); X`09`7D X`09fprintf(optr," %s",seqtype45`5B(seqent.seqtype&48)>>4`5D); X`09if (annent.code=='E') annent.code=2; X`09else if (annent.code=='S') annent.code=0; X`09else if (annent.code=='P') annent.code=1; X`09else if (annent.code=='U') annent.code=3; X X`09fprintf(optr," %-s %02d-%3s-%04d\n",entrytype`5Bannent.code`5D, X`09`09annent.day,montab`5Bannent.month-1`5D,annent.year+1900); X X`09getann(optr); X`09if (anonly) return 1; X`09lseek(libfd,slpos,0); X`09read(libfd,&seqent,sizeof(seqent)); X`09lseek(libfd,slpos,0); X`09lcont = 0; X`09while ((nnt=getlib(seq,MAXSEQ,libstr,&libpos,&lcont))>0)`7B X`09`09nseq += nnt; X`09`09if (lcont==0) break; X`09`09putlib(seq,nnt,optr); X`09`09`7D X`09putlib(seq,nnt,optr); X`09putllib(optr); X`09`7D X Xchar oline`5B70`5D; Xint ocnt=0, olast=0; Xlong onumb=1; X Xputlib(seq,n,optr) X`09char *seq; X`09int n; X`09FILE *optr; X`7B X`09char *sp; X X/* fill up oline, assuming that it may already have characters in it */ X X`09sp = seq; X`09while (n>0) `7B X`09`09for (; ocnt<60 && n>0; ocnt++,n--) `7B X`09`09`09oline`5Bolast++`5D= nt`5B*sp++`5D; X`09`09`09if (ocnt%10 == 9) oline`5Bolast++`5D=' '; X`09`09`09`7D X`09`09if (ocnt<60) return; X`09`09oline`5Bolast-1`5D='\0'; X`09`09ocnt=olast=0; X`09`09fprintf(optr," %7ld %s\n",onumb,oline); X`09`09onumb += 60l; X`09`09`7D X`09`7D X Xputllib(optr) X`09FILE *optr; X`7B X`09oline`5Bolast`5D='\0'; X`09fprintf(optr," %7ld %s\n",onumb,oline); X`09fputs("//\n",optr); X`09`7D X Xchar annot`5BANRLEN+1`5D; /* this depends on characters being signed */ X Xopenann(lname) X`09char *lname; X`7B X`09char rline`5B40`5D, *bp, *strchr(); X#ifndef MACLSC Xl1:`09if ((annfd=open(lname,O_RDONLY+O_BINARY))==-1) `7B X`09`09rline`5B0`5D='\0'; X`09`09printf(" cannot open %s annot file\n",lname); X#ifndef UNIX X`09`09printf(" insert another disk or type Y to skip "); X`09`09fgets(rline,10,stdin); X`09`09if (toupper(rline`5B0`5D)=='Y') return 0; X#else X`09`09printf(" new file name: "); X`09`09fgets(rline,sizeof(rline),stdin); X`09`09if ((bp=strchr(rline,'\n'))!=NULL) *bp='\0'; X`09`09strcpy(lname,rline); X#endif X`09`09goto l1; X`09`09`7D X#else X`09SetVol("\p",anvRef); X`09if ((annfd=open(lname,O_RDONLY+O_BINARY))==-1) `7B X`09`09libenv="\0"; Xl1:`09`09SetVol("\p",anvRef); X`09`09if ((annfd=open(lname,O_RDONLY+O_BINARY))==-1) `7B X`09`09`09sprintf(prompt," cannot open %s\r\r Select Annotation File",lname); X`09`09`09FileDlog(prompt,&freply); X`09`09`09if (freply.good==TRUE) `7B`09 X`09`09`09`09PtoCstr(freply.fName); X`09`09`09`09strcpy(lname,freply.fName); X`09`09`09`09anvRef=sqvRef=freply.vRefNum; X`09`09`09`09goto l1; X`09`09`09`09`7D X`09`09`09else return -1; X`09`09`09`7D X`09`09`7D X#endif X`09if (read(annfd,(char *)&anhead,sizeof(anhead))!=sizeof(anhead)) `7B X`09`09printf(" could not read %s annot file\n",lname); X`09`09return -1; X`09`09`7D X X`09return 1; X`09`7D X Xcloseann() X`7B X`09if (annfd>0) `7B X`09`09close(annfd); X`09`09annfd = -1; X`09`09`7D X`09`7D X Xranann(seek) X`09long seek; X`7B X`09lseek(annfd,seek,0); X`09`7D X X#ifdef BIGMEM X#define MAXJO 200 X#define MAXAU 200 X#define MAXFE 1000 X#else X#define MAXJO 100 X#define MAXAU 100 X#define MAXFE 200 X#endif X Xchar *desptr, *accptr, *orgptr, *jouptr`5BMAXJO`5D, *autptr`5BMAXAU`5D, *fea Vptr`5BMAXFE`5D; Xint ijou, iaut, ifea; X Xgetann(optr) X`09FILE *optr; X`7B X`09int i, j, nrec, rcont; X`09unsigned int nbytes; X`09char *ip; X X`09desptr=accptr=orgptr=NULL; X`09ijou=iaut=ifea=0; X`09for (i=0; i=MAXJO) break; X`09`09`09`09`7D X`09`09`09else if (strncmp(ip,"RA",2)==0) `7B X`09`09`09`09autptr`5Biaut++`5D=(char *)ip+2; X`09`09`09`09if (iaut>=MAXAU) break; X`09`09`09`09`7D X`09`09`09else if (strncmp(ip,"FT",2)==0) `7B X`09`09`09`09feaptr`5Bifea++`5D=(char *)ip+2; X`09`09`09`09if (ifea>=MAXFE) break; X`09`09`09`09`7D X`09`09`09`7D X X`09if (desptr!=NULL) putline(optr,"DEFINITION ",desptr); X`09else fprintf(stderr,"%s - no definition\n",libstr); X X`09if (accptr!=NULL) putline(optr,"ACCESSION ",accptr); X`09else fprintf(stderr,"%s - no accession #\n",libstr); X X`09if (orgptr!=NULL) `7B X`09`09fputs("SOURCE\n",optr); X`09`09putline(optr," ORGANISM ",orgptr); X`09`09`7D X`09else fprintf(stderr,"%s - no organism\n",libstr); X X`09if (ijou!=iaut) `7B X`09 fprintf(stderr,"authors and journals don't match %d %d\n",ijou,iaut); X`09 ijou=iaut=(ijou>iaut)?iaut:ijou; X`09 `7D X`09else for (i=0; i0) fprintf(optr," %6ld other\n",ntc`5B4`5D); X`09else fprintf(optr,"\n"); X`09fprintf(optr,"ORIGIN\n"); X`09`7D X Xchar *featype`5B49`5D=`7B X"",`09/* 0 */ X"pept",`09/* 1 */ X"sigp",`09/* 2 */ X"matp",`09/* 3 */ X"tRNA",`09/* 4 */ X"rRNA",`09/* 5 */ X"allele",`09/* 6 */ X"uRNA",`09/* 7 */ X"RNA",`09/* 8 */ X"anticdn",`09/* 9 */ X"attack",`09/* 10 */ X"binding",`09/* 11 */ X"cell",`09/* 12 */ X"conflict",`09/* 13 */ X"connect",`09/* 14 */ X"cutds",`09/* 15 */ X"cutss",`09/* 16 */ X"d-loop",`09/* 17 */ X"DNA",`09`09/* 18 */ X"iDNA",`09`09/* 19 */ X"iRNA",`09`09/* 20 */ X"IVS",`09`09/* 21 */ X"LTR",`09`09/* 22 */ X"methyl",`09/* 23 */ X"modified",`09/* 24 */ X"mRNA",`09`09/* 25 */ X"mult", X"mut", X"ORF", X"orgrpl", X"pre-msg",`09/* 30 */ X"prov", X"recomb", X"refnumbr", X"revision", X"rpt",`09`09/* 35 */ X"signal", X"site", X"trns", X"unsure", X"variant",`09/* 40 */ X"virion", X"variation", X"pept.ps", X"mRNA.ps", X"sigp.ps",`09/* 45 */ X"matp.ps", X"tRNA.ps", X"uRNA.ps"`7D;`09/* 48 */ X Xputfeat(optr,feaptr,nfea) X`09FILE *optr; X`09char **feaptr; X`09int nfea; X`7B X`09int i, j; X`09unsigned char fcode; X`09char fnote, tnote, cflag; X`09long fstart, fstop; X`09char *featxt; X X`09if (nfea>0) X`09`09fprintf(optr,"FEATURES from to/span description\n"); X`09else return; X X`09for (i=0; iwd) `7B X`09`09for (j=wd, sp=str1+i+j; j>0; j--,sp--) `7B X`09`09`09if (*sp=='\r') continue; X`09`09`09if (*sp<=' ') `7B*sp='\n'; i += j; break;`7D X`09`09`09`7D X`09`09if (j<=0) i += wd+1; X`09`09`7D X`09 else break; X`09 `7D while (i=wd+1) `7B X`09`09`09fprintf(fp,"\n%s",iline); X`09`09`09lpos = 0; X`09`09`09`7D X`09`09`7D X`09fputc('\n',fp); X`09iline`5Bmarg-1`5D=' '; X`09`7D X X#ifndef MACLSC Xmin(x,y) X`09int x,y; X`7B X`09return ((x X#ifdef MACLSC X#include X#else X#include X#endif X X#define XTERNAL X#include "genbank.h" X X#ifndef O_RAW X#ifdef O_BINARY X#define O_RAW O_BINARY X#else X#define O_RAW 0 X#endif X#endif X X#define GBFMAX 13 Xchar *gbfiles`5B`5D = `7B"gpri","grod","gmam","gvrt","ginv","gpln", X`09`09 "gorg","gbct","grna","gvrl","gphg","gsyn","guna"`7D; Xint gb57vers; X Xextern char *libenv; X X#define NAMLEN 10 X Xlong lseek(); Xunsigned minidx,maxidx; X Xstruct ilibhdr idxhdr; Xstruct idxrec indexf; Xstruct alibhdr annhdr; X Xint idxfd = -1; X Xchar annpref`5B80`5D;`09/* if a full directory name is given instead of X`09`09`09 libenv, must get the directory name. */ X#ifdef UNIX X#define FSLASH '/' X#else X#define FSLASH '\\' X#endif X Xopenidx(lname,libenv) X`09char *lname, *libenv; X`7B X`09char rline`5B120`5D; int i; X`09char *strrchr(), *bp; X X`09if (strlen(libenv)>0) strncpy(rline,libenv,120); X`09else `7B X`09`09rline`5B0`5D='\0'; X`09`09strncpy(annpref,lname,sizeof(annpref)); X`09`09if ((bp=strrchr(annpref,FSLASH))!=NULL) *(bp+1)='\0'; X`09`09else annpref`5B0`5D='\0'; X`09`09`7D X`09`09 X#ifdef UNIX X`09if (strlen(libenv)>0) strncat(rline,"/",120); X#endif X`09strncat(rline,lname,120-strlen(rline)); Xl1:`09if ((idxfd=open(rline,O_RDONLY+O_RAW))==-1) `7B X`09`09printf(" cannot open %s index file\n",rline); X`09`09printf(" type new name or to skip :"); X`09`09fgets(rline,120,stdin); X`09`09if (rline`5Bi=strlen(rline)-1`5D=='\n') rline`5Bi`5D='\0'; X`09`09if (rline`5B0`5D=='\0') return 0; X`09`09goto l1; X`09`09`7D X X`09if (read(idxfd,(char *)&idxhdr,sizeof(idxhdr))==-1) `7B X`09`09printf(" could not read %s index file\n",rline); X`09`09return -1; X`09`09`7D X X`09gb57vers = (idxhdr.rlsnam`5B1`5D-'0')*10 + idxhdr.rlsnam`5B2`5D-'0'; X X`09minidx=(unsigned)idxhdr.firstrec`5B0`5D+(unsigned)idxhdr.firstrec`5B1`5D* V256-1; X`09maxidx=(unsigned)idxhdr.lastrec`5B0`5D+(unsigned)idxhdr.lastrec`5B1`5D*25 V6; X X`09return 1; X`09`7D X Xcloseidx() X`7B X`09if (idxfd>0) `7B X`09`09close(idxfd); X`09`09idxfd = -1; X`09`09`7D X`09`7D X`09 X Xidxann(seqnam,str,maxs) X`09char *seqnam, *str; int maxs; X`7B X`09long lpos; X`09char lname`5B120`5D,lext`5B10`5D; X`09int irecln, iannrec; X X`09if (lookup(seqnam)==0) `7B X`09`09sprintf(str," could not find %s",seqnam); X`09`09return; X`09`09`7D X`09 X`09if (strlen(libenv)>0) strncpy(lname,libenv,120); X`09else if (strlen(annpref)>0) strncpy(lname,annpref,sizeof(lname)); X`09else lname`5B0`5D='\0'; X X#ifdef UNIX X`09if (strlen(libenv)>0) strncat(lname,"/",120); X#endif X`09strncat(lname,gbfiles`5Bindexf.divnum-1`5D,120-strlen(lname)); X X`09if (gb57vers<57) X`09 sprintf(lext,"%d.ano",(indexf.filenum&0xF0)>>4); X`09else X`09 sprintf(lext,"%d.ano",indexf.filenum); X X`09strncat(lname,lext,120-strlen(lname)); X`09openann(lname); X`09irecln = annhdr.recln`5B0`5D+annhdr.recln`5B1`5D*256; X`09iannrec = indexf.annrec`5B0`5D+indexf.annrec`5B1`5D*256; X`09lpos = ((long)iannrec-1)*(long)irecln; X`09ranann(lpos); X`09if (getann(str,maxs)==0) X`09`09sprintf(str," could not read annot %s\n",seqnam); X`09closeann(); X`09`7D X Xnewname(nname,oname,suff,maxn) X`09char *nname, *oname, *suff; X`7B X`09char *tptr; X X`09if (oname`5B0`5D=='@') strncpy(nname,&oname`5B1`5D,maxn); X`09else strncpy(nname,oname,maxn); X X`09for (tptr=nname; *tptr!='.'&& *tptr; tptr++); /* get to '.' or EOS */ X`09*tptr++='.'; *tptr='\0'; X`09strncat(nname,suff,maxn); X`09`7D X Xucase(str)`09/* convert a string to upper case */ X`09char *str; X`7B X`09while (*str) `7B X`09`09if (*str >= 'a' && *str <= 'z') *str -= 'a' - 'A'; X`09`09str++; X`09`09`7D X`09`7D X Xlookup(name)`09/* lookup names in library */ X`09char *name; X`7B X`09long hi, lo, mid, diff, i; X`09long pos; X`09char sname`5B11`5D; X X`09strncpy(sname,name,10); X`09sname`5B10`5D='\0'; X`09ucase(sname); X`09strncat(sname," ",10-strlen(name)); X`09sname`5B10`5D='\0'; X X/* binary search for code */ X X`09lo = minidx; X`09hi = maxidx; X`09while (hi >= lo) `7B X`09`09mid = (hi + lo)/2; X`09`09pos = (long)mid * (long)sizeof(indexf); X`09`09lseek(idxfd, pos, 0); X`09if (read(idxfd,(char *)&indexf, sizeof(indexf))!=sizeof(indexf)) `7B X`09`09printf(" cannot read index file\n"); return 0;`7D X`09`09if ((diff = strncmp(sname, indexf.name,10)) == 0) `7B X`09`09`09return 1; X`09`09`09`7D X`09`09else if (diff < 0) X`09`09`09hi = mid - 1; X`09`09else X`09`09`09lo = mid + 1; X`09`09`7D X`09return 0; X`09`7D X Xint annfd = -1; Xunsigned char annot`5BANRLEN+1`5D; /* this depends on characters being signe Vd */ X Xopenann(lname) X`09char *lname; X`7B X`09char rline`5B10`5D; Xl1:`09if ((annfd=open(lname,O_RDONLY+O_RAW))<0) `7B X`09`09rline`5B0`5D='\0'; X`09`09printf(" cannot open %s annot file\n",lname); X`09`09printf(" insert another disk or type Y to skip "); X`09`09fgets(rline,10,stdin); X`09`09if (toupper(rline`5B0`5D)=='Y') return 0; X`09`09goto l1; X`09`09`7D X X`09if (read(annfd,(char *)&annhdr,sizeof(annhdr))==-1) `7B X`09`09printf(" could not read %s annot file\n",lname); X`09`09return -1; X`09`09`7D X X`09return 1; X`09`7D X Xcloseann() X`7B X`09if (annfd>0) `7B X`09`09close(annfd); X`09`09annfd = -1; X`09`09`7D X`09`7D X Xranann(seek) X`09long seek; X`7B X`09lseek(annfd,seek,0); X`09`7D X Xgetann(line,maxl) X`09char *line; int maxl; X`7B X`09int i, j; X X`09j=0; X`09if (read(annfd,annot,ANRLEN)<=0) `7B X`09`09line`5B0`5D='\0'; X`09`09return 0; X`09`09`7D X X`09annot`5BANRLEN`5D='\0'; X`09for (i=19; i0) `7B X`09`09annot`5BANRLEN`5D='\0'; X`09`09for (i=0; i=maxl-1) goto done; X`09`09`7D Xdone:`09line`5Bj`5D=0; X`09for (i=0; line`5Bi`5D; i++)`20 X`09`09if (line`5Bi`5D=='\r'`7C`7Cline`5Bi`5D=='\n') line`5Bi`5D=' '; X`09return j; X`09`7D $ CALL UNPACK GETANN.C;1 910513879 $ create 'f' X/*LINTLIBRARY*/ X#define NULL`090 X#define EOF`09(-1) X#define ERR(s, c)`09if(opterr)`7B\ X`09extern int strlen(), write();\ X`09char errbuf`5B2`5D;\ X`09errbuf`5B0`5D = c; errbuf`5B1`5D = '\n';\ X`09(void) write(2, argv`5B0`5D, (unsigned)strlen(argv`5B0`5D));\ X`09(void) write(2, s, (unsigned)strlen(s));\ X`09(void) write(2, errbuf, 2);`7D X Xextern int strcmp(); Xextern char *strchr(); X Xint`09opterr = 1; Xint`09optind = 1; Xint`09optopt; Xchar`09*optarg; X Xint Xgetopt(argc, argv, opts) Xint`09argc; Xchar`09**argv, *opts; X`7B X`09static int sp = 1; X`09register int c; X`09register char *cp; X X`09if(sp == 1) X`09`09if(optind >= argc `7C`7C X`09`09 argv`5Boptind`5D`5B0`5D != '-' `7C`7C argv`5Boptind`5D`5B1`5D == '\ V0') X`09`09`09return(EOF); X`09`09else if(strcmp(argv`5Boptind`5D, "--") == NULL) `7B X`09`09`09optind++; X`09`09`09return(EOF); X`09`09`7D X`09optopt = c = argv`5Boptind`5D`5Bsp`5D; X`09if(c == ':' `7C`7C (cp=strchr(opts, c)) == NULL) `7B X`09`09ERR(": illegal option -- ", c); X`09`09if(argv`5Boptind`5D`5B++sp`5D == '\0') `7B X`09`09`09optind++; X`09`09`09sp = 1; X`09`09`7D X`09`09return('?'); X`09`7D X`09if(*++cp == ':') `7B X`09`09if(argv`5Boptind`5D`5Bsp+1`5D != '\0') X`09`09`09optarg = &argv`5Boptind++`5D`5Bsp+1`5D; X`09`09else if(++optind >= argc) `7B X`09`09`09ERR(": option requires an argument -- ", c); X`09`09`09sp = 1; X`09`09`09return('?'); X`09`09`7D else X`09`09`09optarg = argv`5Boptind++`5D; X`09`09sp = 1; X`09`7D else `7B X`09`09if(argv`5Boptind`5D`5B++sp`5D == '\0') `7B X`09`09`09sp = 1; X`09`09`09optind++; X`09`09`7D X`09`09optarg = NULL; X`09`7D X`09return(c); X`7D $ CALL UNPACK GETOPT.C;1 1148464736 $ create 'f' X/* a program for evaluating the hydrophobicity of sequence segments */ X X#include X#include "upam.gbl" X#define XTERNAL X#include "uascii.gbl" X Xchar code`5B`5D = "RKDBNSEHZQTGAPVYCMILWFX"; Xint amap`5B23`5D; X Xint dnaseq= -1; X Xfloat factor`5B`5D = `7B0.0,0.6,1.0,1.0,1.0,3.6,1.0,1.3,1.0,1.0,3.8,4.1, X`096.3,2.9,8.7,3.2,7.0,6.4,9.0,8.2,3.6,7.2, 4.5`7D; X X#define MAXSEQ 10000 Xchar sequence`5BMAXSEQ`5D; X Xchar value`5BMAXSEQ`5D; X#define MAXT 60 Xchar title`5BMAXT`5D; X Xmain (argc,argv) X`09int argc; char *argv`5B`5D; X`7B X`09int i,j,k, wind,mid; X`09float total,wfact; X`09char residue; X X`09j = 0; X X`09if (argc < 2) `7B X`09`09printf(" usage - grease filename window\n"); X`09`09exit(1); X`09`09`7D X X`09if (argc > 2) `7B X`09`09sscanf(argv`5B2`5D,"%d",&wind); X`09`09if (wind < 2 `7C`7C wind > 20) wind = 7; X`09`09`7D X`09else wind = 7; X X`09sascii = aascii; X`09if ((j=getseq(argv`5B1`5D,sequence,MAXSEQ,&dnaseq))<=0) `7B X`09`09fprintf(stderr," could not read %s\n",argv`5B1`5D); X`09`09exit(1); X`09`09`7D X X`09gettitle(argv`5B1`5D,title,MAXT); X X`09printf(" Kyte-Doolittle plot of %s, %d aa; window = %d\n", X`09`09argv`5B1`5D,j,wind); X`09printf("%-s\n",title); X X`09mid = wind/2; X`09wfact = 7.0/(float)wind; X X`09makemap(code,amap,naa); X X`09for (i = 0; i X X#ifdef BIGMEM X#define MININT -9999999 X#else X#define MININT -32000 X#endif X X#define DIGIT 10.0 X Xint *CC, *DD; X X/* pointer to the previous crossing point */ Xstatic int *CP, *DP; X Xstatic int IP; X X#ifdef FAR_PTR Xstatic int far *MP`5B3`5D;`09`09/* save crossing points */ Xstatic char far *MT`5B3`5D;`09`09/* 0: rep, 1: del, 2: ins */ Xstatic int far *FP;`09`09/* forward dividing points */ Xstatic char far *FT; X#else Xstatic int *MP`5B3`5D;`09`09/* save crossing points */ Xstatic char *MT`5B3`5D;`09`09/* 0: rep, 1: del, 2: ins */ Xstatic int *FP;`09`09`09/* forward dividing points */ Xstatic char *FT; X#endif X X#define max(x,y) ((x) >= (y) ? (x) : (y)) X#define min(x,y) ((x) <= (y) ? (x) : (y)) X Xstatic int (*w)`5B32`5D;`09`09`09`09/* w = W */ Xstatic int g, h, m;`09`09`09`09/* g = G, h = H, m = g+h */ X X#define gap(k) ((k) <= 0 ? 0 : (g+h*(k)))`09/* k-symbol indel cost */ X Xstatic int *sapp;`09`09`09`09/* Current script append ptr */ Xstatic int last;`09`09`09`09/* Last script op appended */ X X`09`09`09`09`09`09/* Append "Delete k" op */ X#define DEL(k)`09`09`09`09\ X`7B `09`09`09`09`09\ X if (last < 0)`09`09`09`09\ X last = sapp`5B-1`5D -= (k);`09`09\ X else`09`09`09`09`09\ X last = *sapp++ = -(k);`09`09\ X`7D X`09`09`09`09`09`09/* Append "Insert k" op */ X#define INS(k)`09`09`09`09\ X`7B `09`09`09`09`09\ X if (last > 0)`09`09`09`09\ X last = sapp`5B-1`5D += (k);`09`09\ X else`09`09`09`09`09\ X last = *sapp++ = (k);`09`09\ X`7D X X`09`09`09`09`09`09/* Append "Replace" op */ X#define REP `09`09`09`09\ X`7B last = *sapp++ = 0; `09`09`09\ X`7D X X/* align(A,B,M,N,up,low,tb,te) returns the cost of an optimum conversion bet Vween X A`5B1..M`5D and B`5B1..N`5D and appends such a conversion to the current V script. X tb(te)= 1 no gap-open penalty if the conversion begins(ends) with a dele Vte. X tb(te)= 2 no gap-open penalty if the conversion begins(ends) with an ins Vert. X*/ Xstatic int align(A,B,M,N,low,up,tb,te) Xchar *A, *B; int M, N, low, up; char tb, te; X`7B X`09int rmid, k, l, r, v, kt; X`09int t1, t2, t3; X X `7B`09int band, midd; X`09int leftd, rightd;`09/* for CC, DD, CP and DP */ X`09register int midc; X`09register int curd;`09/* current index for CC, DD CP and DP */ X`09register int i, j; X`09register int c, d, e; X`09int t, fr, *wa, ib; X X`09/* Boundary cases: M <= 0 , N <= 0, or up-low <= 0 */ X`09if (N <= 0) `7B`20 X`09`09if (M > 0) DEL(M) X`09`09return; X`09`7D X`09if (M <= 0) `7B X`09`09INS(N) X`09`09return; X`09`7D X`09if ((band = up-low+1) <= 1) `7B X`09`09for (i = 1; i <= M; i++) REP X`09`09return; X`09`7D X X`09/* Divide: Find all crossing points */ X X`09/* Initialization */ X`09midd = band/2 + 1; X`09rmid = low + midd - 1; X`09leftd = 1-low; X`09rightd = up-low+1; X`09if (leftd < midd) `7B X`09`09fr = -1; X`09`09for (j = 0; j < midd; j++)`20 X`09`09 CP`5Bj`5D = DP`5Bj`5D = -1; X`09`09for (j = midd; j <= rightd; j++) `7B X`09`09 CP`5Bj`5D = DP`5Bj`5D = 0; X`09`09`7D X`09`09MP`5B0`5D`5B0`5D = -1; X`09`09MP`5B1`5D`5B0`5D = -1; X`09`09MP`5B2`5D`5B0`5D = -1; X`09`7D else if (leftd > midd) `7B X`09`09fr = leftd-midd; X`09`09for (j = 0; j <= midd; j++) `7B X`09`09 CP`5Bj`5D = DP`5Bj`5D = fr; X`09`09`7D X`09`09for (j = midd+1; j <= rightd; j++)`20 X`09`09 CP`5Bj`5D = DP`5Bj`5D = -1; X`09`09MP`5B0`5D`5Bfr`5D = -1; X`09`09MP`5B1`5D`5Bfr`5D = -1; X`09`09MP`5B2`5D`5Bfr`5D = -1; X`09`7D else `7B X`09`09fr = 0; X`09`09for (j = 0; j < midd; j++) `7B X`09`09 CP`5Bj`5D = DP`5Bj`5D = 0; X`09`09`7D X`09`09for (j = midd; j <= rightd; j++) `7B X`09`09 CP`5Bj`5D = DP`5Bj`5D = 0; X`09`09`7D X`09`09MP`5B0`5D`5B0`5D = -1; X`09`09MP`5B1`5D`5B0`5D = -1; X`09`09MP`5B2`5D`5B0`5D = -1; X`09`7D X X`09CC`5Bleftd`5D = 0; X`09if (tb == 2) t = 0; X`09else t = -g; X`09for (j = leftd+1; j <= rightd; j++) `7B X`09`09CC`5Bj`5D = t = t-h; X`09`09DD`5Bj`5D = t-g; X`09`7D X`09CC`5Brightd+1`5D = MININT; X`09DD`5Brightd+1`5D = MININT; X`09if (tb == 1) DD`5Bleftd`5D = 0; X`09else DD`5Bleftd`5D = -g; X`09CC`5Bleftd-1`5D = MININT; X`09for (i = 1; i <= M; i++) `7B X`09 if (i > N-up) rightd--; X`09 if (leftd > 1) leftd--; X`09 wa = w`5BA`5Bi`5D`5D; X`09 if ((c = CC`5Bleftd+1`5D-m) > (d = DD`5Bleftd+1`5D-h)) `7B X`09`09d = c; X`09`09DP`5Bleftd`5D = CP`5Bleftd+1`5D; X`09 `7D else DP`5Bleftd`5D = DP`5Bleftd+1`5D; X`09 if ((ib = leftd+low-1+i) > 0) c = CC`5Bleftd`5D+wa`5BB`5Bib`5D`5D; X`09 if (d > c `7C`7C ib <= 0) `7B X`09`09c = d; X`09`09CP`5Bleftd`5D = DP`5Bleftd`5D; X`09 `7D X`09 e = c-g; X`09 DD`5Bleftd`5D = d; X`09 CC`5Bleftd`5D = c; X`09 IP = CP`5Bleftd`5D; X`09 if (leftd == midd) CP`5Bleftd`5D = DP`5Bleftd`5D = IP = i; X`09 for (curd=leftd+1; curd <= rightd; curd++) `7B X`09 if (curd != midd) `7B X`09`09 if ((c = c-m) > (e = e-h)) `7B X`09`09 e = c; X`09`09 IP = CP`5Bcurd-1`5D; X`09`09 `7D /* otherwise, IP is unchanged */ X`09`09 if ((c = CC`5Bcurd+1`5D-m) > (d = DD`5Bcurd+1`5D-h)) `7B X`09`09 d = c; X`09`09 DP`5Bcurd`5D = CP`5Bcurd+1`5D; X`09`09 `7D else `7B X`09`09 DP`5Bcurd`5D = DP`5Bcurd+1`5D; X`09`09 `7D X`09`09 c = CC`5Bcurd`5D + wa`5BB`5Bcurd+low-1+i`5D`5D; X`09`09 if (c < d `7C`7C c < e) `7B X`09`09 if (e > d) `7B X`09`09 c = e; X`09`09 CP`5Bcurd`5D = IP; X`09`09 `7D else `7B X`09`09 c = d; X`09`09 CP`5Bcurd`5D = DP`5Bcurd`5D; X`09`09 `7D X`09`09 `7D /* otherwise, CP is unchanged */ X`09`09 CC`5Bcurd`5D = c; X`09`09 DD`5Bcurd`5D = d; X`09`09`7D else `7B /* j == midc */ X`09`09 if ((c = c-m) > (e = e-h)) `7B X`09`09 e = c; X`09`09 MP`5B1`5D`5Bi`5D = CP`5Bcurd-1`5D; X`09`09 MT`5B1`5D`5Bi`5D = 2; X`09`09 `7D else `7B X`09`09 MP`5B1`5D`5Bi`5D = IP; X`09`09 MT`5B1`5D`5Bi`5D = 2; X`09`09 `7D X`09`09 if ((c = CC`5Bcurd+1`5D-m) > (d = DD`5Bcurd+1`5D-h)) `7B X`09`09 d = c; X`09`09 MP`5B2`5D`5Bi`5D = CP`5Bcurd+1`5D; X`09`09 MT`5B2`5D`5Bi`5D = 1; X`09`09 `7D else `7B X`09`09 MP`5B2`5D`5Bi`5D = DP`5Bcurd+1`5D; X`09`09 MT`5B2`5D`5Bi`5D = 1; X`09`09 `7D X`09`09 c = CC`5Bcurd`5D + wa`5BB`5Bcurd+low-1+i`5D`5D; X`09`09 if (c < d `7C`7C c < e) `7B X`09`09 if (e > d) `7B X`09`09 c = e; X`09`09 MP`5B0`5D`5Bi`5D = MP`5B1`5D`5Bi`5D; X`09`09 MT`5B0`5D`5Bi`5D = 2; X`09`09 `7D else `7B X`09`09 c = d; X`09`09 MP`5B0`5D`5Bi`5D = MP`5B2`5D`5Bi`5D; X`09`09 MT`5B0`5D`5Bi`5D = 1; X`09`09 `7D X`09`09 `7D else `7B X`09`09`09 MP`5B0`5D`5Bi`5D = i-1; X`09`09`09 MT`5B0`5D`5Bi`5D = 0; X`09`09 `7D X`09`09 if (c-g > e) `7B X`09`09`09MP`5B1`5D`5Bi`5D = MP`5B0`5D`5Bi`5D; X`09`09`09MT`5B1`5D`5Bi`5D = MT`5B0`5D`5Bi`5D; X`09`09 `7D X`09`09 if (c-g > d) `7B X`09`09`09MP`5B2`5D`5Bi`5D = MP`5B0`5D`5Bi`5D; X`09`09`09MT`5B2`5D`5Bi`5D = MT`5B0`5D`5Bi`5D; X`09`09 `7D X`09`09 CP`5Bcurd`5D = DP`5Bcurd`5D = IP = i; X`09`09 CC`5Bcurd`5D = c; X`09`09 DD`5Bcurd`5D = d; X`09`09`7D X`09 `7D X`09`7D X X`09/* decide which path to be traced back */ X`09if (te == 1 && d+g > c) `7B X`09`09k = DP`5Brightd`5D; X`09`09l = 2; X`09`7D else if (te == 2 && e+g > c) `7B X`09`09k = IP; X`09`09l = 1; X`09`7D else `7B X`09`09k = CP`5Brightd`5D; X`09`09l = 0; X`09`7D X`09if (rmid > N-M) l = 2; X`09else if (rmid < N-M) l = 1; X`09v = c; X `7D X`09/* Conquer: Solve subproblems recursively */ X X`09/* trace back */ X`09r = -1;`09 X`09for (; k > -1; r=k, k=MP`5Bl`5D`5Br`5D, l=MT`5Bl`5D`5Br`5D)`7B X`09`09FP`5Bk`5D = r; X`09`09FT`5Bk`5D = l; X`09`7D X`09/* forward dividing */ X`09if (r == -1) `7B /* optimal alignment did not cross the middle diagonal * V/ X`09 if (rmid < 0) align(A,B,M,N,rmid+1,up,tb,te); X`09 else align(A,B,M,N,low,rmid-1,tb,te); X`09`7D else `7B X`09 k = r; X`09 l = FP`5Bk`5D; X`09 kt = FT`5Bk`5D; X X`09 /* first block */ X`09 if (rmid < 0) `7B X`09`09align(A,B,r-1,r+rmid,rmid+1,min(up,r+rmid),tb,1); X`09`09DEL(1) X`09 `7D else if (rmid > 0) `7B X`09`09align(A,B,r,r+rmid-1,max(-r,low),rmid-1,tb,2); X`09`09INS(1) X`09 `7D X X`09 /* intermediate blocks */ X`09 t2 = up-rmid-1; X`09 t3 = low-rmid+1; X`09 for (; l > -1; k = l, l = FP`5Bk`5D, kt = FT`5Bk`5D) `7B X`09`09if (kt == 0) REP X`09`09else if (kt == 1) `7B /* right-hand side triangle */ X`09`09 INS(1) X`09`09 t1 = l-k-1; X`09`09 align(A+k,B+k+rmid+1,t1,t1,0,min(t1,t2),2,1); X`09`09 DEL(1) X`09`09`7D else `7B /* kt == 2, left-hand side triangle */ X`09`09 DEL(1) X`09`09 t1 = l-k-1; X`09`09 align(A+k+1,B+k+rmid,t1,t1,max(-t1,t3),0,1,2); X`09`09 INS(1) X`09`09`7D X`09 `7D X X`09 /* last block */ X`09 if (N-M > rmid) `7B X`09`09INS(1) X`09`09t1 = k+rmid+1; X`09`09align(A+k,B+t1,M-k,N-t1,0,min(N-t1,t2),2,te); X`09 `7D else if (N-M < rmid) `7B X`09`09DEL(1) X`09`09t1 = M-(k+1); X`09`09align(A+k+1,B+k+rmid,t1,N-(k+rmid),max(-t1,t3),0,1,te); X`09 `7D X`09`7D X`09return(v); X`7D X X#ifndef FAR_PTR X#define FCKALLOC ckalloc X#else X#define FCKALLOC fckalloc X#endif X Xstatic int CHECK_SCORE(); X Xint ALIGN(A,B,M,N,low,up,W,G,H,S,MW,MX) Xchar A`5B`5D,B`5B`5D; int M,N,low,up,MW,MX; int W`5B`5D`5B32`5D,G,H; int S`5 VB`5D; X X`7B`20 X`09int c, i, j; X`09int band; X`09int check_score; X`09char *ckalloc(); X#ifdef FAR_PTR X`09char far * fckalloc(); X#endif X X`09w = W;`09`09`09/* Setup global parameters */ X`09g = G; X`09h = H; X`09m = g+h; X`09sapp = S; X`09last = 0; X`09low = min(max(-M, low),min(N-M,0)); X`09up = max(min(N, up),max(N-M,0)); X X`09if (N <= 0) `7B`20 X`09`09if (M > 0) DEL(M); X`09`09return -gap(M); X`09`7D X`09if (M <= 0) `7B X`09`09INS(N); X`09`09return -gap(N); X`09`7D X`09if ((band = up-low+1) <= 1) `7B X`09`09c = 0; X`09`09for (i = 1; i <= M; i++) `7B X`09`09`09REP; X`09`09`09c += w`5BA`5Bi`5D`5D`5BB`5Bi`5D`5D; X`09`09`7D X`09`09return c; X`09`7D X X`09j = (MW+1+2) * sizeof(int); X`09if (CC==NULL) `7B X`09 CC = (int *) ckalloc(j); X`09 DD = (int *) ckalloc(j); X`09`7D X`09if (CP==NULL) `7B X`09 CP = (int *) ckalloc(j); X`09 DP = (int *) ckalloc(j); X`09`7D X`09 X#ifdef FAR_PTR X`09if (MT`5B0`5D==(char far *)NULL) `7B X`09 j = MX+1; X`09 MT`5B0`5D = (char far *) FCKALLOC(j); X`09 MT`5B1`5D = (char far *) FCKALLOC(j); X`09 MT`5B2`5D = (char far *) FCKALLOC(j); X`09 FT = (char far *) FCKALLOC(j); X X`09 j *= sizeof(int); X`09 MP`5B0`5D = (int far *) FCKALLOC(j); X`09 MP`5B1`5D = (int far *) FCKALLOC(j); X`09 MP`5B2`5D = (int far *) FCKALLOC(j); X`09 FP = (int far *) FCKALLOC(j); X`09`7D X#else X`09if (MT`5B0`5D==NULL) `7B X`09 j = MX+1; X`09 MT`5B0`5D = (char *) ckalloc(j); X`09 MT`5B1`5D = (char *) ckalloc(j); X`09 MT`5B2`5D = (char *) ckalloc(j); X`09 FT = (char *) ckalloc(j); X X`09 j *= sizeof(int); X`09 MP`5B0`5D = (int *) ckalloc(j); X`09 MP`5B1`5D = (int *) ckalloc(j); X`09 MP`5B2`5D = (int *) ckalloc(j); X`09 FP = (int *) ckalloc(j); X`09`7D X#endif X X `09c = align(A,B,M,N,low,up,0,0); X X`09check_score = CHECK_SCORE(A,B,M,N,S); X`09if (check_score != c) printf("\nCheck_score=%d\n", check_score); X`09return c; X X`7D X X X/* Alignment display routine */ X Xstatic char ALINE`5B51`5D, BLINE`5B51`5D, CLINE`5B51`5D; Xextern char *sq; X Xint DISPLAY(A,B,M,N,S,AP,BP) char A`5B`5D, B`5B`5D; int M, N; int S`5B`5D, A VP, BP; X`7B register char *a, *b, *c; X register int i, j, op; X int lines, ap, bp; X X i = j = op = lines = 0; X ap = AP; X bp = BP; X a = ALINE; X b = BLINE; X c = CLINE; X while (i < M `7C`7C j < N) X `7B if (op == 0 && *S == 0) X `7B op = *S++; X *a = sq`5BA`5B++i`5D`5D; X *b = sq`5BB`5B++j`5D`5D; X *c++ = (*a++ == *b++) ? '`7C' : ' '; X `7D X else X `7B if (op == 0) X op = *S++; X if (op > 0) X `7B *a++ = ' '; X *b++ = sq`5BB`5B++j`5D`5D; X op--; X `7D X else X `7B *a++ = sq`5BA`5B++i`5D`5D; X *b++ = ' '; X op++; X `7D X *c++ = '-'; X `7D X if (a >= ALINE+50 `7C`7C i >= M && j >= N) X `7B *a = *b = *c = '\0'; X printf("\n%5d ",50*lines++); X for (b = ALINE+10; b <= a; b += 10) X printf(" . :"); X if (b <= a+5) X printf(" ."); X printf("\n%5d %s\n %s\n%5d %s\n",ap,ALINE,CLINE,bp,BLINE); X`09 ap = AP + i; X`09 bp = BP + j; X a = ALINE; X b = BLINE; X c = CLINE; X `7D X `7D X`7D X X/* CHECK_SCORE - return the score of the alignment stored in S */ X Xstatic int CHECK_SCORE(A,B,M,N,S) char A`5B`5D, B`5B`5D; int M, N; int S`5B` V5D; X`7B`20 X register int i, j, op; X int score; X X score = i = j = op = 0; X while (i < M `7C`7C j < N) `7B X`09op = *S++; X`09if (op == 0)`20 X`09`09score = w`5BA`5B++i`5D`5D`5BB`5B++j`5D`5D + score; X`09else if (op > 0) `7B X`09`09score = score - (g+op*h); X`09`09j = j+op; X`09`7D else `7B X`09`09score = score - (g-op*h); X`09`09i = i-op; X`09`7D X `7D X return(score); X`7D X X X/* lib.c - library of C procedures. */ X X/* fatal - print message and die */ Xfatal(msg) Xchar *msg; X`7B X`09fprintf(stderr, "%s\n", msg); X`09exit(1); X`7D X X/* fatalf - format message, print it, and die */ Xfatalf(msg, val) Xchar *msg, *val; X`7B X`09fprintf(stderr, msg, val); X`09putc('\n', stderr); X`09exit(1); X`7D X`09 X/* ckopen - open file; check for success */ XFILE *ckopen(name, mode) Xchar *name, *mode; X`7B X`09FILE *fopen(), *fp; X X`09if ((fp = fopen(name, mode)) == NULL) X`09`09fatalf("Cannot open %s.", name); X`09return(fp); X`7D X X/* ckalloc - allocate space; check for success */ Xchar *ckalloc(amount) Xint amount; X`7B X`09char *malloc(), *p; X X`09if ((p = malloc( (unsigned) amount)) == NULL) X`09`09fatal("Ran out of memory."); X`09return(p); X`7D X X#ifdef FAR_PTR X#ifdef TURBOC X#define FMALLOC farmalloc X#define MTYPE long X#define FFREE farfree X#else X#define FMALLOC _fmalloc X#define MTYPE unsigned X#define FFREE _ffree X#endif X X/* fckalloc - allocate space; check for success */ Xchar far *fckalloc(amount) X`09int amount; X`7B X`09char far * FMALLOC(), far * p; X X`09if ((p = FMALLOC( (MTYPE) amount)) == (char far *)NULL) X`09`09fatal("Ran out of memory."); X`09return(p); X`7D X#endif $ CALL UNPACK G_BAND.C;1 912174725 $ create 'f' X;P Identity matrix for proteins X 4 60 50 5 2 80 4 X-12 -4 X@ * XA R N D C Q E G H I L K M F P S T W Y V B Z X X0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 2 6 0 X 6 `20 X -3 6 X -3 -3 6 X -3 -3 -3 6 X -3 -3 -3 -3 6 X -3 -3 -3 -3 -3 6 X -3 -3 -3 -3 -3 -3 6 X -3 -3 -3 -3 -3 -3 -3 6 X -3 -3 -3 -3 -3 -3 -3 -3 6 X -3 -3 -3 -3 -3 -3 -3 -3 -3 6 X -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 6 `20 X -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 6 X -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 6 X -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 6 X -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 6 X -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 6 X -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 6 X -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 6 X -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 6 X -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 6 X -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 6 X -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 6 X -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 X $ CALL UNPACK IDNAA.MAT;1 358121637 $ create 'f' X;P weighted protein identity matrix X 4 35 200 5 2 60 2 X -12 -4 X@ * XCSTPAGNDEQHRKMILVFYWX X0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 0 X12`20 X-3 2`20 X-3 -3 3`20 X-3 -3 -3 6`20 X-3 -3 -3 -3 2`20 X-3 -3 -3 -3 -3 5`20 X-3 -3 -3 -3 -3 -3 2`20 X-3 -3 -3 -3 -3 -3 -3 4`20 X-3 -3 -3 -3 -3 -3 -3 -3 4`20 X-3 -3 -3 -3 -3 -3 -3 -3 -3 4`20 X-3 -3 -3 -3 -3 -3 -3 -3 -3 -3 6`20 X-3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 6`20 X-3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 5`20 X-3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 6`20 X-3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 5`20 X-3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 6`20 X-3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 4`20 X-3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 9`20 X-3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 10`20 X-3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 17`20 X0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0`20 $ CALL UNPACK IDPAA.MAT;1 1983099772 $ create 'f' X.TH LALIGN/PLALIGN 1 local X.SH NAME Xlalign \- compare two protein or DNA sequences for local similarity and show V the local sequence alignments X Xplalign \- compare two sequences for local similarity and plot the local seq Vuence alignments X X.SH SYNOPSIS X.B lalign X`5B-msw`5D sequence-file-1 sequence-file-2 `5B X\&#-of-alignments X`5D X X.B plalign X`5B-msv`5D sequence-file-1 sequence-file-2 `5B X\&#-of-alignments X`5D X X.SH DESCRIPTION X.B lalign Xand X.B plalign Xprograms compare two sequences looking for local sequence Xsimilarities. X.B lalign/plalign Xuse code developed by X. Huang and W. Miller (Adv. Appl. Math. (1991) X12:337-357) for the "sim" program. While X.B ssearch Xreports only the best alignment between the query sequence and the Xlibrary sequence, X.B lalign Xand X.B plalign Xwill report a specified number of alignments (the default is 10) Xbetween the two sequences X.B lalign Xshows the actual local alignments between the two sequences and their Xscores, while X.B plalign Xproduces a plot of the alignments that looks similar to a X`60dot-matrix' homology plot. On Unix\(tm systems, X.B plalign Xgenerates tektronix output that can either be displayed on a Xtektronix terminal or piped through the X.B tek2ps Xprogram for output on the laser printer. XOn MS-DOS systems, X.B plalign Xuses the graphics capabilities of the computer screen together with Xthe *.BGI graphics device drivers supplied by Borland with Turbo X`60C'\(tm. X.PP XThe X.B lalign/plalign/fasta Xprograms use a standard text format sequence file. Lines beginning Xwith '>' or ';' are considered comments and ignored; sequences can be upper V or Xlower case, blanks,tabs and unrecognizable characters are ignored. X.B lalign/plalign Xexpect sequences to use the single letter amino acid codes, see X.B protcodes(1) X\&. X.SH OPTIONS X.PP X.B lalign Xand the other programs can be directed to change the scoring matrix, Xsearch parameters, output format, and default search directories by Xentering options on the command line (preceeded by a `60\-'). All of the Xoptions should preceed the file name and ktup arguments). Alternately, Xthese options can be changed by setting environment variables. The Xoptions and environment variables are: X.TP X\-m # X.B (MARKX) X=1,2,3. Alternate display of matches and mismatches in Xalignments. MARKX=1 uses ":","."," ", for identities, consevative Xreplacements, and non-conservative replacements, respectively. MARKX=2 Xuses " ","x", and "X". MARKX=3 does not show the second sequence, but Xuses the second alignment line to display matches with a "." for Xidentity, or with the mismatched residue for mismatches. MARKX=3 is Xuseful for aligning large numbers of similar sequences. X.TP X\-s str X.B (SMATRIX) Xthe filename of an alternative scoring matrix file. For protein Xsequences, PAM250 is used by default; PAM120 can be used with the Xcommand line option X.B -s 120\c X\&. X.TP X\-v str X.B (LINEVAL) X(plalign only) X.B plalign Xcan use up to 4 different line styles to denote the Xscores of local alignments. The scores that correspond to these Xline styles can be specified with the environment variable X.B LINVAL\c X\&, or with the X.B \-v Xoption. In either case, a string with three numbers separated by Xspaces should be given. This string must be surrounded by double Xquotation marks. For example, LINEVAL="200 100 50" tells plalign Xto use solid lines for local alignments with scores greater than 200, Xlong dashed lines for scores between 100 and 200, short dashed lines Xfor scores between 50 and 100, and dotted lines for scores less than 50. X.in +0.5i Xplalign -v "200 100 50" X.in -0.5i XNormally, the values are 200, 100, and 50 for protein sequence comparisons Xand 400, 200, and 100 for DNA sequence comparisons. X.TP X\-w # X.B (LINLEN) Xoutput line length for sequence alignments. (normally 60, Xcan be set up to 200). X.SH EXAMPLES X.TP X(1) X.B lalign Xmchu.aa mchu.aa X.PP XCompare the amino acid sequence in the file mchu.aa with itself and Xreport the ten best local alignments. Sequence files should have the form: X.nf X.in +5n X X>MCHU - Calmodulin - Human ... XADQLTEEQIAEF ... X.in +0n X X.fi X.TP X(2) X.B plalign Xqrhuld.aa egmsmg.aa 50 X.PP XDisplay the 50 best local alignments of the LDL Xreceptor (qrhuld.aa) with epidermal growth factor precursor X(egmsmg.aa). Plot the results on the screen. X.TP X(3) X.B lalign X.PP XRun the X.B lalign Xprogram in interactive mode. The program will prompt for Xthe name of two sequence files and the number of alignments to show. X.SH "SEE ALSO" Xssearch(1), rss(1), fasta(1), protcodes(5), dnacodes(5) X.SH AUTHOR XBill Pearson X.br Xwrp@virginia.EDU $ CALL UNPACK LALIGN.1;1 1534070188 $ create 'f' X/* align.c X`09protein driver for linear sequence comparison method X*/ X X#include X/*#include */ X Xchar *refstr="\nPlease cite:\n X. Huang and W. Miller (1991) Adv. Appl. Math V. 12:373-381\n"; X X#define TRUE 1 X#define FALSE 0 X X#ifndef BIGMEM X#define MAXTST 2000`09/* longest test sequence */ X#define MAXLIB 2000 X#define MAXDIAG (MAXTST+MAXLIB) X#else X#define MAXTST 10000 X#define MAXLIB 50000 X#define MAXDIAG (MAXTST+MAXLIB) X#endif X XFILE *outfd;`09`09/* fd for output file */ X X/* globals for matching */ X Xlong lmark;`09`09/* position in library file from ftell() */ X Xchar libstr`5B21`5D;`09/* partial title from library sequence */ Xchar name0`5B11`5D, name1`5B11`5D;`09/* for labeling output */ X Xchar *aa0=NULL, *aa1=NULL;`09/* amino acid sequence data */ Xchar *seqc0, *seqc1;`09/* aligned sequences */ Xlong sq0off=1, sq1off=1; X Xint dnaseq, lcont; Xint bktup, bkfact, scfact, bestoff, bestscale, histint, bestmax; X Xint nseq=2;`09`09/* same sequence twice */ Xint maxn;`09`09/* max space for lib sequence */ Xint n0, n1;`09/* length of aa0, length of aa1, n0+n1,`09diagonal offset */ Xlong loffset = 0l;`09`09/* offset into sequence */ X X/* the following are defaults for values that are read by X pam.c from *.mat if SMATRIX is defined */ X Xint nshow; char rline`5B20`5D,sline`5B20`5D; X X/* output options */ Xint showall,markx, llen; X Xchar ttitle`5B60`5D, ltitle`5B60`5D; X Xint smark`5B4`5D = `7B-10000,-10000,-10000,-10000`7D; X Xint min0,min1,max0,max1,mins; X#ifdef TPLOT Xchar lvstr`5B40`5D; X#endif X Xextern int optind; Xchar *libenv, *aaenv, *smptr; Xchar smstr`5B40`5D; X X#include "upam.gbl"`09`09/* includes pam array */ X Xmain(argc, argv) X int argc; char **argv; X`7B X`09char tname`5B40`5D, lname`5B40`5D, qline`5B40`5D; X`09int K; X`09int itemp, iln, nln; X`09char *calloc(), *getenv(), *cptr, *bp, *strchr(); X`09float percent; X X`09initenv(argc,argv); X X`09if ((aa0=calloc(MAXTST+MAXLIB,sizeof(char)))==0) `7B X`09`09fprintf(stderr," cannot allocate sequence array\n"); X`09`09exit(1); X`09`09`7D X`09maxn = MAXTST+MAXLIB; X X if (argc-optind < 3) `7B X#ifndef TPLOT X`09printf(" lalign 1.6b `5BNov, 1991`5D compares two sequences\n%s\n",refstr V); X#else X printf(" plalign 1.6b `5BNov, 1991`5D compares two sequences\n%s\n", Vrefstr); X#endif X`09l1:`09printf(" first sequence file name: "); X`09`09fflush(stdout); X`09`09fgets(tname,40,stdin); X`09`09if (tname`5Bstrlen(tname)-1`5D=='\n') tname`5Bstrlen(tname)-1`5D='\0'; X`09`09if (tname`5B0`5D=='\0') goto l1; X `09if ((n0=getseq(tname,aa0,maxn,&dnaseq))==0) `7B X fprintf(stderr," %s : %s sequence not found\n",tname,sqtyp Ve); X goto l1; X `7D X X`09`09resetp(dnaseq); X`09`09dnaseq = -1; X`09`09`09 X`09l2:`09printf(" second sequence file name: "); X`09`09fflush(stdout); X`09`09fgets(lname,40,stdin); X`09`09if (lname`5Bstrlen(lname)-1`5D=='\n') lname`5Bstrlen(lname)-1`5D='\0'; X`09`09if (*lname==0) goto l2; X X`09l3:`09printf(" number of local alignments `5B10`5D: "); X`09`09fflush(stdout); X`09`09if (fgets(rline,sizeof(rline),stdin)==NULL) K=10; X`09`09else `7B X`09`09 sscanf(rline,"%d",&K); X`09`09 if (K<1) K=10; X`09`09 `7D X `09`09`7D X`09else `7B X`09`09strncpy(tname,argv`5Boptind+1`5D,40); X `09if ((n0=getseq(tname,aa0,maxn,&dnaseq))==0) `7B X fprintf(stderr," %s : %s sequence not found\n",tname,sqtyp Ve); X exit(1); X `7D X`09`09resetp(dnaseq); X`09`09dnaseq = -1; X`09`09strncpy(lname,argv`5Boptind+2`5D,40); X`09`09if (argc > optind+3) sscanf(argv`5Boptind+3`5D,"%d",&K); X`09`09else K=10; X`09 `7D X X`09if (strcmp(tname,lname)==0) nseq=1; X`09else nseq=2; X X `09strncpy(name0,tname,6); X `09gettitle(tname,ttitle,50); X `09if (strlen(ttitle)>0) X`09`09if (*ttitle=='>') strncpy(name0,&ttitle`5B1`5D,6); X`09`09else strncpy(name0,ttitle,6); X`09else X`09`09strncpy(name0,tname,6); X`09name0`5B6`5D='\0'; X`09if ((bp=strchr(name0,' '))!=NULL) *bp='\0'; X X#ifdef TPLOT X`09outfd = stderr; X#else X`09outfd = stdout; X#endif X X`09aa1 = aa0 + n0 + 2; X`09maxn -= n0 + 3; X X`09if (nseq==2) `7B X`09`09n1=getseq(lname,aa1,maxn,&dnaseq); X`09`09gettitle(lname,ltitle,50); X`09`09if (strlen(ltitle)>0) X`09`09`09if (*ltitle=='>') strncpy(name1,<itle`5B1`5D,6); X`09`09`09else strncpy(name1,ltitle,6); X`09`09else strncpy(name1,lname,6); X`09`09name1`5B6`5D='\0'; X`09`09if ((bp=strchr(name1,' '))!=NULL) *bp='\0'; X`09`7D X`09else `7B X`09`09aa1 = aa0; X`09`09n1 = n0; X`09`09strncpy(name1,name0,6); X`09`09strncpy(ltitle,ttitle,sizeof(ltitle)); X`09`7D X X `09fprintf(outfd," Comparison of:\n(A) %-10s %-50s - %d %s\n", X`09`09tname,ttitle,n0,sqnam); X`09fprintf(outfd,"(B) %-10s %-50s - %d %s\n",lname,ltitle,n1,sqnam); X`09if (strlen(smptr)>0) fprintf(outfd," using matrix file %s\n",smptr); X`09else fprintf(outfd," using %s matrix\n",sqtype); X X`09initseq(min(n0,n1)*5/4); X X`09initpam2();`09/* convert 1-d pam to 2-d pam2 */ X X#ifdef TPLOT X`09openplt((long)n0,(long)n1); X`09if (nseq==1) drawdiag((long)n0,(long)n1); X`09SIM(aa0-1,aa1-1,n0,n1,K,pam2,-(gdelval-ggapval),-ggapval,nseq); X`09closeplt(); X#else X`09SIM(aa0-1,aa1-1,n0,n1,K,pam2,-(gdelval-ggapval),-ggapval,nseq); X#endif X`09exit(0); X`09`7D X Xextern int *sascii, nascii`5B`5D, aascii`5B`5D; X Xinitenv(argc,argv) X`09int argc; X`09char **argv; X`7B X`09char *cptr, *getenv(); X`09int copt, getopt(); X`09extern char *optarg; X X`09libenv="\0"; X`09aaenv="\0"; X X`09sascii = aascii; X`09pam = apam; X`09sq = aa; X`09hsq = haa; X`09nsq = naa; X`09dnaseq = 0; X X`09showall = 1; X X`09if ((cptr=getenv("LINLEN"))!=NULL) sscanf(cptr,"%d",&llen); X`09else llen = 60; X`09if (llen>=200) llen=200-1; X`09markx=0; X`09if ((cptr=getenv("MARKX"))==NULL) markx=0; X`09else sscanf(cptr,"%d",&markx); X X`09while ((copt=getopt(argc,argv,"nm:s:w:v:x:"))!=EOF) X`09 switch(copt) `7B X`09 case 'w': sscanf(optarg,"%d",&llen); break; X`09 case 'n': dnaseq=1; X`09 sascii = nascii; X`09 sq = nt; X`09 nsq = nnt; X`09 hsq = hnt; X`09 pam = npam; X`09 strcpy(sqnam,"nt"); X`09 strcpy(sqtype,"DNA"); X`09 resetp(dnaseq); X`09 break; X`09 case 'm': sscanf(optarg,"%d",&markx); break; X`09 case 's': strncpy(smstr,optarg,sizeof(smstr)); X`09 smptr = smstr; X`09 if (initpam(smptr)) `7B X`09 dnaseq= -1; X`09 `7D X`09 else smptr="\0"; X`09 break; X`09 case 'x': sscanf(optarg,"%ld %ld",&sq0off,&sq1off); X`09 break; X#ifdef TPLOT X`09 case 'v': strncpy(lvstr,optarg,sizeof(lvstr)); X`09 break; X#endif X`09 default : fprintf(stderr," illegal option -%c\n",copt); X`09 `7D X`09optind--; X`09if (dnaseq>=0) `7B X`09`09if ((smptr=getenv("SMATRIX"))!=NULL && initpam(smptr)) `7B X`09`09`09dnaseq = -1; X`09`09`09`7D X`09`09else smptr="\0"; X`09`09`7D X`09if (strlen(smptr)>0) fprintf(stderr," using matrix file %s\n",smptr); X`09`7D X Xresetp(dnaseq) X`09int dnaseq; X`7B X`09if (dnaseq==1) pam = npam; X`09`7D X Xint match, mismh; X Xinitpam2() X`7B X`09int i, j, k, tmp; X X`09match = -1000; mismh = 1000; X`09k=0; X`09for (i=0; imatch) match=tmp; X`09`09`09if (tmp0) `7B X`09*sp0++ = '-'; X`09*sp1++ = sq`5Baa1`5Bi1++`5D`5D; X`09op--; X`09lenc++; X `7D X else `7B X`09*sp0++ = sq`5Baa0`5Bi0++`5D`5D; X`09*sp1++ = '-'; X`09op++; X`09lenc++; X `7D X `7D X `7D X X *nident = nid; X *nc = lenc; X/*`09now we have the middle, get the right end */ X nd = 0; X return mins+lenc+nd; X`7D X Xinitseq(seqsiz)`09`09/* initialize arrays */ X`09int seqsiz; X`7B X`09char *calloc(); X X`09seqc0=calloc(seqsiz,sizeof(char)); X`09seqc1=calloc(seqsiz,sizeof(char)); X`09if (seqc0==NULL `7C`7C seqc1==NULL) X`09`09`7Bfprintf(stderr,"cannot allocate consensus arrays %d\n",seqsiz); X`09`09 exit();`7D X`09`7D X Xfreeseq() X`7B X`09free(seqc0); free(seqc1); X`09`7D X $ CALL UNPACK LALIGN.C;1 1316324809 $ create 'f' X>LCBO - Prolactin precursor - Bovine XMDSKGSSQKGSRLLLLLVVSNLLLCQGVVSTPVCPNGPGNCQVSLRDLFDRAVMVSHYIHDLSS XEMFNEFDKRYAQGKGFITMALNSCHTSSLPTPEDKEQAQQTHHEVLMSLILGLLRSWNDPLYHL XVTEVRGMKGAPDAILSRAIEIEEENKRLLEGMEMIFGQVIPGAKETEPYPVWSGLPSLQTKDED XARYSAFYNLLHCLRRDSSKIDTYLKLLNCRIIYNNNC* $ CALL UNPACK LCBO.AA;1 23615655 $ create 'f' X>P1;LCBO XProlactin precursor - Bovine XMDSKGSSQKGSRLLLLLVVSNLLLCQGVVSTPVCPNGPGNCQVSLRDLFDRAVMVSHYIHDLSS XEMFNEFDKRYAQGKGFITMALNSCHTSSLPTPEDKEQAQQTHHEVLMSLILGLLRSWNDPLYHL XVTEVRGMKGAPDAILSRAIEIEEENKRLLEGMEMIFGQVIPGAKETEPYPVWSGLPSLQTKDED XARYSAFYNLLHCLRRDSSKIDTYLKLLNCRIIYNNNC* $ CALL UNPACK LCBO.VMS;1 393553830 $ create 'f' Xll_band.obj g_band.obj pam.obj time.obj getopt.obj lfgetaa.obj $ CALL UNPACK LFASTA.RSP;1 1879917898 $ create 'f' X/* A PACKAGE FOR SEQUENCE COMPARISON WITH AFFINE WEIGHTS */ X/* Here we maximize the similarity score */ X X/* Globally passed params and macros */ X X#include X X#ifdef BIGMEM X#define NMAX 80000 X#else X#define NMAX 3000 X#endif X Xstatic int CHECK_SCORE(); X Xstatic int (*w)`5B32`5D;`09`09`09`09/* w = W */ Xstatic int g, h, m;`09`09`09`09/* g = G, h = H, m = g+h */ X X#define gap(k) ((k) <= 0 ? 0 : g+h*(k))`09/* k-symbol indel cost */ X Xstatic int *sapp;`09`09`09`09/* Current script append ptr */ Xstatic int last;`09`09`09`09/* Last script op appended */ X X`09`09`09`09`09`09/* Append "Delete k" op */ X#define DEL(k)`09`09`09`09\ X`7B if (last < 0)`09`09`09`09\ X last = sapp`5B-1`5D -= (k);`09`09\ X else`09`09`09`09`09\ X last = *sapp++ = -(k);`09`09\ X`7D X`09`09`09`09`09`09/* Append "Insert k" op */ X#define INS(k)`09`09`09`09\ X`7B if (last < 0)`09`09`09`09\ X `7B sapp`5B-1`5D = (k); *sapp++ = last; `7D`09\ X else`09`09`09`09`09\ X last = *sapp++ = (k);`09`09\ X`7D X X#define REP `7B last = *sapp++ = 0; `7D`09`09/* Append "Replace" op */ X Xstatic int CC`5BNMAX+1`5D, DD`5BNMAX+1`5D;`09/* Forward cost-only vectors */ Xstatic int RR`5BNMAX+1`5D, SS`5BNMAX+1`5D;`09/* Reverse cost-only vectors */ X X/* align(A,B,M,N,tb,te) returns the cost of an optimum conversion between X A`5B1..M`5D and B`5B1..N`5D that begins(ends) with a delete if tb(te) is V zero X and appends such a conversion to the current script. */ X Xstatic int align(A,B,M,N,tb,te) char *A, *B; int M, N; int tb, te; X X`7B int midi, midj, type;`09/* Midpoint, type, and cost */ X int midc; X`09 int c1, c2; X X`7B register int i, j; X register int c, e, d, s; X int t, *wa; X X/* Boundary cases: M <= 1 or N == 0 */ X X if (N <= 0) X `7B if (M > 0) DEL(M) X return -gap(M); X `7D X if (M <= 1) X `7B if (M <= 0) X `7B INS(N); X return -gap(N); X `7D X if (tb < te) tb = te; X midc = (tb-h) - gap(N); X midj = 0; X wa = w`5BA`5B1`5D`5D; X for (j = 1; j <= N; j++) X `7B c = -gap(j-1) + wa`5BB`5Bj`5D`5D - gap(N-j); X if (c > midc) X `7B midc = c; X midj = j; X `7D X `7D X if (midj == 0) X `7B INS(N) DEL(1) `7D X else X `7B if (midj > 1) INS(midj-1) X REP X if (midj < N) INS(N-midj) X `7D X return midc; X `7D X X/* Divide: Find optimum midpoint (midi,midj) of cost midc */ X X midi = M/2;`09`09`09/* Forward phase: */ X CC`5B0`5D = 0;`09`09`09/* Compute C(M/2,k) & D(M/2,k) for all k */ X t = -g; X for (j = 1; j <= N; j++) X `7B CC`5Bj`5D = t = t-h; X DD`5Bj`5D = t-g; X `7D X t = tb; X for (i = 1; i <= midi; i++) X `7B s = CC`5B0`5D; X CC`5B0`5D = c = t = t-h; X e = t-g; X wa = w`5BA`5Bi`5D`5D; X for (j = 1; j <= N; j++) X `7B if ((c = c - m) > (e = e - h)) e = c; X if ((c = CC`5Bj`5D - m) > (d = DD`5Bj`5D - h)) d = c; X c = s + wa`5BB`5Bj`5D`5D; X if (e > c) c = e; X if (d > c) c = d; X s = CC`5Bj`5D; X CC`5Bj`5D = c; X DD`5Bj`5D = d; X `7D X `7D X DD`5B0`5D = CC`5B0`5D; X X RR`5BN`5D = 0;`09`09`09/* Reverse phase: */ X t = -g;`09`09`09/* Compute R(M/2,k) & S(M/2,k) for all k */ X for (j = N-1; j >= 0; j--) X `7B RR`5Bj`5D = t = t-h; X SS`5Bj`5D = t-g; X `7D X t = te; X for (i = M-1; i >= midi; i--) X `7B s = RR`5BN`5D; X RR`5BN`5D = c = t = t-h; X e = t-g; X wa = w`5BA`5Bi+1`5D`5D; X for (j = N-1; j >= 0; j--) X `7B if ((c = c - m) > (e = e - h)) e = c; X if ((c = RR`5Bj`5D - m) > (d = SS`5Bj`5D - h)) d = c; X c = s + wa`5BB`5Bj+1`5D`5D; X if (e > c) c = e; X if (d > c) c = d; X s = RR`5Bj`5D; X RR`5Bj`5D = c; X SS`5Bj`5D = d; X `7D X `7D X SS`5BN`5D = RR`5BN`5D; X X midc = CC`5B0`5D+RR`5B0`5D;`09`09/* Find optimal midpoint */ X midj = 0; X type = 1; X for (j = 0; j <= N; j++) X if ((c = CC`5Bj`5D + RR`5Bj`5D) >= midc) X if (c > midc `7C`7C CC`5Bj`5D != DD`5Bj`5D && RR`5Bj`5D == SS`5Bj`5D) X `7B midc = c; X midj = j; X `7D X for (j = N; j >= 0; j--) X if ((c = DD`5Bj`5D + SS`5Bj`5D + g) > midc) X `7B midc = c; X midj = j; X type = 2; X `7D X`7D X X/* Conquer: recursively around midpoint */ X X if (type == 1) X `7B c1 = align(A,B,midi,midj,tb,-g); X c2 = align(A+midi,B+midj,M-midi,N-midj,-g,te); X `7D X else X `7B align(A,B,midi-1,midj,tb,0); X DEL(2); X align(A+midi+1,B+midj,M-midi-1,N-midj,0,te); X `7D X return midc; X`7D X X/* Interface and top level of comparator */ X Xint ALIGN(A,B,M,N,W,G,H,S) char A`5B`5D,B`5B`5D; int M,N; int W`5B`5D`5B32`5 VD,G,H; int S`5B`5D; X X`7B`20 X int c, ck; X X if (N > NMAX) return -1;`09/* Error check */ X X w = W;`09`09`09/* Setup global parameters */ X g = G; X h = H; X m = g+h; X sapp = S; X last = 0; X X c = align(A,B,M,N,-g,-g);`09/* OK, do it */ X ck = CHECK_SCORE(A,B,M,N,S); X if (c != ck) printf("Check_score error.\n"); X return c; X`7D X X/* Alignment display routine */ X Xstatic char ALINE`5B51`5D, BLINE`5B51`5D, CLINE`5B51`5D; X Xint DISPLAY(A,B,M,N,S,AP,BP) char A`5B`5D, B`5B`5D; int M, N; int S`5B`5D, A VP, BP; X`7B register char *a, *b, *c; X register int i, j, op; X int lines, ap, bp; X X i = j = op = lines = 0; X ap = AP; X bp = BP; X a = ALINE; X b = BLINE; X c = CLINE; X while (i < M `7C`7C j < N) X `7B if (op == 0 && *S == 0) X `7B op = *S++; X *a = A`5B++i`5D; X *b = B`5B++j`5D; X *c++ = (*a++ == *b++) ? '`7C' : ' '; X `7D X else X `7B if (op == 0) X op = *S++; X if (op > 0) X `7B *a++ = ' '; X *b++ = B`5B++j`5D; X op--; X `7D X else X `7B *a++ = A`5B++i`5D; X *b++ = ' '; X op++; X `7D X *c++ = '-'; X `7D X if (a >= ALINE+50 `7C`7C i >= M && j >= N) X `7B *a = *b = *c = '\0'; X printf("\n%5d ",50*lines++); X for (b = ALINE+10; b <= a; b += 10) X printf(" . :"); X if (b <= a+5) X printf(" ."); X printf("\n%5d %s\n %s\n%5d %s\n",ap,ALINE,CLINE,bp,BLINE); X`09 ap = AP + i; X`09 bp = BP + j; X a = ALINE; X b = BLINE; X c = CLINE; X `7D X `7D X`7D X X/* CHECK_SCORE - return the score of the alignment stored in S */ X Xstatic int CHECK_SCORE(A,B,M,N,S) char A`5B`5D, B`5B`5D; int M, N; int S`5B` V5D; X`7B`20 X register int i, j, op; X int score; X X score = i = j = op = 0; X while (i < M `7C`7C j < N) `7B X`09op = *S++; X`09if (op == 0)`20 X`09`09score = w`5BA`5B++i`5D`5D`5BB`5B++j`5D`5D + score; X`09else if (op > 0) `7B X`09`09score = score - (g+op*h); X`09`09j = j+op; X`09`7D else `7B X`09`09score = score - (g-op*h); X`09`09i = i-op; X`09`7D X `7D X return(score); X`7D X X/* lib.c - library of C procedures. */ X X/* fatal - print message and die */ Xfatal(msg) Xchar *msg; X`7B X`09fprintf(stderr, "%s\n", msg); X`09exit(1); X`7D X X/* fatalf - format message, print it, and die */ Xfatalf(msg, val) Xchar *msg, *val; X`7B X`09fprintf(stderr, msg, val); X`09putc('\n', stderr); X`09exit(1); X`7D X`09 X/* ckopen - open file; check for success */ XFILE *ckopen(name, mode) Xchar *name, *mode; X`7B X`09FILE *fopen(), *fp; X X`09if ((fp = fopen(name, mode)) == NULL) X`09`09fatalf("Cannot open %s.", name); X`09return(fp); X`7D X X/* ckalloc - allocate space; check for success */ Xchar *ckalloc(amount) Xint amount; X`7B X`09char *malloc(), *p; X X`09if ((p = malloc( (unsigned) amount)) == NULL) X`09`09fatal("Ran out of memory."); X`09return(p); X`7D $ CALL UNPACK LLMAX.C;1 1919205613 $ create 'f' X X/* A PACKAGE FOR SEQUENCE COMPARISON WITH AFFINE WEIGHTS */ X/* Maximizes a similarity score and doesn't penalize end-gaps */ X X/* Globally passed params and macros */ X X#include X#ifdef BIGMEM X#define NMAX 80000 X#else X#define NMAX 3000 X#endif X Xstatic int CHECK_SCORE(); X Xstatic int (*w)`5B32`5D;`09`09`09`09/* w = W */ Xstatic int g, h, m;`09`09`09`09/* g = G, h = H, m = g+h */ X X#define gap(k) ((k) <= 0 ? 0 : g+h*(k))`09/* k-symbol indel cost */ X Xstatic int *sapp;`09`09`09`09/* Current script append ptr */ Xstatic int last;`09`09`09`09/* Last script op appended */ X X`09`09`09`09`09`09/* Append "Delete k" op */ X#define DEL(k)`09`09`09`09\ X`7B if (last < 0)`09`09`09`09\ X last = sapp`5B-1`5D -= (k);`09`09\ X else`09`09`09`09`09\ X last = *sapp++ = -(k);`09`09\ X`7D X`09`09`09`09`09`09/* Append "Insert k" op */ X#define INS(k)`09`09`09`09\ X`7B if (last < 0)`09`09`09`09\ X `7B sapp`5B-1`5D = (k); *sapp++ = last; `7D`09\ X else`09`09`09`09`09\ X last = *sapp++ = (k);`09`09\ X`7D X X#define REP `7B last = *sapp++ = 0; `7D`09`09/* Append "Replace" op */ X Xstatic int CC`5BNMAX+1`5D, DD`5BNMAX+1`5D;`09/* Forward cost-only vectors */ Xstatic int RR`5BNMAX+1`5D, SS`5BNMAX+1`5D;`09/* Reverse cost-only vectors */ X X/* align(A,B,M,N,tb,te) returns the cost of an optimum conversion between X A`5B1..M`5D and B`5B1..N`5D that begins(ends) with a delete if tb(te) is V zero X and appends such a conversion to the current script. */ X Xstatic int align(A,B,M,N,tb,te,topr,botr,lc,rc) char *A, *B; int M, N; Xint tb, te; char topr, botr, lc, rc; X X`7B int midi, midj, type;`09/* Midpoint, type, and cost */ X int midc; X`09 int c1, c2; X X`7B register int i, j; X register int c, e, d, s; X int t, *wa; X X/* Boundary cases: M <= 1 or N == 0 */ X X if (N <= 0) X `7B if (M > 0) DEL(M) X if (topr `7C`7C botr) return 0; X else return -gap(M); X `7D X if (M <= 1) X `7B if (M <= 0) X `7B INS(N); X`09 if (topr `7C`7C botr) return 0; X else return -gap(N); X `7D X if (topr) `7B X`09 if (rc) midc = 0; X`09 else midc = te-h; X`09 midj = 0; X`09 wa = w`5BA`5B1`5D`5D; X`09 for (j = 1; j <= N; j++) X`09 `7B c = wa`5BB`5Bj`5D`5D - gap(N-j); X if (c > midc) X `7B midc = c; X midj = j; X `7D X `7D X `7D else if (botr) `7B X`09 if (lc) midc = 0; X`09 else midc = tb-h; X`09 midj = 0; X`09 wa = w`5BA`5B1`5D`5D; X`09 for (j = 1; j <= N; j++) X`09 `7B c = -gap(j-1) + wa`5BB`5Bj`5D`5D; X if (c > midc) X `7B midc = c; X midj = j; X `7D X `7D X `7D else `7B X if (tb < te) tb = te; X`09 if (lc `7C`7C rc) midc = -gap(N); X else midc = (tb-h) - gap(N); X midj = 0; X wa = w`5BA`5B1`5D`5D; X for (j = 1; j <= N; j++) X `7B c = -gap(j-1) + wa`5BB`5Bj`5D`5D - gap(N-j); X if (c > midc) X `7B midc = c; X midj = j; X `7D X `7D X `7D X if (midj == 0) X `7B INS(N) DEL(1) `7D X else X `7B if (midj > 1) INS(midj-1) X REP X if (midj < N) INS(N-midj) X `7D X return midc; X `7D X X/* Divide: Find optimum midpoint (midi,midj) of cost midc */ X X midi = M/2;`09`09`09/* Forward phase: */ X CC`5B0`5D = 0;`09`09`09/* Compute C(M/2,k) & D(M/2,k) for all k */ X if (topr) `7B X`09for (j = 1; j <= N; j++) X`09 `7B CC`5Bj`5D = 0; X`09 DD`5Bj`5D = -g; X`09 `7D X `7D else `7B X `09t = -g; X `09for (j = 1; j <= N; j++) X `09`7B CC`5Bj`5D = t = t-h; X `09 DD`5Bj`5D = t-g; X `7D X `7D X t = tb; X for (i = 1; i <= midi; i++) X `7B s = CC`5B0`5D; X if (lc) `7B X`09CC`5B0`5D = c = 0; X`09e = -g; X `7D else `7B X CC`5B0`5D = c = t = t-h; X e = t-g; X `7D X wa = w`5BA`5Bi`5D`5D; X for (j = 1; j <= N; j++) X `7B if ((c = c - m) > (e = e - h)) e = c; X`09 if ((j == N) && rc) `7B X if ((c = CC`5Bj`5D) > (d = DD`5Bj`5D)) d = c; X`09 `7D else `7B `20 X if ((c = CC`5Bj`5D - m) > (d = DD`5Bj`5D - h)) d = c; X`09 `7D X c = s + wa`5BB`5Bj`5D`5D; X if (e > c) c = e; X if (d > c) c = d; X s = CC`5Bj`5D; X CC`5Bj`5D = c; X DD`5Bj`5D = d; X `7D X `7D X DD`5B0`5D = CC`5B0`5D; X X RR`5BN`5D = 0;`09`09`09/* Reverse phase: */ X `09`09`09`09/* Compute R(M/2,k) & S(M/2,k) for all k */ X if (botr) `7B X`09for (j = N-1; j >= 0; j--) X`09 `7B RR`5Bj`5D = 0; X`09 SS`5Bj`5D = -g; X `7D X `7D else `7B X `09t = -g; X `09for (j = N-1; j >= 0; j--) X `09`7B RR`5Bj`5D = t = t-h; X `09 SS`5Bj`5D = t-g; X `09`7D X `7D X t = te; X for (i = M-1; i >= midi; i--) X `7B s = RR`5BN`5D; X if (rc) `7B X`09RR`5BN`5D = c = 0; X`09e = -g; X `7D else `7B X `09RR`5BN`5D = c = t = t-h; X `09e = t-g; X `7D X wa = w`5BA`5Bi+1`5D`5D; X for (j = N-1; j >= 0; j--) X `7B if ((c = c - m) > (e = e - h)) e = c; X`09 if ((j == 0) && lc) `7B X if ((c = RR`5Bj`5D) > (d = SS`5Bj`5D)) d = c; X`09 `7D else `7B X if ((c = RR`5Bj`5D - m) > (d = SS`5Bj`5D - h)) d = c; X`09 `7D X c = s + wa`5BB`5Bj+1`5D`5D; X if (e > c) c = e; X if (d > c) c = d; X s = RR`5Bj`5D; X RR`5Bj`5D = c; X SS`5Bj`5D = d; X `7D X `7D X SS`5BN`5D = RR`5BN`5D; X X midc = CC`5B0`5D+RR`5B0`5D;`09`09/* Find optimal midpoint */ X midj = 0; X type = 1; X for (j = 0; j <= N; j++) X if ((c = CC`5Bj`5D + RR`5Bj`5D) >= midc) X if (c > midc `7C`7C CC`5Bj`5D != DD`5Bj`5D && RR`5Bj`5D == SS`5Bj`5D) X `7B midc = c; X midj = j; X `7D X if (rc) `7B X if ((c = DD`5BN`5D + SS`5BN`5D) > midc) X `7B midc = c; X midj = N; X type = 2; X `7D X `7D else `7B X if ((c = DD`5BN`5D + SS`5BN`5D + g) > midc) X `7B midc = c; X midj = N; X type = 2; X `7D X `7D X for (j = N-1; j > 0; j--) X if ((c = DD`5Bj`5D + SS`5Bj`5D + g) > midc) X `7B midc = c; X midj = j; X type = 2; X `7D X if (lc) `7B X if ((c = DD`5B0`5D + SS`5B0`5D) > midc) X `7B midc = c; X midj = 0; X type = 2; X `7D X `7D else `7B X if ((c = DD`5B0`5D + SS`5B0`5D + g) > midc) X `7B midc = c; X midj = 0; X type = 2; X `7D X `7D X`7D X X/* Conquer: recursively around midpoint */ X X if (midj == 0 `7C`7C midj == N) `7B X if (type == 1) X `7B align(A,B,midi,midj,tb,-g,topr,0,lc,rc); X align(A+midi,B+midj,M-midi,N-midj,-g,te,0,botr,lc,rc); X `7D X else X `7B align(A,B,midi-1,midj,tb,0,topr,0,lc,rc); X DEL(2); X align(A+midi+1,B+midj,M-midi-1,N-midj,0,te,0,botr,lc,rc); X `7D X `7D else `7B X if (type == 1) X `7B align(A,B,midi,midj,tb,-g,topr,0,lc,0); X align(A+midi,B+midj,M-midi,N-midj,-g,te,0,botr,0,rc); X `7D X else X `7B align(A,B,midi-1,midj,tb,0,topr,0,lc,0); X DEL(2); X align(A+midi+1,B+midj,M-midi-1,N-midj,0,te,0,botr,0,rc); X `7D X `7D X return midc; X`7D X X/* Interface and top level of comparator */ X Xint ALIGN(A,B,M,N,W,G,H,S) char A`5B`5D,B`5B`5D; int M,N; int W`5B`5D`5B32`5 VD,G,H; int S`5B`5D; X X`7B`20 X int c, ck; X int t; X X if (N > NMAX) return -1;`09/* Error check */ X X w = W;`09`09`09/* Setup global parameters */ X g = G; X h = H; X m = g+h; X sapp = S; X last = 0; X X c = align(A,B,M,N,-g,-g,1,1,1,1); /* OK, do it */ X if ((abs(S`5B0`5D) < abs(S`5B1`5D)) && S`5B0`5D != 0) `7B X t = S`5B1`5D; X S`5B1`5D = S`5B0`5D; X S`5B0`5D = t; X `7D X if ((abs(sapp`5B0`5D) < abs(sapp`5B-1`5D)) && sapp`5B0`5D != 0) `7B X t = sapp`5B-1`5D; X sapp`5B-1`5D = sapp`5B0`5D; X sapp`5B0`5D = t; X `7D X ck = CHECK_SCORE(A,B,M,N,S); X if (c != ck) printf("Check_score error. c=%d, ck=%d\n",c,ck); X return c; X`7D X X/* Alignment display routine */ X Xstatic char ALINE`5B51`5D, BLINE`5B51`5D, CLINE`5B51`5D; X Xint DISPLAY(A,B,M,N,S,AP,BP) char A`5B`5D, B`5B`5D; int M, N; int S`5B`5D, A VP, BP; X`7B register char *a, *b, *c; X register int i, j, op; X int lines, ap, bp; X X i = j = op = lines = 0; X ap = AP; X bp = BP; X a = ALINE; X b = BLINE; X c = CLINE; X while (i < M `7C`7C j < N) X `7B if (op == 0 && *S == 0) X `7B op = *S++; X *a = A`5B++i`5D; X *b = B`5B++j`5D; X *c++ = (*a++ == *b++) ? '`7C' : ' '; X `7D X else X `7B if (op == 0) X op = *S++; X if (op > 0) X `7B *a++ = ' '; X *b++ = B`5B++j`5D; X op--; X `7D X else X `7B *a++ = A`5B++i`5D; X *b++ = ' '; X op++; X `7D X *c++ = '-'; X `7D X if (a >= ALINE+50 `7C`7C i >= M && j >= N) X `7B *a = *b = *c = '\0'; X printf("\n%5d ",50*lines++); X for (b = ALINE+10; b <= a; b += 10) X printf(" . :"); X if (b <= a+5) X printf(" ."); X printf("\n%5d %s\n %s\n%5d %s\n",ap,ALINE,CLINE,bp,BLINE); X`09 ap = AP + i; X`09 bp = BP + j; X a = ALINE; X b = BLINE; X c = CLINE; X `7D X `7D X`7D X X/* CHECK_SCORE - return the score of the alignment stored in S */ X Xstatic int CHECK_SCORE(A,B,M,N,S) char A`5B`5D, B`5B`5D; int M, N; int S`5B` V5D; X`7B`20 X register int i, j, op; X int score; X X score = i = j = op = 0; X while (i < M `7C`7C j < N) `7B X`09op = *S++; X`09if (i == 0 && j == 0 && op != 0) `7B X`09`09if (op > 0) j = j+op; X`09`09else i = i-op; X`09`7D else if (i == M `7C`7C j == N) `7B X`09`09i = M; X`09`09j = N; X`09`7D else if (op == 0)`20 X`09`09score = w`5BA`5B++i`5D`5D`5BB`5B++j`5D`5D + score; X`09else if (op > 0) `7B X`09`09score = score - (g+op*h); X`09`09j = j+op; X`09`7D else `7B X`09`09score = score - (g-op*h); X`09`09i = i-op; X`09`7D X `7D X return(score); X`7D X X/* lib.c - library of C procedures. */ X X/* fatal - print message and die */ Xfatal(msg) Xchar *msg; X`7B X`09fprintf(stderr, "%s\n", msg); X`09exit(1); X`7D X X/* fatalf - format message, print it, and die */ Xfatalf(msg, val) Xchar *msg, *val; X`7B X`09fprintf(stderr, msg, val); X`09putc('\n', stderr); X`09exit(1); X`7D X`09 X/* ckopen - open file; check for success */ XFILE *ckopen(name, mode) Xchar *name, *mode; X`7B X`09FILE *fopen(), *fp; X X`09if ((fp = fopen(name, mode)) == NULL) X`09`09fatalf("Cannot open %s.", name); X`09return(fp); X`7D X X/* ckalloc - allocate space; check for success */ Xchar *ckalloc(amount) Xint amount; X`7B X`09char *malloc(), *p; X X`09if ((p = malloc( (unsigned) amount)) == NULL) X`09`09fatal("Ran out of memory."); X`09return(p); X`7D X $ CALL UNPACK LLMAX0.C;1 673847453 $ create 'f' X X#include X X/* extern char name0`5B`5D, name1`5B`5D; */ X/* extern int match, mismh; */ Xextern char *sq, sqnam`5B`5D, *seqc0, *seqc1; Xextern char ttitle`5B`5D, ltitle`5B`5D; Xextern int min0,min1,max0,max1; Xextern int smin0, smin1; Xint gscore; X X#define min(x,y) ((x)<=(y) ? (x) : (y)) X Xextern FILE *outfd; X Xstatic int (*v)`5B32`5D;`09`09`09/* substitution scores */ Xstatic int q, r;`09`09`09/* gap penalties */ Xstatic int qr;`09`09`09`09/* qr = q + r */ X X#ifdef FAR_PTR Xtypedef struct ONE X`09`7B int COL ; struct ONE far * NEXT ;`7D X`09pair, far * pairptr; Xpairptr far *row, z;`09`09/* for saving used aligned pairs */ X#define PAIRNULL (pairptr)NULL X#else Xtypedef struct ONE `7B int COL ; struct ONE *NEXT ;`7D pair, *pairptr; Xpairptr *row, z; `09`09`09/* for saving used aligned pairs */ X#define PAIRNULL (pairptr)NULL X#endif Xstatic int tt; X Xtypedef struct NODE X`09`7B int SCORE; X`09 int STARI; X`09 int STARJ; X`09 int ENDI; X`09 int ENDJ; X`09 int TOP; X`09 int BOT; X`09 int LEFT; X`09 int RIGHT; `7D vertex, X#ifdef FAR_PTR X far *vertexptr; X#else X *vertexptr; X#endif X`09`09 Xvertexptr *LIST;`09`09`09/* an array for saving k best scores */ Xvertexptr low = 0;`09`09`09/* lowest score node in LIST */ Xvertexptr most = 0;`09`09`09/* latestly accessed node in LIST */ Xstatic int numnode;`09`09`09/* the number of nodes in LIST */ X Xstatic int *CC, *DD;`09`09`09/* saving matrix scores */ Xstatic int *RR, *SS, *EE, *FF; `09`09/* saving start-points */ Xstatic int *HH, *WW;`09`09 `09/* saving matrix scores */ Xstatic int *II, *JJ, *XX, *YY; `09`09/* saving start-points */ Xstatic int m1, mm, n1, nn;`09`09/* boundaries of recomputed area */ Xstatic int rl, cl;`09`09`09/* left and top boundaries */ Xstatic int lmin;`09`09`09/* minimum score in LIST */ Xstatic int flag;`09`09`09/* indicate if recomputation necessary*/ X X/* DIAG() assigns value to x if (ii,jj) is never used before */ X#define DIAG(ii, jj, x, value)`09`09`09`09\ X`7B for ( tt = 1, z = row`5B(ii)`5D; z != PAIRNULL; z = z->NEXT )`09\ X if ( z->COL == (jj) )`09`09`09`09\ X `7B tt = 0; break; `7D`09`09`09`09\ X if ( tt )`09`09`09`09`09`09\ X x = ( value );`09`09`09`09`09\ X`7D X X/* replace (ss1, xx1, yy1) by (ss2, xx2, yy2) if the latter is large */ X#define ORDER(ss1, xx1, yy1, ss2, xx2, yy2)`09`09\ X`7B if ( ss1 < ss2 )`09`09`09`09`09\ X `7B ss1 = ss2; xx1 = xx2; yy1 = yy2; `7D`09`09\ X else`09`09`09`09`09`09`09\ X if ( ss1 == ss2 )`09`09`09`09`09\ X `7B if ( xx1 < xx2 )`09`09`09`09\ X`09 `7B xx1 = xx2; yy1 = yy2; `7D`09`09`09\ X`09else`09`09`09`09`09`09\ X`09 if ( xx1 == xx2 && yy1 < yy2 )`09`09\ X`09 yy1 = yy2;`09`09`09`09`09\ X `7D`09`09`09`09`09`09`09\ X`7D X X/* The following definitions are for function diff() */ X Xint diff(), display(); Xstatic int zero = 0;`09`09`09`09/* int type zero */ X X#define gap(k) ((k) <= 0 ? 0 : q+r*(k))`09/* k-symbol indel score */ X Xstatic int *sapp;`09`09`09`09/* Current script append ptr */ Xstatic int last;`09`09`09`09/* Last script op appended */ X Xstatic int I, J;`09`09`09`09/* current positions of A ,B */ Xstatic int no_mat; `09`09`09`09/* number of matches */`20 Xstatic int no_mis; `09`09`09`09/* number of mismatches */`20 Xstatic int al_len; `09`09`09`09/* length of alignment */ X`09`09`09`09`09`09/* Append "Delete k" op */ X#define DEL(k)`09`09`09`09\ X`7B I += k;`09`09`09`09\ X al_len += k;`09`09`09`09\ X if (last < 0)`09`09`09`09\ X last = sapp`5B-1`5D -= (k);`09`09\ X else`09`09`09`09`09\ X last = *sapp++ = -(k);`09`09\ X`7D X`09`09`09`09`09`09/* Append "Insert k" op */ X#define INS(k)`09`09`09`09\ X`7B J += k;`09`09`09`09\ X al_len += k;`09`09`09`09\ X if (last < 0)`09`09`09`09\ X `7B sapp`5B-1`5D = (k); *sapp++ = last; `7D`09\ X else`09`09`09`09`09\ X last = *sapp++ = (k);`09`09\ X`7D X X`09`09`09`09`09`09/* Append "Replace" op */ X#define REP `09`09`09`09\ X`7B last = *sapp++ = 0; `09`09`09\ X al_len += 1;`09`09`09`09\ X`7D X X#ifndef FAR_PTR X#define FCKALLOC ckalloc X#else X#define FCKALLOC fckalloc X#endif X X/* SIM(A,B,M,N,K,V,Q,R) reports K best non-intersecting alignments of X the segments of A and B in order of similarity scores, where X V`5Ba`5D`5Bb`5D is the score of aligning a and b, and -(Q+R*i) is the sco Vre X of an i-symbol indel. `09`09`09`09`09`09*/ X XSIM(A,B,M,N,K,V,Q,R,nseq) X`09char A`5B`5D,B`5B`5D; X`09int M,N,K,nseq; X`09int V`5B`5D`5B32`5D,Q,R; X`7B X int endi, endj, stari, starj;`09/* endpoint and startpoint */`20 X int score; `09`09`09/* the max score in LIST */ X int count;`09`09`09`09/* maximum size of list */`09 X register int i, j;`09`09`09/* row and column indices */ X char *ckalloc();`09`09`09/* space-allocating function */ X#ifdef FAR_PTR X char far *fckalloc(); X#endif X int *S;`09`09`09`09/* saving operations for diff */ X int nc, nd, ns, nident;`09`09/* for display */ X int tmp;`09`09`09`09/* for switching min0,min1 */ X vertexptr cur; `09`09`09/* temporary pointer */ X vertexptr findmax();`09 `09`09/* return the largest score node */ X double percent; X`09 X /* allocate space for all vectors */ X j = (N + 1) * sizeof(int); X CC = ( int * ) ckalloc(j); X DD = ( int * ) ckalloc(j); X RR = ( int * ) ckalloc(j); X SS = ( int * ) ckalloc(j); X EE = ( int * ) ckalloc(j); X FF = ( int * ) ckalloc(j); X i = (M + 1) * sizeof(int); X HH = ( int * ) ckalloc(i); X WW = ( int * ) ckalloc(i); X II = ( int * ) ckalloc(i); X JJ = ( int * ) ckalloc(i); X XX = ( int * ) ckalloc(i); X YY = ( int * ) ckalloc(i); X S = ( int * ) ckalloc(min(i,j)*5/4); X#ifdef FAR_PTR X row = ( pairptr far * ) FCKALLOC( (M + 1) * sizeof(pairptr)); X#else X row = ( pairptr * ) ckalloc( (M + 1) * sizeof(pairptr)); X#endif X X /* set up list for each row */ X if (nseq == 2) for ( i = 1; i <= M; i++ ) row`5Bi`5D= PAIRNULL; X else `7B X`09 z = ( pairptr )FCKALLOC((int)sizeof(pair)*M); X`09 for ( i = 1; i <= M; i++,z++) `7B X`09`09 row`5Bi`5D = z; X`09`09 z->COL = i;`09`09`09 X`09`09 z->NEXT = PAIRNULL; X`09 `7D X `7D X X v = V; X q = Q; X r = R; X qr = q + r; X X LIST = ( vertexptr * ) ckalloc( K * sizeof(vertexptr)); X for ( i = 0; i < K ; i++ ) X LIST`5Bi`5D = ( vertexptr ) FCKALLOC( (int) sizeof(vertex)); X `20 X/* X Xfprintf(outfd,"Match Mismatch Gap-Open Penalty Gap-Extension Penalty\n V"); X fprintf(outfd," %3d %3d %3d %3d\n\n", X`09 match, mismh, q, r ); X if ( nseq == 2 ) X `7B fprintf(outfd," Upper Sequence : %s\n", name0); X fprintf(outfd," Length : %d\n", M); X fprintf(outfd," Lower Sequence : %s\n", name1); X fprintf(outfd," Length : %d\n", N); X `7D X else X `7B fprintf(outfd," Single Sequence : %s\n", name0); X fprintf(outfd," Length : %d\n", M); X `7D X*/ X X numnode = lmin = 0; X big_pass(A,B,M,N,K,nseq); X `20 X /* Report the K best alignments one by one. After each alignment is X output, recompute part of the matrix. First determine the size X of the area to be recomputed, then do the recomputation */ X `20 X for ( count = K - 1; count >= 0 ; count-- ) X `7B if ( numnode == 0 ) X`09fatal("The number of alignments computed is too large"); X cur = findmax();`09/* Return a pointer to a node with max score*/ X score = cur->SCORE; X stari = ++cur->STARI; X starj = ++cur->STARJ; X endi = cur->ENDI; X endj = cur->ENDJ; X m1 = cur->TOP; X mm = cur->BOT; X n1 = cur->LEFT; X nn = cur->RIGHT; X rl = endi - stari + 1; X cl = endj - starj + 1; X I = stari - 1; X J = starj - 1; X sapp = S; X last = 0; X al_len = 0; X no_mat = 0; X no_mis = 0; X diff(&A`5Bstari`5D-1, &B`5Bstarj`5D-1,rl,cl,q,q); X X/* Output the best alignment */ X/* X printf("\n*********************************************************\n" V); X printf(" Number %d Local Alignment\n", K - count); X printf(" Similarity Score : %d\n",score); X printf(" Match Percentage : %d%%\n", (100*no_mat)/al_len); X printf(" Number of Matches : %d\n", no_mat); X printf(" Number of Mismatches : %d\n", no_mis); X printf(" Total Length of Gaps : %d\n", al_len-no_mat-no_mis); X printf(" Begins at (%d, %d) and Ends at (%d, %d)\n", X`09 stari,starj, endi,endj); X display(&A`5Bstari`5D-1,&B`5Bstarj`5D-1,rl,cl,S,stari,starj); X*/ X min0 = stari; X min1 = starj; X max0 = stari+rl-1; X max1 = starj+cl-1; X ns=calcons(A+1,M,B+1,N,S,&nc,&nident); X percent = (double)nident*100.0/(double)nc; X `20 X#ifndef TPLOT X printf("\n %5.1f%% identity in %d %s overlap; score: %4d\n", X`09 percent,nc,sqnam,score); X#endif X outfd = stdout; X gscore=score; X opnline((long)smin0,(long)smin1,score); X discons(seqc0,seqc1,ns); X clsline((long)smin0,(long)smin1,score); X#ifdef TPLOT X if (nseq==1) `7B X`09 tmp = smin0; X`09 smin0 = smin1; X`09 smin1 = tmp; X`09 opnline((long)smin0,(long)smin1,score); X`09 discons(seqc1,seqc0,ns); X`09 clsline((long)smin0,(long)smin1,score); X `7D X#endif X `20 X#ifndef TPLOT X printf("\n----------\n"); X#endif X fflush(stdout); X X if ( count ) X`09`7B flag = 0; X`09 locate(A,B,nseq); X`09 if ( flag ) X`09 small_pass(A,B,count,nseq); X`09`7D X `7D X`7D X X/* A big pass to compute K best classes */ X Xbig_pass(A,B,M,N,K,nseq) char A`5B`5D,B`5B`5D; int M,N,K,nseq; X`7B register int i, j;`09`09`09/* row and column indices */ X register int c;`09`09`09/* best score at current point */ X register int f;`09`09`09/* best score ending with insertion */ X register int d;`09`09`09/* best score ending with deletion */ X register int p;`09`09`09/* best score at (i-1, j-1) */ X register int ci, cj;`09`09/* end-point associated with c */`20 X register int di, dj;`09`09/* end-point associated with d */ X register int fi, fj;`09`09/* end-point associated with f */ X register int pi, pj;`09`09/* end-point associated with p */ X int *va;`09`09`09`09/* pointer to v(A`5Bi`5D, B`5Bj`5D) */ X int addnode();`09`09`09/* function for inserting a node */ X X`09 X`09/* Compute the matrix and save the top K best scores in LIST X`09 CC : the scores of the current row X`09 RR and EE : the starting point that leads to score CC X`09 DD : the scores of the current row, ending with deletion X`09 SS and FF : the starting point that leads to score DD */ X `09/* Initialize the 0 th row */ X`09for ( j = 1; j <= N ; j++ ) X`09 `7B CC`5Bj`5D = 0; X`09 RR`5Bj`5D = 0; X`09 EE`5Bj`5D = j; X`09 DD`5Bj`5D = - (q); X`09 SS`5Bj`5D = 0; X`09 FF`5Bj`5D = j; X`09 `7D X`09for ( i = 1; i <= M; i++)`20 X`09 `7B c = 0;`09`09`09`09/* Initialize column 0 */ X`09 f = - (q); X`09 ci = fi = i; X `09 va = v`5BA`5Bi`5D`5D; X`09 if ( nseq == 2 ) X`09 `7B p = 0; X`09 pi = i - 1; X`09 cj = fj = pj = 0; X`09 `7D X`09 else X`09 `7B p = CC`5Bi`5D; X`09`09 pi = RR`5Bi`5D; X`09`09 pj = EE`5Bi`5D; X`09 cj = fj = i; X`09 `7D X`09 for ( j = (nseq == 2 ? 1 : (i+1)) ; j <= N ; j++ ) `20 X`09 `7B f = f - r; X`09`09 c = c - qr; X`09`09 ORDER(f, fi, fj, c, ci, cj) X`09`09 c = CC`5Bj`5D - qr;`20 X`09`09 ci = RR`5Bj`5D; X`09`09 cj = EE`5Bj`5D; X`09`09 d = DD`5Bj`5D - r; X`09`09 di = SS`5Bj`5D; X`09`09 dj = FF`5Bj`5D; X`09`09 ORDER(d, di, dj, c, ci, cj) X`09`09 c = 0; X`09`09 DIAG(i, j, c, p+va`5BB`5Bj`5D`5D)`09`09/* diagonal */ X`09`09 if ( c <= 0 ) X`09`09 `7B c = 0; ci = i; cj = j; `7D X`09`09 else X`09`09 `7B ci = pi; cj = pj; `7D X`09`09 ORDER(c, ci, cj, d, di, dj) X`09`09 ORDER(c, ci, cj, f, fi, fj) X`09`09 p = CC`5Bj`5D; X`09`09 CC`5Bj`5D = c; X`09`09 pi = RR`5Bj`5D; X`09`09 pj = EE`5Bj`5D; X`09`09 RR`5Bj`5D = ci; X`09`09 EE`5Bj`5D = cj; X`09`09 DD`5Bj`5D = d; X`09`09 SS`5Bj`5D = di; X`09`09 FF`5Bj`5D = dj; X`09`09 if ( c > lmin )`09/* add the score into list */ X`09`09 lmin = addnode(c, ci, cj, i, j, K, lmin); +-+-+-+-+-+-+-+- END OF PART 4 +-+-+-+-+-+-+-+- -+-+-+-+-+-+-+-+ START OF PART 5 -+-+-+-+-+-+-+-+ X`09 `7D X`09 `7D X`7D X X/* Determine the left and top boundaries of the recomputed area */ X Xlocate(A,B,nseq) char A`5B`5D,B`5B`5D; int nseq; X`7B register int i, j;`09`09`09/* row and column indices */ X register int c;`09`09`09/* best score at current point */ X register int f;`09`09`09/* best score ending with insertion */ X register int d;`09`09`09/* best score ending with deletion */ X register int p;`09`09`09/* best score at (i-1, j-1) */ X register int ci, cj;`09`09/* end-point associated with c */`20 X register int di, dj;`09`09/* end-point associated with d */ X register int fi, fj;`09`09/* end-point associated with f */ X register int pi, pj;`09`09/* end-point associated with p */ X int cflag, rflag;`09`09`09/* for recomputation */ X int *va;`09`09`09`09/* pointer to v(A`5Bi`5D, B`5Bj`5D) */ X int addnode();`09`09`09/* function for inserting a node */ X int limit;`09`09`09`09/* the bound on j */ X X`09/* Reverse pass X`09 rows X`09 CC : the scores on the current row X`09 RR and EE : the endpoints that lead to CC X`09 DD : the deletion scores`20 X`09 SS and FF : the endpoints that lead to DD X X`09 columns X`09 HH : the scores on the current columns X`09 II and JJ : the endpoints that lead to HH X`09 WW : the deletion scores X`09 XX and YY : the endpoints that lead to WW X`09*/ X`09for ( j = nn; j >= n1 ; j-- ) X `7B CC`5Bj`5D = 0; X`09 EE`5Bj`5D = j; X`09 DD`5Bj`5D = - (q); X`09 FF`5Bj`5D = j; X`09 if ( nseq == 2 `7C`7C j > mm ) X RR`5Bj`5D = SS`5Bj`5D = mm + 1; X`09 else X RR`5Bj`5D = SS`5Bj`5D = j; X`09 `7D X X for ( i = mm; i >= m1; i-- ) X`09 `7B c = p = 0; X`09 f = - (q); X`09 ci = fi = i; X`09 pi = i + 1; X`09 cj = fj = pj = nn + 1; X`09 va = v`5BA`5Bi`5D`5D; X`09 if ( nseq == 2 `7C`7C n1 > i ) X`09`09limit = n1; X`09 else X`09`09limit = i + 1; X`09 for ( j = nn; j >= limit ; j-- ) `20 X`09 `7B f = f - r; X`09`09 c = c - qr; X`09`09 ORDER(f, fi, fj, c, ci, cj) X`09`09 c = CC`5Bj`5D - qr;`20 X`09`09 ci = RR`5Bj`5D; X`09`09 cj = EE`5Bj`5D; X`09`09 d = DD`5Bj`5D - r; X`09`09 di = SS`5Bj`5D; X`09`09 dj = FF`5Bj`5D; X`09`09 ORDER(d, di, dj, c, ci, cj) X`09`09 c = 0; X`09`09 DIAG(i, j, c, p+va`5BB`5Bj`5D`5D)`09`09/* diagonal */ X`09`09 if ( c <= 0 ) X`09`09 `7B c = 0; ci = i; cj = j; `7D X`09`09 else X`09`09 `7B ci = pi; cj = pj; `7D X`09`09 ORDER(c, ci, cj, d, di, dj) X`09`09 ORDER(c, ci, cj, f, fi, fj) X`09`09 p = CC`5Bj`5D; X`09`09 CC`5Bj`5D = c; X`09`09 pi = RR`5Bj`5D; X`09`09 pj = EE`5Bj`5D; X`09`09 RR`5Bj`5D = ci; X`09`09 EE`5Bj`5D = cj; X`09`09 DD`5Bj`5D = d; X`09`09 SS`5Bj`5D = di; X`09`09 FF`5Bj`5D = dj; X`09`09 if ( c > lmin ) X`09`09 flag = 1; X`09 `7D X`09 if ( nseq == 2 `7C`7C i < n1 ) X`09 `7B HH`5Bi`5D = CC`5Bn1`5D; X`09 II`5Bi`5D = RR`5Bn1`5D; X`09 JJ`5Bi`5D = EE`5Bn1`5D; X`09 WW`5Bi`5D = DD`5Bn1`5D; X`09 XX`5Bi`5D = SS`5Bn1`5D; X`09 YY`5Bi`5D = FF`5Bn1`5D; X`09 `7D X`09 `7D X `20 X for ( rl = m1, cl = n1; ; ) X `7B for ( rflag = cflag = 1; ( rflag && m1 > 1 ) `7C`7C ( cflag && n1 > V 1 ) ; ) X `7B if ( rflag && m1 > 1 )`09/* Compute one row */ X `7B rflag = 0; X`09 m1--; X `09 c = p = 0; X`09 f = - (q); X`09 ci = fi = m1; X`09 pi = m1 + 1; X`09 cj = fj = pj = nn + 1; X`09 va = v`5BA`5Bm1`5D`5D; X`09 for ( j = nn; j >= n1 ; j-- ) `20 X`09 `7B f = f - r; X`09`09 c = c - qr; X`09`09 ORDER(f, fi, fj, c, ci, cj) X`09`09 c = CC`5Bj`5D - qr;`20 X`09`09 ci = RR`5Bj`5D; X`09`09 cj = EE`5Bj`5D; X`09`09 d = DD`5Bj`5D - r; X`09`09 di = SS`5Bj`5D; X`09`09 dj = FF`5Bj`5D; X`09`09 ORDER(d, di, dj, c, ci, cj) X`09`09 c = 0; X`09`09 DIAG(m1, j, c, p+va`5BB`5Bj`5D`5D)`09`09/* diagonal */ X`09`09 if ( c <= 0 ) X`09`09 `7B c = 0; ci = m1; cj = j; `7D X`09`09 else X`09`09 `7B ci = pi; cj = pj; `7D X`09`09 ORDER(c, ci, cj, d, di, dj) X`09`09 ORDER(c, ci, cj, f, fi, fj) X`09`09 p = CC`5Bj`5D; X`09`09 CC`5Bj`5D = c; X`09`09 pi = RR`5Bj`5D; X`09`09 pj = EE`5Bj`5D; X`09`09 RR`5Bj`5D = ci; X`09`09 EE`5Bj`5D = cj; X`09`09 DD`5Bj`5D = d; X`09`09 SS`5Bj`5D = di; X`09`09 FF`5Bj`5D = dj; X`09`09 if ( c > lmin ) X`09`09 flag = 1; X`09`09 if ( ! rflag && ( ci > rl && cj > cl `7C`7C di > rl && dj > cl X`09 `09`09 `7C`7C fi > rl && fj > cl ) ) X`09`09 rflag = 1; X`09 `7D X`09 HH`5Bm1`5D = CC`5Bn1`5D; X`09 II`5Bm1`5D = RR`5Bn1`5D; X`09 JJ`5Bm1`5D = EE`5Bn1`5D; X`09 WW`5Bm1`5D = DD`5Bn1`5D; X`09 XX`5Bm1`5D = SS`5Bn1`5D; X`09 YY`5Bm1`5D = FF`5Bn1`5D; X`09 if ( ! cflag && ( ci > rl && cj > cl `7C`7C di > rl && dj > cl X`09`09`09 `7C`7C fi > rl && fj > cl ) ) X`09 cflag = 1; X`09 `7D X X`09 if ( nseq == 1 && n1 == (m1 + 1) && ! rflag ) X`09 cflag = 0; X`09 if ( cflag && n1 > 1 )`09/* Compute one column */ X`09 `7B cflag = 0; X`09 n1--; X`09 c = 0; X`09 f = - (q); X`09 cj = fj = n1; X`09 va = v`5BB`5Bn1`5D`5D; X`09 if ( nseq == 2 `7C`7C mm < n1 ) X`09`09`7B p = 0; X`09 ci = fi = pi = mm + 1; X`09 pj = n1 + 1; X`09`09 limit = mm; X`09`09`7D X`09 else X`09`09`7B p = HH`5Bn1`5D; X`09`09 pi = II`5Bn1`5D; X`09`09 pj = JJ`5Bn1`5D; X`09 ci = fi = n1; X`09`09 limit = n1 - 1; X`09`09`7D X`09 for ( i = limit; i >= m1 ; i-- ) `20 X`09 `7B f = f - r; X`09`09 c = c - qr; X`09`09 ORDER(f, fi, fj, c, ci, cj) X`09`09 c = HH`5Bi`5D - qr;`20 X`09`09 ci = II`5Bi`5D; X`09`09 cj = JJ`5Bi`5D; X`09`09 d = WW`5Bi`5D - r; X`09`09 di = XX`5Bi`5D; X`09`09 dj = YY`5Bi`5D; X`09`09 ORDER(d, di, dj, c, ci, cj) X`09`09 c = 0; X`09 DIAG(i, n1, c, p+va`5BA`5Bi`5D`5D) X`09`09 if ( c <= 0 ) X`09`09 `7B c = 0; ci = i; cj = n1; `7D X`09`09 else X`09`09 `7B ci = pi; cj = pj; `7D X`09`09 ORDER(c, ci, cj, d, di, dj) X`09`09 ORDER(c, ci, cj, f, fi, fj) X`09`09 p = HH`5Bi`5D; X`09`09 HH`5Bi`5D = c; X`09`09 pi = II`5Bi`5D; X`09`09 pj = JJ`5Bi`5D; X`09`09 II`5Bi`5D = ci; X`09`09 JJ`5Bi`5D = cj; X`09`09 WW`5Bi`5D = d; X`09`09 XX`5Bi`5D = di; X`09`09 YY`5Bi`5D = dj; X`09`09 if ( c > lmin ) X`09`09 flag = 1; X`09 if ( ! cflag && ( ci > rl && cj > cl `7C`7C di > rl && dj > cl X`09`09 `7C`7C fi > rl && fj > cl ) ) X`09`09 cflag = 1; X`09 `7D X`09 CC`5Bn1`5D = HH`5Bm1`5D; X`09 RR`5Bn1`5D = II`5Bm1`5D; X`09 EE`5Bn1`5D = JJ`5Bm1`5D; X`09 DD`5Bn1`5D = WW`5Bm1`5D; X`09 SS`5Bn1`5D = XX`5Bm1`5D; X`09 FF`5Bn1`5D = YY`5Bm1`5D; X`09 if ( ! rflag && ( ci > rl && cj > cl `7C`7C di > rl && dj > cl X`09`09 `7C`7C fi > rl && fj > cl ) ) X`09 rflag = 1; X`09 `7D X`09`7D X if ( m1 == 1 && n1 == 1 `7C`7C no_cross() ) X`09 break; X `7D X m1--; X n1--; X`7D X X/* recompute the area on forward pass */ Xsmall_pass(A,B,count,nseq) char A`5B`5D, B`5B`5D; int count, nseq; X`7B register int i, j;`09`09`09/* row and column indices */ X register int c;`09`09`09/* best score at current point */ X register int f;`09`09`09/* best score ending with insertion */ X register int d;`09`09`09/* best score ending with deletion */ X register int p;`09`09`09/* best score at (i-1, j-1) */ X register int ci, cj;`09`09/* end-point associated with c */`20 X register int di, dj;`09`09/* end-point associated with d */ X register int fi, fj;`09`09/* end-point associated with f */ X register int pi, pj;`09`09/* end-point associated with p */ X int *va;`09`09`09`09/* pointer to v(A`5Bi`5D, B`5Bj`5D) */ X int addnode();`09`09`09/* function for inserting a node */ X int limit;`09`09`09`09/* lower bound on j */ X X`09for ( j = n1 + 1; j <= nn ; j++ ) X`09 `7B CC`5Bj`5D = 0; X`09 RR`5Bj`5D = m1; X`09 EE`5Bj`5D = j; X`09 DD`5Bj`5D = - (q); X`09 SS`5Bj`5D = m1; X`09 FF`5Bj`5D = j; X`09 `7D X`09for ( i = m1 + 1; i <= mm; i++)`20 X`09 `7B c = 0;`09`09`09`09/* Initialize column 0 */ X`09 f = - (q); X`09 ci = fi = i; X`09 va = v`5BA`5Bi`5D`5D; X`09 if ( nseq == 2 `7C`7C i <= n1 ) X`09 `7B p = 0; X`09 pi = i - 1; X`09 cj = fj = pj = n1; X`09`09 limit = n1 + 1; X`09 `7D X`09 else X`09 `7B p = CC`5Bi`5D; X`09`09 pi = RR`5Bi`5D; X`09`09 pj = EE`5Bi`5D; X`09 cj = fj = i; X`09`09 limit = i + 1; X`09 `7D X`09 for ( j = limit ; j <= nn ; j++ ) `20 X`09 `7B f = f - r; X`09`09 c = c - qr; X`09`09 ORDER(f, fi, fj, c, ci, cj) X`09`09 c = CC`5Bj`5D - qr;`20 X`09`09 ci = RR`5Bj`5D; X`09`09 cj = EE`5Bj`5D; X`09`09 d = DD`5Bj`5D - r; X`09`09 di = SS`5Bj`5D; X`09`09 dj = FF`5Bj`5D; X`09`09 ORDER(d, di, dj, c, ci, cj) X`09`09 c = 0; X`09`09 DIAG(i, j, c, p+va`5BB`5Bj`5D`5D)`09`09/* diagonal */ X`09`09 if ( c <= 0 ) X`09`09 `7B c = 0; ci = i; cj = j; `7D X`09`09 else X`09`09 `7B ci = pi; cj = pj; `7D X`09`09 ORDER(c, ci, cj, d, di, dj) X`09`09 ORDER(c, ci, cj, f, fi, fj) X`09`09 p = CC`5Bj`5D; X`09`09 CC`5Bj`5D = c; X`09`09 pi = RR`5Bj`5D; X`09`09 pj = EE`5Bj`5D; X`09`09 RR`5Bj`5D = ci; X`09`09 EE`5Bj`5D = cj; X`09`09 DD`5Bj`5D = d; X`09`09 SS`5Bj`5D = di; X`09`09 FF`5Bj`5D = dj; X`09`09 if ( c > lmin )`09/* add the score into list */ X`09`09 lmin = addnode(c, ci, cj, i, j, count, lmin); X`09 `7D X`09 `7D X`7D X X/* Add a new node into list. */ X Xint addnode(c, ci, cj, i, j, K, cost) int c, ci, cj, i, j, K, cost; X`7B int found;`09`09`09`09/* 1 if the node is in LIST */ X register int d; X X found = 0; X if ( most != 0 && most->STARI == ci && most->STARJ == cj ) X found = 1; X else X for ( d = 0; d < numnode ; d++ ) X`09`7B most = LIST`5Bd`5D; X`09 if ( most->STARI == ci && most->STARJ == cj ) X`09 `7B found = 1; X`09 break; X`09 `7D X `7D X if ( found ) X `7B if ( most->SCORE < c ) X `7B most->SCORE = c; X most->ENDI = i; X most->ENDJ = j; X `7D X if ( most->TOP > i ) most->TOP = i; X if ( most->BOT < i ) most->BOT = i; X if ( most->LEFT > j ) most->LEFT = j; X if ( most->RIGHT < j ) most->RIGHT = j; X `7D X else X `7B if ( numnode == K )`09/* list full */ X`09 most = low; X else X most = LIST`5Bnumnode++`5D; X most->SCORE = c; X most->STARI = ci; X most->STARJ = cj; X most->ENDI = i; X most->ENDJ = j; X most->TOP = most->BOT = i; X most->LEFT = most->RIGHT = j; X `7D X if ( numnode == K ) X `7B if ( low == most `7C`7C ! low )`20 X `7B for ( low = LIST`5B0`5D, d = 1; d < numnode ; d++ ) X if ( LIST`5Bd`5D->SCORE < low->SCORE ) X low = LIST`5Bd`5D; X`09`7D X return ( low->SCORE ) ; X `7D X else X return cost; X`7D X X/* Find and remove the largest score in list */ X Xvertexptr findmax() X`7B vertexptr cur; X register int i, j; X X for ( j = 0, i = 1; i < numnode ; i++ ) X if ( LIST`5Bi`5D->SCORE > LIST`5Bj`5D->SCORE ) X j = i; X cur = LIST`5Bj`5D; X if ( j != --numnode ) X `7B LIST`5Bj`5D = LIST`5Bnumnode`5D; X LIST`5Bnumnode`5D = cur; X `7D X most = LIST`5B0`5D; X if ( low == cur ) low = LIST`5B0`5D; X return ( cur ); X`7D X X/* return 1 if no node in LIST share vertices with the area */ X Xno_cross() X`7B vertexptr cur; X register int i; X X for ( i = 0; i < numnode; i++ ) X`09`7B cur = LIST`5Bi`5D; X`09 if ( cur->STARI <= mm && cur->STARJ <= nn && cur->BOT >= m1-1 &&`20 X`09 cur->RIGHT >= n1-1 && ( cur->STARI < rl `7C`7C cur->STARJ < cl )) X`09 `7B if ( cur->STARI < rl ) rl = cur->STARI; X`09 if ( cur->STARJ < cl ) cl = cur->STARJ; X`09 flag = 1; X`09 break; X`09 `7D X`09`7D X if ( i == numnode ) X`09return 1; X else X`09return 0; X`7D X X/* diff(A,B,M,N,tb,te) returns the score of an optimum conversion between X A`5B1..M`5D and B`5B1..N`5D that begins(ends) with a delete if tb(te) is V zero X and appends such a conversion to the current script. */ X Xint diff(A,B,M,N,tb,te) char *A, *B; int M, N; int tb, te; X X`7B int midi, midj, type;`09/* Midpoint, type, and cost */ X int midc; X X`7B register int i, j; X register int c, e, d, s; X int t, *va; X#ifdef FAR_PTR X`09char far * fckalloc(); X#else X`09char *ckalloc(); X#endif X X/* Boundary cases: M <= 1 or N == 0 */ X X if (N <= 0) X `7B if (M > 0) DEL(M) X return - gap(M); X `7D X if (M <= 1) X `7B if (M <= 0) X `7B INS(N); X return - gap(N); X `7D X if (tb > te) tb = te; X midc = - (tb + r + gap(N) ); X midj = 0; X va = v`5BA`5B1`5D`5D; X for (j = 1; j <= N; j++) X `7B for ( tt = 1, z = row`5BI+1`5D; z != PAIRNULL; z = z->NEXT )`09 X if ( z->COL == j+J )`09`09`09 X`09 `7B tt = 0; break; `7D`09`09 X if ( tt )`09`09`09 X `7B c = va`5BB`5Bj`5D`5D - ( gap(j-1) + gap(N-j) ); X if (c > midc) X `7B midc = c; X midj = j; X `7D X`09 `7D X`09`7D X if (midj == 0) X `7B INS(N) DEL(1) `7D X else X `7B if (midj > 1) INS(midj-1) X REP X`09 if ( A`5B1`5D == B`5Bmidj`5D ) X`09 no_mat += 1; X`09 else X`09 no_mis += 1; X`09 /* mark (A`5BI`5D,B`5BJ`5D) as used: put J into list row`5BI`5D */`09 X I++; J++; X`09 z = ( pairptr ) FCKALLOC( (int) sizeof(pair)); X z->COL = J;`09`09`09 X z->NEXT = row`5BI`5D;`09`09`09`09 X`09 row`5BI`5D = z; X if (midj < N) INS(N-midj) X `7D X return midc; X `7D X X/* Divide: Find optimum midpoint (midi,midj) of cost midc */ X X midi = M/2;`09`09`09/* Forward phase: */ X CC`5B0`5D = 0;`09`09`09/* Compute C(M/2,k) & D(M/2,k) for all k */ X t = -q; X for (j = 1; j <= N; j++) X `7B CC`5Bj`5D = t = t-r; X DD`5Bj`5D = t-q; X `7D X t = -tb; X for (i = 1; i <= midi; i++) X `7B s = CC`5B0`5D; X CC`5B0`5D = c = t = t-r; X e = t-q; X va = v`5BA`5Bi`5D`5D; X for (j = 1; j <= N; j++) X `7B if ((c = c - qr) > (e = e - r)) e = c; X if ((c = CC`5Bj`5D - qr) > (d = DD`5Bj`5D - r)) d = c; X`09 DIAG(i+I, j+J, c, s+va`5BB`5Bj`5D`5D) X if (c < d) c = d; X if (c < e) c = e; X s = CC`5Bj`5D; X CC`5Bj`5D = c; X DD`5Bj`5D = d; X `7D X `7D X DD`5B0`5D = CC`5B0`5D; X X RR`5BN`5D = 0;`09`09`09/* Reverse phase: */ X t = -q;`09`09`09/* Compute R(M/2,k) & S(M/2,k) for all k */ X for (j = N-1; j >= 0; j--) X `7B RR`5Bj`5D = t = t-r; X SS`5Bj`5D = t-q; X `7D X t = -te; X for (i = M-1; i >= midi; i--) X `7B s = RR`5BN`5D; X RR`5BN`5D = c = t = t-r; X e = t-q; X va = v`5BA`5Bi+1`5D`5D; X for (j = N-1; j >= 0; j--) X `7B if ((c = c - qr) > (e = e - r)) e = c; X if ((c = RR`5Bj`5D - qr) > (d = SS`5Bj`5D - r)) d = c; X`09 DIAG(i+1+I, j+1+J, c, s+va`5BB`5Bj+1`5D`5D) X if (c < d) c = d; X if (c < e) c = e; X s = RR`5Bj`5D; X RR`5Bj`5D = c; X SS`5Bj`5D = d; X `7D X `7D X SS`5BN`5D = RR`5BN`5D; X X midc = CC`5B0`5D+RR`5B0`5D;`09`09/* Find optimal midpoint */ X midj = 0; X type = 1; X for (j = 0; j <= N; j++) X if ((c = CC`5Bj`5D + RR`5Bj`5D) >= midc) X if (c > midc `7C`7C CC`5Bj`5D != DD`5Bj`5D && RR`5Bj`5D == SS`5Bj`5D) X `7B midc = c; X midj = j; X `7D X for (j = N; j >= 0; j--) X if ((c = DD`5Bj`5D + SS`5Bj`5D + q) > midc) X `7B midc = c; X midj = j; X type = 2; X `7D X`7D X X/* Conquer: recursively around midpoint */ X X if (type == 1) X `7B diff(A,B,midi,midj,tb,q); X diff(A+midi,B+midj,M-midi,N-midj,q,te); X `7D X else X `7B diff(A,B,midi-1,midj,tb,zero); X DEL(2); X diff(A+midi+1,B+midj,M-midi-1,N-midj,zero,te); X `7D X return midc; X`7D X X/* Alignment display routine */ X Xstatic char ALINE`5B51`5D, BLINE`5B51`5D, CLINE`5B51`5D; X Xint display(A,B,M,N,S,AP,BP) char A`5B`5D, B`5B`5D; int M, N; int S`5B`5D, A VP, BP; X`7B register char *a, *b, *c; X register int i, j, op; X int lines, ap, bp; X X i = j = op = lines = 0; X ap = AP; X bp = BP; X a = ALINE; X b = BLINE; X c = CLINE; X while (i < M `7C`7C j < N) X `7B if (op == 0 && *S == 0) X `7B op = *S++; X *a = sq`5BA`5B++i`5D`5D; X *b = sq`5BB`5B++j`5D`5D; X *c++ = (*a++ == *b++) ? '`7C' : ' '; X `7D X else X `7B if (op == 0) X op = *S++; X if (op > 0) X `7B *a++ = ' '; X *b++ = sq`5BB`5B++j`5D`5D; X op--; X `7D X else X `7B *a++ = sq`5BA`5B++i`5D`5D; X *b++ = ' '; X op++; X `7D X *c++ = '-'; X `7D X if (a >= ALINE+50 `7C`7C i >= M && j >= N) X `7B *a = *b = *c = '\0'; X printf("\n%5d ",50*lines++); X for (b = ALINE+10; b <= a; b += 10) X printf(" . :"); X if (b <= a+5) X printf(" ."); X printf("\n%5d %s\n %s\n%5d %s\n",ap,ALINE,CLINE,bp,BLINE); X`09 ap = AP + i; X`09 bp = BP + j; X a = ALINE; X b = BLINE; X c = CLINE; X `7D X `7D X`7D X X/* lib.c - library of C procedures. */ X X/* fatal - print message and die */ Xfatal(msg) Xchar *msg; X`7B X`09fprintf(stderr, "%s\n", msg); X`09exit(1); X`7D X X/* fatalf - format message, print it, and die */ Xfatalf(msg, val) Xchar *msg, *val; X`7B X`09fprintf(stderr, msg, val); X`09putc('\n', stderr); X`09exit(1); X`7D X`09 X/* ckopen - open file; check for success */ XFILE *ckopen(name, mode) Xchar *name, *mode; X`7B X`09FILE *fopen(), *fp; X X`09if ((fp = fopen(name, mode)) == NULL) X`09`09fatalf("Cannot open %s.", name); X`09return(fp); X`7D X X/* ckalloc - allocate space; check for success */ Xchar *ckalloc(amount) Xint amount; X`7B X`09char *malloc(), *p; X`09static long mtotal; X X`09mtotal += (long)amount; X X`09if ((p = malloc( (unsigned) amount)) == NULL) `7B X`09fprintf(stderr,"Ran out of near memory: %d/%ld\n",amount,mtotal); X`09`09exit(1); X`09`7D X`09return(p); X`7D X X#ifdef FAR_PTR X#ifdef TURBOC X#define FMALLOC farmalloc X#define MTYPE long X#define FFREE farfree X#else X#define FMALLOC _fmalloc X#define MTYPE unsigned X#define FFREE _ffree X#endif X X/* fckalloc - allocate space; check for success */ Xchar far *fckalloc(amount) X`09int amount; X`7B X`09static long ftotal; X`09static int nf; X X`09char far * FMALLOC(), far * p; X X`09ftotal += (long)amount; X`09nf++; X X`09if ((p = FMALLOC( (MTYPE) amount)) == (char far *)NULL) `7B X`09fprintf(stderr,"Ran out of far memory: %d/%ld (%d)\n", X`09`09amount,ftotal,nf); X`09`09exit(1); X`09`7D X`09return(p); X`7D X#endif $ CALL UNPACK LSIM.C;1 2119083705 $ create 'f' X X/* A PACKAGE FOR LOCALLY ALIGNING TWO SEQUENCES WITHIN A BAND: X X To invoke, call LOCAL_ALIGN(A,B,M,N,L,U,W,G,H,S,dflag,&SI,&SJ,&EI,&EJ,MW) V. X The parameters are explained as follows: X`09A, B : two sequences to be aligned X`09M : the length of sequence A X`09N : the length of sequence B X`09L : lower bound of the band X`09U : upper bound of the band X`09W : scoring table for matches and mismatches X`09G : gap-opening penalty X`09H : gap-extension penalty X`09dflag : 0 - no display or backward pass X`09*SI : starting position of sequence A in the optimal local alignment X`09*SJ : starting position of sequence B in the optimal local alignment X`09*EI : ending position of sequence A in the optimal local alignment X`09*EJ : ending position of sequence B in the optimal local alignment X`09MW : maximum window size X*/ X X#include X X#ifdef BIGMEM X#define MININT -9999999 X#else X#define MININT -32000 X#endif X Xextern int *CC, *DD; X X#define max(x,y) ((x) >= (y) ? (x) : (y)) X#define min(x,y) ((x) <= (y) ? (x) : (y)) X Xint LOCAL_ALIGN(A,B,M,N,low,up,W,G,H,dflag,psi,psj,pei,pej,MW) Xchar A`5B`5D,B`5B`5D; int M,N,low,up; int W`5B`5D`5B32`5D,G,H; Xint dflag; Xint *psi, *psj, *pei, *pej; Xint MW; X`7B`20 X int band; X char *ckalloc(); X int i, j, si, ei; X int c, d, e, t, m; X int leftd, rightd; X int best_score, starti, startj, endi, endj; X int *wa, curd; X int ib; X char flag; X `20 X m = G+H; X low = max(-M, low); X up = min(N, up); X `20 X if (N <= 0) `7B`20 X *psi = *psj = *pei = *pej; X return 0; X `7D X if (M <= 0) `7B X *psi = *psj = *pei = *pej; X return 0; X `7D X band = up-low+1; X if (band < 1) `7B X printf("low > up is unacceptable!\n"); X exit(1); X `7D X j = (MW+1+2) * sizeof(int); X if (CC==NULL) `7B X CC = (int *) ckalloc(j); X DD = (int *) ckalloc(j); X `7D X `20 X if (low > 0) leftd = 1; X else if (up < 0) leftd = band; X else leftd = 1-low; X rightd = band; X si = max(0,-up); X ei = min(M,N-low); X CC`5Bleftd`5D = 0; X for (j = leftd+1; j <= rightd; j++) `7B X CC`5Bj`5D = 0; X DD`5Bj`5D = -G; X `7D X CC`5Brightd+1`5D = MININT; X DD`5Brightd+1`5D = MININT; X best_score = 0; X endi = si; X endj = si+low; X CC`5Bleftd-1`5D = MININT; X DD`5Bleftd`5D = -G; X for (i = si+1; i <= ei; i++) `7B X if (i > N-up) rightd--; X if (leftd > 1) leftd--; X wa = W`5BA`5Bi`5D`5D; X if ((c = CC`5Bleftd+1`5D-m) > (d = DD`5Bleftd+1`5D-H)) d = c; X if ((ib = leftd+low-1+i ) > 0) c = CC`5Bleftd`5D+wa`5BB`5Bib`5D`5D; X/* X if (ib > N) fprintf(stderr,"B`5B%d`5D out of range %d\n",ib,N); X*/ X if (d > c) c = d; X if (c < 0) c = 0; X e = c-G; X DD`5Bleftd`5D = d; X CC`5Bleftd`5D = c; X if (c > best_score) `7B X best_score = c; X endi = i; X endj = ib; X `7D X for (curd=leftd+1; curd <= rightd; curd++) `7B X if ((c = c-m) > (e = e-H)) e = c; X if ((c = CC`5Bcurd+1`5D-m) > (d = DD`5Bcurd+1`5D-H)) d = c; X/* X if ((ib=curd+low-1+i) <= 0 `7C`7C ib > N) X`09fprintf(stderr,"B`5B%d`5D:%d\n",ib,B`5Bib`5D); X*/ X c = CC`5Bcurd`5D + wa`5BB`5Bcurd+low-1+i`5D`5D; X if (e > c) c = e; X if (d > c) c = d; X if (c < 0) c = 0; X CC`5Bcurd`5D = c; X DD`5Bcurd`5D = d; X if (c > best_score) `7B X`09best_score = c; X`09endi = i; X`09endj = curd+low-1+i; X `7D X `7D X `7D X `20 X if (!dflag) `7B X *pei = endi; X *pej = endj; X return best_score; X `7D X `20 X leftd = max(1,-endi-low+1); X rightd = band-(up-(endj-endi)); X CC`5Brightd`5D = 0; X t = -G; X for (j = rightd-1; j >= leftd; j--) `7B X CC`5Bj`5D = t = t-H; X DD`5Bj`5D = t-G; X `7D X for (j = rightd+1; j <= band; ++j) CC`5Bj`5D = MININT; X CC`5Bleftd-1`5D = DD`5Bleftd-1`5D = MININT; X DD`5Brightd`5D = -G; X flag = 0; X for (i = endi; i >= 1; i--) `7B X if (i+low <= 0) leftd++; X if (rightd < band) rightd++; X wa = W`5BA`5Bi`5D`5D; X if ((c = CC`5Brightd-1`5D-m) > (d = DD`5Brightd-1`5D-H)) d = c; X if ((ib = rightd+low-1+i) <= N) c = CC`5Brightd`5D+wa`5BB`5Bib`5D`5D; X X/* X if (ib <= 0) fprintf(stderr,"rB`5B%d`5D <1\n",ib); X*/ X if (d > c) c = d; X e = c-G; X DD`5Brightd`5D = d; X CC`5Brightd`5D = c; X if (c == best_score) `7B X starti = i; X startj = ib; X flag = 1; X break; X `7D X for (curd=rightd-1; curd >= leftd; curd--) `7B X if ((c = c-m) > (e = e-H)) e = c; X if ((c = CC`5Bcurd-1`5D-m) > (d = DD`5Bcurd-1`5D-H)) d = c; X X/* X if ((ib=curd+low-1+i) <= 0 `7C`7C ib > N) X`09fprintf(stderr,"i: %d, B`5B%d`5D:%d\n",i,ib,B`5Bib`5D); X*/ X c = CC`5Bcurd`5D + wa`5BB`5Bcurd+low-1+i`5D`5D; X if (e > c) c = e; X if (d > c) c = d; X CC`5Bcurd`5D = c; X DD`5Bcurd`5D = d; X if (c == best_score) `7B X`09starti = i; X`09startj = curd+low-1+i; X`09flag = 1; X`09break; X `7D X `7D X if (flag == 1) break; X `7D X `20 X if (starti < 0 `7C`7C starti > M `7C`7C startj < 0 `7C`7C startj > N) `7B X printf("starti=%d, startj=%d\n",starti,startj); X *psi = *psj = *pei = *pej; X exit(1); X `7D X *psi = starti; X *psj = startj; X *pei = endi; X *pej = endj; X return best_score; X`7D X X#ifdef LFASTA X Xint LLOCAL_ALIGN(A,B,M,N,low,up,W,G,H,dflag,psi,psj,pei,pej,MW) X char A`5B`5D,B`5B`5D; X int M,N,low,up; X int W`5B`5D`5B32`5D,G,H; X int dflag; X int *psi, *psj, *pei, *pej; X int MW; X`7B`20 X int band; X char *ckalloc(); X int i, j, si, ei; X int c, d, e, t, m; X int lc;`09`09/* row local score */ X int leftd, rightd; X int best_score, starti, startj, endi, endj; X int *wa, curd, ib; X int flag; X `20 X m = G+H; X low = max(-M, low); X up = min(N, up); X if (N <= 0) `7B`20 X *psi = *psj = *pei = *pej; X return 0; X `7D X if (M <= 0) `7B X *psi = *psj = *pei = *pej; X return 0; X `7D X band = up-low+1; X if (band < 1) `7B X printf("low > up is unacceptable!\n"); X exit(1); X `7D X j = (MW+1+2) * sizeof(int); X `20 X `20 X if (CC==NULL) `7B X CC = (int *) ckalloc(j); X DD = (int *) ckalloc(j); X `7D X `20 X if (low > 0) leftd = 1; X else if (up < 0) leftd = band; X else leftd = 1-low; X rightd = band; X si = max(0,-up); X ei = min(M,N-low); X CC`5Bleftd`5D = 0; X for (j = leftd+1; j <= rightd; j++) `7B X CC`5Bj`5D = 0; X DD`5Bj`5D = -G; X `7D X CC`5Brightd+1`5D = MININT; X DD`5Brightd+1`5D = MININT; X best_score = 0; X endi = si; X endj = si+low; X CC`5Bleftd-1`5D = MININT; X DD`5Bleftd`5D = -G; X for (i = si+1; i <= ei; i++) `7B X if (i > N-up) rightd--; X if (leftd > 1) leftd--; X e = MININT; X wa = W`5BA`5Bi`5D`5D; X if ((c = CC`5Bleftd+1`5D-m) > (d = DD`5Bleftd+1`5D-H)) d = c; X if ((ib = leftd+low-1+i) > 0) c = CC`5Bleftd`5D+wa`5BB`5Bib`5D`5D; X if (d > c) c = d; X if (c < 0) c = 0; X e = c-G; X DD`5Bleftd`5D = d; X CC`5Bleftd`5D = c; X if (c > best_score) `7B X best_score = c; X endi = i; X endj = ib; X `7D X for (curd=leftd+1; curd <= rightd; curd++) `7B X if ((c = c-m) > (e = e-H)) e = c; X if ((c = CC`5Bcurd+1`5D-m) > (d = DD`5Bcurd+1`5D-H)) d = c; X c = CC`5Bcurd`5D + wa`5BB`5Bcurd+low-1+i`5D`5D; X if (e > c) c = e; X if (d > c) c = d; X if (c < 0) c = 0; X if (c > lc) lc = c; X CC`5Bcurd`5D = c; X DD`5Bcurd`5D = d; X if (c > best_score) `7B X`09best_score = c; X`09endi = i; X`09endj = curd+low-1+i; X `7D X `7D X if (lc <= 0) break; X `7D X `20 X if (!dflag) `7B X /*`09 free(CC); free(DD); */ X *pei = endi; X *pej = endj; X return best_score; X `7D X`7D `20 X Xint RLOCAL_ALIGN(A,B,M,N,low,up,W,G,H,dflag,psi,psj,pei,pej,MW) X char A`5B`5D,B`5B`5D; X int M,N,low,up; X int W`5B`5D`5B32`5D,G,H; X int dflag; X int *psi, *psj, *pei, *pej; X int MW; X`7B`20 X int band; X char *ckalloc(); X int i, j, si, ei; X int c, d, e, t, m; X int lc;`09`09/* row local score */ X int leftd, rightd; X int best_score, starti, startj; X int *wa, curd, ib; X int flag; X `20 X m = G+H; X low = max(-M, low); X up = min(N, up); X if (N <= 0) `7B`20 X *psi = *psj = *pei = *pej; X return 0; X `7D X if (M <= 0) `7B X *psi = *psj = *pei = *pej; X return 0; X `7D X band = up-low+1; X if (band < 1) `7B X printf("low > up is unacceptable!\n"); X exit(1); X `7D X j = (MW+1+2) * sizeof(int); X `20 X if (CC==NULL) `7B X CC = (int *) ckalloc(j); X DD = (int *) ckalloc(j); X `7D X `20 X leftd = max(1,-M-low+1); X rightd = band-(up-(N-M)); X CC`5Brightd`5D = 0; X t = -G; X for (j = rightd-1; j >= leftd; j--) `7B X CC`5Bj`5D = t = t-H; X DD`5Bj`5D = t-G; X `7D X CC`5Bleftd-1`5D = DD`5Bleftd-1`5D = MININT; X CC`5Brightd+1`5D = MININT; X DD`5Brightd`5D = -G; X best_score = 0; X starti = M; X startj = N; X flag = 0; X for (i = M; i >= 1; i--) `7B X if (i+low <= 0) leftd++; X if (rightd < band) rightd++; X e = MININT; X wa = W`5BA`5Bi`5D`5D; X if ((c = CC`5Brightd-1`5D-m) > (d = DD`5Brightd-1`5D-H)) d = c; X if ((ib = rightd+low-1+i) <= N) c = CC`5Brightd`5D+wa`5BB`5Bib`5D`5D; X if (d > c) c = d; X e = c-G; X DD`5Brightd`5D = d; X CC`5Brightd`5D = c; X if (c == best_score) `7B X starti = i; X startj = ib; X flag = 1; X break; X `7D X lc = 0; X for (curd=rightd-1; curd >= leftd; curd--) `7B X if ((c = c-m) > (e = e-H)) e = c; X if ((c = CC`5Bcurd-1`5D-m) > (d = DD`5Bcurd-1`5D-H)) d = c; X c = CC`5Bcurd`5D + wa`5BB`5Bcurd+low-1+i`5D`5D; X if (e > c) c = e; X if (d > c) c = d; X if (c < 0) c = 0; X if (lc < c) lc = c; X CC`5Bcurd`5D = c; X DD`5Bcurd`5D = d; X if (c > best_score) `7B X`09best_score = c; X`09starti = i; X`09startj = curd+low-1+i; X `7D X `7D X if (lc <= 0) break; X `7D X `20 X /* free(CC); X free(DD); X */ X if (starti < 0 `7C`7C starti > M `7C`7C startj < 0 `7C`7C startj > N) `7B X printf("starti=%d, startj=%d\n",starti,startj); X *psi = *psj = *pei = *pej; X exit(1); X `7D X *psi = starti; X *psj = startj; X return best_score; X`7D X X#endif X $ CALL UNPACK L_BAND.C;1 192446240 $ create 'f' Xinstall : all X`09$ fasta :== $ uvaccl$dua8:`5Bsequence.fasta16c`5Dfasta.exe X`09$ tfasta :== $ uvaccl$dua8:`5Bsequence.fasta16c`5Dtfasta.exe X`09$ lfasta :== $ uvaccl$dua8:`5Bsequence.fasta16c`5Dlfasta.exe X`09$ plfasta :== $ uvaccl$dua8:`5Bsequence.fasta16c`5Dplfasta.exe X`09$ align :== $ uvaccl$dua8:`5Bsequence.fasta16c`5Dalign.exe X`09$ lalign :== $ uvaccl$dua8:`5Bsequence.fasta16c`5Dlalign.exe X`09$ plalign :== $ uvaccl$dua8:`5Bsequence.fasta16c`5Dplalign.exe X`09$ ssearch :== $ uvaccl$dua8:`5Bsequence.fasta16c`5Dssearch.exe X`09$ rss :== $ uvaccl$dua8:`5Bsequence.fasta16c`5Drss.exe X`09$ rdf2 :== $ uvaccl$dua8:`5Bsequence.fasta16c`5Drdf2.exe X`09$ bestscore :== $ uvaccl$dua8:`5Bsequence.fasta16c`5Dbestscore.exe X Xall : lfasta.exe plfasta.exe lalign.exe plalign.exe fasta.exe tfasta.exe rdf V2.exe ssearch.exe rss.exe align.exe bestscore.exe X Xlfasta.exe : lfasta.obj pam.obj zlgmata.obj ll_band.obj g_band.obj lgetaa.ob Vj ndispn.obj crck.obj time.obj getenv.obj getopt.obj X`09$link/exe=lfasta lfasta.obj,pam.obj,zlgmata.obj,ll_band.obj,g_band.obj,lg Vetaa.obj,ndispn.obj,crck.obj,time.obj,getenv.obj,getopt.obj X Xplfasta.exe : plfasta.obj pam.obj zlgmata.obj ll_band.obj g_band.obj lgetaa V.obj tldispn.obj crck.obj time.obj getenv.obj getopt.obj X`09$link/exe=plfasta plfasta.obj,pam.obj,zlgmata.obj,ll_band.obj,g_band.obj, Vlgetaa.obj,tldispn.obj,crck.obj,time.obj,getenv.obj,getopt.obj X Xlalign.exe : lalign.obj pam.obj lsim.obj lgetaa.obj ndispn.obj crck.obj time V.obj getenv.obj getopt.obj X`09$link/exe=lalign lalign.obj,pam.obj,lsim.obj,lgetaa.obj,ndispn.obj,crck.o Vbj,time.obj,getenv.obj,getopt.obj X Xplalign.exe : plalign.obj pam.obj plsim.obj lgetaa.obj tldispn.obj crck.obj V time.obj getenv.obj getopt.obj X`09$link/exe=plalign plalign.obj,pam.obj,plsim.obj,lgetaa.obj,tldispn.obj,cr Vck.obj,time.obj,getenv.obj,getopt.obj X Xfasta.exe : ifasta.obj pam.obj zgmata.obj l_band.obj g_band.obj fgetaa.obj n Vdispn.obj time.obj getenv.obj getopt.obj X`09$link/exe=fasta ifasta.obj,pam.obj,zgmata.obj,l_band.obj,g_band.obj,fgeta Va.obj,ndispn.obj,time.obj, getenv.obj,getopt.obj X Xtfasta.exe : tfasta.obj faatran.obj pam.obj zgmata.obj l_band.obj g_band.obj V tgetaa.obj ndispn.obj time.obj getenv.obj getopt.obj X`09$link tfasta.obj,faatran.obj,pam.obj,zgmata.obj,l_band.obj,g_band.obj,tge Vtaa.obj,ndispn.obj,time.obj, getenv.obj, getopt.obj X Xssearch.exe : ssearch.obj pam.obj sgmata.obj llmax.obj fgetaa.obj ndispn.obj V time.obj getenv.obj getopt.obj X`09$link/exe=ssearch ssearch.obj,pam.obj,sgmata.obj,llmax.obj,fgetaa.obj,ndi Vspn.obj,time.obj,getenv.obj,getopt.obj X Xalign.exe : align.obj pam.obj llmax.obj lgetaa.obj ndispn.obj time.obj geten Vv.obj getopt.obj X`09$link/exe=align align.obj,pam.obj,llmax.obj,lgetaa.obj,ndispn.obj,time.ob Vj, getenv.obj,getopt.obj X Xrdf2.exe : urdf.obj pam.obj zgmata.obj l_band.obj g_band.obj nrand.obj lgeta Va.obj time.obj getenv.obj getopt.obj X`09$link/exe=rdf2 urdf.obj,pam.obj,l_band.obj,g_band.obj,zgmata.obj,nrand.ob Vj,lgetaa.obj,time.obj, getenv.obj, getopt.obj X Xrss.exe : urss.obj pam.obj sgmata.obj nrand.obj lgetaa.obj time.obj getenv.o Vbj getopt.obj X`09$link/exe=rss urss.obj,pam.obj,sgmata.obj,nrand.obj,lgetaa.obj,time.obj, V getenv.obj, getopt.obj X Xrelate.exe : relate.obj pam.obj lgetaa.obj time.obj getenv.obj getopt.obj X`09$link/exe=relate relate.obj,pam.obj,lgetaa.obj,time.obj,getenv.obj,getopt V.obj X Xlfasta.obj : fffasta.c upam.gbl X`09$cc/define=(LFASTA,BIGMEM)/obj=lfasta fffasta.c X Xplfasta.obj : fffasta.c upam.gbl X`09$cc/define=(LFASTA,TPLOT,BIGMEM)/obj=plfasta fffasta.c X Xlalign.obj : lalign.c upam.gbl X`09$cc/define=(BIGMEM)/obj=lalign lalign.c X Xplalign.obj : lalign.c upam.gbl X`09$cc/define=(TPLOT,BIGMEM)/obj=plalign lalign.c X Xifasta.obj : fffasta.c upam.gbl X`09$cc/define=(MAXSAV=10,BIGMEM)/obj=ifasta fffasta.c X Xtfasta.obj : fffasta.c upam.gbl X`09$cc/define=(BIGMEM,TFASTA,MAXSAV=10)/obj=tfasta fffasta.c X Xurdf.obj : urdf.c upam.gbl X`09$cc/define=(BIGMEM,MAXSAV=10) urdf.c X Xurdfw.obj : urdf.c upam.gbl X`09$cc/define=(BIGMEM,MAXSAV=10,WINDOW)/obj=urdfw urdf.c X Xl_band.obj : l_band.c zzgmata.gbl upam.gbl X`09$cc/define=(BIGMEM)/obj=l_band.obj X Xll_band.obj : l_band.c zzgmata.gbl upam.gbl X`09$cc/define=(BIGMEM,LFASTA)/obj=ll_band.obj X Xg_band.obj : g_band.c zzgmata.gbl upam.gbl X`09$cc/define=(BIGMEM)/obj=g_band.obj X Xssearch.obj : ssearch.c upam.gbl X`09$cc/define=(BIGMEM) ssearch.c X Xurss.obj : urss.c upam.gbl X`09$cc/define=(BIGMEM) urss.c X Xalign.obj : align.c upam.gbl X`09$cc/define=(BIGMEM) align.c X Xllmax.obj : llmax.c X`09$cc/define=(BIGMEM) llmax.c X Xfaatran.obj : faatran.c upam.gbl aamap.gbl uascii.gbl X`09$cc faatran X Xpam.obj : pam.c uascii.gbl upam.gbl X`09$cc pam X Xsgmata.obj : zzlgmata.c zzgmata.gbl upam.gbl X`09$cc/define=(BIGMEM,SMATCH)/obj=sgmata.obj zzlgmata.c X Xlsim.obj : lsim.c zzgmata.gbl upam.gbl X`09$cc/define=(BIGMEM) lsim.c X Xplsim.obj : lsim.c zzgmata.gbl upam.gbl X`09$cc/define=(BIGMEM,TPLOT)/obj=plsim lsim.c X Xl_band.obj : l_band.c zzgmata.gbl upam.gbl X`09$cc/define=(BIGMEM) l_band.c X Xll_band.obj : l_band.c zzgmata.gbl upam.gbl X`09$cc/define=(BIGMEM,LFASTA)/obj=ll_band l_band.c X Xg_band.obj : g_band.c zzgmata.gbl upam.gbl X`09$cc/define=(BIGMEM) g_band.c X Xzlgmata.obj : zzlgmata.c zzgmata.gbl upam.gbl X`09$cc/define=(BIGMEM,LFASTA)/obj=zlgmata zzlgmata.c X Xinstall : all X`09$ fasta :== $ uvaccl$dua8:`5Bsequence.fasta16c`5Dfasta.exe X`09$ tfasta :== $ uvaccl$dua8:`5Bsequence.fasta16c`5Dtfasta.exe X`09$ lfasta :== $ uvaccl$dua8:`5Bsequence.fasta16c`5Dlfasta.exe X`09$ plfasta :== $ uvaccl$dua8:`5Bsequence.fasta16c`5Dplfasta.exe X`09$ align :== $ uvaccl$dua8:`5Bsequence.fasta16c`5Dalign.exe X`09$ lalign :== $ uvaccl$dua8:`5Bsequence.fasta16c`5Dlalign.exe X`09$ plalign :== $ uvaccl$dua8:`5Bsequence.fasta16c`5Dplalign.exe X`09$ ssearch :== $ uvaccl$dua8:`5Bsequence.fasta16c`5Dssearch.exe X`09$ rss :== $ uvaccl$dua8:`5Bsequence.fasta16c`5Drss.exe X`09$ rdf2 :== $ uvaccl$dua8:`5Bsequence.fasta16c`5Drdf2.exe X`09$ bestscore :== $ uvaccl$dua8:`5Bsequence.fasta16c`5Dbestscore.exe X Xall : lfasta.exe plfasta.exe lalign.exe plalign.exe fasta.exe tfasta.exe rdf V2.exe ssearch.exe rss.exe align.exe bestscore.exe X Xlfasta.exe : lfasta.obj pam.obj zlgmata.obj ll_band.obj g_band.obj lgetaa.ob Vj ndispn.obj crck.obj time.obj getenv.obj getopt.obj X`09$link/exe=lfasta lfasta.obj,pam.obj,zlgmata.obj,ll_band.obj,g_band.obj,lg Vetaa.obj,ndispn.obj,crck.obj,time.obj,getenv.obj,getopt.obj X Xplfasta.exe : plfasta.obj pam.obj plgmata.obj ll_band.obj g_band.obj lgetaa V.obj tldispn.obj crck.obj time.obj getenv.obj getopt.obj X`09$link/exe=plfasta plfasta.obj,pam.obj,plgmata.obj,ll_band.obj,g_band.obj, Vlgetaa.obj,tldispn.obj,crck.obj,time.obj,getenv.obj,getopt.obj X Xlalign.exe : lalign.obj pam.obj lsim.obj lgetaa.obj ndispn.obj crck.obj time V.obj getenv.obj getopt.obj X`09$link/exe=lalign lalign.obj,pam.obj,lsim.obj,lgetaa.obj,ndispn.obj,crck.o Vbj,time.obj,getenv.obj,getopt.obj X Xplalign.exe : plalign.obj pam.obj plsim.obj lgetaa.obj tldispn.obj crck.obj V time.obj getenv.obj getopt.obj X`09$link/exe=plalign plalign.obj,pam.obj,plsim.obj,lgetaa.obj,tldispn.obj,cr Vck.obj,time.obj,getenv.obj,getopt.obj X Xfasta.exe : ifasta.obj pam.obj zgmata.obj l_band.obj g_band.obj fgetaa.obj n Vdispn.obj time.obj getenv.obj getopt.obj X`09$link/exe=fasta ifasta.obj,pam.obj,zgmata.obj,l_band.obj,g_band.obj,fgeta Va.obj,ndispn.obj,time.obj, getenv.obj,getopt.obj X Xtfasta.exe : tfasta.obj faatran.obj pam.obj zgmata.obj l_band.obj g_band.obj V tgetaa.obj ndispn.obj time.obj getenv.obj getopt.obj X`09$link tfasta.obj,faatran.obj,pam.obj,zgmata.obj,l_band.obj,g_band.obj,tge Vtaa.obj,ndispn.obj,time.obj, getenv.obj, getopt.obj X Xssearch.exe : ssearch.obj pam.obj sgmata.obj llmax.obj fgetaa.obj ndispn.obj V time.obj getenv.obj getopt.obj X`09$link/exe=ssearch ssearch.obj,pam.obj,sgmata.obj,llmax.obj,fgetaa.obj,ndi Vspn.obj,time.obj,getenv.obj,getopt.obj X Xalign.exe : align.obj pam.obj llmax.obj lgetaa.obj ndispn.obj time.obj geten Vv.obj getopt.obj X`09$link/exe=align align.obj,pam.obj,llmax.obj,lgetaa.obj,ndispn.obj,time.ob Vj, getenv.obj,getopt.obj X Xrdf2.exe : urdf.obj pam.obj zgmata.obj l_band.obj g_band.obj nrand.obj lgeta Va.obj time.obj getenv.obj getopt.obj X`09$link/exe=rdf2 urdf.obj,pam.obj,l_band.obj,g_band.obj,zgmata.obj,nrand.ob Vj,lgetaa.obj,time.obj, getenv.obj, getopt.obj X Xrss.exe : urss.obj pam.obj sgmata.obj nrand.obj lgetaa.obj time.obj getenv.o Vbj getopt.obj X`09$link/exe=rss urss.obj,pam.obj,sgmata.obj,nrand.obj,lgetaa.obj,time.obj, V getenv.obj, getopt.obj X Xrelate.exe : relate.obj pam.obj lgetaa.obj time.obj getenv.obj getopt.obj X`09$link/exe=relate relate.obj,pam.obj,lgetaa.obj,time.obj,getenv.obj,getopt V.obj X Xlfasta.obj : fffasta.c upam.gbl X`09$cc/define=(LFASTA,BIGMEM)/obj=lfasta fffasta.c X Xplfasta.obj : fffasta.c upam.gbl X`09$cc/define=(LFASTA,TPLOT,BIGMEM)/obj=plfasta fffasta.c X Xlalign.obj : lalign.c upam.gbl X`09$cc/define=(BIGMEM)/obj=lalign lalign.c X Xplalign.obj : lalign.c upam.gbl X`09$cc/define=(TPLOT,BIGMEM)/obj=plalign lalign.c X Xifasta.obj : fffasta.c upam.gbl X`09$cc/define=(MAXSAV=10,BIGMEM)/obj=ifasta fffasta.c X Xtfasta.obj : fffasta.c upam.gbl X`09$cc/define=(BIGMEM,TFASTA,MAXSAV=10)/obj=tfasta fffasta.c X Xurdf.obj : urdf.c upam.gbl X`09$cc/define=(BIGMEM,MAXSAV=10) urdf.c X Xurdfw.obj : urdf.c upam.gbl X`09$cc/define=(BIGMEM,MAXSAV=10,WINDOW)/obj=urdfw urdf.c X Xl_band.obj : l_band.c zzgmata.gbl upam.gbl X`09$cc/define=(BIGMEM)/obj=l_band.obj X Xll_band.obj : l_band.c zzgmata.gbl upam.gbl X`09$cc/define=(BIGMEM,LFASTA)/obj=ll_band.obj X Xg_band.obj : g_band.c zzgmata.gbl upam.gbl X`09$cc/define=(BIGMEM)/obj=g_band.obj X Xssearch.obj : ssearch.c upam.gbl X`09$cc/define=(BIGMEM) ssearch.c X Xurss.obj : urss.c upam.gbl X`09$cc/define=(BIGMEM) urss.c X Xalign.obj : align.c upam.gbl X`09$cc/define=(BIGMEM) align.c X Xllmax.obj : llmax.c X`09$cc/define=(BIGMEM) llmax.c X Xfaatran.obj : faatran.c upam.gbl aamap.gbl uascii.gbl X`09$cc faatran X Xpam.obj : pam.c uascii.gbl upam.gbl X`09$cc pam X Xsgmata.obj : zzlgmata.c zzgmata.gbl upam.gbl X`09$cc/define=(BIGMEM,SMATCH)/obj=sgmata.obj zzlgmata.c X Xlsim.obj : lsim.c zzgmata.gbl upam.gbl X`09$cc/define=(BIGMEM) lsim.c X Xplsim.obj : lsim.c zzgmata.gbl upam.gbl X`09$cc/define=(BIGMEM,TPLOT)/obj=plsim lsim.c X Xl_band.obj : l_band.c zzgmata.gbl upam.gbl X`09$cc/define=(BIGMEM) l_band.c X Xll_band.obj : l_band.c zzgmata.gbl upam.gbl X`09$cc/define=(BIGMEM,LFASTA)/obj=ll_band l_band.c X Xg_band.obj : g_band.c zzgmata.gbl upam.gbl X`09$cc/define=(BIGMEM) g_band.c X Xzlgmata.obj : zzlgmata.c zzgmata.gbl upam.gbl X`09$cc/define=(BIGMEM,LFASTA)/obj=zlgmata zzlgmata.c X Xplgmata.obj : zzlgmata.c zzgmata.gbl upam.gbl X`09$cc/define=(BIGMEM,LFASTA,TPLOT)/obj=plgmata zzlgmata.c X Xzggmata.obj : zzlgmata.c zzgmata.gbl upam.gbl X`09$cc/define=(BIGMEM,GLOBAL)/obj=zggmata zzlgmata.c X Xfgetaa.obj : uwgetaa.c upam.gbl uascii.gbl X`09$cc/define=(VMS5X)/obj=fgetaa uwgetaa.c X Xlgetaa.obj : uwgetaa.c upam.gbl uascii.gbl X`09$cc/define=(NOLIB)/obj=lgetaa uwgetaa.c X Xtgetaa.obj : uwgetaa.c upam.gbl uascii.gbl X`09$cc/define=(VMS5X,TFASTA)/obj=tgetaa uwgetaa.c X Xndispn.obj : ndispn.c upam.gbl X`09$cc ndispn X Xtldispn.obj : tldispn.c upam.gbl X`09$cc tldispn X Xnrand.obj : nrand.c X`09$cc/define=(RAND32) nrand.c X Xtime.obj : time.c X`09$cc/define=(HZ=100)/obj=time time.c X Xgetenv.obj : getenv.c X`09$cc/obj=getenv vmsgeten.c X Xgetopt.obj : getopt.c X`09$cc getopt.c X Xcrck.obj : crck.c X`09$cc crck.c X Xbestscor.exe : bestscor.obj pam.obj lgetaa.obj getopt.obj X`09$link/exe=bestscor.exe bestscor.obj, pam.obj, lgetaa.obj, getopt.obj X Xbestscor.obj : bestscor.c X`09$cc bestscor.c $ CALL UNPACK MAKEFILE.;3 1265102563 $ create 'f' X# makefile for DOS version of fasta programs X# copyright (c) 1987 William R. Pearson X# X X#sun (bsd) X#CC= cc X#CFLAGS= -O -DBIGMEM -Dstrchr=index X#LFLAGS= -lm -o X#NRAND= nrand X#HZ=60 X X#ATT 3b5 X#CC= cc X#CFLAGS= -f -O -DBIGMEM X#LFLAGS= -f -lm -o X#NRAND= nrand48 X#HZ=100 X X# XENIX`09(assumes M_I86 defined by compiler) X# (also assumes M_XENIX defined if FAR_PTR is defined) X#CC= cc X#CFLAGS= -i -Ms2 -K -O -Me -DFAR_PTR X#LFLAGS= -i -lm -o X#NRAND= nrand48 X#HZ= 50 X X# MSDOS MSC commands X#CC= cl X#CFLAGS= -DFAR_PTR -DI86BUG -DALLOCN0 X#LFLAGS= -F1000 X#NRAND= nrand X#HZ=100 X X# MSDOS TURBO C commands XCC= tcc XCFLAGS= -ID:\tc2\include -DFAR_PTR -DALLOCN0 -DMSDOS -DTURBOC XCL= tcc XLFLAGS= -LD:\tc2\lib XNRAND= nrand XHZ=100 X X.c.obj: X`09$(CC) $(CFLAGS) -c $< X Xall : fasta.exe tfasta.exe rdf2.exe ssearch.exe align.exe align0.exe rss.exe V relate.exe lfasta.exe plfasta.exe lalign.exe plalign.exe bestscor.exe greas Ve.exe tgrease.exe gbann.exe extractn.exe sindex.exe extractp.exe garnier.exe V findp.exe findn.exe fromgb.exe aacomp.exe X Xlfasta.exe : lfasta.obj zlgmata.obj ll_band.obj g_band.obj pam.obj lfgetaa.o Vbj ndispn.obj crck.obj time.obj getopt.obj X`09$(CL) $(LFLAGS) -elfasta.exe lfasta.obj zlgmata.obj ndispn.obj crck.obj V @lfasta.rsp X Xplfasta.exe : plfasta.obj plgmata.obj ll_band.obj g_band.obj lfgetaa.obj ttd Vispn.obj pam.obj crck.obj time.obj getopt.obj X`09$(CL) $(LFLAGS) -eplfasta plfasta.obj plgmata.obj ttdispn.obj crck.obj @l Vfasta.rsp graphics.lib X Xfasta.exe : ifastaf.obj pam.obj zgmata.obj l_band.obj g_band.obj nxgetaa.obj V getann.obj ndispn.obj time.obj getopt.obj X`09$(CL) $(LFLAGS) -efasta.exe ifastaf.obj zgmata.obj nxgetaa.obj getann.ob Vj ndispn.obj @fasta.rsp X Xtfasta.exe : tfasta.obj faatran.obj pam.obj zgmata.obj l_band.obj g_band.obj V tnxgetaa.obj ndispn.obj time.obj getopt.obj getann.obj X`09$(CL) $(LFLAGS) -etfasta.exe tfasta.obj faatran.obj zgmata.obj tnxgetaa. Vobj ndispn.obj getann.obj @fasta.rsp X Xssearch.exe : ssearch.obj pam.obj sgmata.obj llmax.obj nxgetaa.obj getann.ob Vj ndispn.obj time.obj getopt.obj`20 X`09$(CL) $(LFLAGS) -essearch.exe ssearch.obj sgmata.obj llmax.obj nxgetaa.o Vbj getann.obj ndispn.obj pam.obj time.obj getopt.obj X Xtsearch.exe : tsearch.obj faatran.obj pam.obj sgmata.obj llmax.obj tnxgetaa. Vobj ndispn.obj time.obj getopt.obj getann.obj X`09$(CL) $(LFLAGS) -etsearch.exe tsearch.obj faatran.obj sgmata.obj llmax.o Vbj tnxgetaa.obj ndispn.obj getann.obj pam.obj time.obj getopt.obj X Xrdf2.exe : urdf.obj pam.obj zgmata.obj l_band.obj g_band.obj $(NRAND).obj lf Vgetaa.obj time.obj X`09$(CL) $(LFLAGS) -erdf2.exe urdf.obj zgmata.obj @fasta.rsp $(NRAND).obj l Vfgetaa.obj X Xrss.exe : urss.obj pam.obj sgmata.obj $(NRAND).obj lfgetaa.obj time.obj geto Vpt.obj X`09$(CL) $(LFLAGS) -erss.exe urss.obj pam.obj sgmata.obj $(NRAND).obj lfgeta Va.obj time.obj getopt.obj X Xrelate.exe : relate.obj pam.obj lfgetaa.obj time.obj X`09$(CL) $(LFLAGS) -erelate.exe relate.obj pam.obj lfgetaa.obj time.obj geto Vpt.obj X Xalign.exe : align.obj pam.obj llmax.obj lfgetaa.obj ndispn.obj time.obj X`09$(CL) $(LFLAGS) -ealign.exe align.obj pam.obj llmax.obj lfgetaa.obj ndis Vpn.obj time.obj getopt.obj X Xalign0.exe : align.obj pam.obj llmax0.obj lfgetaa.obj ndispn.obj time.obj X`09$(CL) $(LFLAGS) -ealign0.exe align.obj pam.obj llmax0.obj lfgetaa.obj nd Vispn.obj time.obj getopt.obj X Xlalign.exe : lalign.obj pam.obj lsim.obj lfgetaa.obj ndispn.obj time.obj get Vopt.obj X`09$(CL) $(LFLAGS) -elalign.exe lalign.obj pam.obj lsim.obj lfgetaa.obj ndis Vpn.obj time.obj getopt.obj X Xplalign.exe : plalign.obj pam.obj plsim.obj lfgetaa.obj ttdispn.obj time.obj V getopt.obj X`09$(CC) $(LFLAGS) -eplalign.exe plalign.obj pam.obj plsim.obj lfgetaa.obj V ttdispn.obj time.obj getopt.obj graphics.lib X Xextractn.exe : extractn.obj fgetgb.obj X`09$(CL) $(LFLAGS) -eextractn.exe extractn.obj fgetgb.obj X Xgbann.exe : gbann.obj fgetgb.obj getopt.obj X`09$(CL) $(LFLAGS) -egbann.exe gbann.obj fgetgb.obj getopt.obj X Xsindex.exe : sindex.c X`09$(CC) -ml $(CFLAGS) $(LFLAGS) sindex.c X Xextractp.exe : extractp.obj X`09$(CL) $(LFLAGS) -eextractp.exe extractp.obj X Xlfasta.obj : fffasta.c upam.gbl X`09$(CC) $(CFLAGS) -DLFASTA -olfasta.obj -c fffasta.c X Xplfasta.obj : fffasta.c upam.gbl X`09$(CC) $(CFLAGS) -DLFASTA -DTPLOT -oplfasta.obj -c fffasta.c X Xifastaf.obj : fffasta.c upam.gbl X`09$(CC) $(CFLAGS) -DMAXSAV=10 -oifastaf.obj -c fffasta.c X Xssearch.obj : ssearch.c upam.gbl X`09$(CC) $(CFLAGS) -ossearch.obj -c ssearch.c X Xtsearch.obj : ssearch.c upam.gbl X`09$(CC) $(CFLAGS) -DTFASTA -otsearch.obj -c ssearch.c X Xtfasta.obj : fffasta.c upam.gbl X`09$(CC) $(CFLAGS) -DTFASTA -DMAXSAV=10 -otfasta.obj -c fffasta.c X Xurdf.obj : urdf.c upam.gbl X`09$(CC) $(CFLAGS) -c -DMAXSAV=10 urdf.c X Xurss.obj : urss.c upam.gbl X`09$(CC) $(CFLAGS) -c urss.c X Xalign.obj : align.c upam.gbl X`09$(CC) $(CFLAGS) -c align.c X Xextractn.obj : extractn.c genbank.h upam.gbl X Xgbann.obj : gbann.c genbank.h upam.gbl X Xlalign.obj : lalign.c upam.gbl X Xplalign.obj : lalign.c upam.gbl X`09$(CC) $(CFLAGS) -DTPLOT -oplalign.obj -c lalign.c X Xlsim.obj : lsim.c X Xplsim.obj : lsim.c X`09$(CC) $(CFLAGS) -DTPLOT -oplsim.obj -c lsim.c X Xllmax.obj : llmax.c X Xllmax0.obj : llmax0.c X Xfaatran.obj : upam.gbl aamap.gbl uascii.gbl X Xpam.obj : uascii.gbl upam.gbl X Xzlgmata.obj : zzlgmata.c zzgmata.gbl upam.gbl X`09$(CC) $(CFLAGS) -DLFASTA -ozlgmata.obj -c zzlgmata.c X Xsgmata.obj : zzlgmata.c zzgmata.gbl upam.gbl X`09$(CC) $(CFLAGS) -DSMATCH -osgmata.obj -c zzlgmata.c X Xplgmata.obj : zzlgmata.c zzgmata.gbl upam.gbl X`09$(CC) $(CFLAGS) -DLFASTA -DTPLOT -oplgmata.obj -c zzlgmata.c X Xzgmata.obj : zzlgmata.c zzgmata.gbl upam.gbl X`09$(CC) $(CFLAGS) -ozgmata.obj -c zzlgmata.c X Xzggmata.obj : zzlgmata.c zzgmata.gbl upam.gbl X`09$(CC) $(CFLAGS) -DGLOBAL -ozggmata.obj -c zzlgmata.c X Xg_band.obj : g_band.c X Xl_band.obj : l_band.c X Xll_band.obj : l_band.c X`09$(CC) $(CFLAGS) -DLFASTA -oll_band.obj -c l_band.c X Xnxgetaa.obj : nxgetaa.c upam.gbl uascii.gbl X Xlfgetaa.obj : nxgetaa.c upam.gbl uascii.gbl X`09$(CC) $(CFLAGS) -DNOLIB -olfgetaa.obj -c nxgetaa.c X Xtnxgetaa.obj : nxgetaa.c upam.gbl uascii.gbl X`09$(CC) $(CFLAGS) -DTFASTA -otnxgetaa.obj -c nxgetaa.c X Xfgetgb.obj : fgetgb.c upam.gbl uascii.gbl genbank.h X`09$(CC) $(CFLAGS) -c fgetgb.c X Xgetann.obj : genbank.h X Xndispn.obj : upam.gbl X Xttdispn.obj : upam.gbl X Xpcldispn.obj : upam.gbl X Xtime.obj : time.c X`09$(CC) $(CFLAGS) -DHZ=$(HZ) -c time.c X Xgrease.exe : grease.obj lfgetaa.obj X`09$(CL) $(LFLAGS) -egrease.exe grease.obj lfgetaa.obj X Xtgrease.exe : tgrease.obj lfgetaa.obj tplotsub.obj X`09$(CL) $(LFLAGS) -etgrease.exe tgrease.obj lfgetaa.obj tplotsub.obj graph Vics.lib X Xbestscor.exe : bestscor.obj pam.obj lfgetaa.obj getopt.obj X`09$(CC) $(LFLAGS) bestscor.obj pam.obj lfgetaa.obj getopt.obj X Xgarnier.exe : garnier.obj lfgetaa.obj X`09$(CL) $(LFLAGS) garnier.obj lfgetaa.obj X Xgarnier.obj : garnier.h X Xfindp.exe : findp.obj qsubs.obj X`09$(CL) $(LFLAGS) -efindp findp.obj qsubs.obj X Xfindn.exe : findn.obj qsubs.obj X`09$(CL) $(LFLAGS) -efindn findn.obj qsubs.obj X Xfindp.obj : findp.c find.gbl X Xfindn.obj : findn.c find.gbl X Xqsubs.obj : qsubs.c qsubs.h X Xchofas.exe : chofas.obj lfgetaa.obj X`09$(CC) $(LFLAGS) -echofas.exe chofas.obj lfgetaa.obj X Xfromgb.exe : fromgb.obj X`09$(CC) $(LFLAGS) -efromgb.exe fromgb.obj X Xaacomp.exe : aacomp.obj X`09$(CC) $(LFLAGS) -eaacomp.exe aacomp.obj $ CALL UNPACK MAKEFILE.TC;1 391156837 $ create 'f' X#sun (bsd) XBIN = /seqprg/slib/bin XCC= cc XCFLAGS= -O -DBIGMEM -DUNIX XLFLAGS= -lm -o XNRAND= nrand XRANFLG= -DRAND32 X#HZ=60 for sun, mips, 100 for rs/6000 XHZ=100 X X#ATT 3b5 X#BIN = /va1/slib/bin X#CC= cc X#CFLAGS= -O -DBIGMEM -DUNIX X#LFLAGS= -lm -o X#NRAND= nrand48 X#HZ=100 X X# XENIX`09(assumes M_I86 defined by compiler) X# (also assumes M_XENIX defined if FAR_PTR is defined) X#CC= cc X#CFLAGS= -i -Ox -DALLOCN0 -DUNIX X#LFLAGS= -i -lm -o X#NRAND= nrand48 X#HZ= 50 X XPROGS= fasta lfasta plfasta pclfasta tfasta rdf2 rss relate grease tgrease b Vestscor lalign plalign ssearch align align0 garnier fromgb X.c.o: X`09$(CC) $(CFLAGS) -c $< X Xall : $(PROGS) X Xinstall :`20 X`09cp $(PROGS) $(BIN) X Xclean-up :`20 X`09rm *.o $(PROGS) X Xlfasta : lfasta.o pam.o zlgmata.o ll_band.o g_band.o lgetaa.o ndispn.o crck. Vo time.o X`09$(CC) lfasta.o pam.o zlgmata.o ll_band.o g_band.o lgetaa.o ndispn.o crck. Vo time.o $(LFLAGS) lfasta X Xplfasta : plfasta.o pam.o plgmata.o ll_band.o g_band.o lgetaa.o tldispn.o cr Vck.o time.o X`09$(CC) plfasta.o pam.o plgmata.o ll_band.o g_band.o lgetaa.o tldispn.o crc Vk.o time.o $(LFLAGS) plfasta X Xpclfasta : plfasta.o pam.o plgmata.o ll_band.o g_band.o lgetaa.o pcldispn.o V crck.o time.o X`09$(CC) plfasta.o pam.o plgmata.o ll_band.o g_band.o lgetaa.o pcldispn.o cr Vck.o time.o $(LFLAGS) pclfasta X Xfasta : ifastaf.o pam.o zgmata.o l_band.o g_band.o getaa.o ndispn.o getann.o V time.o X`09$(CC) ifastaf.o pam.o zgmata.o getaa.o ndispn.o getann.o time.o l_band.o V g_band.o $(LFLAGS) fasta X Xtfasta : tfasta.o faatran.o pam.o zgmata.o l_band.o g_band.o tgetaa.o ndispn V.o getann.o time.o X`09$(CC) tfasta.o faatran.o pam.o zgmata.o l_band.o g_band.o tgetaa.o ndispn V.o getann.o time.o $(LFLAGS) tfasta X Xrdf2 : urdfn.o pam.o zgmata.o l_band.o g_band.o $(NRAND).o lgetaa.o time.o X`09$(CC) urdfn.o pam.o zgmata.o l_band.o g_band.o $(NRAND).o lgetaa.o time.o V $(LFLAGS) rdf2 X Xrss : urss.o pam.o sgmata.o $(NRAND).o lgetaa.o time.o X`09$(CC) urss.o pam.o sgmata.o $(NRAND).o lgetaa.o time.o $(LFLAGS) rss X Xrdf2g : urdfn.o pam.o zggmata.o l_band.o g_band.o $(NRAND).o lgetaa.o time.o X`09$(CC) urdfn.o pam.o zggmata.o l_band.o g_band.o $(NRAND).o lgetaa.o time. Vo $(LFLAGS) rdf2g X Xalign : align.o pam.o llmax.o lgetaa.o ndispn.o time.o X`09$(CC) align.o pam.o llmax.o lgetaa.o ndispn.o time.o $(LFLAGS) align X Xalign0 : align.o pam.o llmax0.o lgetaa.o ndispn.o time.o X`09$(CC) align.o pam.o llmax0.o lgetaa.o ndispn.o time.o $(LFLAGS) align0 X Xlalign : lalign.o pam.o lsim.o lgetaa.o ndispn.o time.o X`09$(CC) lalign.o pam.o lsim.o lgetaa.o ndispn.o time.o $(LFLAGS) lalign X Xplalign : plalign.o pam.o plsim.o lgetaa.o tldispn.o time.o X`09$(CC) plalign.o pam.o plsim.o lgetaa.o tldispn.o time.o $(LFLAGS) plalign X Xpclalign : plalign.o pam.o plsim.o lgetaa.o pcldispn.o time.o X`09$(CC) plalign.o pam.o plsim.o lgetaa.o pcldispn.o time.o $(LFLAGS) pclali Vgn X Xssearch : ssearch.o pam.o sgmata.o llmax.o getaa.o getann.o ndispn.o time.o X`09$(CC) ssearch.o pam.o sgmata.o llmax.o getaa.o getann.o ndispn.o time.o $ V(LFLAGS) ssearch X Xrelate : relate.o pam.o lgetaa.o time.o X`09$(CC) relate.o pam.o lgetaa.o time.o -o relate -lm X Xgbann : gbann.o fgetgb.o X`09$(CC) gbann.o fgetgb.o -o gbann X Xextractn : extractn.o fgetgb.o X`09$(CC) extractn.o fgetgb.o -o extractn X Xextractp : extractp.o X`09$(CC) extractp.o -o extractp X Xfromgb : fromgb.o X`09$(CC) fromgb.o -o fromgb X Xsindex : sindex.c X`09$(CC) -DUNIX -O sindex.c -o sindex X`20 Xlfasta.o : fffasta.c upam.gbl X`09$(CC) $(CFLAGS) -c -DLFASTA fffasta.c X`09mv fffasta.o lfasta.o X Xplfasta.o : fffasta.c upam.gbl X`09$(CC) $(CFLAGS) -c -DLFASTA -DTPLOT fffasta.c X`09mv fffasta.o plfasta.o X Xifastaf.o : fffasta.c upam.gbl X`09$(CC) $(CFLAGS) -c -DMAXSAV=10 fffasta.c X`09mv fffasta.o ifastaf.o X Xtfasta.o : fffasta.c upam.gbl X`09$(CC) $(CFLAGS) -c -DTFASTA -DMAXSAV=10 fffasta.c X`09mv fffasta.o tfasta.o X Xalign.o : align.c upam.gbl X Xplalign.o : lalign.c upam.gbl X`09$(CC) $(CFLAGS) -DTPLOT -c lalign.c X`09mv lalign.o plalign.o X Xlalign.o : lalign.c upam.gbl X Xssearch.o : ssearch.c upam.gbl X Xurdfn.o : urdf.c upam.gbl X`09$(CC) $(CFLAGS) -c -DMAXSAV=10 urdf.c X`09mv urdf.o urdfn.o X Xurss.o : urss.c upam.gbl X`09$(CC) $(CFLAGS) -c -DMAXSAV=10 urss.c X Xurdfw.o : urdf.c upam.gbl X`09$(CC) $(CFLAGS) -c -DMAXSAV=10 -DWINDOW urdf.c X`09mv urdf.o urdfw.o X Xfaatran.o : upam.gbl aamap.gbl uascii.gbl X Xpam.o : uascii.gbl upam.gbl X Xzlgmata.o : zzlgmata.c zzgmata.gbl upam.gbl X`09$(CC) $(CFLAGS) -c -DLFASTA zzlgmata.c X`09mv zzlgmata.o zlgmata.o X Xplgmata.o : zzlgmata.c zzgmata.gbl upam.gbl X`09$(CC) $(CFLAGS) -c -DLFASTA -DTPLOT zzlgmata.c X`09mv zzlgmata.o plgmata.o X Xsgmata.o : zzlgmata.c zzgmata.gbl upam.gbl X`09$(CC) $(CFLAGS) -c -DSMATCH zzlgmata.c X`09mv zzlgmata.o sgmata.o X Xlsim.o : lsim.c zzgmata.gbl upam.gbl X`09$(CC) $(CFLAGS) -c lsim.c X Xplsim.o : lsim.c zzgmata.gbl upam.gbl X`09$(CC) $(CFLAGS) -DTPLOT -c lsim.c X`09mv lsim.o plsim.o X Xl_band.o : l_band.c zzgmata.gbl upam.gbl X`09$(CC) $(CFLAGS) -c l_band.c X Xll_band.o : l_band.c zzgmata.gbl upam.gbl X`09$(CC) $(CFLAGS) -DLFASTA -c l_band.c X`09mv l_band.o ll_band.o X Xg_band.o : g_band.c zzgmata.gbl upam.gbl X`09$(CC) $(CFLAGS) -c g_band.c X Xzgmata.o : zzlgmata.c zzgmata.gbl upam.gbl X`09$(CC) $(CFLAGS) -c zzlgmata.c X`09mv zzlgmata.o zgmata.o X Xzggmata.o : zzlgmata.c zzgmata.gbl upam.gbl X`09$(CC) $(CFLAGS) -DGLOBAL -c zzlgmata.c X`09mv zzlgmata.o zggmata.o X Xgetaa.o : nxgetaa.c upam.gbl uascii.gbl genbank.h altlib.h X`09$(CC) $(CFLAGS) -c nxgetaa.c X`09mv nxgetaa.o getaa.o X Xlgetaa.o : nxgetaa.c upam.gbl uascii.gbl altlib.h X`09$(CC) $(CFLAGS) -DNOLIB -c nxgetaa.c X`09mv nxgetaa.o lgetaa.o X Xtgetaa.o : nxgetaa.c upam.gbl uascii.gbl genbank.h altlib.h X`09$(CC) $(CFLAGS) -DTFASTA -c nxgetaa.c X`09mv nxgetaa.o tgetaa.o X Xgetann.o : genbank.h X Xndispn.o : upam.gbl X Xtldispn.o : upam.gbl X Xpcldispn.o : upam.gbl X Xtime.o : time.c X`09$(CC) $(CFLAGS) -DHZ=$(HZ) -c time.c X Xnrand.o : nrand.c X`09$(CC) $(CFLAGS) $(RANFLG) -c nrand.c X Xgbann.o : genbank.h X`09$(CC) $(CFLAGS) -c gbann.c X Xgarnier : garnier.o lgetaa.o X`09$(CC) $(CFLAGS) garnier.o lgetaa.o -o garnier X Xgarnier.o : garnier.h X Xgrease : grease.o lgetaa.o X`09$(CC) $(CFLAGS) grease.o lgetaa.o -o grease X Xtgrease : tgrease.o lgetaa.o plotsub.o X`09$(CC) $(CFLAGS) tgrease.o lgetaa.o plotsub.o -o tgrease X Xchofas : chofas.o lgetaa.o X`09$(CC) $(CFLAGS) chofas.o lgetaa.o -o chofas X Xbestscor : bestscor.o pam.o lgetaa.o X`09$(CC) $(CFLAGS) bestscor.o pam.o lgetaa.o -o bestscor $ CALL UNPACK MAKEFILE.UNX;1 1919350295 $ create 'f' Xinstall : all X`09$ fasta :== $ uvaccl$dua8:`5Bsequence.fasta16`5Dfasta.exe X`09$ tfasta :== $ uvaccl$dua8:`5Bsequence.fasta16`5Dtfasta.exe X`09$ lfasta :== $ uvaccl$dua8:`5Bsequence.fasta16`5Dlfasta.exe X`09$ plfasta :== $ uvaccl$dua8:`5Bsequence.fasta16`5Dplfasta.exe X`09$ align :== $ uvaccl$dua8:`5Bsequence.fasta16`5Dalign.exe X`09$ lalign :== $ uvaccl$dua8:`5Bsequence.fasta16`5Dlalign.exe X`09$ plalign :== $ uvaccl$dua8:`5Bsequence.fasta16`5Dplalign.exe X`09$ ssearch :== $ uvaccl$dua8:`5Bsequence.fasta16`5Dssearch.exe X`09$ rss :== $ uvaccl$dua8:`5Bsequence.fasta16`5Drss.exe X`09$ rdf2 :== $ uvaccl$dua8:`5Bsequence.fasta16`5Drdf2.exe X`09$ bestscore :== $ uvaccl$dua8:`5Bsequence.fasta16`5Dbestscore.exe X Xall : lfasta.exe plfasta.exe lalign.exe plalign.exe fasta.exe tfasta.exe rdf V2.exe ssearch.exe rss.exe align.exe bestscore.exe X Xlfasta.exe : lfasta.obj pam.obj zlgmata.obj ll_band.obj g_band.obj lgetaa.ob Vj ndispn.obj crck.obj time.obj getenv.obj getopt.obj X`09$link/exe=lfasta lfasta.obj,pam.obj,zlgmata.obj,ll_band.obj,g_band.obj,lg Vetaa.obj,ndispn.obj,crck.obj,time.obj,getenv.obj,getopt.obj X Xplfasta.exe : plfasta.obj pam.obj zlgmata.obj ll_band.obj g_band.obj lgetaa V.obj tldispn.obj crck.obj time.obj getenv.obj getopt.obj X`09$link/exe=plfasta plfasta.obj,pam.obj,zlgmata.obj,ll_band.obj,g_band.obj, Vlgetaa.obj,tldispn.obj,crck.obj,time.obj,getenv.obj,getopt.obj X Xlalign.exe : lalign.obj pam.obj lsim.obj lgetaa.obj ndispn.obj crck.obj time V.obj getenv.obj getopt.obj X`09$link/exe=lalign lalign.obj,pam.obj,lsim.obj,lgetaa.obj,ndispn.obj,crck.o Vbj,time.obj,getenv.obj,getopt.obj X Xplalign.exe : plalign.obj pam.obj plsim.obj lgetaa.obj tldispn.obj crck.obj V time.obj getenv.obj getopt.obj X`09$link/exe=plalign plalign.obj,pam.obj,plsim.obj,lgetaa.obj,tldispn.obj,cr Vck.obj,time.obj,getenv.obj,getopt.obj X Xfasta.exe : ifasta.obj pam.obj zgmata.obj l_band.obj g_band.obj fgetaa.obj n Vdispn.obj time.obj getenv.obj getopt.obj X`09$link/exe=fasta ifasta.obj,pam.obj,zgmata.obj,l_band.obj,g_band.obj,fgeta Va.obj,ndispn.obj,time.obj, getenv.obj,getopt.obj X Xtfasta.exe : tfasta.obj faatran.obj pam.obj zgmata.obj l_band.obj g_band.obj V tgetaa.obj ndispn.obj time.obj getenv.obj getopt.obj X`09$link tfasta.obj,faatran.obj,pam.obj,zgmata.obj,l_band.obj,g_band.obj,tge Vtaa.obj,ndispn.obj,time.obj, getenv.obj, getopt.obj X Xssearch.exe : ssearch.obj pam.obj sgmata.obj llmax.obj fgetaa.obj ndispn.obj V time.obj getenv.obj getopt.obj X`09$link/exe=ssearch ssearch.obj,pam.obj,sgmata.obj,llmax.obj,fgetaa.obj,ndi Vspn.obj,time.obj,getenv.obj,getopt.obj X Xalign.exe : align.obj pam.obj llmax.obj lgetaa.obj ndispn.obj time.obj geten Vv.obj getopt.obj X`09$link/exe=align align.obj,pam.obj,llmax.obj,lgetaa.obj,ndispn.obj,time.ob Vj, getenv.obj,getopt.obj X Xrdf2.exe : urdf.obj pam.obj zgmata.obj l_band.obj g_band.obj nrand.obj lgeta Va.obj time.obj getenv.obj getopt.obj X`09$link/exe=rdf2 urdf.obj,pam.obj,l_band.obj,g_band.obj,zgmata.obj,nrand.ob Vj,lgetaa.obj,time.obj, getenv.obj, getopt.obj X Xrss.exe : urss.obj pam.obj sgmata.obj nrand.obj lgetaa.obj time.obj getenv.o Vbj getopt.obj X`09$link/exe=rss urss.obj,pam.obj,sgmata.obj,nrand.obj,lgetaa.obj,time.obj, V getenv.obj, getopt.obj X Xrelate.exe : relate.obj pam.obj lgetaa.obj time.obj getenv.obj getopt.obj X`09$link/exe=relate relate.obj,pam.obj,lgetaa.obj,time.obj,getenv.obj,getopt V.obj X Xlfasta.obj : fffasta.c upam.gbl X`09$cc/define=(LFASTA,BIGMEM)/obj=lfasta fffasta.c X Xplfasta.obj : fffasta.c upam.gbl X`09$cc/define=(LFASTA,TPLOT,BIGMEM)/obj=plfasta fffasta.c X Xlalign.obj : lalign.c upam.gbl X`09$cc/define=(BIGMEM)/obj=lalign lalign.c X Xplalign.obj : lalign.c upam.gbl X`09$cc/define=(TPLOT,BIGMEM)/obj=plalign lalign.c X Xifasta.obj : fffasta.c upam.gbl X`09$cc/define=(MAXSAV=10,BIGMEM)/obj=ifasta fffasta.c X Xtfasta.obj : fffasta.c upam.gbl X`09$cc/define=(BIGMEM,TFASTA,MAXSAV=10)/obj=tfasta fffasta.c X Xurdf.obj : urdf.c upam.gbl X`09$cc/define=(BIGMEM,MAXSAV=10) urdf.c X Xurdfw.obj : urdf.c upam.gbl X`09$cc/define=(BIGMEM,MAXSAV=10,WINDOW)/obj=urdfw urdf.c X Xl_band.obj : l_band.c zzgmata.gbl upam.gbl X`09$cc/define=(BIGMEM)/obj=l_band.obj X Xll_band.obj : l_band.c zzgmata.gbl upam.gbl X`09$cc/define=(BIGMEM,LFASTA)/obj=ll_band.obj X Xg_band.obj : g_band.c zzgmata.gbl upam.gbl X`09$cc/define=(BIGMEM)/obj=g_band.obj X Xssearch.obj : ssearch.c upam.gbl X`09$cc/define=(BIGMEM) ssearch.c X Xurss.obj : urss.c upam.gbl X`09$cc/define=(BIGMEM) urss.c X Xalign.obj : align.c upam.gbl X`09$cc/define=(BIGMEM) align.c X Xllmax.obj : llmax.c X`09$cc/define=(BIGMEM) llmax.c X Xfaatran.obj : faatran.c upam.gbl aamap.gbl uascii.gbl X`09$cc faatran X Xpam.obj : pam.c uascii.gbl upam.gbl X`09$cc pam X Xsgmata.obj : zzlgmata.c zzgmata.gbl upam.gbl X`09$cc/define=(BIGMEM,SMATCH)/obj=sgmata.obj zzlgmata.c X Xlsim.obj : lsim.c zzgmata.gbl upam.gbl X`09$cc/define=(BIGMEM) lsim.c X Xplsim.obj : lsim.c zzgmata.gbl upam.gbl X`09$cc/define=(BIGMEM,TPLOT)/obj=plsim lsim.c X Xl_band.obj : l_band.c zzgmata.gbl upam.gbl X`09$cc/define=(BIGMEM) l_band.c X Xll_band.obj : l_band.c zzgmata.gbl upam.gbl X`09$cc/define=(BIGMEM,LFASTA)/obj=ll_band l_band.c X Xg_band.obj : g_band.c zzgmata.gbl upam.gbl X`09$cc/define=(BIGMEM) g_band.c X Xzlgmata.obj : zzlgmata.c zzgmata.gbl upam.gbl X`09$cc/define=(BIGMEM,LFASTA)/obj=zlgmata zzlgmata.c X Xzgmata.obj : zzlgmata.c zzgmata.gbl upam.gbl X`09$cc/define=(BIGMEM)/obj=zgmata zzlgmata.c X Xzggmata.obj : zzlgmata.c zzgmata.gbl upam.gbl X`09$cc/define=(BIGMEM,GLOBAL)/obj=zggmata zzlgmata.c X Xfgetaa.obj : uwgetaa.c upam.gbl uascii.gbl X`09$cc/define=(VMS5X)/obj=fgetaa uwgetaa.c X Xlgetaa.obj : uwgetaa.c upam.gbl uascii.gbl X`09$cc/define=(NOLIB)/obj=lgetaa uwgetaa.c X Xtgetaa.obj : uwgetaa.c upam.gbl uascii.gbl X`09$cc/define=(VMS5X,TFASTA)/obj=tgetaa uwgetaa.c X Xndispn.obj : ndispn.c upam.gbl X`09$cc ndispn X Xtldispn.obj : tldispn.c upam.gbl X`09$cc tldispn X Xnrand.obj : nrand.c X`09$cc/define=(RAND32) nrand.c X Xtime.obj : time.c X`09$cc/define=(HZ=100)/obj=time time.c X Xgetenv.obj : getenv.c X`09$cc/obj=getenv vmsgeten.c X Xgetopt.obj : getopt.c X`09$cc getopt.c X Xcrck.obj : crck.c X`09$cc crck.c X Xbestscor.exe : bestscor.obj pam.obj lgetaa.obj getopt.obj X`09$link/exe=bestscor.exe bestscor.obj, pam.obj, lgetaa.obj, getopt.obj X Xbestscor.obj : bestscor.c X`09$cc bestscor.c $ CALL UNPACK MAKEFILE.VMS;1 962409965 $ create 'f' X>MCHU - Calmodulin - Human, rabbit, bovine, rat, and chicken XADQLTEEQIAEFKEAFSLFDKDGDGTITTKELGTVMRSLGQNPTEAELQDMINEVDADGNGTID XFPEFLTMMARKMKDTDSEEEIREAFRVFDKDGNGYISAAELRHVMTNLGEKLTDEEVDEMIREA XDIDGDGQVNYEEFVQMMTAK* $ CALL UNPACK MCHU.AA;1 459235914 $ create 'f' X>P1;MCHU XCalmodulin - Human, rabbit, bovine, rat, and chicken XADQLTEEQIAEFKEAFSLFDKDGDGTITTKELGTVMRSLGQNPTEAELQDMINEVDADGNGTID XFPEFLTMMARKMKDTDSEEEIREAFRVFDKDGNGYISAAELRHVMTNLGEKLTDEEVDEMIREA XDIDGDGQVNYEEFVQMMTAK* $ CALL UNPACK MCHU.MVS;1 491265122 $ create 'f' X>P1;MCHU XCalmodulin - Human, rabbit, bovine, rat, and chicken XADQLTEEQIAEFKEAFSLFDKDGDGTITTKELGTVMRSLGQNPTEAELQDMINEVDADGNGTID XFPEFLTMMARKMKDTDSEEEIREAFRVFDKDGNGYISAAELRHVMTNLGEKLTDEEVDEMIREA XDIDGDGQVNYEEFVQMMTAK* $ CALL UNPACK MCHU.VMS;1 491265122 $ create 'f' X>musplfm transl. of musplfm.seq, 2 to 676 X M L P S L I Q P C S W I L L L `20 X L L V N S S L L W K N V A S F P `20 X M C A M R N G R C F M S F E D T `20 X F E L A G S L S H N I S I E V S `20 X E L F T E F E K H Y S N V S G L `20 X R D K S P M R C N T S F L P T P `20 X E N K E Q A R L T H Y S A L L K `20 X S G A M I L D A W E S P L D D L `20 X V S E L S T I K N V P D I I I S `20 X K A T D I K K K I N A V R N G V `20 X N A L M S T M L Q N G D E E K K `20 X N P A W F L Q S D N E D A R I H `20 X S L Y G M I S C L D N D F K K V `20 X D I Y L N V L K C Y M L K I D N `20 X C `20 $ CALL UNPACK MUSPLFM.AA;1 1074928211 $ create 'f' X>P1;musplfm Xtransl. of musplfm.seq, 2 to 676 X M L P S L I Q P C S W I L L L `20 X L L V N S S L L W K N V A S F P `20 X M C A M R N G R C F M S F E D T `20 X F E L A G S L S H N I S I E V S `20 X E L F T E F E K H Y S N V S G L `20 X R D K S P M R C N T S F L P T P `20 X E N K E Q A R L T H Y S A L L K `20 X S G A M I L D A W E S P L D D L `20 X V S E L S T I K N V P D I I I S `20 X K A T D I K K K I N A V R N G V `20 X N A L M S T M L Q N G D E E K K `20 X N P A W F L Q S D N E D A R I H `20 X S L Y G M I S C L D N D F K K V `20 X D I Y L N V L K C Y M L K I D N `20 X C `20 $ CALL UNPACK MUSPLFM.VMS;1 236728478 $ create 'f' X>MWKW Myosin heavy chain - Caenorhabditis elegans XMEHEKDPGWQYLRRTREQVLEDQSKPYDSKKNVWIPDPEEGYLAGEITATKGDQVTIVTAREMSVIQVTL XKKELVQEMNPPKFEKTEDMSNLSFLNDASVLHNLRSRYAAMLIYTYSGLFCVVINPYKRLPIYTDSCARM XFMGKRKTEMPPHLFAVSDEAYRNMLQDHENQSMLITGESGAGKTENTKKVICYFAAVGASQQEGGAEVDP XNKKKVTLEDQIVQTNPVLEAFGNAKTVRNNNSSRFGKFIRIHFNKHGRLASCDIEHYLLEKSRVIRQAPG XERCYHIFYQIYSDFRPELKKELLLDLPIKDYWFVAQAELIIDGIDDVEEFQLTDEAFDILNFSAVEKQDC XYRLMSAHMHMGNMKFKQRPREEQAEPDGTVEAEKASNMYGIGCE XEFLKALTKPRVKVGTEWVSKGQNCEQVNWAVGAMAKGLYSRVFNWLVKKCNLTLDQKGIDRDYFIGVLDI XAGFEIFDFNSFEQLWINFVNEKLQQFFNHHMFVLEQEEYAREGIQWVFIDFGLDLQACIELIEKPLGIIS XMLDEECIVPKATDLTLASKLVDQHLGKHPNFEKPKPPKGKQGEAHFAMRHYAGTVRYNCLNWLEKNKDPL XNDTVVSAMKQSKGNDLLVEIWQDYTTQEEAAAKAKEGGGGGKKKGKSGSFMTVSMLYRESLNNLMTMLNK XTHPHFIRCIIPNEKKQSGMIDAALVLNQLTCNGVLEGIRICRKGFPNRTLHPDFVQRYAILAAKEAKSDD XDKKKCAEAIMSKLVNDGSLSEEMFRIGLTKVFFKAGVLAHLEDI XRDEKLATILTGFQSQIRWHLGLKDRKRRMEQRAGLLIVQRNVRSWCTLRTWEWFKLYGKVKPMLKAGKEA XEELEKINDKVKALEDSLAKEEKLRKELEESSAKLVEEKTSLFTNLESTKTQLSDAEERLAKLEAQQKDAS XKQLSELNDQLADNEDRTADVQRAKKKIEAEVEALKKQIQDLEMSLRKAESEKQSKDHQIRSLQDEMQQQD XEAIAKLNKEKKHQEEINRKLMEDLQSEEDKGNHQNKVKAKLEQTLDDLEDSLEREKRARADLDKQKRKVE XGELKIAQENIDESGRQRHDLENNLKKKESELHSVSSRLEDEQALVSKLQRQIKDGQSRISELEEELENER XQSRSKADRAKSDLQRELEELGEKLDEQGGATAAQVEVNKKREAE XLAKLRRDLEEANMNHENQLGGLRKKHTDAVAELTDQLDQLNKAKAKVEKDKAQAVRDAEDLAAQLDQETS XGKLNNEKLAKQFELQLTELQSKADEQSRQLQDFTSLKGRLHSENGDLVRQLEDAESQVNQLTRLKSQLTS XQLEEARRTADEEARERQTVAAQAKNYQHEAEQLQESLEEEIEGKNEILRQLSKANADIQQWKARFEGEGL XLKADELEDAKRRQAQKINELQEALDAANSKNASLEKTKSRLVGDLDDAQVDVERANGVASALEKKQKGFD XKIIDEWRKKTDDLAAELDGAQRDLRNTSTDLFKAKNAQEELAEVVEGLRRENKSLSQEIKDLTDQLGEGG XRSVHEMQKIIRRLEIEKEELQHALDEAEAALEAEESKVLRAQVE XVSQIRSEIEKRIQEKEEEFENTRKNHARALESMQASLETEAKGKAELLRIKKKLEGDINELEIALDHANK XANADAQKNLKRYQEQVRELQLQVEEEQRNGADTREQFFNAEKRATLLQSEKEELLVANEAAERARKQAEY XEAADARDQANEANAQVSSLTSAKRKLEGEIQAIHADLDETLNEYKAAEERSKKAIADATRLAEELRQEQE XHSQHVDRLRKGLEQQLKEIQVRLDEAEAAALKGGKKVIAKLEQRVRELESELDGEQRRFQDANKNLGRAD XRRVRELQFQVDEDKKNFERLQDLIDKLQQKLKTQKKQVEEAEELANLNLQKYKQLTHQLEDAEERADQAE XNSLSKMRSKSRASASVAPGLQSSASAAVIRSPSRARASDF`20 $ CALL UNPACK MWKW.AA;1 1415462914 $ create 'f' X>MWRTC1 - Myosin heavy chain 1, cardiac muscle - Rat (fragment) X/DLTEQLGEGGKNVHELEKIRKQLEVEKLELQSALEEAEASLEHEEGKILRAQLEFNQIKAEIE XSKLAEKDEEMEQAKRNHLRVVDSLQTSLDAETRSRNEALRVKKKMEGDLNEMEIQLSQANRIAS XEAQKHLKNAQAHLKDTQLQLDDAVRANDDLKENIAIVERRNTLLQAELEELRAVVEQTERSRKL XAEQELIETSERVQLLHSQNNSLINQKKKMDADLSQLQTEVEEAVQECRNAEEKAKKAITDAAMM XAEELKKEQDTSAHLERMKKNMEQTIKDLQHRLDEAEQIALKGGKKQLQKLEARVRELENELEAE XQKRNAESVKGMRKSERRIKELNYQTEEDKKNLVRLQDLVNKLQLKVKAYKRQAEEAEEQANTNL XSKFRKVQHELDEAEERADIAESQVNKLRAKSRDIGAKQKIHDEE* $ CALL UNPACK MWRTC1.AA;1 204424318 $ create 'f' X>P1;MWRTC1 XMyosin heavy chain 1, cardiac muscle - Rat (fragment) X/DLTEQLGEGGKNVHELEKIRKQLEVEKLELQSALEEAEASLEHEEGKILRAQLEFNQIKAEIE XSKLAEKDEEMEQAKRNHLRVVDSLQTSLDAETRSRNEALRVKKKMEGDLNEMEIQLSQANRIAS XEAQKHLKNAQAHLKDTQLQLDDAVRANDDLKENIAIVERRNTLLQAELEELRAVVEQTERSRKL XAEQELIETSERVQLLHSQNNSLINQKKKMDADLSQLQTEVEEAVQECRNAEEKAKKAITDAAMM XAEELKKEQDTSAHLERMKKNMEQTIKDLQHRLDEAEQIALKGGKKQLQKLEARVRELENELEAE XQKRNAESVKGMRKSERRIKELNYQTEEDKKNLVRLQDLVNKLQLKVKAYKRQAEEAEEQANTNL XSKFRKVQHELDEAEERADIAESQVNKLRAKSRDIGAKQKIHDEE* $ CALL UNPACK MWRTC1.VMS;1 1750294609 $ create 'f' X/*`09dispn.c`09associated subroutines for matching sequences */ X X#include X X#define XTERNAL X#include "upam.gbl" X X#define TRUE 1 X#define FALSE 0 Xextern FILE *outfd; Xextern int smark`5B4`5D; Xextern int min0,min1,max0,max1; Xextern int smin0, smin1, smins; Xextern long loffset; Xextern long sq0off, sq1off; Xextern char name0`5B`5D,name1`5B`5D; Xextern int llen, markx, showall; X X#define MAXOUT 200 X Xdiscons(seqc0, seqc1, nc) X`09char *seqc0, *seqc1; X`09int nc; X`7B X`09char line`5B3`5D`5BMAXOUT`5D, cline`5B2`5D`5BMAXOUT+10`5D; X`09int il, i, lend, loff, il1, il2; X`09int nm; X`09int del0, del1, ic, ll0, ll1, ll01, cl0, cl1, rl0, rl1; X`09int i00, i0n, i10, i1n; X`09int ic0, ic1; X`09int ioff0, ioff1; X`09long qqoff, lloff; X`09int tmp; X`09char *name01; X X`09if (markx==2) name01=name1; else name01 = "\0"; X X`09i00 = smark`5B0`5D; X`09i0n = smark`5B1`5D; X`09i10 = smark`5B2`5D; X`09i1n = smark`5B3`5D; X X`09ioff0=smin0-smins; X`09ioff1=smin1-smins; X X`09nm=0; X X`09for (i=0; i<3; i++) memset(line`5Bi`5D,' ',MAXOUT); X X`09ic = 0; del0=del1=0; X`09for (il=0; il<(nc+llen-1)/llen; il++) `7B X`09`09loff=il*llen; X`09`09lend=min(llen,nc-loff); X X`09`09ll0 = FALSE; ll1 = FALSE; X`09`09ic0 = ic-del0;`09/* save for labeling line */ X`09`09ic1 = ic-del1; X X`09`09for (i=0; i<2; i++) memset(cline`5Bi`5D,' ',MAXOUT); X X`09`09for (i=0; i= min0 && ioff0-del0 <= max0) `7B X`09`09`09 if (toupper(line`5B0`5D`5Bi`5D)==toupper(line`5B2`5D`5Bi`5D)) X`09`09`09`09switch (markx) `7B X`09`09`09`09`09case 0: line`5B1`5D`5Bi`5D= ':'; X`09`09`09`09`09`09break; X`09`09`09`09`09case 1: line`5B1`5D`5Bi`5D= ' '; X`09`09`09`09`09`09break; X`09`09`09`09`09case 2: line`5B1`5D`5Bi`5D= '.'; X`09`09`09`09`09`09break; X`09`09`09`09`09`7D X`09`09`09 else if (markx==2) line`5B1`5D`5Bi`5D=line`5B2`5D`5Bi`5D; X`09`09`09 else if ((il1=iidex(sq,line`5B0`5D`5Bi`5D))>=0 && X`09`09`09`09 (il2=iidex(sq,line`5B2`5D`5Bi`5D))>=0 && X`09`09`09`09`09pam2`5Bil1`5D`5Bil2`5D>= 0) X`09`09`09`09`09 line`5B1`5D`5Bi`5D= (markx) ? 'x':'.'; X`09`09`09 else if ((il1=iidex(sq,line`5B0`5D`5Bi`5D))>=0 && X`09`09`09`09 (il2=iidex(sq,line`5B2`5D`5Bi`5D))>=0) X`09`09`09`09`09 line`5B1`5D`5Bi`5D= (markx) ? 'X':' '; X`09`09`09 `7D X`09`09`09else if (markx==2) line`5B1`5D`5Bi`5D=line`5B2`5D`5Bi`5D; X X`09`09 if (markx==0) `7B X`09`09`09if (ioff0-del0 == i00 && ioff1-del1 == i10) `7B X`09`09`09`09line`5B1`5D`5Bi`5D='X'; X`09`09`09`09i00 = i10 = -1; X`09`09`09`09`7D X`09`09`09if (ioff0-del0 == i0n && ioff1-del1 == i1n) `7B X`09`09`09`09line`5B1`5D`5Bi`5D='X'; X`09`09`09`09i0n = i1n = -1; X`09`09`09`09`7D X`09`09`09if ((ioff0-del0 == i00) `7C`7C (ioff0-del0 == i0n)) `7B X`09`09`09`09line`5B1`5D`5Bi`5D='`5E'; X`09`09`09`09if(ioff0-del0 == i00) i00= -1; X`09`09`09`09else i0n = -1; X`09`09`09`09`7D X`09`09`09if (ioff1-del1 == i10 `7C`7C ioff1-del1 == i1n) `7B X`09`09`09`09line`5B1`5D`5Bi`5D='v'; X`09`09`09`09if(ioff1-del1 == i10) i10= -1; X`09`09`09`09else i1n = -1; X`09`09`09`09`7D X`09`09`09 `7D X`09`09`09`7D X X`09`09for (i=0; i<3; i++) `7Bline`5Bi`5D`5Blend`5D=0;`7D X`09`09for (i=0; i<2; i++) `7Bcline`5Bi`5D`5Blend+7`5D=0;`7D X X`09`09ll01 = ll0&&ll1; X`09`09if (markx==2 && (!showall `7C`7C ll0)) ll1=0; X`09`09fprintf(outfd,"\n"); X`09`09if (ll0) fprintf(outfd,"%s\n",cline`5B0`5D); X`09`09if (ll0) fprintf(outfd,"%-6s %s\n",name0,line`5B0`5D); X`09`09if (ll01) fprintf(outfd,"%-6s %s\n",name01,line`5B1`5D); X`09`09if (ll1) fprintf(outfd,"%-6s %s\n",name1,line`5B2`5D); X`09`09if (ll1) fprintf(outfd,"%s\n",cline`5B1`5D); X`09`09`7D X`09`7D X Xaancpy(to,from,count) X`09char *to, *from; X`09int count; X`7B X`09char *tp; X`09tp=to; X`09while (count--&& *from>=0) `7B X`09`09if (*from='a' && c<='z') return (c-'a'+'A'); X`09return c; X`09`7D X Xmin(arg1, arg2) X`09int arg1, arg2; X`7B X`09return (arg1<=arg2) ? arg1 : arg2; X`09`7D X X#ifdef VMS Xmemset(str, c, cnt) X`09char *str; int cnt; char c; X`7B X`09while (cnt--) *str++ = c; X`09`7D X#endif $ CALL UNPACK NDISPN.C;1 627103925 $ create 'f' Xirand(n)`09/* initialize random number generator */ X`09int n; X`7B X`09srand(n); X`09`7D X Xnrand(n)`09/* returns a random number between 1 and n where n < 64K) */ X`09int n; X`7B X`09int rand(); X`09long rn; X X`09rn = rand(); X#ifdef RAND32 X`09rn = rn >> 16; X#endif X`09rn = rn * n; X`09rn = rn >> 15; X`09return (int)rn; X`09`7D X $ CALL UNPACK NRAND.C;1 1786062902 $ create 'f' Xirand(n)`09/* initialize random number generator */ X`09long n; X`7B X`09srand48(n); X`09`7D X Xnrand(n)`09/* returns a random number between 1 and n where n < 64K) */ X`09int n; X`7B X`09long lrand48(); X`09long rn; X X`09rn = lrand48(); X`09rn = rn >> 16; X`09rn = rn * n; X`09rn = rn >> 15; X`09return (int)rn; X`09`7D X $ CALL UNPACK NRAND48.C;1 1079003879 $ create 'f' X/*`09May, June 1987`09- modified for rapid read of database X X`09June 2, 1987 - added TFASTA X`09March 30, 1988 - combined ffgetaa, fgetgb; X`09April 8, 1988 - added PIRLIB format for unix X`09Feb 4, 1989 - added universal subroutines for libraries X X`09copyright (c) 1987,1988,1989 William R. Pearson X X`09getnt.c`09associated subroutines for matching sequences */ X X/* X8-April-88 X`09The compile time #define PIRLIB allows this routine to be used X`09to read protein and DNA sequence libraries in the NBRF/PIR X`09VAX/VMS library format. That is: X X`09>P1;LCBO X`09This is a line of description X`09GTYH ... the sequence starts on this line X X`09This may ease conversion from UWGCG format libraries. It X`09has not been extensively tested. X X`09In addition, sequence libraries with a '>' in the 4th position X`09are recognized as NBRF format libraries for consistency with X`09UWGCG X X`09February 4, 1988 - this starts a major revision of the getaa X`09routines. The goal is to be able to seach the following format X`09libraries: X X`09`090 - normal FASTA format X`09`091 - full Genbank tape format X`09`092 - NBRF/PIR CODATA format X`09`093 - EMBL/Swiss-prot format X`09`094 - Intelligentics format X`09`095 - NBRF/PIR VMS format X`09`099 - compressed genbank X X`09see file altlib.h to confirm numbers X X`09This is done with a new global variable and a requirement for the X`09FASTLIBS file. The FASTLIBS file will now indicate both the sequence X`09type (protein = 0, DNA = 1) and the file format (the numbers shown X`09above, although intelligenetics may become an alternative to Pearson). X`09This will be done by always using a function pointer for getlib and X`09ranlib(), and setting up a bunch of different getlib() and ranlib() X`09functions. Openlib() will be substantially simplified. X*/ X X/* `09Nov 12, 1987`09- this version checks to see if the sequence X`09is DNA or protein by asking whether > 85% is A, C, G, T X X`09May 5, 1988 - modify the DNA/PROTEIN checker by re-reading X`09DNA sequences in order to check for 'U'. X*/ X X#include X X#include "uascii.gbl" X X#ifdef VMS X#define PIRLIB X#endif X X#define XTERNAL X#include "upam.gbl" X X#define TRUE 1 X#define FALSE 0 X#define MAXLINE 512 X X#define MAXR 15 Xint lascii`5B`5D = `7BES, 0, 1, 7, X`09`09 2, 5, 9,13, X`09`09 3, 8, 6,12, X`09`0910,11,14,15`7D; X X#define LAMASK 15 X Xgetseq(filen,seq,maxs,dnaseq) X`09char *filen, *seq; X`09int maxs, *dnaseq; X`7B X`09FILE *fptr; X`09char line`5B512`5D; X`09int i, j, n; X`09int ic; X X`09if ((fptr=fopen(filen,"r"))==NULL) `7B X`09`09fprintf(stderr," could not open %s\n",filen); X`09`09return 0; X`09`09`7D X`09n=0; X`09while(fgets(line,512,fptr)!=NULL) `7B X#ifdef PIRLIB X`09`09if (line`5B0`5D=='>'&& (line`5B3`5D==';'`7C`7Cline`5B3`5D=='>')) X`09`09`09fgets(line,512,fptr); X`09`09else X#endif X`09`09if (line`5B0`5D!='>'&& line`5B0`5D!=';') `7B X`09`09 for (i=0; (n 0.85) `7B X`09`09*dnaseq = 1; X`09`09`09`09/* convert from protein to DNA sequence */ X`09`09sascii = nascii; X`09`09fseek(fptr,0l,0); X`09`09n=0; X`09`09while(fgets(line,512,fptr)!=NULL) `7B X#ifdef PIRLIB X`09`09`09if (line`5B0`5D=='>'&& (line`5B3`5D==';'`7C`7Cline`5B3`5D=='>')) X`09`09`09`09fgets(line,512,fptr); X`09`09`09else X#endif X`09`09`09if (line`5B0`5D!='>'&& line`5B0`5D!=';') `7B X`09`09`09 for (i=0; (n'`7C`7C line`5B0`5D==';') goto found; X`09`09`7D X`09fclose(fptr); X`09title`5B0`5D='\0'; X`09return 0; X Xfound: X#ifdef PIRLIB X`09if (line`5B0`5D=='>'&&(line`5B3`5D==';'`7C`7Cline`5B3`5D=='>')) `7B X`09`09if ((bp = strchr(line,'\n'))!=NULL) *bp='\0'; X`09`09ll=strlen(line); line`5Bll++`5D=' '; line`5Bll`5D='\0'; X`09`09fgets(&line`5Bll`5D,512-ll,fptr); X`09`7D X#endif X#ifdef MSDOS X`09bp = strpbrk(line,"\n\r"); X#else X`09bp = strchr(line,'\n'); X#endif X`09if (bp!=NULL) *bp = 0; X`09strncpy(title,line,len); X`09title`5Blen-1`5D='\0'; X`09fclose(fptr); X`09return strlen(title); X`09`7D`09 X X#ifndef VMS XFILE *libf=NULL; X#else Xint libf = -1; X#endif X#ifdef NOLIB Xint leof = 0; X#endif X Xlong lpos; Xchar lline`5BMAXLINE`5D; X X X#ifndef NOLIB X#include "genbank.h" X#include "altlib.h" Xextern int ldnaseq; Xint (*getlib)(); Xint (*ranlib)(); X#define GETLIB agetlib X#define RANLIB aranlib Xstruct slibhdr libhdr; Xstruct seqhdr namrec; Xchar seqrec`5BSQRLEN`5D; Xint jsave, recsav; X#else X#define BINARYGB 9 X#define GETLIB getlib X#define RANLIB ranlib X#endif X X/*`09the following is from fgetgb.c */ X X#include X#ifndef O_RAW X#ifdef O_BINARY X#define O_RAW O_BINARY X#else X#define O_RAW 0 X#endif`09`09/* O_BINARY */ X#endif`09`09/* O_RAW */ Xint libfd= -1; X#ifndef NOLIB Xextern int gbflag;`09/* set if a BINARYGB type file is opened */ Xextern int deftype;`09/* default library type */ Xextern int outtty;`09/* flag for no interaction */ X#else Xint deftype=0; Xint outtty=1; X#endif Xint libtype;`09`09/* current open library type */ Xint sfnum;`09`09/* superfamily number from types 0 and 5 */ X X/* a file name for openlib may now include a library type suffix */ X Xopenlib(lname,libenv) X`09char *lname, *libenv; X`7B X`09char rline`5B10`5D,libn`5B120`5D, *strchr(), *bp; X`09long ftell(); X`09int wcnt, ll, opnflg; X X`09if (lname`5B0`5D=='#') return -9; X`09wcnt = 0; X X#ifndef NOLIB X`09if (strlen(libenv)!=0) `7B X`09`09strncpy(libn,libenv,120); X#ifdef UNIX X`09`09strncat(libn,"/",120); X#endif X`09`09strncat(libn,lname,120-strlen(libn)); X`09`09`7D X`09else strncpy(libn,lname,120); X#else X`09strncpy(libn,lname,120); X#endif X X`09/* check for library type */ X`09if ((bp=strchr(libn,' '))!=NULL) `7B X`09 *bp='\0'; X`09 sscanf(bp+1,"%d",&libtype); X`09 if (libtype<0 `7C`7C libtype > BINARYGB) `7B X`09`09fprintf(stderr," invalid library type: %d - resetting\n%s\n", X`09`09`09libtype,lname); X`09`09libtype=deftype; X`09`09`7D X`09 `7D X`09else libtype=deftype; X X#ifndef NOLIB Xl1:`09if (libtype to quit "); X`09`09fflush(stderr); X`09`09if (fgets(libn,120,stdin)==NULL) return -1; X`09`09if ((bp=strchr(libn,'\n'))!=0) *bp='\0'; X`09`09if (strlen(libn)==0) return 0; X`09`09if (++wcnt > 10) return -1; X`09`09goto l1; X`09 `7D X`09 else return 0; X`09 `7D X#ifndef NOLIB X`09if (libtype!=BINARYGB) `7B X`09`09lpos = ftell(libf); X`09`09if (fgets(lline,MAXLINE,libf)==NULL) return -1; X`09`09`7D X`09else if (libtype==BINARYGB) `7B X`09`09if (read(libfd,(char *)&libhdr,sizeof(libhdr))==-1) `7B X`09`09`09fprintf(stderr," could not read %s library\n",libn); X`09`09`09fflush(stderr); X`09`09`09return -1; X`09`09`09`7D X`09`09`7D X`09getlib=getliba`5Blibtype`5D; X`09ranlib=ranliba`5Blibtype`5D; X X#else`09`09/* NOLIB */ X`09lpos = ftell(libf); X`09if (fgets(lline,MAXLINE,libf)==NULL) return -1; X`09leof = 0; X#endif`09`09/* NOLIB */ X`09return 1; X`09`7D X Xcloselib() X`7B X#ifndef NOLIB X`09if (libtype!=BINARYGB) `7B X#endif X`09`09if (libf!=NULL) `7B X`09`09`09fclose(libf); X`09`09`09libf = NULL; X`09`09`09`7D X#ifndef NOLIB X`09`09`7D X`09else `7B X`09`09if (libfd>0) `7B X`09`09`09close(libfd); X`09`09`09libfd = -1; X`09`09`09`7D X`09`09`7D X#endif X`09`7D X XGETLIB(seq,maxs,libstr,libpos,lcont) X`09char *seq; X`09int maxs; X`09char *libstr; X`09long *libpos; X`09int *lcont; X`7B X`09long ftell(); X`09int ll; X`09int ic; X`09register char *cp; X`09register char *seqp; X`09register int *ap; X`09char *seqm, *seqm1, *linep, *strchr(), *bp; X X`09seqp = seq; X`09seqm = &seq`5Bmaxs-9`5D; X`09seqm1 = seqm-1; X#ifndef TFASTA X`09ap = sascii; X#else X`09ap = nascii; X#endif X`09if (*lcont==0) `7B X#ifndef NOLIB X`09`09while (lline`5B0`5D!='>' && lline`5B0`5D!=';') `7B X`09`09`09lpos = ftell(libf); X`09`09`09if (fgets(lline,MAXLINE,libf)==NULL) return 0; X`09`09`7D X`09`09if ((bp=strchr(lline,'`7C'))!=NULL) `7B X`09`09`09*bp='\0'; X`09`09`09sscanf(bp+1,"%d",&sfnum); X`09`09 `7D X`09`09else sfnum=0; X`09`09 X`09`09strncpy(libstr,lline+1,20); X X`09`09libstr`5B10`5D='\0'; X`09`09*libpos = lpos; X#else`09/* NOLIB */ X`09`09if (leof) return 0; X`09`09*libpos = lpos; X`09`09if (lline`5B0`5D=='>' `7C`7C lline`5B0`5D==';') `7B X`09`09`09strncpy(libstr,lline+1,20); X`09`09`09libstr`5B10`5D='\0'; X`09`09`09`7D X`09`09else `7B X`09`09`09libstr`5B0`5D='\0'; X`09`09`09strncpy(seqp,lline,(int)(seqm-seqp)); X`09`09`09for (cp=seqp; seqpNA) break; X`09`09`09`09`7D X`09`09`09if (*seqp==ES) goto done; X`09`09`09`7D X#endif X`09`09`7D X X`09lline`5B0`5D='\0'; X`09while (seqp') goto new; X`09`09if (*seqp==';') `7B X`09`09`09if (strchr(seqp,'\n')==NULL) goto cont; X`09`09`09continue; X`09`09`09`7D X`09`09for (cp=seqp; seqpNA) break; X`09`09`09 `7D X`09`09if (*seqp==ES) goto done; X`09`09lpos = ftell(libf); X`09`09`7D X`09goto done; Xnew:`09strncpy(lline,seqp,MAXLINE); X`09lline`5BMAXLINE-1`5D='\0'; X`09if (strchr(seqp,'\n')==NULL) fgets(lline,MAXLINE-strlen(lline),libf); X`09goto done; X Xcont: X`09fgets(lline,MAXLINE,libf); X`09seqm1 = seqp; X Xdone:`09if (seqp>=seqm1) `7B X`09`09(*lcont)++; X`09`09`7D X`09else `7B X#ifdef NOLIB X`09leof = 1; X#endif X`09*lcont=0; X`09`09`7D X X X`09*seqp = EOSEQ; X`09if ((int)(seqp-seq)==0) return 1; X`09return (int)(seqp-seq); X`09`7D X XRANLIB(str,cnt,seek) X`09char *str; int cnt; long seek; X`7B X`09char *bp; X`09int ll; X`09char *strchr(); X X`09fseek(libf, seek, 0); X`09fgets(lline,MAXLINE,libf); X X`09if (lline`5B0`5D=='>' `7C`7C lline`5B0`5D==';') `7B X`09`09strncpy(str,lline+1,cnt); X`09`09str`5Bcnt-1`5D='\0'; X`09`09if ((bp = strchr(str,'`7C'))!=NULL) *bp='\0'; X`09`09else if ((bp = strchr(str,'\n'))!=NULL) *bp='\0'; X`09`09else str`5Bcnt-1`5D='\0'; X`09`09`7D X`09else `7B X`09`09str`5B0`5D='\0'; X`09`09`7D X#ifdef NOLIB X`09leof=0; X#endif X`09`7D X X#ifndef NOLIB Xggetlib(seq,maxs,libstr,libpos,lcont) X`09char *seq; X`09int maxs; X`09char *libstr; X`09long *libpos; X`09int *lcont; X`7B X`09int i, j, m, n; X`09int arec, nrec, rrec, trec; X`09register int *lap; X`09register char *sptr, *tptr; X`09char *ttptr; X`09int mc2, tmp; X`09char sname`5B11`5D; X`09long lseek(); X X`09sptr = seq; X`09lap = lascii; X X`09if (*lcont==0) `7B X`09`09*libpos = lseek(libfd,0L,1); X`09`09if (read(libfd,(char *)&namrec,sizeof(namrec))==0) return 0; X`09`09recsav = namrec.rcnt`5B0`5D + (namrec.rcnt`5B1`5D<<8) - 1; X`09`09for (j=0; j<11; j++)`20 X`09`09`09if (!(*sptr++ = namrec.seqstart`5Bj`5D)) goto done; X`09`09maxs -= 22; X`09`09strncpy(sname,namrec.seqnam,10); X`09`09sname`5B10`5D='\0'; X`09`09strncpy(libstr,sname,20); X`09`09libstr`5B10`5D='\0'; X`09`09`7D X X`09arec = (maxs-2)/(2*SQRLEN); X`09rrec = min(arec,recsav); X`09if (rrec>0 X`09 && (trec=read(libfd,(char *)sptr,rrec*SQRLEN))!=rrec*SQRLEN) X`09`09goto error; X`09if (rrec == recsav) *lcont=0; X`09else `7B(*lcont)++; recsav -= rrec;`7D X X`09sptr += rrec*SQRLEN; X Xdone: X`09tptr = ttptr = seq + 2*(int)(sptr - seq); X`09while (sptr>seq) `7B X`09`09*--tptr = lap`5B*--sptr&LAMASK`5D; X`09`09*--tptr = lap`5B(*sptr>>4)&LAMASK`5D; X`09`09`7D X X`09tptr = ttptr; X`09while (*--tptr>MAXR); X`09n = (int)(tptr-seq)+1; X`09seq`5Bn`5D= EOSEQ; X`09return (n); X Xerror:`09fprintf(stderr," error reading %10s %4d %4d %4d\n",sname,trec,rrec* VSQRLEN,SQRLEN); X`09fflush(stderr); X`09return (-1); X`09`7D X Xextern int ixstat; X Xgranlib(str,cnt,seek) X`09char *str; int cnt; X`09long seek; X`7B X`09int ctmp; X`09long lseek(); X X`09lseek(libfd,seek,0); X`09if (read(libfd,(char *)&namrec,sizeof(namrec))==0) return 0; X`09strncpy(str,namrec.seqnam,10); X`09str`5B10`5D='\0'; X`09if (ixstat>0) idxann(str,&str`5B10`5D,cnt-10); X`09lseek(libfd,seek,0); X`09`7D X Xchar *cpsave; X Xlgetlib(seq,maxs,libstr,libpos,lcont) X`09char *seq; X`09int maxs; X`09char *libstr; X`09long *libpos; X`09int *lcont; X`7B X`09long ftell(); X`09int i, n, ll; X`09int ic; X`09register char *cp; X`09register char *seqp; X`09register int *ap; X`09char *seqm, *seqm1, *linep, *strchr(); X X`09seqp = seq; X`09seqm = &seq`5Bmaxs-11`5D; X`09seqm1 = seqm-1; X#ifndef TFASTA X`09ap = sascii; X#else X`09ap = nascii; X#endif X`09if (*lcont==0) `7B X`09`09while (lline`5B0`5D!='L' `7C`7C lline`5B1`5D!='O' `7C`7C`20 X`09`09`09`09strncmp(lline,"LOCUS",5)) `7B /* find LOCUS */ X`09`09`09lpos = ftell(libf); X`09`09`09if (fgets(lline,MAXLINE,libf)==NULL) return 0; X`09`09`09`7D X`09`09strncpy(libstr,&lline`5B11`5D,20); X`09`09libstr`5B10`5D='\0'; X`09`09*libpos=lpos; X`09`09while (lline`5B0`5D!='O' `7C`7C lline`5B1`5D!='R' `7C`7C X`09`09`09`09strncmp(lline,"ORIGIN",6)) `7B /* find ORIGIN */ X`09`09`09if (fgets(lline,MAXLINE,libf)==NULL) return 0; X`09`09`09`7D X`09`09`7D X`09else `7B X`09`09for (cp= cpsave; seqpNA) break; X`09`09`09`7D X`09`09`7D X X`09lline`5B0`5D='\0'; X`09while (seqpNA) break; X`09`09`09 `7D X`09`09`7D X`09goto done; Xnew:`09lpos = ftell(libf); X`09fgets(lline,sizeof(lline),libf); X Xdone:`09if (seqp>=seqm1) `7B X`09`09cpsave = cp; X`09`09(*lcont)++; X`09`09`7D X`09else *lcont=0; X X`09*seqp = EOSEQ; X`09if ((int)(seqp-seq)==0) return 1; X`09return (int)(seqp-seq); X`09`7D X Xlranlib(str,cnt,seek) X`09char *str; int cnt; long seek; X`7B X`09char *bp; X`09int ll; X`09char *strchr(); X X`09fseek(libf, seek, 0); X`09fgets(lline,MAXLINE,libf); X X`09strncpy(str,&lline`5B12`5D,10); X`09str`5B10`5D='\0'; X`09fgets(lline,sizeof(lline),libf); X`09while (lline`5B0`5D!='D' `7C`7C lline`5B1`5D!='E' `7C`7C strncmp(lline,"D VEFINITION",10)) X`09`09fgets(lline,sizeof(lline),libf); X`09strncpy(&str`5B10`5D,&lline`5B11`5D,cnt-10); X`09str`5Bcnt-1`5D='\0'; X`09if ((bp = strchr(str,'\n'))!=NULL) *bp='\0'; X X`09fseek(libf,seek,0); X`09fgets(lline,MAXLINE,libf); X`09`7D X Xpgetlib(seq,maxs,libstr,libpos,lcont) X`09char *seq; X`09int maxs; X`09char *libstr; X`09long *libpos; X`09int *lcont; X`7B X`09long ftell(); X`09int i, n, ll; X`09int ic; X`09register char *cp; X`09register char *seqp; X`09register int *ap; X`09char *seqm, *seqm1, *linep, *strchr(); X X`09seqp = seq; X`09seqm = &seq`5Bmaxs-11`5D; X`09seqm1 = seqm-1; X#ifndef TFASTA X`09ap = sascii; X#else X`09ap = nascii; X#endif X`09if (*lcont==0) `7B X`09`09while (lline`5B0`5D!='E' `7C`7C lline`5B1`5D!='N' `7C`7C strncmp(lline V,"ENTRY",5)) X`09`09`7B /* find ENTRY */ X`09`09`09lpos = ftell(libf); X`09`09`09if (fgets(lline,MAXLINE,libf)==NULL) return 0; X`09`09`09`7D X`09`09strncpy(libstr,&lline`5B16`5D,8); X`09`09libstr`5B8`5D='\0'; X`09`09*libpos = lpos; X`09`09while (lline`5B0`5D!='S' `7C`7C lline`5B2`5D!='Q' `7C`7C strncmp(lline V,"SEQUENCE",8)) X`09`09`7B /* find SEQUENCE */ X`09`09`09if (fgets(lline,MAXLINE,libf)==NULL) return 0; X`09`09`09`7D X`09`09fgets(lline,sizeof(lline),libf); /* get the extra line */ X`09`09`7D X`09else `7B X`09`09for (cp= cpsave; seqpNA) break; X`09`09`09`7D X`09`09if (*seqp==ES) goto done; X`09`09`7D X X`09lline`5B0`5D='\0'; X`09while (seqpNA) `7B--seqp; break;`7D; X`09`09`09cp++; X`09`09 `7D X`09`09if (*seqp==ES) goto done; X`09`09`7D X`09goto done; Xnew:`09lpos = ftell(libf); X`09fgets(lline,sizeof(lline),libf); X`09goto done; X Xdone:`09if (seqp>=seqm1) `7B X`09`09cpsave = cp; X`09`09(*lcont)++; X`09`09`7D X`09else *lcont=0; X X`09*seqp = EOSEQ; X`09if ((int)(seqp-seq)==0) return 1; X`09return (int)(seqp-seq); X`09`7D X Xpranlib(str,cnt,seek) X`09char *str; int cnt; long seek; X`7B X`09char *bp; X`09int ll; X`09char *strchr(); X X`09fseek(libf, seek, 0); X`09fgets(lline,MAXLINE,libf); X X`09strncpy(str,&lline`5B16`5D,8); X`09str`5B8`5D='\0'; X`09fgets(lline,sizeof(lline),libf); X`09while (lline`5B0`5D!='T' `7C`7C lline`5B1`5D!='I' `7C`7C strncmp(lline,"T VITLE",5)) X`09`09fgets(lline,sizeof(lline),libf); X`09strncpy(&str`5B8`5D,&lline`5B16`5D,cnt-9); X`09str`5Bcnt-1`5D='\0'; X`09if ((bp = strchr(str,'\n'))!=NULL) *bp='\0'; X X`09fseek(libf,seek,0); X`09fgets(lline,MAXLINE,libf); X`09`7D X Xlong seqsiz; X Xegetlib(seq,maxs,libstr,libpos,lcont) X`09char *seq; X`09int maxs; X`09char *libstr; X`09long *libpos; X`09int *lcont; X`7B X`09long ftell(); X`09int ll; X`09int ic; X`09register char *cp; X`09register char *seqp; X`09register int *ap; X`09char *seqm, *seqm1, *linep, *strchr(); X`09char id`5B11`5D; /* Holds Identifier */ X X`09seqp = seq; X`09seqm = &seq`5Bmaxs-11`5D; X`09seqm1 = seqm-1; X#ifndef TFASTA X`09ap = sascii; X#else X`09ap = nascii; X#endif X`09if (*lcont==0) `7B X`09`09while (lline`5B0`5D!='I' `7C`7C lline`5B1`5D!='D') `7B /* find ID */ X`09`09`09lpos = ftell(libf); X`09`09`09if (fgets(lline,MAXLINE,libf)==NULL) return 0; X`09`09`09`7D X`09`09sscanf(&lline`5B5`5D,"%s",id); X`09`09sprintf(libstr,"%-10.10s",id); X`09`09*libpos = lpos; X`09`09while (lline`5B0`5D!='S' `7C`7C lline`5B1`5D!='Q') `7B /* find ORIGIN V */ X`09`09`09if (fgets(lline,MAXLINE,libf)==NULL) return 0; X`09`09`09`7D X`09`09sscanf(&lline`5B14`5D,"%ld",&seqsiz); X`09`09`7D X`09else `7B X`09`09for (cp= cpsave; seqpNA) break; X`09`09`09`7D X`09`09if (*seqp==ES) goto done; X`09`09`7D X X`09lline`5B0`5D='\0'; X`09while (seqpNA) break; X`09`09`09 `7D X`09`09if (*seqp==ES) goto done; X`09`09`7D X`09goto done; Xnew:`09lpos = ftell(libf); X`09fgets(lline,sizeof(lline),libf); X`09goto done; X Xdone:`09if (seqp>=seqm1) `7B X`09`09cpsave = cp; X`09`09(*lcont)++; X`09`09seqsiz -= (long)(seqp-seq); X`09`09`7D X`09else *lcont=0; X X`09*seqp = EOSEQ; X`09if ((int)(seqp-seq)==0) return 1; X/*`09if (*lcont==0 && (long)(seqp-seq)!=seqsiz) X`09`09printf("%s read %d of %d\n",libstr,(int)(seqp-seq),seqsiz); X*/ X`09return (int)(seqp-seq); X`09`7D X Xeranlib(str,cnt,seek) X`09char *str; int cnt; long seek; X`7B X`09char *bp; X`09char id`5B11`5D; /* Holds Identifier */ X`09int ll; X`09char *strchr(); X X`09fseek(libf, seek, 0); X`09fgets(lline,MAXLINE,libf); X X`09sscanf(&lline`5B5`5D,"%s",id); X`09sprintf(str,"%-10.10s ",id); X`09fgets(lline,sizeof(lline),libf); X`09while (lline`5B0`5D!='D' `7C`7C lline`5B1`5D!='E') fgets(lline,sizeof(lli Vne),libf); X`09strncpy(&str`5B11`5D,&lline`5B5`5D,cnt-11); X`09str`5Bcnt-1`5D='\0'; X`09if ((bp = strchr(str,'\n'))!=NULL) *bp='\0'; X X`09fseek(libf,seek,0); X`09fgets(lline,MAXLINE,libf); X`09`7D X Xigetlib(seq,maxs,libstr,libpos,lcont) X`09char *seq; X`09int maxs; X`09char *libstr; X`09long *libpos; X`09int *lcont; X`7B X`09long ftell(); X`09int i, n, ll; X`09int ic; X`09register char *cp; X`09register char *seqp; X`09register int *ap; X`09char *seqm, *seqm1, *linep, *bp, *strchr(); X X`09seqp = seq; X`09seqm = &seq`5Bmaxs-9`5D; X`09seqm1 = seqm-1; X#ifndef TFASTA X`09ap = sascii; X#else X`09ap = nascii; X#endif X`09if (*lcont==0) `7B X`09`09while (lline`5B0`5D!=';') `7B X`09`09`09lpos = ftell(libf); X`09`09`09if (fgets(lline,MAXLINE,libf)==NULL) return 0; X`09`09`09`7D X`09`09*libpos = lpos; X`09`09while (lline`5B0`5D==';') fgets(lline,sizeof(lline),libf); X`09`09strncpy(libstr,lline+1,10); X`09`09libstr`5B9`5D='\0'; X`09`09if((bp=strchr(libstr,'\n'))!=NULL) *bp='\0'; X`09`09`7D X X`09lline`5B0`5D='\0'; X`09while (seqp') goto new; X`09`09if (*seqp==';') `7B X`09`09`09if (strchr(seqp,'\n')==NULL) goto cont; X`09`09`09continue; X`09`09`09`7D X`09`09for (cp=seqp; seqpNA) break; X`09`09`09 `7D X`09`09if (*seqp==ES) goto done; X`09`09lpos = ftell(libf); X`09`09`7D X`09goto done; Xnew:`09strncpy(lline,seqp,MAXLINE); X`09lline`5BMAXLINE-1`5D='\0'; X`09if (strchr(seqp,'\n')==NULL) fgets(lline,MAXLINE-strlen(lline),libf); X`09goto done; X Xcont: X`09fgets(lline,MAXLINE,libf); X`09seqm1 = seqp; X Xdone:`09if (seqp>=seqm1) `7B X`09`09(*lcont)++; X`09`09`7D X`09else `7B X`09*lcont=0; X`09`09`7D X X X`09*seqp = EOSEQ; X`09if ((int)(seqp-seq)==0) return 1; X`09return (int)(seqp-seq); X`09`7D X Xiranlib(str,cnt,seek) X`09char *str; int cnt; long seek; X`7B X`09char *bp; X`09int ll; X`09char *strchr(); X`09char tline`5B120`5D; X X`09fseek(libf, seek, 0); X`09fgets(lline,MAXLINE,libf); X X`09if (lline`5B0`5D=='>' `7C`7C lline`5B0`5D==';') `7B X`09`09strncpy(tline,lline+1,sizeof(tline)); X`09`09str`5Bcnt-1`5D='\0'; X`09`09if ((bp = strchr(str,'\n'))!=NULL) *bp='\0'; X`09`09else str`5Bcnt-1`5D='\0'; X`09`09`7D X`09else `7B X`09`09tline`5B0`5D='\0'; X`09`09`7D X X`09while (lline`5B0`5D==';') fgets(lline,sizeof(lline),libf); X`09if ((bp=strchr(lline,'\n'))!=NULL) *bp=0; X`09if ((bp=strchr(lline,' '))!=NULL) *bp=0; X`09strncpy(str,lline,cnt); X`09strncat(str," ",cnt-strlen(str)); X`09strncat(str,tline,cnt-strlen(str)); X`09str`5Bcnt-1`5D='\0'; X`09 X`09fseek(libf,seek,0); X`09fgets(lline,MAXLINE,libf); X`09`7D X Xvgetlib(seq,maxs,libstr,libpos,lcont) X`09char *seq; X`09int maxs; X`09char *libstr; X`09long *libpos; X`09int *lcont; X`7B X`09long ftell(); X`09int i, n, ll; X`09int ic; X`09register char *cp; X`09register char *seqp; X`09register int *ap; X`09char *seqm, *seqm1, *linep, *strchr(), *bp; X X`09seqp = seq; X`09seqm = &seq`5Bmaxs-9`5D; X`09seqm1 = seqm-1; X#ifndef TFASTA X`09ap = sascii; X#else X`09ap = nascii; X#endif X`09if (*lcont==0) `7B X`09`09while (lline`5B0`5D!='>' && lline`5B0`5D!=';') `7B X`09`09`09lpos = ftell(libf); X`09`09`09if (fgets(lline,MAXLINE,libf)==NULL) return 0; X`09`09`7D X`09`09if ((bp=strchr(lline,':'))!=NULL) `7B X`09`09`09*bp='\0'; X`09`09`09sscanf(bp+1,"%d",&sfnum); X`09`09 `7D X`09`09else sfnum=0; X`09`09if ((bp=strchr(lline,'\n'))!=NULL) *bp='\0'; X`09`09strncpy(libstr,&lline`5B4`5D,20); X`09`09fgets(lline,MAXLINE,libf); X`09`09libstr`5B10`5D='\0'; X`09`09*libpos = lpos; X`09`09`7D X X`09lline`5B0`5D='\0'; X`09while (seqp') goto new; X`09`09if (*seqp==';') `7B X`09`09`09if (strchr(seqp,'\n')==NULL) goto cont; X`09`09`09continue; X`09`09`09`7D X`09`09for (cp=seqp; seqpNA) break; X`09`09`09 `7D X`09`09if (*seqp==ES) goto done; X`09`09lpos = ftell(libf); X`09`09`7D X`09goto done; Xnew:`09strncpy(lline,seqp,MAXLINE); X`09lline`5BMAXLINE-1`5D='\0'; X`09if (strchr(seqp,'\n')==NULL) fgets(lline,MAXLINE-strlen(lline),libf); X`09goto done; X Xcont: X`09fgets(lline,MAXLINE,libf); X`09seqm1 = seqp; X Xdone:`09if (seqp>=seqm1) `7B X`09`09(*lcont)++; X`09`09`7D X`09else `7B X X`09*lcont=0; X`09`09`7D X X X`09*seqp = EOSEQ; X`09if ((int)(seqp-seq)==0) return 1; X`09return (int)(seqp-seq); X`09`7D X Xvranlib(str,cnt,seek) X`09char *str; int cnt; long seek; X`7B X`09char *bp; X`09int ll; X`09char *strchr(); X X`09fseek(libf, seek, 0); X`09fgets(lline,MAXLINE,libf); X X`09if (lline`5B0`5D=='>'&&(lline`5B3`5D==';'`7C`7Clline`5B3`5D=='>')) `7B X`09`09strncpy(str,&lline`5B4`5D,cnt); X X`09`09if ((bp = strchr(str,':'))!=NULL) *bp='\0'; X`09`09else if ((bp = strchr(str,'\n'))!=NULL) *bp='\0'; X`09`09else str`5Bcnt-1`5D='\0'; X X`09`09fgets(lline,MAXLINE,libf); X`09`09if ((bp = strchr(lline,'\n'))!=NULL) *bp='\0'; X`09`09strncat(str," ",cnt); X`09`09strncat(str,lline,cnt-strlen(str)); X`09`09`7D X`09else `7B X`09`09str`5B0`5D='\0'; X`09`09`7D X X`09fseek(libf,seek,0); X`09fgets(lline,MAXLINE,libf); X`09`7D X X#endif`09/* NOLIB */ X Xscanseq(seq,n,str) X`09char *seq, *str; X`09int n; X`7B X`09int tot,i; X`09char aaray`5BMAXSQ`5D;`09`09/* this must be set > nsq */ X`09 X`09for (i=0; i= 0 && nt < nsq) return cnt`5Bnt`5D; X`09else `7B X`09`09fprintf(stderr," sequence error %d\n",nt); X`09`09fflush(stderr); X`09`7D X`09return -1; X`09`7D X*/ X Xmax(arg1,arg2) X`09int arg1, arg2; X`7B X`09return (arg1>arg2) ? arg1 : arg2; X`09`7D X X#ifdef VMS Xmemcpy(ar0, ar1, n) X`09char *ar0, *ar1; unsigned n; X`7B X`09while (n--) *ar0++ = *ar1++; X`09`7D X Xopenidx() `7B`7D Xnewname() `7B`7D X#endif X#ifdef MACLSC Xmemcpy(ar0, ar1, n) X`09char *ar0, *ar1; unsigned n; X`7B X`09while (n--) *ar0++ = *ar1++; X`09`7D X#endif $ CALL UNPACK NXGETAA.C;1 1426505879 $ create 'f' X>GT8.7 transl. of pa875.con, 19 to 675 X P M I L G Y W N V R G L T H P `20 X I R M L L E Y T D S S Y D E K R `20 X Y T M G D A P D F D R S Q W L N `20 X E K F K L G L D F P N L P Y L I `20 X D G S H K I T Q S N A I L R Y L `20 X A R K H H L D G E T E E E R I R `20 X A D I V E N Q V M D T R M Q L I `20 X M L C Y N P D F E K Q K P E F L `20 X K T I P E K M K L Y S E F L G K `20 X R P W F A G D K V T Y V D F L A `20 X Y D I L D Q Y R M F E P K C L D `20 X A F P N L R D F L A R F E G L K `20 X K I S A Y M K S S R Y I A T P I `20 X F S K M A H W S N K $ CALL UNPACK PA875.AA;1 621286462 $ create 'f' X/*`09pam.c`0919-June-86 X X`09copyright (c) 1987 William R. Pearson X X`09read in the alphabet and pam matrix data X X`09designed for universal matcher X*/ X X#include X X#define XTERNAL X#include "uascii.gbl" X#include "upam.gbl" X Xextern int bestoff, bestscale, bkfact, scfact, bktup, bestmax, histint; X Xinitpam(mfname) X`09char *mfname; X`7B X`09char line`5B512`5D, *lp; X`09int i, iaa, ipam; X`09FILE *fmat; X X`09if (strcmp(mfname,"250")==0) `7B X`09 pam = apam; X`09 strcpy(mfname,"PAM250"); X`09 return 1; X`09`7D X X`09if (strcmp(mfname,"120")==0) `7B X`09 pam = apam120; X`09 strcpy(mfname,"PAM120"); X`09 return 1; X`09`7D X X`09if ((fmat=fopen(mfname,"r"))==NULL) `7B X`09`09printf(" cannot open scoring matrix file %s\n",mfname); X`09`09return 0; X`09`09`7D X Xl1:`09if (fgets(line,512,fmat)==NULL) `7B X`09`09printf(" pam - cannot read first line of SMATRIX file\n"); X`09`09return(0); X`09`09`7D X X`09if (line`5B0`5D==';') `7B X`09`09if (line`5B1`5D=='P') `7B X`09`09`09strcpy(sqnam,"aa"); strcpy(sqtype,"protein");`7D X`09`09else if (line`5B1`5D=='D') `7B X`09`09`09strcpy(sqnam,"nt"); strcpy(sqtype,"DNA");`7D X`09`09goto l1; X`09`09`7D X X`09if (sscanf(line," %d %d %d %d %d %d %d", X`09 &scfact,&bestoff,&bestscale,&bkfact,&bktup,&bestmax,&histint)!=7) `7B X`09 `09printf(" bestcut parameters - bad format\n"); X`09`09exit(1); X`09`09`7D X X`09if (fgets(line,512,fmat)==NULL) `7B X`09`09printf(" pam - cannot read DELVAL line\n"); X`09`09return 0; X`09`09`7D X X`09else if (sscanf(line," %d %d",&gdelval,&ggapval)!=2) `7B X`09`09printf(" DELVAL parameters - bad format\n"); X`09`09exit(1); X`09`09`7D X`09`09 X`09if (fgets(line,512,fmat)==NULL) `7B X`09`09printf(" pam - cannot read EOS line\n"); X`09`09return 0; X`09`09`7D X X/*`09clear out sascii`09*/ X`09for (i=0; i<=AAMASK; i++) sascii`5Bi`5D= NA; X X/*`09set end of line stop`09*/ X`09sascii`5B0`5D=sascii`5B'\r'`5D=sascii`5B'\n'`5D= EL; X X/*`09set end of sequence stop */ X`09for (i=0; line`5Bi`5D; i++) if (line`5Bi`5D>' ') sascii`5Bline`5Bi`5D`5D= V ES; X`09 X`09if (fgets(line,512,fmat)==NULL) `7B X`09`09printf(" pam - cannot read aa line\n"); X`09`09exit(1); X`09`09`7D X X/* read the alphabet */ X`09for (i=0,nsq=0; line`5Bi`5D; i++) if (line`5Bi`5D>' ') X`09`09sq`5Bnsq++`5D=toupper(line`5Bi`5D); X X/* initialize sascii */ X`09for (iaa=0; iaa='A' && sq`5Biaa`5D<='Z' V) X`09`09`09sascii`5Baa`5Biaa`5D-'A'+'a'`5D=sascii`5Baa`5Biaa`5D`5D; X`09`09`7D X X/* read in hnt values */ X`09for (iaa=0; iaa X X#define XTERNAL X#include "upam.gbl" X X#define TRUE 1 X#define FALSE 0 Xextern FILE *outfd; X Xextern int iscore, gscore; X/*extern int colflg;*/ X Xstruct ltype `7B char *type; char *size;`7D X`09*ltptr, X`09 linarr`5B4`5D= X`09`7B"","", X`09"dashed","med ", X`09"dashed","short", X`09"dotted","short"`7D; X Xint nlinarr=4; X Xextern char lvstr`5B`5D; X Xint plinval`5B3`5D=`7B200,100,50`7D; Xint dlinval`5B3`5D=`7B200,100,50`7D; Xint *linval; X Xextern int dnaseq; X Xextern int smin0,smin1; Xextern long loffset; X X#define DIAG 1 X#define INS0 2 X#define INS1 4 X Xlong pminx, pmaxx, pminy, pmaxy, pmaxb, pmaxox, pmaxoy, pmaxob; X Xdiscons(seqc0, seqc1, nc) X`09char *seqc0, *seqc1; X`09int nc; X`7B X`09long x0, x1, y0, y1; X`09int direct, ii; X X`09y1 = y0 = smin0; X`09x1 = x0 = smin1 + loffset; X X`09direct = DIAG; X`09 X`09for (ii=0; ii pmaxy) printf("\r* n0 * %3ld %3ld\n",y1,pmaxy); X`09if (x1 > pmaxx) printf("\r* n1 * %3ld %3ld\n",x1,pmaxx); X`09`7D X Xaancpy(to,from,count) X`09char *to, *from; X`09int count; X`7B X`09char *tp; X`09tp=to; X`09while (count--&& *from>=0) `7B X`09`09if (*from='a' && c<='z') return (c-'a'+'A'); X`09return c; X`09`7D X Xmin(arg1, arg2) X`09int arg1, arg2; X`7B X`09return (arg1<=arg2) ? arg1 : arg2; X`09`7D X Xopenplt(n0, n1) X`09long n0, n1; X`7B X`09char *getenv(), *sptr; X X`09if (strlen(lvstr)>0) `7B X`09`09sscanf(lvstr,"%d %d %d",&plinval`5B0`5D,&plinval`5B1`5D,&plinval`5B2`5 VD); X`09`09fprintf(stderr," linval: %3d %3d %3d\n", X`09`09`09plinval`5B0`5D,plinval`5B1`5D,plinval`5B2`5D); X`09`09linval = plinval; X`09`09`7D X`09else if ((sptr=getenv("LINEVAL"))!=NULL && strlen(sptr)>0) `7B X`09`09sscanf(sptr,"%d %d %d",&plinval`5B0`5D,&plinval`5B1`5D,&plinval`5B2`5D V); X`09`09fprintf(stderr," linval: %3d %3d %3d\n", X`09`09`09plinval`5B0`5D,plinval`5B1`5D,plinval`5B2`5D); X`09`09linval = plinval; X`09`09`7D X`09else `7B X`09`09if (dnaseq==1) linval=dlinval; X`09`09else linval=plinval; X`09`09`7D X X`09pmaxx = n1; X`09pmaxy = n0; X`09pmaxb = (n0>n1) ? n0 : n1; X`09pmaxob = pmaxox = pmaxoy = 0; X X`09printf(".PS\n"); X`09printf("scale=%ld\n",pmaxb); X`09printf("box ht %ld wid %ld with .sw at %ld,%ld\n", X`09`09pmaxy,pmaxx,pmaxox,pmaxoy); X`09printf("yoff=%d\n",pmaxy); X`09printf("xoff=0\n"); X`09printf("med=10; short=5\n"); X`09`7D X`09 Xdrawdiag(n0,n1) X long n0, n1; X`7B X linetype(0); X printf("line %s %s from xoff+%ld,yoff-%ld to xoff+%ld,yoff-%ld\n", X`09 ltptr->type,ltptr->size,0,0,n0,n1); X`7D X Xlinetype(type) X`09int type; X`7B X ltptr = &linarr`5Btype`5D; X`7D X Xcloseplt() X`7B X`09printf(".PE\n"); X`09`7D X Xopnline(x,y,s) X long x, y; X int s; X`7B X if (s>linval`5B0`5D) linetype(0); X else if (s>linval`5B1`5D) linetype(1); X else if (s>linval`5B2`5D) linetype(2); X else linetype(3); X X printf("L: "); X`7D X Xclsline(x,y,s) X long x, y; X int s; X`7B X printf("\"\\s-4(%d)\\s0\" at L.start above\n",s); X`7D X Xmove(x,y) X`09unsigned int x, y; X`7B X`09`7D X Xdraw(x0,y0,x1,y1) X`09long x0,y0,x1, y1; X`7B X`09printf("line %s %s from xoff+%ld,yoff-%ld to xoff+%ld,yoff-%ld\n", X`09`09ltptr->type,ltptr->size,x0,y0,x1,y1); X`09`7D X X#ifdef VMS Xmemset(str, c, cnt) X`09char *str; int cnt; char c; X`7B X`09while (cnt--) *str++ = c; X`09`7D X#endif X X $ CALL UNPACK PCLDISPN.C;1 774652264 $ create 'f' X#include X Xint max_x=1024, max_y=780; X Xint linbw`5B`5D=`7B0,2,4,3,1`7D; Xint lincol`5B`5D=`7B0,1,2,3,4`7D; Xchar linchar`5B`5D=`7B96,'a','b','c','d','e','f','g'`7D; Xint *linarr; Xint nlinarr=5; X Xfloat fxscal, fyscal, fxoff, fyoff; X Xopenpl() X`7B X`09printf("\033\014\n"); X`09printf("\035");`09`09/* send ESC FF GS */ X`09linarr = linbw; X`09linetype(0); X`09`7D X`09 Xlinetype(type) X`09int type; X`7B X`09printf("\033%c",linchar`5Btype`5D); X`09`7D X Xclosepl() X`7B X`09move(0,0); X`09putchar('\r'); X`09`7D X Xspace(x0,y0,x1,y1) X`09int x0, x1, y0, y1; X`7B X`09fxoff = (float)x0; X`09fyoff = (float)y0; X`09fxscal = (float)(max_x)/(float)(x1-x0); X`09fyscal = (float)(max_y)/(float)(y1-y0); X`09`7D X Xmove(x,y) X`09int x, y; X`7B X`09int xx, yy; X`09xx = (int)(((float)(x)-fxoff)*fxscal); X`09yy = (int)(((float)(y)-fyoff)*fyscal); X`09fputc(0x1d,stdout); X`09fputc(((yy&0x3e0)>>5)+0x20,stdout); X`09fputc((yy&0x1f)+0x60,stdout); X`09fputc(((xx&0x3e0)>>5)+0x20,stdout); X`09fputc((xx&0x1f)+0x40,stdout); X`09`7D X Xcont(x,y) X`09int x, y; X`7B X`09int xx, yy; X`09xx = (int)(((float)(x)-fxoff)*fxscal); X`09yy = (int)(((float)(y)-fyoff)*fyscal); X`09fputc(((yy&0x3e0)>>5)+0x20,stdout); X`09fputc((yy&0x1f)+0x60,stdout); X`09fputc(((xx&0x3e0)>>5)+0x20,stdout); X`09fputc((xx&0x1f)+0x40,stdout); X`09`7D X Xdrawstr(str) X`09char *str; X`7B X `09fputc(0x1f,stdout); X`09fputs(str,stdout); X`09fputc(0x1d,stdout); X`09`7D X $ CALL UNPACK PLOTSUB.C;1 1980981881 $ create 'f' X;P standard pam250 matrix for proteins X 4 27 200 5 2 50 2 X -12 -4 X@ * XA R N D C Q E G H I L K M F P S T W Y V B Z X X0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 2 6 0 X 2 X -2 6 X 0 0 2 X 0 -1 2 4 X -2 -4 -4 -5 12 X 0 1 1 2 -5 4 X 0 -1 1 3 -5 2 4 X 1 -3 0 1 -3 -1 0 5 X -1 2 2 1 -3 3 1 -2 6 X -1 -2 -2 -2 -2 -2 -2 -3 -2 5 X -2 -3 -3 -4 -6 -2 -3 -4 -2 2 6 X -1 3 1 0 -5 1 0 -2 0 -2 -3 5 X -1 0 -2 -3 -5 -1 -2 -3 -2 2 4 0 6 X -4 -4 -4 -6 -4 -5 -5 -5 -2 1 2 -5 0 9 X 1 0 -1 -1 -3 0 -1 -1 0 -2 -3 -1 -2 -5 6 X 1 0 1 0 0 -1 0 1 -1 -1 -3 0 -2 -3 1 2 X 1 -1 0 0 -2 -1 0 0 -1 0 -2 0 -1 -3 0 1 3 X -6 2 -4 -7 -8 -5 -7 -7 -3 -5 -2 -3 -4 0 -6 -2 -5 17 X -3 -4 -2 -4 0 -4 -4 -5 0 -1 -1 -4 -2 7 -5 -3 -3 0 10 X 0 -2 -2 -2 -2 -2 -2 -1 -2 4 2 -2 2 -1 -1 -1 0 -6 -2 4 X 0 -1 2 3 -4 1 2 0 1 -2 -3 1 -2 -5 -1 0 0 -5 -3 -2 2 X 0 0 1 3 -5 3 3 -1 2 -2 -3 0 -2 -5 0 0 -1 -6 -4 -2 2 3 X 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 X`20 X $ CALL UNPACK PROT.MAT;1 1331388093 $ create 'f' X>QRHULD LDL receptor precursor - Human XMGPWGWKLRWTVALLLAAAGTAVGDRCERNEFQCQDGKCISYKWVCDGSAECQDGSDESQETCLSVTCKS XGDFSCGGRVNRCIPQFWRCDGQVDCDNGSDEQGCPPKTCSQDEFRCHDGKCISRQFVCDSDRDCLDGSDE XASCPVLTCGPASFQCNSSTCIPQLWACDNDPDCEDGSDEWPQRCRGLYVFQGDSSPCSAFEFHCLSGECI XHSSWRCDGGPDCKDKSDEENCAVATCRPDEFQCSDGNCIHGSRQCDREYDCKDMSDEVGCVNVTLCEGPN XKFKCHSGECITLDKVCNMARDCRDWSDEPIKECGTNECLDNNGGCSHVCNDLKIGYECLCPDGFQLVAQR XRCEDIDECQDPDTCSQLCVNLEGGYKCQCEEGFQLDPHTKACKAVGSIAYLFFTNRHEVRKMTLDRSEYT XSLIPNLRNVVA XLDTEVASNRIYWSDLSQRMICSTQLDRAHGVSSYDTVISRDIQAPDGLAVDWIHSNIYWTDSVLGTVSVA XDTKGVKRKTLFRENGSKPRAIVVDPVHGFMYWTDWGTPAKIKKGGLNGVDIYSLVTENIQWPNGITLDLL XSGRLYWVDSKLHSISSIDVNGGNRKTILEDEKRLAHPFSLAVFEDKVFWTDIINEAIFSANRLTGSDVNL XLAENLLSPEDMVLFHNLTQPRGVNWCERTTLSNGGCQYLCLPAPQINPHSPKFTCACPDGMLLARDMRSC XLTEAEAAVATQETSTVRLKVSSTAVRTQHTTTRPVPDTSRLPGATPGLTTVEIVTMSHQALGDVAGRGNE XKKPSSVRALSIVLPIVLLVFLCLGVFLLWKNWRLKNINSINFDNPVYQKTTEDEVHICHNQDGYSYPSRQ XMVSLEDDVA`20 $ CALL UNPACK QRHULD.AA;1 151748032 $ create 'f' X>P1;QRHULD XLDL receptor precursor - Human XMGPWGWKLRWTVALLLAAAGTAVGDRCERNEFQCQDGKCISYKWVCDGSAECQDGSDESQETCLSVTCKS XGDFSCGGRVNRCIPQFWRCDGQVDCDNGSDEQGCPPKTCSQDEFRCHDGKCISRQFVCDSDRDCLDGSDE XASCPVLTCGPASFQCNSSTCIPQLWACDNDPDCEDGSDEWPQRCRGLYVFQGDSSPCSAFEFHCLSGECI XHSSWRCDGGPDCKDKSDEENCAVATCRPDEFQCSDGNCIHGSRQCDREYDCKDMSDEVGCVNVTLCEGPN XKFKCHSGECITLDKVCNMARDCRDWSDEPIKECGTNECLDNNGGCSHVCNDLKIGYECLCPDGFQLVAQR XRCEDIDECQDPDTCSQLCVNLEGGYKCQCEEGFQLDPHTKACKAVGSIAYLFFTNRHEVRKMTLDRSEYT XSLIPNLRNVVA XLDTEVASNRIYWSDLSQRMICSTQLDRAHGVSSYDTVISRDIQAPDGLAVDWIHSNIYWTDSVLGTVSVA XDTKGVKRKTLFRENGSKPRAIVVDPVHGFMYWTDWGTPAKIKKGGLNGVDIYSLVTENIQWPNGITLDLL XSGRLYWVDSKLHSISSIDVNGGNRKTILEDEKRLAHPFSLAVFEDKVFWTDIINEAIFSANRLTGSDVNL XLAENLLSPEDMVLFHNLTQPRGVNWCERTTLSNGGCQYLCLPAPQINPHSPKFTCACPDGMLLARDMRSC XLTEAEAAVATQETSTVRLKVSSTAVRTQHTTTRPVPDTSRLPGATPGLTTVEIVTMSHQALGDVAGRGNE XKKPSSVRALSIVLPIVLLVFLCLGVFLLWKNWRLKNINSINFDNPVYQKTTEDEVHICHNQDGYSYPSRQ XMVSLEDDVA`20 $ CALL UNPACK QRHULD.VMS;1 258241068 $ create 'f' X/*`09qsub.c`09`09some routines for building queues */ X X X#include "qsubs.h" X X/* puts elements of the structure into squeue if there is room */ X Xenqueue(cur,nm,state) X`09char *cur, *nm; X`09int state; X`7B X`09int nhead; X`09if (head X/*#include */ X X#define TRUE 1 X#define FALSE 0 X X#ifndef BIGMEM X#define MAXTST 2000`09/* longest test sequence */ X#define MAXLIB 5000 X#else X#define MAXTST 10000 X#define MAXLIB 20000 X#endif X X#define MAXHIST 51`09/* number of histogram divisions */ X XFILE *outfd;`09`09/* fd for output file */ Xint smark`5B4`5D; X Xchar libstr`5B21`5D;`09/* partial title from library sequence */ Xchar name0`5B11`5D, name1`5B11`5D;`09/* for labeling output */ X Xchar *aa0, *aa1;`09/* amino acid sequence data */ Xint n0, n1, maxn;`09/* length of aa0, length of aa1 */ Xint nlib; Xlong ntt; Xint ktup; X`09`09`09`09 Xlong loffset = 0;`09`09/* offset into sequence */ X Xint iscore, gscore;`09`09/* for displaying scores without showbest */ X X/* the following are defaults for values that are read by X pam.c from *.mat if SMATRIX is defined */ X Xint histint=5; Xint bestscale=200; Xint bkfact=5; Xint scfact=4; Xint bktup=2; Xint ktmax=2; Xint bestmax=50; Xint bestoff=27;`09/* values for calculating bestcut */ X#ifndef NT Xint dnaseq = 0; X#else Xint dnaseq = 1; X#endif X Xlong hist`5BMAXHIST`5D;`09`09/* histogram of all score */ Xint histoff; Xdouble lsum, lsumsq;`09`09/* mean, sd of all scores */ Xdouble sqrt(); Xlong nmean;`09`09`09/* number of scores averaged in mean */ X Xint nshow; char rline`5B20`5D,sline`5B20`5D; X Xlong tstart, tscan, tdone, stime(); X Xextern int optind; Xchar *libenv, *aaenv, *smptr; X X#include "upam.gbl"`09`09/* includes pam array */ X Xmain(argc, argv) X int argc; char **argv; X`7B X`09char tname`5B40`5D, lname`5B40`5D, qline`5B40`5D; X`09int itemp, iln, nln; X`09char *calloc(), *getenv(), *cptr; X X`09initenv(argc,argv); X`09if ((aa0=calloc(MAXTST+MAXLIB,sizeof(char)))==0) `7B X`09`09fprintf(stderr," cannot allocate sequence array\n"); X`09`09exit(1); X`09`09`7D X`09maxn = MAXTST+MAXLIB; X X`09ktmax = ktup = 25; X X if (argc-optind < 3) `7B X printf(" relate 1.0 `5BApril, 1988`5D searches a sequence da Vta bank\n"); X`09l1:`09printf(" test sequence file name: "); X X`09`09fgets(tname,40,stdin); X`09`09if (tname`5Bstrlen(tname)-1`5D=='\n') tname`5Bstrlen(tname)-1`5D='\0'; X`09`09if (tname`5B0`5D=='\0') goto l1; X X if ((n0=getseq(tname,aa0,MAXTST,&dnaseq))==0) `7B X fprintf(stderr," %s : %s sequence not found\n",tname,sqtype) V; X`09`09goto l1; X `7D X X`09`09resetp(dnaseq); X`09`09`09 X`09l2:`09printf(" second sequence file name: "); X`09`09fgets(lname,40,stdin); X`09`09if (lname`5Bstrlen(lname)-1`5D=='\n') lname`5Bstrlen(lname)-1`5D='\0'; X`09`09if (*lname==0) goto l2; X`09`09printf(" window `5B%d`5D ",ktmax); X`09`09fgets(qline,40,stdin); X`09`09ktup = ktmax; X`09`09if (qline`5B0`5D!='\0' && qline`5B0`5D!='\n') `7B X`09`09`09sscanf(qline,"%d",&ktup); X`09`09`09if (ktup < 1 `7C`7C ktup>ktmax ) `7B X`09printf(" warning ktup = %d out of range, reset to %d\n",ktup,ktmax); X`09`09`09`09ktup = ktmax; X`09`09`09`09`7D X`09 `7D X`09`09`7D X`09else `7B X`09`09strncpy(tname,argv`5Boptind+1`5D,40); X if ((n0=getseq(tname,aa0,MAXTST,&dnaseq))==0) `7B X fprintf(stderr," %s : %s sequence not found\n",tname,sqtype) V; X exit(1); X `7D X X`09`09resetp(dnaseq); X`09`09strncpy(lname,argv`5B2`5D,40); X`09`09`7D X X`09initpam2();`09`09/* convert 1-d pam to 2-d pam2 */ X X`09strncpy(name0,tname,6); name0`5B6`5D='\0'; X X`09fprintf(stderr," %s : %4d %-s\n",tname, n0, sqnam); X X`09aa1 = aa0 + n0 + 2; X`09maxn -= n0 + 3; X X`09tstart = stime(); X`09histoff = histint*(MAXHIST-1)/2; X`09inithist();`09`09/* initialize histogram, mean, sd */ X X`09nlib = 0; X`09ntt = 0l; X X`09if (openlib(lname,"\0")<=0) `7B X`09`09fprintf(stderr," could not open %s library\n",lname); X`09`09exit(1); X`09`09`7D X`09dhash();`09/* do the hash through the library */ X X`09tscan = stime(); X X`09prhist(stdout);`09`09/* print histogram, statistics */ X X l3:`09printf(" Enter filename for results : "); X`09fgets(rline,20,stdin); X`09outfd = stdout; X`09if (rline`5B0`5D!='\n' && rline`5B0`5D!=0) `7B X`09`09rline`5Bstrlen(rline)-1`5D=0; X`09`09if ((outfd=fopen(rline,"w"))==0) `7B X`09`09`09printf(" could not open %s\n",rline); X`09`09`09goto l3; X`09`09`09`7D X`09`09fprintf(outfd," %s, %d %s vs %s library\n", X`09`09`09tname, n0, sqnam, lname); X`09`09if (strlen(smptr)>0) fprintf(outfd," using matrix file %s\n",smptr); X`09`09else fprintf(outfd," using pam250 matrix\n"); X`09`09prhist(outfd); X`09`09`7D`20 X`09`7D X Xextern int *sascii, nascii`5B`5D, aascii`5B`5D; X Xinitenv(argc,argv) X`09int argc; char **argv; X`7B X`09char *cptr, *getenv(); X`09int copt, getopt(); X`09extern char *optarg; X X`09libenv="\0"; X`09aaenv="\0"; X X#ifndef NT X`09sascii = aascii; X`09pam = apam; X`09sq = aa; X`09hsq = haa; X`09nsq = naa; X`09dnaseq = 0; X#else X`09sascii = nascii; X`09pam = npam; X`09hsq = hnt; X`09sq = nt; X`09nsq = nnt; X`09dnaseq = 1; X#endif X`09if ((smptr=getenv("SMATRIX"))!=NULL && initpam(smptr)) X`09`09dnaseq = -1; X`09else X`09`09smptr="\0"; X X`09while ((copt=getopt(argc,argv,"s:"))!=EOF) X`09`09switch(copt) `7B X`09`09`09case 's': smptr=optarg;`20 X`09`09`09`09if (initpam(smptr)) dnaseq= -1; X`09`09`09`09else smptr="\0"; X`09`09`09`09break; X`09`09`09default : fprintf(stderr," illegal option -%c\n",copt); X`09`09`09`7D X`09optind--; X X`09if (strlen(smptr)>0) fprintf(stderr," using matrix file %s\n",smptr); X`09`7D X Xresetp(dnaseq) X`09int dnaseq; X`7B X`09if (dnaseq==1) `7B X`09`09histint=10; X`09`09bestscale=400; X`09`09bkfact=5; X`09`09bestmax=80; X`09`09bestoff=45; X`09`09pam = npam; X`09`09`7D X`09`7D X X/*`09hashaa - hash sequence 0 for rapid lookup of seq 1 (library) */ X Xdhash() X`7B X`09int i0, i1; X`09int lcont, ocont, loff; X`09long lmark; X`09char *aa1ptr; X X`09loffset=0l; X`09lcont=0; X`09ocont=0; X`09loff = 0; X`09aa1ptr = aa1; X X while ((n1=getlib(aa1ptr,maxn-loff,libstr,&lmark,&lcont))>0) `7B X`09`09ntt += n1; X`09`09if (aa1!=aa1ptr) `7Bn1 += loff; nlib--;`7D X`09`09nlib++; X X`09 for (i0=0; i0<(n0-ktup); i0++) X`09 `09for (i1=0; i1<(n1-ktup); i1++) X`09 `09 addhist(spam(aa0+i0,aa1+i1,ktup)); X X`09 if (lcont) `7B X`09`09 loff = ktup-1; X`09`09 memcpy(aa1,&aa1`5Bn1-loff`5D,loff); X`09`09 aa1ptr= &aa1`5Bloff`5D; X`09`09 loffset += n1-loff; X`09`09 ocont = lcont; X`09`09 `7D X`09 else `7B X`09`09 loff = 0; X`09`09 aa1ptr=aa1; X`09`09 loffset = 0l; X`09`09 ocont = lcont; X`09`09 `7D X`09 `7D X`09`7D X Xspam(sq0, sq1, n) X`09char *sq0, *sq1; int n; X`7B X`09int tot; X`09tot = 0; X`09while (n-->0) tot += pam2`5B*sq0++`5D`5B*sq1++`5D; X`09return tot; X`09`7D X Xinitpam2() X`7B X`09int i, j, k; X X`09k=0; X`09for (i=0; i1) `7B X`09`09lsd = (lsumsq - (lsum*lsum)/(float)nmean)/(float)(nmean-1); X`09`09lsd = sqrt(lsd); X`09`09`7D X`09else lsd = 0.0; X`09if (nmean>0) lmean = lsum/(float)nmean; X`09else lmean = 0.0; X X`09for (i=0; i<10; i++) sdarr`5Bi`5D= 1000; X`09for (i=0; i<9; i++) sdarr`5Bi`5D=(int)(lmean+lsd*(float)i); X`09hl = (lmean + lsd*4.0); X X`09for (i=(hl+histoff)/histint, ssum=0l; i' : ' '; X`09`09pch = (i==0) ? '<' : pch; X`09`09if ((i+1)*histint-histoff > sdarr`5Bis`5D) `7B X`09`09`09pch = '0'+is; sdarr`5Bis++`5D=1000; `7D X`09`09fprintf(fd,"%c%5d %5ld :", X`09 pch,(i 50) hl = 50; X`09`09for (j=0; j0) `7Bhline`5B0`5D='.'; hline`5B1`5D='\0';`7D X`09`09fprintf(fd,"%s\n",hline); X`09`09`7D X X`09fprintf(fd, X`09 "%4ld residues, %ld comparisons of window: %d, mean score: %5.1f (%.2 Vf)\n", X`09`09ntt,nmean,ktup,lmean,lsd); X`09fprintf(fd,"%ld segments >= 4 sd above mean; scan time: ",ssum); ptime(f Vd,tscan-tstart); fprintf(fd,"\n"); X`09`7D X Xaddhist(score) X`09int score; X`7B X`09lsum = lsum + (double)score; X`09lsumsq = lsumsq + (double)score*(double)score; X`09nmean++; X X`09score = (score+histoff)/histint; X`09if (score < 0) score=0; X`09else if (score >= MAXHIST) score = MAXHIST-1; X`09hist`5Bscore`5D++; X`09`7D X Xtoupper(c) X`09char c; X`7B X`09if (c>='a' && c<='z') return (c-'a'+'A'); X`09return c; X`09`7D X $ CALL UNPACK RELATE.C;1 1144939423 $ create 'f' X.TH RSS 1 local X.SH NAME Xrss \- test a protein sequence similarity for significance X.SH SYNOPSIS X.B rss X\&`5B X.I -w X`5D Xsequence-file-1 sequence-file-2 X`5B X.I #-of-shuffles X`5D `5B X.I window-size X`5D X X.B rss X\- interactive mode X X.SH DESCRIPTION X.B rss Xis used to evaluate the significance of a protein sequence Xsimilarity score by comparing two sequences and calculating Xoptimal similarity scores, and then repeatedly shuffling the Xsecond sequence, calculating optimal scores, Xand then calculating the "z-value" or number of standard deviations Xthe unshuffled scores are above the mean of the distribution of Xshuffled sequence scores. This program is a variation of the`20 X.B rdf2 Xprogram, described by Lipman and Pearson (Science (1985) 227:1427), XPearson and Lipman, PNAS (1988) 85:2444-2448, and Pearson (Meth. Enz. X(1990) 183:63-98). X.B rss Xuses calculates optimal scores using the same rigorous Smith-Waterman Xalgorithm (Smith and Waterman, J. Mol. Biol. (1983) 147:195-197) used by the X.B ssearch Xprogram. X.PP X.B rss Xalso allows a more sophisticated shuffling method: residues can be shuffled Xwithin a local window, so that the order of residues 1-10, 11-20, etc, Xis destroyed but a residue in the first 10 is never swapped with a residue Xoutside the first ten, and so on for each local window. X.SH EXAMPLES X.TP X(1) X.B rss X-w musplfm.aa lcbo.aa 100 10 X.PP XCompare the amino acid sequence in the file musplfm.aa with that Xin lcbo.aa, then shuffle lcbo.aa 100 times using a local shuffle with Xa window of 10. Report the significance of the Xunshuffled musplfm/lcbo comparison scores with respect to the shuffled Xscores. X.TP X(2) X.B rss Xmusplfm.aa lcbo.aa 100 X.PP XCompare the amino acid sequence in the file musplfm.aa with the sequences Xin the file lcbo.aa. X.TP X(3) X.B rss X.PP XRun rss in interactive mode. The program will prompt for Xthe file name of the two query sequence files Xand the number of shuffles to be used. 50 or 100 shuffles are Xmore appropriate that the 20 default. X.SH "SEE ALSO" Xssearch(1), rdf2(1), fasta(1), lfasta(1), protcodes(5) X.SH BUGS X.B rss Xshould do more than 20 shuffles by default, 50 or 100 are more reasonable. XWindow shuffles should be the default. X.SH AUTHOR XBill Pearson X.br Xwrp@virginia.EDU $ CALL UNPACK RSS.1;1 1131952327 $ create 'f' X/*`09index.c`09`0924-Mar-1985`09*/ X X/*`09modified May, 1990 to allow for indexing very large libraries X`09(up to 5 * DEFREC) entries X X`09For Turbo 'C' - Must be compiled with -ml or -mh option X*/`09`09 X X/*`09modified for no '-' in title and 10 char sequence names X`09Nov, 1987 X*/ X/*`09copyright (C) 1985, 1988, 1989 William R. Pearson */ X X/* X`09this program scans a protein library file and builds and index X`09for use with extractp X X`09modified for TURBOC and huge databases X`09`09 X*/ X X#include X#include X#include X Xchar *calloc(); X X#ifdef UNIX X#include X#endif X X#ifdef THINK_C X#include X#include X#include X#include XSFReply freply; XPoint wpos; Xint tval; Xchar prompt`5B256`5D; X#endif X X#define TRUE 1 X#define FALSE 0 X X#ifdef BIGMEM X#define DEFREC 50000 X#else X#define DEFREC 10000 X#define BIGNUM 30000 X#endif X X#define MAXGRP 5 X X#define NAMLEN`0911`09/* length of a protein sequence name */ Xint fidx;`09`09/* fd for index file */ XFILE *finx; X X XFILE *libf=NULL; Xlong lpos; X X#define MAXLINE 512 Xchar line`5BMAXLINE`5D; Xint lline; X XFILE *namf; Xint namflag; X X/* arrays for sequence names, marks, and index */ Xint iidx=0, jidx, nidx; Xlong iitt`5BMAXGRP`5D; Xint indx`5BMAXGRP`5D; Xchar *namptr, **namidx`5BMAXGRP`5D; X#define NAMAVE 8`09/* average name size */ Xlong *markarr`5BMAXGRP`5D; Xchar *markfn`5BMAXGRP`5D; Xunsigned nrec; Xlong namtot, maxnam; X X#define MAXLF 20 X#define MAXLN 50 Xchar *libenv, ldname`5B80`5D; Xchar *lbnarr;`09`09/* name array of libraries to be opened in list */ Xchar *lbnames`5BMAXLF`5D;`09/* names of libraries to be opened */ Xint libfn;`09`09/* current library file being searched */ Xint iln, nln; X Xlong ntt, ontt; Xint ltt; X X#ifdef THINK_C Xint glvRef,anvRef, sqvRef, ouvRef; X#endif X Xmain(argc,argv) X`09int argc; char **argv; X`7B X`09char lname`5B80`5D,iname`5B80`5D,inname`5B80`5D,nname`5B80`5D,rline`5B80` V5D; X`09char *bp, *strchr(); X X`09struct `7B X`09`09char nam`5BNAMLEN`5D; X`09`09char fn; X`09`09long lmark; X`09`09`7D seq; X`09int i,ii, itemp; X X#ifdef THINK_C X`09if (OpenResFile("\pFASTA.rsrc")<0) `7B X`09`09SysBeep(100); fprintf(stderr," WARNING FASTA.rsrc file could not be fo Vund\n"); X`09`09`7D X`09GetVol(prompt,&ouvRef); X`09wpos.h=50; wpos.v=100; X#endif X X`09libenv=ldname; X X`09if (argc < 2) `7B X printf(" sindex (1.4c) indexes a protein sequence data bank\ Vn"); X`09`09printf(" library file name: "); X`09`09fgets(lname,80,stdin); X`09`09if ((bp=strchr(lname,'\n'))!=NULL) *bp='\0'; X`09`09newname(iname,lname,"ixx",sizeof(iname)); X`09`09newname(inname,lname,"inx",sizeof(inname)); X`09`09printf(" name file name `5B`5D: "); X`09`09fgets(rline,80,stdin); X`09`09if (rline`5Bstrlen(rline)-1`5D=='\n') rline`5Bstrlen(rline)-1`5D='\0'; X`09`09if (*rline!=0) strncpy(nname,rline,80); X`09`09 else nname`5B0`5D='\0'; X`09`09`7D X`09else `7B X`09`09strncpy(lname,argv`5B1`5D,80); X`09`09newname(iname,lname,"ixx",sizeof(iname)); X`09`09newname(inname,lname,"inx",sizeof(inname)); X`09`09if (argc>2) strncpy(nname,argv`5B2`5D,sizeof(nname)); X`09`09 else nname`5B0`5D='\0'; X`09`09`7D X X`09nrec = DEFREC; X X `09/* space for total characters in names */ X`09maxnam = (long)NAMAVE* (long)nrec; X X`09if (maxnam>BIGNUM) maxnam=BIGNUM; X X`09allocrec(0,nrec); X`09 X`09if ((namidx`5B0`5D`5B0`5D=namptr= X`09 calloc((size_t)maxnam,(size_t)sizeof(char)))==NULL) `7B X`09`09printf(" cannot allocate sequence name array\n"); X`09`09exit(0); X`09`09`7D X X`09ntt = 0l; X`09ltt = 0; X X`09openidx(iname); X`09namflag = FALSE; X`09if (nname`5B0`5D) `7B X`09`09if ((namf=fopen(nname,"w"))==0) X`09`09`09printf(" cannot open %s \n",nname); X`09`09else namflag=TRUE; X`09`09`7D X`09namtot = 0; X`09i = 0; X X X`09if (lname`5B0`5D!='@') `7B X`09`09libfn = 0; nln=1; X`09`09lbnames`5B0`5D=lname; X`09`09openlib(lbnames`5B0`5D,libenv); X`09`09doindex(); X`09`09closelib(); X`09`09strcpy(namidx`5Biidx`5D`5Bltt`5D,"\177"); X`09`09iitt`5Biidx++`5D=ltt; X`09`09`7D X`09else `7B X`09`09nln=getlnames(&lname`5B1`5D); X`09`09for (iln=0; iln0) `7B X`09`09`09`09libfn = iln; X`09`09`09`09printf(" indexing %s library -",lbnames`5Biln`5D); X`09`09`09`09fflush(stdout); X`09`09`09`09`7D X`09`09`09if (itemp<0) continue; X`09`09`09ontt=ntt; X`09`09`09doindex(); X`09`09`09closelib(); X`09`09`09printf(" %5ld sequences\n",ntt-ontt); X`09`09`09`7D X`09`09strcpy(namidx`5Biidx`5D`5Bltt`5D,"\177"); X`09`09iitt`5Biidx++`5D=ltt; X`09`09`7D X X/* Xfor (i=0; i<20; i++) printf("%5d %s\n",i,namidx`5Bi`5D); Xfor (i=ntt-20; i0) jidx=iidx; X`09`09ii = indx`5Bjidx`5D; X`09`09strncpy(seq.nam,namidx`5Bjidx`5D`5Bii`5D,NAMLEN); X`09`09seq.fn = markfn`5Bjidx`5D`5Bii`5D; X`09`09seq.lmark=markarr`5Bjidx`5D`5Bii`5D; X`09`09if (write(fidx,&seq,sizeof(seq))!=sizeof(seq)) `7B X`09`09`09printf(" error writing %s\n",seq.nam); X`09`09`09break; X`09`09`09`7D X`09`09indx`5Bjidx`5D++; X`09`09`7D X`09close(fidx); X`09printf(" %ld sequences indexed\n",ntt); X`09`7D X Xdoindex() X`7B X`09int llen; X X`09while (getlib(namidx`5Biidx`5D`5Bltt`5D,&markarr`5Biidx`5D`5Bltt`5D)>0) ` V7B X`09`09markfn`5Biidx`5D`5Bltt`5D=libfn; X`09`09llen=strlen(namidx`5Biidx`5D`5Bltt`5D); X`09`09namtot += llen+1; X`09`09namidx`5Biidx`5D`5Bltt+1`5D = namidx`5Biidx`5D`5Bltt`5D+llen+1; X`09`09ntt++; ltt++; X`09`09if (ltt >= nrec-1) `7B X`09`09`09strcpy(namidx`5Biidx`5D`5Bltt`5D,"\177"); X`09`09`09namtot += 2; X`09`09`09iitt`5Biidx++`5D=ltt; X`09`09`09allocrec(iidx,nrec); X`09`09`09namidx`5Biidx`5D`5B0`5D=namptr+namtot; X`09`09`09ltt = 0; X`09`09`09`7D X X`09`09if (namtot + NAMLEN > maxnam) `7B X`09`09 if ((namidx`5Biidx`5D`5B(int)(ltt)`5D=namptr= X`09`09`09calloc((size_t)maxnam,(size_t)sizeof(char)))==NULL) `7B X`09`09printf("\n\n name space exceeded at `5B%d`5D %d %s (%ld) (%ld)\n\n", X`09`09`09`09iidx,ltt-1,namidx`5Biidx`5D`5Bltt-1`5D,namtot,maxnam); X`09`09`09exit(1); X`09`09`09`7D X`09`09 namtot = 0l; X`09`09 `7D X`09`09`7D X`09`7D X X/* newname generates a new filename with prefix oname and suffix suff */ X Xnewname(nname,oname,suff,maxn) X`09char *nname, *oname, *suff; X`09int maxn; X`7B X`09char *tptr; X`09if (*oname!='@') strncpy(nname,oname,maxn); X`09else strncpy(nname,oname+1,maxn); X X`09for (tptr=nname; *tptr!='.'&& *tptr; tptr++); /* get to '.' or EOS */ X`09*tptr++='.'; *tptr='\0'; X`09strncat(nname,suff,maxn); X`09`7D X Xallocrec(iidx,nrec) X`09int iidx; X`09unsigned nrec; X`7B X X`09if ((namidx`5Biidx`5D=(char **)calloc((size_t)nrec,(size_t)sizeof(char *) V))==NULL) `7B X`09`09printf(" cannot allocate sequence name pointer array\n"); X`09`09exit(0); X`09`09`7D X X`09 X`09if ((markarr`5Biidx`5D=(long *)calloc((size_t)nrec,(size_t)sizeof(long))) V==NULL) `7B X`09`09printf(" cannot allocate file position array\n"); X`09`09exit(0); X`09`09`7D X X`09if ((markfn`5Biidx`5D=(char *)calloc((size_t)nrec,(size_t)sizeof(char)))= V=NULL) `7B X`09`09printf(" cannot allocate file number array\n"); X`09`09exit(0); X`09`09`7D X`09`7D X Xopenlib(lname,libenv) X`09char *lname, *libenv; X`7B X`09char lbname`5B80`5D, *bp, *strchr(); X`09long ftell(); X X`09if (lname`5B0`5D=='.') return -9; X`09if ((bp=strchr(lname,' '))!=NULL) *bp='\0'; X X`09if (*libenv!='\0') `7B X`09`09strncpy(lbname,libenv,sizeof(lbname)); X#ifdef UNIX X`09`09strcat(lbname,"/"); X#endif X`09`09`7D X`09else *lbname='\0'; X X`09strncat(lbname,lname,sizeof(lbname)-strlen(lbname)); X X#ifdef THINK_C X`09SetVol("\p",sqvRef); Xl1:`09if ((libf=fopen(lbname,"r"))==NULL) `7B X`09`09sprintf(prompt," cannot open %s\r Select library filename",lbname); X`09`09FileDlog(prompt,&freply); X`09`09if (freply.good==TRUE) `7B X`09`09`09strcpy(libenv,"\0");`09 X`09`09`09PtoCstr((char *)freply.fName); X`09`09`09strcpy(lbname,(char *)freply.fName); X`09`09`09sqvRef=anvRef=freply.vRefNum; X`09`09`09SetVol("\p\0",sqvRef); X`09`09`09goto l1; X`09`09`09`7D X`09`09else return -1; X`09`09`7D X#else`09`09/* MSDOS */ X`09if ((libf=fopen(lbname,"r"))==0) `7B X`09`09printf(" cannot open %s library\n",lbname); X`09`09return -1; X`09`09`7D X#endif X X`09lpos = ftell(libf); X`09fgets(line,MAXLINE,libf); X`09return 1; X`09`7D X Xcloselib() X`7B X`09if (libf!=NULL) fclose(libf); X`09`7D X Xgetlib(libstr,libpos) X`09char *libstr; X`09long *libpos; X`7B X`09long ftell(); X`09char *sp, *lp; X`09int i; X X`09while (line`5B0`5D!='>') `7B X`09`09lpos = ftell(libf); X`09`09if (fgets(line,MAXLINE,libf)==0) return 0; X`09`09`7D X`09*libpos = lpos; X`09for (sp = libstr,lp = &line`5B1`5D, i=0; X`09 *lp && i < NAMLEN && !(*lp==' '); i++) X`09`09*sp++ = *lp++; X`09*sp = '\0'; X`09if (namflag) fputs(line,namf); X X`09while (fgets(line,MAXLINE,libf)!=0) `7B X`09`09if (line`5B0`5D=='>') break; X`09`09lpos = ftell(libf); X`09`09`7D X`09return 1; X`7D X X#ifndef UNIX X#define PCODE 0644 X#else X#include X#include X#define PCODE (S_IWRITE+S_IREAD) X#define O_BINARY 0 X#endif X Xopenidx(iname) X`09char *iname; X`7B X#ifndef THINK_C X`09if ((fidx=open(iname,O_RDWR+O_CREAT+O_BINARY,PCODE))==0) `7B X#else X`09SetVol("\p\0",ouvRef); X`09if ((fidx=open(iname,O_RDWR+O_CREAT+O_BINARY))==0) `7B X#endif X`09`09printf(" cannot open %s index\n",iname); X`09`09exit(1); X`09`09`7D X`09`7D X Xshell(ix,n) X`09int ix; long n; X`7B X`09long gap, i, j; X`09char *qptr; X`09long tmark; X`09int tfn; X X`09for (gap=n/2; gap>0; gap/=2) X`09 for (i=gap; i=0; j -= gap) `7B X`09`09 if (strcmp(namidx`5Bix`5D`5Bj`5D,namidx`5Bix`5D`5Bj+gap`5D) <= 0) V break; X`09`09 qptr=namidx`5Bix`5D`5Bj`5D; X`09`09 namidx`5Bix`5D`5Bj`5D=namidx`5Bix`5D`5Bj+gap`5D; X`09`09 namidx`5Bix`5D`5Bj+gap`5D=qptr; X`09`09 tmark=markarr`5Bix`5D`5Bj`5D; X`09`09 markarr`5Bix`5D`5Bj`5D=markarr`5Bix`5D`5Bj+gap`5D; X`09`09 markarr`5Bix`5D`5Bj+gap`5D=tmark; X`09`09 tfn=markfn`5Bix`5D`5Bj`5D; X`09`09 markfn`5Bix`5D`5Bj`5D=markfn`5Bix`5D`5Bj+gap`5D; X`09`09 markfn`5Bix`5D`5Bj+gap`5D=tfn; X`09`09 `7D X`09`7D X Xgetlnames(tname)`09`09/* read in the library names */ X`09char *tname; X`7B X`09int i, nn; X`09char *lbptr, *bp, *strchr(); X`09FILE *tptr; X X`09if ((tptr=fopen(tname,"r"))==0) `7B X`09`09fprintf(stderr," could not open file of names: %s\n",tname); X`09`09exit(1); X`09`09`7D X X`09if ((lbnarr=calloc((size_t)MAXLF*MAXLN,(size_t)sizeof(char)))==NULL) `7B X`09`09fprintf(stderr," could not allocate name table\n"); X`09`09exit(1); X`09`09`7D X X`09nn = 0; X`09lbptr = lbnarr; X X`09while (fgets(lbptr,MAXLN,tptr)!=NULL) `7B X`09`09if (lbptr`5B0`5D=='>' `7C`7C lbptr`5B0`5D==';' `7C`7C lbptr`5B0`5D=='# V') continue; X`09`09if ((bp=strchr(lbptr,'\n'))!=NULL) *bp='\0'; X`09`09if ((bp=strchr(lbptr,' '))!=NULL) *bp='\0'; X`09`09lbnames`5Bnn`5D=lbptr; X`09`09if (lbptr`5B0`5D=='<') `7B X`09`09`09strncpy(ldname,&lbptr`5B1`5D,sizeof(ldname)); X`09`09`09ldname`5Bsizeof(ldname)-1`5D='\0'; X`09`09`09continue; X`09`09`09`7D X`09`09if (lbptr`5B0`5D=='\0') continue; X`09`09lbptr += (i=strlen(lbptr)+1); X`09`09nn++; X`09`09if (nn>=MAXLF) break; X`09`09`7D X X`09fclose(tptr); X`09return nn; X`09`7D $ CALL UNPACK SINDEX.C;1 1314446668 $ create 'f' X.TH SSEARCH 1 local X.SH NAME Xssearch \- scan a protein or DNA sequence library for similar sequences X X.SH SYNOPSIS X.B ssearch X`5B-a -b # -d # -l X.I FASTLIBS X\& -r X.I STATFILE X-m # -Q -s X.I SMATRIX X-w # X`5D query-sequence-file library-file X X.B ssearch X`5B-Qabdlmorsw`5D query-file @library-name-file X X.B ssearch X`5B-Qabdlmrsw`5D query-file "%PRMVI" X X.B ssearch X`5B-almrsw`5D \- interactive mode X X.SH DESCRIPTION X.B ssearch Xcompares a protein or DNA sequence to all of the entries in Xa sequence library using the rigorous Smith-Waterman algorithm (Smith Xand Waterman, J. Mol. Biol. (1983) 147:195-197. For example, X.B ssearch Xcan compare a protein sequence to all of the sequences in the NBRF XPIR protein sequence database. X.B ssearch Xwill automatically decide whether the query sequence is DNA or protein by Xreading the query sequence as protein and determining whether the X`60amino-acid composition' is more than 85% A+C+G+T. XThe program can be invoked either with command line Xarguments or in interactive mode. X.B ssearch Xcompares a query sequence to a sequence library which consists Xof sequence data interspersed with comments, see below. XThe X.B fasta Xprograms, including X.B ssearch\c X\&, use a standard text format sequence file. Lines beginning with X'>' or ';' are considered comments and ignored; sequences can be upper Xor lower case, blanks,tabs and unrecognizable characters are ignored. X.B ssearch Xexpects sequences to use the single letter amino acid codes, see X.B protcodes(1) X\&. XLibrary files for ssearch should have the form shown below. X.SH OPTIONS X.PP X.B ssearch Xcan be directed to change the scoring matrix, search parameters, Xoutput format, and default search directories by entering options on Xthe command line (preceeded by a `60\-'). All of the Xoptions should preceed the file name and ktup arguments). Alternately, Xthese options can be changed by setting environment variables. The Xoptions and environment variables are: X X.TP X\-a X.B (SHOWALL) XModifies the display of the two sequences in Xalignments. Normally, both sequences are shown only where they Xoverlap (SHOWALL=0); If \-a or the environment variable SHOWALL = 1, Xboth sequences are shown in their entirety. X.TP X\-b # XThe number of similarity scores to be shown when the X.B -Q Xoption is used. This value is usually calculated based on the Xactual scores. X.TP X\-d # XThe number of alignments to be shown. Normally, X.B ssearch Xshows the same number of alignments as similarity scores. By using X.B ssearch -Q -b`20 X200 X.B -d X50, one would see the top scoring 200 sequences and alignments for the X50 best scores. X.TP X\-l # X.B (FASTLIBS) XThe name of the library menu file. Normally this will be determined Xby the environment variable X.B FASTLIBS\c X\&. However, a library menu file can also be specified with X.B \-l\c X\&. X.TP X\-m # X.B (MARKX) X=1,2,3. Alternate display of matches and mismatches in Xalignments. MARKX=1 uses ":","."," ", for identities, consevative Xreplacements, and non-conservative replacements, respectively. MARKX=2 Xuses " ","x", and "X". MARKX=3 does not show the second sequence, but Xuses the second alignment line to display matches with a "." for Xidentity, or with the mismatched residue for mismatches. MARKX=3 is Xuseful for aligning large numbers of similar sequences. X.TP X\-Q Quiet option. This allows ssearch to search a database and report Xthe results without asking any questions. ssearch -Q file library > Xoutput can be put in the background or run at a later time with the Xunix 'at' command. The number of similarity scores and alignments Xdisplayed with the X.B -Q Xoption can be modified with the X.B -b X(scores) and X.B -d X(alignments) options. X.TP X\-r X.I STATFILE XCauses X.B ssearch Xto write out the sequence identifier, superfamily number (if available), Xand similarity scores to X.I STATFILE Xfor every sequence in the library. These results are not sorted. X.TP X\-s str X.B (SMATRIX) Xthe filename of an alternative scoring matrix file. For protein Xsequences, PAM250 is used by default; PAM120 can be used with the Xcommand line option X.B -s 120\c X\&. X.TP X\-w # X.B (LINLEN) Xoutput line length for sequence alignments. (normally 60, Xcan be set up to 200). X X.SH EXAMPLES X.TP X(1) X.B ssearch Xmusplfm.aa $AABANK X.PP XCompare the amino acid sequence in the file musplfm.aa with the complete XPIR protein sequence library. This is extremely slow and should Xalmost never be done. X.B ssearch Xis designed to search very small libraries of sequences. X.nf X.in +5n X X>LCBO bovine preprolactin XWILLLSQ ... X>LCHU human ... X\&... X.in +0n X X.fi X.TP X(2) X.B ssearch X-a -w 80 musplfm.aa lcbo.aa X.PP XCompare the amino acid sequence in the file musplfm.aa with the sequences Xin the file lcbo.aa using X.I ktup X\= 1. Show both sequences in their entirety, with 80 residues on Xeach output line. X.TP X(3) X.B ssearch X.PP XRun the X.B ssearch Xprogram in interactive mode. The program will prompt for Xthe file name for the query sequence, list alternative libraries Xto be seached (if FASTLIBS is set), and prompt for the`20 X.I ktup. X.PP XYou can use your own sequence files for X.B ssearch\c X\&, just be certain to put a '>' and comment as the first line Xbefore the sequence. X.SH "SEE ALSO" Xrss(1), align(1), fasta(1), rdf2(1),protcodes(5), dnacodes(5) X.SH AUTHOR XBill Pearson X.br Xwrp@virginia.EDU $ CALL UNPACK SSEARCH.1;1 1813977564 $ create 'f' X/* ssearch.c Aug, 1991 X copyright (c) 1991 William R. Pearson X*/ X/* X`09ssearch is a version of fffasta.c that calculates a rigorous X`09smith-waterman local similarity score. X*/ X X X#include X Xchar *refstr="\nPlease cite:\n T. F. Smith and M. S. Waterman, (1981) J. Mol V. Biol. 147:195-197; \n W.R. Pearson (1991) Genomics 11:635-650\n"; X X#define TRUE 1 X#define FALSE 0 X X#define max(a,b) (((a)>(b))?(a):(b)) X X#ifndef BIGMEM X#define BIGNUM 32000 X#ifdef TFASTA X#define MAXTST 1000`09/* longest test sequence */ X#define MAXTRN 4000`09/* MAXTRN must be (MAXTST*3+MAXLIB)/3 */ X#define MAXLIB 8000 X#define MAXDIAG (MAXTST+MAXTRN) X#else X#define MAXTST 2000`09/* longest test sequence */ X#define MAXLIB 10000 X#define MAXDIAG (MAXTST+MAXLIB) X#endif X#else X#define BIGNUM 1000000000 X#define MAXTST 10000 X#define MAXLIB 50000 X#define MAXDIAG (MAXTST+MAXLIB) X#ifdef TFASTA X#define MAXTRN 30000 X#endif X#endif X X#define MAXHIST 41`09/* number of histogram divisions */ X X#ifndef BIGMEM X#define MAXBEST 2000`09/* number of good matches remembered */ X#else X#define MAXBEST 6000 X#endif X XFILE *outfd;`09`09/* fd for output file */ Xint smark`5B4`5D; X XFILE *tmpfd; Xchar tmpfname`5B80`5D; Xint dataflg=0; X X/* globals for matching */ X Xlong lmark;`09`09/* position in library file from ftell() */ Xlong nlib, onlib; Xlong ntt, ontt;`09`09/* number of library sequences, number of X`09`09`09`09residues scanned*/ X X#define BINARYGB 9`09/* this must agree with altlib.h */ Xextern int (*getlib)(), (*ranlib)(); Xextern int sfnum; X#define GETLIB (*getlib) X#define RANLIB (*ranlib) X Xchar libstr`5B21`5D;`09/* partial title from library sequence */ Xchar name0`5B11`5D, name1`5B11`5D;`09/* for labeling output */ Xint ixstat;`09`09/* >0 if annotations displayed */ X X#define MAXLF`0980`09/* number of library names */ X#ifdef BIGMEM X#define MAXLN`0940`09/* size of a library name */ X#else X#define MAXLN`0920 X#endif X Xchar *lbnarr;`09`09/* name array of libraries to be opened in list */ Xchar *lbnames`5BMAXLF`5D;`09/* names of libraries to be opened */ Xint nln;`09`09/* number of library files */ Xint gbflag=0;`09`09/* flag if any library is BINARYGB type */ Xint deftype=0;`09`09/* default library type */ X Xchar libfn;`09`09/* current library file being searched */ Xchar iname`5B80`5D; `09/* index file name */ Xchar ldname`5B80`5D; X Xchar *aa0, *aa1;`09/* amino acid sequence data */ X X#ifdef TFASTA Xchar *aa10; Xint nframe=6; X#endif X Xint maxn, maxt;`09`09/* max space for lib sequence */ Xint n0, n1, nd, noff;`09/* length of aa0, length of aa1, n0+n1, X`09`09`09`09diagonal offset */ Xlong sq0off=1, sq1off=1; Xlong loffset = 0l;`09`09/* offset into sequence */ X Xstruct beststr `7B X`09int score;`09/* pam score with segment optimization*/ X`09long lseek;`09/* position in library file */ X`09int cont;`09/* offset into sequence */ X`09int frame; X`09int lib;`09/* library for current sequence */ X`09`7D`20 X`09 *qptr, X#ifndef FAR_PTR X`09 *bbp,`09`09/* pointer for fbest */ X`09 *bestptr,`09/* temp pointer */ X`09 **bptr,`09/* array of pointers for sorting */ X`09 *best;`09/* array of best score data */ X#else X`09 far * bbp, X`09 far * best, X`09 far * bestptr,`09/* temp pointer */ X`09 far * far * bptr; X#endif X Xint iscore, gscore;`09/* for displaying scores without showbest */ X Xint nbest;`09/* number of sequences better than bestcut in best */ Xint bestcut=1; `09/* cut off for getting into MAXBEST */ X X/* the following are defaults for values that are read by X pam.c from *.mat if SMATRIX is defined */ X Xint histint=2; Xint bestscale=200; Xint bkfact=5; Xint scfact=4; Xint bktup=2; Xint ktmax=2; Xint bestmax=50; Xint bestoff=27;`09/* values for calculating bestcut */ Xint pamfact= 1;`09/* flag for using pam values for kfact */ Xint dnaseq = 0;`09/* true if DNA query sequence */ Xint ldnaseq = 0; X Xint bestfull=0; Xint igncnt=0; Xint optall=0; Xint optcount=0; X Xint nsav, lowscor;`09/* number of saved runs, worst saved X`09`09`09`09run, score of worst saved run */ Xstruct beststr *lowmax; X Xint hist`5BMAXHIST`5D;`09`09/* histogram of all score */ Xdouble lsum, lsumsq;`09`09/* mean, sd of all scores */ Xdouble sqrt(); Xlong nmean;`09`09`09/* number of scores averaged in mean */ Xint bigscore; X Xint fact, gm; /* scoring factors */ X Xint nshow=20, mshow=50, ashow=20; Xchar rline`5B20`5D,sline`5B20`5D; X X/* output options */ Xint showall, llen, markx;`09/* show all of both sequences */ X Xchar ttitle`5B60`5D; Xchar ltitle`5B60`5D; X Xlong tstart, tscan, tdone, stime(); X Xextern int optind; Xint optcnt; X Xint outtty; X Xchar *libenv, *aaenv, *smptr; Xchar smstr`5B40`5D; Xchar flstr`5B40`5D; X X#include "upam.gbl"`09`09/* includes pam array */ X Xmain(argc, argv) X int argc; char **argv; X`7B X`09char tname`5B40`5D, lname`5B80`5D, llname`5B80`5D, qline`5B40`5D; X`09int itemp, iln;`20 X`09char *calloc(), *getenv(), *cptr; X X#ifdef UNIX X`09outtty=isatty(1); X#else X`09outtty=1; X#endif X`09initenv(argc,argv); X`09if (dataflg && (tmpfd=fopen(tmpfname,"w"))==NULL) `7B X`09`09fprintf(stderr," cannot open temp file: %s\n",tmpfname); X`09`09dataflg=0; X`09`09`7D X X#ifdef TFASTA X`09aainit(); X`09dnaseq = -1;`09/* force to protein */ X`09ldnaseq = 1; X`09if (sqtype`5B0`5D=='D') `7B X`09fprintf(stderr," tssearch compares a protein to a translated\n\ XDNA sequence library. Do not use a DNA scoring matrix.\n"); X`09`09exit(1); X`09`09`7D X#endif X X`09if ((aa0=calloc(MAXTST+MAXLIB,sizeof(char)))==0) `7B X`09`09fprintf(stderr," cannot allocate sequence array\n"); X`09`09exit(1); X`09`09`7D X`09maxn = MAXTST+MAXLIB; X X#ifdef TFASTA X`09if ((aa1=calloc(MAXTRN,sizeof(char)))==0) `7B X`09`09fprintf(stderr," cannot allocate translation array\n"); X `09`09exit(1); X `09`09`7D X#endif X X if (argc-optind < 3) `7B X#ifdef TFASTA Xprintf(" tssearch 1.6a1 `5BSept, 1991`5D translates and searches a sequence V data bank\n%s\n",refstr); X`09l1:`09printf(" test sequence file name: "); X#else Xprintf(" ssearch 1.6a1 `5BSept, 1991`5D searches a sequence data bank\n%s\n" V,refstr); X`09l1:`09printf(" test sequence file name: "); X#endif X`09`09fflush(stdout); X`09`09if (fgets(tname,40,stdin)==NULL) exit(0); X`09`09if (tname`5Bstrlen(tname)-1`5D=='\n') tname`5Bstrlen(tname)-1`5D='\0'; X`09`09if (tname`5B0`5D=='\0') goto l1; X `09if ((n0=getseq(tname,aa0,maxn,&dnaseq))==0) `7B X fprintf(stderr," %s : %s sequence not found\n",tname,sqtyp Ve); X goto l1; X `7D X`09`09resetp(dnaseq); X X#ifndef TFASTA X if (dnaseq==1 && n0>(MAXTST+MAXLIB)/3) `7B X `09fprintf(stderr," query sequence is too long %d %s\n",n0,sqnam); X `09exit(1); X`09 `7D X else if (dnaseq==0 && n0>(MAXTST+MAXLIB)/2) `7B X `09fprintf(stderr," query sequence is too long %d %s\n",n0,sqnam); X `09exit(1); X`09 `7D X#else `09 X if (n0 > MAXTST) `7B X`09 fprintf(stderr," query sequence is too long %d %s\n",n0,sqnam); X exit(1); X `09`7D X#endif X`09`09`09 X`09libchoice(lname,sizeof(lname),aaenv); X`09libselect(lname); X`09`7D X`09else `7B X`09`09strncpy(tname,argv`5Boptind+1`5D,sizeof(tname)); X `09if ((n0=getseq(tname,aa0,maxn,&dnaseq))==0) `7B X fprintf(stderr," %s : %s sequence not found\n",tname,sqtyp Ve); X exit(1); X `7D X`09`09resetp(dnaseq); X#ifndef TFASTA X if (dnaseq==1 && n0>(MAXTST+MAXLIB)/3) `7B X `09fprintf(stderr," query sequence is too long %d %s\n",n0,sqnam); X `09exit(1); X`09 `7D X else if (dnaseq==0 && n0>(MAXTST+MAXLIB)/2) `7B X `09fprintf(stderr," query sequence is too long %d %s\n",n0,sqnam); X `09exit(1); X`09 `7D X#else `09 X if (n0 > MAXTST) `7B X `09fprintf(stderr," query sequence is too long %d %s\n",n0,sqnam); X `09exit(1); X`09 `7D X#endif X`09`09strncpy(lname,argv`5Boptind+2`5D,sizeof(lname)); X X`09`09libselect(lname); X`09 `7D X X`09if (!outtty) fprintf(stderr," %s : %4d %-s\n",tname, n0, sqnam); X`09gettitle(tname,ttitle,50); X`09if (strlen(ttitle)>0) X`09`09if (*ttitle=='>') strncpy(name0,&ttitle`5B1`5D,6); X`09`09else strncpy(name0,ttitle,6); X`09else X`09`09strncpy(name0,tname,6); X`09name0`5B6`5D='\0'; X X`09if (strlen(ttitle)>0) X`09`09printf(" %s : %d %s\n vs %s library\n",ttitle,n0,sqnam,ltitle); X`09else X`09`09printf(" %s : %d %s vs %s library\n",tname,n0,sqnam,ltitle); X X`09if (dataflg) `7B X`09 if (strlen(ttitle)>0) X fprintf(tmpfd,"; %s : %d %s\n; vs %s library\n",ttitle,n0,sqnam,ltitle) V; X`09 else X fprintf(tmpfd,"; %s : %d %s vs %s library\n",tname,n0,sqnam,ltitle); X`09`7D X X#ifndef TFASTA X`09aa1 = aa0 + n0 + 2; X#else X`09aa10 = aa0 + n0 + 2; X#endif X X`09maxn -= n0 + 3; X X`09initpam2();`09/* convert 1-d pam to 2-d pam2 */ X X`09initparm(); X`09if (dataflg) `7B X`09`09fprintf(tmpfd,"; ggapval %d gdelval %d \n",ggapval,gdelval); X`09`7D X X`09tstart = stime(); X X`09inithist();`09`09/* initialize histogram, mean, sd */ X X`09initbest(MAXBEST+1);`09/* +1 required for select() */ X`09for (nbest=0; nbest0) `7B X`09 printf(" searching %s library\n",lbnames`5Biln`5D); X`09 dhash(); X`09 `7D X`09 if (itemp== -9) `7B X`09 printf(" %8ld %s in %5ld sequences\n",ntt-ontt, X`09`09 sqnam,nlib-onlib); X`09 ontt=ntt; onlib=nlib; continue; X`09 `7D X`09 if (itemp<0) break; X`09 closelib(); X`09`7D X X`09tscan = stime(); X X`09if (dataflg) `7B X`09fprintf(tmpfd,"; %8ld %s in %5ld sequences; scan time: ", X`09`09ntt,sqnam,nlib); X`09ptime(tmpfd,tscan-tstart); X`09fputs("\n",tmpfd); X`09`7D X X`09prhist(stdout);`09`09/* print histogram, statistics */ X X`09outfd = stdout; X l3:`09if (outtty) `7Bprintf(" Enter filename for results : "); fflush(stdo Vut);`7D X`09`09rline`5B0`5D='\0'; X`09`09if (outtty && fgets(rline,20,stdin)==NULL) exit(0); X`09`09if (rline`5B0`5D!='\n' && rline`5B0`5D!=0) `7B X`09`09`09rline`5Bstrlen(rline)-1`5D=0; X`09`09`09if ((outfd=fopen(rline,"w"))==0) `7B X`09`09`09`09printf(" could not open %s\n",rline); X`09`09`09`09goto l3; X`09`09`09`09`7D X`09`09`09fprintf(outfd," %s, %d %s vs %s library\n", X`09`09`09`09tname, n0, sqnam, lname); X`09`09`09if (strlen(smptr)>0) X`09`09`09`09fprintf(outfd," using matrix file %s\n",smptr); X`09`09`09else fprintf(outfd," using %s matrix\n",sqtype); X`09`09`09prhist(outfd); X`09`09`09`7D X X`09if (nbest<=0) `7Bfprintf(outfd," No similar regions found\n"); exit(0);`7 VD X X`09sortbest(); X X`09if (gbflag) `7B X`09`09if (iname`5B0`5D=='\0') newname(iname,lname,"idx",40); X`09`09ixstat=openidx(iname,libenv); X`09`09`7D X X`09if (nbest <= 0) `7B X fprintf(outfd," no sequences with scores greater than %d found\n",bestcut) V; X if (outfd != stdout)`20 X fprintf(outfd," no sequences with scores greater than %d found\n",bestcut) V; X exit(0); X `7D X`09showbest();`09/* display best matches */ X X`09rline`5B0`5D='Y'; X`09if (outtty) `7B X`09`09printf(" Display alignments also? "); fflush(stdout); X`09`09if (fgets(rline,20,stdin)==NULL) exit(0); X`09`09`7D X`09if (toupper(rline`5B0`5D)=='Y') `7B X`09`09if (outtty) `7B X`09`09`09printf(" number of alignments `5B%d`5D? ",nshow); X`09`09`09fflush(stdout); X`09`09`09if (fgets(rline,20,stdin)==NULL) exit(0); X`09`09`09if (rline`5B0`5D!=0) sscanf(rline,"%d",&nshow); X`09`09 ashow=nshow; X`09`09`09`7D X`09`09showalign(nshow); X`09`09`7D X`09tdone = stime(); X`09printf("Library scan: "); ptime(stdout,tscan-tstart); X`09printf(" total CPU time: "); ptime(stdout,tdone-tstart); X`09printf("\n"); X`09if (outfd!=stdout) `7B X`09`09fprintf(outfd,"Library scan: "); ptime(outfd,tscan-tstart); X`09`09fprintf(outfd," total CPU time: "); ptime(outfd,tdone-tstart); X`09`09fprintf(outfd,"\n"); X`09`09`7D X`09exit(0); X`7D X Xextern int *sascii, nascii`5B`5D, aascii`5B`5D; X Xinitenv(argc,argv) X`09int argc; X`09char **argv; X`7B X`09char *cptr, *getenv(); X`09int copt, getopt(); X`09extern char *optarg; X`09int i; X X`09libenv="\0"; X`09if ((aaenv=getenv("AABANK"))==NULL) aaenv="\0"; X`09if ((cptr=getenv("FASTLIBS"))!=NULL) strncpy(flstr,cptr,sizeof(flstr)); X`09else flstr`5B0`5D='\0'; X X`09sascii = aascii; X`09pam = apam; X`09sq = aa; X`09hsq = haa; X`09nsq = naa; X`09dnaseq = 0; X`09ldnaseq = 0; X X`09showall = 0; X X`09if ((cptr=getenv("SHOWALL"))!=NULL) X`09`09if (sscanf(cptr,"%d",&showall)!=1) showall = 1; X X`09if ((cptr=getenv("LINLEN"))!=NULL) sscanf(cptr,"%d",&llen); X`09else llen = 60; X`09if (llen>=200) llen=200-1; X`09markx=0; X`09if ((cptr=getenv("MARKX"))==NULL) markx=0; X`09else sscanf(cptr,"%d",&markx); X X`09if ((cptr=getenv("LIBTYPE"))!=NULL) sscanf(cptr,"%d",&deftype); X`09if (deftype<0 `7C`7C deftype>BINARYGB) deftype= 0; X X`09while ((copt=getopt(argc,argv,"Qqab:d:l:m:nr:s:w:3x:"))!=EOF) X`09`09switch(copt) `7B X`09`09`09case 'q': X`09`09`09case 'Q': outtty=0; break; X`09`09`09case 'a': showall=1; break; X`09`09`09case 'b': sscanf(optarg,"%d",&mshow); X`09`09`09`09`09if (mshow<5) mshow=20; X`09`09`09`09`09break; X`09`09`09case 'd': sscanf(optarg,"%d",&ashow); X`09`09`09 `09`09if (ashow<0) ashow=20; X`09`09`09 `09`09break; X`09`09`09case 'l': strncpy(flstr,optarg,sizeof(flstr)); X`09`09`09`09break; X`09`09`09case 'm': sscanf(optarg,"%d",&markx); break; X`09`09`09case 'n': dnaseq=1; X`09`09`09 sascii = nascii; X`09`09`09 sq = nt; X`09`09`09 nsq = nnt; X`09`09`09 hsq = hnt; X`09`09`09 pam = npam; X`09`09`09 strcpy(sqnam,"nt"); X`09`09`09 strcpy(sqtype,"DNA"); X`09`09`09 resetp(dnaseq); X`09`09`09 break; X`09`09`09case 's': strncpy(smstr,optarg,sizeof(smstr)); X`09`09`09 smptr = smstr; X`09`09`09 if (initpam(smptr)) `7B X`09`09`09 dnaseq= -1; X`09`09`09 ldnaseq = (sqtype`5B0`5D=='D')?1:0; X`09`09`09 `7D X`09`09`09 else smptr="\0"; X`09`09`09 break; X X`09`09`09case 'r': dataflg=1;`20 X`09`09`09`09strncpy(tmpfname,optarg,sizeof(tmpfname)); X`09`09`09`09break; X`09`09`09case 'w': sscanf(optarg,"%d",&llen); break; X`09`09 case 'x': sscanf(optarg,"%ld %ld",&sq0off,&sq1off); X`09`09`09 break; X#ifdef TFASTA X`09`09`09case '3': nframe=3; break; X#else X`09`09`09case '3': X#endif X`09`09`09default : fprintf(stderr," illegal option -%c\n",copt); X`09`09`09`7D X X`09optind--; X X`09if (dnaseq>=0) `7B X`09`09if ((smptr=getenv("SMATRIX"))!=NULL && initpam(smptr)) `7B X`09`09`09dnaseq = -1; X`09`09`09ldnaseq = (sqtype`5B0`5D=='D')?1:0; X`09`09`09`7D X`09`09else X`09`09`09smptr="\0"; X`09`09`7D X X`09if (strlen(smptr)>0) fprintf(stderr," using matrix file %s\n",smptr); X`09`7D X Xresetp(dnaseq) X`09int dnaseq; X`7B X`09if (dnaseq==1) `7B X`09`09histint=4; X`09`09bestscale=80; X`09`09bkfact=5; X`09`09scfact=1; X`09`09bktup=6; X`09`09ktmax=6; X`09`09bestmax=80; X`09`09bestoff=45; X`09`09pam = npam; X`09`09ldnaseq=1; X`09`09if (pamfact>=0) pamfact = 0; X`09`09`7D X`09`7D X Xinitparm() X`7B X`09char *getenv(), *cptr; X`09int itemp, btemp; X X`09btemp = 2*bestoff/3 + n0/bestscale; X`09if (btemp>bestmax) btemp = bestmax; X`09if (btemp > 3*n0) btemp = 3*shscore(aa0,n0)/5; X X`09bigscore = btemp + 2*bestoff; X`09bestfull = 0; X`09`7D X X/* this is the main loop. First zero the diagonal arrays, X then go through the sequence ktup at a time updating the X diagonals appropriately. Finally, scan the diagonals, X looking for the max score, and use the pam matrix X*/ X Xdhash() X`7B X int nd,ndo;`09`09 /* diagonal array size */ X int scor; X`09int im, ib, nsave; X`09int cmps();`09`09`09/* comparison routine for ksort */ X`09char *aa1ptr; X#ifdef TFASTA X`09int n10, i; X#endif X`09int itt,lcont, ocont, loff;`09/* lcont is returned by getlib to X`09`09`09`09`09indicate there is more sequence X`09`09`09`09`09remaining. ocont is the previous X`09`09`09`09`09value of lcont, for going back later. X`09`09`09`09`09loff corrects maxn for the modified X`09`09`09`09`09size of aa1 for continued sequences X`09`09`09`09`09*/ X/* X`09these initializations have been added to deal with reading X`09sequences in chunks X*/ X X#ifndef TFASTA X`09aa1ptr=aa1; X#else X`09aa1ptr=aa10; X#endif X`09lcont=0; X`09ocont=0; X`09loff = 0; X#ifndef TFASTA X while ((n1=GETLIB(aa1ptr,maxn-loff,libstr,&lmark,&lcont))>0) `7B X`09`09nlib++; X`09`09ntt += n1; X`09`09if (n1==1) `7B X`09`09`09if (igncnt++ <10) X`09`09`09`09fprintf(stderr,"Ignoring: %s\n",libstr); X`09`09`09goto loop; X`09`09`7D X`09`09if (aa1!=aa1ptr) `7Bn1 += n0; nlib--;`7D X#else X`09maxt = maxn-loff-3; maxt -= maxt%3; maxt++; X while ((n10=GETLIB(aa1ptr,maxt,libstr,&lmark,&lcont))>0) `7B X`09`09nlib++; X`09`09ntt += n10; X`09`09if (n10==1 `7C`7C n10 < 3*ktup) `7B X`09`09`09if (igncnt++ <10) X`09`09`09`09fprintf(stderr,"Ignoring: %s\n",libstr); X`09`09`09goto loop; X`09`09 `7D X`09`09if (aa10!=aa1ptr) `7Bn10 += 3*n0; nlib--;`7D X#endif X X#ifdef TFASTA X`09 for (itt=0; itt bestcut) `7B X`09`09if (nbest >= MAXBEST) `7B X`09`09 `09bestfull = nbest-MAXBEST/4; X`09`09 select(bestfull-1,nbest); X`09`09`09bestcut = bptr`5Bbestfull-1`5D->score; X`09`09`09nbest = bestfull; X`09`09`09`7D X`09`09 bestptr = bptr`5Bnbest`5D; X`09`09 bestptr->score = scor; X`09`09 bestptr->lseek = lmark; X`09`09 bestptr->cont = ocont; X`09`09 bestptr->lib = libfn; X`09`09 bestptr->frame = itt; X `09`09 if (dataflg) X`09`09`09fprintf(tmpfd,"%-10s %4d %4d %8ld\n", X`09`09`09 libstr,sfnum,scor,bestptr->lseek); X`09`09 nbest++; X`09`09`7D X X#ifdef TFASTA X`09`7D X#endif X Xloop: X`09 if (lcont) `7B X#ifndef TFASTA X`09`09 loff = n0; X`09`09 memcpy(aa1,&aa1`5Bn1-n0`5D,n0); X`09`09 aa1ptr= &aa1`5Bloff`5D; X#else X `09`09 loff = 3*n0; X `09`09 memcpy(aa10,&aa10`5Bn10-loff`5D,loff); X `09`09 aa1ptr= &aa10`5Bloff`5D; X`09`09 maxt = maxn-loff-3; maxt -= maxt%3; maxt++; X#endif X`09`09 ocont = lcont; X`09`09 `7D X`09 else `7B X`09`09 loff = 0; X#ifndef TFASTA X`09`09 aa1ptr=aa1; X#else X`09`09 aa1ptr = aa10; X`09`09 maxt = maxn-loff-3; maxt -= maxt%3; maxt++; X#endif X`09`09 ocont = lcont; X`09`09 `7D X`09 `7D X`09`7D X Xinitpam2() X`7B X int i, j, k; X `20 X k=0; X for (i=0; i' : ' '; X`09`09pch = (i==0) ? '<' : pch; X`09`09hl = hist`5Bi`5D; X`09`09fprintf(fd,"%c%3d %5d:", X`09`09`09pch,(i 50) hl = 50; X`09`09for (j=0; j1) `7B X`09`09lsd = (lsumsq - (lsum*lsum)/nmean)/(nmean-1); X`09`09lsd = sqrt(lsd); X`09`09`7D X`09else lsd = 0.0; X`09if (nmean>0) `7Blmean = lsum/nmean;`7D X`09else lmean = 0.0; X`09fprintf(fd, X`09 "%7ld residues in %5ld sequences\n",ntt,nlib); X`09fprintf(fd," statistics exclude scores greater than %d\n",bigscore); X`09fprintf(fd," mean opt score: %5.1f (%.2f)\n",lmean,lsd); X`09fprintf(fd," %4d scores better than %d saved\n",nbest,bestcut); X X`09if (dataflg) `7B X`09fprintf(tmpfd,"; statistics exclude scores greater than: %3d\n",bigscore) V; X`09fprintf(tmpfd,"; mean opt score: %5.1f (%.2f)\n",lmean,lsd); X `7D X`09fprintf(fd," scan time: "); ptime(fd,tscan-tstart); fprintf(fd,"\n"); X`09fflush(fd); X`09`7D X Xaddhist(score) X`09int score; X`7B X`09double tmp; X`09if (score < bigscore) `7B X`09`09tmp = (double)score; X`09`09lsum += tmp; X`09`09lsumsq += tmp*tmp; X`09`09nmean++; X`09`09`7D X`09score = (score-1)/histint; X`09if (score < 0) score=0; X`09else if (score >= MAXHIST) score = MAXHIST-1; X`09hist`5Bscore`5D++; X`09`7D X Xshowalign(nshow) X`09int nshow; X`7B X`09int ib, istart, istop; X`09char bline`5B120`5D, *bp, *strchr(); X`09int lcont, ccont, loff; X`09char *aa1ptr; X`09int olib; X#ifdef TFASTA X`09int n10; X#endif X X`09olib = -1; X X`09istart = 0; istop = min(min(nbest,ashow),nshow); X`09for (ib=istart; iblib!=olib) `7B X`09`09`09closelib(); X`09`09`09if (openlib(lbnames`5Bbbp->lib`5D,"\0")<=0) exit(0); X`09`09`09olib=bbp->lib; X`09`09`09`7D X X`09`09RANLIB(bline,55,bbp->lseek); X`09`09if (strlen(bline)==0) `7B X`09`09`09bline`5B0`5D='>'; X`09`09`09strncpy(&bline`5B1`5D,lbnames`5Bbbp->lib`5D,55); X`09`09`09`7D X#ifndef TFASTA X`09 aa1ptr=aa1; X#else X`09 aa1ptr = aa10; X#endif X`09 loff=0; loffset = 0l; lcont=0; X`09 for (ccont=0; ccont<=bbp->cont; ccont++) `7B X#ifndef TFASTA X`09`09n1=GETLIB(aa1ptr,maxn-loff,libstr,&lmark,&lcont); X`09`09if (aa1ptr!=aa1) n1 += n0; X#else X`09`09maxt = maxn-loff-3; maxt -= maxt%3; maxt++; X`09`09n10 = GETLIB(aa1ptr,maxt,libstr,&lmark,&lcont); X`09`09if (aa1ptr!=aa10) n10 += 3*n0; X#endif X`09`09if (lcont>bbp->cont) break; X#ifndef TFASTA X`09`09if (lcont) `7B X`09`09 loff = n0; X`09`09 memcpy(aa1,&aa1`5Bn1-n0`5D,n0); X`09`09 aa1ptr= &aa1`5Bloff`5D; X`09`09 loffset += n1-n0; X`09`09 `7D X`09`09else `7B X`09`09 loff = 0; X`09`09 aa1ptr=aa1; X`09`09 `7D X#else X`09`09if (lcont) `7B X`09`09 loff = 3*n0; X`09`09 memcpy(aa10,&aa10`5Bn10-loff`5D,loff); X`09`09 aa1ptr= &aa10`5Bloff`5D; X`09`09 loffset += n10-loff; X`09`09 maxt = maxn-loff-3; maxt -= maxt%3; maxt++; X`09`09 `7D X`09`09else `7B X`09`09 loff = 0; X`09`09 aa1ptr = aa10; X`09`09 maxt = maxn-loff-3; maxt -= maxt%3; maxt++; X`09`09 `7D X#endif X`09`09`7D X#ifdef TFASTA X`09`09n1 = aatran(aa10,aa1,n10,bbp->frame); X`09`09loffset /= 3; X#endif X`09`09fprintf(outfd,"%-55s",bline); X#ifndef TFASTA X`09`09fprintf(outfd,"%4d\n",bbp->score); X#else X`09`09fprintf(outfd,"(%1d) %4d\n",bbp->frame+1,bbp->score); X#endif X`09`09strncpy(name1,bline,6); X`09`09name1`5B6`5D='\0'; X`09`09if ((bp = strchr(name1,' '))!=NULL) *bp = '\0'; X`09`09smark`5B2`5D= -BIGNUM; X`09`09smark`5B3`5D= -BIGNUM; X`09`09smark`5B0`5D= -BIGNUM; X`09`09smark`5B1`5D= -BIGNUM; X`09`09smatch(aa0,n0,aa1,n1,TRUE); X`09`09fprintf(outfd,"\n"); X`09`09fflush(outfd); X`09`09`7D X`09`7D X X#ifdef FAR_PTR X#ifdef M_XENIX X#include X#else X#ifdef TURBOC X#define FMALLOC farmalloc X#define MTYPE long X#define FFREE farfree X#else X#define FMALLOC _fmalloc X#define MTYPE unsigned X#define FFREE _ffree X#endif X#endif X#endif X Xinitbest(nbest)`09`09/* allocate arrays for best sort */ X`09int nbest; X`7B X#ifndef FAR_PTR X`09char *calloc(); X`09if ((best=(struct beststr *)calloc(nbest,sizeof(struct beststr))) X`09`09== NULL) `7Bfprintf(stderr,"cannot allocate best struct\n"); exit(1);` V7D X`09if ((bptr=(struct beststr **)calloc(nbest,sizeof(struct beststr *))) X`09`09== NULL) `7Bfprintf(stderr,"cannot allocate bptr\n"); exit(1);`7D X#else`09/* FAR_PTR */ X#ifndef M_XENIX X`09char far * FMALLOC(); X`09if ((best=(struct beststr far *) X`09 FMALLOC((MTYPE)(nbest*sizeof(struct beststr)))) X`09`09== (char far *)0) `7B X`09`09fprintf(stderr,"cannot allocate best struct\n"); exit(1);`7D X`09if ((bptr=(struct beststr far * far *) X`09 FMALLOC((MTYPE)(nbest*sizeof(struct beststr far *)))) X`09`09== (char far * far *)0) `7Bfprintf(stderr,"cannot allocate bptr\n"); e Vxit(1);`7D X#else`09/* M_XENIX */`09`09 X`09char far * brkctl(); X`09if ((best=(struct beststr far *) X`09 brkctl(BR_NEWSEG,(long)((unsigned)nbest*(unsigned)sizeof(struct bests Vtr)))) X`09`09== (struct beststr far *)-1) `7Bfprintf(stderr,"cannot allocate best s Vtruct\n"); exit(1);`7D X`09if ((bptr=(struct beststr far * far *) X`09 brkctl(BR_NEWSEG,(long)(nbest*sizeof(struct beststr far *)))) X`09`09== (struct beststr far * far *)-1) `7Bfprintf(stderr,"cannot allocate V bptr\n"); exit(1);`7D X#endif`09/* M_XENIX */ X#endif`09/* FAR_PTR */ X`09`7D X Xfreebest() X`7B X#ifndef BIGMEM X#ifndef FAR_PTR X`09free(bptr); X`09free(best); X#else`09/* FAR_PTR */ X#ifndef M_XENIX X`09FFREE(bptr); X`09FFREE(best); X#else`09/* M_XENIX */ X`09brkctl(BR_ARGSEG,(long)(-(unsigned)nbest*(unsigned)sizeof(struct beststr V far *)),bptr); X`09brkctl(BR_IMPSEG,0L,bptr); X`09brkctl(BR_ARGSEG,(long)(-nbest*sizeof(struct beststr)),best); X`09brkctl(BR_IMPSEG,0L,best); X#endif`09/* M_XENIX */ X#endif`09/* FAR_PTR */ X#endif`09/* BIGMEM */ X`09`7D X Xgetbest() X`7B X`09`7D X Xshowbest() X`7B X`09int ib, istart, istop; X`09char bline`5B120`5D; X`09int ntmp; X`09int lcont, ccont, loff; X`09char *aa1ptr; X`09int olib; X`09int hcutoff; X#ifdef TFASTA X`09int n10; X#endif X X`09if (nshow <= 0) return; X X`09hcutoff = 6*(MAXHIST-1)*histint; X`09hcutoff /= 10; X`09olib = -1; X X`09nshow = min(nshow,nbest); X`09mshow = min(mshow,nbest); X`09if (outtty) `7B X`09`09printf(" How many scores would you like to see? `5B%d`5D ",nshow); X`09`09fflush(stdout); X`09`09if (fgets(rline,20,stdin)==NULL) exit(0); X`09`09if (rline`5B0`5D!='\n' && rline`5B0`5D!=0) sscanf(rline,"%d",&nshow); X`09`09if (nshow<=0) nshow = min(20,nbest); X`09`09`7D X`09else nshow=mshow; X X#ifndef TFASTA X`09fprintf(outfd,"The best scores are:\t\t\t\t opt\n"); X#else X `09fprintf(outfd,"The best scores are:\t\t\t\t\t opt\n"); X#endif X`09if (outfd != stdout) X#ifndef TFASTA X`09 fprintf(stdout,"The best scores are:\t\t\t\t opt\n"); X#else X`09 fprintf(stdout,"The best scores are:\t\t\t\t\t opt\n"); X#endif X`09istart = 0; Xl1:`09istop = min(nbest,nshow); X`09for (ib=istart; iblib!=olib) `7B X`09`09`09closelib(); X`09`09`09if (openlib(lbnames`5Bbbp->lib`5D,"\0")<=0) exit(0); X`09`09`09olib=bbp->lib; X`09`09`09`7D X X`09`09RANLIB(bline,60,bbp->lseek); X`09`09bline`5B54`5D='\0'; X X#ifndef TFASTA X`09 aa1ptr=aa1; X#else X`09 aa1ptr = aa10; X#endif X`09 loff=0; lcont=0; X`09 for (ccont=0; ccont <= bbp->cont; ccont++) `7B X#ifndef TFASTA X`09`09n1=GETLIB(aa1ptr,maxn-loff,libstr,&lmark,&lcont); X`09`09if (aa1ptr!=aa1) n1 += n0; X#else X`09`09maxt = maxn-loff-3; maxt -= maxt%3; maxt++; X`09`09n10=GETLIB(aa1ptr,maxt,libstr,&lmark,&lcont); X`09`09if (aa1ptr!=aa10) n10 += 3*n0; X#endif X`09`09if (lcont>bbp->cont) break; X#ifndef TFASTA X`09`09if (lcont) `7B X`09`09 loff = n0; X`09`09 memcpy(aa1,&aa1`5Bn1-n0`5D,n0); X`09`09 aa1ptr= &aa1`5Bloff`5D; X`09`09 `7D X`09`09else `7B X`09`09 loff = 0; X`09`09 aa1ptr=aa1; X`09`09 `7D X#else X`09`09if (lcont) `7B X`09`09 loff = 3*n0; X`09`09 memcpy(aa10,&aa10`5Bn10-loff`5D,loff); X`09`09 aa1ptr= &aa10`5Bloff`5D; X`09`09 maxt = maxn-loff-3; maxt -= maxt%3; maxt++; X`09`09 `7D X`09`09else `7B X`09`09 aa1ptr=aa10; X`09`09 loff = 0; X`09`09 maxt = maxn-loff-3; maxt -= maxt%3; maxt++; X`09`09 `7D X#endif X`09`09`7D X X#ifdef TFASTA X`09`09n1=aatran(aa10,aa1,n10,bbp->frame); X#endif X X`09`09fprintf(outfd,"%-55s",bline); X#ifndef TFASTA X`09`09fprintf(outfd,"%4d\n",bbp->score); X#else X `09`09fprintf(outfd,"(%1d) %4d\n",bbp->frame+1,bbp->score); X#endif X X`09`09if (outfd!=stdout) `7B X`09`09 fprintf(stdout,"%-55s",bline); X#ifndef TFASTA X`09`09 fprintf(stdout,"%4d\n",bbp->score); X#else X `09`09fprintf(stdout,"(%1d) %4d\n",bbp->frame+1,bbp->score); X#endif X`09`09 `7D X`09`09`7D X X`09fflush(outfd); if (outfd!=stdout) fflush(stdout); X X`09if (outtty) `7B X`09`09printf(" More scores? `5B0`5D "); X`09`09fflush(stdout); X`09`09if (fgets(rline,20,stdin)==NULL) exit(0); X`09`09ntmp = 0; X`09`09if (rline`5B0`5D!='\n' && rline`5B0`5D!=0) sscanf(rline,"%d",&ntmp); X`09`09if (ntmp<=0) ntmp = 0; X`09`09if (ntmp>0) `7B X`09`09`09istart = istop; X`09`09`09nshow += ntmp; X`09`09`09mshow += ntmp; X`09`09`09goto l1; X`09`09`09`7D X`09`09`7D X`09else if (bbp->score > (2*hcutoff)) `7B X`09`09istart=istop; X`09`09nshow += 10; X`09`09if (istart l ) `7B X i = l-1; X j = r; X v = bptr`5Br`5D->score; X do `7B X while (bptr`5B++i`5D->score > v ) ; X while (bptr`5B--j`5D->score < v ) ; X tmptr = bptr`5Bi`5D; bptr`5Bi`5D=bptr`5Bj`5D; bptr`5Bj`5D=tmptr; X `7D while (j > i); X bptr`5Bj`5D=bptr`5Bi`5D; bptr`5Bi`5D=bptr`5Br`5D; bptr`5Br`5D=tmptr; X if (i>=k) r = i-1; X if (i<=k) l = i+1; X `7D X`7D X Xsortbest() X`7B X#ifndef FAR_PTR X`09int cmps(), cmp1(), cmpa(); X`09ksort(bptr,nbest,cmps); X#else X`09int fcmps(), fcmp1(), fcmpa(); X`09fksort(bptr,nbest,fcmps); X#endif X`09`7D X Xcmps(ptr1,ptr2) X`09struct beststr *ptr1, *ptr2; X`7B X`09if (ptr1->score < ptr2->score) return (1); X`09else if (ptr1->score > ptr2->score) return (-1); X`09else return (0); X`09`7D X X#ifdef FAR_PTR Xfcmps(ptr1,ptr2) X`09struct beststr far * ptr1, far * ptr2; X`7B X`09if (ptr1->score < ptr2->score) return (1); X`09else if (ptr1->score > ptr2->score) return (-1); X`09else return (0); X`09`7D X#endif X Xkssort(v,n) X`09struct beststr *v`5B`5D; int n; X`7B X`09int gap, i, j; X`09struct beststr *tmp; X`09 X`09for (gap=n/2; gap>0; gap/=2) X`09`09for (i=gap; i=0; j -= gap) `7B X`09`09`09`09if (v`5Bj`5D->score >= v`5Bj+gap`5D->score) X`09`09`09`09`09break; X`09`09`09`09tmp = v`5Bj`5D; v`5Bj`5D=v`5Bj+gap`5D; v`5Bj+gap`5D=tmp; X`09`09`09`09`7D X`09`7D X Xksort(v,n,comp) X`09char *v`5B`5D; int n, (*comp)(); X`7B X`09int gap, i, j; X`09char *tmp; X`09 X`09for (gap=n/2; gap>0; gap/=2) X`09`09for (i=gap; i=0; j -= gap) `7B X`09`09`09`09if ((*comp)(v`5Bj`5D,v`5Bj+gap`5D) <=0) X`09`09`09`09`09break; X`09`09`09`09tmp = v`5Bj`5D; v`5Bj`5D=v`5Bj+gap`5D; v`5Bj+gap`5D=tmp; X`09`09`09`09`7D X`09`7D X X#ifdef FAR_PTR Xfksort(v,n,comp) X`09char far * far *v; X`09int n, (*comp)(); X`7B X`09int gap, i, j; X`09char far *tmp; X`09 X`09for (gap=n/2; gap>0; gap/=2) X`09`09for (i=gap; i=0; j -= gap) `7B X`09`09`09`09if ((*comp)(v`5Bj`5D,v`5Bj+gap`5D) <=0) X`09`09`09`09`09break; X`09`09`09`09tmp = v`5Bj`5D; v`5Bj`5D=v`5Bj+gap`5D; v`5Bj+gap`5D=tmp; X`09`09`09`09`7D X`09`7D X X#endif X Xgetlnames(tname)`09`09/* read in the library names */ X`09char *tname; X`7B X`09int i; X`09char *calloc(), *bp, *strchr(); X`09char lline`5B120`5D; X`09FILE *tptr; X X`09if (*tname != '@') `7Baddfile(tname,"\0"); return;`7D X`09else tname++; X X`09if ((bp=strchr(tname,' '))!=NULL) `7B X`09`09 *bp='\0'; X#ifndef LFASTA X`09`09 sscanf(bp+1,"%d",&deftype); X`09`09 if (deftype<0 `7C`7C deftype>BINARYGB) `7B X`09`09`09fprintf(stderr," default type error %d\n",deftype); X`09`09`09deftype=0; X`09`09 `7D X#endif`09`09 X`09`09 `7D X X`09if ((tptr=fopen(tname,"r"))==NULL) `7B X`09`09fprintf(stderr," could not open file of names: %s\n",tname); X`09`09return 0; X`09`09`7D X X`09while (fgets(lline,sizeof(lline),tptr)!=NULL) `7B X`09`09if (lline`5B0`5D==';') continue; X`09`09if ((bp=strchr(lline,'\n'))!=NULL) *bp='\0'; X`09`09if (lline`5B0`5D=='>') `7B X`09`09`09strncpy(iname,&lline`5B1`5D,sizeof(iname)); X`09`09`09iname`5Bsizeof(iname)-1`5D='\0'; X#ifndef LFASTA X`09`09`09if (deftype==0) deftype=BINARYGB; X#endif X`09`09`09gbflag=1; X`09`09 `7D X`09`09else if (lline`5B0`5D=='<') `7B X`09`09 if (ldname`5B0`5D!='\0' && strcmp(ldname,lline+1)!=0)`20 X`09`09 fprintf(stderr, X`09`09`09 " changing default directory name from %s to %s\n", X`09`09`09 ldname,lline+1); X`09`09`09strncpy(ldname,&lline`5B1`5D,sizeof(ldname)); X`09`09`09ldname`5Bsizeof(iname)-1`5D='\0'; X`09`09`09libenv=ldname; X`09`09`09`7D X`09`09else addfile(lline,libenv); X`09 `7D X`09fclose(tptr); X`09return 1; X`7D X X/*`09modified Dec 13, 1989 requires different FASTLIBS */ X X#define MAXCHFIL 80 X#define MAXCH 20 X Xlibchoice(lname,nl,aaenv) X`09char *lname, *aaenv; X`09int nl; X`7B X`09char tolower(); X`09FILE *fch; X`09char line`5B120`5D, *bp, *strchr(); X`09char *chstr`5BMAXCH`5D,*chfile`5BMAXCH`5D; X`09char *calloc(), *chtmp, *charr; X`09int i,j,k,chlen; X X`09charr = NULL; X`09if (strlen(flstr)>0) `7B X`09`09chlen = MAXCH*MAXCHFIL; X`09`09if ((chtmp=charr=calloc(chlen,sizeof(char)))==NULL) `7B X`09`09`09fprintf(stderr,"cannot allocate choice file array\n"); X`09`09`09goto l1; X`09`09`09`7D X`09`09chlen--; X`09`09if ((fch=fopen(flstr,"r"))==NULL) `7B X`09`09`09fprintf(stderr," cannot open choice file: %s\n",flstr); X`09`09`09goto l1; X`09`09`09`7D X`09`09fprintf(stderr,"\n Choose sequence library:\n\n"); X X`09`09for (i=j=0; j<20; i++) `7B X`09`09`09if (fgets(line,sizeof(line),fch)==NULL) break; X`09`09`09if (line`5B0`5D==';') continue; X`09`09`09if ((bp=strchr(line,'\n'))!=NULL) *bp='\0'; X`09`09`09if ((bp=strchr(line,'$'))==NULL) continue; X`09`09`09*bp++='\0'; X`09`09`09if ((*bp++ -'0')!=ldnaseq) continue; X`09`09`09if ((k=strlen(line))>chlen) break; X`09`09`09strncpy(chstr`5Bj`5D=chtmp,line,chlen); X`09`09`09chtmp += k+1; chlen -= k+1; X`09`09`09if ((k=strlen(bp))>chlen) break; X`09`09`09strncpy(chfile`5Bj`5D=chtmp,bp,chlen); X`09`09`09chtmp += k+1; chlen -= k+1; X`09`09`09fprintf(stderr," %c: %s\n",*chfile`5Bj++`5D,line); X`09`09`09`7D Xl2: fprintf(stderr,"\n Enter library filename (e.g. %s), letter (e.g. P)\n" V, X`09`09`09(ldnaseq==0)? "prot.lib" : "dna.lib"); X fprintf(stderr," or a %% followed by a list of letters (e.g. %%PN): "); X`09`09fflush(stderr); X`09`09if (fgets(line,sizeof(line),stdin)==NULL) exit(0); X`09`09if ((bp=strchr(line,'\n'))!=NULL) *bp='\0'; X`09`09if (strlen(line)==0) goto l2; X`09`09strncpy(lname,line,nl); X`09`09`7D X `09else `7B Xl1:`09`09fprintf(stderr," library file name `5B%s`5D: ",aaenv); X`09`09fflush(stderr); X`09`09if (fgets(line,sizeof(line),stdin)==NULL) exit(0); X`09`09if ((bp=strchr(line,'\n'))!=NULL) *bp='\0'; X`09`09if (strlen(line)>0) strncpy(lname,line,nl); X`09`09else strncpy(lname,aaenv,nl); X`09`09`7D X`09if (charr!=NULL) `7B X`09`09fclose(fch); X`09`09free(charr); X`09`09`7D X`09`7D X X Xlibselect(lname) X`09char *lname; X`7B X`09char tolower(); X`09char line`5B120`5D, *bp, *strchr(), *ulindex(); X`09FILE *fch; X`09int i; X X`09if (strlen(lname)>1 && *lname != '%') getlnames(lname); X`09else `7B X`09 if (*lname=='%') lname++; X`09 if (strlen(flstr)>0) `7B X`09 if ((fch=fopen(flstr,"r"))==NULL) `7B X`09 fprintf(stderr," cannot open choice file: %s\n",flstr); X`09 return; X`09 `7D X`09 `7D X`09 else addfile(lname,"\0"); X X`09 while (fgets(line,sizeof(line),fch)!=NULL) `7B`20 X`09 if (line`5B0`5D==';') continue; X`09 if ((bp=strchr(line,'\n'))!=NULL) *bp='\0'; X`09 if ((bp=strchr(line,'$'))==NULL) continue; X`09 *bp++='\0'; X`09 if ((*bp++ -'0')!=ldnaseq) continue; X`09 if (ulindex(lname,*bp)!=NULL) `7B X`09 strncpy(ltitle,line,sizeof(ltitle)); X`09 getlnames(bp+1); X`09 `7D X`09 `7D X`09 fclose(fch); X`09`7D X `7D X Xchar *lbptr; Xint nnsize; X Xaddfile(fname,env) X char *fname, *env; X`7B X char tname`5B120`5D; X char *calloc(); X int len, lenv, i; X X/* allocate some space for file names */ X if (lbnarr==NULL) `7B X if ((lbnarr=calloc(MAXLF*MAXLN,sizeof(char)))==NULL) `7B X`09fprintf(stderr," could not allocate name table\n"); X`09exit(1); X`09`7D X X nln = 0; X nnsize = MAXLF*MAXLN; X lbptr = lbnarr; X `7D X X lenv = strlen(env)+1; X len=strlen(fname)+1+lenv; X if (nnsize > sizeof(tname)) `7B X if (lenv > 1 && *fname != '#') `7B X strncpy(tname,env,sizeof(tname)); X#ifdef UNIX X strcat(tname,"/"); X#endif X `7D X else tname`5B0`5D='\0'; X strncat(tname,fname,sizeof(tname)-strlen(tname)-1); X len=strlen(tname)+1; X strncpy(lbptr,tname,nnsize); X `7D X else fprintf(stderr,"no more space for filenames: %s ignored\n",fname); X if (nln< MAXLF) lbnames`5Bnln++`5D=lbptr; X else fprintf(stderr," no more file name slots: %s ignored\n",lbptr); X lbptr += len; X nnsize -= len; X`7D X Xchar tolower(a) X char a; X`7B X if (a>='A' && a<='Z') return a + ('a'-'A'); X else return a; X`7D X Xchar *ulindex(str,chr) X char *str, chr; X`7B X char c; X`20 X c = tolower(chr); X X while (*str != '\0' && tolower(*str) !=c ) str++; X if (*str=='\0') return NULL; X else return str; X`7D $ CALL UNPACK SSEARCH.C;1 167948375 $ create 'f' X/* a program for evaluating the hydrophobicity of sequence segments */ X X#include X#include "upam.gbl" X#define XTERNAL X#include "uascii.gbl" X Xchar code`5B`5D = "RKDBNSEHZQTGAPVYCMILWFX"; Xfloat factor`5B`5D = `7B0.0,0.6,1.0,1.0,1.0,3.6,1.0,1.3,1.0,1.0,3.8,4.1, X`096.3,2.9,8.7,3.2,7.0,6.4,9.0,8.2,3.6,7.2,4.5`7D; X X#define MAXSEQ 2000 Xchar sequence`5BMAXSEQ`5D; X Xint dnaseq = -1; Xextern int *sascii, aascii`5B`5D; X Xfloat value`5BMAXSEQ`5D; X#define MAXT 60 Xchar title`5BMAXT`5D; Xchar lstr`5B120`5D; X Xfloat fx, fy; X#define SX(x) (int)(fx*(float)(x)) X#define SY(y) (int)(fy*(float)(y)) X#define FSY(y) (int)(fy*(y)) X Xmain (argc,argv) X`09int argc; char *argv`5B`5D; X`7B X`09int i,n0,n1,k, wind, mid; X`09int x0, x1, y0, y1, cc=0; X`09float total; X`09char residue; X X`09if (argc < 2) `7B X`09`09printf(" usage - grease filename `5Bwind`5D\n"); X`09`09exit(1); X`09`09`7D X X`09sascii = aascii; X`09if ((n0=getseq(argv`5B1`5D,sequence,MAXSEQ,&dnaseq))<=0) `7B X`09`09fprintf(stderr," could not read %s\n",argv`5B1`5D); X`09`09exit(1); X`09`09`7D X X`09gettitle(argv`5B1`5D,title,MAXT); X X`09if (argc > 2) `7B X`09`09sscanf(argv`5B2`5D,"%d",&wind); X`09`09if (wind < 2 `7C`7C wind > 20) wind = 7; X`09`09`7D X`09else wind = 7; X`09mid = wind/2; X X`09x1 = n0; X`09n1 = wind*9; X`09y1 = 3*n1/2; X X`09x0 = -x1/10; X`09y0 = -n1/2; X`09fx = 1000./(float)x1; X`09fy = 1000./(float)y1; X X`09openpl(); X`09space(SX(x0),SY(y0),SX(x1-x0),SY(y1)); X X`09move(0,0); X`09cont(0,SY(n1)); X`09cont(SX(n0),SY(n1)); X`09cont(SX(n0),0); X`09cont(0,0); X`09move(0,SY(n1/2)); X`09cont(SX(n0),SY(n1/2)); X`09xaxis(n0); X`09move(-60,SY(n1)-10); X`09drawstr("CH3"); X`09move(-60,-20); X`09drawstr("H2O"); X X`09for (i = 0; i X#ifndef MSDOS X#define TIMES X#ifndef VMS X#include X#include X#else Xstruct tms `7B long tms_utime, tms_stime, tms_cutime, tms_cstime; `7D X#endif /* VMS */ X#else /* MSDOS */ X#undef TIMES X#endif X X#ifndef HZ X#define HZ 100 X#endif X Xlong stime()`09`09/* gets the time as an int */ X`7B X#ifndef TIMES X`09long time(), tt; X`09return time(&tt)*HZ; X#else X`09struct tms tt; X`09times(&tt); X`09return (long)tt.tms_utime; X#endif X`09`7D X Xptime(fd,time) X`09FILE *fd; long time; X`7B X`09long dtime, mtime, htime, stime; X X`09stime = HZ; X`09mtime = stime*60; X`09htime = mtime*60; X`09dtime = htime*24; X X`09if (time < 0) time = time + dtime; X`09fprintf(fd,"%2ld:%02ld:%02ld", X`09`09time/htime,(time%htime)/mtime,(time%mtime)/stime); X`09`7D X $ CALL UNPACK TIME.C;1 963006501 $ create 'f' X/*`09dispn.c`09associated subroutines for matching sequences */ X/* `09modified for Tek4014 terminal, not 4027 */ X X#include X X#define XTERNAL X#include "upam.gbl" X X#define TRUE 1 X#define FALSE 0 Xextern FILE *outfd; X Xextern int iscore, gscore; Xextern char name0`5B`5D, ltitle`5B`5D; X/*extern int colflg;*/ X Xint linbw`5B`5D=`7B0,4,2,1,3`7D; Xint lincol`5B`5D=`7B0,1,2,3,4`7D; Xchar linchar`5B`5D=`7B96,'a','b','c','d','e','f','g'`7D; Xint *linarr; Xint nlinarr=5; X Xextern char lvstr`5B`5D; X Xint plinval`5B3`5D=`7B200,100,50`7D; Xint dlinval`5B3`5D=`7B400,200,100`7D; Xint *linval; X Xextern int dnaseq; X Xextern int smin0,smin1; Xextern long loffset; X X#define DIAG 1 X#define INS0 2 X#define INS1 4 X Xlong pminx, pmaxx, pminy, pmaxy; Xint max_x=1000, max_y=770; X Xdouble fxscal, fyscal, fxoff, fyoff; X#define SX(x) (int)((double)(x)*fxscal+fxoff) X#define SY(y) (int)((double)(y)*fyscal+fyoff) X Xdiscons(seqc0, seqc1, nc) X`09char *seqc0, *seqc1; X`09int nc; X`7B X`09long x0, x1, y0, y1; X`09int direct, ii; X X`09y1 = y0 = smin0; X`09x1 = x0 = smin1 + loffset; X X`09direct = DIAG; X`09 X`09move(SX(x0),SY(y0)); X X`09for (ii=0; ii pmaxy) printf("\r* n0 * %3ld %3ld\n",y1,pmaxy); X`09if (x1 > pmaxx) printf("\r* n1 * %3ld %3ld\n",x1,pmaxx); X`09`7D X Xaancpy(to,from,count) X`09char *to, *from; X`09int count; X`7B X`09char *tp; X`09tp=to; X`09while (count--&& *from>=0) `7B X`09`09if (*from='a' && c<='z') return (c-'a'+'A'); X`09return c; X`09`7D X Xmin(arg1, arg2) X`09int arg1, arg2; X`7B X`09return (arg1<=arg2) ? arg1 : arg2; X`09`7D X Xopenplt(n0, n1) X`09long n0, n1; X`7B X`09char *getenv(), *sptr; X X`09if (strlen(lvstr)>0) `7B X`09`09sscanf(lvstr,"%d %d %d",&plinval`5B0`5D,&plinval`5B1`5D,&plinval`5B2`5 VD); X`09`09linval = plinval; X`09`09`7D X`09else if ((sptr=getenv("LINEVAL"))!=NULL && strlen(sptr)>0) `7B X`09`09sscanf(sptr,"%d %d %d",&plinval`5B0`5D,&plinval`5B1`5D,&plinval`5B2`5D V); X`09`09linval = plinval; X`09`09`7D X`09else `7B X`09`09if (dnaseq==1) linval=dlinval; X`09`09else linval=plinval; X`09`09`7D X X`09printf("\033\014\n"); X`09printf("\035");`09`09/* send ESC FF GS */ X X/*`09if (colflg) linarr=lincol; else linarr = linbw; */ X`09linarr = linbw; X X`09pmaxx = n1; X`09pmaxy = n0; X X`09fxscal = (double)(max_x-1)/(double)(n1); X`09fyscal = (double)(max_y-1)/(double)(n0); X X`09if (fxscal > fyscal) fxscal = fyscal; else fyscal = fxscal; X X`09if (fyscal * n0 < (double)max_y/5.0)`20 X`09`09fyscal = (double)(max_y-1)/((double)(n0)*5.0); X X`09fxscal *= 0.9; fxoff = (double)(max_x-1)/11.0; X`09fyscal *= 0.9; fyoff = (double)(max_y-1)/11.0; X X`09linetype(0); X`09move(SX(0),SY(0)); X`09draw(SX(0),SY(n0)); X`09draw(SX(n1),SY(n0)); X`09draw(SX(n1),SY(0)); X`09draw(SX(0),SY(0)); X`09xaxis(n1); X`09yaxis(n0); X`09legend(); X`09`7D X`09 Xdrawdiag(n0,n1) X`09long n0, n1; X`7B X`09linetype(0); X`09move(SX(0),SY(0)); X`09draw(SX(n0),SY(n1)); X`7D X Xint tarr`5B`5D = `7B10,20,50,100,200,500,1000,2000,5000`7D; Xint ntarr = sizeof(tarr); Xxaxis(n) X long n; X`7B X`09int i, jm, tick; X`09long js; X`09char numstr`5B20`5D; X X`09tick = 10; X X`09for (i=0; i%3d",linval`5Bi`5D); X`09`09drawstr(numstr); X`09`09`7D X`09`7D X Xlinetype(type) X`09int type; X`7B X/*`09if (colflg) printf("\r!COL C%1d",type);`09*/ X`09printf("\033%c",linchar`5Blinarr`5Btype`5D`5D); X`09`09`7D X Xcloseplt() X`7B X`09move(0,0); X`09putchar('\r'); X`09`7D X Xopnline(x,y,s) X long x, y; X int s; X`7B X if (s>linval`5B0`5D) linetype(0); X else if (s>linval`5B1`5D) linetype(1); X else if (s>linval`5B2`5D) linetype(2); X else linetype(3); X`7D X Xclsline(x,y,s) X long x, y; X int s; X`7B X`7D X Xmove(x,y) X`09unsigned int x, y; X`7B X`09fputc(0x1d,stdout); X`09fputc(((y&0x3e0)>>5)+0x20,stdout); X`09fputc((y&0x1f)+0x60,stdout); X`09fputc(((x&0x3e0)>>5)+0x20,stdout); X`09fputc((x&0x1f)+0x40,stdout); X`09`7D X Xdraw(x,y) X`09unsigned int x, y; X`7B X`09fputc(((y&0x3e0)>>5)+0x20,stdout); X`09fputc((y&0x1f)+0x60,stdout); X`09fputc(((x&0x3e0)>>5)+0x20,stdout); X`09fputc((x&0x1f)+0x40,stdout); X`09`7D X Xdrawstr(str) X`09char *str; X`7B X `09fputc(0x1f,stdout); X`09fputs(str,stdout); X`09fputc(0x1d,stdout); X`09`7D X X#ifdef VMS Xmemset(str, c, cnt) X`09char *str; int cnt; char c; X`7B X`09while (cnt--) *str++ = c; X`09`7D X#endif X X $ CALL UNPACK TLDISPN.C;1 655885654 $ create 'f' X#include X#include X X#ifdef UNIX Xint tkflag=1; X#else Xint tkflag=0;`09`09/* flag to indicate turboc drivers */ X#endif X Xint max_x, max_y; X Xint lintc`5B`5D=`7BSOLID_LINE,CENTER_LINE,DASHED_LINE,DOTTED_LINE`7D; Xint lintk`5B`5D=`7B0,2,4,1,3`7D; Xint lintkc`5B`5D=`7B0,1,2,3,4`7D; Xchar linchar`5B`5D=`7B96,'a','b','c','d','e','f','g'`7D; X Xfloat fxscal, fyscal, fxoff, fyoff,aratio; X Xint g_driver=DETECT, g_mode; X Xint ErrorCode, palette, MaxColors, MaxX, MaxY; Xint xasp, yasp; X Xopenpl() X`7B X`09char *getenv(), *g_path, *sptr; X`09double ftemp; X X`09if ((sptr=getenv("TEKPLOT"))!=NULL) sscanf(sptr,"%d",&tkflag); X X`09if (!tkflag) `7B X`09 if ((g_path=getenv("BGIDIR"))==NULL) g_path="\0"; X X`09 initgraph(&g_driver,&g_mode,g_path); X`09 ErrorCode = graphresult();`09/* Read result of initialization*/ X`09 if( ErrorCode != grOk )`7B`09/* Error occured during init`09*/ X`09`09printf(" Graphics System Error: %s\n", X`09`09`09grapherrormsg( ErrorCode ) ); X`09`09exit( 1 ); X`09`09`7D X X`09 getaspectratio(&xasp,&yasp); X`09 aratio = (double)xasp/(double)yasp; X`09 MaxX = getmaxx(); X`09 max_x = MaxX*aratio; X`09 max_y = getmaxy(); /* Read size of screen`09*/ X`09 `7D X`09else `7B X`09`09MaxX = 1000; X`09`09max_x = 1000; X`09`09max_y = 770; X`09`09aratio = 1.0; X`09`09`7D X`09linetype(0); X`09`7D X`09 Xlinetype(type) X`09int type; X`7B X`09if (!tkflag) setlinestyle(lintc`5Btype`5D,0,NORM_WIDTH); X`09printf("\033%c",linchar`5Blintk`5Btype`5D`5D); X`09`7D X Xclosepl() X`7B X`09char line`5B10`5D, *str; X`09str = " to continue"; X`09if (!tkflag) `7B X`09`09moveto(MaxX-textwidth(str),max_y-textheight(str)); X`09`09outtext(str); X`09`09fgets(line,sizeof(line),stdin); X`09`09closegraph(); X`09`09`7D X`09else `7B X`09`09fputc(0x1d,stdout); X`09`09fputc(((0&0x3e0)>>5)+0x20,stdout); X`09`09fputc((0&0x1f)+0x60,stdout); X`09`09fputc(((0&0x3e0)>>5)+0x20,stdout); X`09`09fputc((0&0x1f)+0x40,stdout); X`09`09putchar('\r'); X`09`09`7D X`09`7D X Xspace(x0,y0,x1,y1) X`09int x0, x1, y0, y1; X`7B X`09fxoff = (float)x0; X`09fyoff = (float)y0; X`09fxscal = (float)(max_x)/(float)((x1-x0)*aratio); X`09fyscal = (float)(max_y)/(float)(y1-y0); X`09`7D X Xmove(x,y) X`09int x, y; X`7B X`09int xx, yy; X X`09xx = (int)(((float)(x)-fxoff)*fxscal); X`09yy = (int)(((float)(y)-fyoff)*fyscal); X X`09if (!tkflag) moveto(xx,max_y-yy); X`09else `7B X`09`09fputc(0x1d,stdout); X`09`09fputc(((yy&0x3e0)>>5)+0x20,stdout); X`09`09fputc((yy&0x1f)+0x60,stdout); X`09`09fputc(((xx&0x3e0)>>5)+0x20,stdout); X`09`09fputc((xx&0x1f)+0x40,stdout); X`09`09`7D X`09`7D X Xcont(x,y) X`09int x, y; X`7B X`09int xx, yy; X X`09xx = (int)(((float)(x)-fxoff)*fxscal); X`09yy = (int)(((float)(y)-fyoff)*fyscal); X X`09if (!tkflag) lineto(xx,max_y-yy); X`09else `7B X`09`09fputc(((yy&0x3e0)>>5)+0x20,stdout); X`09`09fputc((yy&0x1f)+0x60,stdout); X`09`09fputc(((xx&0x3e0)>>5)+0x20,stdout); X`09`09fputc((xx&0x1f)+0x40,stdout); X`09`09`7D X`09`7D X Xdrawstr(str) X`09char *str; X`7B X`09if (!tkflag) outtext(str); X`09else `7B X`09`09fputc(0x1f,stdout); X`09`09fputs(str,stdout); X`09`09fputc(0x1d,stdout); X`09`09`7D X`09`7D X Xpsizex() X`7B X`09if (tkflag) return 8; X`09else return textwidth("x"); X`09`7D X Xpsizey() X`7B X`09if (tkflag) return 8; X`09else return textheight("X"); X`7D $ CALL UNPACK TPLOTSUB.C;1 1786676577 $ create 'f' X/*`09dispn.c`09associated subroutines for matching sequences */ X/* `09tcdispn.c uses turbo'c' 1.5 graphics calls */ X X#include X#include X X#define XTERNAL X#include "upam.gbl" X X#define TRUE 1 X#define FALSE 0 X X#ifdef UNIX Xint tkflag=1; X#else Xint tkflag=0;`09`09/* flag to indicate turboc drivers */ X#endif X Xextern FILE *outfd; X Xextern int iscore, gscore; Xextern char name0`5B`5D, ltitle`5B`5D; X/*extern int colflg;*/ X Xint lintc`5B`5D=`7BSOLID_LINE,CENTER_LINE,DASHED_LINE,DOTTED_LINE`7D; Xint lintk`5B`5D=`7B0,2,4,1,3`7D; Xint lintkc`5B`5D=`7B0,1,2,3,4`7D; Xchar linchar`5B`5D=`7B96,'a','b','c','d','e','f','g'`7D; X Xextern char lvstr`5B`5D; X Xint plinval`5B3`5D=`7B200,100,50`7D; Xint dlinval`5B3`5D=`7B400,200,100`7D; Xint *linval; X Xextern int dnaseq; X Xextern int smin0,smin1; Xextern long loffset; X X#define DIAG 1 X#define INS0 2 X#define INS1 4 X Xlong pminx, pmaxx, pminy, pmaxy; X Xint max_x, max_y; X Xdouble fxscal, fyscal, fxoff, fyoff, aratio; X#define SX(x) (int)(((double)(x)*fxscal+fxoff)/aratio) X#define SY(y) (int)((double)(y)*fyscal+fyoff) X Xdiscons(seqc0, seqc1, nc) X`09char *seqc0, *seqc1; X`09int nc; X`7B X`09long x0, x1, y0, y1; X`09int direct, ii; X X`09y1 = y0 = smin0; X`09x1 = x0 = smin1 + loffset; X X`09direct = DIAG; X`09 X`09move(SX(x0),SY(y0)); X X`09for (ii=0; ii pmaxy) printf("\r* n0 * %3ld %3ld\n",y1,pmaxy); X`09if (x1 > pmaxx) printf("\r* n1 * %3ld %3ld\n",x1,pmaxx); X`09`7D X Xaancpy(to,from,count) X`09char *to, *from; X`09int count; X`7B X`09char *tp; X`09tp=to; X`09while (count--&& *from>=0) `7B X`09`09if (*from='a' && c<='z') return (c-'a'+'A'); X`09return c; X`09`7D X Xmin(arg1, arg2) X`09int arg1, arg2; X`7B X`09return (arg1<=arg2) ? arg1 : arg2; X`09`7D X X Xint g_driver=DETECT, g_mode; X Xint ErrorCode, palette, MaxColors, MaxX, MaxY; Xint xasp, yasp; X Xopenplt(n0, n1) X`09long n0, n1; X`7B X`09char *getenv(), *g_path, *sptr; X`09double ftemp; X X`09if ((sptr=getenv("TEKPLOT"))!=NULL) sscanf(sptr,"%d",&tkflag); X X`09if (!tkflag) `7B X`09`09if ((g_path=getenv("BGIDIR"))==NULL) g_path="\0"; X X`09`09initgraph(&g_driver,&g_mode,g_path); X`09`09ErrorCode = graphresult(); /* Read result of initialization*/ X`09`09if( ErrorCode != grOk )`7B /* Error occured during init */ X`09`09`09printf(" Graphics System Error: %s\n", X`09`09`09`09grapherrormsg( ErrorCode ) ); X`09`09`09exit( 1 ); X`09`09`09`7D X`09`09getaspectratio(&xasp,&yasp); X`09`09MaxX = getmaxx(); X`09`09aratio = (double)xasp/(double)yasp; X`09`09max_x = MaxX*aratio; X`09`09max_y = getmaxy(); /* Read size of screen`09`09*/ X`09`09`7D X`09else `7B X`09`09MaxX = 1000; X`09`09max_x = 1000; X`09`09max_y = 770; X`09`09aratio = 1.0; X`09`09`7D X X`09if (strlen(lvstr)>0) `7B X`09`09sscanf(lvstr,"%d %d %d",&plinval`5B0`5D,&plinval`5B1`5D,&plinval`5B2`5 VD); X`09`09linval = plinval; X`09`09`7D X`09else if ((sptr=getenv("LINEVAL"))!=NULL && strlen(sptr)>0) `7B X`09`09sscanf(sptr,"%d %d %d",&plinval`5B0`5D,&plinval`5B1`5D,&plinval`5B2`5D V); X`09`09linval = plinval; X`09`09`7D X`09else `7B X`09`09if (dnaseq==1) linval=dlinval; X`09`09else linval=plinval; X`09`09`7D X X`09pmaxx = n1; X`09pmaxy = n0; X X`09fxscal = (double)(max_x-1)/(double)(n1); X`09fyscal = (double)(max_y-1)/(double)(n0); X X`09ftemp=0.0; X`09if (fxscal > fyscal) fxscal = fyscal; X`09`09else `7Bftemp = (fyscal-fxscal)*(double)max_y/2.0; X`09`09`09fyscal = fxscal;`7D X X`09if (fyscal * n0 < (double)max_y/5.0)`20 X`09`09fyscal = (double)(max_y-1)/((double)(n0)*5.0); X X`09fxscal *= 0.9; fxoff = (double)(max_x-1)/11.0; X`09fyscal *= 0.9; fyoff = (double)(max_y-1)/11.0 + ftemp; X X X`09linetype(0); X`09move(SX(0),SY(0)); X`09draw(SX(0),SY(n0)); X`09draw(SX(n1),SY(n0)); X`09draw(SX(n1),SY(0)); X`09draw(SX(0),SY(0)); X`09xaxis(n1); X`09yaxis(n0); X`09legend(n1); X`09`7D X`09 Xdrawdiag(n0,n1) X`09long n0, n1; X`7B X`09linetype(0); X`09move(SX(0),SY(0)); X`09draw(SX(n0),SY(n1)); X`7D X Xint tarr`5B`5D = `7B10,20,50,100,200,500,1000,2000,5000`7D; Xint ntarr = sizeof(tarr); Xxaxis(n) X long n; X`7B X`09int i, jm, tick; X`09long js; X`09char numstr`5B20`5D; X X`09if (!tkflag) tick = 4; else tick=10; X X`09for (i=0; i(MaxX-11*del)) return; X`09for (i=0; i<4; i++) `7B X`09`09linetype(i); X`09`09if (!tkflag) `7B X`09`09`09ixp = MaxX-11*del; X`09`09`09iyp = max_y*(i+1)/5; X`09`09`09`7D X`09`09else `7B X`09`09`09ixp = max_x - 11*del; X`09`09`09iyp = max_y*(4-i)/5; X`09`09`09`7D X`09`09move(ixp,iyp); X`09`09draw(ixp+5*del,iyp); X`09`09move(ixp+6*del,iyp); X`09`09if (i==3) sprintf(numstr,"<%3d",linval`5B2`5D); X`09`09else sprintf(numstr,">%3d",linval`5Bi`5D); X`09`09drawstr(numstr); X`09`09`7D X`09`7D X Xlinetype(type) X`09int type; X`7B X`09if (!tkflag) setlinestyle(lintc`5Btype`5D,0,NORM_WIDTH); X`09else printf("\033%c",linchar`5Blintk`5Btype`5D`5D); X`09`7D X Xcloseplt() X`7B X`09char line`5B10`5D, *str; X`09str = " to continue"; X`09if (!tkflag) `7B X`09`09moveto(MaxX-textwidth(str),max_y-textheight(str)); X`09`09outtext(str); X`09`09fgets(line,sizeof(line),stdin); X`09`09closegraph(); X`09`09`7D X`09else `7B X`09`09move(0,0); X`09`09putchar('\r'); X`09`09`7D X`09`7D X Xopnline(x,y,s) X long x, y; X int s; X`7B X if (s>linval`5B0`5D) linetype(0); X else if (s>linval`5B1`5D) linetype(1); X else if (s>linval`5B2`5D) linetype(2); X else linetype(3); X`7D X Xclsline(x,y,s) X long x, y; X int s; X`7B X`7D X Xmove(x,y) X`09unsigned int x, y; X`7B X`09if (!tkflag) moveto(x,max_y-y); X`09else `7B X`09`09fputc(0x1d,stdout); X`09`09fputc(((y&0x3e0)>>5)+0x20,stdout); X`09`09fputc((y&0x1f)+0x60,stdout); X`09`09fputc(((x&0x3e0)>>5)+0x20,stdout); X`09`09fputc((x&0x1f)+0x40,stdout); X`09`09`7D X`09`7D X Xdraw(x,y) X`09unsigned int x, y; X`7B X`09if (!tkflag) lineto(x,max_y-y); X`09else `7B X`09`09fputc(((y&0x3e0)>>5)+0x20,stdout); X`09`09fputc((y&0x1f)+0x60,stdout); X`09`09fputc(((x&0x3e0)>>5)+0x20,stdout); X`09`09fputc((x&0x1f)+0x40,stdout); X`09`09`7D X`09`7D X Xdrawstr(str) X`09char *str; X`7B X`09if (!tkflag) outtext(str); X`09else `7B X`09`09fputc(0x1f,stdout); X`09`09fputs(str,stdout); X`09`09fputc(0x1d,stdout); X`09`09`7D X`09`7D X X#ifdef VMS Xmemset(str, c, cnt) X`09char *str; int cnt; char c; X`7B X`09while (cnt--) *str++ = c; X`09`7D X#endif $ CALL UNPACK TTDISPN.C;1 1130526407 $ create 'f' X/*`09ascii.gbl`09ascii translation to amino acids */ X/*`09modified 10-Mar-1987 for B, Z`09*/ X X#define NA 124 X#define EL 125 X#define ES 126 X X#ifndef XTERNAL X/* 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15`09*/ Xint aascii`5B`5D=`7B X`09EL,NA,NA,NA,NA,NA,NA,NA,NA,NA,EL,NA,NA,EL,NA,NA, X`09NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA, X`09NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,ES,NA,NA,NA,NA,NA, X`09NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA, X`09ES, 0,20, 4, 3, 6,13, 7, 8, 9,NA,11,10,12, 2,NA, X`0914, 5, 1,15,16,NA,19,17,22,18,21,NA,NA,NA,NA,NA, X`09ES, 0,20, 4, 3, 6,13, 7, 8, 9,NA,11,10,12, 2,NA, X`0914, 5, 1,15,16,NA,19,17,22,18,21,NA,NA,NA,NA,NA`7D; X Xint *sascii; X#define AAMASK 127 X Xint nascii`5B`5D=`7B X/*`09 0 1 2 3 5 6 7 8 9 10 11 12 13 14 15 15 X`09 @ A B C D E F G H I J K L M N O X`09 P Q R S T U V W X Y Z`09`09*/ X`09EL,NA,NA,NA,NA,NA,NA,NA,NA,NA,EL,NA,NA,EL,NA,NA, X`09NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA, X`09NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,ES,NA,NA,16,NA,NA, X`09ES,ES,ES,NA,NA,NA,NA,NA,NA,NA,NA,ES,NA,NA,ES,NA, X`09ES, 0,14, 1,11,NA,NA, 2,12,NA,NA,10,NA, 7,15,NA, X`09 5, 6, 5, 9, 3, 4,13, 8,15, 6,NA,NA,NA,NA,NA,NA, X`09ES, 0,14, 1,11,NA,NA, 2,12,NA,NA,10,NA, 7,15,NA, X`09 5, 6, 5, 9, 3, 4,13, 8,15, 6,NA,NA,NA,NA,NA,NA`7D; X X#else Xextern int aascii`5B`5D; Xextern int nascii`5B`5D; Xextern int *sascii; X X#define AAMASK 127 X Xextern int lascii`5B`5D; X X#define LAMASK 15 X#endif $ CALL UNPACK UASCII.GBL;1 1127775885 $ create 'f' X/*`0920-June-1986`09universal pam file */ X X#ifndef XTERNAL X Xint gdelval= -12; Xint ggapval= -4; X Xextern int gdelval, ggapval; X X X#define EOSEQ 127 X#define MAXSQ 32 X X Xchar sqnam`5B`5D=`7B"aa"`7D; Xchar sqtype`5B`5D=`7B"protein"`7D; X Xchar *sq; Xchar aa`5BMAXSQ`5D = `7B"ARNDCQEGHILKMFPSTWYVBZX"`7D; X Xint naa = 23; Xint nsq; X Xint haa`5BMAXSQ`5D = `7B0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,2, V6,0`7D; Xint *hsq; X Xint apam`5B450`5D = `7B X 2, X-2, 6, X 0, 0, 2, X 0,-1, 2, 4, X-2,-4,-4,-5,12, X 0, 1, 1, 2,-5, 4, X 0,-1, 1, 3,-5, 2, 4, X 1,-3, 0, 1,-3,-1, 0, 5, X-1, 2, 2, 1,-3, 3, 1,-2, 6, X-1,-2,-2,-2,-2,-2,-2,-3,-2, 5, X-2,-3,-3,-4,-6,-2,-3,-4,-2, 2, 6, X-1, 3, 1, 0,-5, 1, 0,-2, 0,-2,-3, 5, X-1, 0,-2,-3,-5,-1,-2,-3,-2, 2, 4, 0, 6, X-4,-4,-4,-6,-4,-5,-5,-5,-2, 1, 2,-5, 0, 9, X 1, 0,-1,-1,-3, 0,-1,-1, 0,-2,-3,-1,-2,-5, 6, X 1, 0, 1, 0, 0,-1, 0, 1,-1,-1,-3, 0,-2,-3, 1, 2, X 1,-1, 0, 0,-2,-1, 0, 0,-1, 0,-2, 0,-1,-3, 0, 1, 3, X-6, 2,-4,-7,-8,-5,-7,-7,-3,-5,-2,-3,-4, 0,-6,-2,-5,17, X-3,-4,-2,-4, 0,-4,-4,-5, 0,-1,-1,-4,-2, 7,-5,-3,-3, 0,10, X 0,-2,-2,-2,-2,-2,-2,-1,-2, 4, 2,-2, 2,-1,-1,-1, 0,-6,-2, 4, X 0,-1, 2, 3,-4, 1, 2, 0, 1,-2,-3, 1,-2,-5,-1, 0, 0,-5,-3,-2, 2, X 0, 0, 1, 3,-5, 3, 3,-1, 2,-2,-3, 0,-2,-5, 0, 0,-1,-6,-4,-2, 2, 3, X 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0`7D; X Xint apam120`5B`5D = `7B X 3, X -3, 6, X 0,-1, 4, X 0,-3, 2, 5, X -3,-4,-5,-7, 9, X -1, 1, 0, 1,-7, 6, X 0,-3, 1, 3,-7, 2, 5, X 1,-4, 0, 0,-5,-3,-1, 5, X -3, 1, 2, 0,-4, 3,-1,-4, 7, X -1,-2,-2,-3,-3,-3,-3,-4,-4, 6, X -3,-4,-4,-5,-7,-2,-4,-5,-3, 1, 5, X -2, 2, 1,-1,-7, 0,-1,-3,-2,-2,-4, 5, X -2,-1,-3,-4,-6,-1,-4,-4,-4, 1, 3, 0, 8, X -4,-4,-4,-7,-6,-6,-6,-5,-2, 0, 0,-6,-1, 8, X 1,-1,-2,-2,-3, 0,-1,-2,-1,-3,-3,-2,-3,-5, 6, X 1,-1, 1, 0,-1,-2,-1, 1,-2,-2,-4,-1,-2,-3, 1, 3, X 1,-2, 0,-1,-3,-2,-2,-1,-3, 0,-3,-1,-1,-4,-1, 2, 4, X -7, 1,-5,-8,-8,-6,-8,-8,-5,-7,-5,-5,-7,-1,-7,-2,-6, 12, X -4,-6,-2,-5,-1,-5,-4,-6,-1,-2,-3,-6,-4, 4,-6,-3,-3,-1, 8, X 0,-3,-3,-3,-2,-3,-3,-2,-3, 3, 1,-4, 1,-3,-2,-2, 0,-8,-3, 5, X 1,-1, 4, 5,-4, 1, 3, 1, 2,-2,-3, 1,-3,-4,-1, 1, 1,-5,-2,-2, 6, X 0, 0, 1, 3,-6, 5, 5,-1, 2,-2,-2, 0,-1,-5, 0, 0,-1,-6,-4,-2, 4, 6, X -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1`7D; X X/*`09DNA alphabet X X`09A, C, G, T U X`09R, Y X`09M (A or C)`096 X`09W (A or T)`097 X`09S (C or G)`098 X`09K (G or T)`099 X`09D (not C)`0910 X`09H (not G)`0911 X`09V (not T)`0912 X`09B (not A)`0913 X`09N X `09`0914 X*/ X Xchar nt`5BMAXSQ`5D=`7B"ACGTURYMWSKDHVBNX"`7D; X Xint nnt = 17; X Xint hnt`5BMAXSQ`5D = `7B0,1,2,3,3,0,1,0,0,1,2,0,0,0,1,0,0`7D; X Xint npam`5B450`5D = `7B X/* A C G T U R Y M W S K D H V B N X */ X`09 4,`09`09`09`09`09`09/* A */ X`09-3, 4,`09`09`09`09`09`09/* C */ X`09-3,-3, 4,`09`09`09`09`09/* G */ X`09-3,-3,-3, 4,`09`09`09`09`09/* T */ X`09-3,-3,-3, 4, 4,`09`09`09`09`09/* U */ X`09 2,-1, 2,-1,-1, 2,`09`09`09`09/* R (A G)*/ X`09-1, 2,-1, 2, 2,-2, 2,`09`09`09`09/* Y (C T)*/ X`09 2, 2,-1,-1,-1, 0, 0, 2,`09`09`09/* M (A C)*/ X`09 2,-1,-1, 2, 2, 1, 1, 1, 2,`09`09`09/* W (A T)*/ X`09-1, 2, 2,-1,-1, 1, 1, 1,-1, 2,`09`09`09/* S (C G)*/ X`09-1,-1, 2, 2, 2, 1, 1,-1, 1, 1, 2,`09`09/* K (G T)*/ X`09 1,-2, 1, 1, 1, 1, 0, 0, 1, 0, 1, 1,`09`09/* D (!C) */ X`09 1, 1,-2, 1, 1, 0, 1, 1, 1, 0, 0, 0, 1,`09`09/* H (!G) */ X`09 1, 1, 1,-2,-1, 1, 0, 1, 0, 1, 0, 0, 0, 1,`09/* V (!T) */ X`09-2, 1, 1, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 0, 1,`09/* B (!A) */ X`09 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* N */ X`09 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0`7D; /* X */ X/* A C G T U R Y M W S K D H V B N */ X Xint *pam; Xint pam2`5BMAXSQ`5D`5BMAXSQ`5D; Xint pamh1`5BMAXSQ`5D;`09`09/* used for kfact replacement */ X X#else X#define MAXSQ 32 X Xextern char sqnam`5B`5D; Xextern char sqtype`5B`5D; Xextern int gdelval, ggapval; Xextern`09char aa`5B`5D; Xextern`09char nt`5B`5D; Xextern `09char *sq; X X#define EOSEQ 127 X Xextern int naa; Xextern int nnt; Xextern`09int nsq; X Xextern int hnt`5B`5D; Xextern int haa`5B`5D; Xextern`09int *hsq; X Xextern int apam`5B`5D,apam120`5B`5D; Xextern`09int npam`5B`5D; Xextern`09int *pam; X Xextern int pam2`5BMAXSQ`5D`5BMAXSQ`5D; Xextern int pam2m`5BMAXSQ`5D`5BMAXSQ`5D; Xextern`09int pamh1`5B`5D; X#endif $ CALL UNPACK UPAM.GBL;1 891709539 $ create 'f' X/* urdf.c 12-Feb-1984, 22-Sept-85, 17-Oct-1985 X copyright (c) 1984,1987,1988 William R. Pearson and David Lipma Vn X X`09urdf.c - version of udf.c which scrambles sequences for testing X`09significance X X`09modified for argc or queries X X`099-May-85`09change shuffling algorithm X X`0922-Sept-85`09display both initial and optimized histogram X`0917-Oct-85`09correct bigscore bug, savemax bug X`0927-Dec-85`09correct savemax bug, put 32 wide window in ngdist X`0922-June-86`09added universal matrix X`09 4-Apr-88`09update to new kfact calculation X`09Nov, 1991`09include -n option to force DNA sequences`09 X*/ X X#include X/*#include */ X X#define TRUE 1 X#define FALSE 0 X X#ifndef BIGMEM X#define MAXTST 2000`09/* longest test sequence */ X#define MAXLIB 10000 X#define MAXDIAG (MAXTST+MAXLIB) X#else X#define MAXTST 10000 X#define MAXLIB 50000 X#define MAXDIAG (MAXTST+MAXLIB) X#endif X X#ifndef MAXSAV X#define MAXSAV 20`09/* number of best diagonals saved */ X#endif X#define MAXHIST 41`09/* number of histogram divisions */ X/*#define HISTSIZE 2`09/* size of histogram division */ X XFILE *outfd;`09`09/* fd for output file */ Xint smark`5B4`5D; X X/* globals for matching */ X Xlong lmark;`09`09/* position in library file from ftell() */ Xint nlib; Xlong ntt;`09`09/* number of library sequences, number of X`09`09`09`09residues scanned*/ Xchar libstr`5B21`5D;`09/* partial title from library sequence */ X Xchar *aa0, *aa10, *aa1;`09/* amino acid sequence data */ Xint maxn;`09`09/* max space for lib sequence (MAXDIAG-n0) */ Xint n0, n1, nd, noff;`09/* length of aa0, length of aa1, n0+n1, X`09`09`09`09diagonal offset */ X Xstruct dstruct `7B`09/* diagonal structure for saving current run */ X int start;`09/* start of current match */ X int stop;`09/* end of current match */ X int score;`09/* hash score of current match */ X`09struct beststr *dmax;`09/* location in vmax`5B`5D where best score data s Vaved */ X `7D *diag; X X Xstruct beststr `7B X`09int score;`09/* pam score with segment opt */ X`09int score0;`09/* pam score of best single segment */ X`09int gscore;`09/* score from global match */ X`09long lseek;`09/* position in library file */ X`09int dp;`09`09/* diagonal of match */ X`09int start;`09/* start of match in lib seq */ X`09int stop;`09/* end of match in lib seq */ X`09`7D *qptr, X`09 vmax`5BMAXSAV`5D,`09/* best matches saved for one sequence */ X`09 *vptr`5BMAXSAV`5D; X X Xint cgap;`09/* gap threshold */ Xint pgap=20;`09/* gap penalty for optimized alignment of diagonals */ X Xint nbest;`09/* number of sequences better than bestcut in best */ Xint bestcut; `09/* cut off for getting into MAXBEST */ X Xint histint=2; Xint bestscale=200; Xint bkfact=5; Xint scfact=4; Xint bktup=2; Xint ktmax=2; Xint bestmax=50; Xint bestoff=27;`09/* values for calculating bestcut */ Xint pamfact = 1;`09/* flag for using pam values for kfact */ Xint dnaseq = 0;`09/* true if DNA query sequence */ X Xint nsav, lowscor;`09/* number of saved runs, worst saved X`09`09`09`09run, score of worst saved run */ Xstruct beststr *lowmax; X Xint hist`5BMAXHIST`5D;`09`09/* histogram of all score */ Xdouble lsum, lsumsq;`09`09/* mean, sd of all scores */ Xint lmax; Xint nmean;`09`09`09/* number of scores averaged in mean */ Xdouble sqrt(); X Xint hist0`5BMAXHIST`5D;`09`09/* histogram of init0 scores */ Xdouble lsum0, lsumsq0;`09`09/* mean, sd of init0 scores */ Xint lmax0; Xint nmean0;`09`09`09/* number of init0 scores */ X Xint ghist`5BMAXHIST`5D;`09`09/* histogram of optimized score */ Xdouble glsum, glsumsq;`09`09/* mean, sd of optimized scores */ Xint glmax; Xint gnmean;`09`09`09/* number of optimized scores averaged */ X Xint fact, gm; /* scoring factors */ X Xint hmask, hmax;`09`09/* hash constants */ Xint *pamh2;`09`09`09`09/* pam based kfact array */ Xint *link, *harr;`09`09/* hash arrays */ Xint ktup, kshft, kt1;`09`09/* ktuple constants */ X Xint nshow; char rline`5B20`5D,sline`5B20`5D; Xint showall; Xlong tstart, tscan, tdone, stime(); X X#include "upam.gbl"`09`09/* includes pam array */ X Xextern int optind; Xchar *getenv(), *smptr, *cptr;`09`09/* scoring matrix env */ Xchar smstr`5B40`5D; X Xint wflag = -1; Xint wsiz; X Xmain(argc, argv) X int argc; char **argv; X`7B X`09char tname`5B40`5D, lname`5B40`5D, qline`5B40`5D; X`09char *calloc(), *strchr(), *bp; X`09int score, gscore, score0, gscore0;`09/* scores calculated */ X`09int i0score, i0score0; X`09int icnt, rcnt;`09`09`09/* number of random shuffles */ X`09int i; X X`09if ((aa0=calloc(MAXTST+MAXLIB,sizeof(char)))==0) `7B X`09`09printf(" cannot allocate sequence array\n"); X`09`09exit(); X`09`09`7D X`09maxn = MAXTST+MAXLIB; X`09if ((aa10=calloc(MAXLIB,sizeof(char)))==0) `7B X`09`09printf(" cannot allocate sequence array\n"); X`09`09exit(); X`09`09`7D X X`09initenv(argc,argv); X X if (argc-optind < 3) `7B X printf(" rdf2 1.6c `5BMarch, 1992`5D compares a test sequence to V a shuffled sequence\n"); Xl1:`09`09printf(" test sequence file name: "); X`09`09fgets(tname,40,stdin); X`09`09if (tname`5Bstrlen(tname)-1`5D=='\n') tname`5Bstrlen(tname)-1`5D='\0'; X`09`09if (strlen(tname)==0) goto l1; X if ((n0=getseq(tname,aa0,maxn,&dnaseq))==0) `7B X printf(" %s : sequence not found\n",tname); X`09`09goto l1; X `7D X`09`09resetp(dnaseq); X Xl2:`09`09printf(" sequence to be shuffled: "); X`09`09fgets(lname,40,stdin); X`09`09if (lname`5Bstrlen(lname)-1`5D=='\n') lname`5Bstrlen(lname)-1`5D='\0'; X`09`09if (strlen(lname)==0) goto l2; X X`09`09printf(" ktup? (1 to %d) `5B%d`5D ",ktmax,ktmax); X`09`09fgets(qline,40,stdin); X`09`09ktup = ktmax; X`09`09if (qline`5B0`5D!='\0' && qline`5B0`5D!='\n') `7B X`09`09`09sscanf(qline,"%d",&ktup); X`09`09`09if (ktup < 1 `7C`7C ktup>ktmax) ktup = ktmax; X`09 `7D X`09`09printf(" number of random shuffles? `5B20`5D "); X`09`09fgets(qline,40,stdin); X`09`09rcnt = 20; X`09`09if (qline`5B0`5D!='\0' && qline`5B0`5D!='\n') `7B X`09`09`09sscanf(qline,"%d",&rcnt); X`09`09`09if (rcnt < 1) rcnt = 20; X`09`09`09`7D X X`09`09if (wflag<=0) `7B X`09`09`09printf(" local (window) (w) or uniform (u) shuffle `5Bu`5D? "); X`09`09`09fgets(qline,40,stdin); X`09`09`09if ((bp=strchr(qline,'\n'))!=NULL) *bp='\0'; X`09`09`09`7D X`09`09else qline`5B0`5D='\0'; X`09`09if (tolower(qline`5B0`5D)=='w' `7C`7C wflag==1) `7B X`09`09`09wflag = 1; X`09`09`09printf(" local shuffle window size `5B10`5D "); X`09`09`09fgets(qline,40,stdin); X`09`09`09wsiz = 10; X`09`09`09if (qline`5B0`5D!='\0' && qline`5B0`5D!='\n') `7B X`09`09`09`09sscanf(qline,"%d",&wsiz); X`09`09`09`09if (wsiz < 1) wsiz = 10; X`09`09`09`09`7D X`09`09`09`7D X`09`09else wflag=0; X`09`09`7D X`09else `7B X`09`09strncpy(tname,argv`5Boptind+1`5D,40); X if ((n0=getseq(tname,aa0,maxn,&dnaseq))==0) `7B X printf(" %s : sequence not found\n",tname); X exit(); X `7D X`09`09resetp(dnaseq); X`09`09strncpy(lname,argv`5Boptind+2`5D,40); X`09 if (argc-optind>3) sscanf(argv`5Boptind+3`5D,"%d",&ktup); X`09 else ktup=ktmax; X`09`09rcnt = 20; X`09`09if (argc-optind>4) sscanf(argv`5Boptind+4`5D,"%d",&rcnt); X`09`09if (wflag==1) `7B X`09`09`09wsiz = 10; X`09`09`09if (argc-optind>5) sscanf(argv`5Boptind+5`5D,"%d",&wsiz); X`09`09`09`7D X`09`09`7D X X X`09printf(" %s : %4d %s\n",tname, n0, sqnam); X X`09aa1 = aa0 + n0 + 2; X`09maxn -= n0 + 3; X`09if (maxn > MAXLIB) maxn = MAXLIB; X X if ((n1=getseq(lname,aa10,maxn,&dnaseq))==0) `7B X printf(" %s : %s sequence not found\n",lname,sqtype); X exit(); X `7D X`09printf(" %s : %4d %s\n",lname, n1, sqnam); X X`09initpam2();`09`09/* convert 1-d pam to 2-d pam2 */ X X`09initparm(); X X`09tstart = stime(); X X`09fact = ktup*scfact; X`09hashaa(aa0,n0,ktup);`09/* hash test sequence */ X X#ifndef ALLOCN0 X`09allocdiag(MAXDIAG); X#else X`09allocdiag(n0); X#endif X`09inithist();`09`09/* initialize histogram, mean, sd */ X X`09for (i=0; i 0) `7B X`09`09if (wflag==1) wshuffle(aa1,n1,wsiz); X`09`09else shuffle(aa1,n1); X`09`09score=dhash(&i0score,&gscore);`09/* do the hash */ X`09 addhist(score); X`09`09addhist0(i0score); X`09`09addhistg(gscore); X`09`09`7D X X`09tscan = stime(); X X`09prhist(stdout,score0,i0score0,gscore0);`09`09/* print histogram, statisti Vcs */ X X l3:`09printf(" Enter filename for results : "); X`09fgets(rline,20,stdin); X`09outfd = stdout; X`09if (rline`5B0`5D!='\n' && rline`5B0`5D!=0) `7B X`09`09rline`5Bstrlen(rline)-1`5D=0; X`09`09if ((outfd=fopen(rline,"w"))==0) `7B X`09`09`09printf(" could not open %s\n",rline); X`09`09`09goto l3; X`09`09`09`7D X`09`09fprintf(outfd," %s, %d amino acids vs %s\n", X`09`09`09tname, n0, lname); X`09`09prhist(outfd,score0,i0score0,gscore0); X`09`09`7D X `7D X Xextern int *sascii, nascii`5B`5D, aascii`5B`5D; X Xinitenv(argc,argv) X`09int argc; char **argv; X`7B X`09char *cptr, *getenv(); X`09int copt, getopt(); X`09extern char *optarg; X X`09sascii = aascii; X`09pam = apam; X`09sq = aa; X`09hsq = haa; X`09nsq = naa; X`09dnaseq = 0; X X`09if ((cptr=getenv("GAPPEN"))!=NULL) sscanf(cptr,"%d",&cgap); X`09else cgap=0; X X`09if ((cptr=getenv("CUTOFF"))!=NULL) sscanf(cptr,"%d",&bestcut); X`09else bestcut = 0; X X`09if ((cptr=getenv("PAMFACT"))!=NULL) sscanf(cptr,"%d",&pamfact); X`09if (pamfact!=1) pamfact=0; X`09else pamfact = -2; X X`09while ((copt=getopt(argc,argv,"c:fknp:s:w"))!=EOF) X`09 switch(copt) `7B X`09 case 'c': sscanf(optarg,"%d",&bestcut); break; X`09 case 'k': pamfact= -1; break; X`09 case 'f': pamfact= -2; break; X`09 case 'n': dnaseq=1; X`09 sascii = nascii; X`09 sq = nt; X`09 nsq = nnt; X`09 hsq = hnt; X`09 pam = npam; X`09 strcpy(sqnam,"nt"); X`09 strcpy(sqtype,"DNA"); X`09 resetp(dnaseq); X`09 break; X`09 case 'p': sscanf(optarg,"%d",&cgap); break; X`09 case 's': strncpy(smstr,optarg,sizeof(smstr)); X`09 smptr=smstr; X`09 if (initpam(smptr)) dnaseq= -1; X`09 else smptr="\0"; X`09 break; X`09 case 'w': wflag = 1; X`09 break; X`09 default : fprintf(stderr," illegal option -%c\n",copt); X`09 `7D X`09optind--; X X`09if (dnaseq>=0) `7B X`09`09if ((smptr=getenv("SMATRIX"))!=NULL && initpam(smptr)) X`09`09`09dnaseq = -1; X`09`09else X`09`09`09smptr="\0"; X`09`09`7D X X`09ktmax = bktup; X`09 X`09if (strlen(smptr)>0) fprintf(stderr," using matrix file %s\n",smptr); X`09`7D X Xresetp(dnaseq) X`09int dnaseq; X`7B X`09if (dnaseq==1) `7B X`09`09histint=4; X`09`09bestscale=80; X`09`09bkfact=5; X`09`09scfact=1; X`09`09bktup=6; X`09`09ktmax=6; X`09`09bestmax=80; X`09`09bestoff=45; X`09`09pam = npam; X`09`09if (pamfact>=0) pamfact = 0; X`09`09`7D X`09`7D X Xinitparm() X`7B X`09char *getenv(), *cptr; X`09int itemp; X X`09if (bestcut<=0) `7B X`09`09bestcut = bestoff + n0/bestscale + bkfact*(bktup-ktup); X`09`09if (bestcut>bestmax) bestcut = bestmax; X`09`09if (bestcut > 3*n0) bestcut = 3*n0; X`09`09`7D X X`09if (cgap<=0) cgap=bestcut; X`09`7D X X/*`09hashaa - hash sequence 0 for rapid lookup of seq 1 (library) */ X Xhashaa(aa0, n0, ktup) X`09char *aa0; int n0, ktup; X`7B X`09char *calloc(); X`09int mhv; X `09int i0, hv, phv; X X`09if (pamfact == -1) pamfact=0; X`09else if (pamfact== -2) pamfact=1; X X`09for (i0=0, mhv= -1; i0mhv) mhv=hsq`5Bi0`5D; X X`09if (mhv<=0) `7B X`09`09printf(" maximum hsq <=0 %d\n",mhv); X`09`09exit(1); X`09`09`7D X`09`09 X`09for (kshft=0; mhv>0; mhv/=2) `7B X`09`09kshft++; X`09`7D X X/* kshft = 2;`09*/ X kt1 = ktup-1; X X`09hv = 1; X`09for (i0 = 0; i0>kshft)-1; X X`09allochash(n0,hmax); X X X for (i0=0; i0stop = -1; X`09`09`09dptr->dmax = NULL; X`09`09`09dptr++->score = 0; X `7D X X`09`09for (vmptr=vmax; vmptr<&vmax`5BMAXSAV`5D; vmptr++) X`09`09`09vmptr->score = 0; X`09`09lowmax = vmax; X`09`09lowscor = 0; X X X /* start hashing */ X lhval = 0; X for (lpos=0; lpos=0; tpos=link`5Btpos`5D) `7B X`09`09 if ((tscor = (dptr = &diagp`5B-tpos`5D)->stop)>=0) `7B X#else X`09lposn0 = noff + lpos; X for ( ; lpos=0; tpos=link`5Btpos`5D) `7B X`09`09 dpos = lposn0 - tpos; X`09`09 if ((tscor = (dptr = &diag`5Bdpos%nd`5D)->stop)>=0) `7B X#endif X`09`09`09tscor += ktup; X`09`09`09if ((tscor -=lpos)<=0) `7B X`09`09`09 scor = dptr->score; X#ifdef FKFACT X`09`09`09 if ((tscor += kfact)<0 && lowscor=kfact) `7B X `09`09`09`09dptr->score = tscor; X `09`09`09`09dptr->stop=lpos; X `09`09`09`09`7D X `09`09`09 else `7B X `09`09`09`09dptr->score = kfact; X `09`09`09`09dptr->start = (dptr->stop = lpos) - kt1; X`09`09`09`09`7D X`09`09`09 `7D X`09`09`09else `7B X#ifdef FKFACT X`09`09 `09 dptr->score += fact; X#else X`09`09 `09 dptr->score += pamh1`5Baa0`5Btpos`5D`5D; X#endif X`09`09 `09 dptr->stop = lpos; X`09`09`09 `7D X`09`09`09`7D X`09`09 else `7B X#ifdef FKFACT X`09`09 `09dptr->score = kfact; X#else X`09`09 `09dptr->score = pamh2`5Blhval`5D; X#endif X`09`09 `09dptr->start = (dptr->stop=lpos) - kt1; X`09`09`09`7D X`09`09 `7D /* end tpos */ X#ifdef ALLOCN0 X`09`09/* reinitialize diag structure */ X X`09`09if ((dptr= &diag`5Blpos%nd`5D)->score>lowscor)`20 X`09`09`09savemax(dptr,lpos); X`09`09dptr->stop = -1; X`09`09dptr->dmax = NULL; X`09`09dptr->score = 0; X#endif X `7D /* end lpos */ X X#ifdef ALLOCN0 X`09for (tpos=0, dpos = noff+n1-1; tpos < n0; tpos++,dpos--) `7B X`09`09if ((dptr= &diag`5Bdpos%nd`5D)->score>lowscor) savemax(dptr,dpos); X`09`09`7D X#else X`09for (dptr=diag; dptr < dpmax; ) `7B X`09`09if (dptr->score>lowscor) savemax(dptr); X`09`09dptr->stop = -1; X`09`09dptr->dmax = NULL; X`09`09dptr++->score = 0; X`09`09`7D X`09ndo = nd; X#endif X X/* X at this point all of the elements of aa1`5Blpos`5D X have been searched for elements of aa0`5Btpos`5D X with the results in diag`5Bdpos`5D X*/ X`09for (ib= nsave =0,vmptr=vmax; vmptr < &vmax`5BMAXSAV`5D; vmptr++) `7B X`09`09if (vmptr->score>0) `7B X`09`09`09vmptr->score=spam(vmptr); X`09`09`09vptr`5Bib++`5D= vmptr; X`09`09`09nsave++; X`09`09`09`7D X`09`09`7D X X`09if (nsave>0) `7B X`09`09scor = sconn(vptr,nsave); X`09`09ksort(vptr,nsave,cmps); X`09`09scor = max(scor,vptr`5B0`5D->score); X`09`09*i0score = vptr`5B0`5D->score; X`09`09*gscore = dmatch(noff-vptr`5B0`5D->dp,FALSE); X`09`09return scor; X`09`09`7D`20 X`09else `7B *i0score=0; *gscore=0; return 0;`7D X`09`7D X X#ifdef ALLOCN0 Xsavemax(dptr,dpos) X`09register struct dstruct *dptr; int dpos; X`7B X`09register struct beststr *vmptr; X`09register int i; X X#else Xsavemax(dptr) X`09register struct dstruct *dptr; X`7B X`09register int dpos; X`09register struct beststr *vmptr; X`09register int i; X#ifndef I86BUG X`09dpos = (int)(dptr-diag); X#else X`09dpos = ((unsigned)dptr-(unsigned)diag)>>L2DSTR; X#endif X#endif X/* check to see if this is the continuation of a run that is already saved * V/ X X`09if ((vmptr=dptr->dmax)!=NULL && vmptr->dp== dpos && X`09`09vmptr->start==dptr->start) `7B X`09`09vmptr->stop = dptr->stop; X`09`09if ((i=dptr->score)<=vmptr->score) return; X`09`09vmptr->score = i; X`09`09if (vmptr!=lowmax) return; X`09`09`7D X`09else `7B X`09`09i=lowmax->score = dptr->score; X`09`09lowmax->dp = dpos; X`09`09lowmax->start = dptr->start; X`09`09lowmax->stop = dptr->stop; X`09`09dptr->dmax = lowmax; X`09`09`7D X X`09for (vmptr = vmax; vmptr < &vmax`5BMAXSAV`5D; vmptr++) X`09`09if (vmptr->score < i) `7B X`09`09`09i = vmptr->score; X`09`09`09lowmax = vmptr; X`09`09`09`7D X`09lowscor = i; X`09`7D X`09 Xinitpam2() X`7B X`09int i, j, k; X X`09k=0; X`09for (i=0; istart`5D; X`09aa0p= &aa0`5Blpos - dmax->dp + noff`5D; X`09curv.start = lpos; X X`09tot = curv.score = maxv.score = 0; X`09for ( ; lpos <= dmax->stop; lpos++) `7B X`09`09tot += pam2`5B*aa0p++`5D`5B*aa1p++`5D; X`09`09if (tot > curv.score) `7B X`09`09`09curv.stop = lpos; X`09`09`09curv.score = tot; X`09`09`09`7D X`09`09else if (tot < 0) `7B X`09`09`09if (curv.score > maxv.score) `7B X`09`09`09`09maxv.start = curv.start; X`09`09`09`09maxv.stop = curv.stop; X`09`09`09`09maxv.score = curv.score; X`09`09`09`09`7D X`09`09`09tot = curv.score = 0; X`09`09`09curv.start = lpos; X`09`09`09`7D X`09`09`7D X X`09if (curv.score > maxv.score) `7B X`09`09maxv.start = curv.start; X`09`09maxv.stop = curv.stop; X`09`09maxv.score = curv.score; X`09`09`7D X X/*`09if (maxv.start != dmax->start `7C`7C maxv.stop != dmax->stop) X`09`09printf(" new region: %3d %3d %3d %3d\n",maxv.start, X`09`09`09dmax->start,maxv.stop,dmax->stop); X*/ X`09dmax->start = maxv.start; X`09dmax->stop = maxv.stop; X X`09return maxv.score; X`09`7D X Xsconn(v,n) X`09struct beststr *v`5B`5D; X`09int n; X`7B X`09int i,si,cmpp(); X`09struct slink `7B X`09`09int score; X`09`09struct beststr *vp; X`09`09struct slink *next; X`09`09`7D *start, *sl, *sj, *so, sarr`5BMAXSAV`5D; X`09int lstart, tstart, plstop, ptstop; X X/*`09sort the score left to right in lib pos */ X X`09ksort(v,n,cmpp); X X`09start = NULL; X X/*`09for the remaining runs, see if they fit */ X X`09for (i=0,si=0; iscore < cgap) continue; X`09`09lstart=v`5Bi`5D->start; X`09`09tstart=lstart-v`5Bi`5D->dp+noff; X X/*`09put the run in the group */ X`09`09sarr`5Bsi`5D.vp = v`5Bi`5D; X`09`09sarr`5Bsi`5D.score = v`5Bi`5D->score; X`09`09sarr`5Bsi`5D.next = NULL; X X/* `09if it fits, then increase the score */ X`09`09for (sl=start; sl!= NULL; sl = sl->next) `7B X`09`09`09plstop = sl->vp->stop; X`09`09`09ptstop = plstop - sl->vp->dp + noff; X`09`09`09if (plstopscore+v`5Bi`5D->score-pgap; X`09`09`09`09break; X`09`09`09`09`7D X`09`09`09`7D X X/*`09now recalculate where the score fits */ X`09`09if (start==NULL) start= &sarr`5Bsi`5D; X`09`09else for (sj=start, so=NULL; sj!=NULL; sj = sj->next) `7B X`09`09`09if (sarr`5Bsi`5D.score>sj->score) `7B X`09`09`09`09sarr`5Bsi`5D.next = sj; X`09`09`09`09if (so!=NULL) so->next= &sarr`5Bsi`5D; X`09`09`09`09else start= &sarr`5Bsi`5D; X`09`09`09`09break; X`09`09`09`09`7D X`09`09`09so=sj; X`09`09`09`7D X`09`09si++; X`09`09`7D X X`09if (start!=NULL) return (start->score); X`09else return (0); X`09`7D X Xinithist() X`7B X`09int i; X X`09for (i=0; i' : ' '; X`09`09pch = (i==0) ? '<' : pch; X`09`09fprintf(fd,"%c%3d %5d %5d %5d:", X`09`09`09pch,(i 50) hl = 50; X`09`09if (gl > 50) gl = 50; X`09`09for (j=0; jhl) `7Bfor (j=hl; j= (i+1)*histint && score0 < (i+2)*histint) `7C`7C X`09`09`09(score0 >= mh1*histint && i==mh1)) fprintf(fd," I"); X`09`09if ((gscore0 >= (i+1)*histint && gscore0 < (i+2)*histint) `7C`7C X`09`09`09(gscore0 >= mh1*histint && i==mh1)) fprintf(fd," O"); X`09`09fprintf(fd,"\n"); X`09`09`7D X X`09if (nmean>1) `7B X`09`09lsd = (lsumsq - (lsum*lsum)/nmean)/(nmean-1); X`09`09lsd = sqrt(lsd); X`09`09lsd0 = (lsumsq0 - (lsum0*lsum0)/nmean0)/(nmean0-1); X`09`09lsd0 = sqrt(lsd0); X`09`09glsd = (glsumsq - (glsum*glsum)/nmean)/(nmean-1); X`09`09glsd = sqrt(glsd); X`09`09`7D X`09else glsd = lsd = lsd0 = 0.0; X`09if (nmean>0) `7B X`09`09lmean = lsum/nmean; X`09`09glmean = glsum/nmean; X`09`09lmean0 = lsum0/nmean; X`09`09`7D X`09else glmean = lmean = lmean0 = 0.0; X`09fprintf(fd,"%7ld residues in %5d sequences,\n",ntt,nlib); X`09if (wflag==1) fprintf(fd," local shuffle, window size: %d\n",wsiz); X`09fprintf(fd," mean initn score: %5.1f (%.2f); max initn score: %3d\n", X`09`09lmean,lsd,lmax); X`09fprintf(fd," mean init0 score: %5.1f (%.2f); max init0 score: %3d\n", X`09`09lmean0,lsd0,lmax0); X`09fprintf(fd," mean opt score: %5.1f (%.2f); max opt score: %3d\n", X`09`09glmean,glsd,glmax); X`09fprintf(fd," init score: %4d is %5.2f s.d. above mean\n", X`09`09score0, lsd>0.0 ? (score0-lmean)/lsd : 0.0); X`09fprintf(fd," init0 score: %4d is %5.2f s.d. above mean\n", X`09`09i0score0, lsd>0.0 ? (i0score0-lmean0)/lsd0 : 0.0); X`09fprintf(fd," opt score: %4d is %5.2f s.d. above mean\n", X`09`09gscore0, glsd>0.0 ? (gscore0-glmean)/glsd : 0.0); X`09fprintf(fd," ktup: %d, fact: %d",ktup, fact); X`09fprintf(fd," scan time: "); ptime(fd,tscan-tstart); fprintf(fd,"\n"); X`09`7D X Xaddhist(score) X`09int score; X`7B X`09lsum = lsum + (double)score; X`09lsumsq = lsumsq + (double)score*(double)score; X`09if (score>lmax) lmax = score; X`09nmean++; X X`09score = (score-1)/histint; X`09if (score < 0) score=0; X`09else if (score >= MAXHIST) score = MAXHIST-1; X`09hist`5Bscore`5D++; X`09`7D X Xaddhistg(score) X`09int score; X`7B X`09glsum = glsum + (double)score; X`09glsumsq = glsumsq + (double)score*(double)score; X`09if (score>glmax) glmax = score; X`09gnmean++; X X`09score = (score-1)/histint; X`09if (score < 0) score=0; X`09else if (score >= MAXHIST) score = MAXHIST-1; X`09ghist`5Bscore`5D++; X`09`7D X Xaddhist0(score) X`09int score; X`7B X`09lsum0 = lsum0 + (double)score; X`09lsumsq0 = lsumsq0 + (double)score*(double)score; X`09if (score>lmax0) lmax0 = score; X`09nmean0++; X X`09score = (score-1)/histint; X`09if (score < 0) score=0; X`09else if (score >= MAXHIST) score = MAXHIST-1; X`09hist0`5Bscore`5D++; X`09`7D X Xallocdiag(dsize)`09/* allocates diagonal structures */ X`09int dsize; X`7B X`09char *calloc(); X X`09diag = (struct dstruct *)calloc(dsize,sizeof(struct dstruct)); X X`09if (diag==NULL) `7B X`09`09printf(" cannot allocate diagonal arrays\n"); X`09`09exit(); X`09`09`7D X`09`7D X Xcmps(ptr1,ptr2) X`09struct beststr *ptr1, *ptr2; X`7B X`09if (ptr1->score < ptr2->score) return (1); X`09else if (ptr1->score > ptr2->score) return (-1); X`09else return (0); X`09`7D X Xcmpp(ptr1,ptr2) X`09struct beststr *ptr1, *ptr2; X`7B X`09if (ptr1->start < ptr2->start) return (-1); X`09else if (ptr1->start > ptr2->start) return (1); X`09else return (0); X`09`7D X Xksort(v,n,comp) X`09char *v`5B`5D; int n, (*comp)(); X`7B X`09int gap, i, j; X`09char *tmp; X`09 X`09for (gap=n/2; gap>0; gap/=2) X`09`09for (i=gap; i=0; j -= gap) `7B X`09`09`09`09if ((*comp)(v`5Bj`5D,v`5Bj+gap`5D) <=0) X`09`09`09`09`09break; X`09`09`09`09tmp = v`5Bj`5D; v`5Bj`5D=v`5Bj+gap`5D; v`5Bj+gap`5D=tmp; X`09`09`09`09`7D X`09`7D X/* Xquick(sptr,i0, in) X`09struct beststr *sptr`5B`5D; int i0, in; X`7B X`09int tval; X`09int j0, jn; X X`09if (i0>=in) return; X`09j0 = i0; jn = in; X`09tval = sptr`5B(j0+jn)/2`5D->score; X`09while (j0score > tval) j0++; X`09`09while (sptr`5Bjn`5D->score < tval) jn--; X`09`09if (j0<=jn) `7B X`09`09`09qptr=sptr`5Bj0`5D; X`09`09`09sptr`5Bj0`5D=sptr`5Bjn`5D; X`09`09`09sptr`5Bjn`5D=qptr; X`09`09`09j0++; jn--; X`09`09`09`7D X`09`09`7D X`09if (i01; i--) `7B X`09`09`09j = nrand(i); X`09`09`09tmp = fromp`5Bj`5D; X`09`09`09fromp`5Bj`5D = fromp`5Bi-1`5D; X`09`09`09fromp`5Bi-1`5D = tmp; X`09`09`09`7D X`09`09`7D X`09`09fromp = &from`5Bn-mm`5D; X`09`09for (i=mm; i>1; i--) `7B X`09`09`09j = nrand(i); X`09`09`09tmp = fromp`5Bj`5D; X`09`09`09fromp`5Bj`5D = fromp`5Bi-1`5D; X`09`09`09fromp`5Bi-1`5D = tmp; X`09`09`09`7D X`09 ieven = 0; X`09 `7D X`09else `7B X`09 for (k=n; k>=wsiz; k -= wsiz) `7B X`09`09fromp = &from`5Bk-wsiz`5D; X`09`09for (i=wsiz; i>1; i--) `7B X`09`09`09j = nrand(i); X`09`09`09tmp = fromp`5Bj`5D; X`09`09`09fromp`5Bj`5D = fromp`5Bi-1`5D; X`09`09`09fromp`5Bi-1`5D = tmp; X`09`09`09`7D X`09`09`7D X`09`09fromp = &from`5B0`5D; X`09`09for (i=mm; i>1; i--) `7B X`09`09`09j = nrand(i); X`09`09`09tmp = fromp`5Bj`5D; X`09`09`09fromp`5Bj`5D = fromp`5Bi-1`5D; X`09`09`09fromp`5Bi-1`5D = tmp; X`09`09`09`7D X`09 ieven = 1; X`09 `7D X`09from`5Bn`5D = -1; X`09`7D X Xshuffle(from,n)`09/* copies from from to from shuffling */ X`09char *from; int n; X`7B X`09int i,j; char tmp; X X`09for (i=n; i>1; i--) `7B X`09`09j = nrand(i); X`09`09tmp = from`5Bj`5D; X`09`09from`5Bj`5D = from`5Bi-1`5D; X`09`09from`5Bi-1`5D = tmp; X`09`09`7D X`09from`5Bn`5D = -1; X`09`7D X X/* stubs for linking */ Xint llen; X Xaancpy() X`7B`7D X Xmin(v0,v1) X`09int v0, v1; X`7B X`09return (v0>v1) ? v1 : v0; X`7D X Xdiscons() X`7B`7D X Xtolower(c) X`09char c; X`7B X`09if (c>='A' && c<='Z') return (c-'A'+'a'); X`09return c; X`09`7D X Xtoupper(c) X`09char c; X`7B X`09if (c>='a' && c<='z') return (c-'a'+'A'); X`09return c; X`09`7D X X#ifdef VMS Xmemset()`7B`7D X#endif $ CALL UNPACK URDF.C;2 524703114 $ create 'f' X/* urss.c Sept, 1991 X copyright (c) 1984,1987,1988,1991 William R. Pearson X X`09urss.c`09`09urss.c is a version of urdf.c that works with the X`09`09`09Smith-Waterman algorithm X X`09Nov, 1991`09include -n option to force DNA sequences`09 X*/ X X#include X/*#include */ X X#define TRUE 1 X#define FALSE 0 X X#ifndef BIGMEM X#define MAXTST 2000`09/* longest test sequence */ X#define MAXLIB 10000 X#define MAXDIAG (MAXTST+MAXLIB) X#else X#define MAXTST 10000 X#define MAXLIB 50000 X#define MAXDIAG (MAXTST+MAXLIB) X#endif X X#define MAXHIST 41`09/* number of histogram divisions */ X/*#define HISTSIZE 2`09/* size of histogram division */ X XFILE *outfd;`09`09/* fd for output file */ Xint smark`5B4`5D; X X/* globals for matching */ X Xlong lmark;`09`09/* position in library file from ftell() */ Xint nlib; Xlong ntt;`09`09/* number of library sequences, number of X`09`09`09`09residues scanned*/ Xchar libstr`5B21`5D;`09/* partial title from library sequence */ X Xchar *aa0, *aa10, *aa1;`09/* amino acid sequence data */ Xint maxn;`09`09/* max space for lib sequence (MAXDIAG-n0) */ Xint n0, n1, nd, noff;`09/* length of aa0, length of aa1, n0+n1, X`09`09`09`09diagonal offset */ X Xint nbest;`09/* number of sequences better than bestcut in best */ Xint bestcut; `09/* cut off for getting into MAXBEST */ X Xint histint=2; Xint bestscale=200; Xint bkfact=5; Xint scfact=4; Xint bktup=2; Xint ktmax=2; Xint bestmax=50; Xint bestoff=27;`09/* values for calculating bestcut */ Xint pamfact = 1;`09/* flag for using pam values for kfact */ Xint dnaseq = 0;`09/* true if DNA query sequence */ X Xint nsav, lowscor;`09/* number of saved runs, worst saved X`09`09`09`09run, score of worst saved run */ X Xint hist`5BMAXHIST`5D;`09`09/* histogram of all score */ Xdouble lsum, lsumsq;`09`09/* mean, sd of all scores */ Xint lmax; Xint nmean;`09`09`09/* number of scores averaged in mean */ Xdouble sqrt(); X Xint nshow; char rline`5B20`5D,sline`5B20`5D; Xint showall; Xlong tstart, tscan, tdone, stime(); X X#include "upam.gbl"`09`09/* includes pam array */ X Xextern int optind; Xchar *getenv(), *smptr, *cptr;`09`09/* scoring matrix env */ Xchar smstr`5B40`5D; Xint wflag = -1; Xint wsiz; X Xmain(argc, argv) X int argc; char **argv; X`7B X`09char tname`5B40`5D, lname`5B40`5D, qline`5B40`5D; X`09char *calloc(), *strchr(), *bp; X`09int score, gscore, score0, gscore0;`09/* scores calculated */ X`09int i0score, i0score0; X`09int icnt, rcnt;`09`09`09/* number of random shuffles */ X`09int i; X X`09if ((aa0=calloc(MAXTST+MAXLIB,sizeof(char)))==0) `7B X`09`09printf(" cannot allocate sequence array\n"); X`09`09exit(); X`09`09`7D X`09maxn = MAXTST+MAXLIB; X`09if ((aa10=calloc(MAXLIB,sizeof(char)))==0) `7B X`09`09printf(" cannot allocate sequence array\n"); X`09`09exit(); X`09`09`7D X X`09initenv(argc,argv); X X if (argc-optind < 3) `7B X printf(" rss 1.6b `5BNov 1991`5D compares a test sequence to a s Vhuffled sequence\n"); Xl1:`09`09printf(" test sequence file name: "); X`09`09fgets(tname,40,stdin); X`09`09if (tname`5Bstrlen(tname)-1`5D=='\n') tname`5Bstrlen(tname)-1`5D='\0'; X`09`09if (strlen(tname)==0) goto l1; X if ((n0=getseq(tname,aa0,maxn,&dnaseq))==0) `7B X printf(" %s : sequence not found\n",tname); X`09`09goto l1; X `7D X`09`09resetp(dnaseq); X Xl2:`09`09printf(" sequence to be shuffled: "); X`09`09fgets(lname,40,stdin); X`09`09if (lname`5Bstrlen(lname)-1`5D=='\n') lname`5Bstrlen(lname)-1`5D='\0'; X`09`09if (strlen(lname)==0) goto l2; X X`09`09printf(" number of random shuffles? `5B20`5D "); X`09`09fgets(qline,40,stdin); X`09`09rcnt = 20; X`09`09if (qline`5B0`5D!='\0' && qline`5B0`5D!='\n') `7B X`09`09`09sscanf(qline,"%d",&rcnt); X`09`09`09if (rcnt < 1) rcnt = 20; X`09`09`09`7D X X`09`09if (wflag<=0) `7B X`09`09`09printf(" local (window) (w) or uniform (u) shuffle `5Bu`5D? "); X`09`09`09fgets(qline,40,stdin); X`09`09`09if ((bp=strchr(qline,'\n'))!=NULL) *bp='\0'; X`09`09`09`7D X`09`09else qline`5B0`5D='\0'; X`09`09if (tolower(qline`5B0`5D)=='w' `7C`7C wflag==1) `7B X`09`09`09wflag = 1; X`09`09`09printf(" local shuffle window size `5B10`5D "); X`09`09`09fgets(qline,40,stdin); X`09`09`09wsiz = 10; X`09`09`09if (qline`5B0`5D!='\0' && qline`5B0`5D!='\n') `7B X`09`09`09`09sscanf(qline,"%d",&wsiz); X`09`09`09`09if (wsiz < 1) wsiz = 10; X`09`09`09`09`7D X`09`09`09`7D X`09`09else wflag=0; X`09`09`7D X`09else `7B X`09`09strncpy(tname,argv`5Boptind+1`5D,40); X if ((n0=getseq(tname,aa0,maxn,&dnaseq))==0) `7B X printf(" %s : sequence not found\n",tname); X exit(); X `7D X`09`09resetp(dnaseq); X`09`09strncpy(lname,argv`5Boptind+2`5D,40); X`09`09rcnt = 20; X`09`09if (argc-optind>3) sscanf(argv`5Boptind+3`5D,"%d",&rcnt); X`09`09if (wflag==1) `7B X`09`09`09wsiz = 10; X`09`09`09if (argc-optind>4) sscanf(argv`5Boptind+4`5D,"%d",&wsiz); X`09`09`09`7D X`09`09`7D X X X`09printf(" %s : %4d %s\n",tname, n0, sqnam); X X`09aa1 = aa0 + n0 + 2; X`09maxn -= n0 + 3; X`09if (maxn > MAXLIB) maxn = MAXLIB; X X if ((n1=getseq(lname,aa10,maxn,&dnaseq))==0) `7B X printf(" %s : %s sequence not found\n",lname,sqtype); X exit(); X `7D X`09printf(" %s : %4d %s\n",lname, n1, sqnam); X X`09initpam2();`09`09/* convert 1-d pam to 2-d pam2 */ X X`09initparm(); X X`09tstart = stime(); X X`09inithist();`09`09/* initialize histogram, mean, sd */ X X`09for (i=0; i 0) `7B X`09`09if (wflag==1) wshuffle(aa1,n1,wsiz); X`09`09else shuffle(aa1,n1); X`09`09ntt += n1; X`09`09nlib++; X`09`09score=smatch(aa0,n0,aa1,n1,FALSE);`09 X`09 addhist(score); X`09`09`7D X X`09tscan = stime(); X X`09prhist(stdout,score0);`09`09/* print histogram, statistics */ X X l3:`09printf(" Enter filename for results : "); X`09fgets(rline,20,stdin); X`09outfd = stdout; X`09if (rline`5B0`5D!='\n' && rline`5B0`5D!=0) `7B X`09`09rline`5Bstrlen(rline)-1`5D=0; X`09`09if ((outfd=fopen(rline,"w"))==0) `7B X`09`09`09printf(" could not open %s\n",rline); X`09`09`09goto l3; X`09`09`09`7D X`09`09fprintf(outfd," %s, %d amino acids vs %s\n", X`09`09`09tname, n0, lname); X`09`09prhist(outfd,score0); X`09`09`7D X `7D X Xextern int *sascii, nascii`5B`5D, aascii`5B`5D; X Xinitenv(argc,argv) X`09int argc; char **argv; X`7B X`09char *cptr, *getenv(); X`09int copt, getopt(); X`09extern char *optarg; X X`09sascii = aascii; X`09pam = apam; X`09sq = aa; X`09hsq = haa; X`09nsq = naa; X`09dnaseq = 0; X X`09while ((copt=getopt(argc,argv,"ns:w"))!=EOF) X`09 switch(copt) `7B X`09 case 'n': dnaseq=1; X`09 sascii = nascii; X`09 sq = nt; X`09 nsq = nnt; X`09 hsq = hnt; X`09 pam = npam; X`09 strcpy(sqnam,"nt"); X`09 strcpy(sqtype,"DNA"); X`09 resetp(dnaseq); X`09 break; X`09 case 's': strncpy(smstr,optarg,sizeof(smstr)); X`09 smptr=smstr; X`09 if (initpam(smptr)) dnaseq= -1; X`09 else smptr="\0"; X`09 break; X`09 case 'w': wflag = 1; X`09 break; X`09 default : fprintf(stderr," illegal option -%c\n",copt); X`09 `7D X`09optind--; X X`09if (dnaseq>=0) `7B X`09`09if ((smptr=getenv("SMATRIX"))!=NULL && initpam(smptr)) X`09`09`09dnaseq = -1; X`09`09else X`09`09`09smptr="\0"; X`09`09`7D X X`09if (strlen(smptr)>0) fprintf(stderr," using matrix file %s\n",smptr); X`09`7D X Xresetp(dnaseq) X`09int dnaseq; X`7B X`09if (dnaseq==1) `7B X`09`09histint=4; X`09`09bestscale=80; X`09`09bkfact=5; X`09`09scfact=1; X`09`09bktup=6; X`09`09ktmax=6; X`09`09bestmax=80; X`09`09bestoff=45; X`09`09pam = npam; X`09`09if (pamfact>=0) pamfact = 0; X`09`09`7D X`09`7D X Xinitparm() X`7B X`09char *getenv(), *cptr; X`09int itemp; X X`09`7D X X Xinitpam2() X`7B X`09int i, j, k; X X`09k=0; X`09for (i=0; i' : ' '; X`09`09pch = (i==0) ? '<' : pch; X`09`09fprintf(fd,"%c%3d %5d:", X`09`09`09pch,(i 50) hl = 50; X`09`09for (j=0; j= (i+1)*histint && score0 < (i+2)*histint) `7C`7C X`09`09`09(score0 >= mh1*histint && i==mh1)) fprintf(fd," O"); X`09`09fprintf(fd,"\n"); X`09`09`7D X X`09if (nmean>1) `7B X`09`09lsd = (lsumsq - (lsum*lsum)/nmean)/(nmean-1); X`09`09lsd = sqrt(lsd); X`09`09`7D X`09else lsd = 0.0; X`09if (nmean>0) `7B X`09`09lmean = lsum/nmean; X`09`09`7D X`09else lmean = 0.0; X`09fprintf(fd,"%7ld residues in %5d sequences,\n",ntt,nlib); X`09if (wflag==1) fprintf(fd," local shuffle, window size: %d\n",wsiz); X`09fprintf(fd," mean initn score: %5.1f (%.2f); max score: %3d\n", X`09`09lmean,lsd,lmax); X`09fprintf(fd," score: %4d is %5.2f s.d. above mean\n", X`09`09score0, lsd>0.0 ? (score0-lmean)/lsd : 0.0); X`09fprintf(fd," scan time: "); ptime(fd,tscan-tstart); fprintf(fd,"\n"); X`09`7D X Xaddhist(score) X`09int score; X`7B X`09lsum = lsum + (double)score; X`09lsumsq = lsumsq + (double)score*(double)score; X`09if (score>lmax) lmax = score; X`09nmean++; X X`09score = (score-1)/histint; X`09if (score < 0) score=0; X`09else if (score >= MAXHIST) score = MAXHIST-1; X`09hist`5Bscore`5D++; X`09`7D X Xint ieven = 1; Xwshuffle(from,n,wsiz)`09/* copies from from to from shuffling */ X`09char *from; int n, wsiz; X`7B X`09int i,j, k, mm; char tmp, *fromp; X`09 X`09mm = n%wsiz; X X`09if (ieven) `7B X`09 for (k=0; k<(n-wsiz); k += wsiz) `7B X`09`09fromp = &from`5Bk`5D; X`09`09for (i=wsiz; i>1; i--) `7B X`09`09`09j = nrand(i); X`09`09`09tmp = fromp`5Bj`5D; X`09`09`09fromp`5Bj`5D = fromp`5Bi-1`5D; X`09`09`09fromp`5Bi-1`5D = tmp; X`09`09`09`7D X`09`09`7D X`09`09fromp = &from`5Bn-mm`5D; X`09`09for (i=mm; i>1; i--) `7B X`09`09`09j = nrand(i); X`09`09`09tmp = fromp`5Bj`5D; X`09`09`09fromp`5Bj`5D = fromp`5Bi-1`5D; X`09`09`09fromp`5Bi-1`5D = tmp; X`09`09`09`7D X`09 ieven = 0; X`09 `7D X`09else `7B X`09 for (k=n; k>=wsiz; k -= wsiz) `7B X`09`09fromp = &from`5Bk-wsiz`5D; X`09`09for (i=wsiz; i>1; i--) `7B X`09`09`09j = nrand(i); X`09`09`09tmp = fromp`5Bj`5D; X`09`09`09fromp`5Bj`5D = fromp`5Bi-1`5D; X`09`09`09fromp`5Bi-1`5D = tmp; X`09`09`09`7D X`09`09`7D X`09`09fromp = &from`5B0`5D; X`09`09for (i=mm; i>1; i--) `7B X`09`09`09j = nrand(i); X`09`09`09tmp = fromp`5Bj`5D; X`09`09`09fromp`5Bj`5D = fromp`5Bi-1`5D; X`09`09`09fromp`5Bi-1`5D = tmp; X`09`09`09`7D X`09 ieven = 1; X`09 `7D X`09from`5Bn`5D = -1; X`09`7D X Xshuffle(from,n)`09/* copies from from to from shuffling */ X`09char *from; int n; X`7B X`09int i,j; char tmp; X X`09for (i=n; i>1; i--) `7B X`09`09j = nrand(i); X`09`09tmp = from`5Bj`5D; X`09`09from`5Bj`5D = from`5Bi-1`5D; X`09`09from`5Bi-1`5D = tmp; X`09`09`7D X`09from`5Bn`5D = -1; X`09`7D X X/* stubs for linking */ Xint llen; X Xaancpy() X`7B`7D X Xmin(v0,v1) X`09int v0, v1; X`7B X`09return (v0>v1) ? v1 : v0; X`7D X XALIGN() X`7B`7D X Xdiscons() X`7B`7D X Xtolower(c) X`09char c; X`7B X`09if (c>='A' && c<='Z') return (c-'A'+'a'); X`09return c; X`09`7D X Xtoupper(c) X`09char c; X`7B X`09if (c>='a' && c<='z') return (c-'a'+'A'); X`09return c; X`09`7D X X#ifdef VMS Xmemset()`7B`7D X#endif $ CALL UNPACK URSS.C;1 1212698254 $ create 'f' X/* May, June 1987 - modified for rapid read of database X `20 X`09May, 1989 - Modified for new format of UWGCG libraries. X`09Also modified to compile correctly with VMS 5.0 runtime. X`09Switch added for compilation on 4.X vs 5.X X X`09November 23, 1988 (with help from Greg Cathell) X`09This version has been substantially modified to work with the X`09UWGCG format files on the VAX. As a result of this modification, X`09this version knows about two kinds of files: X X`09PIR files, which have the form X X`09>XX:YYYY X`09Title line X`09sequence X`09and have a sequence terminator as a '*' X X`09and UWGCG files, which have the format: X X`09X comment lines X`09line ending with .. X`09sequence starting in column 11 X X`09After a file has been opened, the program makes a choice of X`09which of these format is being used (by the presence of a X`09>XX;YYYY at the start of the first line. X`09 X June 2, 1987 - added TFASTA`20 X March 30, 1988 - combined ffgetaa, fgetgb;`20 X April 8, 1988 - added PIRLIB format for unix X copyright (c) 1987,1988 William R. Pearson X `20 X getnt.c associated subroutines for matching sequences */`20 X `20 X/* X8-April-88 X The compile time #define PIRLIB allows this routine to be used X to read protein and DNA sequence libraries in the NBRF/PIR X VAX/VMS library format. That is: X `20 X >P1;LCBO X This is a line of description X GTYH ... the sequence starts on this line X `20 X This may ease conversion from UWGCG format libraries. It X has not been extensively tested.`20 X `20 X In addition, sequence libraries with a '>' in the 4th position X are recognized as NBRF format libraries for consistency with X UWGCG`20 X*/ X `20 X/* Nov 12, 1987 - this version checks to see if the sequence`20 X is DNA or protein by asking whether > 85% is A, C, G, T`20 X `20 X May 5, 1988 - modify the DNA/PROTEIN checker by re-reading`20 X DNA sequences in order to check for 'U'. X*/ X `20 X#include `20 X `20 X#include "uascii.gbl"`20 X Xextern int outtty; X X#ifdef VMS`20 X#define PIRLIB X#endif`20 X `20 X#define XTERNAL`20 X#include "upam.gbl"`20 X `20 X#define TRUE 1 X#define FALSE 0`20 X#define MAXLINE 512`20 X `20 X#define MAXR 15`20 Xint lascii`5B`5D = `7BES, 0, 1, 7, X 2, 5, 9,13, X 3, 8, 6,12, X 10,11,14,15`7D; X `20 X#define LAMASK 15`20 X `20 Xgetseq(filen,seq,maxs,dnaseq)`20 X char *filen, *seq; X int maxs, *dnaseq;`20 X`7B X FILE *fptr;`20 X char line`5B512`5D;`20 X int i, j, n, ll; X int ic; X`09int uwflag; X float fc; X `20 X if ((fptr=fopen(filen,"r"))==NULL) `7B X fprintf(stderr," could not open %s\n",filen);`20 X return 0;`20 X `7D X n=0;`20 X X`09if (fgets(line,512,fptr)==NULL) return 0; X`09uwflag = !(line`5B0`5D=='>'&&line`5B3`5D==';'); X X if (uwflag) `7B X`09ll=strlen(line); X`09if (ll<4 `7C`7C !(line`5Bll-3`5D=='.'&&line`5Bll-2`5D=='.')) X`09 while(fgets(line,512,fptr)!=NULL && !((ll=strlen(line))>4 && X`09`09line`5Bstrlen(line)-3`5D=='.' && line`5Bstrlen(line)-2`5D=='.'))`20 X `7B`7D X while(fgets(line,512,fptr)!=NULL) `7B X`09`09ll = strlen(line); X`09`09for (i=10; i=maxs) `7B X fprintf(stderr," sequence may be truncated %d %d\n",n,maxs); V`20 X fflush(stderr);`20 X `7D X seq`5Bn`5D= EOSEQ; X X`09if (n==0) return 0; X `20 X if (*dnaseq==0 && (fc=(float)scanseq(seq,n,"ACGT")/(float)n) > 0.85) V `7B X *dnaseq = 1; X/* convert from protein to DNA sequence */ X sascii = nascii; X fseek(fptr,0l,0);`20 X`09`09fgets(line,512,fptr); X n=0;`20 X`09 if (uwflag) `7B X`09`09if ((ll=strlen(line))<4 `7C`7C !(line`5Bll-3`5D=='.'&&line`5Bll-2`5D== V'.')) X`09`09 while(fgets(line,512,fptr)!=NULL && !((ll=strlen(line))>4 && X`09`09`09line`5Bstrlen(line)-3`5D=='.'&&line`5Bstrlen(line)-2`5D=='.')) X`09`09`09`7B`7D X`09 while(fgets(line,512,fptr)!=NULL) `7B X`09`09`09ll = strlen(line); X`09`09`09for (i=10; i=maxs) `7B X`09`09`09fprintf(stderr, X`09`09`09 " sequence may be truncated %d %d\n",n,maxs); X`09 fflush(stderr);`20 X`09 `7D X`09 seq`5Bn`5D= EOSEQ; X X`09 sq = nt; X`09 nsq = nnt; X`09 hsq = hnt; X`09 pam = npam; X`09 strcpy(sqnam,"nt"); X`09 strcpy(sqtype,"DNA");`20 X`09 `7D X `20 X fclose(fptr);`20 X `20 X return n; X `7D X `20 Xgettitle(filen,title,len) X char *filen, *title; int len;`20 X`7B X FILE *fptr;`20 X char line`5B512`5D;`20 X char *bp;`20 X int ll; X char *strchr();`20 X X if ((fptr=fopen(filen,"r"))==NULL) `7B X fprintf(stderr," file %s was not found\n",filen); X fflush(stderr);`20 X return 0;`20 X `7D X `20 X while(fgets(line,512,fptr)!=0) `7B`20 X if (line`5B0`5D=='>'`7C`7C line`5B0`5D==';') goto found;`20 X`09`09if ((ll=strlen(line))>4&&line`5Bll-3`5D=='.'&&line`5Bll-2`5D=='.') X`09`09`09goto found; X `7D X fclose(fptr);`20 X title`5B0`5D='\0';`20 X return 0;`20 X `20 Xfound: X if (line`5B0`5D=='>'&&(line`5B3`5D==';'`7C`7Cline`5B3`5D=='>')) `7B X if ((bp = strchr(line,'\n'))!=NULL) *bp='\0'; X ll=strlen(line); line`5Bll++`5D=' '; line`5Bll`5D='\0';`20 X fgets(&line`5Bll`5D,512-ll,fptr); X`09 bp = strchr(line,'\n'); X `09if (bp!=NULL) *bp = 0; X `09strncpy(title,line,len);`20 X`09`09`7D X`09else `7B X`09`09bp = strchr(line,'\n'); X`09`09if (bp!=NULL) *bp='\0'; X`09`09strncpy(title,line+4,len); X`09`09`7D X title`5Blen-1`5D='\0'; X fclose(fptr);`20 X return strlen(title); X `7D X `20 X#ifndef VMS`20 XFILE *libf=NULL; X#else`20 Xint libf = -1;`20 X#endif`20 X#ifdef NOLIB`20 Xint leof = 0; X#endif`20 X `20 Xlong lpos; Xchar lline`5BMAXLINE`5D;`20 X `20 Xint luwflag= -1; X X#ifndef NOLIB`20 X#define BINARYGB 0 Xextern int ldnaseq;`20 Xextern int deftype; Xint (*getlib)();`20 Xint (*ranlib)();`20 X#define GETLIB agetlib`20 X#define RANLIB aranlib`20 X#else`20 X#define BINARYGB 0 X#define GETLIB getlib`20 X#define RANLIB ranlib`20 Xint deftype=0; X#endif Xint libtype=0;`09`09/* current library type */ Xint sfnum=0;`09`09/* superfamily number (not implemented)*/ `20 Xopenlib(lname,libenv)`20 X char *lname, *libenv; X`7B X char rline`5B10`5D,libn`5B120`5D, *strchr(), *bp; X long ftell(); X#ifndef NOLIB`20 X int agetlib(),aranlib(); X#endif`20 X int wcnt, ll, opnflg; X `20 X wcnt = 0;`20 X#ifndef NOLIB`20 X if (strlen(libenv)!=0) `7B`20 X strncpy(libn,libenv,120); X strncat(libn,lname,120-strlen(libn));`20 X `7D X else strncpy(libn,lname,120);`20 X#else`20 X strncpy(libn,lname,120); X#endif`20 X X`09/* check for library type */ X`09if ((bp=strchr(libn,' '))!=NULL) `7B X`09 *bp='\0'; X`09 sscanf(bp+1,"%d",&libtype); X`09 if (libtype<0 `7C`7C libtype > BINARYGB) `7B X`09`09fprintf(stderr," invalid library type: %d - resetting\n%s\n", X`09`09`09libtype,lname); X`09`09libtype=deftype; X`09`09`7D X`09 `7D X`09else libtype=deftype; X Xl1: opnflg=((libf=open(libn,0))!= -1); X if (!opnflg) `7B`20 X rline`5B0`5D='\0';`20 X fprintf(stderr," cannot open %s library\n",libn);`20 X fprintf(stderr," enter new file name or to quit "); X fflush(stderr);`20 X if (fgets(libn,120,stdin)==NULL) return -1;`20 X if ((bp=strchr(libn,'\n'))!=0) *bp='\0';`20 X if (strlen(libn)==0) return 0; X if (++wcnt > 10) return -1;`20 X goto l1;`20 X `7D X#ifndef NOLIB X`09getlib = agetlib; X`09ranlib = aranlib; X#else X`09leof = 0; X#endif`09`09/* NOLIB */ X`09lpos = lseek(libf,0,1); X`09ll=read(libf,lline,MAXLINE); lline`5Bll`5D='\0'; X return 1;`20 X `7D X `20 Xcloselib() X`7B X if (libf!= -1) `7B`20 X close(libf);`20 X libf = -1; X `7D X `7D X `20 XGETLIB(seq,maxs,libstr,libpos,lcont) X char *seq;`20 X int maxs; X char *libstr;`20 X long *libpos;`20 X int *lcont;`20 X`7B X long lseek(); X X int i, n, ll; X int ic; X register char *cp; X register char *seqp; X register int *ap; X char *seqm, *seqm1, *linep, *strchr(), *bp; X `20 X seqp = seq; X seqm = &seq`5Bmaxs-9`5D; X seqm1 = seqm-1; X#ifndef TFASTA X ap = sascii; X#else X ap = nascii; X#endif X i=0; X n=0; X if (*lcont==0) `7B X`09 if (luwflag==0) `7B X while (lline`5B0`5D!='>' && lline`5B0`5D!=';') `7B X#ifdef VMS5X X lpos = lseek(libf,0,1); X#endif X if ((ll=read(libf,lline,MAXLINE))==0) return 0; X lline`5Bll`5D='\0'; X#ifdef VMS4X X lpos = lseek(libf,0,1); X#endif X`09`09`09`7D X strncpy(libstr,&lline`5B4`5D,20);`20 X ll=read(libf,lline,512); lline`5Bll`5D='\0'; X`09`09`7D X`09 else if (luwflag==1) `7B X`09`09lpos = 0; X`09`09ll = strlen(lline); X`09`09while (ll < 40 `7C`7C !(lline`5Bll-2`5D=='.'&&lline`5Bll-3`5D=='.')) ` V7B X`09`09`09if ((ll=read(libf,lline,MAXLINE))==0) return 0; X`09`09`09lline`5Bll`5D='\0'; X`09`09`09`7D X`09`09strncpy(libstr,&lline`5B3`5D,10); X`09`09`7D X`09 else if (luwflag== -1) `7B X`09`09ll = strlen(lline); X while (lline`5B0`5D!='>' &&`20 X`09`09 (ll < 40 `7C`7C !(lline`5Bll-2`5D=='.'&&lline`5Bll-3`5D=='.'))) V `7B X#ifdef VMS5X X lpos = lseek(libf,0,1); X#endif X if ((ll=read(libf,lline,MAXLINE))==0) return 0; X lline`5Bll`5D='\0'; X#ifdef VMS4X X lpos = lseek(libf,0,1); X#endif X`09`09`09`7D X`09`09if (lline`5B0`5D=='>') `7B X`09`09 luwflag=0; X`09`09 strncpy(libstr,&lline`5B4`5D,20); X`09`09 ll=read(libf,lline,512); lline`5Bll`5D='\0'; X`09`09 `7D X`09`09else if (lline`5Bll-2`5D=='.'&&lline`5Bll-3`5D=='.') `7B X`09`09 lpos = 0;`20 X`09`09 luwflag=1; X`09`09 strncpy(libstr,&lline`5B3`5D,10); X`09`09 `7D X`09 `7D X`09 if ((bp=strchr(libstr,'\n'))!=NULL) *bp='\0'; X libstr`5B10`5D='\0'; X *libpos = lpos;`20 X`09 `7D X X lline`5B0`5D='\0';`20 X if (luwflag==0) X while (seqp0) `7B X seqp`5Bll`5D='\0'; X#ifdef VMS4X X lpos = lseek(libf,0,1); X#endif X if (*seqp=='>') goto new; X if (*seqp==';') `7B X if (strchr(seqp,'\n')==NULL) goto cont; X continue;`20 X `7D X for (cp=seqp; seqpNA) break;`20 X `7D X if (*seqp==ES) goto done;`20 X#ifdef VMS5X X`09`09lpos = lseek(libf,0,1); X#endif X `7D X else X while (seqp0) `7B X lline`5Bll`5D='\0'; X`09`09for (i=10; (i=seqm1) `7B X (*lcont)++; X `7D X else `7B`20 X#ifdef NOLIB`20 X leof = 1;`20 X#endif`20 X *lcont=0; X `7D X `20 X *seqp = EOSEQ; X return (int)(seqp-seq);`20 X `7D X X `20 XRANLIB(str,cnt,seek) X char *str; int cnt; long seek;`20 X`7B X char *bp;`20 X int ll; X char *strchr();`20 X X lseek(libf,seek,0); X ll=read(libf,lline,MAXLINE);`20 X lline`5Bll`5D='\0'; X if (luwflag==0) `7B X if (lline`5B0`5D=='>'&&(lline`5B3`5D==';'`7C`7Clline`5B3`5D=='>')) ` V7B X strncpy(str,&lline`5B4`5D,cnt);`20 X str`5Bcnt-1`5D='\0'; X bp = strchr(str,'\n'); X if (bp!=NULL) *bp = 0; else str`5Bcnt-1`5D='\0';`20 X ll=read(libf,lline,MAXLINE);`20 X if ((bp = strchr(lline,'\n'))!=NULL) *bp='\0'; X strncat(str," ",cnt); X strncat(str,lline,cnt-strlen(str)); X `7D X else `7B`20 X str`5B0`5D='\0';`20 X `7D X`09`7D X else `7B X`09while (!(ll>40&&lline`5Bll-2`5D=='.'&&lline`5Bll-3`5D=='.')) `7B X`09 ll=read(libf,lline,MAXLINE);`20 X`09 lline`5Bll`5D='\0'; X`09`09`7D X`09str`5B0`5D='>'; X`09strncpy(str+1,lline+4,cnt-1); X`09str`5Bcnt-1`5D='\0'; X`09`7D X#ifdef NOLIB`20 X leof=0;`20 X#endif`20 X lseek(libf,seek,0); X ll=read(libf,lline,MAXLINE); lline`5Bll`5D='\0'; X `7D `20 X `20 Xscanseq(seq,n,str) X char *seq, *str; X int n; X`7B X int tot,i;`20 X char aaray`5BMAXSQ`5D; /* this must be set > nsq */`20 X `20 X for (i=0; i= 0 && nt < nsq) return cnt`5Bnt`5D; X else `7B`20 X fprintf(stderr," sequence error %d\n",nt); X fflush(stderr);`20 X `7D X return -1; X `7D X*/ X `20 Xmax(arg1,arg2) X`09int arg1, arg2; X`7B X`09return (arg1>arg2) ? arg1 : arg2; +-+-+-+-+-+-+-+- END OF PART 7 +-+-+-+-+-+-+-+- -+-+-+-+-+-+-+-+ START OF PART 8 -+-+-+-+-+-+-+-+ X`09`7D X X#ifdef VMS`20 Xmemcpy(ar0, ar1, n) X char *ar0, *ar1; unsigned n;`20 X`7B X while (n--) *ar0++ = *ar1++; X `7D X `20 Xopenidx() `7B`7D`20 Xnewname() `7B`7D`20 X#endif`20 X#ifdef MACLSC Xmemcpy(ar0, ar1, n) X char *ar0, *ar1; unsigned n;`20 X`7B X while (n--) *ar0++ = *ar1++; X `7D X#endif`20 X $ CALL UNPACK UWGETAA.C;1 1312329582 $ create 'f' X#include X#include X#include X#include X#include X#include X#include X#include X#include X Xchar * vms_getenv( var ) Xchar X * var; X`7B X char namebuf`5B 100 `5D; X char retbuf`5B 100 `5D, * retptr; X int ret_desc`5B 2 `5D = `7B 100, retbuf `7D; X short len; X int status; X struct dsc$descriptor logname; X X strcpy( namebuf, var ); X logname.dsc$w_length = strlen( namebuf ); X logname.dsc$b_dtype = DSC$K_DTYPE_T; X logname.dsc$b_class = DSC$K_CLASS_S; X logname.dsc$a_pointer = namebuf; X status = lib$sys_trnlog( &logname, &len, ret_desc ); X if ( ! ( status & 1 )) X`09return ( NULL ); X if ( status == SS$_NOTRAN ) `7B X`09if ( strcmp( var, "HOME" ) == 0 `7C`7C X`09 strcmp( var, "TERM" ) == 0 `7C`7C X`09 strcmp( var, "PATH" ) == 0 `7C`7C X`09 strcmp( var, "USER" ) == 0 ) X`09 return ( getenv( var )); X`09return ( NULL ); X`09`7D X retbuf`5B len `5D = '\0'; X retptr = (char *) malloc( len + 1 ); X strcpy( retptr, retbuf ); X return ( retptr ); X`7D /* emacs_getenv */ $ CALL UNPACK VMSGETEN.C;1 727087784 $ create 'f' X#define TRUE 1 X#define FALSE 0 X X/*`09globals for match array`09*/ X X#define MAXARR 4000 X#ifndef MAXWINDOW X#define MAXWINDOW 32 X#endif X X#ifndef XTERNAL Xint maxv, max0, max1;`09`09/* best match values */ Xint min0, min1;`09`09`09/* left end of match */ Xint minc, maxc;`09`09`09/* consensus pointers */ Xint mins; X Xchar *seqc0, *seqc1;`09/* arrays for the consensus sequence */ Xint salloc=0;`09`09/* flag for initseq */ X#endif $ CALL UNPACK ZZGMATA.GBL;1 222460725 $ create 'f' X/* X`09zzlgmata.c Needleman-Wunsch nucleotide mapper to find overlaps X Xcopyright (c) 1983,1986,1987 William R. Pearson X X`09Aug, 1991 - completely dchanged match() to use Miller/Chao linear Xspace in band algorithm. X X`09July 27, 1988 - improved output from consens, so that some context Xof the match is shown. Put in showall == -1 briefly, then removed it. X X`09June 29, 1988 - fixed bug in call to initmat(); X X`09September 24, 1987 - combined zzlgmata.c and zggmata.c with X-DGLOBAL X X*/ X X#include X X#define max(a,b) (((a)>(b))?(a):(b)) X X#include "zzgmata.gbl" X#define XTERNAL X#include "upam.gbl" X Xextern int n0, n1;`09`09/* length of sequences */ Xextern char *aa0, *aa1;`09`09/* sequence arrays */ Xextern FILE *outfd; Xextern int showall;`09/* show complete sequences, not just overlaps */ Xextern int llen; X Xint smin0, smin1, smins;`09/* set bounds for discons */ X X#ifdef LFASTA Xextern int oneseq; Xextern int lcrc0`5B`5D; Xextern int lcrc1`5B`5D; Xextern int ncrc; Xextern int iscore, gscore; X#endif X Xint window; Xint nident; Xint *res; X X#ifndef SMATCH X#ifdef LFASTA Xdmatch(s0,s1,display) X`09int s0,s1,display; X`7B X#else Xdmatch(hoff,display) X`09int hoff, display; X`7B X`09int s0, s1; X#endif X`09int nc, ns; X`09float percent; X`09unsigned int i,j; X`09int low, up; X X`09window=min(n1,MAXWINDOW); X X#ifndef LFASTA X`09low = -window/2-hoff; X`09up = low+window; X X`09if (!display)`20 X`09 return LOCAL_ALIGN(aa0-1,aa1-1,n0,n1, low, up, X`09`09`09 pam2,-(gdelval-ggapval),-ggapval,0, X`09`09`09 &min0,&min1,&max0,&max1,MAXWINDOW); X X`09i=LOCAL_ALIGN(aa0-1,aa1-1,n0,n1, low, up, X`09`09`09 pam2,-(gdelval-ggapval),-ggapval,1, X`09`09`09 &min0,&min1,&max0,&max1,MAXWINDOW); X X`09if (showall==1) `7B X`09`09if (hoff>0) maxc=MAXWINDOW+((n0-hoff>=n1) ? n0 : n1+hoff); X`09`09else maxc=MAXWINDOW+((n1+hoff>=n0) ? n1 : n0-hoff); X`09 `7D X`09else maxc = min(n0,n1)+2+2*MAXWINDOW+2*llen; X`09initseq(maxc,n0+2+2*MAXWINDOW); /* allocate consensus arrays */ X X#else X`09low = - window/2 - (s0-s1); X`09up = low + window; X X/*`09fprintf(stderr," starting at: %3d %3d (%3d %3d)\n", X`09`09s0, s1, low, up); X*/ X`09RLOCAL_ALIGN(aa0-1,aa1-1,s0+1,s1+1, low, up, pam2, X`09`09 -(gdelval-ggapval), -ggapval, 0, X`09`09 &min0, &min1, &max0, &max1,MAXWINDOW); X X/*`09fprintf(stderr," starting from: %3d %3d\n", X`09`09min0, min1); X*/ X`09maxv = LLOCAL_ALIGN(aa0-1+min0-1,aa1-1+min1-1,n0-min0+1,n1-min1+1,`20 X`09`09 -window/2, window/2,pam2,-(gdelval-ggapval),-ggapval,0, X`09`09 &min0,&min1,&max0,&max1,MAXWINDOW); X X`09max0 += min0-1; X`09max1 += min1-1; X X/*`09fprintf(stderr," ending at: %3d %3d\n", X`09`09max0, max1); X*/ X`09maxc = n0+2+2*window; X`09if (!salloc) initseq(maxc,maxc); X#endif X X`09ALIGN(aa0-1+min0-1,aa1-1+min1-1,max0-min0+1,max1-min1+1, X`09 -window/2,window/2, X`09 pam2,-(gdelval-ggapval),-ggapval,res,MAXWINDOW,n0); X X/* `09DISPLAY(aa0-1+min0,aa1-1+min1,max0-min0+1,max1-min1+1, X`09`09res,min0,min1); X*/ X`09ns = calcons(aa0,n0,aa1,n1,res,&nc); X`09percent = (float)nident*100.0/nc; X X#ifndef LFASTA X`09fprintf(outfd," %5.1f%% identity in %d %s overlap\n",percent,nc,sqnam); X`09discons(seqc0,seqc1,ns); X`09freeseq(); X#else X`09if (crcknew(seqc0,seqc1,ns)) `7B X`09`09if (display) fprintf(outfd, X`09 "\n %5.1f%% identity in %d %s overlap; init: %4d, opt: %4d\n", X`09`09`09percent,nc,sqnam,iscore,maxv); X`09`09gscore = maxv; X`09`09opnline((long)smin0,(long)smin1,gscore); X`09`09discons(seqc0,seqc1,ns); X`09`09clsline((long)smin0,(long)smin1,gscore); X#ifdef TPLOT X`09`09if (oneseq) `7B X`09`09`09i = smin0; X`09`09`09smin0 = smin1; X`09`09`09smin1 = i; X`09`09`09opnline((long)smin0,(long)smin1,gscore); X`09`09`09discons(seqc1,seqc0,ns); X`09`09`09clsline((long)smin0,(long)smin1,gscore); X`09`09 `7D X#endif X`09`09`7D X`09else maxv = -1; X#endif X`09return maxv; X`09`7D X X#else /* SMATCH */ X Xint *HH, *EE; X Xsmatch(aa0,n0,aa1,n1,flag) X`09char *aa0, *aa1; X`09int n0, n1; X`09int flag; X`7B X`09int i, j; X`09int f, h, p; X`09int q, r; X`09int score, I, J, cost, K, L; X`09char *calloc(); X`09int nc, minc, maxc, lc; X`09float percent; X X`09q = -(gdelval - ggapval); X`09r = -ggapval; X X`09/* allocate space for the scoring arrays */ X`09if (HH==NULL) `7B X`09`09if ((HH=(int *)calloc(n0+1,sizeof(int)))==NULL) `7B X`09`09`09fprintf(stderr,"cannot allocate HH array %3d\n",n0); X`09`09`09exit(1); X`09`09`7D X`09`09if ((EE=(int *)calloc(n0+1,sizeof(int)))==NULL) `7B X`09`09`09fprintf(stderr,"cannot allocate EE array %3d\n",n0); X`09`09`09exit(1); X`09`09`7D X`09`09EE++; X`09`09HH++; X`09`7D X X/* X`09This subroutine simply finds the best local similarity score X`09between two sequences using Needleman Wunsch Sellers. It does X`09not do an alignment. X*/ X X`09/* initialize 0th row */ X X`09score = I = J = 0; X`09for (j=0; j score) `7B X`09 score = h; X`09 I = i; X`09 J = j; X`09 `7D X`09 `7D X`09`7D /* done with forward pass */ X X`09if (flag==FALSE) return score; X X`09 /* to get the start point, go backwards */ X X`09 cost = K = L = 0; X`09 for (j=J; j>=0; j--) HH`5Bj`5D= EE`5Bj`5D= -1; X X`09 for (i=I; i>=0; i--) `7B X`09 h = f = -1; X`09 p = (i == I) ? 0 : -1; X`09 for (j=J; j>=0; j--) `7B X`09 f = max (f,h-q)-r; X`09 EE`5Bj`5D=max(EE`5Bj`5D,HH`5Bj`5D-q)-r; X`09 h = max(max(EE`5Bj`5D,f),p+pam2`5Baa0`5Bj`5D`5D`5Baa1`5Bi`5D`5D); X`09 p = HH`5Bj`5D; X`09 HH`5Bj`5D=h; X`09 if (h > cost) `7B X`09`09cost = h; X`09`09K = i; X`09`09L = j; X`09`09if (cost >= score) goto found; X`09 `7D X`09 `7D X`09 `7D X X Xfound:`09 X X/* printf(" %d: L: %3d-%3d/%3d; K: %3d-%3d/%3d\n",score,L,J,n0,K,I,n1); */ X X /* allocate consensus arrays */ X`09if (showall==1) initseq(max(n0,n1)*5/4,n0*5/4);`09 X`09else initseq(min(n0,n1)*5/4+2*llen,n0*5/4); X X`09max0 = J+1; min0 = L+1; max1 = I+1; min1 = K+1; X X`09ALIGN(&aa0`5Bmin0-2`5D,&aa1`5Bmin1-2`5D,max0-min0,max1-min1,pam2,q,r,res) V; X`09nc=calcons(aa0,n0,aa1,n1,res,&lc); X`09percent = (100.0*(float)nident)/(float)lc; X X`09fprintf(outfd," %5.1f%% identity in %d %s overlap\n", X`09`09percent,lc,sqnam); X`09discons(seqc0,seqc1,nc); X`09freeseq(); X X`09return score; X `7D X#endif X Xinitseq(seqsiz,rsiz)`09`09/* initialize arrays */ X`09int seqsiz, rsiz; X`7B X`09char *calloc(); X X`09seqc0=calloc(seqsiz,sizeof(char)); X`09seqc1=calloc(seqsiz,sizeof(char)); X`09if (res==NULL) res = (int *)calloc(rsiz,sizeof(int)); X`09if (seqc0==NULL `7C`7C seqc1==NULL `7C`7C res==NULL) X`09`09`7Bfprintf(stderr,"cannot allocate consensus arrays %d\n",seqsiz); X`09`09 exit();`7D X`09salloc = 1; X`09`7D X Xfreeseq() X`7B X`09free(seqc0); free(seqc1); X`09`7D X X/* X`09this function builds a consensus sequence in place by X`09going to the maximum match and moving left and up X*/ X X Xcalcons(aa0,n0,aa1,n1,res,nc) X char *aa0, *aa1; X int n0, n1; X int *res; X int *nc; X`7B X int i0, i1; X int op, lenc, nd, ns, itmp; X char *sp0, *sp1; X int *rp; X `20 X /* first fill in the ends */ X min0--; min1--; X X#ifndef LFASTA X if (min(min0,min1)=min1) `7B /* aa0 extends more to left * V/ X smins=0; X if (showall==1) mins=min0; X else mins = min(min0,llen/2); X aancpy(seqc0,aa0+min0-mins,mins); X smin0 = min0-mins; X if ((mins-min1)>0) `7B X`09memset(seqc1,' ',mins-min1); X`09aancpy(seqc1+mins-min1,aa1,min1); X`09smin1 = 0; X `7D X else `7B X`09aancpy(seqc1,aa1+min1-mins,mins); X`09smin1 = min1-mins; X `7D X `7D X else `7B X smins=0; X if (showall == 1) mins=min1; X else mins = min(min1,llen/2); X aancpy(seqc1,aa1+min1-mins,mins); X smin1 = min1-mins; X if ((mins-min0)>0) `7B X`09memset(seqc0,' ',mins-min0); X`09aancpy(seqc0+mins-min0,aa0,min0); X`09smin0 = 0; X `7D X else `7B X`09aancpy(seqc0,aa0+min0-mins,mins); X`09smin0 = min0-mins; X `7D X `7D X else `7B X mins= min(llen/2,min(min0,min1)); X smins=mins; X smin0=min0; X smin1=min1; X aancpy(seqc0,aa0+min0-mins,mins); X aancpy(seqc1,aa1+min1-mins,mins); X `7D X#else X smin0 = min0; X smin1 = min1; X smins = mins = 0; X#endif X X/* now get the middle */ X X sp0 = seqc0+mins; X sp1 = seqc1+mins; X rp = res; X lenc = nident = op = 0; X i0 = min0; X i1 = min1; X `20 X while (i0 < max0 `7C`7C i1 < max1) `7B X if (op == 0 && *rp == 0) `7B X op = *rp++; X *sp0 = sq`5Baa0`5Bi0++`5D`5D; X *sp1 = sq`5Baa1`5Bi1++`5D`5D; X lenc++; X if (*sp0++ == *sp1++) nident++; X `7D X else `7B X if (op==0) op = *rp++; X if (op>0) `7B X`09*sp0++ = '-'; X`09*sp1++ = sq`5Baa1`5Bi1++`5D`5D; X`09op--; X`09lenc++; X `7D X else `7B X`09*sp0++ = sq`5Baa0`5Bi0++`5D`5D; X`09*sp1++ = '-'; X`09op++; X`09lenc++; X `7D X `7D X `7D X X *nc = lenc; X/*`09now we have the middle, get the right end */ X X#ifndef LFASTA X ns = mins + lenc + llen; X ns -= (itmp = ns %llen); X if (itmp>llen/2) ns += llen; X nd = ns - (mins+lenc); X if (nd > max(n0-max0,n1-max1)) nd = max(n0-max0,n1-max1); X `20 X if (showall==1) `7B X nd = max(n0-max0,n1-max1);`09`09/* reset for showall=1 */ X /* get right end */ X aancpy(seqc0+mins+lenc,aa0+max0,n0-max0); X aancpy(seqc1+mins+lenc,aa1+max1,n1-max1); X /* fill with blanks */ X memset(seqc0+mins+lenc+n0-max0,' ',nd-(n0-max0)); X memset(seqc1+mins+lenc+n1-max1,' ',nd-(n1-max1)); X `7D X else `7B X aancpy(seqc0+mins+lenc,aa0+max0,nd); X aancpy(seqc1+mins+lenc,aa1+max1,nd); X if ((nd-(n0-max0))>0)`20 X memset(seqc0+mins+lenc+n0-max0,' ',nd-(n0-max0)); X if ((nd-(n1-max1))>0)`20 X memset(seqc1+mins+lenc+n1-max1,' ',nd-(n1-max1)); X `7D X `20 X#else`09/* LFASTA */ X nd = 0; X#endif X return mins+lenc+nd; X`7D X X#ifdef LFASTA Xcrcknew(seqc0,seqc1,nc) X`09char *seqc0, *seqc1; int nc; X`7B X`09int crc0, crc1, ii; X X`09crc0 = crck(seqc0,nc); X`09crc1 = crck(seqc1,nc); X X`09for (ii=0; ii