Exemplo n.º 1
0
int main() {
    const int kmerSizeMod = KMERSIZE+1;
    int finalANI = 0;
    char *ptr, *ptr2;
    char tempArr[kmerSizeMod], tempArr2[kmerSizeMod];
    FILE *fnaPointer;
    int numLines1 = numberOfLines(LINESIZE, FNANAME1);
    int numLines2 = numberOfLines(LINESIZE, FNANAME2);
    char **fna1Characters = fnaCharactersOf(FNANAME1, LINESIZE, numLines1); 
    char **fna2Characters = fnaCharactersOf(FNANAME2, LINESIZE, numLines2);
    int minimumLines;
    ptr=fna1Characters[0];
    ptr2=fna2Characters[0];
    int chr = 0;
    int chr2 = 0;
    int kmerCount = 0;
    if(numLines1 < numLines2) {
        minimumLines = numLines1;
    } else {
        minimumLines = numLines2;
    }
    const int numChars = minimumLines*LINESIZE;
    const int numKmers = (numLines1-1)*LINESIZE-KMERSIZE;
    for(int i=0; i<numChars; i++) {
        for(int j=0; j<kmerSizeMod; j++) {
            if(j == 0) {
                chr = i;
                chr2 = i;
            }
            if(j==kmerSizeMod-1) {
                tempArr[j] = '\0';
            } else {
                tempArr[j] = ptr[chr++];
            }
            if(j==kmerSizeMod-1) {
                tempArr2[j] = '\0';
            } else {
                tempArr2[j] = ptr2[chr2++];
            }
        } 
        if(strlen(tempArr) != KMERSIZE && strlen(tempArr2) != KMERSIZE) {break;}
        //int kmerANI = editDistance(tempArr, tempArr2, KMERSIZE, KMERSIZE);
        //finalANI = finalANI + kmerANI;
        printf("\nTempArr1: %s\n", tempArr);
        printf("TempArr2: %s\n", tempArr2);
        kmerCount++;
        //printf("%d\n", kmerANI);
    }
    //printf("\n ANI: %d\n", finalANI);
}
void RingBuffer::print(){
    Serial.print(F("Buffer Used: "));
    Serial.println(length());
    Serial.print(F("Buffer Number of Lines: "));
    Serial.println(numberOfLines());
    Serial.print(F("Buffer Begin: "));
    Serial.println(_beginningOfString);
    Serial.print(F("Buffer End: "));
    Serial.println(_endOfString);

    Serial.print(F("Buffer Contents: "));
    int i = _beginningOfString;
    while(i != _endOfString){
        if (_buffer[i] == '\n') {
            Serial.print(F("\\n"));
        }
        else if (_buffer[i] == '\r') {
            Serial.print(F("\\r"));
        }
        else if (_buffer[i] == '\t') {
            Serial.print(F("\\t"));
        }
        else {
            Serial.print(_buffer[i]);
        }
        _incrementVariable(&i);
    }

    Serial.println(F("(End of Buffer)"));

}
Exemplo n.º 3
0
//const char *FNANAME2 = "5mers2.fna";
int main() {
	int finalANI = 0;
  int numLines1 = numberOfLines(LINESIZE, FNANAME1) - 1;
  //int numLines2 = numberOfLines(LINESIZE, FNANAME2) - 1;
  char **fna1Characters = fnaCharactersOf(FNANAME1, LINESIZE, numLines1);
  //char **fna2Characters = fnaCharactersOf(FNANAME2, LINESIZE, numLines2);
  int numberOfKmers1 = numLines1*LINESIZE;
  //int numberOfKmers2 = numLines2*LINESIZE;
  char **kmersArrayMalloc1 = queryKmersIntoArray(fna1Characters[0], KMERSIZE, numLines1, LINESIZE);
  free(fna1Characters[0]);
  free(fna1Characters);
  //char **kmersArrayMalloc2 = queryKmersIntoArray(fna2Characters[0], KMERSIZE, numLines2, LINESIZE);
  //free(fna2Characters[0]);
  //free(fna2Characters);
  /*
  int minimumNumberOfKmers;
  if(numberOfKmers1 > numberOfKmers2) {
    minimumNumberOfKmers = numberOfKmers2;
  } else {
    minimumNumberOfKmers = numberOfKmers1;
  }
  for (int k = 0; k < minimumNumberOfKmers; k++) {
		int kmerANI = editDistance(kmersArrayMalloc1[k], kmersArrayMalloc2[k], KMERSIZE, KMERSIZE);
   		finalANI = finalANI + kmerANI;
   	}
    printf("ANI: %d\n", finalANI);
    free(kmersArrayMalloc1);
    free(kmersArrayMalloc2);
    */
    return 0;
}
void LineOrientedVT100Client::paint()
{
    int maximumNumberOfLinesToDraw = std::min(numberOfLines(), static_cast<size_t>(charactersWide()));
    int linesToDraw = calculateHowManyLinesFitWithWrapping(maximumNumberOfLinesToDraw);

    int currentBaseline = 0;
    for (size_t i = linesToDraw; i > 0; i--) {
        renderLine(linesToDraw - i, currentBaseline);
    }
}
int LineOrientedVT100Client::calculateHowManyLinesFitWithWrapping(int linesToDraw)
{
    int linesThatFit = 0;
    int currentLine = numberOfLines() - 1;
    int consumedHeight = 0;

    while (consumedHeight < charactersTall() && linesThatFit < linesToDraw) {
        linesThatFit++;
        consumedHeight += ceilf(static_cast<float>(lineAt(currentLine)->numberOfCharacters()) /
                                static_cast<float>(charactersWide()));
        currentLine--;
    }
    return linesThatFit;
}
Exemplo n.º 6
0
TEST(LC_806_Test, Test2) {

	std::string output;
	testing::internal::CaptureStdout();
	std::vector<int> widths = { 4,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10 };
	std::string S;
	S = "bbbcccdddaaa";

	std::vector<int> res = numberOfLines(widths, S);
	std::cout << res[0] << "\t" << res[1];

	output = testing::internal::GetCapturedStdout();

	EXPECT_EQ(1, 1);
	EXPECT_TRUE(true);
}
Exemplo n.º 7
0
TEST(LC_806_Test, Test1) {

	std::string output;
	testing::internal::CaptureStdout();
	std::vector<int> widths = { 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10 };
	std::string S;
	S = "abcdefghijklmnopqrstuvwxyz";

	std::vector<int> res = numberOfLines(widths, S);
	std::cout << res[0] << "\t" << res[1];

	output = testing::internal::GetCapturedStdout();

	EXPECT_EQ(1, 1);
	EXPECT_TRUE(true);
}
void RingBuffer::readLine(String &lineToReturn){
    /*

    Return one line (terminated with \n) from the buffer
    if there are no full lines in the buffer, passed string will be empty

    */
    lineToReturn = "";            // begin with an empty string

    if (numberOfLines() > 0) {    // there is at least one full line in the buffer
        char lastReadValue = '\0';
        while(lastReadValue != '\n'){   //read until the end of the line is found, building the string
            lastReadValue = read();
            lineToReturn += lastReadValue;
        }
    }
}
Exemplo n.º 9
0
/*
 *parseAnalyzeMdfFile function
 *
 *file : a pointer to file MDF file descriptor
 *
 *this function will take a MDF file descriptor and return
 *a pointer to a MDF struct represinting the information in the file
 */
