void Sim4::loadGlimmerModel (char *train_dir) { char filename[1000]; if (initGlimmerModel) return; /* LLL is this still needed? Yes, since it is initialized in the class Sim4*/ sprintf(filename, "%s/%s", train_dir, Glimmer_posDonModelPath); readModel (&donor_pos_model, filename); sprintf(filename, "%s/%s", train_dir, Glimmer_negDonModelPath); readModel (&donor_neg_model, filename); sprintf(filename, "%s/%s", train_dir, Glimmer_posAccModelPath); readModel (&acceptor_pos_model, filename); sprintf(filename, "%s/%s", train_dir, Glimmer_negAccModelPath); readModel (&acceptor_neg_model, filename); donor_pos_model_len = getModelLength (donor_pos_model); donor_neg_model_len = getModelLength (donor_neg_model); acceptor_pos_model_len = getModelLength (acceptor_pos_model); acceptor_neg_model_len = getModelLength (acceptor_neg_model); if (donor_pos_model_len!=donor_neg_model_len) fatal ("ERROR: Positive and negative donor model lengths differ\n"); if (acceptor_pos_model_len!=acceptor_neg_model_len) fatal ("ERROR: Positive and negative acceptor model lengths differ\n"); initGlimmerModel = 1; }
const U2AssemblyCoverageStat &AssemblyModel::getCoverageStat(U2OpStatus & os) { QMutexLocker mutexLocker(&mutex); Q_UNUSED(mutexLocker); if(cachedCoverageStat.isEmpty()) { U2AttributeDbi * attributeDbi = dbiHandle.dbi->getAttributeDbi(); if(NULL != attributeDbi) { U2ByteArrayAttribute attr = U2AttributeUtils::findByteArrayAttribute(attributeDbi, assembly.id, COVERAGE_STAT_ATTRIBUTE_NAME, os); if(!os.isCoR()) { if(attr.hasValidId()) { // TODO: check version U2AssemblyUtils::deserializeCoverageStat(attr.value, cachedCoverageStat, os); } else { qint64 length = getModelLength(os); if(!os.isCoR()) { static const qint64 MAX_COVERAGE_CACHE_SIZE = 1000*1000; int coverageCacheSize = (int)qMin(MAX_COVERAGE_CACHE_SIZE, length); cachedCoverageStat.resize(coverageCacheSize); calculateCoverageStat(U2Region(0, length), cachedCoverageStat, os); if(!os.isCoR()) { U2ByteArrayAttribute attribute; attribute.objectId = assembly.id; attribute.name = COVERAGE_STAT_ATTRIBUTE_NAME; attribute.value = U2AssemblyUtils::serializeCoverageStat(cachedCoverageStat); attribute.version = assembly.version; U2OpStatusImpl opStatus; attributeDbi->createByteArrayAttribute(attribute, opStatus); LOG_OP(opStatus); } } } } } else { os.setError("Attribute DBI is not supported"); } } return cachedCoverageStat; }
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; }
U2Region AssemblyModel::getGlobalRegion() { U2OpStatusImpl os; return U2Region(0, getModelLength(os)); }