Example #1
0
 ustring lastChar (const gchar *s) {
     return lastChar (_(s));
 }
Example #2
0
 bool analyseWordCheckSpecialConsonants (ustringArrayT word,
                                         ustring consonant) {
     return lastChar (word[0]).lowercase () == _(consonant[0]) &&
         firstChar (word[1]).lowercase () == _(consonant[1]);
 }
Example #3
0
 ustring lastChar (string s) {
     return lastChar (_(s));
 }
Example #4
0
 /*
  *  The command isprint() is used to determine printable
  *  characters.
  *
  *    @param   s       Input string
  *    @return  Returns a copy of the string, stripped
  *             of leading and trailing white space
  */
 std::string stripws(const std::string &s) {
   int ifirst = firstChar(s);
   int ilast = lastChar(s);
   return s.substr(ifirst, ilast - ifirst + 1); 
 }
Example #5
0
std::size_t ZLUnicodeUtil::lastChar(Ucs4Char &ch, const std::string &utf8String) {
	return lastChar(ch, utf8String.data() + utf8String.length());
}
void readFinfFiles(char *gsDir)
/* Read in .finf files and save info in cloneHash/cloneList. */
{
struct lineFile *lf;
struct clone *clone = NULL;
struct endInfo *end;
char fileName[512];
int i;
char *words[7];
char lastClone[64];
char cloneName[64];
int gsInfoCount = 0;
struct frag *frag;
boolean isFin;
char *s, *e;

strcpy(lastClone, "");
for (i=0; i<ArraySize(gsFiles); ++i)
    {
    isFin = (i <= 0);
    sprintf(fileName, "%s/%s", gsDir, gsFiles[i]);
    printf("Reading info from %s\n", fileName);
    lf = lineFileOpen(fileName, TRUE);
    while (lineFileRow(lf, words))
        {
	if (!sameString(words[1], lastClone))
	    {
	    struct clone *oldClone;
	    strcpy(lastClone, words[1]);
	    strcpy(cloneName, words[1]);
	    AllocVar(clone);
	    s = strchr(cloneName, '.');
	    if (s == NULL)
	        errAbort("Bad clone name format line %d of %s\n", lf->lineIx, lf->fileName);
	    if (strlen(s) >= sizeof(clone->version))
	        errAbort("Bad clone name format line %d of %s\n", lf->lineIx, lf->fileName);
	    strcpy(clone->version, s);
	    chopSuffix(cloneName);
	    clone->size = atoi(words[3]);
	    if ((oldClone = hashFindVal(cloneHash, cloneName)) != NULL)
		{
		if (isFin && clone->size == oldClone->size && sameString(clone->version, oldClone->version))
		    warn("Apparently benign duplication of %s line %d of %s", cloneName, lf->lineIx, lf->fileName);
		else
		    warn("%s duplicated line %d of %s (size %d oldSize %d)", cloneName, lf->lineIx, lf->fileName,
		    	clone->size, oldClone->size);
		}
	    hashAddSaveName(cloneHash, cloneName, clone, &clone->name);
	    clone->isFin = isFin;
	    slAddHead(&cloneList, clone);
	    }
	frag = newFrag(words[0], lf);
	slAddTail(&clone->fragList, frag);
	++clone->fragCount;
	if (!clone->isFin && !sameString(words[6], "?") && !sameString(words[6], "i") 
	   && !sameString(words[6], "w"))
	    {
	    char *s = strchr(words[0], '~');
	    char c;

	    if (s == NULL)
	        errAbort("Expecting ~ in fragment name line %d of %s\n", lf->lineIx, lf->fileName);
	    ++s;
	    AllocVar(end);
	    end->contig = cloneString(s);
	    subChar(s, '.', '_');
	    end->text = cloneString(words[6]);
	    c = lastChar(end->text);
	    if (!(c == 'L' || c == 'R'))
	        c = '?';
	    end->lr = c;
	    slAddHead(&clone->gsList, end);
	    ++gsInfoCount;
	    }
	}
    lineFileClose(&lf);
    }
printf("Found %d ends in %d clones\n", gsInfoCount, slCount(cloneList));
}
void addBacEndInfo(char *spFile)
/* Add BAC end info from Shiaw-Pyng's file to clones in cloneHash. */
{
struct lineFile *lf = lineFileOpen(spFile, TRUE);
char *line;
int lineSize, wordCount;
int spCount = 0;
char *words[16];

while (lineFileNext(lf, &line, &lineSize))
    {
    char *s, *e, c;
    struct clone *clone;
    struct endInfo *end;
    char *firstWord;
    char *contig;

    if (line[0] == '#')
       continue;
    wordCount = chopLine(line, words);
    if (wordCount == 0)
        continue;
    firstWord = words[0];
    s = strchr(firstWord, '.');
    if (s == NULL)
	errAbort("Expecting dot line %d of %s\n", lf->lineIx, lf->fileName);
    *s++ = 0;
    if ((clone = hashFindVal(cloneHash, firstWord)) == NULL)
	{
	warn("%s in %s but not .finf files", firstWord, spFile);
	continue;
	}
    if (!startsWith("Contig", s))
	errAbort("Expecting .Contig line %d of %s\n", lf->lineIx, lf->fileName);
    s += 6;
    contig = s;
    if (wordCount == 1)
	{
	/* Older style - just one word. */
	e = strrchr(contig, '.');
	if (e == NULL)
	    errAbort("Expecting last dot line %d of %s\n", lf->lineIx, lf->fileName);
	*e++ = 0;
	AllocVar(end);
	subChar(s, '.', '_');
	end->contig = cloneString(contig);
	end->text = cloneString(e);
	c = lastChar(end->text);
	if (!(c == 'L' || c == 'R'))
	    c = '?';
	end->lr = c;
	slAddHead(&clone->spList, end);
	++spCount;
	}
    else if (wordCount == 15)
        {
	/* Newer style - 15 words. */
	if (!sameWord(words[11], "total_repeats"))
	    {
	    AllocVar(end);
	    end->contig = cloneString(contig);
	    end->text = cloneString(words[2]);
	    c = words[3][0];
	    if (!(c == 'L' || c == 'R'))
		c = '?';
	    end->lr = c;
	    slAddHead(&clone->spList, end);
	    ++spCount;
	    }
	}
    else
        {
	lineFileExpectWords(lf, 15, wordCount);
	}
    }
lineFileClose(&lf);
printf("Info on %d ends in %s\n", spCount, spFile);
}