Esempio n. 1
0
void tex::append_choices ()
	{
	tail_append(new_choice());
	incr(save_ptr);
	saved(-1) = 0;
	scan_left_brace();
	push_math(MATH_CHOICE_GROUP);
	}
Esempio n. 2
0
void GapFiller::BFS(const CondensedDeBruijnGraph& graph, const size_t from, const size_t to, int gap, size_t max_depth, size_t max_queue, PathList& pathlist) {
	size_t step = 0;

    Path path = boost::assign::list_of(from);
    typedef std::pair< Path, int > Choice;
    std::deque< Choice > Q = boost::assign::list_of(std::make_pair(
                path, 0 - (_K - 1)
                ));
    while (!Q.empty()) {
        ++step;
		if (step > max_depth) {
			LOG4CXX_DEBUG(logger, boost::format("BFS step is bigger than %d...") % max_depth);
			break;
		}

        if (Q.size() > max_queue) {
			LOG4CXX_DEBUG(logger, boost::format("BFS Q size=%d is greater than %d...") % Q.size() % max_queue);
            break;
        }

        std::deque< Choice > nextQ;
        while (!Q.empty()) {
            Choice choice = Q.front();
            Q.pop_front();

            size_t node = choice.first.back();
            if (node == to) {
                pathlist.push_back(choice.first);
            }
            if (choice.second > gap - (_K - 1)) {
                continue;
            }
            const CondensedDeBruijnGraph::CondensedEdge& edge = graph._indexer[node];
            std::string suffix = edge.seq.substr(edge.seq.length() - (_K - 1), _K - 1);
            CondensedDeBruijnGraph::NodeList::const_iterator i = graph._parents.find(suffix);
            if (i != graph._parents.end()) {
                for (CondensedDeBruijnGraph::EdgeList::const_iterator j = i->second.begin(); j != i->second.end(); ++j) {
                    //size_t length = graph._indexer[j->second].seq.length();
                    size_t length = graph._indexer[j->second].seq.length() - (_K - 1);

                    Choice new_choice(choice);
                    new_choice.first.push_back(j->second);
                    new_choice.second += length;

                    nextQ.push_back(new_choice);
                }
            }
        }

        Q = nextQ;
    }
}
/**
 * append_char_choice
 *
 * Create a new choice record. Store the string value in a safe place.
 * Add the new choice record to the list.
 *
 * NB - This is only used by matchers, so permuter is always NO_PERM
 * SPC 16/9/92
 */
CHOICES append_char_choice(CHOICES ratings,
                           const char *string,
                           const char *lengths,
                           float rating,
                           float certainty,
                           inT8 config,
                           int script_id) {
  A_CHOICE *this_choice;

  this_choice = new_choice (string, lengths, rating, certainty,
                            config, script_id, NO_PERM, false, NULL);
  ratings = push_last (ratings, (LIST) this_choice);
  return (ratings);
}
/**
 * copy_choices
 *
 * Copy a list of choices.  This means that there will be two copies
 * in memory.
 */
CHOICES copy_choices(CHOICES choices) {
  CHOICES l;
  CHOICES result = NIL;

  iterate_list(l, choices) {
    A_CHOICE *choice = (A_CHOICE *)(first_node(l));
    result = push (result,
      (LIST) new_choice (class_string(choice),
                         class_lengths(choice),
                         class_rating(choice),
                         class_certainty(choice),
                         class_config(choice),
                         class_script_id(choice),
                         class_permuter(choice),
                         class_fragment_mark(choice),
                         class_fragment_lengths(choice)));
  }