bool ContextBase::isValidState() { if (!openFiles()) { return false; } if (!cmdArgsValid()) { return false; } if (!determineOutputType()) { return false; } return true; }
bool ContextBase::isValidState() { if (!openFiles()) { return false; } if (!cmdArgsValid()) { return false; } if (!determineOutputType()) { return false; } if (_program != GROUP_BY && _files[0]->getRecordType() == FileRecordTypeChecker::NO_POS_PLUS_RECORD_TYPE) { _errorMsg = "ERROR: file "; _errorMsg.append(_files[0]->getFileName()); _errorMsg.append(" has non positional records, which are only valid for \n"); _errorMsg.append(" the groupBy tool. Perhaps you are using a header"); _errorMsg.append(" line(s) that starts with \n"); _errorMsg.append(" something other than \"#\", \"chrom\", or \"chr\" (any case)?"); return false; } if (getObeySplits()) { _splitBlockInfo = new BlockMgr(_overlapFractionA, _reciprocalFraction); } if (hasColumnOpsMethods()) { if (hasIntersectMethods()) { for (int i=0; i < (int)_dbFileIdxs.size(); i++) { FileRecordMgr *dbFile = getFile(_dbFileIdxs[i]); _keyListOps->setDBfileType(dbFile->getFileType()); if (!_keyListOps->isValidColumnOps(dbFile)) { return false; } } } else { FileRecordMgr *dbFile = getFile(0); _keyListOps->setDBfileType(dbFile->getFileType()); if (!_keyListOps->isValidColumnOps(dbFile)) { return false; } } //if user specified a precision, pass it to //keyList ops if (_reportPrecision != -1) { _keyListOps->setPrecision(_reportPrecision); } } return true; }
bool ContextBase::isValidState() { if (!openFiles()) { return false; } if (!cmdArgsValid()) { return false; } if (!determineOutputType()) { return false; } if (hasColumnOpsMethods()) { FileRecordMgr *dbFile = getFile(hasIntersectMethods() ? _databaseFileIdx : 0); _keyListOps->setDBfileType(dbFile->getFileType()); if (!_keyListOps->isValidColumnOps(dbFile)) { return false; } } return true; }
bool ContextBase::isValidState() { if (!openFiles()) { return false; } if (!cmdArgsValid()) { return false; } if (!determineOutputType()) { return false; } if (getObeySplits()) { _splitBlockInfo = new BlockMgr(_overlapFraction, _reciprocal); } if (hasColumnOpsMethods()) { if (hasIntersectMethods()) { for (int i=0; i < (int)_dbFileIdxs.size(); i++) { FileRecordMgr *dbFile = getFile(_dbFileIdxs[i]); _keyListOps->setDBfileType(dbFile->getFileType()); if (!_keyListOps->isValidColumnOps(dbFile)) { return false; } } } else { FileRecordMgr *dbFile = getFile(0); _keyListOps->setDBfileType(dbFile->getFileType()); if (!_keyListOps->isValidColumnOps(dbFile)) { return false; } } //if user specified a precision, pass it to //keyList ops if (_reportPrecision != -1) { _keyListOps->setPrecision(_reportPrecision); } } return true; }
int main(int argc, const char *argv[]) { struct cmdlineInfo cmdline; FILE * underlayFileP; FILE * overlayFileP; FILE * alphaFileP; struct pam underlayPam; struct pam overlayPam; struct pam alphaPam; struct pam composedPam; int originLeft, originTop; pm_proginit(&argc, argv); parseCommandLine(argc, argv, &cmdline); overlayFileP = pm_openr(cmdline.overlayFilespec); overlayPam.comment_p = NULL; pnm_readpaminit(overlayFileP, &overlayPam, PAM_STRUCT_SIZE(opacity_plane)); if (overlayPam.len < PAM_STRUCT_SIZE(opacity_plane)) pm_error("Libnetpbm is too old. This program requires libnetpbm from " "Netpbm 10.56 (September 2011) or newer"); if (!overlayPam.visual) pm_error("Overlay image has tuple type '%s', which is not a " "standard visual type. We don't know how to compose.", overlayPam.tuple_type); initAlphaFile(cmdline, &overlayPam, &alphaFileP, &alphaPam); underlayFileP = pm_openr(cmdline.underlyingFilespec); underlayPam.comment_p = NULL; pnm_readpaminit(underlayFileP, &underlayPam, PAM_STRUCT_SIZE(opacity_plane)); assert(underlayPam.len >= PAM_STRUCT_SIZE(opacity_plane)); if (!overlayPam.visual) pm_error("Overlay image has tuple type '%s', which is not a " "standard visual type. We don't know how to compose.", overlayPam.tuple_type); computeOverlayPosition(underlayPam.width, underlayPam.height, overlayPam.width, overlayPam.height, cmdline, &originLeft, &originTop); composedPam.size = PAM_STRUCT_SIZE(opacity_plane); composedPam.len = PAM_STRUCT_SIZE(allocation_depth); composedPam.allocation_depth = 0; composedPam.file = pm_openw(cmdline.outputFilespec); composedPam.comment_p = NULL; determineOutputType(&underlayPam, &overlayPam, &composedPam); pnm_setminallocationdepth(&underlayPam, composedPam.depth); pnm_setminallocationdepth(&overlayPam, composedPam.depth); composite(originLeft, originTop, &underlayPam, &overlayPam, alphaFileP ? &alphaPam : NULL, cmdline.alphaInvert, cmdline.opacity, &composedPam, cmdline.linear, cmdline.mixtransparency); if (alphaFileP) pm_close(alphaFileP); pm_close(overlayFileP); pm_close(underlayFileP); pm_close(composedPam.file); /* If the program failed, it previously aborted with nonzero completion code, via various function calls. */ return 0; }
int main(int argc, char *argv[]) { struct cmdlineInfo cmdline; FILE * underlayFileP; FILE * overlayFileP; FILE * alphaFileP; struct pam underlayPam; struct pam overlayPam; struct pam alphaPam; struct pam composedPam; int originLeft, originTop; pnm_init(&argc, argv); parseCommandLine(argc, argv, &cmdline); overlayFileP = pm_openr(cmdline.overlayFilespec); pnm_readpaminit(overlayFileP, &overlayPam, PAM_STRUCT_SIZE(allocation_depth)); if (cmdline.alphaFilespec) { alphaFileP = pm_openr(cmdline.alphaFilespec); pnm_readpaminit(alphaFileP, &alphaPam, PAM_STRUCT_SIZE(allocation_depth)); if (overlayPam.width != alphaPam.width || overlayPam.height != alphaPam.height) pm_error("Opacity map and overlay image are not the same size"); } else alphaFileP = NULL; underlayFileP = pm_openr(cmdline.underlyingFilespec); pnm_readpaminit(underlayFileP, &underlayPam, PAM_STRUCT_SIZE(allocation_depth)); computeOverlayPosition(underlayPam.width, underlayPam.height, overlayPam.width, overlayPam.height, cmdline, &originLeft, &originTop); composedPam.size = sizeof(composedPam); composedPam.len = PAM_STRUCT_SIZE(allocation_depth); composedPam.allocation_depth = 0; composedPam.file = pm_openw(cmdline.outputFilespec); determineOutputType(&composedPam, &underlayPam, &overlayPam); pnm_setminallocationdepth(&underlayPam, composedPam.depth); pnm_setminallocationdepth(&overlayPam, composedPam.depth); composite(originLeft, originTop, &underlayPam, &overlayPam, alphaFileP ? &alphaPam : NULL, cmdline.alphaInvert, cmdline.opacity, &composedPam, cmdline.linear); if (alphaFileP) pm_close(alphaFileP); pm_close(overlayFileP); pm_close(underlayFileP); pm_close(composedPam.file); /* If the program failed, it previously aborted with nonzero completion code, via various function calls. */ return 0; }