Exemple #1
0
static void checkQueryFormat(struct hgFindSpec *hfs)
/* Make sure query looks right and jives with searchMethod. */
{
if (isNotEmpty(hfs->query) && !hgFindSpecSetting(hfs, "dontCheckQueryFormat"))
    {
    if (! regexMatchNoCase(hfs->query, queryFormatRegex))
	errAbort("hfsPolish: search %s: query needs to be of the format "
		 "\"select field1,field2,field3,field4 from %%s "
		 "where field4 like '%%s'\" "
		 "(for prefix, '%%s%%%%'; for fuzzy, '%%%%%%s%%%%'), "
		 "but instead is this:\n%s",
		 hfs->searchName, hfs->query);
    if (isNotEmpty(hfs->xrefQuery))
	{
	if (!regexMatchNoCase(hfs->query, exactTermFormatRegex))
	    errAbort("hfsPolish: search %s: there is an xrefQuery so query "
		     "needs to end with %s (exact match to xref results).",
		     hfs->searchName, exactTermFormat);
	}
    else
	{
	if (sameString(hfs->searchMethod, "fuzzy") &&
	    !endsWith(hfs->query, fuzzyTermFormat))
	    errAbort("hfsPolish: search %s: searchMethod is fuzzy so query "
		     "needs to end with %s.",
		     hfs->searchName, fuzzyTermFormat);
	else if (sameString(hfs->searchMethod, "prefix") &&
		 !regexMatchNoCase(hfs->query, prefixTermFormatRegex))
	    errAbort("hfsPolish: search %s: searchMethod is prefix so query "
		     "needs to end with %s.",
		     hfs->searchName, prefixTermFormat);
	
	else if (sameString(hfs->searchMethod, "exact") &&
		 !regexMatchNoCase(hfs->query, exactTermFormatRegex))
	    errAbort("hfsPolish: search %s: searchMethod is exact so query "
		     "needs to end with %s.",
		     hfs->searchName, exactTermFormat);
	}
    }
}
void LocalisedStrings::loadFromText (const String& fileContents, bool ignoreCase)
{
    translations.setIgnoresCase (ignoreCase);

    StringArray lines;
    lines.addLines (fileContents);

    for (auto& l : lines)
    {
        auto line = l.trim();

        if (line.startsWithChar ('"'))
        {
            auto closeQuote = findCloseQuote (line, 1);
            auto originalText = unescapeString (line.substring (1, closeQuote));

            if (originalText.isNotEmpty())
            {
                auto openingQuote = findCloseQuote (line, closeQuote + 1);
                closeQuote = findCloseQuote (line, openingQuote + 1);
                auto newText = unescapeString (line.substring (openingQuote + 1, closeQuote));

                if (newText.isNotEmpty())
                    translations.set (originalText, newText);
            }
        }
        else if (line.startsWithIgnoreCase ("language:"))
        {
            languageName = line.substring (9).trim();
        }
        else if (line.startsWithIgnoreCase ("countries:"))
        {
            countryCodes.addTokens (line.substring (10).trim(), true);
            countryCodes.trim();
            countryCodes.removeEmptyStrings();
        }
    }

    translations.minimiseStorageOverheads();
}
Exemple #3
0
char *vcfGetSlashSepAllelesFromWords(char **words, struct dyString *dy,
				     boolean *retSkippedFirstBase)
