JPRED-2 Add sources of all binaries (except alscript) to Git
[jpred.git] / sources / readseq / ureadseq.h
1 /* File: ureadseq.h
2  *
3  * Header for module UReadSeq
4  */
5
6 #ifndef UREADSEQ_H
7 #define UREADSEQ_H
8
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=8;\
104   p.numwidth=5;\
105   p.interline=1;\
106   p.spacer=10;\
107   p.seqwidth=50;\
108   p.tab=0; }
109
110 #ifdef UREADSEQ_G
111 prettyopts  gPretty;
112 #else
113 extern  prettyopts  gPretty;
114 #endif
115
116
117 #ifdef __cplusplus
118 extern "C" {
119 #endif
120
121 extern short seqFileFormat(const char *filename, long *skiplines, short *error );
122 extern short seqFileFormatFp(FILE *fseq, long  *skiplines, short *error );
123
124 extern char *listSeqs(const char *filename, const long skiplines,
125                        const short format, short *nseq, short *error );
126
127 extern char *readSeq(const short whichEntry, const char *filename,
128                       const long skiplines, const short format,
129                       long *seqlen, short *nseq, short *error, char *seqid );
130
131 extern char *readSeqFp(const short whichEntry_, FILE  *fp_,
132   const long  skiplines_, const short format_,
133         long  *seqlen_,  short *nseq_, short *error_, char *seqid_ );
134
135 extern short writeSeq(FILE *outf, const char *seq, const long seqlen,
136                        const short outform, const char *seqid );
137
138 extern unsigned long CRC32checksum(const char *seq, const long seqlen, unsigned long *checktotal);
139 extern unsigned long GCGchecksum(const char *seq, const long seqlen, unsigned long *checktotal);
140 #ifdef SMALLCHECKSUM
141 #define seqchecksum  GCGchecksum
142 #else
143 #define seqchecksum  CRC32checksum
144 #endif
145
146 extern short getseqtype(const char *seq, const long seqlen );
147 extern char *compressSeq( const char gapc, const char *seq, const long seqlen, long *newlen);
148
149 #ifdef NCBI
150
151 extern char *listASNSeqs(const char *filename, const long skiplines,
152                   const short format, short *nseq, short *error );
153
154 extern char *readASNSeq(const short whichEntry, const char *filename,
155                 const long skiplines, const short format,
156                 long *seqlen, short *nseq, short *error, char **seqid );
157 #endif
158
159
160   /* patches for some missing string.h stuff */
161 extern int Strcasecmp(const char *a, const char *b);
162 extern int Strncasecmp(const char *a, const char *b, long maxn);
163
164 #ifdef __cplusplus
165 }
166 #endif
167
168 #endif /*UREADSEQ_H*/
169