| 60 | } |
| 61 | |
| 62 | static String writeFrequencies(Map<String, knucleotide> frequencies) { |
| 63 | ArrayList<knucleotide> list = new ArrayList<knucleotide>(frequencies.size()); |
| 64 | int sum = 0; |
| 65 | for (knucleotide fragment : frequencies.values()) { |
| 66 | list.add(fragment); |
| 67 | sum += fragment.count; |
| 68 | } |
| 69 | |
| 70 | Collections.sort(list, new Comparator<knucleotide>() { |
| 71 | public int compare(knucleotide o1, knucleotide o2) { |
| 72 | int c = o2.count - o1.count; |
| 73 | if (c == 0) { |
| 74 | c = o1.sequence.compareTo(o2.sequence); |
| 75 | } |
| 76 | return c; |
| 77 | } |
| 78 | }); |
| 79 | |
| 80 | StringBuilder sb = new StringBuilder(); |
| 81 | for (knucleotide k : list) |
| 82 | sb.append(String.format("%s %.3f\n", k.sequence.toUpperCase(), (float)(k.count) * 100.0f / (double)sum)); |
| 83 | |
| 84 | return sb.toString(); |
| 85 | } |
| 86 | |
| 87 | static String writeCount(List<Future<Map<String, knucleotide>>> futures, String nucleotideFragment) throws Exception { |
| 88 | int count = 0; |