bool Version::IsInRange(const wstring& sAssemblyVersion, const wstring& sOldVersion) { wstring sHigh = sOldVersion; Version assemblyVersion(sAssemblyVersion); std::string::size_type pos = sHigh.find(L"-"); if (pos != std::wstring::npos) { Version lowVersion(sHigh.substr(0, pos)); Version highVersion(sHigh.substr(pos + 1)); if (lowVersion <= assemblyVersion && assemblyVersion <= highVersion) { return true; } } else { Version aHightVer(sHigh); if (assemblyVersion == aHightVer) { return true; } } return false; }
void ConservationPlotWorkerFactory::init() { //init data path U2DataPath* dataPath = NULL; U2DataPathRegistry* dpr = AppContext::getDataPathRegistry(); if (dpr){ U2DataPath* dp = dpr->getDataPathByName(CONSERVATION_DATA_NAME); if (dp && dp->isValid()){ dataPath = dp; } } QList<PortDescriptor*> portDescs; //in port QMap<Descriptor, DataTypePtr> inTypeMap; Descriptor treatDesc(ANNOT_SLOT_ID, ConservationPlotWorker::tr("Input regions"), ConservationPlotWorker::tr("Regions (centered at peak summits for better performance).")); inTypeMap[treatDesc] = BaseTypes::ANNOTATION_TABLE_LIST_TYPE(); Descriptor inPortDesc(IN_PORT_DESCR, ConservationPlotWorker::tr("conservation_plot data"), ConservationPlotWorker::tr("Regions to plot the PhastCons scores profiles.")); DataTypePtr inTypeSet(new MapDataType(IN_TYPE_ID, inTypeMap)); portDescs << new PortDescriptor(inPortDesc, inTypeSet, true); QList<Attribute*> attrs; { Descriptor outFile(OUTPUT_FILE, ConservationPlotWorker::tr("Output file"), ConservationPlotWorker::tr("File to store phastcons results (BMP).")); Descriptor titleDescr(TITLE, ConservationPlotWorker::tr("Title"), ConservationPlotWorker::tr("Title of the figure (--title).")); Descriptor labelDescr(LABEL, ConservationPlotWorker::tr("Label"), ConservationPlotWorker::tr("Label of data in the figure (--bed-label).")); Descriptor assemblyVersion(ASSEMBLY_VER, ConservationPlotWorker::tr("Assembly version"), ConservationPlotWorker::tr("The directory to store phastcons scores (--phasdb).")); Descriptor windowSizeDescr(WINDOW_S, ConservationPlotWorker::tr("Window width"), ConservationPlotWorker::tr("Window width centered at middle of regions (-w).")); Descriptor heightDescr(HEIGHT, ConservationPlotWorker::tr("Height"), ConservationPlotWorker::tr("Height of plot (--height).")); Descriptor widthDescr(WIDTH, ConservationPlotWorker::tr("Width"), ConservationPlotWorker::tr("Width of plot (--width).")); attrs << new Attribute(outFile, BaseTypes::STRING_TYPE(), true, QVariant("")); attrs << new Attribute(titleDescr, BaseTypes::STRING_TYPE(), true, QVariant("Average Phastcons around the Center of Sites")); attrs << new Attribute(labelDescr, BaseTypes::STRING_TYPE(), true, QVariant("Conservation_at_peak_summits")); Attribute* assemblyVerAttr = NULL; if (dataPath){ const QList<QString>& dataNames = dataPath->getDataNames(); if (!dataNames.isEmpty()){ assemblyVerAttr = new Attribute(assemblyVersion, BaseTypes::STRING_TYPE(), true, dataPath->getPathByName(dataNames.first())); }else{ assemblyVerAttr = new Attribute(assemblyVersion, BaseTypes::STRING_TYPE(), true); } }else{ assemblyVerAttr = new Attribute(assemblyVersion, BaseTypes::STRING_TYPE(), true); } attrs << assemblyVerAttr; attrs << new Attribute(windowSizeDescr, BaseTypes::NUM_TYPE(), false, QVariant(1000)); attrs << new Attribute(heightDescr, BaseTypes::NUM_TYPE(), false, QVariant(1000)); attrs << new Attribute(widthDescr, BaseTypes::NUM_TYPE(), false, QVariant(1000)); } QMap<QString, PropertyDelegate*> delegates; { delegates[OUTPUT_FILE] = new URLDelegate(DialogUtils::prepareFileFilter(ConservationPlotWorker::tr("Conservation plot file"), QStringList("bmp"), true), "", false, false); { QVariantMap vm; vm["minimum"] = QVariant(0); vm["maximum"] = INT_MAX; vm["singleStep"] = QVariant(1000); delegates[WINDOW_S] = new SpinBoxDelegate(vm); delegates[HEIGHT] = new SpinBoxDelegate(vm); delegates[WIDTH] = new SpinBoxDelegate(vm); } { QVariantMap vm; if (dataPath){ vm = dataPath->getDataItemsVariantMap(); } delegates[ASSEMBLY_VER] = new ConservationPlotComboBoxWithUrlsDelegate(vm, true); } } Descriptor protoDesc(ConservationPlotWorkerFactory::ACTOR_ID, ConservationPlotWorker::tr("Build Conservation Plot"), ConservationPlotWorker::tr("Plots the PhastCons scores profiles.")); ActorPrototype *proto = new IntegralBusActorPrototype(protoDesc, portDescs, attrs); proto->setPrompter(new ConservationPlotPrompter()); proto->setEditor(new DelegateEditor(delegates)); proto->addExternalTool(ET_CONSERVATION_PLOT); WorkflowEnv::getProtoRegistry()->registerProto(BaseActorCategories::CATEGORY_CHIP_SEQ(), proto); WorkflowEnv::getDomainRegistry()->getById(LocalDomainFactory::ID)->registerEntry(new ConservationPlotWorkerFactory()); }