Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//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 class=\"warn\">" + seq.substring(index, tail) + "</span>";
            }
            index += Integer.parseInt(nums[i]);
        }
        return htmlEmbedded;
    }
}