#include "common.h"#include "linefile.h"#include "hash.h"#include "localmem.h"#include "ra.h"Include dependency graph for ra.c:

Go to the source code of this file.
Functions | |
| hash * | raNextRecord (struct lineFile *lf) |
| hash * | raFromString (char *string) |
| char * | raFoldInOneRetName (struct lineFile *lf, struct hash *hashOfHash) |
| boolean | raFoldInOne (struct lineFile *lf, struct hash *hashOfHash) |
| void | raFoldIn (char *fileName, struct hash *hashOfHash) |
| hash * | raReadSingle (char *fileName) |
| hash * | raReadAll (char *fileName, char *keyField) |
Variables | |
| static char const | rcsid [] = "$Id: ra.c,v 1.11 2007/03/28 17:13:55 kent Exp $" |
| void raFoldIn | ( | char * | fileName, | |
| struct hash * | hashOfHash | |||
| ) |
Definition at line 150 of file ra.c.
References errAbort(), lineFile::fileName, hashAdd(), hashFree, hashLookup(), hashNew, lineFileClose(), lineFileMayOpen(), lineFile::lineIx, name, raFoldInOneRetName(), and TRUE.
00155 { 00156 struct lineFile *lf = lineFileMayOpen(fileName, TRUE); 00157 if (lf != NULL) 00158 { 00159 struct hash *uniqHash = hashNew(0); 00160 char *name; 00161 while ((name = raFoldInOneRetName(lf, hashOfHash)) != NULL) 00162 { 00163 if (hashLookup(uniqHash, name)) 00164 errAbort("%s duplicated in record ending line %d of %s", name, 00165 lf->lineIx, lf->fileName); 00166 hashAdd(uniqHash, name, NULL); 00167 } 00168 lineFileClose(&lf); 00169 hashFree(&uniqHash); 00170 } 00171 }
Here is the call graph for this function:

Definition at line 145 of file ra.c.
References raFoldInOneRetName().
00146 { 00147 return raFoldInOneRetName(lf, hashOfHash) != NULL; 00148 }
Here is the call graph for this function:

Definition at line 90 of file ra.c.
References errAbort(), lineFile::fileName, hashAdd(), hashFindVal(), hashLookup(), lineFileNext(), lineFileNextReal(), lineFile::lineIx, hash::lm, lmCloneString(), name, newHash(), nextWord(), sameString, skipLeadingSpaces(), and hashEl::val.
Referenced by raFoldIn(), and raFoldInOne().
00095 { 00096 char *word, *line, *name; 00097 struct hash *ra; 00098 struct hashEl *hel; 00099 00100 /* Get first nonempty non-comment line and make sure 00101 * it contains name. */ 00102 if (!lineFileNextReal(lf, &line)) 00103 return NULL; 00104 word = nextWord(&line); 00105 if (!sameString(word, "name")) 00106 errAbort("Expecting 'name' line %d of %s, got %s", 00107 lf->lineIx, lf->fileName, word); 00108 name = nextWord(&line); 00109 if (name == NULL) 00110 errAbort("Short name field line %d of %s", lf->lineIx, lf->fileName); 00111 00112 /* Find ra hash associated with name, making up a new 00113 * one if need be. */ 00114 if ((ra = hashFindVal(hashOfHash, name)) == NULL) 00115 { 00116 ra = newHash(7); 00117 hashAdd(hashOfHash, name, ra); 00118 hashAdd(ra, "name", lmCloneString(ra->lm, name)); 00119 } 00120 00121 /* Fill in fields of ra hash with data up to next 00122 * blank line or end of file. */ 00123 for (;;) 00124 { 00125 if (!lineFileNext(lf, &line, NULL)) 00126 break; 00127 line = skipLeadingSpaces(line); 00128 if (line[0] == 0) 00129 break; 00130 if (line[0] == '#') 00131 continue; 00132 word = nextWord(&line); 00133 line = skipLeadingSpaces(line); 00134 if (line == NULL) 00135 line = ""; 00136 hel = hashLookup(ra, word); 00137 if (hel == NULL) 00138 hel = hashAdd(ra, word, lmCloneString(ra->lm, line)); 00139 else 00140 hel->val = lmCloneString(ra->lm, line); 00141 } 00142 return hashFindVal(ra, "name"); 00143 }
Here is the call graph for this function:

