Skip to content
Snippets Groups Projects
Commit 7d4ab4fe authored by sauloal's avatar sauloal
Browse files

more programs

parent 421cb0f5
Branches master
No related tags found
No related merge requests found
Pipeline #
Showing
with 2994 additions and 27 deletions
......@@ -3,15 +3,17 @@ libs/old
*.o
*.tar.gz
*_static
bedGraphToBigWig
bedToBigBed
wigToBedGraph
bigBedInfo
bigBedSummary
bigBedToBed
bigWigInfo
bigWigSummary
bigWigToBedGraph
bigWigToWig
wigToBed
wigToBedGraph
wigToBigWig
bedGraphToBigWig_static
bedToBigBed_static
wigToBedGraph_static
wigToBed_static
wigToBigWig_static
This diff is collapsed.
No preview for this file type
This diff is collapsed.
No preview for this file type
This diff is collapsed.
No preview for this file type
This diff is collapsed.
No preview for this file type
/* bigBedInfo - Show information about a bigBed file.. */
/* Copyright (C) 2014 The Regents of the University of California
* See README in this or parent directory for licensing information. */
#include "common.h"
#include "linefile.h"
#include "hash.h"
#include "options.h"
#include "udc.h"
#include "bPlusTree.h"
#include "bbiFile.h"
#include "bigBed.h"
#include "obscure.h"
#include "hmmstats.h"
void usage()
/* Explain usage and exit. */
{
errAbort(
"bigBedInfo - Show information about a bigBed file.\n"
"usage:\n"
" bigBedInfo file.bb\n"
"options:\n"
" -udcDir=/dir/to/cache - place to put cache for remote bigBed/bigWigs\n"
" -chroms - list all chromosomes and their sizes\n"
" -zooms - list all zoom levels and their sizes\n"
" -as - get autoSql spec\n"
" -extraIndex - list all the extra indexes\n"
);
}
static struct optionSpec options[] = {
{"udcDir", OPTION_STRING},
{"chroms", OPTION_BOOLEAN},
{"zooms", OPTION_BOOLEAN},
{"as", OPTION_BOOLEAN},
{"extraIndex", OPTION_BOOLEAN},
{NULL, 0},
};
void printLabelAndLongNumber(char *label, long long l)
/* Print label: 1,234,567 format number */
{
printf("%s: ", label);
printLongWithCommas(stdout, l);
printf("\n");
}
void bigBedInfo(char *fileName)
/* bigBedInfo - Show information about a bigBed file.. */
{
struct bbiFile *bbi = bigBedFileOpen(fileName);
printf("version: %d\n", bbi->version);
printf("fieldCount: %d\n", bbi->fieldCount);
printf("hasHeaderExtension: %s\n", (bbi->extensionOffset != 0 ? "yes" : "no"));
printf("isCompressed: %s\n", (bbi->uncompressBufSize > 0 ? "yes" : "no"));
printf("isSwapped: %d\n", bbi->isSwapped);
printf("extraIndexCount: %d\n", bbi->extraIndexCount);
if (optionExists("extraIndex"))
{
struct slName *el, *list = bigBedListExtraIndexes(bbi);
for (el = list; el != NULL; el = el->next)
{
int fieldIx = 0;
struct bptFile *bpt = bigBedOpenExtraIndex(bbi, el->name, &fieldIx);
printf(" %s (field %d) with %lld items\n", el->name, fieldIx, (long long)bpt->itemCount);
}
}
printLabelAndLongNumber("itemCount", bigBedItemCount(bbi));
printLabelAndLongNumber("primaryDataSize", bbi->unzoomedIndexOffset - bbi->unzoomedDataOffset);
if (bbi->levelList != NULL)
{
long long indexEnd = bbi->levelList->dataOffset;
printLabelAndLongNumber("primaryIndexSize", indexEnd - bbi->unzoomedIndexOffset);
}
struct bbiChromInfo *chrom, *chromList = bbiChromList(bbi);
printf("zoomLevels: %d\n", bbi->zoomLevels);
if (optionExists("zooms"))
{
struct bbiZoomLevel *zoom;
for (zoom = bbi->levelList; zoom != NULL; zoom = zoom->next)
{
printf("\t%d\t%d\n", zoom->reductionLevel, (int)(zoom->indexOffset - zoom->dataOffset));
for (chrom=chromList; chrom != NULL; chrom = chrom->next)
{
struct bbiSummary *sum, *sumList = bbiSummariesInRegion(zoom, bbi, chrom->id,0, chrom->size);
for (sum = sumList; sum != NULL; sum = sum->next)
{
printf("\t\t%s:%d-%d\n",chrom->name, sum->start, sum->end);
}
}
}
}
printf("chromCount: %d\n", slCount(chromList));
if (optionExists("chroms"))
for (chrom=chromList; chrom != NULL; chrom = chrom->next)
printf("\t%s %d %d\n", chrom->name, chrom->id, chrom->size);
if (optionExists("as"))
{
char *asText = bigBedAutoSqlText(bbi);
if (asText == NULL)
printf("as: n/a\n");
else
{
printf("as:\n");
printf("%s", asText);
}
}
struct bbiSummaryElement sum = bbiTotalSummary(bbi);
printLabelAndLongNumber("basesCovered", sum.validCount);
double meanDepth = 0, depthStd = 0;
if (sum.validCount > 0)
{
meanDepth = sum.sumData/sum.validCount;
depthStd = calcStdFromSums(sum.sumData, sum.sumSquares, sum.validCount);
}
printf("meanDepth (of bases covered): %f\n", meanDepth);
printf("minDepth: %f\n", sum.minVal);
printf("maxDepth: %f\n", sum.maxVal);
printf("std of depth: %f\n", depthStd);
}
int main(int argc, char *argv[])
/* Process command line. */
{
optionInit(&argc, argv, options);
if (argc != 2)
usage();
udcSetDefaultDir(optionVal("udcDir", udcDefaultDir()));
bigBedInfo(argv[1]);
if (verboseLevel() > 1)
printVmPeak();
return 0;
}
Source diff could not be displayed: it is too large. Options to address this: view the blob.
This diff is collapsed.
File added
Source diff could not be displayed: it is too large. Options to address this: view the blob.
File added
/* bigBedSummary - Extract summary information from a bigBed file.. */
/* Copyright (C) 2011 The Regents of the University of California
* See README in this or parent directory for licensing information. */
#include "common.h"
#include "linefile.h"
#include "hash.h"
#include "options.h"
#include "sqlNum.h"
#include "bigBed.h"
#include "asParse.h"
#include "udc.h"
#include "obscure.h"
char *summaryType = "coverage";
void usage()
/* Explain usage and exit. */
{
errAbort(
"bigBedSummary - Extract summary information from a bigBed file.\n"
"usage:\n"
" bigBedSummary file.bb chrom start end dataPoints\n"
"Get summary data from bigBed for indicated region, broken into\n"
"dataPoints equal parts. (Use dataPoints=1 for simple summary.)\n"
"options:\n"
" -type=X where X is one of:\n"
" coverage - %% of region that is covered (default)\n"
" mean - average depth of covered regions\n"
" min - minimum depth of covered regions\n"
" max - maximum depth of covered regions\n"
" -fields - print out information on fields in file.\n"
" If fields option is used, the chrom, start, end, dataPoints\n"
" parameters may be omitted\n"
" -udcDir=/dir/to/cache - place to put cache for remote bigBed/bigWigs\n"
);
}
static struct optionSpec options[] = {
{"type", OPTION_STRING},
{"fields", OPTION_BOOLEAN},
{"udcDir", OPTION_STRING},
{NULL, 0},
};
void bigBedSummary(char *fileName, char *chrom, int start, int end, int dataPoints)
/* bigBedSummary - Extract summary information from a bigBed file.. */
{
/* Make up values array initialized to not-a-number. */
double nan0 = strtod("NaN", NULL);
double summaryValues[dataPoints];
int i;
for (i=0; i<dataPoints; ++i)
summaryValues[i] = nan0;
struct bbiFile *bbi = bigBedFileOpen(fileName);
if (bigBedSummaryArray(bbi, chrom, start, end, bbiSummaryTypeFromString(summaryType),
dataPoints, summaryValues))
{
for (i=0; i<dataPoints; ++i)
{
double val = summaryValues[i];
if (i != 0)
printf("\t");
if (isnan(val))
printf("n/a");
else
printf("%g", val);
}
printf("\n");
}
else
{
errAbort("no data in region %s:%d-%d in %s\n", chrom, start, end, fileName);
}
bbiFileClose(&bbi);
}
void bigBedFields(char *fileName)
/* Print out info about fields in bed file. */
{
struct bbiFile *bbi = bigBedFileOpen(fileName);
printf("%d bed definition fields, %d total fields\n", bbi->definedFieldCount, bbi->fieldCount);
struct asObject *as = bigBedAs(bbi);
if (as != NULL)
{
struct asColumn *col;
for (col = as->columnList; col != NULL; col = col->next)
{
printf("\t%s\t%s\n", col->name, col->comment);
}
}
else
{
printf("No additional field information included.\n");
}
}
int main(int argc, char *argv[])
/* Process command line. */
{
optionInit(&argc, argv, options);
udcSetDefaultDir(optionVal("udcDir", udcDefaultDir()));
if (optionExists("fields"))
{
if (argc < 2)
usage();
bigBedFields(argv[1]);
}
else
{
summaryType = optionVal("type", summaryType);
if (argc != 6)
usage();
bigBedSummary(argv[1], argv[2], sqlUnsigned(argv[3]), sqlUnsigned(argv[4]), sqlUnsigned(argv[5]));
}
if (verboseLevel() > 1)
printVmPeak();
return 0;
}
Source diff could not be displayed: it is too large. Options to address this: view the blob.
This diff is collapsed.
File added
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment