lib/repMask.c

Go to the documentation of this file.
00001 /* repMask.c was originally generated by the autoSql program, which also 
00002  * generated repMask.h and repMask.sql.  This module links the database and the RAM 
00003  * representation of objects. */
00004 
00005 #include "common.h"
00006 #include "sqlList.h"
00007 #include "sqlNum.h"
00008 #include "repMask.h"
00009 
00010 static char const rcsid[] = "$Id: repMask.c,v 1.6 2005/04/10 14:41:25 markd Exp $";
00011 
00012 void repeatMaskOutStaticLoad(char **row, struct repeatMaskOut *ret)
00013 /* Load a row from repeatMaskOut table into ret.  The contents of ret will
00014  * be replaced at the next call to this function. */
00015 {
00016 int i;
00017 
00018 ret->score = sqlUnsigned(row[0]);
00019 ret->percDiv = atof(row[1]);
00020 ret->percDel = atof(row[2]);
00021 ret->percInc = atof(row[3]);
00022 ret->qName = row[4];
00023 ret->qStart = sqlSigned(row[5]);
00024 ret->qEnd = sqlSigned(row[6]);
00025 ret->qLeft = row[7];
00026 strcpy(ret->strand, row[8]);
00027 ret->rName = row[9];
00028 ret->rFamily = row[10];
00029 ret->rStart = row[11];  /* sometimes this number is enclosed in (parens) */
00030 /* This row[12] is interpreted as an Unsigned - but I can find no good reason
00031  * for it to be an error exit when there is a negative number here.
00032  * The only programs that use this routine are blat, psLayout and
00033  * maskOutFa and none of them even use this number for anything.
00034  * For data base loading of the rmsk tracks, these .out files are parsed
00035  * by hgLoadOut and none of this business is referenced.
00036  */
00037 i = sqlSigned(row[12]);
00038 if( i < 0 ) {
00039     warn("WARNING: negative rEnd: %d %s:%d-%d %s", i, ret->qName, ret->qStart, ret->qEnd, ret->rName);
00040     ret->rEnd = 0;
00041 } else {
00042 ret->rEnd = sqlUnsigned(row[12]);
00043 }
00044 ret->rLeft = row[13];
00045 }
00046 
00047 struct repeatMaskOut *repeatMaskOutLoad(char **row)
00048 /* Load a repeatMaskOut from row fetched with select * from repeatMaskOut
00049  * from database.  Dispose of this with repeatMaskOutFree(). */
00050 {
00051 struct repeatMaskOut *ret;
00052 
00053 AllocVar(ret);
00054 ret->score = sqlUnsigned(row[0]);
00055 ret->percDiv = atof(row[1]);
00056 ret->percDel = atof(row[2]);
00057 ret->percInc = atof(row[3]);
00058 ret->qName = cloneString(row[4]);
00059 ret->qStart = sqlSigned(row[5]);
00060 ret->qEnd = sqlSigned(row[6]);
00061 ret->qLeft = cloneString(row[7]);
00062 strcpy(ret->strand, row[8]);
00063 ret->rName = cloneString(row[9]);
00064 ret->rFamily = cloneString(row[10]);
00065 ret->rStart = cloneString(row[11]);
00066 ret->rEnd = sqlUnsigned(row[12]);
00067 ret->rLeft = cloneString(row[13]);
00068 return ret;
00069 }
00070 
00071 struct repeatMaskOut *repeatMaskOutCommaIn(char **pS)
00072 /* Create a repeatMaskOut out of a comma separated string. */
00073 {
00074 struct repeatMaskOut *ret;
00075 char *s = *pS;
00076 
00077 AllocVar(ret);
00078 ret->score = sqlUnsignedComma(&s);
00079 ret->percDiv = sqlSignedComma(&s);
00080 ret->percDel = sqlSignedComma(&s);
00081 ret->percInc = sqlSignedComma(&s);
00082 ret->qName = sqlStringComma(&s);
00083 ret->qStart = sqlSignedComma(&s);
00084 ret->qEnd = sqlSignedComma(&s);
00085 ret->qLeft = sqlStringComma(&s);
00086 sqlFixedStringComma(&s, ret->strand, sizeof(ret->strand));
00087 ret->rName = sqlStringComma(&s);
00088 ret->rFamily = sqlStringComma(&s);
00089 ret->rStart = sqlStringComma(&s);
00090 ret->rEnd = sqlUnsignedComma(&s);
00091 ret->rLeft = sqlStringComma(&s);
00092 *pS = s;
00093 return ret;
00094 }
00095 
00096 void repeatMaskOutFree(struct repeatMaskOut **pEl)
00097 /* Free a single dynamically allocated repeatMaskOut such as created
00098  * with repeatMaskOutLoad(). */
00099 {
00100 struct repeatMaskOut *el;
00101 
00102 if ((el = *pEl) == NULL) return;
00103 freeMem(el->qName);
00104 freeMem(el->qLeft);
00105 freeMem(el->rName);
00106 freeMem(el->rFamily);
00107 freeMem(el->rStart);
00108 freeMem(el->rLeft);
00109 freez(pEl);
00110 }
00111 
00112 void repeatMaskOutFreeList(struct repeatMaskOut **pList)
00113 /* Free a list of dynamically allocated repeatMaskOut's */
00114 {
00115 struct repeatMaskOut *el, *next;
00116 
00117 for (el = *pList; el != NULL; el = next)
00118     {
00119     next = el->next;
00120     repeatMaskOutFree(&el);
00121     }
00122 *pList = NULL;
00123 }
00124 
00125 void repeatMaskOutOutput(struct repeatMaskOut *el, FILE *f, char sep, char lastSep) 
00126 /* Print out repeatMaskOut.  Separate fields with sep. Follow last field with lastSep. */
00127 {
00128 fprintf(f, "%u", el->score);
00129 fputc(sep,f);
00130 fprintf(f, "%f", el->percDiv);
00131 fputc(sep,f);
00132 fprintf(f, "%f", el->percDel);
00133 fputc(sep,f);
00134 fprintf(f, "%f", el->percInc);
00135 fputc(sep,f);
00136 if (sep == ',') fputc('"',f);
00137 fprintf(f, "%s", el->qName);
00138 if (sep == ',') fputc('"',f);
00139 fputc(sep,f);
00140 fprintf(f, "%d", el->qStart);
00141 fputc(sep,f);
00142 fprintf(f, "%d", el->qEnd);
00143 fputc(sep,f);
00144 if (sep == ',') fputc('"',f);
00145 fprintf(f, "%s", el->qLeft);
00146 if (sep == ',') fputc('"',f);
00147 fputc(sep,f);
00148 if (sep == ',') fputc('"',f);
00149 fprintf(f, "%s", el->strand);
00150 if (sep == ',') fputc('"',f);
00151 fputc(sep,f);
00152 if (sep == ',') fputc('"',f);
00153 fprintf(f, "%s", el->rName);
00154 if (sep == ',') fputc('"',f);
00155 fputc(sep,f);
00156 if (sep == ',') fputc('"',f);
00157 fprintf(f, "%s", el->rFamily);
00158 if (sep == ',') fputc('"',f);
00159 fputc(sep,f);
00160 if (sep == ',') fputc('"',f);
00161 fprintf(f, "%s", el->rStart);
00162 if (sep == ',') fputc('"',f);
00163 fputc(sep,f);
00164 fprintf(f, "%u", el->rEnd);
00165 fputc(sep,f);
00166 if (sep == ',') fputc('"',f);
00167 fprintf(f, "%s", el->rLeft);
00168 if (sep == ',') fputc('"',f);
00169 fputc(lastSep,f);
00170 }
00171 

Generated on Tue Dec 25 18:39:31 2007 for blat by  doxygen 1.5.2