Here is the caller graph for this function:

| struct hash* raFromString | ( | char * | string | ) | [read] |
Definition at line 63 of file ra.c.
References cloneString(), freeMem(), hashAdd(), hash::lm, lmCloneString(), newHash(), nextWord(), and skipLeadingSpaces().
00066 { 00067 char *dupe = cloneString(string); 00068 char *s = dupe, *lineEnd; 00069 struct hash *hash = newHash(7); 00070 char *key, *val; 00071 00072 for (;;) 00073 { 00074 s = skipLeadingSpaces(s); 00075 if (s == NULL || s[0] == 0) 00076 break; 00077 lineEnd = strchr(s, '\n'); 00078 if (lineEnd != NULL) 00079 *lineEnd++ = 0; 00080 key = nextWord(&s); 00081 val = skipLeadingSpaces(s); 00082 s = lineEnd; 00083 val = lmCloneString(hash->lm, val); 00084 hashAdd(hash, key, val); 00085 } 00086 freeMem(dupe); 00087 return hash; 00088 }
Here is the call graph for this function:

Definition at line 17 of file ra.c.
References hashAdd(), lineFileNext(), lineFileReuse(), hash::lm, lmCloneString(), newHash(), nextWord(), skipLeadingSpaces(), and startsWith().
Referenced by raReadAll(), and raReadSingle().
00023 { 00024 struct hash *hash = NULL; 00025 char *line, *key, *val; 00026 00027 /* Skip leading empty lines. */ 00028 for (;;) 00029 { 00030 if (!lineFileNext(lf, &line, NULL)) 00031 return NULL; 00032 line = skipLeadingSpaces(line); 00033 if (line[0] != 0) 00034 break; 00035 } 00036 lineFileReuse(lf); 00037 for (;;) 00038 { 00039 if (!lineFileNext(lf, &line, NULL)) 00040 break; 00041 line = skipLeadingSpaces(line); 00042 if (line[0] == 0) 00043 break; 00044 if (line[0] == '#') 00045 { 00046 if (startsWith("#EOF", line)) 00047 return NULL; 00048 else 00049 continue; 00050 } 00051 if (hash == NULL) 00052 hash = newHash(7); 00053 key = nextWord(&line); 00054 val = skipLeadingSpaces(line); 00055 if (line == NULL) 00056 line = ""; 00057 val = lmCloneString(hash->lm, val); 00058 hashAdd(hash, key, val); 00059 } 00060 return hash; 00061 }
Here is the call graph for this function:

Here is the caller graph for this function:

| struct hash* raReadAll | ( | char * | fileName, | |
| char * | keyField | |||
| ) | [read] |
Definition at line 182 of file ra.c.
References errAbort(), lineFile::fileName, hashAdd(), hashFindVal(), hashNew, lineFileClose(), lineFileOpen(), lineFile::lineIx, raNextRecord(), and TRUE.
00186 { 00187 struct lineFile *lf = lineFileOpen(fileName, TRUE); 00188 struct hash *bigHash = hashNew(0); 00189 struct hash *hash; 00190 while ((hash = raNextRecord(lf)) != NULL) 00191 { 00192 char *key = hashFindVal(hash, keyField); 00193 if (key == NULL) 00194 errAbort("Couldn't find key field %s line %d of %s", 00195 keyField, lf->lineIx, lf->fileName); 00196 hashAdd(bigHash, key, hash); 00197 } 00198 lineFileClose(&lf); 00199 return bigHash; 00200 }
Here is the call graph for this function:

| struct hash* raReadSingle | ( | char * | fileName | ) | [read] |
Definition at line 173 of file ra.c.
References lineFileClose(), lineFileOpen(), raNextRecord(), and TRUE.
00175 { 00176 struct lineFile *lf = lineFileOpen(fileName, TRUE); 00177 struct hash *hash = raNextRecord(lf); 00178 lineFileClose(&lf); 00179 return hash; 00180 }
Here is the call graph for this function:

char const rcsid[] = "$Id: ra.c,v 1.11 2007/03/28 17:13:55 kent Exp $" [static] |
1.5.2