inc/tabRow.h File Reference

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

Go to the source code of this file.

Data Structures

struct  tabRow

Functions

tabRowtabRowNew (int colCount)
int tabRowMaxColCount (struct tabRow *rowList)
tabRowtabRowByWhite (struct slName *lineList, char *fileName, boolean varCol)
tabRowtabRowByChar (struct slName *lineList, char c, char *fileName, boolean varCol)
tabRowtabRowByFixedOffsets (struct slName *lineList, struct slInt *offList, char *fileName)
tabRowtabRowByFixedGuess (struct slName *lineList, char *fileName)
slInttabRowGuessFixedOffsets (struct slName *lineList, char *fileName)


Function Documentation

struct tabRow* tabRowByChar ( struct slName lineList,
char  c,
char *  fileName,
boolean  varCol 
) [read]

Definition at line 76 of file tabRow.c.

References chopByChar(), countChars(), errAbort(), slName::name, slName::next, slAddHead, and tabRowNew().

00080 {
00081 struct slName *line;
00082 struct tabRow *rowList = NULL, *row;
00083 
00084 if (varCol)
00085     {
00086     for (line = lineList; line != NULL; line = line->next)
00087         {
00088         char *s = line->name;
00089         int rowSize = countChars(s, c) + 1;
00090         row = tabRowNew(rowSize);
00091         chopByChar(s, c, row->columns, rowSize);
00092         slAddHead(&rowList, row);
00093         }
00094     }
00095 else
00096     {
00097     if (lineList)
00098         {
00099         int rowSize = countChars(lineList->name, c) + 1;
00100         int extraSize = rowSize+1;
00101         int ix = 1;
00102         for (line = lineList; line != NULL; line = line->next, ++ix)
00103             {
00104             int oneSize;
00105             row = tabRowNew(rowSize);
00106             oneSize = chopByChar(line->name, c, row->columns, extraSize);
00107             if (oneSize != rowSize)
00108                 {
00109                 if (oneSize > rowSize)
00110                     errAbort("Got more than the expected %d columns line %d of %s",
00111                             rowSize, ix, fileName);
00112                 else
00113                     errAbort("Expecting %d columns got %d, line %d of %s",
00114                         rowSize, oneSize, ix, fileName);
00115 
00116                 }
00117             slAddHead(&rowList, row);
00118             }
00119         }
00120     }
00121 return rowList;
00122 }

Here is the call graph for this function:

struct tabRow* tabRowByFixedGuess ( struct slName lineList,
char *  fileName 
) [read]

Definition at line 220 of file tabRow.c.

References slFreeList(), tabRowByFixedOffsets(), and tabRowGuessFixedOffsets().

00222 {
00223 struct slInt *offList = tabRowGuessFixedOffsets(lineList, fileName);
00224 struct tabRow *rowList = tabRowByFixedOffsets(lineList, offList, fileName);
00225 slFreeList(&offList);
00226 return rowList;
00227 }

Here is the call graph for this function:

struct tabRow* tabRowByFixedOffsets ( struct slName lineList,
struct slInt offList,
char *  fileName 
) [read]

Definition at line 171 of file tabRow.c.

References errAbort(), slName::name, slInt::next, slName::next, slAddHead, slCount(), slReverse(), tabRowNew(), trimSpaces(), and slInt::val.

Referenced by tabRowByFixedGuess().

00175 {
00176 struct slName *line;
00177 struct slInt *off;
00178 struct tabRow *rowList = NULL, *row;
00179 int rowSize = slCount(offList);
00180 
00181 if (lineList)
00182     {
00183     int lineSize = strlen(lineList->name);
00184     int lineIx = 1;
00185     for (off = offList; off != NULL; off = off->next)
00186         {
00187         if (off->val >= lineSize)
00188             errAbort("Offset %d is bigger than lineSize of %d", off->val, lineSize);
00189         }
00190     for (line = lineList; line != NULL; line = line->next, ++lineIx)
00191         {
00192         char *linePt = line->name;
00193         int offIx = 0;
00194         if (strlen(linePt) != lineSize)
00195            errAbort("Line %d of %s has %lu chars, but first line has just %d",
00196                lineIx, fileName, (unsigned long)strlen(linePt), lineSize);
00197         row = tabRowNew(rowSize);
00198         for (off = offList; off != NULL; off = off->next, ++offIx)
00199             {
00200             int start = off->val, end;
00201             if (off->next != NULL)
00202                 {
00203                 end = off->next->val-1;
00204                 if (linePt[end] != ' ')
00205                    errAbort("Line %d of %s expecting space column %d, got %c",
00206                            lineIx, fileName, end, linePt[end]);
00207                 }
00208             else
00209                 end = lineSize;
00210             linePt[end] = 0;
00211             row->columns[offIx] = trimSpaces(linePt + start);
00212             }
00213         slAddHead(&rowList, row);
00214         }
00215     slReverse(&rowList);
00216     }
00217 return rowList;
00218 }

