int main(int argc, char **argv) { Base base(10); AnotherBase anotherBase(20); Derived derived(30, 40); printBase(base); printBase(derived); printAnotherBase(anotherBase); printAnotherBase(derived); return 0; }
void printModel(Game *game) { int i; for(i=0; i<game->numRounds; i++) { printBase(&flopsBase[i]); } }
void printModel(Game *game) { int i; for(i=0; i<game->numRounds; i++) { fprintf(stdout, "%d th round:\n", i); printBase(&flopsBase[i]); } }
// o+o+o+o+o+o+o+o+o+o+o+o+o+o+o+o+o+o+o+o+o+o+o+o+o+o+o+o+o+o+o+o void Type::printType( std::ostream& out, Symbol *name, bool showBase, int level ) const { if (showBase) { printBase(out,level); if (name != NULL) out << " "; } printBefore(out,name,level); printAfter(out); }
void processIntToken( char* inStr, struct argsInfo info ){ long intToken; int i; ptrError = EINVAL; // Convert string to long intToken = strToLong(inStr, info.inputBase); /* Check for non-integer errors */ if (errno == ptrError) { (void) fprintf(stderr, STR_INT_ENDPTR_ERR, inStr,\ info.inputBase); return; } /* Check for conversion errors */ if (errno) { perror(inStr); return; } /* Print English mode */ if (info.mode & E_FLAG) { /* Check for negative numbers */ if (intToken < 0) { (void) printf(STR_MINUS); // Print out minus sign } printEnglish(abs(intToken)); (void) printf(STR_NEWLINE); } /* Print out the numbers in the given bases*/ for (i = MIN_BASE; i <= MAX_BASE; i++) { // Get the actual base value based on the given flags int realBase = getRealBase(BASE_MASK(i) & info.outputBases); switch (realBase) { case 0: break; /* Print in binary representation*/ case 2: printIntBinary(intToken); break; /* Print out prefix 0 and number in base 8 */ case 8: /* Print out negative sign if negative number */ if (intToken < 0) { (void) printf(STR_NEG_PREFIX); } (void) printf(STR_OCT_PREFIX); printBase(abs(intToken), realBase); (void) printf(STR_NEWLINE); break; /* Print out prefix 0x and number in base 16 */ case 16: /* Print out negative sign if negative number */ if (intToken < 0) { (void) printf(STR_NEG_PREFIX); } (void) printf(STR_HEX_PREFIX); printBase(abs(intToken), realBase); (void) printf(STR_NEWLINE); break; /* Print out number in given bases without prefixes */ default: if (intToken < 0) { (void) printf(STR_NEG_PREFIX); } printBase(abs(intToken), realBase); (void) printf(STR_NEWLINE); break; } } }
//main processing function // controlling flow for collecting data // from each alignment int processline(string line) { // variable definition stringList columns, deletions, insertions, mismatchList; string softclippedHead, softclippedTail; numList baseCounter, deletionBaseCounter, insertionBaseCounter, mismatchBaseCounter; numList headClippedBaseCounter, tailClippedBaseCounter; string chrom, id, sequence,quality; string deletionsString, insertionString, clippedString; string XGfield = "A", NMfield, MDfield; int numberOfMismatch, numberOfGapExtention; string cigarString, MDline, cigarLine; int i, seqlength, headClipped = 0, tailClipped = 0; double averageQualityScore, head5Qual, end5Qual; columns = split(line,'\t'); chrom = columns[2]; // only collect data from aligned reads if (chrom != "*") { //define columns id = columns[0]; cigarString = columns[5]; sequence = columns[9]; quality = columns[10]; seqlength = sequence.length(); baseCounter = getBaseCount(sequence); // collect base content averageQualityScore = averageQual(quality); // whole sequence quality head5Qual = averageQual(quality.substr(0,5)); // first 5 base quality end5Qual = averageQual(quality.substr(seqlength-5,5)); //end 5 base quality //define extra field // for XG, NM and MD findField(columns, XGfield, NMfield, MDfield); //get field item numberOfMismatch = atoi(extractField(NMfield).c_str()); if (XGfield.at(0) == 'X') { numberOfGapExtention = atoi(extractField(XGfield).c_str()); } else { numberOfGapExtention = 0; } // creating a line using MDfield MDline = processMD(MDfield, deletions); cigarLine = processCigar(cigarString, headClipped, tailClipped); mismatchList = insertionAndMismatch(cigarLine, MDline, sequence, insertions, softclippedHead, softclippedTail, id, numberOfMismatch); mismatchBaseCounter = getMismatchCount(mismatchList); int sumOfMismatch = std::accumulate(mismatchBaseCounter.begin(), mismatchBaseCounter.end(), 0); //count deletion and insertion deletionsString = concatString(deletions); insertionString = concatString(insertions); deletionBaseCounter = getBaseCount(deletionsString); insertionBaseCounter = getBaseCount(insertionString); headClippedBaseCounter = getBaseCount(softclippedHead); tailClippedBaseCounter = getBaseCount(softclippedTail); //assertions for verifying program assert (softclippedTail.length() == tailClipped); assert (softclippedHead.length() == headClipped); assert(accumulate(baseCounter.begin(),baseCounter.end(),0) == seqlength); //assert(sumOfMismatch + numberOfGapExtention == numberOfMismatch); // print out result cout << id << "\t"; //print out base counts printBase(baseCounter) ; cout << averageQualityScore << "\t" << head5Qual << "\t" << end5Qual << "\t"; cout << numberOfGapExtention << "\t" << numberOfMismatch - numberOfGapExtention << "\t"; //print mismatch // AtoC, AtoT, AtoG, CtoA, CtoT, CtoG, GtoA, GtoT, GtoC, TtoA,TtoC, TtoG printBase(mismatchBaseCounter); // print out deletion printBase(deletionBaseCounter) ; printBase(insertionBaseCounter) ; cout << headClipped << "\t" << tailClipped << "\t"; printBase(headClippedBaseCounter); printBase(tailClippedBaseCounter); cout << seqlength; cout << '\n'; } return 0; }
void testprintBase() { printf( "Testing printBase()\n\n" ); printf( "First line in each group below is the *expected* output.\n" ); printf( "Second line in each group is what *printBase* outputs.\n"); printf( "They should match exactly!\n" ); /* * Test with 0. */ printf( "\nTesting with value 0 - should print:\n" "0000 0000 0000 0000 0000 0000 0000 0000\n" ); printBase( 0 ); printf( "\n" ); /* * Test with 1. */ printf( "\nTesting with value 1 - should print:\n" "0000 0000 0000 0000 0000 0000 0000 0001\n" ); printBase( 1 ); printf( "\n" ); /* * Test with -1. */ printf( "\nTesting with value -1 - should print:\n" "1111 1111 1111 1111 1111 1111 1111 1111\n" ); printBase( -1 ); printf( "\n" ); /* * Test with LONG_MAX. */ printf( "\nTesting with value LONG_MAX - should print:\n" "0111 1111 1111 1111 1111 1111 1111 1111\n" ); printBase( LONG_MAX ); printf( "\n" ); /* * Test with LONG_MIN. */ printf( "\nTesting with value LONG_MIN - should print:\n" "1000 0000 0000 0000 0000 0000 0000 0000\n" ); printBase( LONG_MIN ); printf( "\n" ); }