예제 #1
0
파일: xp.c 프로젝트: JinfengChen/pblat
void xpFree(struct xp **pXp)
/* Free up an xp parser. */
{
int i;
struct xp *xp = *pXp;
if (xp != NULL)
    {
    struct xpStack *stack;
    for (stack = xp->stackBufEnd; --stack >= xp->stackBuf; )
        {
	if (stack->tag == NULL)
	    break;
	freeDyString(&stack->tag);
	freeDyString(&stack->text);
	}
    for (i=0; i<ArraySize(xp->attDyBuf); ++i)
        {
	if (xp->attDyBuf[i] == NULL)
	    break;
	freeDyString(&xp->attDyBuf[i]);
	}
    freeDyString(&xp->endTag);
    freeMem(xp->fileName);
    hashFree(&xp->symHash);
    freez(pXp);
    }
}
void taxonGeneticCodeSaveToDbEscaped(struct sqlConnection *conn, struct taxonGeneticCode *el, char *tableName, int updateSize)
/* Save taxonGeneticCode as a row to the table specified by tableName.
 * As blob fields may be arbitrary size updateSize specifies the approx size.
 * of a string that would contain the entire query. Automatically
 * escapes all simple strings (not arrays of string) but may be slower than taxonGeneticCodeSaveToDb().
 * For example automatically copies and converts:
 * "autosql's features include" --> "autosql\'s features include"
 * before inserting into database. */
{
    struct dyString *update = newDyString(updateSize);
    char  *abbr, *name, *tranlsation, *starts, *comments;
    abbr = sqlEscapeString(el->abbr);
    name = sqlEscapeString(el->name);
    tranlsation = sqlEscapeString(el->tranlsation);
    starts = sqlEscapeString(el->starts);
    comments = sqlEscapeString(el->comments);

    dyStringPrintf(update, "insert into %s values ( %u,'%s','%s','%s','%s','%s')",
                   tableName, el->id ,  abbr,  name,  tranlsation,  starts,  comments);
    sqlUpdate(conn, update->string);
    freeDyString(&update);
    freez(&abbr);
    freez(&name);
    freez(&tranlsation);
    freez(&starts);
    freez(&comments);
}
예제 #3
0
void paraNodeStart(char *machineList)
/* Start node servers on all machines in list. */
{
char *exe = optionVal("exe", "paraNode");
char *rsh = optionVal("rsh", "rsh");
struct lineFile *lf = lineFileOpen(machineList, TRUE);
char *row[2];
struct dyString *dy = newDyString(256);

while (lineFileRow(lf, row))
    {
    char *name = row[0];
    int cpu = atoi(row[1]);
    if (cpu <= 0)
        errAbort("Expecting cpu count in second column, line %d of %s\n",
		lf->lineIx, lf->fileName);
    dyStringClear(dy);
    dyStringPrintf(dy, "%s %s %s start -cpu=%d", rsh, name, exe, cpu);
    carryOption("logFacility", dy);
    carryOption("logMinPriority", dy);
    carryOption("log", dy);
    carryOption("hub", dy);
    carryOption("umask", dy);
    carryOption("sysPath", dy);
    carryOption("userPath", dy);
    carryMultiOption("env", dy);
    carryOption("randomDelay", dy);
    printf("%s\n", dy->string);
    system(dy->string);
    }
lineFileClose(&lf);
freeDyString(&dy);
}
void makeItemsItemSaveToDbEscaped(struct sqlConnection *conn, struct makeItemsItem *el, char *tableName, int updateSize)
/* Save makeItemsItem as a row to the table specified by tableName. 
 * As blob fields may be arbitrary size updateSize specifies the approx size.
 * of a string that would contain the entire query. Automatically 
 * escapes all simple strings (not arrays of string) but may be slower than makeItemsItemSaveToDb().
 * For example automatically copies and converts: 
 * "autosql's features include" --> "autosql\'s features include" 
 * before inserting into database. */ 
{
struct dyString *update = newDyString(updateSize);
char  *chrom, *name, *strand, *description;
chrom = sqlEscapeString(el->chrom);
name = sqlEscapeString(el->name);
strand = sqlEscapeString(el->strand);
description = sqlEscapeString(el->description);

dyStringPrintf(update, "insert into %s values ( %u,'%s',%u,%u,'%s',%u,'%s',%u,%u,%u,'%s',%u)", 
	tableName,  el->bin,  chrom,  el->chromStart,  el->chromEnd,  name,  el->score,  strand,  el->thickStart,  el->thickEnd,  el->itemRgb,  description,  el->id);
sqlUpdate(conn, update->string);
freeDyString(&update);
freez(&chrom);
freez(&name);
freez(&strand);
freez(&description);
}
void protVarSaveToDbEscaped(struct sqlConnection *conn, struct protVar *el, char *tableName, int updateSize)
/* Save protVar as a row to the table specified by tableName.
 * As blob fields may be arbitrary size updateSize specifies the approx size.
 * of a string that would contain the entire query. Automatically
 * escapes all simple strings (not arrays of string) but may be slower than protVarSaveToDb().
 * For example automatically copies and converts:
 * "autosql's features include" --> "autosql\'s features include"
 * before inserting into database. */
{
    struct dyString *update = newDyString(updateSize);
    char  *id, *name, *srcId, *baseChangeType, *location;
    id = sqlEscapeString(el->id);
    name = sqlEscapeString(el->name);
    srcId = sqlEscapeString(el->srcId);
    baseChangeType = sqlEscapeString(el->baseChangeType);
    location = sqlEscapeString(el->location);

    dyStringPrintf(update, "insert into %s values ( '%s','%s','%s','%s','%s',%u)",
                   tableName,  id,  name,  srcId,  baseChangeType,  location,  el->coordinateAccuracy);
    sqlUpdate(conn, update->string);
    freeDyString(&update);
    freez(&id);
    freez(&name);
    freez(&srcId);
    freez(&baseChangeType);
    freez(&location);
}
int nextRepeatPos(char *chrom, int desiredPos, struct sqlConnection *conn)
/* Find next 0% diverged repeat on the chrom and return midpoint */
{
struct sqlResult *sr;
char **row;
int pos = -1;
int start, end;
struct hTableInfo *hti = hFindTableInfo(db, chrom, "rmsk");
struct dyString *query = newDyString(1024);

if (hti == NULL)
    errAbort("table %s.rmsk doesn't exist", db);
dyStringPrintf(query, "select genoStart,genoEnd from ");
if (hti->isSplit)
    dyStringPrintf(query, "%s_rmsk where ", chrom);
else
    dyStringPrintf(query, "rmsk where %s='%s' AND ", hti->chromField, chrom);
dyStringPrintf(query,
    "(genoStart >= %d AND \
    milliDiv=0 AND \
    repClass<>'Simple_repeat' AND repClass<>'Low_complexity' AND \
    genoEnd-genoStart>%d) order by genoStart limit 1",
        desiredPos, minRepeat);
sr = sqlGetResult(conn, query->string);
freeDyString(&query);

if ((row = sqlNextRow(sr)) != NULL)
    {
    start = sqlSigned(row[0]);
    end = sqlSigned(row[1]);
    pos = start + (end - start)/2;
    }
sqlFreeResult(&sr);
return pos;
}
void affy10KDetailsSaveToDbEscaped(struct sqlConnection *conn, struct affy10KDetails *el, char *tableName, int updateSize)
/* Save affy10KDetails as a row to the table specified by tableName. 
 * As blob fields may be arbitrary size updateSize specifies the approx size.
 * of a string that would contain the entire query. Automatically 
 * escapes all simple strings (not arrays of string) but may be slower than affy10KDetailsSaveToDb().
 * For example automatically copies and converts: 
 * "autosql's features include" --> "autosql\'s features include" 
 * before inserting into database. */ 
{
struct dyString *update = newDyString(updateSize);
char  *affyId, *rsId, *tscId, *baseA, *baseB, *sequenceA, *sequenceB, *enzyme;
affyId = sqlEscapeString(el->affyId);
rsId = sqlEscapeString(el->rsId);
tscId = sqlEscapeString(el->tscId);
baseA = sqlEscapeString(el->baseA);
baseB = sqlEscapeString(el->baseB);
sequenceA = sqlEscapeString(el->sequenceA);
sequenceB = sqlEscapeString(el->sequenceB);
enzyme = sqlEscapeString(el->enzyme);

dyStringPrintf(update, "insert into %s values ( '%s','%s','%s','%s','%s','%s','%s','%s')", 
	tableName,  affyId,  rsId,  tscId,  baseA,  baseB,  sequenceA,  sequenceB,  enzyme);
sqlUpdate(conn, update->string);
freeDyString(&update);
freez(&affyId);
freez(&rsId);
freez(&tscId);
freez(&baseA);
freez(&baseB);
freez(&sequenceA);
freez(&sequenceB);
freez(&enzyme);
}
void protVarLinkSaveToDbEscaped(struct sqlConnection *conn, struct protVarLink *el, char *tableName, int updateSize)
/* Save protVarLink as a row to the table specified by tableName.
 * As blob fields may be arbitrary size updateSize specifies the approx size.
 * of a string that would contain the entire query. Automatically
 * escapes all simple strings (not arrays of string) but may be slower than protVarLinkSaveToDb().
 * For example automatically copies and converts:
 * "autosql's features include" --> "autosql\'s features include"
 * before inserting into database. */
{
    struct dyString *update = newDyString(updateSize);
    char  *id, *attrType, *raKey, *acc, *displayVal;
    id = sqlEscapeString(el->id);
    attrType = sqlEscapeString(el->attrType);
    raKey = sqlEscapeString(el->raKey);
    acc = sqlEscapeString(el->acc);
    displayVal = sqlEscapeString(el->displayVal);

    dyStringPrintf(update, "insert into %s values ( '%s','%s','%s','%s','%s')",
                   tableName,  id,  attrType,  raKey,  acc,  displayVal);
    sqlUpdate(conn, update->string);
    freeDyString(&update);
    freez(&id);
    freez(&attrType);
    freez(&raKey);
    freez(&acc);
    freez(&displayVal);
}
static char *ccFreezeDbConversion(char *database, char *freeze, char *org)
/* Find freeze given database or vice versa.  Pass in NULL
 * for parameter that is unknown and it will be returned
 * as a result.  This result can be freeMem'd when done. */
{
struct sqlConnection *conn = hConnectCentral();
struct sqlResult *sr;
char **row;
char *ret = NULL;
struct dyString *dy = newDyString(128);

if (database != NULL)
    dyStringPrintf(dy, "select description from dbDb where name = '%s' and (genome like '%s' or genome like 'Zoo')", 
		   database, org);
else if (freeze != NULL)
    dyStringPrintf(dy, "select name from dbDb where description = '%s' and (genome like '%s' or genome like 'Zoo')", 
		   freeze, org);
else
    internalErr();
sr = sqlGetResult(conn, dy->string);
if ((row = sqlNextRow(sr)) != NULL)
    ret = cloneString(row[0]);
sqlFreeResult(&sr);
hDisconnectCentral(&conn);
freeDyString(&dy);
return ret;
}
int nextGapPos(char *chrom, int desiredPos, struct sqlConnection *conn)
{
/* Find next gap on the chrom and return midpoint */
struct sqlResult *sr;
char **row;
int pos = -1;
int start, end;
struct hTableInfo *hti = hFindTableInfo(db, chrom, "gap");
struct dyString *query = newDyString(1024);

if (hti == NULL)
    errAbort("table %s.gap doesn't exist", db);
dyStringPrintf(query, "select chromStart,chromEnd from ");
if (hti->isSplit)
    dyStringPrintf(query, "%s_gap where ", chrom);
else
    dyStringPrintf(query, "gap where %s='%s' AND ", hti->chromField, chrom);

dyStringPrintf(query, "(chromStart >= %d and chromEnd-chromStart > %d)\
    order by chromStart limit 1",
        desiredPos, minGap);
sr = sqlGetResult(conn, query->string);
freeDyString(&query);

if ((row = sqlNextRow(sr)) != NULL)
    {
    start = sqlSigned(row[0]);
    end = sqlSigned(row[1]);
    pos = start + (end - start)/2;
    }
sqlFreeResult(&sr);
return pos;
}
void cutterSaveToDbEscaped(struct sqlConnection *conn, struct cutter *el, char *tableName, int updateSize)
/* Save cutter as a row to the table specified by tableName. 
 * As blob fields may be arbitrary size updateSize specifies the approx size.
 * of a string that would contain the entire query. Automatically 
 * escapes all simple strings (not arrays of string) but may be slower than cutterSaveToDb().
 * For example automatically copies and converts: 
 * "autosql's features include" --> "autosql\'s features include" 
 * before inserting into database. */ 
{
struct dyString *update = newDyString(updateSize);
char  *name, *seq, *scizsArray, *companiesArray, *refsArray;
name = sqlEscapeString(el->name);
seq = sqlEscapeString(el->seq);

scizsArray = sqlStringArrayToString(el->scizs, el->numSciz);
companiesArray = sqlCharArrayToString(el->companies, el->numCompanies);
refsArray = sqlUnsignedArrayToString(el->refs, el->numRefs);
dyStringPrintf(update, "insert into %s values ( '%s',%u,%u,'%s',%u,%d,%u,%u,%u,'%s',%u,'%s',%u,'%s')", 
	tableName,  name, el->size , el->matchSize ,  seq, el->cut , el->overhang , el->palindromic , el->semicolon , el->numSciz ,  scizsArray , el->numCompanies ,  companiesArray , el->numRefs ,  refsArray );
sqlUpdate(conn, update->string);
freeDyString(&update);
freez(&name);
freez(&seq);
freez(&scizsArray);
freez(&companiesArray);
freez(&refsArray);
}
void affyAtlasSaveToDbEscaped(struct sqlConnection *conn, struct affyAtlas *el, char *tableName, int updateSize)
/* Save affyAtlas as a row to the table specified by tableName. 
 * As blob fields may be arbitrary size updateSize specifies the approx size.
 * of a string that would contain the entire query. Automatically 
 * escapes all simple strings (not arrays of string) but may be slower than affyAtlasSaveToDb().
 * For example automatically copies and converts: 
 * "autosql's features include" --> "autosql\'s features include" 
 * before inserting into database. */ 
{
struct dyString *update = newDyString(updateSize);
char  *annName, *probeSet, *detection, *tissue;
annName = sqlEscapeString(el->annName);
probeSet = sqlEscapeString(el->probeSet);
detection = sqlEscapeString(el->detection);
tissue = sqlEscapeString(el->tissue);

dyStringPrintf(update, "insert into %s values ( '%s','%s',%f,'%s',%f,'%s')", 
	tableName,  annName,  probeSet, el->signal ,  detection, el->pval ,  tissue);
sqlUpdate(conn, update->string);
freeDyString(&update);
freez(&annName);
freez(&probeSet);
freez(&detection);
freez(&tissue);
}
void tfbsConsSaveToDbEscaped(struct sqlConnection *conn, struct tfbsCons *el, char *tableName, int updateSize)
/* Save tfbsCons as a row to the table specified by tableName. 
 * As blob fields may be arbitrary size updateSize specifies the approx size.
 * of a string that would contain the entire query. Automatically 
 * escapes all simple strings (not arrays of string) but may be slower than tfbsConsSaveToDb().
 * For example automatically copies and converts: 
 * "autosql's features include" --> "autosql\'s features include" 
 * before inserting into database. */ 
{
struct dyString *update = newDyString(updateSize);
char  *chrom, *name, *strand, *species, *factor, *id;
chrom = sqlEscapeString(el->chrom);
name = sqlEscapeString(el->name);
strand = sqlEscapeString(el->strand);
species = sqlEscapeString(el->species);
factor = sqlEscapeString(el->factor);
id = sqlEscapeString(el->id);

dyStringPrintf(update, "insert into %s values ( '%s',%u,%u,'%s',%u,'%s','%s','%s','%s')", 
	tableName,  chrom, el->chromStart , el->chromEnd ,  name, el->score ,  strand,  species,  factor,  id);
sqlUpdate(conn, update->string);
freeDyString(&update);
freez(&chrom);
freez(&name);
freez(&strand);
freez(&species);
freez(&factor);
freez(&id);
}
예제 #14
0
void doSubmitToGreat(const char *path)
/* Send a URL to GREAT that it can use to retrieve the results. */
{
struct dyString *requestName = getRequestName();
struct dyString *requestURL = dyStringCreate("http://%s/%s", cgiServerNamePort(), path);
struct dyString *greatRequest;

greatRequest = dyStringCreate(
    "<meta http-equiv='refresh' content='0;url=http://great.stanford.edu/public/cgi-bin/greatStart.php?requestURL=%s&requestSpecies=%s&requestName=%s&requestSender=UCSC%20Table%20Browser'>",
    dyStringContents(requestURL), database, dyStringContents(requestName));

hPrintf("<b>GREAT</b> is processing BED data from \"%s\"...please wait.\n", dyStringContents(requestName));
hWrites(dyStringContents(greatRequest));
freeDyString(&greatRequest);
freeDyString(&requestName);
freeDyString(&requestURL);
}
예제 #15
0
void correctOne(struct dnaSeq *est, struct psl *psl, char *nibDir, 
   struct hash *nibHash, FILE *f)
