| 33 | } |
| 34 | |
| 35 | static Map<String, knucleotide> createFragmentMap(String sequence, int offset, int fragmentLength) { |
| 36 | HashMap<String, knucleotide> map = new HashMap<String, knucleotide>(); |
| 37 | int lastIndex = sequence.length() - fragmentLength + 1; |
| 38 | for (int index=offset; index<lastIndex; index+=fragmentLength) { |
| 39 | String temp = sequence.substring(index, index + fragmentLength); |
| 40 | knucleotide fragment = (knucleotide)map.get(temp); |
| 41 | if (fragment != null) |
| 42 | fragment.count++; |
| 43 | else |
| 44 | map.put(temp, new knucleotide(temp)); |
| 45 | } |
| 46 | |
| 47 | return map; |
| 48 | } |
| 49 | |
| 50 | // Destructive! |
| 51 | static Map<String, knucleotide> sumTwoMaps(Map<String, knucleotide> map1, Map<String, knucleotide> map2) { |