| 199 | } |
| 200 | |
| 201 | private static String getBestPartner(HashMap<String, Interval> map, Interval source, int tolerance) { |
| 202 | String bestPartner = null; |
| 203 | int bestScore = 0; |
| 204 | |
| 205 | for (Entry<String, Interval> e : map.entrySet()) { |
| 206 | Interval merged = merge(source, e.getValue()); |
| 207 | if (merged != null) { |
| 208 | int score = (merged.end - source.end) + (source.start - merged.start); |
| 209 | if (score > bestScore && score >= tolerance) { |
| 210 | bestScore = score; |
| 211 | bestPartner = e.getKey(); |
| 212 | } |
| 213 | } |
| 214 | } |
| 215 | |
| 216 | return bestPartner; |
| 217 | } |
| 218 | |
| 219 | private static class Overlap implements Comparable<Overlap> { |
| 220 | String tName; |