Example #1
0
VectorXf ClstrSeqWeightEstimator::estimate(const vector<string>& msa) const {
    const size_t rows = msa.size();
    VectorXf memnum = VectorXf::Ones(rows);
    for (size_t i = 0; i < rows; ++i) {
        for (size_t j = i + 1; j < rows; ++j) {
            if (calc_identity(msa[i], msa[j]) > maxidt) {
                memnum(i) += 1;
                memnum(j) += 1;
            }
        }
    }
    return VectorXf::Ones(rows).cwiseQuotient(memnum);
}
Example #2
0
double Cluster::add_to_cluster(Node* new_read, Model_factory *mf, int read_index) {
    
    finalise();
    
    stringstream ss;
    ss << "#" << read_index << "#";
    
    Node* new_root = new Node();
    new_root->set_name(ss.str());
    new_root->add_left_child(root);
    new_root->add_right_child(new_read);
    
    new_root->set_nhx_tid(root->get_nhx_tid());    
    new_read->set_nhx_tid(root->get_nhx_tid());
    
    root->set_distance_to_parent(0.001);
    
    
    new_root->align_sequences_this_node(mf, true, false);
    
    
    double read_identity = calc_identity(new_root, new_read);
    bool cluster_success = read_identity > id_threshold;
    
    new_root->has_left_child(false);
    new_root->has_right_child(false);
    
    
    if(cluster_success) {
        // clustering was successful, so add the read to list of members
        // and replace the old root with the new one
        if(fast_cluster) {
            delete root;
        }
        else {
            prev_root = root;
        }
    
        root = new_root;
        cluster_members.push_back(read_index);
    }
    else {
        // not added to cluster, so ignore old root and read and
        // delete the failed new root
        delete new_root;
    }
    
    return read_identity;
}