private void addGene( Map<String, Gene> map, String gene, String chr, long start, long end, long len) { if (map.containsKey(gene)) { Gene geneObj = map.get(gene); // move start if (geneObj.getStart() > start) { geneObj.setStart(start); } // move end if (geneObj.getEnd() < end) { geneObj.setEnd(end); } // update length geneObj.setLen(geneObj.getLen() + len); } else { Gene geneObj = new Gene(gene, chr, start, end, len); map.put(gene, geneObj); } }