Proteome Informatics Group > Java Proteomic Library
 

Recipe 1.5. Merging sequences of symbols

Problem

You want to concatenate symbol sequence symbols.

Solution

// an instance of a symbol merger
SequenceSymbolMergerImpl<Integer> merger =
	SequenceSymbolMergerImpl.newInstance();

// the first sequence of card symbols
SymbolSequenceImpl<Integer> flop =
	new SymbolSequenceImpl.Builder<Integer>("A22", 
		CardRankSymbol.getSymbolType()).build();

// the second sequence
SymbolSequenceImpl<Integer> turnRiver =
	new SymbolSequenceImpl.Builder<Integer>("45",
	CardRankSymbol.getSymbolType()).build();
	
// make the concatenation
merger.process(flop, turnRiver);
Assert.assertEquals("A2245", merger.getMergedSequence().toString());

Discussion

See Also