class SequenceDatabase {

	public TreeSet<FrequentSequenceItem> getGloballyFrequentItems(int minSupport) {
		Map<SequenceItem, Integer> itemBag = new HashMap<SequenceItem, Integer>();
		TreeSet<FrequentSequenceItem> frequentItemSet = new TreeSet<FrequentSequenceItem>();
		//count all items
		for (Sequence seq : sequences) {
			for (int i = 0; i < sequenceLength; ++i) {
				SequenceItem fItem = new SequenceItem(seq.getSequenceAsString().substring(i, i + 1), i);
				Integer count = itemBag.get(fItem);
				if (count == null) {
					itemBag.put(fItem, new Integer(seq.getCount()));
				}
				else {
					itemBag.put(fItem, count + seq.getCount());
				}
			}
		}

		//iterate through itemBag and save the frequent items
		for (Entry<SequenceItem, Integer> itemAndCount : itemBag.entrySet()) {
			int count = itemAndCount.getValue();
			if (count >= minSupport) {
				frequentItemSet.add(new FrequentSequenceItem(count, itemAndCount.getKey()));
			}
		}
		return frequentItemSet;
	}

	public  SequenceDatabase(List<Sequence> sequencesToMine, int sequenceLength);

}