home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Source Code / Libraries / DCLAP 4j / DBio / ureadseq.h < prev   
Encoding:
C/C++ Source or Header  |  1995-12-17  |  5.9 KB  |  234 lines  |  [TEXT/R*ch]

  1. /* File: ureadseq.h
  2.  *
  3.  * Header for module UReadSeq
  4.  */
  5.  
  6. #ifndef UREADSEQ_H
  7. #define UREADSEQ_H
  8.  
  9. #ifdef __cplusplus
  10. extern "C" {
  11. #endif
  12.  
  13. #ifndef boolean
  14. #ifdef _NCBI_
  15. #define boolean Nlm_Boolean
  16. #else
  17. typedef unsigned char boolean;
  18. #endif
  19. #endif
  20.  
  21. #ifndef false
  22. #define false 0
  23. #endif
  24. #ifndef true
  25. #define true  1
  26. #endif
  27.  
  28. #ifndef NEWLINE
  29. #define NEWLINE         '\n'
  30. #endif
  31. #ifndef min
  32. #define min(a,b)      (a<b)?a:b
  33. #endif
  34. #ifndef max
  35. #define max(a,b)      (a>b)?a:b
  36. #endif
  37. #ifndef skipwhitespace
  38. #define skipwhitespace(string)  {while (*string <= ' ' && *string != 0) string++;}
  39. #endif
  40.  
  41.   /* NLM strings */
  42. #ifndef is_upper
  43. #define is_upper(c) ('A'<=(c) && (c)<='Z')
  44. #endif
  45. #ifndef is_lower
  46. #define is_lower(c) ('a'<=(c) && (c)<='z')
  47. #endif
  48. #ifndef to_lower
  49. #define to_lower(c) ((char)(is_upper(c) ? (c)+' ' : (c)))
  50. #endif
  51. #ifndef to_upper
  52. #define to_upper(c) ((char)(is_lower(c) ? (c)-' ' : (c)))
  53. #endif
  54.  
  55.  
  56.   /* readSeq errors */
  57. #define eFileNotFound   -1
  58. #define eNoData         -2
  59. #define eMemFull        -3
  60. #define eItemNotFound   -4
  61. #define eOneFormat      -5
  62. #define eUnequalSize    -6
  63. #define eFileCreate     -7
  64. #define eUnknownFormat  -8
  65. #define eOptionBad      -9
  66. #define eASNerr         -10
  67.  
  68.   /* magic number for readSeq(whichEntry) to give seq list */
  69. #define kListSequences  -1
  70.  
  71.  
  72.     /* name space collisions !! damn defines */
  73. #ifdef UREADSEQ_G
  74.  
  75.   /* sequence types parsed by getseqtype */
  76. #define kOtherSeq   0
  77. #define kDNA        1
  78. #define kRNA        2
  79. #define kNucleic    3
  80. #define kAmino      4
  81.  
  82.   /* formats known to readSeq */
  83. #define kIG             1
  84. #define kGenBank        2
  85. #define kNBRF           3
  86. #define kEMBL           4
  87. #define kGCG            5
  88. #define kStrider        6
  89. #define kFitch          7
  90. #define kPearson        8
  91. #define kZuker          9
  92. #define kOlsen          10
  93. #define kPhylip2        11
  94. #define kPhylip4        12
  95. #define kPhylip3        kPhylip4
  96. #define kPhylip         kPhylip4
  97. #define kPlain          13  /* keep this at #13 */
  98. #define kPIR            14
  99. #define kMSF            15
  100. #define kASN1           16
  101. #define kPAUP           17
  102. #define kPretty         18
  103.  
  104. #define kMaxFormat      18
  105. #define kMinFormat      1
  106. #define kNoformat       -1    /* format not tested */
  107. #define kUnknown        0     /* format not determinable */
  108.  
  109.   /* subsidiary types */
  110. #define kASNseqentry    51
  111. #define kASNseqset      52
  112.  
  113. #define kPhylipInterleave 61
  114. #define kPhylipSequential 62
  115.  
  116.  
  117. #define kRSFile_Eof            1
  118. #define kRSFile_Read        2
  119. #define kRSFile_Write        3
  120. #define kRSFile_Seek        4
  121. #define kRSFile_Rewind        5
  122. #define kRSFile_Tell        6
  123.  
  124. #endif
  125.  
  126.  
  127. typedef struct {
  128.   boolean isactive, baseonlynum,
  129.         numright, numleft, numtop, numbot,
  130.         nameright, nameleft, nametop,
  131.         noleaves, domatch, degap;
  132.   char  matchchar, gapchar;
  133.   short numline, atseq,
  134.         namewidth, numwidth,
  135.         interline, spacer, seqwidth, tab;
  136.   } prettyopts;
  137.  
  138.  
  139. #define gPrettyInit(p) { \
  140.   p.isactive=false;\
  141.   p.baseonlynum=true;\
  142.   p.numline= p.atseq= 0;\
  143.   p.numright= p.numtop= true; \
  144.   p.numleft= p.numbot= false;\
  145.   p.nameright= true; \
  146.   p.nameleft= p.nametop= false;\
  147.   p.noleaves= p.domatch= p.degap= false;\
  148.   p.matchchar='.';\
  149.   p.gapchar='-';\
  150.   p.namewidth=8;\
  151.   p.numwidth=5;\
  152.   p.interline=1;\
  153.   p.spacer=10;\
  154.   p.seqwidth=50;\
  155.   p.tab=0; }
  156.  
  157. #ifdef UREADSEQ_G
  158. prettyopts  gPretty;
  159. #else
  160. extern  prettyopts  gPretty;
  161. #endif
  162.  
  163.  
  164.  
  165. typedef  long (*ReadWriteProc)( char* line, long maxline, short action);
  166.  
  167. extern short seqFileFormat(const char *filename, long *skiplines, short *error );
  168. extern short seqFileFormatFp(FILE *fseq, long  *skiplines, short *error );
  169. extern short seqFileFormatCall(ReadWriteProc reader, long *skiplines, short *error );
  170.  
  171. extern char *listSeqs(const char *filename, const long skiplines,
  172.                        const short format, short *nseq, short *error );
  173.                                              
  174. extern char *listSeqsCall(ReadWriteProc reader, const long skiplines,
  175.                        const short format, short *nseq, short *error );
  176.  
  177.  
  178. extern char *readSeq(const short whichEntry, const char *filename,
  179.                       const long skiplines, const short format,
  180.                       long *seqlen, short *nseq, short *error, char *seqid );
  181.  
  182. extern char *readSeqFp(const short whichEntry, FILE  *fp,
  183.                                      const long  skiplines, const short format,
  184.                                long  *seqlen,  short *nseq, short *error, char *seqid );
  185.  
  186. extern char *readSeqCall(const short whichEntry, ReadWriteProc reader,
  187.                       const long skiplines, const short format,
  188.                       long *seqlen, short *nseq, short *error, char *seqid );
  189.  
  190.  
  191.                                 
  192. extern short writeSeq(FILE *outf, const char *seq, const long seqlen,
  193.                        const short outform, const char *seqid );
  194.  
  195. extern short writeSeqCall(ReadWriteProc writer, const char *seq, const long seqlen,
  196.                 const short outform, const char *seqid);
  197.  
  198. extern unsigned long CRC32checksum(const char *seq, const long seqlen, unsigned long *checktotal);
  199. extern unsigned long GCGchecksum(const char *seq, const long seqlen, unsigned long *checktotal);
  200.  
  201. #ifdef SMALLCHECKSUM
  202. #define seqchecksum  GCGchecksum
  203. #else
  204. #define seqchecksum  CRC32checksum
  205. #endif
  206.  
  207. extern short getseqtype(const char *seq, const long seqlen );
  208. extern void GetSeqStats( const char* seq, const long seqlen, 
  209.                             short* seqtype, unsigned long* checksum, long* basecount);
  210. extern char *compressSeq( const char gapc, const char *seq, const long seqlen, long *newlen);
  211.  
  212.  
  213. #ifdef NCBI
  214.  
  215. extern char *listASNSeqs(const char *filename, const long skiplines,
  216.                   const short format, short *nseq, short *error );
  217.  
  218. extern char *readASNSeq(const short whichEntry, const char *filename,
  219.                 const long skiplines, const short format,
  220.                 long *seqlen, short *nseq, short *error, char **seqid );
  221. #endif
  222.  
  223.  
  224.   /* patches for some missing string.h stuff */
  225. /* extern int Strcasecmp(const char *a, const char *b); */
  226. /* extern int Strncasecmp(const char *a, const char *b, long maxn); */
  227.  
  228. #ifdef __cplusplus
  229. }
  230. #endif
  231.  
  232. #endif /*UREADSEQ_H*/
  233.  
  234.