/* Write one corrected EST to file. */
{
struct dnaSeq *geno = readCachedNib(nibHash, nibDir, psl->tName, 
	psl->tStart, psl->tEnd - psl->tStart);
struct dyString *t = newDyString(est->size+20);
int qSize = psl->qSize;
int tSize = psl->tSize;
int qLastEnd = 0;
int blockIx;
struct mrnaBlock *mbList, *mb;
int genoOffset = psl->tStart;
boolean isRc = FALSE;

/* Load sequence and alignment blocks, coping with reverse
 * strand as necessary. */
toUpperN(geno->dna, geno->size);	/* This helps debug... */
mbList = mrnaBlockFromPsl(psl);
if (psl->strand[0] == '-')
    {
    reverseComplement(geno->dna, geno->size);
    genoOffset = tSize - psl->tEnd;
    for (mb = mbList; mb != NULL; mb = mb->next)
         {
	 reverseIntRange(&mb->tStart, &mb->tEnd, tSize);
	 reverseIntRange(&mb->qStart, &mb->qEnd, qSize);
	 }
    slReverse(&mbList);
    isRc = TRUE;
    }

/* Make t have corrected sequence. */
for (mb = mbList; mb != NULL; mb = mb->next)
    {
    int qStart = mb->qStart;
    int qEnd = mb->qEnd;
    int uncovSize = qStart - qLastEnd;
    if (uncovSize > 0)
	dyStringAppendN(t, est->dna + qLastEnd, uncovSize);
    dyStringAppendN(t, geno->dna + mb->tStart - genoOffset, 
    	mb->tEnd - mb->tStart);
    qLastEnd = qEnd;
    }
if (qLastEnd != qSize)
    {
    int uncovSize = qSize - qLastEnd;
    dyStringAppendN(t, est->dna + qLastEnd, uncovSize);
    }

/* Output */
faWriteNext(f, est->name, t->string, t->stringSize);

/* Clean up time. */
slFreeList(&mbList);
freeDyString(&t);
freeDnaSeq(&geno);
}
void getTransFromFile(FILE* infile, char *path)
{
FILE* outfile = NULL;
int start, end, tmNumber, count, seqLength;
char *line, *token;
struct dyString *proteinID = newDyString(24);
start = end = tmNumber = count = seqLength = 0;
while( ( line  = readLine(infile) ) != NULL )
    {  /*grab the protein ID after each <PRE> tag*/
    while( (token = nextWord(&line)) != NULL )
        {
   	    if( sameString(token,"<PRE>#"))
                {  /*create a new xml file*/
                token = nextWord(&line);
       	        dyStringAppend(proteinID, token);
                token = lastWordInLine(line);
                seqLength = atoi(token);
                }
            if( sameString(token,"predicted") )
                {   /*grab the number of transmembrane helices*/
                token = lastWordInLine(line);
                tmNumber = atoi(token);
                    if(tmNumber > 0)
                        {
                        outfile = createXMLFile(proteinID->string, path);
                        populateXMLFile(outfile, tmNumber, proteinID->string, path);
                        }
                }
            if( sameString(token,"</PRE>") )
                {  /*close the xml file*/
                carefulClose(&outfile);
  	        dyStringClear(proteinID);
                count = 0;
                }
            if( sameString(token,"TMhelix") )
                {
                    if( (token = nextWord(&line)) != NULL )
                         {  /*get the start*/
                         start = atoi(token);
                              if( (token = nextWord(&line)) != NULL  )
                                  end = atoi(token);
                         }
                    if( count == 0)
                        addCoordinatesToXMLFile(outfile, 1, start-1, "N-term", count);
                    count++;
                    addCoordinatesToXMLFile(outfile, start, end, "TM", count);
                    if( count == tmNumber && outfile != NULL )
                        {
                        addCoordinatesToXMLFile(outfile,end+1,seqLength,"C-term",count);
                        finishXMLFile(outfile, proteinID->string, seqLength);
                        }
                }
        } /*end inner while*/
    }   /*end outer while*/
    freeMem(line);
    freeDyString(&proteinID);
}
예제 #17
0
static struct mimePart * cgiParseMultipart(int fd, FILE *out, boolean autoBoundary)
/* process a multipart form */
{
char h[1024];  /* hold mime header line */
char *s = NULL;
struct dyString *dy = newDyString(256);
struct mimeBuf *mb = NULL;
struct mimePart *mp = NULL;
char **env = NULL;

if (altHeader)
    {
    /* find the CONTENT_ environment strings, use to make Alternate Header string for MIME */
    for(env=environ; *env; env++)
	if (startsWith("CONTENT_",*env))
	    {
	    //debug
	    //fprintf(stderr,"%s\n",*env);  //debug
	    safef(h,sizeof(h),"%s",*env);
	    /* change env syntax to MIME style header, from _ to - */
	    s = strchr(h,'_');    
	    if (!s)
		errAbort("expecting '_' parsing env var %s for MIME alt header", *env);
	    *s = '-';
	    /* change env syntax to MIME style header, from = to : */
	    s = strchr(h,'=');
	    if (!s)
		errAbort("expecting '=' parsing env var %s for MIME alt header", *env);
	    *s = ':';
	    dyStringPrintf(dy,"%s\r\n",h);
	    }
    dyStringAppend(dy,"\r\n"); /* blank line at end means end of headers */
    fprintf(out,"Alternate Header Text:\n%s",dy->string);
    }

mb = initMimeBuf(fd);

if (altHeader)
    mp = parseMultiParts(mb, cloneString(dy->string)); /* The Alternate Header will get freed */
else if (autoBoundary)    
    mp = parseMultiParts(mb, "autoBoundary"); 
else    
    mp = parseMultiParts(mb, NULL); 

if(!mp->multi) /* expecting multipart child parts */
    errAbort("Malformatted multipart-form.");

freeDyString(&dy);

freez(&mb);


printMimeInfo(mp, out, 0);

return mp;
}
예제 #18
0
파일: ccCp.3.c 프로젝트: blumroy/kentUtils
void sshSelf(char *hostList, char *host, int start, char *destFile, char *lockDir)
/* Execute ssh command to invoke self. */
{
struct dyString *dy = newDyString(512);
dyStringPrintf(dy, 
        "ssh -x %s /projects/compbio/experiments/hg/bin/i386/ccCp %s %s %d %s &",
	host, destFile, hostList, start, lockDir);
system(dy->string);
freeDyString(&dy);
}
예제 #19
0
파일: ccCp.c 프로젝트: sktu/kentUtils
void rshSelf(char *hostList, char *host, int start, char *destFile, char *lockDir)
/* Execute rsh command to invoke self. */
{
struct dyString *dy = newDyString(512);
dyStringPrintf(dy, 
        "rsh %s /cse/guests/kent/bin/i386/ccCp %s %s %d %s &",
	host, destFile, hostList, start, lockDir);
system(dy->string);
freeDyString(&dy);
}
예제 #20
0
파일: ccCp.3.c 프로젝트: blumroy/kentUtils
int cpFile(char *source, char *destFile)
/* Execute cp command to copy file to host. */
{
struct dyString *dy = newDyString(512);
int ret;

dyStringPrintf(dy, "cp %s %s",  source, destFile);
ret = system(dy->string);
freeDyString(&dy);
return ret;
}
예제 #21
0
void freeDyStringList(struct dyString **pDs)
/* free up a list of dyStrings */
{
struct dyString *ds, *next;
for(ds = *pDs; ds != NULL; ds = next)
    {
    next = ds->next;
    freeDyString(&ds);
    }
*pDs = NULL;
}
예제 #22
0
void loadTableFromTabFile(char *database, char *table, char *tabFile)
/* Load up table from tab file. */
{
struct sqlConnection *conn = sqlConnect(database);
struct dyString *ds = newDyString(2048);
sqlDyStringPrintf(ds, 
   "load data local infile '%s' into table %s", tabFile, table);
sqlUpdate(conn, ds->string);
sqlDisconnect(&conn);
freeDyString(&ds);
}
예제 #23
0
void makeCustomTable(char *database, char *table, char *defString)
/* create/recreate table. */
{
struct sqlConnection *conn = sqlConnect(database);
struct dyString *ds = newDyString(2048);

sqlDyStringPrintf(ds, defString, table);
sqlRemakeTable(conn, table, ds->string);
sqlDisconnect(&conn);
freeDyString(&ds);
}
예제 #24
0
파일: ccCp.3.c 프로젝트: blumroy/kentUtils
int scpFile(char *source, char *destHost, char *destFile)
/* Execute scp command to copy source file to host. */
{
struct dyString *dy = newDyString(512);
int ret;

dyStringPrintf(dy, "scp %s %s:/%s >/dev/null",  source, destHost, destFile);
ret = system(dy->string);
freeDyString(&dy);
return ret;
}
예제 #25
0
void gapFileToTable(struct sqlConnection *conn, char *gapFileName,
		    char *gapTableName)
