Exemplo n.º 1
0
void aNotB(char *aFile, char *bFile, char *outFile)
/* aNotB - List symbols that are in a but not b. */
{
struct hash *bHash = hashFirstWord(bFile);
struct lineFile *lf = lineFileOpen(aFile, TRUE);
FILE *f = mustOpen(outFile, "w");
char *row[1];
while (lineFileRow(lf, row))
    {
    if (!hashLookup(bHash, row[0]))
	fprintf(f, "%s\n", row[0]);
    }
carefulClose(&f);
}
Exemplo n.º 2
0
void hgSgdPep(char *inName, char *outName, char *symbolName)
/* hgSgdPep - Parse yeast protein fasta files into format we can load. */
{
struct lineFile *lf = lineFileOpen(inName, TRUE);
FILE *f = mustOpen(outName, "w");
FILE *symF = mustOpen(symbolName, "w");
boolean inPep = FALSE;
char *line;
char *pattern = "ORFP:";
int patternSize = strlen(pattern);
struct hash *restrictHash = NULL;

if (optionExists("restrict"))
    restrictHash = hashFirstWord(optionVal("restrict", NULL));
while (lineFileNext(lf, &line, NULL))
    {
    if (line[0] == '>')
        {
	char *orf, *gene;
	inPep = FALSE;
	if ((line = stringIn(pattern, line)) != NULL)
	    {
	    line += patternSize;
	    orf = nextWord(&line);
	    gene = nextWord(&line);
	    if (orf == NULL)
	        errAbort("Expecting ORF name starting with Y line %d of %s",
			lf->lineIx, lf->fileName);
	    if (gene != NULL)
		fprintf(symF, "%s\t%s\n", orf, gene);
	    if (restrictHash == NULL || hashLookup(restrictHash, orf))
		{
		fprintf(f, ">%s\n", orf);
		inPep = TRUE;
		}
	    }
	else
	    {
	    errAbort("No %s line %d of %s\n", 
	    	pattern, lf->lineIx, lf->fileName);
	    }
	}
    else if (inPep)
        fprintf(f, "%s\n", line);
    }
}