Here you can find the source of colorizeSequence(String cigar, String seq)
public static String colorizeSequence(String cigar, String seq)
//package com.java2s; //License from project: Apache License public class Main { public static String colorizeSequence(String cigar, String seq) { String[] letter = cigar.replaceAll("[0-9]", "").split(""); String[] nums = cigar.split("[MIDNSHPX]"); int index = 0; String htmlEmbedded = ""; for (int i = 0; i < nums.length; i++) { int tail = Integer.parseInt(nums[i]) + index; if (letter[i + 1].equals("M")) { htmlEmbedded += seq.substring(index, tail); } else { htmlEmbedded += "<span style=\"color:red;\">" + seq.substring(index, tail) + "</span>"; }/* ww w .j av a 2 s . co m*/ index += Integer.parseInt(nums[i]); } return htmlEmbedded; } }