BAMImporterTask::BAMImporterTask(const GUrl& url, bool _useGui, const QVariantMap &hints) : DocumentProviderTask(tr("BAM/SAM file import: %1").arg(url.fileName()), TaskFlags_NR_FOSCOE), loadInfoTask(NULL), loadBamInfoTask(NULL), prepareToImportTask(NULL), convertTask(NULL), loadDocTask(NULL), isSqliteDbTransit(false), useGui(_useGui), sam(hints.value(SAM_HINT, false).toBool()), hints(hints), hintedDbiRef(hints.value(DocumentFormat::DBI_REF_HINT).value<U2DbiRef>()) { documentDescription = url.fileName(); loadInfoTask = new LoadInfoTask( url, sam ); addSubTask(loadInfoTask); }
void BAMImporterTask::initPrepareToImportTask() { GUrl srcUrl = loadInfoTask->getSourceUrl(); isSqliteDbTransit = hintedDbiRef.isValid() && SQLITE_DBI_ID != hintedDbiRef.dbiFactoryId; if (!isSqliteDbTransit) { localDbiRef = U2DbiRef(SQLITE_DBI_ID, srcUrl.dirPath() + QDir::separator() + srcUrl.fileName() + ".ugenedb"); } else { const QString tmpDir = AppContext::getAppSettings()->getUserAppsSettings()->getCurrentProcessTemporaryDirPath("assembly_conversion") + QDir::separator(); QDir().mkpath(tmpDir); const QString pattern = tmpDir + "XXXXXX.ugenedb"; QTemporaryFile *tempLocalDb = new QTemporaryFile(pattern, this); tempLocalDb->open(); const QString filePath = tempLocalDb->fileName(); tempLocalDb->close(); SAFE_POINT_EXT(QFile::exists(filePath), setError(tr("Can't create a temporary database")), ); localDbiRef = U2DbiRef(SQLITE_DBI_ID, filePath); } QString refUrl; bool convert = true; if (useGui) { QObjectScopedPointer<ConvertToSQLiteDialog> convertDialog = new ConvertToSQLiteDialog(loadInfoTask->getSourceUrl(), loadInfoTask->getInfo(), loadInfoTask->isSam()); convertDialog->hideAddToProjectOption(); const int rc = convertDialog->exec(); CHECK_EXT(!convertDialog.isNull(), setError("NULL dialog"), ); if (rc == QDialog::Accepted) { localDbiRef = U2DbiRef(SQLITE_DBI_ID, convertDialog->getDestinationUrl().getURLString()); refUrl = convertDialog->getReferenceUrl(); } else { convert = false; stateInfo.setCanceled(true); } } else if (loadInfoTask->isSam() && loadInfoTask->getInfo().getHeader().getReferences().isEmpty()) {