inc/ra.h File Reference

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

hashraNextRecord (struct lineFile *lf)
hashraFromString (char *string)
boolean raFoldInOne (struct lineFile *lf, struct hash *hashOfHash)
void raFoldIn (char *fileName, struct hash *hashOfHash)
hashraReadSingle (char *fileName)
hashraReadAll (char *fileName, char *keyField)


Function Documentation

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:

boolean raFoldInOne ( struct lineFile lf,
struct hash hashOfHash 
)

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:

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:

struct hash* raNextRecord ( struct lineFile lf  )  [read]

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:


Generated on Tue Dec 25 19:13:45 2007 for blat by  doxygen 1.5.2