/* Overwrite dy with a /-separated allele string from VCF words,
 * skipping the extra initial base that VCF requires for indel alleles if necessary.
 * Return dy->string for convenience. */
{
dyStringClear(dy);
// VCF reference allele gets its own column:
char *refAllele = words[3];
char *altAlleles = words[4];
// First determine whether there is an extra initial base that we need to skip:
boolean allStartSame = TRUE;
char *p;
while ((p = strchr(altAlleles, ',')) != NULL)
    {
    if (altAlleles[0] != refAllele[0])
	allStartSame = FALSE;
    altAlleles = p+1;
    }
if (altAlleles[0] != refAllele[0])
    allStartSame = FALSE;
int offset = allStartSame ? 1 : 0;
if (refAllele[offset] == '\0')
    dyStringAppendC(dy, '-');
else
    dyStringAppend(dy, refAllele+offset);
// VCF alternate alleles are comma-separated, make them /-separated:
altAlleles = words[4];
if (isNotEmpty(altAlleles) && differentString(altAlleles, "."))
    {
    // Now construct the string:
    while ((p = strchr(altAlleles, ',')) != NULL)
	{
	dyStringAppendC(dy, '/');
	int len = p - altAlleles - offset;
	if (len == 0)
	    dyStringAppendC(dy, '-');
	else
	    dyStringAppendN(dy, altAlleles+offset, len);
	altAlleles = p+1;
	}
    dyStringAppendC(dy, '/');
    int len = strlen(altAlleles) - offset;
    if (len == 0)
	dyStringAppendC(dy, '-');
    else
	dyStringAppendN(dy, altAlleles+offset, len);
    }
if (retSkippedFirstBase)
    *retSkippedFirstBase = offset;
return dy->string;
}
Exemple #4
0
void ModuleList::scanGlobalJuceModulePath()
{
    modules.clear();

    auto& settings = getAppSettings();

    auto path = settings.getStoredPath (Ids::defaultJuceModulePath).toString();

    if (path.isNotEmpty())
        addAllModulesInFolder ({ path });

    sort();
}
Exemple #5
0
static boolean tableExists(char *database, char *table, char *splitPrefix)
/* Return TRUE if database and table exist.  If splitPrefix is given,
 * check for existence with and without it. */
{
struct sqlConnection *conn = hAllocConnMaybe(database);
if (conn == NULL)
    return FALSE;
char t2[1024];
if (isNotEmpty(splitPrefix))
    safef(t2, sizeof(t2), "%s%s", splitPrefix, table);
else
    safef(t2, sizeof(t2), "%s", table);
boolean hasSqlWildcard = (strchr(t2, '%') || strchr(t2, '_'));
boolean exists = hasSqlWildcard ? sqlTableWildExists(conn, t2) : sqlTableExists(conn, t2);
if (!exists && isNotEmpty(splitPrefix))
    {
    hasSqlWildcard = (strchr(table, '%') || strchr(table, '_'));
    exists = hasSqlWildcard ? sqlTableWildExists(conn, table) : sqlTableExists(conn, table);
    }
hFreeConn(&conn);
return exists;
}
Exemple #6
0
static void gapSanityCheck(struct agpGap *gapList)
{
int prevEnd = 0;
int prevStart = 0;
char *prevChr = NULL;
char *prevType = NULL;
struct agpGap *gap;

for (gap = gapList; gap; gap = gap->next)
    {
    int chrSize = hashIntVal(cInfoHash, gap->chrom);
    if (gap->chromEnd > chrSize)
	verbose(1, "WARNING: gap chromEnd > chromSize(%d) "
	    "at %s:%d-%d\n", chrSize, gap->chrom,
		gap->chromStart, gap->chromEnd);
    if (gap->chromEnd == chrSize && differentString(gap->type, "telomere"))
	verbose(1, "WARNING: gap at end of chromosome not telomere "
	    "at %s:%d-%d, type: %s\n", gap->chrom,
		gap->chromStart, gap->chromEnd, gap->type);
    if (gap->chromStart >= gap->chromEnd)
	verbose(1, "WARNING: gap chromStart >= chromEnd at %s:%d-%d\n",
	    gap->chrom, gap->chromStart, gap->chromEnd);
    if (prevEnd > 0)
	{
	if (sameWord(prevChr, gap->chrom) &&
		(prevEnd >= gap->chromStart))
	    verbose(1,"WARNING: overlapping gap at "
		"%s:%d-%d(%s) and %s:%d-%d(%s)\n",
		    gap->chrom, prevStart, prevEnd, prevType, gap->chrom,
			gap->chromStart, gap->chromEnd, gap->type);
	}
    else
	{
	prevStart = gap->chromStart;
	prevEnd = gap->chromEnd;
	prevType = gap->type;
	}
    if (isNotEmpty(prevChr))
	{
	if (differentWord(prevChr, gap->chrom))
	    {
	    freeMem(prevChr);
	    prevChr = cloneString(gap->chrom);
	    }
	}
    else
	prevChr = cloneString(gap->chrom);
    prevStart = gap->chromStart;
    prevEnd = gap->chromEnd;
    }
}
Exemple #7
0
static void vcfTabixLoadItems(struct track *tg)
/* Load items in window from VCF file using its tabix index file. */
{
char *fileOrUrl = NULL;
/* Figure out url or file name. */
if (tg->parallelLoading)
    {
    /* do not use mysql during parallel-fetch load */
    fileOrUrl = trackDbSetting(tg->tdb, "bigDataUrl");
    }
else
    {
    struct sqlConnection *conn = hAllocConnTrack(database, tg->tdb);
    fileOrUrl = bbiNameFromSettingOrTableChrom(tg->tdb, conn, tg->table, chromName);
    hFreeConn(&conn);
    }
if (isEmpty(fileOrUrl))
    return;
int vcfMaxErr = -1;
struct vcfFile *vcff = NULL;
boolean hapClustEnabled = cartOrTdbBoolean(cart, tg->tdb, VCF_HAP_ENABLED_VAR, TRUE);
/* protect against temporary network error */
struct errCatch *errCatch = errCatchNew();
if (errCatchStart(errCatch))
    {
    vcff = vcfTabixFileMayOpen(fileOrUrl, chromName, winStart, winEnd, vcfMaxErr, -1);
    if (vcff != NULL)
	{
	filterRecords(vcff, tg->tdb);
	if (hapClustEnabled && vcff->genotypeCount > 1 && vcff->genotypeCount < 3000 &&
	    (tg->visibility == tvPack || tg->visibility == tvSquish))
	    vcfHapClusterOverloadMethods(tg, vcff);
	else
	    {
	    tg->items = vcfFileToPgSnp(vcff, tg->tdb);
	    // pgSnp bases coloring/display decision on count of items:
	    tg->customInt = slCount(tg->items);
	    }
	// Don't vcfFileFree here -- we are using its string pointers!
	}
    }
errCatchEnd(errCatch);
if (errCatch->gotError || vcff == NULL)
    {
    if (isNotEmpty(errCatch->message->string))
	tg->networkErrMsg = cloneString(errCatch->message->string);
    tg->drawItems = bigDrawWarning;
    tg->totalHeight = bigWarnTotalHeight;
    }
errCatchFree(&errCatch);
}
static struct hash *hashFromCommaString(char *commaString)
/* Return a hash that stores words in comma-separated string, or NULL if string is NULL or empty. */
{
struct hash *hash = NULL;
if (isNotEmpty(commaString))
    {
    hash = hashNew(0);
    char *words[1024];
    int i, wordCount = chopCommas(commaString, words);
    for (i = 0;  i < wordCount;  i++)
        hashStoreName(hash, words[i]);
    }
return hash;
}
String AudioChannelSet::getSpeakerArrangementAsString() const
{
    StringArray speakerTypes;

    for (auto& speaker : getChannelTypes())
    {
        auto name = getAbbreviatedChannelTypeName (speaker);

        if (name.isNotEmpty())
            speakerTypes.add (name);
    }

    return speakerTypes.joinIntoString (" ");
}
Exemple #10
0
static void wikiTrackMapItem(struct track *tg, struct hvGfx *hvg, void *item,
	char *itemName, char *mapItemName, int start, int end, int x, int y, int width, int height)
