// $Id: seqContainerTreeMap.cpp 12494 2014-08-06 15:54:00Z haim $ #include #include "seqContainerTreeMap.h" #include "logFile.h" #include "treeUtil.h" /******************************************************************************************** *********************************************************************************************/ void intersectNamesInTreeAndSequenceContainer(tree& et, sequenceContainer & sc, bool bLeavesOnly){ LOGnOUT(4,<<"\n intersectNames Tree vs Sequence. Before intersect numOfSeq= "< nodes2remove; vector seqIDs2remove; //cout<<"tree names:"<isInternal()) continue; } sequenceContainer::constTaxaIterator it=sc.constTaxaBegin(); for (;it != sc.constTaxaEnd(); ++it) { string scName = it->name(); string treeNodeName = mynode->name(); if (it->name() == mynode->name()) { if(bFound) bFound_more = true; bFound = true; //break; } if (bFound_more == true) { string errMsg = "The taxID:\t"; errMsg += mynode->name(); errMsg += "\twas found again in the sequence file. Removed from sequence."; LOGnOUT(4,<id()); bFound_more = false; } } if (bFound == false) { string errMsg = "The taxID:\t"; errMsg += mynode->name(); errMsg += "\twas found in the tree file but not found in the sequence file. Removed from tree."; LOGnOUT(4,<isInternal()) continue; } if (myseq->name() == mynode->name()) { if(bFound) bFound_more = true; bFound = true; //break; } if (bFound_more == true) { string errMsg = "The taxID name:\t"; errMsg += myseq->name(); errMsg += "\twas found again in the tree file. Removed."; LOGnOUT(4,<name(); errMsg += "\twas found in the sequence file but not found in the tree file. Removed."; LOGnOUT(4,<id()); } } for(int i=0; iisInternal()) continue; } sequenceContainer::constTaxaIterator it=sc.constTaxaBegin(); for (;it != sc.constTaxaEnd(); ++it) { string scName = it->name(); string treeNodeName = mynode->name(); if (it->name() == mynode->name()) { bFound = true; break; } } if (bFound == false) { string errMsg = "The sequence name: "; errMsg += mynode->name(); errMsg += " was found in the tree file but not found in the sequence file.\n"; errMsg += " Please, Re-run program with _intersectTreeAndSeq to produce new MSA and Tree.\n"; LOG(4,<isInternal()) continue; } if (it->name() == mynode->name()) { bFound = true; break; } } if (bFound == false) { string errMsg = "The sequence name: "; errMsg += it->name(); errMsg += " was found in the sequence file but not found in the tree file.\n"; errMsg += " Please, Re-run program with _intersectTreeAndSeq to produce new MSA and Tree.\n"; errorMsg::reportError(errMsg); } } } /******************************************************************************************** // input: a tree and a sequence-container containing all of the leaves sequences. // output: fills sc_leaves with the sequences of the leaves only. *********************************************************************************************/ void getLeavesSequences(const sequenceContainer& sc, const tree& tr, sequenceContainer& sc_leaves) { vector leavesNames = getSequencesNames(tr); vector::iterator itr_leaves; for (itr_leaves=leavesNames.begin();itr_leaves!=leavesNames.end();++itr_leaves) { sequenceContainer::constTaxaIterator it_sc=sc.constTaxaBegin(); for (;it_sc != sc.constTaxaEnd(); ++it_sc) { if (it_sc->name() == *(itr_leaves)) { sc_leaves.add(*it_sc); break; } } } if (tr.getLeavesNum() != sc_leaves.numberOfSeqs()) { string errMsg = "getLeavesSequencese: the number of leaves is not equal to the number of leaves' sequences"; errorMsg::reportError(errMsg); } }