本文整理汇总了C++中U2OpStatus::isCoR方法的典型用法代码示例。如果您正苦于以下问题:C++ U2OpStatus::isCoR方法的具体用法?C++ U2OpStatus::isCoR怎么用?C++ U2OpStatus::isCoR使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类U2OpStatus
的用法示例。
在下文中一共展示了U2OpStatus::isCoR方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getModelHeight
qint64 AssemblyModel::getModelHeight(U2OpStatus & os) {
if(NO_VAL == cachedModelHeight) {
U2AttributeDbi * attributeDbi = dbiHandle.dbi->getAttributeDbi();
if(attributeDbi != NULL) {
U2IntegerAttribute attr = U2AttributeUtils::findIntegerAttribute(attributeDbi, assembly.id, U2BaseAttributeName::max_prow, os);
LOG_OP(os);
if(attr.hasValidId()) {
if(attr.version == assembly.version) {
cachedModelHeight = attr.value;
} else if(checkPermissions(QFile::WriteUser,false)) {
U2AttributeUtils::removeAttribute(attributeDbi, attr.id, os);
LOG_OP(os);
}
}
}
if(cachedModelHeight == NO_VAL) {
// if could not get value from attribute, recompute the value...
cachedModelHeight = assemblyDbi->getMaxPackedRow(assembly.id, U2Region(0, getModelLength(os)), os);
LOG_OP(os);
if(! os.isCoR()) {
// ...and store it in a new attribure
U2IntegerAttribute attr;
U2AttributeUtils::init(attr, assembly, U2BaseAttributeName::max_prow);
attr.value = cachedModelHeight;
attributeDbi->createIntegerAttribute(attr, os);
}
}
if(cachedModelHeight == NO_VAL){
os.setError("Can't get model height, database is corrupted");
LOG_OP(os);
}
}
return cachedModelHeight;
}
示例2: errorLoggingBreak
static bool errorLoggingBreak(U2OpStatus& os, QMap<QString, QString>& skippedLines, const QString& seqName){
if (os.isCoR()){
if (skippedLines.size() < SKIPPED_LINES_ERRORS_LIMIT){
skippedLines.insert(seqName, os.getError());
}
return true;
}
return false;
}
示例3: count
void MysqlUpgraderFrom_1_15_To_1_16::upgradeFeatureDbi(U2OpStatus &os, MysqlDbRef *dbRef) const {
const bool featureClassFieldExist = (1 == U2SqlQuery(QString("SELECT count(*) FROM information_schema.COLUMNS WHERE "
"TABLE_SCHEMA = '%1' AND TABLE_NAME = 'Feature' "
"AND COLUMN_NAME = 'class'").
arg(dbRef->handle.databaseName()), dbRef, os).selectInt64());
CHECK_OP(os, );
CHECK(!featureClassFieldExist, );
U2SqlQuery("ALTER TABLE Feature CHANGE type class INTEGER NOT NULL", dbRef, os).execute();
CHECK_OP(os, );
U2SqlQuery("ALTER TABLE Feature ADD type INTEGER NOT NULL DEFAULT 0", dbRef, os).execute();
if (os.isCoR()) {
U2OpStatusImpl innerOs;
U2SqlQuery("ALTER TABLE Feature CHANGE class type INTEGER NOT NULL", dbRef, innerOs).execute();
return;
}
U2FeatureDbi *featureDbi = dbi->getFeatureDbi();
SAFE_POINT_EXT(NULL != featureDbi, os.setError(L10N::nullPointerError("feature dbi")), );
U2DbiIterator<U2Feature> *dbIterator = featureDbi->getFeatures(FeatureQuery(), os);
CHECK_OP(os, );
while (dbIterator->hasNext()) {
U2Feature feature = dbIterator->next();
U2FeatureType guessedFeatureType = U2FeatureTypes::MiscFeature;
GBFeatureKey gbFeatureKey = GBFeatureUtils::getKey(feature.name);
if (GBFeatureKey_UNKNOWN != gbFeatureKey) {
guessedFeatureType = GBFeatureUtils::getKeyInfo(GBFeatureUtils::getKey(feature.name)).type;
}
U2FeatureUtils::updateFeatureType(feature.id, guessedFeatureType, dbi->getDbiRef(), os);
CHECK_OP(os, );
}
U2SqlQuery("ALTER TABLE Feature ALTER type DROP DEFAULT", dbRef, os).execute();
CHECK_OP(os, );
}
示例4: readSequence
bool SwissProtPlainTextFormat::readSequence(ParserState *st, U2SequenceImporter& seqImporter, int& sequenceLen, int& fullSequenceLen, U2OpStatus& os){
QByteArray res;
IOAdapter* io = st->io;
U2OpStatus& si = st->si;
si.setDescription(tr("Reading sequence %1").arg(st->entry->name));
int headerSeqLen = st->entry->seqLen;
res.reserve(res.size() + headerSeqLen);
QByteArray readBuffer(READ_BUFF_SIZE, '\0');
char* buff = readBuffer.data();
//reading sequence
QBuffer writer(&res);
writer.open( QIODevice::WriteOnly);
bool ok = true;
int len;
while (ok && (len = io->readLine(buff, READ_BUFF_SIZE)) > 0) {
if (si.isCoR()) {
res.clear();
break;
}
if (len <= 0) {
si.setError(tr("Error parsing sequence: unexpected empty line"));
break;
}
if (buff[0] == '/') { //end of the sequence
break;
}
bool isSeek = writer.seek(0);
assert(isSeek); Q_UNUSED(isSeek);
//add buffer to result
for (int i= 0; i < len; i++) {
char c = buff[i];
if (c != ' ' && c != '\t') {
ok = writer.putChar(c);
if (!ok) {
break;
}
}
}
if (!ok) {
si.setError(tr("Error reading sequence: memory allocation failed"));
break;
}
seqImporter.addBlock(res,res.size(),os);
if(os.isCoR()){
break;
}
sequenceLen += res.size();
fullSequenceLen += res.size();
res.clear();
si.setProgress(io->getProgress());
}
if (!si.isCoR() && buff[0] != '/') {
si.setError(tr("Sequence is truncated"));
}
writer.close();
return true;
}
示例5: readBuff
void PDBFormat::PDBParser::parseBioStruct3D(BioStruct3D& biostruct, U2OpStatus& ti) {
QByteArray readBuff(DocumentFormat::READ_BUFF_SIZE + 1, 0);
char* buf = readBuff.data();
qint64 len = 0;
bool firstCompndLine = true;
while (!ti.isCoR()) {
bool lineOk = true;
len = io->readUntil(buf, DocumentFormat::READ_BUFF_SIZE, TextUtils::LINE_BREAKS, IOAdapter::Term_Include, &lineOk);
if (len == 0) {
break;
}
// there could be no terminator if this is end of file, so we have to check for this
if (!lineOk && !io->isEof()) {
ti.setError(U2::PDBFormat::tr("Line is too long"));
return;
}
currentPDBLine = QString(QByteArray(buf, len));
ti.setProgress(io->getProgress() * 0.8);
if (currentPDBLine.startsWith("HEADER")) {
parseHeader(biostruct, ti);
continue;
}
if (currentPDBLine.startsWith("COMPND")) {
parseMacromolecularContent(firstCompndLine, ti);
firstCompndLine = false;
continue;
}
if (currentPDBLine.startsWith("SEQRES")) {
parseSequence(biostruct, ti);
continue;
}
if (currentPDBLine.startsWith("HELIX ") || currentPDBLine.startsWith("SHEET ")
|| currentPDBLine.startsWith("TURN ")) {
parseSecondaryStructure(biostruct, ti);
continue;
}
if (currentPDBLine.startsWith("ATOM ") || currentPDBLine.startsWith("HETATM")) {
parseAtom(biostruct, ti);
continue;
}
if (currentPDBLine.startsWith("TER")) {
++currentChainIndex;
continue;
}
if (currentPDBLine.startsWith("SPLIT ")) {
parseSplitSection(ti);
continue;
}
if (currentPDBLine.startsWith("MODEL")) {
currentChainIndex = 1;
parseModel(biostruct, ti);
continue;
}
if (currentPDBLine.startsWith("ENDMDL")) {
flagMultipleModels = true;
++currentModelIndex;
continue;
}
}
CHECK_OP(ti,);
if (!flagAtomRecordPresent) {
ti.setError(U2::PDBFormat::tr("Some mandatory records are absent"));
}
updateSecStructChainIndexes(biostruct);
}
示例6: load
/**
* FASTQ format specification: http://maq.sourceforge.net/fastq.shtml
*/
static void load(IOAdapter* io, const U2DbiRef& dbiRef, const QVariantMap& hints, const GUrl& docUrl, QList<GObject*>& objects, U2OpStatus& os,
int gapSize, int predictedSize, QString& writeLockReason) {
DbiOperationsBlock opBlock(dbiRef, os);
CHECK_OP(os, );
Q_UNUSED(opBlock);
writeLockReason.clear();
bool merge = gapSize!=-1;
QByteArray sequence;
QByteArray qualityScores;
QStringList headers;
QSet<QString> uniqueNames;
QVector<U2Region> mergedMapping;
QByteArray gapSequence((merge ? gapSize : 0), 0);
sequence.reserve(predictedSize);
qualityScores.reserve(predictedSize);
// for lower case annotations
GObjectReference sequenceRef;
qint64 sequenceStart = 0;
U2SequenceImporter seqImporter(hints, true);
const QString folder = hints.value(DocumentFormat::DBI_FOLDER_HINT, U2ObjectDbi::ROOT_FOLDER).toString();
int seqNumber = 0;
int progressUpNum = 0;
const int objectsCountLimit = hints.contains(DocumentReadingMode_MaxObjectsInDoc) ? hints[DocumentReadingMode_MaxObjectsInDoc].toInt() : -1;
const bool settingsMakeUniqueName = !hints.value(DocumentReadingMode_DontMakeUniqueNames, false).toBool();
while (!os.isCoR()) {
//read header
QString sequenceName = readSequenceName(os, io, '@');
// check for eof while trying to read another FASTQ block
if (io->isEof()) {
break;
}
CHECK_OP_BREAK(os);
if(sequenceName.isEmpty()){
sequenceName = "Sequence";
}
if ((merge == false) || (seqNumber == 0)) {
QString objName = sequenceName;
if (settingsMakeUniqueName) {
objName = (merge) ? "Sequence" : TextUtils::variate(sequenceName, "_", uniqueNames);
objName.squeeze();
uniqueNames.insert(objName);
}
seqImporter.startSequence(dbiRef, folder, objName, false, os);
CHECK_OP_BREAK(os);
}
//read sequence
if (merge && sequence.length() > 0) {
seqImporter.addDefaultSymbolsBlock(gapSize,os);
sequenceStart += sequence.length();
sequenceStart+=gapSize;
CHECK_OP_BREAK(os);
}
sequence.clear();
readSequence(os, io, sequence);
MemoryLocker lSequence(os, qCeil(sequence.size()/(1000*1000)));
CHECK_OP_BREAK(os);
Q_UNUSED(lSequence);
seqImporter.addBlock(sequence.data(),sequence.length(),os);
CHECK_OP_BREAK(os);
QString qualSequenceName = readSequenceName(os, io, '+');
if (!qualSequenceName.isEmpty()) {
static const QString err = U2::FastqFormat::tr("Not a valid FASTQ file: %1, sequence name differs from quality scores name: %2 and %3");
CHECK_EXT_BREAK(sequenceName == qualSequenceName,
os.setError(err.arg(docUrl.getURLString()).arg(sequenceName).arg(qualSequenceName)));
}
// read qualities
qualityScores.clear();
readQuality(os, io, qualityScores, sequence.size());
CHECK_OP_BREAK(os);
static const QString err = U2::FastqFormat::tr("Not a valid FASTQ file: %1. Bad quality scores: inconsistent size.").arg(docUrl.getURLString());
CHECK_EXT_BREAK(sequence.length() == qualityScores.length(), os.setError(err));
seqNumber++;
progressUpNum++;
if (merge) {
headers.append(sequenceName);
mergedMapping.append(U2Region(sequenceStart, sequence.length() ));
}
else {
if (objectsCountLimit > 0 && objects.size() >= objectsCountLimit) {
os.setError(FastqFormat::tr("File \"%1\" contains too many sequences to be displayed. "
"However, you can process these data using instruments from the menu <i>Tools -> NGS data analysis</i> "
"or pipelines built with Workflow Designer.")
//.........这里部分代码省略.........
示例7: load
void EMBLGenbankAbstractDocument::load(const U2DbiRef& dbiRef, IOAdapter* io, QList<GObject*>& objects, QVariantMap& fs, U2OpStatus& os, QString& writeLockReason) {
DbiOperationsBlock opBlock(dbiRef, os);
CHECK_OP(os, );
Q_UNUSED(opBlock);
writeLockReason.clear();
//get settings
int gapSize = qBound(-1, DocumentFormatUtils::getMergeGap(fs), 1000*1000);
bool merge = gapSize!=-1;
QScopedPointer<AnnotationTableObject> mergedAnnotations(NULL);
QStringList contigs;
QVector<U2Region> mergedMapping;
// Sequence loading is 'lazy', so, if there is no sequence, it won't be created and there is no need to remove it.
U2SequenceImporter seqImporter(fs, true);
const QString folder = fs.value(DBI_FOLDER_HINT, U2ObjectDbi::ROOT_FOLDER).toString();
QSet<QString> usedNames;
GObjectReference sequenceRef(GObjectReference(io->getURL().getURLString(), "", GObjectTypes::SEQUENCE));
QByteArray readBuffer(ParserState::LOCAL_READ_BUFFER_SIZE, '\0');
ParserState st(isNcbiLikeFormat() ? 12 : 5, io, NULL, os);
st.buff = readBuffer.data();
TmpDbiObjects dbiObjects(dbiRef, os);
int num_sequence = 0;
qint64 sequenceStart = 0;
int sequenceSize = 0;
int fullSequenceSize = 0;
const int objectsCountLimit = fs.contains(DocumentReadingMode_MaxObjectsInDoc) ? fs[DocumentReadingMode_MaxObjectsInDoc].toInt() : -1;
for (int i=0; !os.isCoR(); i++, ++num_sequence) {
if (objectsCountLimit > 0 && objects.size() >= objectsCountLimit) {
os.setError(EMBLGenbankAbstractDocument::tr("File \"%1\" contains too many sequences to be displayed. "
"However, you can process these data using instruments from the menu <i>Tools -> NGS data analysis</i> "
"or pipelines built with Workflow Designer.")
.arg(io->getURL().getURLString()));
break;
}
//TODO: reference to a local variable??? Such a pointer will become invalid
EMBLGenbankDataEntry data;
st.entry = &data;
if (num_sequence == 0 || merge == false){
seqImporter.startSequence(dbiRef, folder, "default sequence name", false, os); //change name and circularity after finalize method
CHECK_OP(os, );
}
sequenceSize = 0;
os.setDescription(tr("Reading entry header"));
int offset = 0;
if (merge && num_sequence > 0) {
offset = gapSize;
}
if (!readEntry(&st,seqImporter,sequenceSize,fullSequenceSize,merge,offset, os)) {
break;
}
if (merge && sequenceSize > 0 && num_sequence > 0) {
sequenceStart = fullSequenceSize - sequenceSize;
sequenceStart += gapSize;
fullSequenceSize += gapSize;
}
// tolerate blank lines between records
char ch;
bool b;
while ((b = st.io->getChar(&ch)) && (ch == '\n' || ch == '\r')){}
if (b) {
st.io->skip(-1);
}
AnnotationTableObject *annotationsObject = NULL;
if (data.hasAnnotationObjectFlag) {
QString annotationName = genObjectName(usedNames, data.name, data.tags, i+1, GObjectTypes::ANNOTATION_TABLE);
QVariantMap hints;
hints.insert(DBI_FOLDER_HINT, fs.value(DBI_FOLDER_HINT, U2ObjectDbi::ROOT_FOLDER));
if (Q_UNLIKELY(merge && NULL == mergedAnnotations)) {
mergedAnnotations.reset(new AnnotationTableObject(annotationName, dbiRef, hints));
}
annotationsObject = merge ? mergedAnnotations.data() : new AnnotationTableObject(annotationName, dbiRef, hints);
QStringList groupNames;
QMap<QString, QList<SharedAnnotationData> > groupName2Annotations;
for (int i = 0, n = data.features.size(); i < n; ++i) {
SharedAnnotationData &d = data.features[i];
if (!d->location->regions.isEmpty()) {
for (int i = 0, n = d->location->regions.size(); i < n; ++i) {
// for some reason larger numbers cannot be stored within rtree SQLite tables
if (d->location->regions[i].endPos() > 9223371036854775807LL) {
d->location->regions[i].length = 9223371036854775807LL - d->location->regions[i].startPos;
}
}
}
//.........这里部分代码省略.........
示例8: load
static void load(IOAdapter* io, const U2DbiRef& dbiRef, QList<GObject*>& objects, const QVariantMap& fs, U2OpStatus& os) {
DbiOperationsBlock opBlock(dbiRef, os);
CHECK_OP(os, );
Q_UNUSED(opBlock);
U2SequenceImporter seqImporter(fs, true);
const QString folder = fs.value(DocumentFormat::DBI_FOLDER_HINT, U2ObjectDbi::ROOT_FOLDER).toString();
QByteArray readBuffer(DocumentFormat::READ_BUFF_SIZE, '\0');
char* buff = readBuffer.data();
QBitArray ALPHAS = TextUtils::ALPHA_NUMS;
ALPHAS['-'] = true;
QByteArray seq;
QString seqName(io->getURL().baseFileName());
//reading sequence
QBuffer writer(&seq);
writer.open(QIODevice::WriteOnly);
TmpDbiObjects dbiObjects(dbiRef, os);
bool ok = true;
int len = 0;
bool isStarted = false;
int sequenceCounter = 0;
bool terminatorFound = false;
bool isSplit = fs.value((DocumentReadingMode_SequenceAsSeparateHint), false).toBool();
while (ok && !io->isEof()) {
len = io->readLine(buff, DocumentFormat::READ_BUFF_SIZE, &terminatorFound);
if (len <= 0){
continue;
}
seq.clear();
bool isSeek = writer.seek(0);
assert(isSeek); Q_UNUSED(isSeek);
if (os.isCoR()) {
break;
}
for (int i=0; i<len && ok; i++) {
char c = buff[i];
if (ALPHAS[(uchar)c]) {
ok = writer.putChar(c);
}
}
if(seq.size()>0 && isStarted == false ){
QString name = sequenceCounter == 0 ? seqName : seqName + QString("_%1").arg(sequenceCounter);
isStarted = true;
seqImporter.startSequence(dbiRef, folder, name, false, os);
}
if(isStarted){
seqImporter.addBlock(seq.data(),seq.size(),os);
}
if (seq.size()>0 && isStarted && terminatorFound && isSplit){
finishSequence(objects, io, os, dbiRef, fs, dbiObjects, seqImporter);
sequenceCounter++;
isStarted = false;
}
if (os.isCoR()) {
break;
}
os.setProgress(io->getProgress());
}
writer.close();
CHECK_OP(os, );
if (sequenceCounter == 0){
CHECK_EXT(isStarted == true, os.setError(RawDNASequenceFormat::tr("Sequence is empty")), );
}
示例9: load
static void load(IOAdapter* io, const U2DbiRef& dbiRef, const QVariantMap& fs, QList<GObject*>& objects,
int gapSize, QString& writeLockReason, U2OpStatus& os)
{
DbiOperationsBlock opBlock(dbiRef, os);
CHECK_OP(os, );
Q_UNUSED(opBlock);
static char fastaCommentStartChar = FastaFormat::FASTA_COMMENT_START_SYMBOL;
MemoryLocker memoryLocker(os, 1);
CHECK_OP(os, );
writeLockReason.clear();
QByteArray readBuff(DocumentFormat::READ_BUFF_SIZE + 1, 0);
char* buff = readBuff.data();
qint64 len = 0;
bool merge = gapSize != -1;
QStringList headers;
QSet<QString> uniqueNames;
QVector<U2Region> mergedMapping;
// for lower case annotations
GObjectReference sequenceRef;
//skip leading whites if present
bool lineOk = true;
static QBitArray nonWhites = ~TextUtils::WHITES;
io->readUntil(buff, DocumentFormat::READ_BUFF_SIZE, nonWhites, IOAdapter::Term_Exclude, &lineOk);
CHECK_EXT(!io->hasError(), os.setError(io->errorString()), );
U2SequenceImporter seqImporter(fs, true);
const QString folder = fs.value(DocumentFormat::DBI_FOLDER_HINT, U2ObjectDbi::ROOT_FOLDER).toString();
qint64 sequenceStart = 0;
int sequenceNumber = 0;
DbiConnection con(dbiRef, os);
bool headerReaded = false;
QStringList emptySeqNames;
const int objectsCountLimit = fs.contains(DocumentReadingMode_MaxObjectsInDoc) ? fs[DocumentReadingMode_MaxObjectsInDoc].toInt() : -1;
const bool settingsMakeUniqueName = !fs.value(DocumentReadingMode_DontMakeUniqueNames, false).toBool();
while (!os.isCoR()) {
//skip start comments and read header
if(!headerReaded){
do{
len = io->readLine(buff, DocumentFormat::READ_BUFF_SIZE);
CHECK_EXT(!io->hasError(), os.setError(io->errorString()), );
}while(buff[0] == fastaCommentStartChar && len > 0);
}
if (len == 0 && io->isEof()) { //end if stream
break;
}
CHECK_EXT(!io->hasError(), os.setError(io->errorString()), );
CHECK_EXT_BREAK(lineOk, os.setError(FastaFormat::tr("Line is too long")));
QString headerLine = QString(QByteArray(buff+1, len-1)).trimmed();
CHECK_EXT_BREAK(buff[0] == FastaFormat::FASTA_HEADER_START_SYMBOL, os.setError(FastaFormat::tr("First line is not a FASTA header")));
//read sequence
if (sequenceNumber == 0 || !merge) {
QString objName = headerLine;
if(objName.isEmpty()){
objName = "Sequence";
}
if (settingsMakeUniqueName) {
objName = (merge) ? "Sequence" : TextUtils::variate(objName, "_", uniqueNames);
objName.squeeze();
memoryLocker.tryAcquire(2*objName.size());
CHECK_OP_BREAK(os);
uniqueNames.insert(objName);
}
seqImporter.startSequence(os, dbiRef, folder, objName, false);
CHECK_OP_BREAK(os);
sequenceRef = GObjectReference(io->getURL().getURLString(), objName, GObjectTypes::SEQUENCE);
}
if (sequenceNumber >= 1 && merge) {
seqImporter.addDefaultSymbolsBlock(gapSize, os);
sequenceStart += gapSize;
CHECK_OP_BREAK(os);
}
int sequenceLen = 0;
while (!os.isCoR()) {
do {
len = io->readLine(buff, DocumentFormat::READ_BUFF_SIZE);
CHECK_EXT(!io->hasError(), os.setError(io->errorString()), );
} while (len <= 0 && !io->isEof());
CHECK_EXT(!io->hasError(), os.setError(io->errorString()), );
if (len <= 0 && io->isEof()) {
break;
}
CHECK_EXT(!io->hasError(), os.setError(io->errorString()), );
buff[len] = 0;
if(buff[0] != fastaCommentStartChar && buff[0] != FastaFormat::FASTA_HEADER_START_SYMBOL){
len = TextUtils::remove(buff, len, TextUtils::WHITES);
//.........这里部分代码省略.........