public static < C extends Compound > Map < C , Integer > getComposition ( Sequence < C > sequence ) { Map < C , Integer > results = new HashMap < C , Integer > ( ) ; for ( C currentCompound : sequence ) { Integer currentInteger = results . get ( currentCompound ) ; if ( currentInteger == null ) currentInteger = 0 ; currentInteger ++ ; results . put ( currentCompound , currentInteger ) ; } return results ; }
Does a linear scan over the given Sequence and records the number of times each base appears . The returned map will return 0 if a compound is asked for and the Map has no record of it .