ARB
ureadseq.h
Go to the documentation of this file.
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 #define ePipeStdin -11
38 
39  /* magic number for readSeq(whichEntry) to give seq list */
40 #define kListSequences -1
41 
42  /* sequence types parsed by getseqtype */
43 #define kOtherSeq 0
44 #define kDNA 1
45 #define kRNA 2
46 #define kNucleic 3
47 #define kAmino 4
48 
49  /* formats known to readSeq */
50 #define kIG 1
51 #define kGenBank 2
52 #define kNBRF 3
53 #define kEMBL 4
54 #define kGCG 5
55 #define kStrider 6
56 #define kFitch 7
57 #define kPearson 8
58 #define kZuker 9
59 #define kOlsen 10
60 #define kPhylip2 11
61 #define kPhylip4 12
62 #define kPhylip3 kPhylip4
63 #define kPhylip kPhylip4
64 #define kPlain 13 /* keep this at #13 */
65 #define kPIR 14
66 #define kMSF 15
67 #define kASN1 16
68 #define kPAUP 17
69 #define kPretty 18
70 
71 #define kMaxFormat 18
72 #define kMinFormat 1
73 #define kNoformat -1 /* format not tested */
74 #define kUnknown 0 /* format not determinable */
75 
76  /* subsidiary types */
77 #define kASNseqentry 51
78 #define kASNseqset 52
79 
80 #define kPhylipInterleave 61
81 #define kPhylipSequential 62
82 
83 
84 typedef struct {
85  boolean isactive, baseonlynum;
86  boolean numright, numleft, numtop, numbot;
87  boolean nameright, nameleft, nametop;
88  boolean noleaves, domatch, degap;
89  char matchchar, gapchar;
90  short numline, atseq;
91  short namewidth, numwidth;
92  short interline, spacer, seqwidth, tab;
93  } prettyopts;
94 
95 #define gPrettyInit(p) { \
96  p.isactive=false;\
97  p.baseonlynum=true;\
98  p.numline= p.atseq= 0;\
99  p.numright= p.numleft= p.numtop= p.numbot= false;\
100  p.nameright= p.nameleft= p.nametop= false;\
101  p.noleaves= p.domatch= p.degap= false;\
102  p.matchchar='.';\
103  p.gapchar='-';\
104  p.namewidth=10;\
105  p.numwidth=5;\
106  p.interline=1;\
107  p.spacer=10;\
108  p.seqwidth=50;\
109  p.tab=0; }
110 
111 extern prettyopts gPretty;
112 
113 
114 #ifdef __cplusplus
115 extern "C" {
116 #endif
117 
118 extern short seqFileFormat(const char *filename, long *skiplines, short *error );
119 extern short seqFileFormatFp(FILE *fseq, long *skiplines, short *error );
120 
121 extern char *listSeqs(const char *filename, const long skiplines,
122  const short format, short *nseq, short *error );
123 
124 extern char *readSeq(const short whichEntry, const char *filename,
125  const long skiplines, const short format,
126  long *seqlen, short *nseq, short *error, char *seqid );
127 
128 extern char *readSeqFp(const short whichEntry_, FILE *fp_,
129  const long skiplines_, const short format_,
130  long *seqlen_, short *nseq_, short *error_, char *seqid_ );
131 
132 extern short writeSeq(FILE *outf, const char *seq, const long seqlen,
133  const short outform, const char *seqid );
134 
135 extern unsigned long CRC32checksum(const char *seq, const long seqlen, unsigned long *checktotal);
136 extern unsigned long GCGchecksum(const char *seq, const long seqlen, unsigned long *checktotal);
137 #ifdef SMALLCHECKSUM
138 #define seqchecksum GCGchecksum
139 #else
140 #define seqchecksum CRC32checksum
141 #endif
142 
143 extern short getseqtype(const char *seq, const long seqlen );
144 extern char *compressSeq( const char gapc, const char *seq, const long seqlen, long *newlen);
145 
146 #ifdef NCBI
147 
148 extern char *listASNSeqs(const char *filename, const long skiplines,
149  const short format, short *nseq, short *error );
150 
151 extern char *readASNSeq(const short whichEntry, const char *filename,
152  const long skiplines, const short format,
153  long *seqlen, short *nseq, short *error, char **seqid );
154 #endif
155 
156 
157  /* patches for some missing string.h stuff */
158 extern int Strcasecmp(const char *a, const char *b);
159 extern int Strncasecmp(const char *a, const char *b, long maxn);
160 
161 #ifdef __cplusplus
162 }
163 #endif
164 
165 #endif /*UREADSEQ_H*/
166 
unsigned long GCGchecksum(const char *seq, const long seqlen, unsigned long *checktotal)
Definition: ureadseq.c:1420
prettyopts gPretty
Definition: ureadseq.c:31
int Strcasecmp(const char *a, const char *b)
Definition: ureadseq.c:34
AliDataPtr format(AliDataPtr data, const size_t wanted_len, GB_ERROR &error)
Definition: insdel.cxx:615
char matchchar
Definition: ureadseq.h:89
short getseqtype(const char *seq, const long seqlen)
Definition: ureadseq.c:1511
boolean noleaves
Definition: ureadseq.h:88
short seqFileFormat(const char *filename, long *skiplines, short *error)
Definition: ureadseq.c:1151
short writeSeq(FILE *outf, const char *seq, const long seqlen, const short outform, const char *seqid)
Definition: ureadseq.c:1583
FILE * seq
Definition: rns.c:46
boolean numtop
Definition: ureadseq.h:86
short seqFileFormatFp(FILE *fseq, long *skiplines, short *error)
Definition: ureadseq.c:1165
char * compressSeq(const char gapc, const char *seq, const long seqlen, long *newlen)
Definition: ureadseq.c:1545
unsigned long CRC32checksum(const char *seq, const long seqlen, unsigned long *checktotal)
Definition: ureadseq.c:1492
int Strncasecmp(const char *a, const char *b, long maxn)
Definition: ureadseq.c:48
static void error(const char *msg)
Definition: mkptypes.cxx:96
char boolean
Definition: ureadseq.h:11
boolean isactive
Definition: ureadseq.h:85
long outform
Definition: readseq.c:466
boolean nametop
Definition: ureadseq.h:87
char * listSeqs(const char *filename, const long skiplines, const short format, short *nseq, short *error)
Definition: ureadseq.c:1134
char * readSeq(const short whichEntry, const char *filename, const long skiplines, const short format, long *seqlen, short *nseq, short *error, char *seqid)
Definition: ureadseq.c:1082
char * readSeqFp(const short whichEntry_, FILE *fp_, const long skiplines_, const short format_, long *seqlen_, short *nseq_, short *error_, char *seqid_)
Definition: ureadseq.c:1033
short numline
Definition: ureadseq.h:90
short tab
Definition: ureadseq.h:92
short numwidth
Definition: ureadseq.h:91