/* create a special map box item with different i=hgcClickName and
 * pop-up statusLine with the item name
 */
{
char *userName;

/* already been determined to be enabled by getting here, need to verify
 *	userName vs editors and vs owner
 */
(void) wikiTrackEnabled(database, &userName);
char *hgcClickName = tg->mapItemName(tg, item);
char *statusLine = tg->itemName(tg, item);
boolean editor = isWikiEditor(userName);
struct wikiTrack *wikiItem = NULL;
boolean enableHgcClick = FALSE;

/* allow hgc click (i.e. delete privs) if the following are true
    1. this is the item 0 "add new item"
    2. logged into the wiki
    3. user is an editor or user is the owner
 */

if (differentWord("0", hgcClickName))
    wikiItem = findWikiItemId(hgcClickName);
else
    enableHgcClick = TRUE;	/* item 0 "add new item" must go to hgc */

if (wikiItem)
    {
    if (isNotEmpty(userName) && sameWord(userName, wikiItem->owner))
	enableHgcClick = TRUE;	/* owner has delete privls */
    if (editor)
	enableHgcClick = TRUE;	/* editors have delete privls */
    }

if (enableHgcClick)
    {
    mapBoxHgcOrHgGene(hvg, start, end, x, y, width, height, tg->track, 
                  hgcClickName, statusLine, NULL, FALSE, NULL         );
    }
else
    {	/* go directly to the wiki description */
    char *directUrl = wikiUrl(wikiItem);
    mapBoxHgcOrHgGene(hvg, start, end, x, y, width, height, tg->track, 
                  hgcClickName, statusLine, directUrl, FALSE, NULL);
    freeMem(directUrl);
    }
}
void CameraMovement::applySettings(ResourceDescriptor settings) {

    ResourceDescriptor sub = settings.getSubResource("CameraFriction");
    if (isNotEmpty(sub.getValue())) {
        m_cameraFriction = std::stod(sub.getValue());
    }

    sub = settings.getSubResource("ZoomInMultiplier");
    if (isNotEmpty(sub.getValue())) {
        m_zoomInMultiplier = std::stod(sub.getValue());
    }

    sub = settings.getSubResource("ZoomOutMultiplier");
    if (isNotEmpty(sub.getValue())) {
        m_zoomOutMultiplier = std::stod(sub.getValue());
    }

    sub = settings.getSubResource("MinimumCameraZ");
    if (isNotEmpty(sub.getValue())) {
        m_minimumCameraZ = std::stod(sub.getValue());
    }

}
Exemple #12
0
static void singleBamDetails(const bam1_t *bam)
/* Print out the properties of this alignment. */
{
const bam1_core_t *core = &bam->core;
char *itemName = bam1_qname(bam);
int tLength = bamGetTargetLength(bam);
int tStart = core->pos, tEnd = tStart+tLength;
boolean isRc = useStrand && bamIsRc(bam);
printPosOnChrom(seqName, tStart, tEnd, NULL, FALSE, itemName);
if (!skipQualityScore)
    printf("<B>Alignment Quality: </B>%d<BR>\n", core->qual);
printf("<B>CIGAR string: </B><tt>%s</tt> (", bamGetCigar(bam));
bamShowCigarEnglish(bam);
printf(")<BR>\n");
printf("<B>Tags:</B>");
bamShowTags(bam);
puts("<BR>");
printf("<B>Flags: </B><tt>0x%02x:</tt><BR>\n &nbsp;&nbsp;", core->flag);
bamShowFlagsEnglish(bam);
puts("<BR>");
if (bamIsRc(bam))
    printf("<em>Note: although the read was mapped to the reverse strand of the genome, "
	   "the sequence and CIGAR in BAM are relative to the forward strand.</em><BR>\n");
puts("<BR>");
struct dnaSeq *genoSeq = hChromSeq(database, seqName, tStart, tEnd);
char *qSeq = bamGetQuerySequence(bam, FALSE);
if (isNotEmpty(qSeq) && !sameString(qSeq, "*"))
    {
    char *qSeq = NULL;
    struct ffAli *ffa = bamToFfAli(bam, genoSeq, tStart, useStrand, &qSeq);
    printf("<B>Alignment of %s to %s:%d-%d%s:</B><BR>\n", itemName,
	   seqName, tStart+1, tEnd, (isRc ? " (reverse complemented)" : ""));
    ffShowSideBySide(stdout, ffa, qSeq, 0, genoSeq->dna, tStart, tLength, 0, tLength, 8, isRc,
		     FALSE);
    }
if (!skipQualityScore && core->l_qseq > 0)
    {
    printf("<B>Sequence quality scores:</B><BR>\n<TT><TABLE><TR>\n");
    UBYTE *quals = bamGetQueryQuals(bam, useStrand);
    int i;
    for (i = 0;  i < core->l_qseq;  i++)
        {
        if (i > 0 && (i % 24) == 0)
	    printf("</TR>\n<TR>");
        printf("<TD>%c<BR>%d</TD>", qSeq[i], quals[i]);
        }
    printf("</TR></TABLE></TT>\n");
    }
}
Exemple #13
0
static void vcfLoadItems(struct track *tg)
/* Load items in window from VCF file. */
{
int vcfMaxErr = -1;
struct vcfFile *vcff = NULL;
boolean hapClustEnabled = cartOrTdbBoolean(cart, tg->tdb, VCF_HAP_ENABLED_VAR, TRUE);
char *table = tg->table;
struct customTrack *ct = tg->customPt;
struct sqlConnection *conn;
if (ct == NULL)
    conn = hAllocConnTrack(database, tg->tdb);
else
    {
    conn = hAllocConn(CUSTOM_TRASH);
    table = ct->dbTableName;
    }
char *vcfFile = bbiNameFromSettingOrTable(tg->tdb, conn, table);
hFreeConn(&conn);
/* protect against parse error */
struct errCatch *errCatch = errCatchNew();
if (errCatchStart(errCatch))
    {
    vcff = vcfFileMayOpen(vcfFile, chromName, winStart, winEnd, vcfMaxErr, -1, TRUE);
    if (vcff != NULL)
	{
	filterRecords(vcff, tg->tdb);
	if (hapClustEnabled && vcff->genotypeCount > 1 && vcff->genotypeCount < 3000 &&
	    (tg->visibility == tvPack || tg->visibility == tvSquish))
	    vcfHapClusterOverloadMethods(tg, vcff);
	else
	    {
	    tg->items = vcfFileToPgSnp(vcff, tg->tdb);
	    // pgSnp bases coloring/display decision on count of items:
	    tg->customInt = slCount(tg->items);
	    }
	// Don't vcfFileFree here -- we are using its string pointers!
	}
    }
errCatchEnd(errCatch);
if (errCatch->gotError || vcff == NULL)
    {
    if (isNotEmpty(errCatch->message->string))
	tg->networkErrMsg = cloneString(errCatch->message->string);
    tg->drawItems = bigDrawWarning;
    tg->totalHeight = bigWarnTotalHeight;
    }
errCatchFree(&errCatch);
}
Exemple #14
0
static void writeFindPositionInfo(struct jsonWrite *jw, char *db, int taxId, char *hubUrl,
                                  char *position)
