void BaseConnection::SetOptions_() { if (!Descriptor().SetNoSignal(true)) { logger_.warn("Could not disable SIGPIPE signaling on socket errors."); Descriptor().Close(); return; } if (!Descriptor().SetNoDelay(true)) { logger_.warn("Could not disable Nagle algorithm on socket."); Descriptor().Close(); return; } if (!Descriptor().SetNonBlocking()) { logger_.warn("Could not set non-blocking socket operation."); Descriptor().Close(); return; } if (!Descriptor().SetSendTimeout(handler_->GetConnectionTimeout())) { logger_.warn("Could not set socket send timeout."); Descriptor().Close(); return; } if (!Descriptor().SetReceiveTimeout(handler_->GetConnectionTimeout())) { logger_.warn("Could not set socket receive timeout."); Descriptor().Close(); return; } }
ObjectDescription FileDescriptionDBManager::loadObjectDescription(const std::string& inputStr) const { ObjectDescription entireDescription; std::vector<std::string> numbers(predictElementCount(inputStr)); numbers = boost::split(numbers, inputStr, [](char c){return c == NUMBER_DELIMITER;}); for(auto num: numbers) boost::algorithm::trim(num); // if(numbers.size() % 2 != 0) // throw InvalidFile("Input stream contains odd number of descriptors! They are not supported in current implementation. Entire input line: " + inputStr); // try // { auto it = numbers.begin(); while(it < numbers.end()) { // Descriptor::value_type re = boost::lexical_cast<Descriptor::value_type>(*it++); // Descriptor::value_type im = boost::lexical_cast<Descriptor::value_type>(*it++); // entireDescription.push_back(Descriptor(re, im)); entireDescription.push_back(Descriptor(boost::lexical_cast<Descriptor>(*it++))); } // } // catch(boost::bad_lexical_cast err) // { // throw std::runtime_error(std::string(err.what()) + " in line: " + inputStr); // } return entireDescription; }
void GetFileListWorkerFactory::init() { QList<PortDescriptor*> portDescs; { QMap<Descriptor, DataTypePtr> outTypeMap; outTypeMap[BaseSlots::URL_SLOT()] = BaseTypes::STRING_TYPE(); outTypeMap[BaseSlots::DATASET_SLOT()] = BaseTypes::STRING_TYPE(); DataTypePtr outTypeSet(new MapDataType(BasePorts::OUT_TEXT_PORT_ID(), outTypeMap)); portDescs << new PortDescriptor(Descriptor(OUT_PORT_ID, GetFileListWorker::tr("Output URL"), GetFileListWorker::tr("Paths read by the element.")), outTypeSet, false, true); } QList<Attribute*> attrs; { Descriptor inUrl(URL_ATTR, GetFileListWorker::tr("Input URL"), GetFileListWorker::tr("Input URL")); attrs << new URLAttribute(BaseAttributes::URL_IN_ATTRIBUTE(), BaseTypes::URL_DATASETS_TYPE(), true); } Descriptor protoDesc(GetFileListWorkerFactory::ACTOR_ID, GetFileListWorker::tr("File List"), GetFileListWorker::tr("Produces URL(s) to files from specified folders.")); ActorPrototype *proto = new IntegralBusActorPrototype(protoDesc, portDescs, attrs); proto->setEditor(new DelegateEditor(QMap<QString, PropertyDelegate*>())); proto->setPrompter(new GetFileListPrompter()); proto->setValidator(new DatasetValidator()); if(AppContext::isGUIMode()) { proto->setIcon( GUIUtils::createRoundIcon(QColor(85,85,255), 22)); } WorkflowEnv::getProtoRegistry()->registerProto(BaseActorCategories::CATEGORY_DATASRC(), proto); WorkflowEnv::getDomainRegistry()->getById(LocalDomainFactory::ID)->registerEntry(new GetFileListWorkerFactory()); }
Message Message::getEmptyMapMessage() { static const QVariantMap emptyData; static const QMap<Descriptor, DataTypePtr> emptyTypeMap; static DataTypePtr emptyType(new MapDataType(Descriptor(), emptyTypeMap)); return Message(emptyType, emptyData, -1); }
InferredType::Descriptor InferredType::Descriptor::forFlags(VM& vm, PutByIdFlags flags) { Kind kind = kindForFlags(flags); Structure* structure; if (hasStructure(kind)) structure = vm.heap.structureIDTable().get(decodeStructureID(flags)); else structure = nullptr; return Descriptor(kind, structure); }
void BaseConnection::Initialize() { if (!handler_) { Descriptor().Close(); return; } if (handler_->GetPoll()) { handler_->GetPoll()->Open(this); handler_->GetPoll()->InsertRead(this); handler_->GetPoll()->InsertWrite(this); handler_->GetPoll()->InsertError(this); } else { Descriptor().Close(); return; } SetState(STATE_CONNECTED); }
void BaseConnection::Close() { if (state_ == STATE_CLOSING) { return; } SetState(STATE_CLOSING); BaseConnection::sptr c = weak_this_.lock(); handler_->DeleteConnection(weak_this_); if (handler_->GetPoll()) { handler_->GetPoll()->RemoveRead(this); handler_->GetPoll()->RemoveWrite(this); handler_->GetPoll()->RemoveError(this); handler_->GetPoll()->Close(this); } if (Descriptor().IsValid()) { Descriptor().Close(); } }
void PortMapping::add(Protocol protocol, uint16_t internal, uint16_t suggested) { remove(protocol, internal); std::unique_lock<std::mutex> lock(mMutex); Entry &entry = mMap[Descriptor(protocol, internal)]; entry.suggested = suggested; entry.external = suggested; if(mProtocol) mProtocol->add(protocol, internal, entry.external); }
void IOFile::Open(const std::string &filename, std::ios_base::openmode mode) { char error_desc_buf[256] = {0}; bool readmode = !!(mode & ios_base::in); bool writemode = !!(mode & ios_base::out); bool appendmode = !!(mode & ios_base::app); bool seekend = !!(mode & ios_base::ate); bool truncate = !!(mode & ios_base::trunc); if (!readmode && !writemode) readmode = true; int flags = (readmode ? (writemode ? O_RDWR : O_RDONLY) : (writemode ? O_WRONLY : O_RDONLY)) | (appendmode ? O_APPEND : 0) | (truncate ? O_TRUNC : 0) | (O_CREAT); Descriptor fileno(open(filename.c_str(), flags)); if (fileno.GetNumber() == -1) throw IOException::MakeException(filename, errno); if (readmode) SetReadDescriptor(fileno); else SetReadDescriptor(Descriptor(-1)); if (writemode) SetWriteDescriptor(fileno); else SetWriteDescriptor(Descriptor(-1)); }
void AbstractTarget::Build(void) { Sizer(); Descriptor(); Allocator(); Vector(); VectorX(); Printer(); ShiftDipolesAndX(); PrepareIaniso(); PreparePyzd(); }
void DNAStatWorkerFactory::init() { QList<PortDescriptor*> portDescs; QList<Attribute*> attribs; //accept sequence and annotated regions as input QMap<Descriptor, DataTypePtr> inputMap; QMap<Descriptor, DataTypePtr> outputMap; inputMap[ BaseSlots::DNA_SEQUENCE_SLOT() ] = BaseTypes::DNA_SEQUENCE_TYPE(); outputMap[ BaseSlots::ANNOTATION_TABLE_SLOT() ] = BaseTypes::ANNOTATION_TABLE_TYPE(); { //Create input port descriptors Descriptor inDesc( BasePorts::IN_SEQ_PORT_ID(), DNAStatWorker::tr("Input sequence"), DNAStatWorker::tr("Sequence for which GC-content and GC3-content will be evaluated.") ); Descriptor outDesc( BasePorts::OUT_ANNOTATIONS_PORT_ID(), DNAStatWorker::tr("Result annotation"), DNAStatWorker::tr("Resulted annotations, with GC-content and GC3-content.") ); portDescs << new PortDescriptor( inDesc, DataTypePtr(new MapDataType("filter.anns", inputMap)), /*input*/ true ); portDescs << new PortDescriptor( outDesc, DataTypePtr(new MapDataType("filter.anns", outputMap)), /*input*/false, /*multi*/true ); } attribs << new Attribute(Descriptor(GCCONTENT, DNAStatWorker::tr("GC-content"), DNAStatWorker::tr("Evaluate GC-content.")), BaseTypes::BOOL_TYPE(),false, true); attribs << new Attribute(Descriptor(GC1CONTENT, DNAStatWorker::tr("GC1-content"), DNAStatWorker::tr("Evaluate GC1-content.")), BaseTypes::BOOL_TYPE(),false, true); attribs << new Attribute(Descriptor(GC2CONTENT, DNAStatWorker::tr("GC2-content"), DNAStatWorker::tr("Evaluate GC2-content.")), BaseTypes::BOOL_TYPE(),false, true); attribs << new Attribute(Descriptor(GC3CONTENT, DNAStatWorker::tr("GC3-content"), DNAStatWorker::tr("Evaluate GC3-content.")), BaseTypes::BOOL_TYPE(),false, true); Descriptor desc( ACTOR_ID, DNAStatWorker::tr("DNA Statistics"), DNAStatWorker::tr("Evaluates statistics for DNA sequences.") ); ActorPrototype * proto = new IntegralBusActorPrototype( desc, portDescs, attribs ); proto->setPrompter( new DNAStatWorkerPrompter() ); proto->setEditor(new DelegateEditor(QMap<QString, PropertyDelegate*>())); WorkflowEnv::getProtoRegistry()->registerProto( BaseActorCategories::CATEGORY_STATISTIC(), proto ); DomainFactory* localDomain = WorkflowEnv::getDomainRegistry()->getById( LocalDomainFactory::ID ); localDomain->registerEntry( new DNAStatWorkerFactory() ); }
BaseConnection::BaseConnection(const std::string& local, sockets::SocketAddress& remote, ServerSPtr& handler) : is_persistent_(false) , buffer_length_(1500) , buffer_(buffer_length_) , handler_(handler) , logger_(log4cpp::Category::getInstance("webserver")) { sockets::SocketFd fd; if (!fd.Open() || !fd.SetReuseAddress(true)) { base_throw(IOException, "Could not allocate socket for communication"); } if (!local.empty() && !fd.Bind(local)) { base_throw(IOException, "Could not bind socket to address"); } SetDescriptor(fd); SetOptions_(); if (!fd.Connect(remote)) { if (errno != EINPROGRESS) { fd.Close(); base_throw(IOException, "Could not connect to remote peer"); } fd_set rset, wset; timeval tv; FD_ZERO(&rset); FD_ZERO(&wset); FD_SET(Descriptor().Descriptor(), &rset); FD_SET(Descriptor().Descriptor(), &wset); tv.tv_sec = handler_->GetConnectionTimeout(); tv.tv_usec = 0; if (::select(fd.Descriptor() + 1, &rset, &wset, 0, &tv) == 0) { Descriptor().Close(); base_throw(IOException, "Connection timed out"); } } }
TEST(Descriptor, DefaultConstructedHasProperState) { ASSERT_EQ(0, Descriptor().map_type); ASSERT_EQ(0, Descriptor().num_partitions); ASSERT_EQ(Version::MAJOR, Descriptor().major_version); ASSERT_EQ(Version::MINOR, Descriptor().minor_version); ASSERT_FALSE(Descriptor().getFilePrefix().empty()); ASSERT_FALSE(Descriptor().getFileName().empty()); }
bool PortMapping::get(Protocol protocol, uint16_t internal, uint16_t &external) const { std::unique_lock<std::mutex> lock(mMutex); if(!mProtocol) return false; external = internal; Entry entry; if(mMap.get(Descriptor(protocol, internal), entry)) return false; if(!entry.external) return false; external = entry.external; return true; }
SSAO::SSAO(unsigned int width, unsigned int height, float radius) { _radius = radius; _ssaoFramebuffer = std::unique_ptr<Framebuffer>(new Framebuffer(width, height, GL_R8, false)); _blurSSAOBuffer = std::unique_ptr<BoxBlur>(new BoxBlur(width, height, true, Descriptor(GL_R8))); _programSSAO = Resources::manager().getProgram2D("ssao"); // Generate samples. std::vector<glm::vec3> samples; // We need random vectors in the half sphere above z, with more samples close to the center. for(int i = 0; i < 24; ++i){ glm::vec3 randVec = glm::vec3(Random::Float(-1.0f, 1.0f), Random::Float(-1.0f, 1.0f), Random::Float(0.0f, 1.0f) ); samples.push_back(glm::normalize(randVec)); samples.back() *= Random::Float(0.0f,1.0f); // Skew the distribution towards the center. float scale = i/24.0f; scale = 0.1f+0.9f*scale*scale; samples.back() *= scale; } // Send the samples to the GPU. _programSSAO->cacheUniformArray("samples", samples); // Noise texture (same size as the box blur applied after SSAO computation). // We need to generate two dimensional normalized offsets. std::vector<glm::vec3> noise; for(int i = 0; i < 25; ++i){ glm::vec3 randVec = glm::vec3(Random::Float(-1.0f, 1.0f), Random::Float(-1.0f, 1.0f), 0.0f); noise.push_back(glm::normalize(randVec)); } // Send the texture to the GPU. glGenTextures(1, &_noiseTextureID); glBindTexture(GL_TEXTURE_2D, _noiseTextureID); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB16F, 5 , 5, 0, GL_RGB, GL_FLOAT, &(noise[0])); // Need nearest filtering and repeat. glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_NEAREST); glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_NEAREST); glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S, GL_REPEAT); glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T, GL_REPEAT); checkGLError(); }
int sock_acceptor::open(const Address& local_addr, int recv_bufsize, int send_bufsize) { STACK_TRACE_LOG(); int rc = m_socket_.open(AF_INET, SOCK_STREAM, IPPROTO_TCP); if (0 != rc) { LOG(ERROR)("sock_acceptor::open error, open error, errno:%d", error_no()); return -1; } Socket::setnonblock(Descriptor(m_socket_)); //ÉèÖÃÍøÂçµ×²ãÊÕ·¢»º³åÇø³¤¶È Socket::setsockopt(Descriptor(m_socket_), SOL_SOCKET, SO_RCVBUF, reinterpret_cast<char*>(&recv_bufsize), sizeof(recv_bufsize)); int real_rcvbufsize = 0; socklen_t nsize = sizeof(real_rcvbufsize); Socket::getsockopt(Descriptor(m_socket_), SOL_SOCKET, SO_RCVBUF, reinterpret_cast<char*>(&real_rcvbufsize), &nsize); if (real_rcvbufsize != recv_bufsize) { LOG(WARN)("sock_acceptor::open error, setsockopt so_rcvbuf failed. set_size:%d real_size:%d.", recv_bufsize, real_rcvbufsize); } Socket::setsockopt(Descriptor(m_socket_), SOL_SOCKET, SO_SNDBUF, reinterpret_cast<char*>(&send_bufsize), sizeof(send_bufsize)); int real_sndbufsize = 0; Socket::getsockopt(Descriptor(m_socket_), SOL_SOCKET, SO_SNDBUF, reinterpret_cast<char*>(&real_sndbufsize), &nsize); if (real_sndbufsize != send_bufsize) { LOG(WARN)("sock_acceptor::open error, setsockopt so_sndbuf failed. set_size:%d real_size:%d.", send_bufsize, real_sndbufsize); } int val = 1; Socket::setsockopt(Descriptor(m_socket_), SOL_SOCKET, SO_REUSEADDR, (char*)&val, sizeof(val)); rc = m_socket_.bind(local_addr); if (0 != rc) { LOG(ERROR)("sock_acceptor::open error, bind error, errno:%d", error_no()); m_socket_.close(); return -1; } rc = m_socket_.listen(10240); if (0 != rc) { LOG(ERROR)("sock_acceptor::open error, listen error, errno:%d", error_no()); m_socket_.close(); return -1; } return 0; }
void SiteconWorkerFactory::init() { ActorPrototypeRegistry* r = WorkflowEnv::getProtoRegistry(); assert(r); { QMap<Descriptor, DataTypePtr> m; m[BaseSlots::URL_SLOT()] = BaseTypes::STRING_TYPE(); m[SiteconWorkerFactory::SITECON_SLOT] = SiteconWorkerFactory::SITECON_MODEL_TYPE(); DataTypePtr t(new MapDataType(Descriptor("write.sitecon.content"), m)); QList<PortDescriptor*> p; QList<Attribute*> a; Descriptor pd(SITECON_IN_PORT_ID, SiteconIO::tr("Sitecon model"), SiteconIO::tr("Input Sitecon model")); p << new PortDescriptor(pd, t, true /*input*/); Descriptor desc(SiteconWriter::ACTOR_ID, SiteconIO::tr("Write SITECON Model"), SiteconIO::tr("Saves all input SITECON profiles to specified location.")); IntegralBusActorPrototype* proto = new WriteSiteconProto(desc, p, a); proto->setPrompter(new SiteconWritePrompter()); r->registerProto(BaseActorCategories::CATEGORY_TRANSCRIPTION(), proto); } { QList<PortDescriptor*> p; QList<Attribute*> a; Descriptor pd(SITECON_OUT_PORT_ID, SiteconIO::tr("Sitecon model"), SiteconIO::tr("Loaded SITECON profile data.")); QMap<Descriptor, DataTypePtr> outM; outM[SiteconWorkerFactory::SITECON_SLOT] = SiteconWorkerFactory::SITECON_MODEL_TYPE(); p << new PortDescriptor(pd, DataTypePtr(new MapDataType("sitecon.read.out", outM)), false /*input*/, true /*multi*/); Descriptor desc(SiteconReader::ACTOR_ID, SiteconIO::tr("Read SITECON Model"), SiteconIO::tr("Reads SITECON profiles from file(s). The files can be local or Internet URLs.")); IntegralBusActorPrototype* proto = new ReadSiteconProto(desc, p, a); proto->setPrompter(new SiteconReadPrompter()); r->registerProto(BaseActorCategories::CATEGORY_TRANSCRIPTION(), proto); } SiteconBuildWorker::registerProto(); SiteconSearchWorker::registerProto(); DomainFactory* localDomain = WorkflowEnv::getDomainRegistry()->getById(LocalDomainFactory::ID); localDomain->registerEntry(new SiteconWorkerFactory(SiteconReader::ACTOR_ID)); localDomain->registerEntry(new SiteconWorkerFactory(SiteconWriter::ACTOR_ID)); localDomain->registerEntry(new SiteconWorkerFactory(SiteconSearchWorker::ACTOR_ID)); localDomain->registerEntry(new SiteconWorkerFactory(SiteconBuildWorker::ACTOR_ID)); }
void PFMatrixConvertWorker::registerProto() { QList<PortDescriptor*> p; QList<Attribute*> a; QMap<Descriptor, DataTypePtr> m; Descriptor id(FMATRIX_IN_PORT_ID, PFMatrixConvertWorker::tr("Frequency matrix"), PFMatrixConvertWorker::tr("Frequency matrix to convert.")); m[PFMatrixWorkerFactory::FMATRIX_SLOT] = PFMatrixWorkerFactory::FREQUENCY_MATRIX_MODEL_TYPE(); DataTypePtr t(new MapDataType(Descriptor("convert.pfmatrix.content"), m)); Descriptor od(WMATRIX_OUT_PORT_ID, PFMatrixConvertWorker::tr("Weight matrix"), PFMatrixConvertWorker::tr("Produced statistical model of specified TFBS data.")); p << new PortDescriptor(id, t, true /*input*/); QMap<Descriptor, DataTypePtr> outM; outM[PWMatrixWorkerFactory::WMATRIX_SLOT] = PWMatrixWorkerFactory::WEIGHT_MATRIX_MODEL_TYPE(); p << new PortDescriptor(od, DataTypePtr(new MapDataType("fmatrix.convert.out", outM)), false /*input*/, true /*multi*/); { Descriptor ad(ALG_ATTR, PWMatrixBuildWorker::tr("Weight algorithm"), PWMatrixBuildWorker::tr("Different weight algorithms uses different functions to build weight matrices. It allows us to get better precision on different data sets. Log-odds, NLG and Match algorithms are sensitive to input matrices with zero values, so some of them may not work on those matrices.")); a << new Attribute(ad, BaseTypes::STRING_TYPE(), true, BuiltInPWMConversionAlgorithms::BVH_ALGO); } { Descriptor td(TYPE_ATTR, PWMatrixBuildWorker::tr("Matrix type"), PWMatrixBuildWorker::tr("Dinucleic matrices are more detailed, while mononucleic one are more useful for small input data sets.")); a << new Attribute(td, BaseTypes::BOOL_TYPE(), true, false /* false = mononucleic, true = dinucleic */); } Descriptor desc(ACTOR_ID, tr("Convert Frequency Matrix"), tr("Converts frequency matrix to weight matrix. Weight matrices are used for probabilistic recognition of transcription factor binding sites.")); ActorPrototype* proto = new IntegralBusActorPrototype(desc, p, a); QMap<QString, PropertyDelegate*> delegates; { QVariantMap modeMap; QStringList algo = AppContext::getPWMConversionAlgorithmRegistry()->getAlgorithmIds(); foreach (QString curr, algo) { modeMap[curr] = QVariant(curr); } delegates[ALG_ATTR] = new ComboBoxDelegate(modeMap); }
void PFMatrixBuildWorker::registerProto() { QList<PortDescriptor*> p; QList<Attribute*> a; QMap<Descriptor, DataTypePtr> m; Descriptor id(BasePorts::IN_MSA_PORT_ID(), PFMatrixBuildWorker::tr("Input alignment"), PFMatrixBuildWorker::tr("Input multiple sequence alignment for building statistical model.")); m[BaseSlots::MULTIPLE_ALIGNMENT_SLOT()] = BaseTypes::MULTIPLE_ALIGNMENT_TYPE(); DataTypePtr t(new MapDataType(Descriptor("build.pfmatrix.content"), m)); Descriptor od(FMATRIX_OUT_PORT_ID, PFMatrixBuildWorker::tr("Frequency matrix"), PFMatrixBuildWorker::tr("Produced statistical model of specified TFBS data.")); p << new PortDescriptor(id, t, true /*input*/); QMap<Descriptor, DataTypePtr> outM; outM[PFMatrixWorkerFactory::FMATRIX_SLOT] = PFMatrixWorkerFactory::FREQUENCY_MATRIX_MODEL_TYPE(); p << new PortDescriptor(od, DataTypePtr(new MapDataType("fmatrix.build.out", outM)), false /*input*/, true /*multi*/); { Descriptor td(TYPE_ATTR, PWMatrixBuildWorker::tr("Matrix type"), PWMatrixBuildWorker::tr("Dinucleic matrices are more detailed, while mononucleic one are more useful for small input data sets.")); a << new Attribute(td, BaseTypes::BOOL_TYPE(), true, false /* false = mononucleic, true = dinucleic */); } Descriptor desc(ACTOR_ID, tr("Build Frequency Matrix"), tr("Builds frequency matrix. Frequency matrices are used for probabilistic recognition of transcription factor binding sites.")); ActorPrototype* proto = new IntegralBusActorPrototype(desc, p, a); QMap<QString, PropertyDelegate*> delegates; { QVariantMap modeMap; modeMap[tr("Mononucleic")] = QVariant(false); modeMap[tr("Dinucleic")] = QVariant(true); delegates[TYPE_ATTR] = new ComboBoxDelegate(modeMap); } proto->setPrompter(new PFMatrixBuildPrompter()); proto->setEditor(new DelegateEditor(delegates)); proto->setIconPath(":weight_matrix/images/weight_matrix.png"); WorkflowEnv::getProtoRegistry()->registerProto(BaseActorCategories::CATEGORY_TRANSCRIPTION(), proto); }
InferredType::Descriptor InferredType::Descriptor::forValue(JSValue value) { if (value.isBoolean()) return Boolean; if (value.isUndefinedOrNull()) return Other; if (value.isInt32()) return Int32; if (value.isNumber()) return Number; if (value.isCell()) { JSCell* cell = value.asCell(); if (cell->isString()) return String; if (cell->isSymbol()) return Symbol; if (cell->isObject()) { if (cell->structure()->transitionWatchpointSetIsStillValid()) return Descriptor(ObjectWithStructure, cell->structure()); return Object; } } return Top; }
void createTestData() { ObjectDescription objDesc11; objDesc11.push_back(Descriptor(100)); objDesc11.push_back(Descriptor(200)); objDesc11.push_back(Descriptor(300));; ClassDescription clsDesc1; clsDesc1.push_back(objDesc11); ObjectDescription objDesc21; objDesc21.push_back(Descriptor(-100)); objDesc21.push_back(Descriptor(-200)); objDesc21.push_back(Descriptor(-300)); ClassDescription clsDesc2; clsDesc2.push_back(objDesc21); testData.insert(std::make_pair(ClassName("one"), clsDesc1)); testData.insert(std::make_pair(ClassName("two"), clsDesc2)); }
const Descriptor BaseActorCategories::CATEGORY_EXTERNAL() { return Descriptor("ex", tr("Custom Elements with CMD Tools"),""); }
/** * Creates an empty descriptor. */ Descriptor Descriptor::empty() { return Descriptor(); }
Descriptor Descriptor::create() { return Descriptor(new __Descriptor()); }
void createTestData() { ObjectDescription objDesc11; objDesc11.push_back(Descriptor(50)); objDesc11.push_back(Descriptor(50)); objDesc11.push_back(Descriptor(50)); ObjectDescription objDesc12; objDesc12.push_back(Descriptor(10)); objDesc12.push_back(Descriptor(10)); objDesc12.push_back(Descriptor(10)); ObjectDescription objDesc13; objDesc13.push_back(Descriptor(30)); objDesc13.push_back(Descriptor(30)); objDesc13.push_back(Descriptor(30)); ObjectDescription objDesc14; objDesc14.push_back(Descriptor(40)); objDesc14.push_back(Descriptor(40)); objDesc14.push_back(Descriptor(40)); ObjectDescription objDesc15; objDesc15.push_back(Descriptor(20)); objDesc15.push_back(Descriptor(20)); objDesc15.push_back(Descriptor(20)); ClassDescription clsDesc1; clsDesc1.push_back(objDesc11); clsDesc1.push_back(objDesc12); clsDesc1.push_back(objDesc13); clsDesc1.push_back(objDesc14); clsDesc1.push_back(objDesc15); ObjectDescription objDesc21; objDesc21.push_back(Descriptor(100)); objDesc21.push_back(Descriptor(100)); objDesc21.push_back(Descriptor(100)); ObjectDescription objDesc22; objDesc22.push_back(Descriptor(120)); objDesc22.push_back(Descriptor(120)); objDesc22.push_back(Descriptor(120)); ObjectDescription objDesc23; objDesc23.push_back(Descriptor(140)); objDesc23.push_back(Descriptor(140)); objDesc23.push_back(Descriptor(140)); ObjectDescription objDesc24; objDesc24.push_back(Descriptor(160)); objDesc24.push_back(Descriptor(160)); objDesc24.push_back(Descriptor(160)); ObjectDescription objDesc25; objDesc25.push_back(Descriptor(150)); objDesc25.push_back(Descriptor(150)); objDesc25.push_back(Descriptor(150)); ClassDescription clsDesc2; clsDesc2.push_back(objDesc21); clsDesc2.push_back(objDesc22); clsDesc2.push_back(objDesc23); clsDesc2.push_back(objDesc24); clsDesc2.push_back(objDesc25); testData.insert(std::make_pair(ClassName("one"), clsDesc1)); testData.insert(std::make_pair(ClassName("two"), clsDesc2)); }
int main(int argc, char **argv[]) { string name; vector<Mat>Images(100), TestImages(50); vector<Mat> Descriptor(100), TestDescriptor(50), TestPcafeature(50); vector<vector<KeyPoint>>Keypoints(100), TestKeypoint(50); Mat histogram = Mat::zeros(100, Cluster, CV_32F); Mat Testhistogram = Mat::zeros(50, Cluster, CV_32F); Mat Keyword = Mat::zeros(Cluster, 20, CV_32F); Mat full_Descriptor, Pcafeature, Pcaduplicate, clusteridx, trainlabels(100, 1, CV_32F); vector<vector<DMatch>> matches(50); Mat predicted(Testhistogram.rows, 1, CV_32F); // Read Training Images. read_train(Images, name); //Calculate SIFT features for the Training Images. calculate_SIFT(Images,Keypoints,Descriptor); merge_descriptor(full_Descriptor,Descriptor); //Compute PCA for all the features across all Images. PCA pca; perform_PCA(full_Descriptor, Pcafeature, pca); //Perform K-Means on all the PCA reduced features. Pcafeature.convertTo(Pcaduplicate, CV_32F); calculate_Kmeans(Pcaduplicate, clusteridx); //Calculate the Keywords in the Feature Space. make_dictionary(clusteridx, Pcaduplicate, Keyword); //Get the Histogram for each Training Image. hist(Descriptor, clusteridx, histogram); //Read Test Image read_test(TestImages, name); //Calculate the SIFT feature for all the test Images. calculate_SIFT(TestImages, TestKeypoint, TestDescriptor); //Project the SIFT feature of each feature on the lower dimensional PCA plane calculated above. pca_testProject(TestDescriptor, TestPcafeature, pca); //Find the Label by searching for keywords closest to current feature. get_matches(TestPcafeature,Keyword,matches); //Calculate Histogram for each test Image. hist_test(TestDescriptor, matches, Testhistogram); //Perform classification through Knn Classifier. train_labels(trainlabels); KNearest knn; train_classifier(histogram, trainlabels, knn); test_classify(Testhistogram,predicted,knn); //Calculate Accuracy for each class. calculate_accuracy(predicted); getchar(); return 0; }
const Descriptor BaseActorCategories::CATEGORY_CHIP_SEQ() { return Descriptor("chs", tr("NGS: ChIP-Seq Analysis"), ""); }
const Descriptor BaseActorCategories::CATEGORY_SNP_ANNOTATION() { return Descriptor("sch", tr("SNP Annotation"),""); }
const Descriptor BaseActorCategories::CATEGORY_INCLUDES() { return Descriptor("inc", tr("Includes"),""); }
const Descriptor BaseActorCategories::CATEGORY_DATAFLOW() { return Descriptor("df", tr("Data Flow"),""); }