Beispiel #1
0
static struct ccdsGeneMap *ccdsGetGenes(struct sqlConnection *conn, char *mapTable,
                                        char *ccdsId)
/* Get ccdsGeneMap objects for a ccdsId.  Returns only
 * the best overlapping ones (ones with the same cdsSimilariy as
 * the highest cdsSimilariy. */
{
struct ccdsGeneMap *ccdsGenes = NULL, *bestCcdsGenes = NULL, *ccdsGene;

/* filter by chrom due to PAR */
ccdsGenes = ccdsGeneMapSelectByCcds(conn, mapTable, ccdsId, seqName, 0.0);
if (ccdsGenes == NULL)
    return NULL;

bestCcdsGenes = slPopHead(&ccdsGenes);  /* seed with first */
while ((ccdsGene = slPopHead(&ccdsGenes)) != NULL)
    {
    if (ccdsGene->cdsSimilarity == bestCcdsGenes->cdsSimilarity)
        {
        /* same as best, keep */
        slAddHead(&bestCcdsGenes, ccdsGene);
        }
    else if (ccdsGene->cdsSimilarity > bestCcdsGenes->cdsSimilarity)
        {
        /* new best, replace list */
        ccdsGeneMapFreeList(&bestCcdsGenes);
        bestCcdsGenes = ccdsGene;
        }
    else
        {
        /* worse, drop */
        ccdsGeneMapFree(&ccdsGene);
        }
    }

/* only keep one of each gene */
slUniqify(&bestCcdsGenes, ccdsGeneMapGeneIdCmp, ccdsGeneMapFree);

return bestCcdsGenes;
}
Beispiel #2
0
int main(int argc, char *argv[])
/* Process command line. */
{
optionInit(&argc, argv, options);

if (argc != 2 && !optionExists("settings"))
    usage();

struct trackHubCheckOptions *checkOptions = NULL;
AllocVar(checkOptions);

checkOptions->specHost = (optionExists("test") ? "genome-test.soe.ucsc.edu" : "genome.ucsc.edu");
checkOptions->specHost = optionVal("specHost", checkOptions->specHost);

checkOptions->printMeta = optionExists("printMeta");
checkOptions->checkFiles = !optionExists("noTracks");
checkOptions->checkSettings = optionExists("checkSettings");

struct trackHubSettingSpec *setting = NULL;
AllocVar(setting);
setting->level = optionVal("level", "all");
if (trackHubSettingLevel(setting) < 0)
    {
    fprintf(stderr, "ERROR: Unrecognized support level %s\n\n", setting->level);
    usage();
    }
checkOptions->level = setting->level;

char *version = NULL;
if (optionExists("version"))
    version = optionVal("version", NULL);
checkOptions->version = version;

char *extraFile = optionVal("extra", NULL);
if (extraFile != NULL)
    addExtras(extraFile, checkOptions);

cacheTime = optionInt("cacheTime", cacheTime);
udcSetCacheTimeout(cacheTime);
// UDC cache dir: first check for hg.conf setting, then override with command line option if given.
setUdcCacheDir();
udcSetDefaultDir(optionVal("udcDir", udcDefaultDir()));

knetUdcInstall();  // make the htslib library use udc

if (optionExists("settings"))
    {
    showSettings(checkOptions);
    return 0;
    }

struct dyString *errors = newDyString(1024);
if (trackHubCheck(argv[1], checkOptions, errors))
    {
    // uniquify and count errors
    struct slName *errs = slNameListFromString(errors->string, '\n');
    slUniqify(&errs, slNameCmp, slNameFree);
    int errCount = slCount(errs);
    printf("Found %d problem%s:\n", errCount, errCount == 1 ? "" : "s");
    printf("%s\n", slNameListToString(errs, '\n'));
    return 1;
    }
return 0;
}