/* Write JSON for the info needed to populate the 'Find Position' section. */
{
char *genome = hGenome(db);
if (isEmpty(genome))
    {
    jsonWriteStringf(jw, "error", "No genome for db '%s'", db);
    }
else
    {
    jsonWriteString(jw, "db", db);
    jsonWriteNumber(jw, "taxId", taxId);
    jsonWriteString(jw, "genome", genome);
    struct slPair *dbOptions = NULL;
    char genomeLabel[PATH_LEN*4];
    if (isNotEmpty(hubUrl))
        {
        struct trackHub *hub = hubConnectGetHub(hubUrl);
        if (hub == NULL)
            {
            jsonWriteStringf(jw, "error", "Can't connect to hub at '%s'", hubUrl);
            return;
            }
        struct dbDb *dbDbList = trackHubGetDbDbs(hub->name);
        dbOptions = trackHubDbDbToValueLabel(dbDbList);
        safecpy(genomeLabel, sizeof(genomeLabel), hub->shortLabel);
        jsonWriteString(jw, "hubUrl", hubUrl);
        }
    else
        {
        dbOptions = hGetDbOptionsForGenome(genome);
        safecpy(genomeLabel, sizeof(genomeLabel), genome);
        }
    jsonWriteValueLabelList(jw, "dbOptions", dbOptions);
    jsonWriteString(jw, "genomeLabel", genomeLabel);
    jsonWriteString(jw, "position", position);
    char *suggestTrack = NULL;
    if (! trackHubDatabase(db))
        suggestTrack = assemblyGeneSuggestTrack(db);
    jsonWriteString(jw, "suggestTrack", suggestTrack);
    char *description = maybeGetDescriptionText(db);
    //#*** TODO: move jsonStringEscape inside jsonWriteString
    char *encoded = jsonStringEscape(description);
    jsonWriteString(jw, "description", encoded);
    listAssemblyHubs(jw);
    }
}
	CUtf8TextSegment & CUtf8TextSegment::operator=(const CUtf8TextSegment & x)
	{
		if (isNotEmpty())
		{
			MakeEmpty();
		}
		if (x.isNotEmpty())
		{
			m_pbyData = x.m_pbyData;
			m_uiByteCount = x.m_uiByteCount;
			m_uiAllocatedByteCount = x.m_uiAllocatedByteCount;
			m_puiRefCount = x.m_puiRefCount;
			(*m_puiRefCount)++;
		}
		return *this;
	}