Here is the call graph for this function:

Here is the caller graph for this function:

struct tabRow* tabRowByWhite ( struct slName lineList,
char *  fileName,
boolean  varCol 
) [read]

Definition at line 27 of file tabRow.c.

References chopByWhite(), errAbort(), slName::name, slName::next, slAddHead, slReverse(), and tabRowNew().

00031 {
00032 struct slName *line;
00033 struct tabRow *rowList = NULL, *row;
00034 
00035 if (varCol)
00036     {
00037     for (line = lineList; line != NULL; line = line->next)
00038         {
00039         char *s = line->name;
00040         int rowSize = chopByWhite(s, NULL, 0);
00041         row = tabRowNew(rowSize);
00042         chopByWhite(s, row->columns, rowSize);
00043         slAddHead(&rowList, row);
00044         }
00045     }
00046 else
00047     {
00048     if (lineList)
00049         {
00050         int rowSize = chopByWhite(lineList->name, NULL, 0);
00051         int extraSize = rowSize+1;
00052         int ix = 1;
00053         for (line = lineList; line != NULL; line = line->next, ++ix)
00054             {
00055             int oneSize;
00056             row = tabRowNew(rowSize);
00057             oneSize = chopByWhite(line->name, row->columns, extraSize);
00058             if (oneSize != rowSize)
00059                 {
00060                 if (oneSize > rowSize)
00061                     errAbort("Got more than the expected %d columns line %d of %s",
00062                             rowSize, ix, fileName);
00063                 else
00064                     errAbort("Expecting %d columns got %d, line %d of %s",
00065                         rowSize, oneSize, ix, fileName);
00066 
00067                 }
00068             slAddHead(&rowList, row);
00069             }
00070         }
00071     }
00072 slReverse(&rowList);
00073 return rowList;
00074 }

Here is the call graph for this function:

struct slInt* tabRowGuessFixedOffsets ( struct slName lineList,
char *  fileName 
) [read]

Definition at line 124 of file tabRow.c.

References AllocVar, cloneString(), errAbort(), slName::name, slName::next, skipLeadingSpaces(), skipToSpaces(), slAddHead, and slReverse().

Referenced by tabRowByFixedGuess().

00127 {
00128 struct slInt *offList = NULL, *off;
00129 
00130 if (lineList)
00131     {
00132     char *spaceRec = cloneString(lineList->name), *s;
00133     int lineSize = strlen(spaceRec);
00134     struct slName *line;
00135     int lineIx=1;
00136 
00137     /* First 'or' together all lines into spaceRec, which will
00138      * have a space wherever all columns of all lines are space and
00139      * non-space elsewhere. */
00140     for (line = lineList->next; line != NULL; line = line->next, ++lineIx)
00141         {
00142         int i;
00143         s = line->name;
00144         if (strlen(s) != lineSize)
00145            errAbort("Line %d of %s has %lu chars, but first line has just %d",
00146                lineIx, fileName, (unsigned long)strlen(s), lineSize);
00147         for (i=0; i<lineSize; ++i)
00148             {
00149             if (s[i] != ' ')
00150                 spaceRec[i] = 'X';
00151             }
00152         }
00153 
00154     /* Now make up slInt list that describes where words begin */
00155     s = spaceRec;
00156     for (;;)
00157         {
00158         s = skipLeadingSpaces(s);
00159         if (s == NULL || s[0] == 0)
00160             break;
00161         AllocVar(off);
00162         off->val = s - spaceRec;
00163         slAddHead(&offList, off);
00164         s = skipToSpaces(s);
00165         }
00166     slReverse(&offList);
00167     }
00168 return offList;
00169 }

Here is the call graph for this function:

Here is the caller graph for this function:

int tabRowMaxColCount ( struct tabRow rowList  ) 

Definition at line 16 of file tabRow.c.

References tabRow::colCount, and tabRow::next.

00018 {
00019 int maxCount = 0;
00020 struct tabRow *row;
00021 for (row = rowList; row != NULL; row = row->next)
00022     if (row->colCount > maxCount)
00023         maxCount = row->colCount;
00024 return maxCount;
00025 }

struct tabRow* tabRowNew ( int  colCount  )  [read]

Definition at line 8 of file tabRow.c.

References needMem().

Referenced by tabRowByChar(), tabRowByFixedOffsets(), and tabRowByWhite().

00010 {
00011 struct tabRow *row = needMem(sizeof(*row) + colCount*sizeof(char*));
00012 row->colCount = colCount;
00013 return row;
00014 }

Here is the call graph for this function:

Here is the caller graph for this function:


Generated on Tue Dec 25 19:17:11 2007 for blat by  doxygen 1.5.2