int RemoveGroupsCommand::execute(){ try { if (abort == true) { if (calledHelp) { return 0; } return 2; } //get groups you want to remove if (accnosfile != "") { m->readAccnos(accnosfile, Groups); m->setGroups(Groups); } if (groupfile != "") { groupMap = new GroupMap(groupfile); groupMap->readMap(); //make sure groups are valid //takes care of user setting groupNames that are invalid or setting groups=all vector<string> namesGroups = groupMap->getNamesOfGroups(); vector<string> checkedGroups; for (int i = 0; i < Groups.size(); i++) { if (m->inUsersGroups(Groups[i], namesGroups)) { checkedGroups.push_back(Groups[i]); } else { m->mothurOut("[WARNING]: " + Groups[i] + " is not a valid group in your groupfile, ignoring.\n"); } } if (checkedGroups.size() == 0) { m->mothurOut("[ERROR]: no valid groups, aborting.\n"); delete groupMap; return 0; } else { Groups = checkedGroups; m->setGroups(Groups); } //fill names with names of sequences that are from the groups we want to remove fillNames(); delete groupMap; }else if (countfile != ""){ if ((fastafile != "") || (listfile != "") || (taxfile != "")) { m->mothurOut("\n[NOTE]: The count file should contain only unique names, so mothur assumes your fasta, list and taxonomy files also contain only uniques.\n\n"); } CountTable ct; ct.readTable(countfile, true); if (!ct.hasGroupInfo()) { m->mothurOut("[ERROR]: your count file does not contain group info, aborting.\n"); return 0; } vector<string> gNamesOfGroups = ct.getNamesOfGroups(); SharedUtil util; util.setGroups(Groups, gNamesOfGroups); vector<string> namesOfSeqs = ct.getNamesOfSeqs(); sort(Groups.begin(), Groups.end()); for (int i = 0; i < namesOfSeqs.size(); i++) { vector<string> thisSeqsGroups = ct.getGroups(namesOfSeqs[i]); if (m->isSubset(Groups, thisSeqsGroups)) { //you only have seqs from these groups so remove you names.insert(namesOfSeqs[i]); } } } if (m->control_pressed) { return 0; } //read through the correct file and output lines you want to keep if (namefile != "") { readName(); } if (fastafile != "") { readFasta(); } if (groupfile != "") { readGroup(); } if (countfile != "") { readCount(); } if (listfile != "") { readList(); } if (taxfile != "") { readTax(); } if (sharedfile != "") { readShared(); } if (designfile != "") { readDesign(); } if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } return 0; } if (outputNames.size() != 0) { m->mothurOutEndLine(); m->mothurOut("Output File names: "); m->mothurOutEndLine(); for (int i = 0; i < outputNames.size(); i++) { m->mothurOut(outputNames[i]); m->mothurOutEndLine(); } m->mothurOutEndLine(); //set fasta file as new current fastafile string current = ""; itTypes = outputTypes.find("fasta"); if (itTypes != outputTypes.end()) { if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setFastaFile(current); } } itTypes = outputTypes.find("name"); if (itTypes != outputTypes.end()) { if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setNameFile(current); } } itTypes = outputTypes.find("group"); if (itTypes != outputTypes.end()) { if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setGroupFile(current); } } itTypes = outputTypes.find("list"); if (itTypes != outputTypes.end()) { if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setListFile(current); } } itTypes = outputTypes.find("taxonomy"); if (itTypes != outputTypes.end()) { if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setTaxonomyFile(current); } } itTypes = outputTypes.find("shared"); if (itTypes != outputTypes.end()) { if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setSharedFile(current); } } itTypes = outputTypes.find("design"); if (itTypes != outputTypes.end()) { if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setDesignFile(current); } } itTypes = outputTypes.find("count"); if (itTypes != outputTypes.end()) { if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setCountTableFile(current); } } } return 0; } catch(exception& e) { m->errorOut(e, "RemoveGroupsCommand", "execute"); exit(1); } }
int GetSeqsCommand::execute(){ try { if (abort == true) { if (calledHelp) { return 0; } return 2; } //get names you want to keep readAccnos(); if (m->control_pressed) { return 0; } //read through the correct file and output lines you want to keep if (namefile != "") { readName(); } if (fastafile != "") { readFasta(); } if (groupfile != "") { readGroup(); } if (alignfile != "") { readAlign(); } if (listfile != "") { readList(); } if (taxfile != "") { readTax(); } if (qualfile != "") { readQual(); } if (accnosfile2 != "") { compareAccnos(); } if (m->control_pressed) { outputTypes.clear(); for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } return 0; } if (outputNames.size() != 0) { m->mothurOutEndLine(); m->mothurOut("Output File Names: "); m->mothurOutEndLine(); for (int i = 0; i < outputNames.size(); i++) { m->mothurOut(outputNames[i]); m->mothurOutEndLine(); } m->mothurOutEndLine(); //set fasta file as new current fastafile string current = ""; itTypes = outputTypes.find("fasta"); if (itTypes != outputTypes.end()) { if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setFastaFile(current); } } itTypes = outputTypes.find("name"); if (itTypes != outputTypes.end()) { if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setNameFile(current); } } itTypes = outputTypes.find("group"); if (itTypes != outputTypes.end()) { if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setGroupFile(current); } } itTypes = outputTypes.find("list"); if (itTypes != outputTypes.end()) { if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setListFile(current); } } itTypes = outputTypes.find("taxonomy"); if (itTypes != outputTypes.end()) { if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setTaxonomyFile(current); } } itTypes = outputTypes.find("qfile"); if (itTypes != outputTypes.end()) { if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setQualFile(current); } } } return 0; } catch(exception& e) { m->errorOut(e, "GetSeqsCommand", "execute"); exit(1); } }
// 解析出刀塔骨架数据 Dota_Skeleton_Data* DotaAnimParser::parseDotaSkeletonData( const std::string &fcaFile) { const float PI = 3.14159265358979323846f; ByteArray byteArray; bool bRet = byteArray.loadFromZipFile(fcaFile.c_str(), "cha"); if (!bRet) return nullptr; Dota_Skeleton_Data * skeletonData = new Dota_Skeleton_Data(); if (skeletonData == nullptr) { byteArray.close(); return nullptr; } skeletonData->name = readName(byteArray); CCLOG("RoleName:%s\n", skeletonData->name.c_str()); float factor = 0.1f; if (skeletonData->name.substr(0, 14) == "effect/eff_UI_") factor = 0.5f; int boneCount = byteArray.readInt(); CCLOG("BoneCnt:%d\n", boneCount); for (int i = 0; i < boneCount; i++) { Dota_Bone_Data * boneData = new Dota_Bone_Data(); boneData->name = readName(byteArray); boneData->textureName = readName(byteArray); boneData->index = byteArray.readInt(); skeletonData->boneDataList.push_back(boneData); CCLOG("BoneData:\nName:%s\nTextureName:%s\nIndex:%d\n\n", boneData->name.c_str(), boneData->textureName.c_str(), boneData->index); } CCLOG("BoneCnt:%d\n", (int)skeletonData->boneDataList.size()); int animCount = byteArray.readInt(); CCLOG("AnimCnt:%d\n", animCount); for (int i = 0; i < animCount; i++) { Dota_Anim_Data * animData = new Dota_Anim_Data(); animData->name = readName(byteArray); CCLOG("AnimName:%s\n", animData->name.c_str()); byteArray.readBytes(animData->unknownData, sizeof(animData->unknownData)); int frameCount = byteArray.readInt(); CCLOG("FrameCnt:%d\n", frameCount); for (int j = 0; j < frameCount; j++) { Dota_Frame_Data * frameData = new Dota_Frame_Data(); frameData->type = byteArray.readInt(); if (frameData->type == 1) { frameData->unknownData1 = byteArray.readInt(); CCLOG("UnknownData1:%d\n", frameData->unknownData1); frameData->soundName = readName(byteArray); byteArray.readBytes(frameData->soundData, sizeof(frameData->soundData)); frameData->unknownData2 = byteArray.readInt(); CCLOG("UnknownData2:%d\n", frameData->unknownData2); } int slotCount = byteArray.readInt(); for (int k = 0; k < slotCount; k++) { Dota_Slot_Data * slotData = new Dota_Slot_Data(); slotData->boneIndex = byteArray.readShort(); slotData->opacity = byteArray.readByte(); float a = byteArray.readFloat(); float b = byteArray.readFloat(); float c = byteArray.readFloat(); float d = byteArray.readFloat(); float tx = byteArray.readFloat(); float ty = byteArray.readFloat(); slotData->x = tx * factor; slotData->y = ty * factor; slotData->skX = atan2(-c, d) * (180/PI); slotData->skY = atan2(b, a) * (180/PI); slotData->scX = sqrt(a*a + b*b); slotData->scY = sqrt(c*c + d*d); frameData->slotDataList.push_back(slotData); } animData->frameDataList.push_back(frameData); } CCLOG("FrameCnt:%d\n", animData->frameDataList.size()); skeletonData->animDataList.push_back(animData); } byteArray.close(); for (int i = 0; i < (int)skeletonData->animDataList.size(); i++) { Dota_Anim_Data * animData = skeletonData->animDataList[i]; Dota_Anim_Data2 * animData2 = new Dota_Anim_Data2(); for (int j = 0; j < (int)animData->frameDataList.size(); j++) { Dota_Frame_Data * frameData = animData->frameDataList[j]; for (int k = 0; k < (int)frameData->slotDataList.size(); k++) { Dota_Slot_Data * slotData = frameData->slotDataList[k]; if (frameData->type == 1 && 0 == k) slotData->soundName = frameData->soundName; slotData->zOrder = k; //slotData->boneIndex; std::string boneName = getBone(skeletonData->boneDataList, slotData->boneIndex); Dota_Anim_Data2::iterator iter = animData2->find(boneName); if (iter == animData2->end()) { Dota_Timeline_Data * timelineData = new Dota_Timeline_Data(); timelineData->insert(Dota_Timeline_Data::value_type(toString(j), slotData)); animData2->insert(Dota_Anim_Data2::value_type(boneName, timelineData)); skeletonData->firstFrameOfBoneMap.insert(Dota_First_Frame_Data::value_type(boneName, slotData)); } else { Dota_Timeline_Data * timelineData = iter->second; Dota_Timeline_Data::iterator iter2 = timelineData->find(toString(j)); if (iter2 == timelineData->end()) { timelineData->insert(Dota_Timeline_Data::value_type(toString(j), slotData)); } } } } skeletonData->animDataMap.insert(std::map<std::string, Dota_Anim_Data2 *>::value_type(animData->name, animData2)); } return skeletonData; }
temp<Token> Lexer::readToken() { while (true) { if (isDone()) return Token::create(TOKEN_EOF, String::create("")); start_ = pos_; char c = advance(); switch (c) { case ' ': case '\t': case '\r': // Skip whitespace. while (isWhitespace(peek())) advance(); break; case '(': return makeToken(TOKEN_LEFT_PAREN); case ')': return makeToken(TOKEN_RIGHT_PAREN); case '[': return makeToken(TOKEN_LEFT_BRACKET); case ']': return makeToken(TOKEN_RIGHT_BRACKET); case '{': return makeToken(TOKEN_LEFT_BRACE); case '}': return makeToken(TOKEN_RIGHT_BRACE); case '=': return makeToken(TOKEN_EQUALS); case '+': return makeToken(TOKEN_PLUS); case '-': return makeToken(TOKEN_MINUS); case '*': return makeToken(TOKEN_STAR); case '%': return makeToken(TOKEN_PERCENT); case '<': return makeToken(TOKEN_LESS_THAN); case '\n': return makeToken(TOKEN_LINE); case '/': if (peek() == '/') { skipLineComment(); /*} else if (peek() == '*') { skipBlockComment();*/ } else { return makeToken(TOKEN_SLASH); } break; /* case ',': return singleToken(TOKEN_LINE); case '@': return singleToken(TOKEN_AT); case '.': return singleToken(TOKEN_DOT); case '#': return singleToken(TOKEN_HASH); case ';': return singleToken(TOKEN_SEMICOLON); case '\\': return singleToken(TOKEN_IGNORE_LINE); case '|': return singleToken(TOKEN_PIPE); case ':': advance(); if (peek() == ':') { // "::". advance(); return Ref<Token>(new Token(TOKEN_BIND)); } // Just a ":" by itself. return Ref<Token>(new Token(TOKEN_KEYWORD, ":")); case '-': advance(); if (isDigit(peek())) return readNumber(); return readOperator(); case '/': advance(); if (peek() == '/') { // Line comment, so ignore the rest of the line and // emit the line token. mNeedsLine = true; return Ref<Token>(new Token(TOKEN_LINE)); } else if (peek() == '*') { skipBlockComment(); } else { return readOperator(); } break; case '"': return readString(); default: if (isDigit(c)) return readNumber(); if (isOperator(c)) return readOperator(); */ default: if (isNameStart(c)) return readName(); if (isDigit(c)) return readNumber(); // If we got here, we don't know what it is. return makeToken(TOKEN_ERROR); } } }