Exemple #16
0
void writeAltFixMatches(struct jsonWrite *jw, struct slName *matches, char *category)
/* Append JSON objects containing alt or fix patch sequence names & optional category. */
{
struct slName *match;
for (match = matches; match != NULL; match = match->next)
    {
    if (strchr(match->name, '_'))
        {
        jsonWriteObjectStart(jw, NULL);
        jsonWriteString(jw, "value", match->name);
        if (isNotEmpty(category))
            jsonWriteString(jw, "category", category);
        jsonWriteObjectEnd(jw);
        }
    }
}
Exemple #17
0
void writePcrResultTrack(struct gfPcrOutput *gpoList, char *db, char *target)
/* Write trash files and store their name in a cart variable. */
{
    char *cartVar = pcrResultCartVar(db);
    struct tempName bedTn, primerTn;
    char buf[2048];
    trashDirFile(&bedTn, "hgPcr", "hgPcr", ".psl");
    trashDirFile(&primerTn, "hgPcr", "hgPcr", ".txt");
    gfPcrOutputWriteAll(gpoList, "psl", NULL, bedTn.forCgi);
    writePrimers(gpoList, primerTn.forCgi);
    if (isNotEmpty(target))
        safef(buf, sizeof(buf), "%s %s %s", bedTn.forCgi, primerTn.forCgi, target);
    else
        safef(buf, sizeof(buf), "%s %s", bedTn.forCgi, primerTn.forCgi);
    cartSetString(cart, cartVar, buf);
}
Exemple #18
0
void jsMakeTrackingRadioButtonExtraHtml(char *cgiVar, char *jsVar,
                                        char *val, char *selVal, char *extraHtml)
