Пример #1
0
int main(int argc, const char * argv[]) {

    const char *sentence = "He was not in the cab at the time.";
    printf("\"%s\" has %d spaces \n", sentence, spaceCount(sentence));
    
    return 0;
}
Пример #2
0
int main(int argc, const char * argv[])
{

    char *word = "KC Arabit is AWESOME";

    printf("\"%s\"\n" ,word);
    printf("has %d number of spaces",spaceCount(word));
    
    return 0;
}
Пример #3
0
struct lineAli *makeLineAli(char *name, struct ffAli *aliList, DNA *hay, DNA *needle, int displayOffset)
/* Make up structure showing local alignment in detail. */
{
struct lineAli *la = AllocA(struct lineAli);
int dispSize = lineSize;
DNA *dispStart = hay + displayOffset;
DNA *dispEnd = dispStart + dispSize;
int displayEndIx = displayOffset + dispSize;
struct ffAli *ali;
int i;
int startIx, endIx;
int hToN;
DNA *h, *n;
DNA nuc;
int matchCount = 0;
int totalCount = 0;

la->name = name;
memset(la->line, ' ', dispSize);
for (ali = aliList; ali != NULL; ali = ali->right)
    {
    if (ali->hStart >= dispEnd || ali->hEnd <= dispStart)
        continue;
    startIx = ali->hStart - hay;
    if (startIx < displayOffset)
        startIx = displayOffset;
    endIx = ali->hEnd - hay;
    if (endIx > displayEndIx)
        endIx = displayEndIx;
    hToN = ali->nStart - ali->hStart;
    for (i=startIx; i<endIx; ++i)
        {
        h = hay+i;
        n = h + hToN;
        nuc = *n;
        if (*h != nuc)
            nuc = toupper(nuc);
        else
            ++matchCount;
        la->line[i-displayOffset] = nuc;
        ++totalCount;
        }
    }
la->score = lineSize - spaceCount(la->line);
return la;
}
Пример #4
0
int main(int argc, char* argv[]) {
  char* lines1[] = {
      "    xxxxxxxx    ",
      "   x        x   ",
      "  x          x  ",
      " x            x ",
      "x              x", //5
      "x    x    x    x",
      "x   xxx  xxx   x",
      "x    x    x    x",
      "x              x",
      "x     xxxx     x", //10
      "x      xx      x",
      "x   x      x   x",
      " x   xxxxxx   x ",
      "  x          x  ",
      "   x        x   ", //15
      "    xx    xx    ",
      "      xxxx      ", //17
      0 };
  int* image1 = makeImage(lines1);

  char* lines2[] = {
      "RRRRRRRRRRRR    ",
      "RR          RR  ",
      "RR           RR ",
      "RR            RR",
      "RR            RR", // 5
      "RR           RR ",
      "RR        RRRR  ",
      "RRRRRRRRRRRR    ",
      "RR        RRR   ",
      "RR          RR  ", // 10
      "RR           RR ",
      "RR            RR",
      "RR            RR",
      "RR            RR",
      "                ", //15
      "                ",
      "                ", //17
      0 };
  int* image2 = makeImage(lines2);

  char* lines3[] = { "ABC", "DEF", 0 };
  int* image3 = makeImage(lines3);

  char* lines4[] = {
    "abcdef",
    "ghijkl",
    "mnopqr",
    0 };
  int* image4 = makeImage(lines4);

  char* lines5[] = {
    "A CD F",
    " H  K ",
    "M OP R",
    0 };
  int* image5 = makeImage(lines5);

  printf("Here is the first image:\n");
  showImage(image1);

  printf("Here is the second image:\n");
  showImage(image2);

  printf("spaces in image1: %i\n\n", spaceCount(image1));
  printf("spaces in image2: %i\n\n", spaceCount(image2));
  printf("Here is the third image:\n");
  showImage(image3);


  printf("Result of call is %d\n", f(image1, image2));

  printf("Here is the first output image:\n");
  showImage(image1);

  printf("Here is the second output image:\n");
  showImage(image2);

  //printf("Here is the fourth output image:\n");
  //showImage(image4);

  return 0;
}
Пример #5
0
void showClump(struct ernaClump *clump, FILE *f)
/* Show detailed alignment for one clump. */
{
int chromStart = clump->start - 1000;
int chromEnd = clump->end + 1000;
int chromSize;
DNA *chromDna;
struct wormFeature *cdnaNameList, *cdnaName;
struct lineAli *laList = NULL, *la;
struct ffAli *ali;
struct dnaSeq *cdna;
boolean rcCdna;
int clumpSize = clump->end - clump->start + 1;
int displaySize = lineSize;
int displayStart = (clump->start+clump->end)/2 - displaySize/2;
int displayEnd = displayStart + displaySize;
int displayDnaOffset;
DNA *displayDna;
struct ernaHit *hit;

/* Get genomic dna and list of all cDNAs in area around clump. */
wormClipRangeToChrom(clump->chrom, &chromStart, &chromEnd);
chromSize = chromEnd - chromStart;
chromDna = wormChromPart(clump->chrom, chromStart, chromSize);
cdnaNameList = wormCdnasInRange(clump->chrom, chromStart, chromEnd);

/* Figure out 60 bases to display alignment around clump. */
wormClipRangeToChrom(clump->chrom, &displayStart, &displayEnd);
displaySize = displayEnd - displayStart;
displayDnaOffset = displayStart - chromStart;
displayDna = chromDna + displayDnaOffset;

/* Make up detailed alignment on each cDNA */
for (cdnaName = cdnaNameList; cdnaName != NULL; cdnaName = cdnaName->next)
    {
    struct wormCdnaInfo info;
    if (!wormCdnaSeq(cdnaName->name, &cdna, &info))
        {
        warn("Couldn't find %s", cdnaName->name);
        continue;
        }
    if (!ffFindEitherStrandN(cdna->dna, cdna->size, chromDna, chromSize, ffCdna, &ali, &rcCdna))
        {
        warn("Couldn't align %s", cdnaName->name);
        continue;
        }
    if (rcCdna)
        reverseComplement(cdna->dna, cdna->size);
    la = makeLineAli(cdnaName->name, ali, chromDna, cdna->dna, displayDnaOffset);
    la->isEmbryo = info.isEmbryonic;
    slAddHead(&laList, la);    
    freeDnaSeq(&cdna);
    ffFreeAli(&ali);
    }

/* Display genomic with upper case at hot spots*/
displayDna[displaySize] = 0;
for (hit = clump->hits; hit != NULL; hit = hit->next)
    {
    int doff = hit->pos - chromStart;
    chromDna[doff] = toupper(chromDna[doff]);
    }
fprintf(f, "%s Genomic\n", displayDna);

/* Display aligned list by sorted score. */
slSort(&laList, cmpLaScore);
for (la = laList; la != NULL; la = la->next)
    {
    if (spaceCount(la->line) != lineSize)
        fprintf(f, "%s %s %s\n", la->line, la->name, (la->isEmbryo ? "emb" : "   "));
    }
/* Clean up. */
slFreeList(&cdnaNameList);
slFreeList(&laList);
freeMem(chromDna);
}
Пример #6
0
int main(int argc, const char * argv[]) {
    // Counting Space Characters in String
    const char *sentence = "He was not in the cab at the time!";
    printf("There are %d spaces in the sentence: %s\n", spaceCount(sentence), sentence);
    return 0;
}