Пример #1
0
void fastq_stats_read(char *filename, struct fastq_stats *fqs)
/* read from a file */
{
    struct lineFile *lf = lineFileOpen(filename, TRUE);
    char *line;
    char *words[FASTQ_MAX_LEN];
    int numWords = 0;
    int i, j;
    if (!lineFileNext(lf, &line, NULL))
	errAbort("bad file, total count section");
    fqs->total_count = sqlUnsignedLong(line);
    if (!lineFileNext(lf, &line, NULL))
	errAbort("bad file, skipped count section");
    fqs->all_b = sqlUnsignedLong(line);
    if (!lineFileNext(lf, &line, NULL))
	errAbort("bad file, skipped count section");
    fqs->skipped_count = sqlUnsignedLong(line);
    if (!lineFileNext(lf, &line, NULL))
	errAbort("bad file, skipped count section");
    fqs->kept_count = sqlUnsignedLong(line);
    if (!lineFileNext(lf, &line, NULL))
	errAbort("bad file, longest read section");
    fqs->longest_read = sqlUnsigned(line);
    numWords = lineFileChopTab(lf, words);
    if (numWords != fqs->longest_read)
	errAbort("bad file: original lengths section shoud have %u cols, has %d", fqs->longest_read, numWords);
    for (i = 0; i < numWords; i++)
	fqs->original_lengths[i] = sqlUnsignedLong(words[i]);
    numWords = lineFileChopTab(lf, words);
    if (numWords != fqs->longest_read)
	errAbort("bad file: trimmed lengths section shoud have %u cols, has %d", fqs->longest_read, numWords);
    for (i = 0; i < numWords; i++)
	fqs->trimmed_lengths[i] = sqlUnsignedLong(words[i]);
    for (i = 0; i <= FASTQ_SANGER_MAX_QUAL; i++)
    {
	numWords = lineFileChopTab(lf, words);
	if (numWords != fqs->longest_read)
	    errAbort("bad file:  before_quals section line %d shoud have %u cols, has %d", i+1, fqs->longest_read, numWords);
	for (j = 0; j < numWords; j++)
	    fqs->before_quals[j][i] = sqlUnsignedLong(words[j]);
    }
    for (i = 0; i <= FASTQ_SANGER_MAX_QUAL; i++)
    {
	numWords = lineFileChopTab(lf, words);
	if (numWords != fqs->longest_read)
	    errAbort("bad file:  after_quals section line %d shoud have %u cols, has %d", i+1, fqs->longest_read, numWords);
	for (j = 0; j < numWords; j++)
	    fqs->after_quals[j][i] = sqlUnsignedLong(words[j]);
    }
    lineFileClose(&lf);
}
Пример #2
0
struct galleryEntry *galLoad(char **row)
/* Load a session entry from a row.  A row consists of:
 * 0. gbMembers.realName
 * 1. namedSessionDb.userName
 * 2. gbMembers.idx
 * 3. namedSessionDb.sessionName
 * 4. namedSessionDb.useCount
 * 5. namedSessionDb.settings
 * 6. namedSessionDb.contents
 * 7. namedSessionDb.firstUse */
{
char *dbIdx, *dbEnd;
struct galleryEntry *ret;
AllocVar(ret);
ret->realName = cloneString(row[0]);
ret->userName = cloneString(row[1]);
cgiDecodeFull(ret->userName, ret->userName, strlen(ret->userName));
ret->sessionName = cloneString(row[3]);
cgiDecodeFull(ret->sessionName, ret->sessionName, strlen(ret->sessionName));
ret->sessionUrl = dyStringCreate("hgS_doOtherUser=submit&hgS_otherUserName=%s&hgS_otherUserSessionName=%s", row[1], row[3]);

ret->imgPath = sessionThumbnailFilePath(row[2], row[3], row[7]);
if (fileExists(ret->imgPath))
    ret->imgUri = sessionThumbnailFileUri(row[2], row[3], row[7]);
else
    ret->imgUri = NULL;
ret->useCount = sqlUnsignedLong(row[4]);
ret->settings = cloneString(row[5]);
if (startsWith("db=", row[6]))
    dbIdx = row[6] + 3;
else
    dbIdx = strstr(row[6], "&db=") + 4;
if (dbIdx != NULL)
    {
    dbEnd = strchr(dbIdx, '&');
    if (dbEnd != NULL)
        ret->db = cloneStringZ(dbIdx, dbEnd-dbIdx);
    else
        ret->db = cloneString(dbIdx);
    }
else
    ret->db = cloneString("n/a");
ret->firstUse = cloneString(row[7]);
char *spacePt = strchr(ret->firstUse, ' ');
if (spacePt != NULL) *spacePt = '\0';
return ret;
}
Пример #3
0
void cdwJobCleanFailed(int submitId)
/* Check out the symlink to determine its type. */
{

struct sqlConnection *conn = sqlConnect("cdw");

struct dyString *query = dyStringNew(0);
sqlDyStringPrintf(query, 
 "select id, commandLine, startTime, endTime, returnCode, pid from cdwJob where submitId=%d "
"order by commandLine,CAST(returnCode AS unsigned)", 
 submitId);
 // NOTE we need this CAST on returnCode since it can be -1. we want success 0 first.

// TODO DO we need to add any other conditions such as distinguishing
// between running, queued, and done?

/* Scan through result set finding redundant rows beyond success row. */
struct sqlResult *sr = sqlGetResult(conn, query->string);
char **row;
char *lastCommand = "";
boolean success = FALSE;
struct slInt *list = NULL;
struct slInt *e;
while ((row = sqlNextRow(sr)) != NULL)
    {
    unsigned int id = sqlUnsigned(row[0]);
    char *commandLine = row[1];
    unsigned long startTime = sqlUnsignedLong(row[2]);
    unsigned long endTime = sqlUnsignedLong(row[3]);
    int returnCode = sqlSigned(row[4]);
    unsigned int pid = sqlUnsigned(row[5]);
    verbose(2, "%u\t%s\t%lu\t%lu\t%d\t%u\t%u\n", id, commandLine, startTime, endTime, returnCode, pid, submitId);
    if (sameString(lastCommand, commandLine))
	{
	if (success)  // we already succeeded, the old failure is unwanted baggage.
	    {
	    e = slIntNew(id);  // or add it to a list of rows whose ids should get removed
	    slAddHead(&list, e);
	    }
	}
    else
	{
	if (returnCode == 0)
	    success = TRUE;
	else
	    success = FALSE;
	}
    // note fields pid and submitId are defined as signed integers in cdwJob table, probably should be unsigned.
    lastCommand = cloneString(commandLine);
    }
                                                                              
sqlFreeResult(&sr);

slReverse(&list);
for(e=list;e;e=e->next)
    {
    dyStringClear(query);
    sqlDyStringPrintf(query, "delete from cdwJob where id=%u", (unsigned int) e->val);
    //printf("%s\n", query->string);
    sqlUpdate(conn, query->string);
    }

/* Clean up and go home */
dyStringFree(&query);

sqlDisconnect(&conn);


}