vector<bool>& leaves);
118 const intkNumSeqs = 12;
121vector<string> labels = calc.
SetLabels();
122 for(
int i=1;
i<= kNumSeqs;
i++) {
131 "((4:0.474, (1:0.814, ((2:0.092, 3:0.060):0.586, " 132 "(((9:0.044, ((7:0.012, 8:0.020):0.045, 6:0.044)" 133 ":0.018):0.070, 10:0.000):0.390, (0:0.000, 5:0.034)" 134 ":0.393):0.078):0.072):0.474):x)");
150 const intkNumSeqs = 12;
153vector<string> labels = calc.
SetLabels();
154 for(
int i=1;
i<= kNumSeqs;
i++) {
163 "((4:0.449, ((1:0.699, (2:0.061, 3:0.062):0.440)" 164 ":0.070, (((9:0.038, ((7:0.005, 8:0.017):0.044, " 165 "6:0.037):0.017):0.050, 10:0.000):0.403, (0:0.000, " 166 "5:0.034):0.360):0.104):0.449):x)");
187 "(((5:0.000, 9:0.000):0.002, (7:0.000, (3:0.000, " 188 "(4:0.001, (1:0.000, (0:0.000, ((6:0.000, 8:0.000)" 189 ":0.000, 2:0.000):0.000):0.000):0.001):0.000):0.000)" 213 "(((5:0.000, 9:0.000):0.002, (7:0.000, (3:0.000, " 214 "(4:0.001, (1:0.000, (0:0.000, ((6:0.000, 8:0.000)" 215 ":0.000, 2:0.000):0.000):0.000):0.001):0.000):0.000)" 231vector<string>& labels = calc.
SetLabels();
232labels.push_back(
"label1");
233labels.push_back(
"label2");
378 #if NCBI_PLATFORM_BITS == 64 381 const stringkSeq1 =
"A--";
382 const stringkSeq2 =
"-A-";
385BOOST_REQUIRE_EQUAL(kSeq1.length(), kSeq2.length());
387 for(
size_t i=0;
i< kSeq1.length();
i++) {
388BOOST_REQUIRE(kSeq1[
i] ==
'-'|| kSeq2[
i] ==
'-');
405dmat(0, 1) = dmat(1, 0) = -1.0;
410 #if NCBI_PLATFORM_BITS == 64 420dmat(0, 1) = dmat(1, 0) = numeric_limits<double>::quiet_NaN();
425dmat(0, 1) = dmat(1, 0) = numeric_limits<double>::signaling_NaN();
436 const intnum_seqs = 2;
443denseg.
SetDim(num_seqs);
445denseg.
SetIds().push_back(
id);
446denseg.
SetIds().push_back(
id);
453denseg.
SetLens().push_back(10);
454denseg.
SetLens().push_back(10);
459 constvector<int>& starts = denseg.
GetStarts();
460 for(
size_t i=0;
i< starts.size();
i+=num_seqs) {
461BOOST_REQUIRE(starts[
i] < 0 || starts[
i+1] < 0);
465vector<int> included_inds;
470BOOST_REQUIRE_EQUAL(valid,
false);
474BOOST_REQUIRE_EQUAL(included_inds.size(), 1u);
477BOOST_REQUIRE_EQUAL(included_inds[0], 0);
494BOOST_REQUIRE_EQUAL((
int)seg_info.size(), seq_align.
GetDim());
496BOOST_REQUIRE(!seq->empty());
497 ITERATE(vector<CPhyTreeCalc::TRange>, it, *seq) {
498BOOST_REQUIRE(it->NotEmpty());
514BOOST_REQUIRE(instream);
522 while(!line_reader.
AtEOF()) {
528 "Could not retrieve seq entry");
550BOOST_REQUIRE(!
label.empty());
554BOOST_REQUIRE(
id>= 0 &&
id< (
int)leaves.size());
557BOOST_REQUIRE(!leaves[
id]);
573vector<bool> leaves(num_sequences,
false);
577 ITERATE(vector<bool>, it, leaves) {
621vector<bool>& leaves)
623 if(node->IsLeaf()) {
625 string label= node->GetFeature(
"label");
628BOOST_REQUIRE(!
label.empty());
632BOOST_REQUIRE(
id>= 0 &&
id< (
int)leaves.size());
635BOOST_REQUIRE(!leaves[
id]);
641CBioTreeDynamic::CBioNode::TParent::TNodeList_CI child
642= node->SubNodeBegin();
644 while(child != node->SubNodeEnd()) {
658vector<bool> leaves(num_sequences,
false);
662 ITERATE(vector<bool>, it, leaves) {
674 const intkNumInputSequences = seq_align.
GetDim();
675 const intkNumUsedSequences = calc.
GetSeqIds().size();
680BOOST_REQUIRE_EQUAL(kNumUsedSequences, diverg.
GetNumElements());
683BOOST_REQUIRE(diverg(
i, j) >= 0.0 && diverg(
i, j) <= 1.0);
691BOOST_REQUIRE_EQUAL(kNumUsedSequences, diverg.
GetNumElements());
694BOOST_REQUIRE(dist(
i, j) >= 0.0);
703BOOST_REQUIRE_EQUAL(kNumInputSequences,
708 constvector< CRef<CSeq_id> > input_seq_ids
711 constvector< CRef<CSeq_id> > used_seq_ids
714vector<bool> found(used_seq_ids.size(),
false);
715 for(
size_t i=0;
i< used_seq_ids.size();
i++) {
716 for(
size_tj=0;j < input_seq_ids.size();j++) {
717 if(used_seq_ids[
i]->Match(*input_seq_ids[j])) {
723 ITERATE(vector<bool>, it, found) {
739vector< CRef<CSeq_id> > input_seq_ids;
740input_seq_ids.reserve(seq_align_set.
Get().size());
741input_seq_ids.push_back(
742(*seq_align_set.
Get().begin())->GetSegs().GetDenseg().GetIds()[0]);
745BOOST_REQUIRE_EQUAL((*it)->GetSegs().GetDenseg().GetDim(), 2);
746 int i= (
int)input_seq_ids.size() - 1;
747 while(
i>= 0 && !(*it)->GetSegs().GetDenseg().GetIds()[1]->Match(
748*input_seq_ids[
i])) {
752input_seq_ids.push_back((*it)->GetSegs().GetDenseg().GetIds()[1]);
756 const intkNumInputSequences = (
int)input_seq_ids.size();
757 const intkNumUsedSequences = calc.
GetSeqIds().size();
760BOOST_REQUIRE_EQUAL(kNumUsedSequences, diverg.
GetNumElements());
763BOOST_REQUIRE(diverg(
i, j) >= 0.0 && diverg(
i, j) <= 1.0);
771BOOST_REQUIRE(dist(
i, j) >= 0.0);
778BOOST_REQUIRE_EQUAL(kNumInputSequences,
783 constvector< CRef<CSeq_id> > used_seq_ids
786vector<bool> found(used_seq_ids.size(),
false);
787 for(
size_t i=0;
i< used_seq_ids.size();
i++) {
788 for(
size_tj=0;j < input_seq_ids.size();j++) {
789 if(used_seq_ids[
i]->Match(*input_seq_ids[j])) {
795 ITERATE(vector<bool>, it, found) {
BOOST_AUTO_TEST_SUITE_END() static int s_GetSegmentFlags(const CBioseq &bioseq)
void Validate(bool full_test=false) const
static TTree * NjTree(const TMatrix &dist_mat, const vector< string > &labels=vector< string >())
Compute a tree by neighbor joining; as per Hillis et al.
static double Divergence(const string &seq1, const string &seq2)
Calculate pairwise fractions of non-identity.
static TTree * FastMeTree(const TMatrix &dist_mat, const vector< string > &labels=vector< string >(), EFastMePar btype=eOls, EFastMePar wtype=eOls, EFastMePar ntype=eBalanced)
Compute a tree using the fast minimum evolution algorithm.
Base class for reading FASTA sequences.
Guide tree calc exceptions.
Distance matrix (square, symmetric with zeros on diagnol)
int GetNumElements(void) const
Get number of rows/columns.
Computaion of distance-based phylognetic tree.
void SetTreeMethod(ETreeMethod method)
Set algorithm for phylogenetic tree computation.
vector< string > & SetLabels(void)
Set labels for tree leaves.
CRef< CSeq_align > GetSeqAlign(void) const
Get seq_align that corresponds to current tree.
CRef< CBioTreeContainer > GetSerialTree(void) const
Get serial tree.
void SetMaxDivergence(double div)
Set maximum allowed divergence between sequences included in tree.
void SetCalcAlnSegInfo(bool s)
Calculate summarized segment positions in mutliple alignment.
bool CalcBioTree(void)
Compute bio tree for the current alignment in a black box manner.
const vector< string > & GetMessages(void) const
Get error/warning messages.
const vector< string > & GetRemovedSeqIds(void) const
Get ids of sequences excluded from tree computation.
const vector< CRef< CSeq_id > > & GetSeqIds(void) const
Get seq-ids of sequences used in tree construction.
@ eFastME
Fast Minumum Evolution.
const CDistMatrix & GetDivergenceMatrix(void) const
Get divergence matrix.
bool x_CalcDivergenceMatrix(vector< int > &used_indices)
Compute divergence matrix and find sequences to exclude from tree reconstruction.
void SetDistMethod(EDistMethod method)
Set evolutionary correction method for computing distance between sequences.
TPhyTreeNode * GetTree(void)
Get computed tree.
vector< vector< TRange > > TSegInfo
const CDistMatrix & GetDistanceMatrix(void) const
Get distance matrix.
const TSegInfo & GetAlnSegInfo(void) const
Get simplified segment positions in multiple or query anchored alignment.
Simple implementation of ILineReader for i(o)streams.
Test class for accessing CPhyTreeCalc private methods and attributes.
static bool CalcDivergenceMatrix(CPhyTreeCalc &calc, vector< int > &included)
definition of a Culling tree
Template class for iteration on objects of class C (non-medifiable version)
Operators to edit gaps in sequences.
#define ITERATE(Type, Var, Cont)
ITERATE macro to sequence through container elements.
#define NCBI_THROW(exception_class, err_code, message)
Generic macro to throw an exception, given the exception class, error code and message string.
#define MSerial_AsnText
I/O stream manipulators â.
virtual CRef< CSeq_entry > ReadOneSeq(ILineErrorListener *pMessageListener=nullptr)
Read a single effective sequence, which may turn out to be a segmented set.
bool AtEOF(void) const
Indicates (negatively) whether there is any more input.
@ fNoParseID
Generate an ID (whole defline -> title)
@ fForceType
Force specified type regardless of accession.
@ fAssumeProt
Assume prots unless accns indicate otherwise.
CConstBeginInfo ConstBegin(const C &obj)
Get starting point of non-modifiable object hierarchy.
static CRef< CObjectManager > GetInstance(void)
Return the existing object manager or create one.
CSeq_entry_Handle AddTopLevelSeqEntry(CSeq_entry &top_entry, TPriority pri=kPriority_Default, EExist action=eExist_Default)
Add seq_entry, default priority is higher than for defaults or loaders Add object to the score with p...
void AddDefaults(TPriority pri=kPriority_Default)
Add default data loaders from object manager.
IO_PREFIX::ifstream CNcbiIfstream
Portable alias for ifstream.
static string DoubleToString(double value, int precision=-1, TNumToStringFlags flags=0)
Convert double to string.
static int StringToInt(const CTempString str, TStringToNumFlags flags=0, int base=10)
Convert string to int.
static string IntToString(int value, TNumToStringFlags flags=0, int base=10)
Convert int to string.
TNodeList_CI SubNodeBegin(void) const
Return first const iterator on subnode list.
void BioTreeConvertContainer2Dynamic(TDynamicTree &dyn_tree, const TBioTreeContainer &tree_container, bool preserve_node_ids=false)
Convert ASN.1 BioTree container to dynamic tree.
TNodeList::const_iterator TNodeList_CI
bool IsLeaf() const
Report whether this is a leaf node.
TNodeList_CI SubNodeEnd(void) const
Return last const iterator on subnode list.
const TBioTreeNode * GetTreeNode() const
const TValue & GetValue(void) const
Return node's value.
const TTreeType * GetParent(void) const
Get node's parent.
static const char label[]
const TDenseg & GetDenseg(void) const
Get the variant data.
Tdata & Set(void)
Assign a value to data member.
TLens & SetLens(void)
Assign a value to Lens data member.
const TStarts & GetStarts(void) const
Get the Starts member data.
TDim GetDim(void) const
Get the Dim member data.
void SetSegs(TSegs &value)
Assign a value to Segs data member.
void SetDim(TDim value)
Assign a value to Dim data member.
void SetDim(TDim value)
Assign a value to Dim data member.
TStarts & SetStarts(void)
Assign a value to Starts data member.
void SetNumseg(TNumseg value)
Assign a value to Numseg data member.
const TIds & GetIds(void) const
Get the Ids member data.
list< CRef< CSeq_align > > Tdata
TIds & SetIds(void)
Assign a value to Ids data member.
const Tdata & Get(void) const
Get the member data.
const TSegs & GetSegs(void) const
Get the Segs member data.
const TAlign & GetAlign(void) const
Get the variant data.
const TData & GetData(void) const
Get the Data member data.
unsigned int
A callback function used to compare two keys in a database.
BOOST_AUTO_TEST_CASE(TestProteinSeqAlign)
static void s_TraverseDynTree(const CBioTreeDynamic::CBioNode *node, vector< bool > &leaves)
static CRef< CScope > s_CreateScope(const string &filename)
static void s_TraverseTree(const TPhyTreeNode *node, vector< bool > &leaves)
static string s_GetNewickLike(const TPhyTreeNode *tree)
static bool s_TestTree(int num_sequences, const TPhyTreeNode *tree)
static bool s_TestTreeContainer(int num_sequences, const CBioTreeContainer &tree)
static bool s_TestCalc(const CSeq_align &seq_align, const CPhyTreeCalc &calc)
static void s_GetNewick(const TPhyTreeNode *node, string &result)
BOOST_AUTO_TEST_SUITE(psiblast_iteration)
Utility stuff for more convenient using of Boost.Test library.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4