Mercurial > repos > dawe > srf2fastq
annotate srf2fastq/io_lib-1.12.2/io_lib/traceType.c @ 0:d901c9f41a6a default tip
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
author | dawe |
---|---|
date | Tue, 07 Jun 2011 17:48:05 -0400 |
parents | |
children |
rev | line source |
---|---|
0
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
1 /* |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
2 * Copyright (c) Medical Research Council 1994. All rights reserved. |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
3 * |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
4 * Permission to use, copy, modify and distribute this software and its |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
5 * documentation for any purpose is hereby granted without fee, provided that |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
6 * this copyright and notice appears in all copies. |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
7 * |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
8 * This file was written by James Bonfield, Simon Dear, Rodger Staden, |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
9 * as part of the Staden Package at the MRC Laboratory of Molecular |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
10 * Biology, Hills Road, Cambridge, CB2 2QH, United Kingdom. |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
11 * |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
12 * MRC disclaims all warranties with regard to this software. |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
13 */ |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
14 |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
15 /* |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
16 Title: traceType |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
17 |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
18 File: traceType.c |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
19 Purpose: determining trace format |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
20 |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
21 Last update: 01/09/94 |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
22 |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
23 Change log : Update for use with the Read library. |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
24 */ |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
25 |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
26 /* ---- Imports ---- */ |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
27 |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
28 #include <stdio.h> |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
29 #include <stdlib.h> |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
30 #include <unistd.h> |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
31 |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
32 #include "io_lib/stdio_hack.h" |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
33 |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
34 #include "io_lib/traceType.h" |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
35 #include "io_lib/Read.h" |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
36 #include "io_lib/open_trace_file.h" |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
37 |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
38 #ifdef USE_BIOLIMS |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
39 #include "spBiolims.h" |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
40 #endif |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
41 |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
42 #ifndef isascii |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
43 #define isascii(c) ((c) >= 0 && (c) <= 0x7f) |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
44 #endif |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
45 |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
46 /* ---- Privates ---- */ |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
47 static struct { |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
48 int type; |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
49 int offset; |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
50 char *string; |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
51 } magics[] = { |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
52 { TT_SCF, 0, ".scf" } , |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
53 { TT_CTF, 1, "\007\375\343\000" } , /* mieg */ |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
54 { TT_ZTR, 0, "\256ZTR\r\n\032\n" } , |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
55 { TT_ABI, 0, "ABIF" } , |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
56 { TT_ABI, 128, "ABIF" } , |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
57 { TT_ALF, 518, "ALF " } , |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
58 { TT_SCF, 0, "\234\330\300\000" }, /* Amersham variant */ |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
59 { TT_SFF, 0, ".sff" } , |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
60 { TT_EXP, 0, "ID " } , |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
61 { TT_ALF, 0, "ALF " } , /* Added by newer alfsplit programs */ |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
62 { TT_ALF, 0, "\021G\021G" } , /* Pharmacia's alfsplit equiv */ |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
63 { TT_ALF, 1546,"X-axis" } /* Good guestimation if all else fails */ |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
64 }; |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
65 |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
66 #define Number(A) ( sizeof(A) / sizeof((A)[0]) ) |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
67 |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
68 /* ---- exported ---- */ |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
69 |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
70 /* unix specific file deletion routine */ |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
71 int remove_file(char *fn) { return unlink(fn); } |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
72 |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
73 |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
74 /* |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
75 * Determine the trace type for FILE * 'fp'. |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
76 * |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
77 * NB - This function should NOT be used when biolims support is required |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
78 * (as biolims doesn't use files !) |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
79 * |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
80 * Returns: |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
81 * TT_SCF, TT_CTF, TT_ZTR, TT_ABI, TT_ALF, or TT_PLN for success. |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
82 * TT_UNK for unknown type. |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
83 * TT_ERR for error. |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
84 */ |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
85 int fdetermine_trace_type(FILE *fp) |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
86 { |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
87 unsigned int i; |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
88 size_t len; |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
89 char buf[512]; |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
90 int ps; |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
91 int acgt; |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
92 int c; |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
93 |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
94 /* check magics */ |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
95 for (i = 0 ; i < Number(magics) ; i++) { |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
96 if (fseek(fp,magics[i].offset,0) == 0) { |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
97 len = strlen(magics[i].string); |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
98 if (fread(buf,1,len,fp)==len) { |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
99 if (strncmp(buf,magics[i].string,len)==0) { |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
100 return magics[i].type; |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
101 } |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
102 } |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
103 } |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
104 } |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
105 fseek(fp, 0, 0); |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
106 |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
107 /* determine if this is a text file */ |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
108 len = 0; ps = 0; acgt = 0; |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
109 for (i = 0; i < 512; i++) { |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
110 if ( ( c = fgetc(fp) ) == EOF ) break; |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
111 switch(c) { |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
112 case 'a': case 'c': case 'g': case 't': |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
113 case 'A': case 'C': case 'G': case 'T': |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
114 /*YUK! need the next line?*/ |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
115 case 'n': case 'N': case '-': |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
116 acgt++; |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
117 default: |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
118 len++; |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
119 if ( (isprint(c) && isascii(c)) || isspace(c) ) ps++; |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
120 } |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
121 } |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
122 fseek(fp, 0, 0); |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
123 /*YUK! 75% of characters printable means text*/ |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
124 if ( 100 * (size_t)ps > 75 * len ) { |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
125 /*YUK! 75% of printables ACGTN means plain*/ |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
126 if (100 * acgt > 75 * ps) { |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
127 return TT_PLN; |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
128 } |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
129 } |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
130 |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
131 /* YUK! short files are not traces? */ |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
132 if (len<512) { |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
133 return TT_UNK; |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
134 } |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
135 |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
136 return TT_UNK; |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
137 } |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
138 |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
139 /* |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
140 * Determine the trace type for file 'fn'. |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
141 * |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
142 * Returns: |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
143 * TT_SCF, TT_CTF, TT_ZTR, TT_ABI, TT_ALF, TT_BIO, or TT_PLN for success. |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
144 * TT_UNK for unknown type. |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
145 * TT_ERR for error. |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
146 */ |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
147 int determine_trace_type(char *fn) |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
148 { |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
149 FILE *fp; |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
150 int r; |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
151 |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
152 #ifdef USE_BIOLIMS |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
153 if(IS_BIOLIMS_PATH(fn)) |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
154 return TT_BIO; |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
155 #endif |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
156 |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
157 if ( (fp = open_trace_file(fn, NULL)) == NULL ) return TT_ERR; |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
158 |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
159 r = fdetermine_trace_type(fp); |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
160 fclose(fp); |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
161 |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
162 return r; |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
163 } |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
164 |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
165 /* |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
166 * Converts a trace type string to an integer. |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
167 */ |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
168 int trace_type_str2int(char *str) { |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
169 if (strcmp(str, "SCF") == 0 || strcmp(str, "scf") == 0) |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
170 return TT_SCF; |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
171 else if (strcmp(str, "SFF") == 0 || strcmp(str, "sff") == 0) |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
172 return TT_SFF; /* 454 */ |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
173 else if (strcmp(str, "CTF") == 0 || strcmp(str, "ctf") == 0) |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
174 return TT_CTF; /* mieg */ |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
175 else if (strcmp(str, "ZTR") == 0 || strcmp(str, "ztr") == 0) |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
176 return TT_ZTR; |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
177 else if (strcmp(str, "ZTR1") == 0 || strcmp(str, "ztr1") == 0) |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
178 return TT_ZTR1; |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
179 else if (strcmp(str, "ZTR2") == 0 || strcmp(str, "ztr2") == 0) |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
180 return TT_ZTR2; |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
181 else if (strcmp(str, "ZTR3") == 0 || strcmp(str, "ztr3") == 0) |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
182 return TT_ZTR3; |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
183 else if (strcmp(str, "ABI") == 0 || strcmp(str, "abi") == 0) |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
184 return TT_ABI; |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
185 else if (strcmp(str, "ALF") == 0 || strcmp(str, "alf") == 0) |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
186 return TT_ALF; |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
187 else if (strcmp(str, "PLN") == 0 || strcmp(str, "pln") == 0) |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
188 return TT_PLN; |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
189 else if (strcmp(str, "EXP") == 0 || strcmp(str, "exp") == 0) |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
190 return TT_EXP; |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
191 else if (strcmp(str, "BIO") == 0 || strcmp(str, "bio") == 0) |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
192 return TT_BIO; |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
193 else if (strcmp(str, "ANYTR") == 0 || strcmp(str, "anytr") == 0) |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
194 return TT_ANYTR; |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
195 else |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
196 return TT_UNK; |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
197 } |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
198 |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
199 /* |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
200 * Converts a trace type integer to a string. |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
201 */ |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
202 char *trace_type_int2str(int type) { |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
203 char *t; |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
204 |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
205 switch(type) { |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
206 case TT_SCF: t = "SCF"; break; |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
207 case TT_SFF: t = "SFF"; break; /* 454 */ |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
208 case TT_CTF: t = "CTF"; break; /* mieg */ |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
209 case TT_ZTR: t = "ZTR";break; |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
210 case TT_ZTR1: t = "ZTR1";break; |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
211 case TT_ZTR2: t = "ZTR2";break; |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
212 case TT_ZTR3: t = "ZTR3";break; |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
213 case TT_ABI: t = "ABI"; break; |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
214 case TT_ALF: t = "ALF"; break; |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
215 case TT_PLN: t = "PLN"; break; |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
216 case TT_EXP: t = "EXP"; break; |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
217 case TT_BIO: t = "BIO"; break; |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
218 case TT_ANYTR: t="ANYTR"; break; |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
219 default: |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
220 case TT_UNK: t = "UNK"; break; |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
221 } |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
222 |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
223 return t; |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
224 } |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
225 |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
226 /* |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
227 * Returns a statically declared string containing a 3 character |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
228 * identifier for the trace type of this file. |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
229 * "ERR" represents error, and "UNK" for unknown. |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
230 * Successful values are "SCF", "ABI", "ALF", "PLN", "CTF", "ZTR" and "BIO". |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
231 */ |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
232 char *trace_type_str(char *traceName) |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
233 { |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
234 int t; |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
235 |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
236 if ((t = determine_trace_type(traceName)) == TT_ERR) |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
237 return "ERR"; |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
238 else |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
239 return trace_type_int2str(t); |
d901c9f41a6a
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
dawe
parents:
diff
changeset
|
240 } |