Example #1
0
int main(int argc, char *argv[])
{
char *sourceName, *destRootName;
int maxSize;
char destName[512];
char faName[512];
int destIx;
int size, start;
struct dnaSeq *seq;


if (argc != 4)
    usage();
sourceName = argv[1];
maxSize = atoi(argv[2]);
if (maxSize < 1)
    usage();
destRootName = argv[3];
printf("reading %s\n", sourceName);
seq = faReadDna(sourceName);
for (start = 0, destIx = 1; start < seq->size; start += size, ++destIx)
    {
    size = seq->size - start;
    if (size > maxSize)
	size = maxSize;
    sprintf(destName, "%s%02d.fa", destRootName, destIx);
    sprintf(faName, "%s.%d", seq->name, destIx);
    printf("writing %s\n", destName);
    faWrite(destName, faName, seq->dna+start, size);
    }
return 0;
}
Example #2
0
void showDetailedMatch(char *bacAcc, int contig, int qStart, int qSize, int tStart, int tSize, char *repeatMask)
/* Process a click on active area. */
{
struct dnaSeq *queryList, *query, *target;
struct ffAli *ali;
boolean rc;
char needleName[128], hayName[128];

makeFileNames(bacAcc, repeatMask);
queryList = faReadAllDna(unfinBac);
target = faReadDna(finBac);
query = slElementFromIx(queryList, contig);

if (!ffFindEitherStrandN(query->dna + qStart, qSize, target->dna + tStart, tSize,
    ffCdna, &ali, &rc))
    {
    errAbort("Couldn't align %s and %s", unfinBac, finBac);
    }
sprintf(needleName, "%s contig %d %d-%d", bacAcc, contig, qStart, qStart+qSize);
sprintf(hayName, "%s finished %d-%d", bacAcc, tStart, tStart+tSize);
query->dna[qStart+qSize] = 0;
target->dna[tStart+tSize] = 0;
ffShowAli(ali, needleName, query->dna + qStart, 0,
               hayName, target->dna + tStart, 0, rc);
}
Example #3
0
void hgNibSeq(char *database, char *destDir, int faCount, char *faNames[])
/* hgNibSeq - convert DNA to nibble-a-base and store location in database. */
{
char dir[256], name[128], chromName[128], ext[64];
char nibName[512];
struct sqlConnection *conn = sqlConnect(database);
char query[512];
int i;
char *faName;
struct dnaSeq *seq = NULL;
unsigned long total = 0;
int size;

if (!strchr(destDir, '/'))
   errAbort("Use full path name for nib file dir\n");

makeDir(destDir);
if ((!appendTbl) || !sqlTableExists(conn, tableName))
    createTable(conn);
for (i=0; i<faCount; ++i)
    {
    faName = faNames[i];
    splitPath(faName, dir, name, ext);
    sprintf(nibName, "%s/%s.nib", destDir, name);
    printf("Processing %s to %s\n", faName, nibName);
    if (preMadeNib)
        {
	FILE *nibFile;
	nibOpenVerify(nibName, &nibFile, &size);
	carefulClose(&nibFile);
	}
    else
	{
	seq = faReadDna(faName);
	if (seq != NULL)
	    {
	    size = seq->size;
	    uglyf("Read DNA\n");
	    nibWrite(seq, nibName);
	    uglyf("Wrote nib\n");
	    freeDnaSeq(&seq);
	    }
	}
    strcpy(chromName, chromPrefix);
    strcat(chromName, name);
    sqlSafef(query, sizeof query, "INSERT into %s VALUES('%s', %d, '%s')",
        tableName, chromName, size, nibName);
    sqlUpdate(conn,query);
    total += size;
    }
sqlDisconnect(&conn);
printf("%lu total bases\n", total);
}
void agpCloneCheck(char *agpFile, char *gsDir)
/* agpCloneCheck - Check that have all clones in an agp file (and the right version too). */
{
    struct lineFile *lf = lineFileOpen(agpFile, TRUE);
    char *line, *words[16];
    int lineSize, wordCount, i;
    char clonePath[512];
    char clone[128], *cloneVer;
    static char *phases[3] = {"fin", "draft", "predraft",};
    boolean found;

    while (lineFileNext(lf, &line, &lineSize))
    {
        if (line[0] == '#')
            continue;
        wordCount = chopLine(line, words);
        if (wordCount == 0)
            continue;
        if (wordCount < 5)
            errAbort("Bad line %d of %s", lf->lineIx, lf->fileName);
        if (words[4][0] == 'N' || words[4][0] == 'U')
            continue;
        cloneVer = words[5];
        strcpy(clone, cloneVer);
        chopSuffix(clone);
        found = FALSE;
        for (i = 0; i < 3; ++i)
        {
            char *phase = phases[i];
            sprintf(clonePath, "%s/%s/fa/%s.fa", gsDir, phase, clone);
            if (fileExists(clonePath))
            {
                struct dnaSeq *seq = faReadDna(clonePath);
                char *e = strchr(seq->name, '_');

                if (e != NULL) *e = 0;
                if (!sameString(seq->name, cloneVer))
                    printf("%s\t(wrong version %s)\n", cloneVer, seq->name);
                else if (i != 0)
                    printf("%s\t(not finished)\n", cloneVer);
                found = TRUE;
            }
        }
        if (!found)
            printf("%s\t(not found)\n", cloneVer);
    }
}
Example #5
0
void flagMhcClones(char *mhcFile, char *gsDir)
/* flagMhcClones - Look for clones Stephan wants in MHC.. */
{
struct lineFile *lf = lineFileOpen(mhcFile, TRUE);
char *line, *words[16];
int lineSize, wordCount, i;
char clonePath[512];
char *clone, *cloneVer;
static char *phases[3] = {"fin", "draft", "predraft",};
boolean found;

while (lineFileNext(lf, &line, &lineSize))
    {
    if (line[0] == '#')
        continue;
    wordCount = chopLine(line, words);
    if (wordCount == 0)
        continue;
    lineFileExpectWords(lf, 7, wordCount);
    clone = words[0];
    cloneVer = words[1];
    found = FALSE;
    for (i = 0; i < 3; ++i)
        {
	char *phase = phases[i];
	sprintf(clonePath, "%s/%s/fa/%s.fa", gsDir, phase, clone);
	if (fileExists(clonePath))
	    {
	    struct dnaSeq *seq = faReadDna(clonePath);
	    char *e = strchr(seq->name, '_');

	    if (e != NULL) *e = 0;
	    if (!sameString(seq->name, cloneVer))
		printf("%s\t(wrong version %s)\n", cloneVer, seq->name);
	    else if (i != 0)
	        printf("%s\t(not finished)\n", cloneVer);
	    found = TRUE;
	    }
	}
    if (!found)
        printf("%s\t(not found)\n", cloneVer);
    }
}
Example #6
0
struct hash *loadGeno(char *genoFile)
/* load genome sequences into a hash.  This supports the multi-sequence
 * specs of twoBitLoadAll */
{
struct dnaSeq *genos = NULL, *geno;
struct hash *genoHash = hashNew(0);

if (nibIsFile(genoFile))
    genos = nibLoadAllMasked(NIB_MASK_MIXED|NIB_BASE_NAME, genoFile);
else if (twoBitIsSpec(genoFile))
    genos = twoBitLoadAll(genoFile);
else
    genos = faReadDna(genoFile);

while ((geno = slPopHead(&genos)) != NULL)
    {
    tolowers(geno->dna);
    hashAdd(genoHash, geno->name, geno);
    }
return genoHash;
}
Example #7
0
void countCosmids(char *listFileName, FILE *out)
/* Read each cosmid in list file and find out how big it is. */
{
FILE *listFile = mustOpen(listFileName, "r");
char line[512], *s;
int lineCount;
struct dnaSeq *seq;
char path[512];

while (fgets(line, sizeof(line), listFile))
    {
    ++lineCount;
    s = trimSpaces(line);
    sprintf(path, "%s/%s", "C:/biodata/cbriggsae/finish", s);
    seq = faReadDna(path);
    ++cosmidCount;
    cosmidTotalSize += seq->size;
    freeDnaSeq(&seq);
    }
fclose(listFile);
cosmidAverageSize = round((double)cosmidTotalSize/cosmidCount);
fprintf(out, "%d cosmids, average length %d\n", cosmidCount, cosmidAverageSize);
}