void twinOrfStats(char *axtFile, char *raFile, char *outFile) /* twinOrfStats - Collect stats on refSeq cDNAs aligned to another species via axtForEst. */ { struct hash *rsiHash = readRefRa(raFile); struct lineFile *lf = lineFileOpen(axtFile, TRUE); FILE *f = mustOpen(outFile, "w"); struct axt *axt; static struct countMatrix kozak[10], all, utr5, utr3, cds; static struct c2Counts c2All, c2Utr5, c2Utr3, c2Cds; char label[64]; char *predictFile = optionVal("predict", NULL); int i; struct codonCounts codons; initCounts(&codons, 1); threshold = optionFloat("threshold", threshold); while ((axt = axtRead(lf)) != NULL) { struct refSeqInfo *rsi = hashFindVal(rsiHash, axt->tName); if (rsi != NULL && rsi->cdsStart >= 5) { if (checkAtg(axt, rsi->cdsStart)) { for (i=0; i<10; ++i) addPos(&kozak[i], axt, rsi->cdsStart - 5 + i); addRange(&all, &c2All, axt, 0, rsi->size); addRange(&utr5, &c2Utr5, axt, 0, rsi->cdsStart); addRange(&cds, &c2Cds, axt, rsi->cdsStart, rsi->cdsEnd); addRange(&utr3, &c2Utr3, axt, rsi->cdsEnd, rsi->size); addCodons(&codons, axt, rsi->cdsStart, rsi->cdsEnd-3); } } axtFree(&axt); } lineFileClose(&lf); dumpCounts(f, &all, "all"); dumpCounts(f, &utr5, "utr5"); dumpCounts(f, &cds, "cds"); dumpCounts(f, &utr3, "utr3"); dumpM1(f, &c2All, "c2_all"); dumpM1(f, &c2Utr5, "c2_utr5"); dumpM1(f, &c2Cds, "c2_cds"); dumpM1(f, &c2Utr3, "c2_utr3"); for (i=0; i<10; ++i) { sprintf(label, "kozak[%d]", i-5); dumpCounts(f, &kozak[i], label); } dumpCodon(f, &codons, "codon"); if (predictFile) { predict(kozak, &all, axtFile, predictFile, rsiHash); } }
QuoteDialog::QuoteDialog(bool full, QWidget *parent) : QDialog(parent) { initCounts(); QFile styleSheet(":/resources/styles/fritzing.qss"); if (!styleSheet.open(QIODevice::ReadOnly)) { DebugDialog::debug("Unable to open :/resources/styles/fritzing.qss"); } else { this->setStyleSheet(styleSheet.readAll()); } setWindowTitle(tr("Fritzing Fab Quote")); QVBoxLayout * vLayout = new QVBoxLayout(this); QLabel * label = new QLabel(tr("Order your PCB from Fritzing Fab")); label->setObjectName("quoteOrder"); vLayout->addWidget(label); m_messageLabel = new QLabel(tr("")); m_messageLabel->setObjectName("quoteMessage"); vLayout->addWidget(m_messageLabel); m_tableWidget = new QTableWidget(3, MessageCount + 1); m_tableWidget->setObjectName("quoteTable"); m_tableWidget->setShowGrid(false); m_tableWidget->verticalHeader()->setVisible(false); m_tableWidget->horizontalHeader()->setVisible(false); #if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) m_tableWidget->verticalHeader()->setResizeMode(QHeaderView::ResizeToContents); m_tableWidget->horizontalHeader()->setResizeMode(QHeaderView::ResizeToContents); #else m_tableWidget->verticalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents); m_tableWidget->horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents); #endif m_tableWidget->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); m_tableWidget->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); m_tableWidget->setItemDelegate(new CustomDelegate(m_tableWidget)); QStringList labels; labels << tr("Copies") << tr("Price per board") << tr("Price"); int ix = 0; foreach (QString labl, labels) { QTableWidgetItem * item = new QTableWidgetItem(labl); item->setFlags(0); m_tableWidget->setItem(ix, 0, item); ix += 1; }
/******************************************************************************* ** Function: testStandardConditions ** Description: execute tests for standard conditions (see above). ** Parameters: ** players: the number of players ** player: the current player index ** handpos: index in hand the card was played from ** pre: gameState before card effect execution ** post: gameState after card effect execution ** passes: count of tests passed ** failures: count of tests failed ** Pre-Conditions: ** 2 <= players <= MAX_PLAYERS ** 0 <= player < MAX_PLAYERS ** handpos valid for current player ** pre and post are pointers to valid gameState structs ** passes and failures are pointers to valid integer accumulators ** Post-Conditions: passes and failures are incremented per test results *******************************************************************************/ void testStandardConditions(int players, int player, int handpos, struct gameState* pre, struct gameState* post, int* passes, int* failures) { int i; int result, result1, result2; int treasures; int playerDeltas[treasure_map + 1]; /* array of all card types */ int playedDeltas[treasure_map + 1]; /* array of all card types */ int handDeltas[treasure_map + 1]; /* array of all card types */ if (OUTPUTLEVEL > 1) printf("\nState: %d players, player index %d played " xstr(CARDUNDERTEST) " from hand position %d\n", players, player, handpos); /* VERIFY POST-CONDITIONS */ /* 1. The played card is added to the played cards pile */ /* check playedCardCount */ if (OUTPUTLEVEL > 1) printf("Test: Count played cards...\n"); result = deltaPlayedCardCount(pre, post); if (OUTPUTLEVEL > 1) printf("Result: Played %d cards, expected %d. ", result, 1); updateTestResult(result == 1, passes, failures); /* check that the played card is the only type added to playedCards */ if (OUTPUTLEVEL > 1) printf("Test: Played exactly 1 " xstr(CARDUNDERTEST) " card...\n"); result = checkSpecificPlayedCard(pre, post, CARDUNDERTEST); if (OUTPUTLEVEL > 1) printf("Result: "); updateTestResult(result == TRUE, passes, failures); /* 2. Current player receives <= 2 cards */ if (OUTPUTLEVEL > 1) printf("Test: Count cards added to hand...\n"); /* check count of cards in play (player hand + played) */ result = 0; result += deltaPlayedCardCount(pre, post); result += deltaPlayerHandCount(pre, post, player); if (OUTPUTLEVEL > 1) printf("Result: Added %d cards, expected <= %d. ", result, 2); updateTestResult(result <= 2 && result >= 0, passes, failures); result1 = result; /* Cards added are treasure cards */ if (OUTPUTLEVEL > 1) printf("Test: Cards added to hand are treasures...\n"); deltaPlayerCardTypesInHand(pre, post, player, handDeltas); result = TRUE; treasures = 0; for (i = 0; i <= treasure_map; i++) { if (i == copper || i == silver || i == gold) { if (handDeltas[i] < 0) result = FALSE; treasures += handDeltas[i]; } else if (i == CARDUNDERTEST) /* card that was played */ { if (handDeltas[i] != -1) result = FALSE; } else { if (handDeltas[i] != 0) result = FALSE; } } if (OUTPUTLEVEL > 1) printf("Result: "); updateTestResult(result == TRUE && treasures >= 0, passes, failures); /* 3. <= 2 cards received from the current player's deck */ if (OUTPUTLEVEL > 1) printf("Test: Count cards removed from deck...\n"); /* check count of cards drawn from player deck */ result = 0; result += deltaPlayerDeckCount(pre, post, player); /* current deck, may include discards shuffled into new deck */ result += deltaPlayerDiscardCount(pre, post, player); /* discard may have been shuffled into a new deck */ if (OUTPUTLEVEL > 1) printf("Result: Removed %d cards, expected <= %d. ", -result, 2); /* deck supply cards should decrease, so check negative of result */ updateTestResult(-result <= 2 && -result >= 0, passes, failures); result2 = -result; if (OUTPUTLEVEL > 1) printf("Test: Count cards added to hand == cards removed from deck...\n"); if (OUTPUTLEVEL > 1) printf("Result: Added %d, removed %d. ", result1, result2); updateTestResult(result1 == result2, passes, failures); /* * 4. The cards of the player's set of cards (in deck, hand, played, discard) * are unchanged(no cards "magically" appear or disappear). */ /* check count of cards */ if (OUTPUTLEVEL > 1) printf("Test: Player overall card COUNT (hand + deck + discard + played) unchanged...\n"); result = 0; result += deltaPlayedCardCount(pre, post); result += deltaPlayerCardCount(pre, post, player); if (OUTPUTLEVEL > 1) printf("Result: "); updateTestResult(result == 0, passes, failures); /* check type of cards */ if (OUTPUTLEVEL > 1) printf("Test: Player overall card TYPES (hand + deck + discard + played) unchanged...\n"); initCounts(playedDeltas); deltaPlayedCardTypes(pre, post, playedDeltas); initCounts(playerDeltas); deltaPlayerCardTypes(pre, post, player, playerDeltas); result = 0; for (i = 0; i <= treasure_map; i++) result += playedDeltas[i] + playerDeltas[i]; if (OUTPUTLEVEL > 1) printf("Result: "); updateTestResult(result == 0, passes, failures); /* 5. No state changes occur to other players */ if (OUTPUTLEVEL > 1) printf("Test: Other players' states unchanged...\n"); for (i = 0; i < players; i++) { if (i != player) { if (OUTPUTLEVEL > 1) printf("Result: Player %d state: ", i); result = playerCardStateChanged(pre, post, i); if (OUTPUTLEVEL > 1) { if (result == FALSE) printf("unchanged. "); else printf("changed. "); } updateTestResult(result == FALSE, passes, failures); } } /* 6. No state changes occur to the supply cards(kingdom, treasure, curse) nor to the victory cards */ if (OUTPUTLEVEL > 1) printf("Test: Curse, Victory, Treasure, Kingdom card COUNTS unchanged...\n"); result = curseCardStateChanged(pre, post); if (OUTPUTLEVEL > 1) { if (result == FALSE) printf("Result: Curse cards unchanged. "); else printf("Result: Curse cards changed. "); } updateTestResult(result == FALSE, passes, failures); result = victoryCardStateChanged(pre, post); if (OUTPUTLEVEL > 1) { if (result == FALSE) printf("Result: Victory cards unchanged. "); else printf("Result: Victory cards changed. "); } updateTestResult(result == FALSE, passes, failures); result = treasureCardStateChanged(pre, post); if (OUTPUTLEVEL > 1) { if (result == FALSE) printf("Result: Treasure cards unchanged. "); else printf("Result: Treasure cards changed. "); } updateTestResult(result == FALSE, passes, failures); result = kingdomCardStateChanged(pre, post, Kingdom); if (OUTPUTLEVEL > 1) { if (result == FALSE) printf("Result: Kingdom cards unchanged. "); else printf("Result: Kingdom cards changed. "); } updateTestResult(result == FALSE, passes, failures); }