/* Make a radio button with extra HTML attributes that also sets tracking variable
 * in javascript. */
{
char id[256];
safef(id, sizeof id, "%s_%s", cgiVar, val);
hPrintf("<INPUT TYPE=RADIO NAME='%s' ID='%s'", cgiVar, id);
hPrintf(" VALUE=\"%s\"", val);
if (isNotEmpty(extraHtml))
    hPrintf(" %s", extraHtml);
jsOnEventByIdF("click", id, "%s='%s';", jsVar, val);
if (sameString(val, selVal))
    hPrintf(" CHECKED");
hPrintf(">");
}
Exemple #19
0
static char *maybeGetDescriptionText(char *db)
/* Slurp the description.html file for db into a string (if possible, don't die if
 * we can't read it) and return it. */
{
struct errCatch *errCatch = errCatchNew();
char *descText = NULL;
if (errCatchStart(errCatch))
    {
    char *htmlPath = hHtmlPath(db);
    if (isNotEmpty(htmlPath))
        descText = udcFileReadAll(htmlPath, NULL, 0, NULL);
    }
errCatchEnd(errCatch);
// Just ignore errors for now.
return descText;
}
Exemple #20
0
static void processProtSeq(FILE *fh, struct sqlConnection *conn, struct refSeqVerInfo *rsvi, struct hash *doneProts)
/* get an protein sequence, which already includes version in name. Don't duplicate NPs */
{
char query[128];
sqlSafef(query, sizeof(query), "SELECT protAcc FROM refLink WHERE mrnaAcc = \"%s\"", rsvi->acc);
char *protAcc = sqlNeedQuickString(conn, query);
if (isNotEmpty(protAcc) && hashLookup(doneProts, protAcc) == NULL)
    {
    struct dnaSeq *seq = hGenBankGetPepC(conn, protAcc, NULL);
    if (seq == NULL)
        errAbort("failed to get %s from database", protAcc);
    faWriteNext(fh, seq->name, seq->dna, seq->size);
    dnaSeqFree(&seq);
    hashAdd(doneProts, protAcc, NULL);
    }
freeMem(protAcc);
}
Exemple #21
0
INLINE void gtSummaryString(struct vcfRecord *rec, struct dyString *dy)
// Make pgSnp-like mouseover text, but with genotype counts instead of allele counts.
{
if (isNotEmpty(rec->name) && !sameString(rec->name, "."))
    dyStringPrintf(dy, "%s: ", rec->name);
if (rec->alleleCount < 2)
    {
    dyStringAppendC(dy, '?');
    return;
    }
const struct vcfFile *vcff = rec->file;
int gtRefRefCount = 0, gtRefAltCount = 0, gtAltAltCount = 0, gtUnkCount = 0, gtOtherCount = 0;
boolean allHaploid = TRUE;
int i;
for (i=0;  i < vcff->genotypeCount;  i++)
    {
    struct vcfGenotype *gt = &(rec->genotypes[i]);
    if (! gt->isHaploid)
        allHaploid = FALSE;
    if (gt->hapIxA == 0 && gt->hapIxB == 0)
	gtRefRefCount++;
    else if (gt->hapIxA == 1 && gt->hapIxB == 1)
	gtAltAltCount++;
    else if ((gt->hapIxA == 0 && gt->hapIxB == 1) || (gt->hapIxA == 1 && gt->hapIxB == 0))
	gtRefAltCount++;
    else if (gt->hapIxA < 0 || gt->hapIxB < 0)
	gtUnkCount++;
    else
	gtOtherCount++;
    }
char refAl[16];
abbrevAndHandleRC(refAl, sizeof(refAl), rec->alleles[0]);
char altAl1[16];
abbrevAndHandleRC(altAl1, sizeof(altAl1), rec->alleles[1]);
if (allHaploid)
    dyStringPrintf(dy, "%s:%d %s:%d",
		   refAl, gtRefRefCount, altAl1, gtRefAltCount);
else
    dyStringPrintf(dy, "%s/%s:%d %s/%s:%d %s/%s:%d", refAl, refAl, gtRefRefCount,
		   refAl, altAl1, gtRefAltCount, altAl1, altAl1, gtAltAltCount);
if (gtUnkCount > 0)
    dyStringPrintf(dy, " unknown:%d", gtUnkCount);
if (gtOtherCount > 0)
    dyStringPrintf(dy, " other:%d", gtOtherCount);
}
Exemple #22
0
static Array<File> getAllPossibleModulePathsFromExporters (Project& project)
{
    StringArray paths;

    for (Project::ExporterIterator exporter (project); exporter.next();)
    {
        auto& modules = project.getModules();
        auto n = modules.getNumModules();

        for (int i = 0; i < n; ++i)
        {
            auto id = modules.getModuleID (i);

            if (modules.shouldUseGlobalPath (id))
                continue;

            const auto path = exporter->getPathForModuleString (id);

            if (path.isNotEmpty())
                paths.addIfNotAlreadyThere (path);
        }

        String oldPath (exporter->getLegacyModulePath());

        if (oldPath.isNotEmpty())
            paths.addIfNotAlreadyThere (oldPath);
    }

    Array<File> files;

    for (auto& path : paths)
    {
        auto f = project.resolveFilename (path);

        if (f.isDirectory())
        {
            files.addIfNotAlreadyThere (f);

            if (f.getChildFile ("modules").isDirectory())
                files.addIfNotAlreadyThere (f.getChildFile ("modules"));
        }
    }

    return files;
}
Exemple #23
0
static void bigWigClick(struct trackDb *tdb, char *fileName)
/* Display details for BigWig data tracks. */
{
char *chrom = cartString(cart, "c");

/* Open BigWig file and get interval list. */
struct bbiFile *bbi = NULL;
struct lm *lm = lmInit(0);
struct bbiInterval *bbList = NULL;
char *maxWinToQuery = trackDbSettingClosestToHome(tdb, "maxWindowToQuery");

unsigned maxWTQ = 0;
if (isNotEmpty(maxWinToQuery))
    maxWTQ = sqlUnsigned(maxWinToQuery);

if ((maxWinToQuery == NULL) || (maxWTQ > winEnd-winStart))
    {
    bbi = bigWigFileOpen(fileName);
    bbList = bigWigIntervalQuery(bbi, chrom, winStart, winEnd, lm);
    }

char num1Buf[64], num2Buf[64]; /* big enough for 2^64 (and then some) */
sprintLongWithCommas(num1Buf, BASE_1(winStart));
sprintLongWithCommas(num2Buf, winEnd);
printf("<B>Position: </B> %s:%s-%s<BR>\n", chrom, num1Buf, num2Buf );
sprintLongWithCommas(num1Buf, winEnd-winStart);
printf("<B>Total Bases in view: </B> %s <BR>\n", num1Buf);

if (bbList != NULL)
    {
    bbiIntervalStatsReport(bbList, tdb->table, chrom, winStart, winEnd);
    }
else if ((bbi == NULL) && (maxWTQ <= winEnd-winStart))
    {
    sprintLongWithCommas(num1Buf, maxWTQ);
    printf("<P>Zoom in to a view less than %s bases to see data summary.</P>",num1Buf);
    }
else
    {
    printf("<P>No data overlapping current position.</P>");
    }

lmCleanup(&lm);
bbiFileClose(&bbi);
}
static void aftInitialize(struct annoFormatter *vSelf, struct annoStreamer *primary,
			  struct annoStreamer *integrators)
