Esempio n. 1
0
int main(int argc, char *argv[])
/* Process command line. */
{
    if (argc != 4)
	errAbort("bad running of bwmake");
    struct hash *sizeHash = readCsizeHash(argv[1]);
    writeBw(argv[2], argv[3], sizeHash);
    hashFree(&sizeHash);
    return 0;
}
Esempio n. 2
0
void bwtool_shift(struct hash *options, char *favorites, char *regions, unsigned decimals, enum wigOutType wot,
		  boolean condense, char *val_s, char *bigfile, char *tmp_dir, char *outputfile)
/* bwtool_shift - main for shifting program */
{
    const double na = NANUM;
    int shft = sqlSigned(val_s);
    int abs_shft = abs(shft);
    struct metaBig *mb = metaBigOpen_check(bigfile, tmp_dir, regions);
    if (!mb)
	errAbort("problem opening %s", bigfile);
    char wigfile[512];
    safef(wigfile, sizeof(wigfile), "%s.tmp.wig", outputfile);
    FILE *out = mustOpen(wigfile, "w");
    struct bed *section;
    boolean up = TRUE;
    if (shft > 0)
	up = FALSE;
    if (shft == 0)
	errAbort("it doesn't make sense to shift by zero.");
    for (section = mb->sections; section != NULL; section = section->next)
    {
	struct perBaseWig *pbw = perBaseWigLoadSingleContinue(mb, section->chrom, section->chromStart,
							      section->chromEnd, FALSE, na);
	int i;
	/* if the shift size is bigger than the section, NA the entire thing */
	int size = pbw->len;
	if (abs_shft >= size)
	    for (i = 0; i < size; i++)
		pbw->data[i] = na;
	else
	{
	    if (!up)
	    {
		for (i = size-1; i >= abs_shft; i--)
		    pbw->data[i] = pbw->data[i - abs_shft];
		for (; i >= 0; i--)
		    pbw->data[i] = na;
	    }
	    else
	    {
		for (i = 0; i < size - abs_shft; i++)
		    pbw->data[i] = pbw->data[i + abs_shft];
		for (; i < size; i++)
		    pbw->data[i] = na;
	    }
	}
	perBaseWigOutputNASkip(pbw, out, wot, decimals, NULL, FALSE, condense);
	perBaseWigFree(&pbw);
    }
    carefulClose(&out);
    writeBw(wigfile, outputfile, mb->chromSizeHash);
    remove(wigfile);
    metaBigClose(&mb);
}
Esempio n. 3
0
void bwtool_lift(struct hash *options, char *favorites, char *regions, unsigned decimals,
		 enum wigOutType wot, char *bigfile, char *chainfile, char *outputfile)
/* bwtool_lift - main for lifting program */
{
    struct hash *sizeHash = NULL;
    struct hash *chainHash = readLiftOverMapChainHash(chainfile);
    struct hash *gpbw = NULL;
    char *size_file = hashFindVal(options, "sizes");
    char *bad_file = hashFindVal(options, "unlifted");
    if (size_file)
	sizeHash = readCsizeHash(size_file);
    else
	sizeHash = qSizeHash(chainfile);
    gpbw = genomePbw(sizeHash);
    struct metaBig *mb = metaBigOpen_check(bigfile, regions);
    char wigfile[512];
    safef(wigfile, sizeof(wigfile), "%s.tmp.wig", outputfile);
    FILE *out = mustOpen(wigfile, "w");
    struct hashEl *elList = hashElListHash(gpbw);
    struct hashEl *el;
    verbose(2,"starting first pass\n");
    do_pass1(mb, chainHash, gpbw);
    verbose(2, "starting second pass\n");
    do_pass2(mb, chainHash, gpbw);
    verbose(2,"starting final pass\n");
    do_final_pass(mb, chainHash, gpbw, bad_file);
    slSort(&elList, pbwHashElCmp);
    for (el = elList; el != NULL; el = el->next)
    {
	struct perBaseWig *pbw = (struct perBaseWig *)el->val;
	perBaseWigOutputNASkip(pbw, out, wot, decimals, NULL, FALSE, FALSE);
    }
    hashElFreeList(&elList);
    carefulClose(&out);
    hashFreeWithVals(&chainHash, freeChainHashMap);
    hashFreeWithVals(&gpbw, perBaseWigFree);
    writeBw(wigfile, outputfile, sizeHash);
    hashFree(&sizeHash);
    remove(wigfile);
    metaBigClose(&mb);
}
Esempio n. 4
0
void bwtool_fill(struct hash *options, char *favorites, char *regions, unsigned decimals, enum wigOutType wot,
		 boolean condense, char *val_s, char *bigfile, char *tmp_dir, char *outputfile)
/* bwtool_fill - main for filling program */
{
    double val = sqlDouble(val_s);
    struct metaBig *mb = metaBigOpen_check(bigfile, tmp_dir, regions);
    char wigfile[512];
    safef(wigfile, sizeof(wigfile), "%s.tmp.wig", outputfile);
    FILE *out = mustOpen(wigfile, "w");
    struct bed *section;
    int i;
    for (section = mb->sections; section != NULL; section = section->next)
    {
	struct perBaseWig *pbw = perBaseWigLoadSingleContinue(mb, section->chrom, section->chromStart,
							      section->chromEnd, FALSE, val);
	perBaseWigOutput(pbw, out, wot, decimals, NULL, FALSE, condense);
	perBaseWigFree(&pbw);
    }
    carefulClose(&out);
    writeBw(wigfile, outputfile, mb->chromSizeHash);
    remove(wigfile);
    metaBigClose(&mb);
}