| 1 | /* File: ureadseq.h | 
|---|
| 2 | * | 
|---|
| 3 | * Header for module UReadSeq | 
|---|
| 4 | */ | 
|---|
| 5 |  | 
|---|
| 6 | #ifndef UREADSEQ_H | 
|---|
| 7 | #define UREADSEQ_H | 
|---|
| 8 | #define short int | 
|---|
| 9 |  | 
|---|
| 10 |  | 
|---|
| 11 | typedef char  boolean; | 
|---|
| 12 | #define NEWLINE         '\n' | 
|---|
| 13 | #define false 0 | 
|---|
| 14 | #define true  1 | 
|---|
| 15 | #define min(a,b)      (a<b)?a:b | 
|---|
| 16 | #define max(a,b)      (a>b)?a:b | 
|---|
| 17 | #define skipwhitespace(string)  {while (*string <= ' ' && *string != 0) string++;} | 
|---|
| 18 |  | 
|---|
| 19 | /* NLM strings */ | 
|---|
| 20 | #define is_upper(c) ('A'<=(c) && (c)<='Z') | 
|---|
| 21 | #define is_lower(c) ('a'<=(c) && (c)<='z') | 
|---|
| 22 | #define to_lower(c) ((char)(is_upper(c) ? (c)+' ' : (c))) | 
|---|
| 23 | #define to_upper(c) ((char)(is_lower(c) ? (c)-' ' : (c))) | 
|---|
| 24 |  | 
|---|
| 25 |  | 
|---|
| 26 | /* readSeq errors */ | 
|---|
| 27 | #define eFileNotFound   -1 | 
|---|
| 28 | #define eNoData         -2 | 
|---|
| 29 | #define eMemFull        -3 | 
|---|
| 30 | #define eItemNotFound   -4 | 
|---|
| 31 | #define eOneFormat      -5 | 
|---|
| 32 | #define eUnequalSize    -6 | 
|---|
| 33 | #define eFileCreate     -7 | 
|---|
| 34 | #define eUnknownFormat  -8 | 
|---|
| 35 | #define eOptionBad      -9 | 
|---|
| 36 | #define eASNerr         -10 | 
|---|
| 37 |  | 
|---|
| 38 | /* magic number for readSeq(whichEntry) to give seq list */ | 
|---|
| 39 | #define kListSequences  -1 | 
|---|
| 40 |  | 
|---|
| 41 | /* sequence types parsed by getseqtype */ | 
|---|
| 42 | #define kOtherSeq   0 | 
|---|
| 43 | #define kDNA        1 | 
|---|
| 44 | #define kRNA        2 | 
|---|
| 45 | #define kNucleic    3 | 
|---|
| 46 | #define kAmino      4 | 
|---|
| 47 |  | 
|---|
| 48 | /* formats known to readSeq */ | 
|---|
| 49 | #define kIG             1 | 
|---|
| 50 | #define kGenBank        2 | 
|---|
| 51 | #define kNBRF           3 | 
|---|
| 52 | #define kEMBL           4 | 
|---|
| 53 | #define kGCG            5 | 
|---|
| 54 | #define kStrider        6 | 
|---|
| 55 | #define kFitch          7 | 
|---|
| 56 | #define kPearson        8 | 
|---|
| 57 | #define kZuker          9 | 
|---|
| 58 | #define kOlsen          10 | 
|---|
| 59 | #define kPhylip2        11 | 
|---|
| 60 | #define kPhylip4        12 | 
|---|
| 61 | #define kPhylip3        kPhylip4 | 
|---|
| 62 | #define kPhylip         kPhylip4 | 
|---|
| 63 | #define kPlain          13  /* keep this at #13 */ | 
|---|
| 64 | #define kPIR            14 | 
|---|
| 65 | #define kMSF            15 | 
|---|
| 66 | #define kASN1           16 | 
|---|
| 67 | #define kPAUP           17 | 
|---|
| 68 | #define kPretty         18 | 
|---|
| 69 |  | 
|---|
| 70 | #define kMaxFormat      18 | 
|---|
| 71 | #define kMinFormat      1 | 
|---|
| 72 | #define kNoformat       -1    /* format not tested */ | 
|---|
| 73 | #define kUnknown        0     /* format not determinable */ | 
|---|
| 74 |  | 
|---|
| 75 | /* subsidiary types */ | 
|---|
| 76 | #define kASNseqentry    51 | 
|---|
| 77 | #define kASNseqset      52 | 
|---|
| 78 |  | 
|---|
| 79 | #define kPhylipInterleave 61 | 
|---|
| 80 | #define kPhylipSequential 62 | 
|---|
| 81 |  | 
|---|
| 82 |  | 
|---|
| 83 | typedef struct  { | 
|---|
| 84 | boolean isactive, baseonlynum; | 
|---|
| 85 | boolean numright, numleft, numtop, numbot; | 
|---|
| 86 | boolean nameright, nameleft, nametop; | 
|---|
| 87 | boolean noleaves, domatch, degap; | 
|---|
| 88 | char  matchchar, gapchar; | 
|---|
| 89 | short numline, atseq; | 
|---|
| 90 | short namewidth, numwidth; | 
|---|
| 91 | short interline, spacer, seqwidth, tab; | 
|---|
| 92 | } prettyopts; | 
|---|
| 93 |  | 
|---|
| 94 | #define gPrettyInit(p) { \ | 
|---|
| 95 | p.isactive=false;\ | 
|---|
| 96 | p.baseonlynum=true;\ | 
|---|
| 97 | p.numline= p.atseq= 0;\ | 
|---|
| 98 | p.numright= p.numleft= p.numtop= p.numbot= false;\ | 
|---|
| 99 | p.nameright= p.nameleft= p.nametop= false;\ | 
|---|
| 100 | p.noleaves= p.domatch= p.degap= false;\ | 
|---|
| 101 | p.matchchar='.';\ | 
|---|
| 102 | p.gapchar='-';\ | 
|---|
| 103 | p.namewidth=10;\ | 
|---|
| 104 | p.numwidth=5;\ | 
|---|
| 105 | p.interline=1;\ | 
|---|
| 106 | p.spacer=10;\ | 
|---|
| 107 | p.seqwidth=50;\ | 
|---|
| 108 | p.tab=0; } | 
|---|
| 109 |  | 
|---|
| 110 | extern  prettyopts  gPretty; | 
|---|
| 111 |  | 
|---|
| 112 |  | 
|---|
| 113 | #ifdef __cplusplus | 
|---|
| 114 | extern "C" { | 
|---|
| 115 | #endif | 
|---|
| 116 |  | 
|---|
| 117 | extern short seqFileFormat(const char *filename, long *skiplines, short *error ); | 
|---|
| 118 | extern short seqFileFormatFp(FILE *fseq, long  *skiplines, short *error ); | 
|---|
| 119 |  | 
|---|
| 120 | extern char *listSeqs(const char *filename, const long skiplines, | 
|---|
| 121 | const short format, short *nseq, short *error ); | 
|---|
| 122 |  | 
|---|
| 123 | extern char *readSeq(const short whichEntry, const char *filename, | 
|---|
| 124 | const long skiplines, const short format, | 
|---|
| 125 | long *seqlen, short *nseq, short *error, char *seqid ); | 
|---|
| 126 |  | 
|---|
| 127 | extern char *readSeqFp(const short whichEntry_, FILE  *fp_, | 
|---|
| 128 | const long  skiplines_, const short format_, | 
|---|
| 129 | long  *seqlen_,  short *nseq_, short *error_, char *seqid_ ); | 
|---|
| 130 |  | 
|---|
| 131 | extern short writeSeq(FILE *outf, const char *seq, const long seqlen, | 
|---|
| 132 | const short outform, const char *seqid ); | 
|---|
| 133 |  | 
|---|
| 134 | extern unsigned long CRC32checksum(const char *seq, const long seqlen, unsigned long *checktotal); | 
|---|
| 135 | extern unsigned long GCGchecksum(const char *seq, const long seqlen, unsigned long *checktotal); | 
|---|
| 136 | #ifdef SMALLCHECKSUM | 
|---|
| 137 | #define seqchecksum  GCGchecksum | 
|---|
| 138 | #else | 
|---|
| 139 | #define seqchecksum  CRC32checksum | 
|---|
| 140 | #endif | 
|---|
| 141 |  | 
|---|
| 142 | extern short getseqtype(const char *seq, const long seqlen ); | 
|---|
| 143 | extern char *compressSeq( const char gapc, const char *seq, const long seqlen, long *newlen); | 
|---|
| 144 |  | 
|---|
| 145 | #ifdef NCBI | 
|---|
| 146 |  | 
|---|
| 147 | extern char *listASNSeqs(const char *filename, const long skiplines, | 
|---|
| 148 | const short format, short *nseq, short *error ); | 
|---|
| 149 |  | 
|---|
| 150 | extern char *readASNSeq(const short whichEntry, const char *filename, | 
|---|
| 151 | const long skiplines, const short format, | 
|---|
| 152 | long *seqlen, short *nseq, short *error, char **seqid ); | 
|---|
| 153 | #endif | 
|---|
| 154 |  | 
|---|
| 155 |  | 
|---|
| 156 | /* patches for some missing string.h stuff */ | 
|---|
| 157 | extern int Strcasecmp(const char *a, const char *b); | 
|---|
| 158 | extern int Strncasecmp(const char *a, const char *b, long maxn); | 
|---|
| 159 |  | 
|---|
| 160 | #ifdef __cplusplus | 
|---|
| 161 | } | 
|---|
| 162 | #endif | 
|---|
| 163 |  | 
|---|
| 164 | #endif /*UREADSEQ_H*/ | 
|---|
| 165 |  | 
|---|