/* Print header, regardless of whether we get any data after this. */
{
struct annoFormatTab *self = (struct annoFormatTab *)vSelf;
if (self->needHeader)
    {
    char *primaryHeader = primary->getHeader(primary);
    if (isNotEmpty(primaryHeader))
	fprintf(self->f, "# Header from primary input:\n%s", primaryHeader);
    printHeaderColumns(self->f, primary, TRUE);
    struct annoStreamer *grator;
    for (grator = integrators;  grator != NULL;  grator = grator->next)
	printHeaderColumns(self->f, grator, FALSE);
    fputc('\n', self->f);
    self->needHeader = FALSE;
    }
}
Exemple #25
0
static char *lrgItemName(struct track *tg, void *item)
/* Return LRG ID and (if available) HUGO/HGNC gene symbol. */
{
struct linkedFeatures *lf = item;
struct lrg *lrg = lf->original;
if (isNotEmpty(lrg->hgncSymbol))
    {
    int nameLen = strlen(lrg->name);
    int symLen = strlen(lrg->hgncSymbol);
    int extraLen = 3;  // " ()"
    int labelSize = nameLen + symLen + extraLen + 1;
    char *label = needMem(labelSize);
    safef(label, labelSize, "%s (%s)", lrg->name, lrg->hgncSymbol);
    return label;
    }
else
    return lf->name;
}
Exemple #26
0
static char *trackHubDefaultAssembly(struct trackHub *hub)
/* If hub->defaultDb is an assembly genome, return it; otherwise return the first assembly.
 * Don't free result. */
{
char *defaultDb = hub->defaultDb;
char *firstAssemblyDb = NULL;
struct trackHubGenome *genome;
for (genome = hub->genomeList;  genome != NULL;  genome = genome->next)
    {
    if (isNotEmpty(genome->twoBitPath))
        {
        if (sameString(defaultDb, genome->name))
            return defaultDb;
        else if (firstAssemblyDb == NULL)
            firstAssemblyDb = genome->name;
        }
    }
return firstAssemblyDb;
}
Exemple #27
0
struct vcfFile *vcfTabixFileMayOpen(char *fileOrUrl, char *chrom, int start, int end,
				    int maxErr, int maxRecords)
