ALPHA SeqVect::GuessAlpha() const { // If at least MIN_NUCLEO_PCT of the first CHAR_COUNT non-gap // letters belong to the nucleotide alphabet, guess nucleo. // Otherwise amino. const unsigned CHAR_COUNT = 100; const unsigned MIN_NUCLEO_PCT = 95; const unsigned uSeqCount = GetSeqCount(); if (0 == uSeqCount) return ALPHA_Amino; unsigned uSeqIndex = 0; unsigned uPos = 0; unsigned uSeqLength = GetSeqLength(0); unsigned uDNACount = 0; unsigned uRNACount = 0; unsigned uTotal = 0; const Seq *ptrSeq = &GetSeq(0); for (;;) { while (uPos >= uSeqLength) { ++uSeqIndex; if (uSeqIndex >= uSeqCount) break; ptrSeq = &GetSeq(uSeqIndex); uSeqLength = ptrSeq->Length(); uPos = 0; } if (uSeqIndex >= uSeqCount) break; char c = ptrSeq->at(uPos++); if (IsGapChar(c)) continue; if (IsDNA(c)) ++uDNACount; if (IsRNA(c)) ++uRNACount; ++uTotal; if (uTotal >= CHAR_COUNT) break; } if (uTotal != 0 && ((uDNACount*100)/uTotal) >= MIN_NUCLEO_PCT) return ALPHA_DNA; if (uTotal != 0 && ((uRNACount*100)/uTotal) >= MIN_NUCLEO_PCT) return ALPHA_RNA; return ALPHA_Amino; }
boost::shared_ptr<FileBrowserCommand> RestoreFileCommand(const QByteArray& messRawData) { static bool first = true; if(first) { InitCodeToCreator(); first = false; } boost::shared_ptr<MessagePack> messagePack = MessagePack::createMessagePack(); if( !messagePack->unmarshal(messRawData) ) { qDebug()<<"Unnmarshal message error"; return boost::shared_ptr<FileBrowserCommand>(); } if(!CodeToCreator.contains(messagePack->getCode())) { return boost::shared_ptr<FileBrowserCommand>(); } boost::shared_ptr<FileBrowserCommand> command( CodeToCreator[messagePack->getCode()](messagePack) ); int seq = GetSeq(messagePack); if(seq == 0) { return boost::shared_ptr<FileBrowserCommand>(); } command->setSeq(seq); return command; }
tBinSearchNodeBase *PrevNodeFast(tBinSearchTreeBase &Tree, size_t &CurIndex, tTraversalOrder Order) { if (!CurIndex) return nullptr; if ( CurIndex >= Tree.size()) CurIndex = Tree.size(); tBinSearchNodeBase **ppFastSeq = GetSeq(Tree, Order); assert(ppFastSeq); return ppFastSeq[--CurIndex]; } // PrevNodeFast(Tree, )
tBinSearchNodeBase *NextNodeFast(tBinSearchTreeBase &Tree, size_t &CurIndex, tTraversalOrder Order) { if (CurIndex >= Tree.size()) return nullptr; tBinSearchNodeBase **ppFastSeq = GetSeq(Tree, Order); assert(ppFastSeq); return ppFastSeq[++CurIndex]; } // NextNodeFast(Tree, )
tBinSearchNodeBase *GetPtrFast(tBinSearchTreeBase &Tree, tTraversalOrder Order, size_t Index) { if (Index >= Tree.size()) return nullptr; tBinSearchNodeBase **ppFastSeq = GetSeq(Tree, Order); assert(ppFastSeq); return ppFastSeq[Index]; } // GetPtrFast(Tree, )
Seq &SeqVect::GetSeqById(unsigned uId) { const unsigned uSeqCount = GetSeqCount(); for (unsigned i = 0; i < uSeqCount; ++i) { if (GetSeqId(i) == uId) return GetSeq(i); } Quit("SeqVect::GetSeqIdByUd(%d): not found", uId); return (Seq &) *((Seq *) 0); }
static rc_t GetSeqInternal(RefSeqMgr *const self, RefSeq const **const result, unsigned const seq_id_sz, char const seq_id[]) { RefSeq *obj = NULL; if (self->mru == NULL || self->mru->vt->compare(self->mru, seq_id_sz, seq_id) != 0) { rc_t const rc = GetSeq(self, &obj, seq_id_sz, seq_id); if (rc) return rc; } else obj = self->mru; { rc_t const rc = GetReader(self, obj); if (rc) return rc; } obj->vt->setRow(obj, seq_id_sz, seq_id); *result = obj; return 0; }
// 处理已接收数据 bool RecvEnterConferenceTask::Handle(const TransportProtocol* tp) { bool result = false; AmfParser parser; amf_object_handle root = parser.Decode((char*)tp->data, tp->GetDataLength()); if ( !root.isnull() && root->type == DT_OBJECT ) { // mFromId amf_object_handle fromIdObject = root->get_child("fromId"); if ( !fromIdObject.isnull() && fromIdObject->type == DT_STRING ) { mFromId = fromIdObject->strValue; } // mToId amf_object_handle toIdObject = root->get_child("toId"); if ( !toIdObject.isnull() && toIdObject->type == DT_STRING ) { mToId = toIdObject->strValue; } // mbAuth amf_object_handle authObject = root->get_child("auth"); if ( !authObject.isnull() && authObject->type == DT_TRUE ) { mbAuth = true; } // mKey amf_object_handle keyObject = root->get_child("key"); if ( !keyObject.isnull() && keyObject->type == DT_STRING ) { mKey = keyObject->strValue; } // m_errMsg amf_object_handle msgObject = root->get_child("msg"); if ( !msgObject.isnull() && msgObject->type == DT_STRING ) { m_errMsg = msgObject->strValue; } if( mFromId.length() > 0 && mToId.length() > 0 && mKey.length() > 0 ) { result = true; m_errType = LCC_ERR_SUCCESS; } } // 协议解析失败 if (!result) { m_errType = LCC_ERR_PROTOCOLFAIL; m_errMsg = ""; } // Json::Value root; // Json::Reader reader; // if( reader.parse((char*)tp->data, root, false) ) { // if( root.isObject() ) { // if( root["userId1"].isString() && root["userId2"].isString() ) { // result = true; // // m_userId1 = root["userId1"].asString(); // m_userId2 = root["userId2"].asString(); // // m_errType = LCC_ERR_SUCCESS; // } // } // } // 打log FileLog("LiveChatClient", "RecvEnterConferenceTask::Handle() " "cmd:%d, " "errType:%d, " "errMsg:%s, " "mFromId:%s, " "mToId:%s, " "mbAuth:%s, " "mKey:%s", GetCmdCode(), m_errType, m_errMsg.c_str(), mFromId.c_str(), mToId.c_str(), mbAuth?"true":"false", mKey.c_str() ); // 通知listener if ( NULL != m_listener ) { m_listener->OnRecvEnterConference(m_client, GetSeq(), mFromId, mToId, mKey, mbAuth, m_errType, m_errMsg); } return result; }