Exemplo n.º 1
0
bool Analyzer::convert(Pattern& pattern, vector<string>& items, RowData& row_data){

	// pattern and item size must match
	if (pattern.size() != items.size()) {
		return false;
	}
		
	Pattern::iterator itr_pattern = pattern.begin();
	vector<string>::iterator itr_items = items.begin();

	// process every element using proper element parser
	// return true only if all items are proper handled
	while (itr_pattern != pattern.end()) {
		Element* ele = *(*itr_pattern);
		string str = *itr_items;

		// increase pattern itr and corresponding item itr
		itr_pattern++;
		itr_items++;

		Data data;

		if (ele->convert(str, data)) {
			row_data.push_back(data);
		} else {
			row_data.clear();
			return false;
		}
	}
	return true;
}
Exemplo n.º 2
0
Matrix clipped_Hebbian(const Pattern& Z, const Topology& W)
{
	Matrix J(W.n, W.n, 0); // Create a nxn Matrix filled with 0

	// clipped Hebbian Definition: Jij=Wij * Zp(i) * Zp(j)
	// Redefinition:
	// 	If there is a connection between neuron i and neuron j,
	// 	check if neuron i and neuron j are both in pattern p
	// ----------------------------
	// 1. Go through all the patterns
	for (Pattern::const_iterator p=Z.begin(); p!=Z.end(); ++p)
		// 2. Go through all connections of the topology
		for (Topology::const_iterator i=W.begin(); i!=W.end(); ++i)
		{
		// 3. Check if neuron 'i' is in pattern
		if (find(p->begin(), p->end(), i->first)!=p->end())
			// 4. If so, then check if any of the neurons connected to 'i' is in the pattern 'p' as well
			for (NeuronList::const_iterator j=i->second.begin(); j!=i->second.end(); ++j)
				if (find(p->begin(), p->end(), *j)!=p->end())
					// If so, Jij is equal to 1
					J(i->first,*j)=1;
		}
	return J;
}
Exemplo n.º 3
0
Pattern gram::get_kmer_from_read(const uint32_t &kmer_size, const Pattern &read) {
    Pattern kmer;
    auto kmer_start_it = read.begin() + read.size() - kmer_size;
    kmer.assign(kmer_start_it, read.end());
    return kmer;
}