/* Build a single gap table from a single gap file. */
{
struct lineFile *lf = lineFileOpen(gapFileName, TRUE);
char tabFileName[256];
FILE *tabFile = NULL;
char *words[16];
int wordCount;

safef(tabFileName, sizeof(tabFileName), "%s.tab", gapTableName);
tabFile = mustOpen(tabFileName, "w");
while ((wordCount = lineFileChop(lf, words)) > 0)
    {
    if (wordCount < 5)
	errAbort("Short line %d of %s", lf->lineIx, lf->fileName);
    if (words[4][0] == 'N' || words[4][0] == 'U')
	{
	int len = strlen(words[0]);
	if (len > maxChromNameSize)
	    {
	    maxChromNameSize = len;
	    if (maxChromNameSize > 254)
		errAbort("ERROR: chrom name size is over 254(%d) characters: "
			"'%s'", maxChromNameSize, words[0]);
	    }
	struct agpGap gap;
	agpGapStaticLoad(words, &gap);
	gap.chromStart -= 1;
	fprintf(tabFile, "%u\t", hFindBin(gap.chromStart, gap.chromEnd));
	agpGapTabOut(&gap, tabFile);
	}
    }
lineFileClose(&lf);
fclose(tabFile);

if (! noLoad)
    {
    struct dyString *ds = newDyString(2048);
    if (unsplit)
	sqlDyStringPrintf(ds,  createGapUnsplit, gapTableName,
		maxChromNameSize, maxChromNameSize);
    else
	sqlDyStringPrintf(ds, createGapSplit, gapTableName);
    char query[1024];
    sqlRemakeTable(conn, gapTableName, ds->string);
    sqlSafef(query, sizeof(query), "LOAD data local infile '%s' into table %s", 
	  tabFileName, gapTableName);
    sqlUpdate(conn, query);
    remove(tabFileName);
    freeDyString(&ds);
    }
}
예제 #26
0
파일: gv.c 프로젝트: bowhan/kent
void gvSaveToDb(struct sqlConnection *conn, struct gv *el, char *tableName, int updateSize)
/* Save gv as a row to the table specified by tableName. 
 * As blob fields may be arbitrary size updateSize specifies the approx size
 * of a string that would contain the entire query. Arrays of native types are
 * converted to comma separated strings and loaded as such, User defined types are
 * inserted as NULL. Strings are automatically escaped to allow insertion into the database. */
{
struct dyString *update = newDyString(updateSize);
sqlDyStringPrintf(update, "insert into %s values ( '%s','%s','%s','%s','%s',%u)", 
	tableName,  el->id,  el->name,  el->srcId,  el->baseChangeType,  el->location,  el->coordinateAccuracy);
sqlUpdate(conn, update->string);
freeDyString(&update);
}
예제 #27
0
void trackVersionSaveToDb(struct sqlConnection *conn, struct trackVersion *el, char *tableName, int updateSize)
/* Save trackVersion as a row to the table specified by tableName. 
 * As blob fields may be arbitrary size updateSize specifies the approx size
 * of a string that would contain the entire query. Arrays of native types are
 * converted to comma separated strings and loaded as such, User defined types are
 * inserted as NULL. Strings are automatically escaped to allow insertion into the database. */
{
struct dyString *update = newDyString(updateSize);
sqlDyStringPrintf(update, "insert into %s values ( %d,'%s','%s','%s','%s','%s','%s','%s','%s')", 
	tableName,  el->ix,  el->db,  el->name,  el->who,  el->version,  el->updateTime,  el->comment,  el->source,  el->dateReference);
sqlUpdate(conn, update->string);
freeDyString(&update);
}
예제 #28
0
void makeItemsItemSaveToDb(struct sqlConnection *conn, struct makeItemsItem *el, char *tableName, int updateSize)
/* Save makeItemsItem as a row to the table specified by tableName.
 * As blob fields may be arbitrary size updateSize specifies the approx size
 * of a string that would contain the entire query. Arrays of native types are
 * converted to comma separated strings and loaded as such, User defined types are
 * inserted as NULL. Strings are automatically escaped to allow insertion into the database. */
{
struct dyString *update = newDyString(updateSize);
sqlDyStringPrintf(update, "insert into %s values ( %u,'%s',%u,%u,'%s',%u,'%s',%u,%u,%u,%s,%u)",
	tableName,  el->bin,  el->chrom,  el->chromStart,  el->chromEnd,  el->name,  el->score,  el->strand,  el->thickStart,  el->thickEnd,  el->itemRgb,  el->description,  el->id);
sqlUpdate(conn, update->string);
freeDyString(&update);
}
예제 #29
0
void taxonGeneticCodeSaveToDb(struct sqlConnection *conn, struct taxonGeneticCode *el, char *tableName, int updateSize)
/* Save taxonGeneticCode as a row to the table specified by tableName. 
 * As blob fields may be arbitrary size updateSize specifies the approx size
 * of a string that would contain the entire query. Arrays of native types are
 * converted to comma separated strings and loaded as such, User defined types are
 * inserted as NULL. Strings are automatically escaped to allow insertion into the database. */
{
struct dyString *update = newDyString(updateSize);
sqlDyStringPrintf(update, "insert into %s values ( %u,'%s','%s','%s','%s','%s')", 
	tableName,  el->id,  el->abbr,  el->name,  el->tranlsation,  el->starts,  el->comments);
sqlUpdate(conn, update->string);
freeDyString(&update);
}
예제 #30
0
void snpExceptionsSaveToDb(struct sqlConnection *conn, struct snpExceptions *el, char *tableName, int updateSize)
/* Save snpExceptions as a row to the table specified by tableName. 
 * As blob fields may be arbitrary size updateSize specifies the approx size
 * of a string that would contain the entire query. Arrays of native types are
 * converted to comma separated strings and loaded as such, User defined types are
 * inserted as NULL. Strings are automatically escaped to allow insertion into the database. */
{
struct dyString *update = newDyString(updateSize);
sqlDyStringPrintf(update, "insert into %s values ( %u,'%s',%u,'%s','%s')", 
	tableName,  el->exceptionId,  el->query,  el->num,  el->description,  el->resultPath);
sqlUpdate(conn, update->string);
freeDyString(&update);
}