/* Parse header and rows within the given position range from a VCF file that has been
 * compressed and indexed by tabix into a vcfFile object; return NULL if or if file has
 * no items in range.
 * If maxErr not zero, then continue to parse until this number of error have been reached.
 * A maxErr less than zero does not stop and reports all errors. */
{
struct lineFile *lf = lineFileTabixMayOpen(fileOrUrl, TRUE);
struct vcfFile *vcff = vcfFileHeaderFromLineFile(lf, maxErr);
if (vcff == NULL)
    return NULL;
if (isNotEmpty(chrom) && start != end)
    {
    if (lineFileSetTabixRegion(lf, chrom, start, end))
	vcfParseData(vcff, maxRecords);
    }
return vcff;
}
struct dyString *ensContigViewUrl(
char *database, char *ensOrg, char *chrom, int chromSize,
                            int winStart, int winEnd, char *archive)
/* Return a URL that will take you to ensembl's contig view. */
/* Not using chromSize.  archive is possibly a date reference */
{
struct dyString *dy = dyStringNew(0);
char *chrName;
char *ensemblName = ucscToEnsembl(database, chrom);
int ensemblLift = 0;
int start = winStart;
int end = winEnd;

if (isNotEmpty(ensemblName))
    {
    chrName = ensemblName;
    ensemblLift = liftToEnsembl(database, ensemblName);
    start += ensemblLift;
    end += ensemblLift;
    }
else if (startsWith("scaffold", chrom))
    chrName = chrom;
else
    chrName = skipChr(chrom);
if (archive)
    if (sameWord(archive,"ncbi36"))
	{
    dyStringPrintf(dy, 
	   "http://%s.ensembl.org/%s/contigview?chr=%s&start=%d&end=%d",
		    archive, ensOrg, chrName, start, end);
	}
    else
	{
    dyStringPrintf(dy, 
	   "http://%s.archive.ensembl.org/%s/contigview?chr=%s&start=%d&end=%d",
		    archive, ensOrg, chrName, start, end);
	}
else
    dyStringPrintf(dy, 
               "http://www.ensembl.org/%s/contigview?chr=%s&start=%d&end=%d", ensOrg, chrName, start, end);
return dy;
}
Exemple #29
0
    static String getMangledParameters (const URL& url)
    {
        jassert (url.getParameterNames().size() == url.getParameterValues().size());
        String p;

        for (int i = 0; i < url.getParameterNames().size(); ++i)
        {
            if (i > 0)
                p << '&';

            auto val = url.getParameterValues()[i];

            p << URL::addEscapeChars (url.getParameterNames()[i], true);

            if (val.isNotEmpty())
                p << '=' << URL::addEscapeChars (val, true);
        }

        return p;
    }
void print(Node *head){
    // Traverse to print
    NodeStack *s = (NodeStack *)malloc(sizeof(NodeStack));
    Node *current;
    initStack(s);

    tryPush(s, head);
    while(isNotEmpty(s)){
        current = pop(s);
        tryPush(s, current->right);
        tryPush(s, current->left);

        if (current->word != ""){
            printf(">%s<", current->word);
        }
    }

    printf("\n");
    free(s);
}