struct MDF *parseAnalyzeMdfFile(FILE *file)
{
  int max_nol;
  char **arr;
  char **arr2;
  char **arr3;
  struct MDF *res;

  max_nol = numberOfLines(file);
  rewind(file);
  arr = getArrayOfLines(file, max_nol, 1000);
  fclose(file);

  arr2 = removeComments(arr, max_nol, 1000);
  freeCharArray(arr, max_nol);
  arr3 = removeEmptyLines(arr2, max_nol, 1000);
  freeCharArray(arr2, max_nol);

  res = createMDF(arr3);
  freeCharArray(arr3, max_nol);

  return res;
}
Exemplo n.º 10
0
int main(int argc, char** argv)
{
	int rank, p;
    	int n;
	int nb;
	int prow;
    	char ** a;
    	float *b;
	float * pb;
	gk_csr_t *mat;
	int * nEachData;
	int ndata;
	int i, j;
		if (argc != 3)
		{
			printf("error: invalid arguments\n");
			exit(-1);
		}
		mat = (gk_csr_t *) malloc(sizeof(gk_csr_t));
		n = numberOfLines(argv[1]);
		nb = numberOfLines(argv[2]);
		mat->nrows = nb;
		mat->ncols = nb;
		a = getDataA(argv[1], n);
		b = getDataB(argv[2], nb);
		mat->rowptr = (int *) calloc(nb + 1, sizeof(int));
		mat->rowval = (float *) malloc(sizeof(float) * n);
		mat->rowind = (int *) malloc(sizeof(int) * n);

		if (parseInput(a, mat, n, nb) == -1)
		{
			printf("ERROR: Failed to parse data.\n");
			exit(-1);
		}

	gk_csr_CreateIndex(mat, GK_CSR_COL);

	float * result = (float *) calloc(nb, sizeof(float));
	for (i = 0; i < nb; i++)
	{
		float output = 0.0;
		int total = mat->colptr[i+1] - mat->colptr[i];
		int * startind = mat->colind + mat->colptr[i];
		float * startval = mat->colval + mat->colptr[i];
		for (j = 0; j < total; j++)
		{
			result[startind[j]] += b[i] * startval[j];
//			printf("%f : val %f\n", b[startind[j]] ,startval[j]);
		}
	}
/*
	float * result = (float *) malloc(sizeof(float) * nb);
	for (i = 0; i < nb; i++)
	{
		float output = 0.0;
		int total = mat->rowptr[i+1] - mat->rowptr[i];
		int * startind = mat->rowind + mat->rowptr[i];
		float * startval = mat->rowval + mat->rowptr[i];
		for (j = 0; j < total; j++)
		{
			output += b[startind[j]] * startval[j];
			printf("%f : val %f\n", b[startind[j]] ,startval[j]);
		}
		result[i] = output;
	}
*/
	for (i = 0; i < nb; i++)
	{
		printf("%f\n", result[i]);
	}

/*
	for (i = 0; i < nb; i++)
	{
		int total = mat->rowptr[i+1] - mat->rowptr[i];
		int * startind = mat->rowind + mat->rowptr[i];
		float * startval = mat->rowval + mat->rowptr[i];
		for (j = 0; j < total; j++)
		{
			printf("row %d col %d : val %f\n",i, startind[j] ,startval[j]);
		}
	}
	printf("cols\n\n");
	for (i = 0; i < nb; i++)
	{
		int total = mat->colptr[i+1] - mat->colptr[i];
		int * startind = mat->colind + mat->colptr[i];
		float * startval = mat->colval + mat->colptr[i];
		for (j = 0; j < total; j++)
		{
			printf("col %d row %d : val %f\n",i, startind[j] ,startval[j]);
		}
	}
*/
	return 0;

    }
void LineOrientedVT100Client::appendNewLine()
{
    m_lines.push_back(new Line());
    m_cursorColumn = 0;
    m_cursorRow = numberOfLines() - 1;
}